:root {
  --bg: #f5f6fa;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --ok: #16a34a;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.2px;
}

.brand span { color: var(--accent); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

nav.top-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

nav.top-nav a {
  padding: 7px 13px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

nav.top-nav a:hover {
  background: var(--bg);
  color: var(--text);
}

nav.top-nav a.active {
  background: #eef2ff;
  color: var(--accent);
}

.header-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
}

.header-meta {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}

main {
  max-width: 1000px;
  margin: 28px auto;
  padding: 0 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
}

.card h2 {
  margin: 0 0 4px;
  font-size: 17px;
}

.card .hint {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13.5px;
}

.center-card {
  max-width: 380px;
  margin: 12vh auto;
}

/* Forms */
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 12px 0 5px;
  color: var(--text);
}

input[type="text"],
input[type="password"],
input[type="file"],
select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14.5px;
  background: #fff;
  color: var(--text);
}

input:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.row > * { flex: 1; min-width: 160px; }
.row > .actions { flex: 0 0 auto; min-width: 0; }

/* Buttons */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: background 0.15s;
  text-decoration: none;
}

button:hover, .btn:hover { background: var(--accent-hover); }

button.secondary, .btn.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

button.secondary:hover, .btn.secondary:hover { background: var(--bg); }

button.danger {
  background: #fff;
  color: var(--danger);
  border-color: #fecaca;
}

button.danger:hover { background: var(--danger-bg); }

button.small, .btn.small {
  padding: 5px 11px;
  font-size: 12.5px;
  border-radius: 7px;
}

button:disabled { opacity: 0.55; cursor: not-allowed; }

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
  white-space: nowrap;
}

td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tbody tr:hover { background: #fafbff; }

.mono {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
}

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

.empty {
  color: var(--muted);
  text-align: center;
  padding: 26px 0;
  font-size: 14px;
}

.link-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 320px;
}

.link-cell .mono {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.link-cell button {
  flex-shrink: 0;
}

td.name-cell {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #eef2ff;
  color: var(--accent);
}

.badge.gray { background: #f3f4f6; color: var(--muted); }

.note-input {
  width: 100%;
  min-width: 150px;
  padding: 6px 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 13.5px;
  background: transparent;
  color: var(--text);
}

.note-input:hover { border-color: var(--border); background: #fff; }

.note-input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

.note-input::placeholder { color: #b6bcc8; }

/* Upload area */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 30px 20px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: #eef2ff;
  color: var(--accent);
}

.dropzone strong { color: inherit; }

.progress {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 14px;
  display: none;
}

.progress .bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.15s;
}

/* Messages */
.message {
  padding: 10px 13px;
  border-radius: 8px;
  font-size: 13.5px;
  margin: 12px 0 0;
  display: none;
}

.message.error { display: block; background: var(--danger-bg); color: var(--danger); }
.message.success { display: block; background: #f0fdf4; color: var(--ok); }

.result {
  display: none;
  margin-top: 16px;
  padding: 16px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
}

.result.visible { display: block; }

.result .url-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
}

.result .url-row input { flex: 1; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }

.radio-group {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.radio-group label {
  flex: 1;
  margin: 0;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}

.radio-group input { display: none; }

.radio-group label:has(input:checked) {
  border-color: var(--accent);
  background: #eef2ff;
  color: var(--accent);
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  padding: 20px;
}