/* ============================================================
   Minimal, modern, functional. No dark theme, no gradients,
   one muted accent used sparingly. System font stack,
   hairline borders instead of shadows.
   ============================================================ */

:root {
  --bg: #FAFAF9;
  --surface: #FFFFFF;
  --border: #E4E4E7;
  --border-strong: #D4D4D8;
  --text: #18181B;
  --text-mid: #52525B;
  --text-dim: #A1A1AA;
  --accent: #3B5BA5;
  --accent-soft: #EEF1F8;
  --danger: #B3413A;
  --danger-soft: #FBEEED;
  --mono: 'SF Mono', 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Helvetica, Arial, sans-serif;
  --radius: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }

.hidden { display: none !important; }

/* ---------- Shell ---------- */
.shell { max-width: 1160px; margin: 0 auto; }
.view { min-height: 100vh; width: 100%; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
}

.wordmark { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }

.nav-tabs { display: flex; gap: 4px; }

.nav-tab {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 6px 4px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin: 0 10px;
}
.nav-tab:hover { color: var(--text); }
.nav-tab.active { color: var(--text); border-bottom-color: var(--accent); }

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  margin-left: 5px;
  border-radius: 100px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  vertical-align: middle;
}

.who {
  font-size: 13px;
  color: var(--text-mid);
  display: flex;
  align-items: center;
  gap: 14px;
}

.text-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  text-decoration: none;
}
.text-btn:hover { color: var(--text); }

.link-block {
  display: block;
  margin-top: 18px;
  text-decoration: underline;
}

/* ---------- Page padding ---------- */
.page { padding: 28px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-head h1 { font-size: 20px; font-weight: 600; margin: 0 0 4px 0; letter-spacing: -0.01em; }
.page-head p { margin: 0; color: var(--text-dim); font-size: 13px; }

/* ---------- Buttons ---------- */
.btn {
  border-radius: var(--radius);
  padding: 8px 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  white-space: nowrap;
}
.btn:hover { border-color: var(--text-dim); }

.btn-primary { background: var(--text); color: var(--surface); border-color: var(--text); }
.btn-primary:hover { background: #000; border-color: #000; }

.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Search ---------- */
.search-bar { display: flex; gap: 10px; margin-bottom: 6px; }

.search-input-wrap { flex: 1; position: relative; }
.search-input-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-dim); }

#search-input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  outline: none;
}
#search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.search-meta { color: var(--text-dim); font-size: 12.5px; margin: 10px 2px 18px 2px; }

/* ---------- Table ---------- */
.table-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }

table { width: 100%; border-collapse: collapse; }

thead th {
  text-align: left;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #FBFBFA; }

.col-id { width: 60px; font-family: var(--mono); color: var(--text-dim); font-size: 12.5px; }
.col-name { width: 24%; font-weight: 500; }
.col-info { color: var(--text-mid); }
.col-link { width: 20%; }
.col-updated { width: 130px; color: var(--text-dim); font-size: 12.5px; }

td.col-id { font-family: var(--mono); }

.name-cell { display: flex; flex-direction: column; }
.match-note { font-size: 11.5px; color: var(--accent); margin-top: 2px; }

.link-cell a {
  color: var(--text-mid);
  font-size: 12.5px;
  text-decoration: none;
  border-bottom: 1px solid var(--border-strong);
}
.link-cell a:hover { color: var(--accent); border-color: var(--accent); }

.empty-state { padding: 40px 20px; text-align: center; color: var(--text-dim); }

/* ---------- Needs review tab ---------- */
.col-reason { width: 18%; }
.col-review-actions { width: 140px; text-align: right; }

.reason-tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 100px;
  font-weight: 500;
  color: var(--danger);
  border: 1px solid #EFC9C5;
  background: var(--danger-soft);
}

.review-actions-cell { display: flex; gap: 6px; justify-content: flex-end; }
.review-actions-cell .btn { padding: 5px 10px; font-size: 12px; }

#review-tbody tr:hover { background: none; cursor: default; }

/* ---------- Pager ---------- */
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 18px; color: var(--text-dim); font-size: 12.5px; }

/* ---------- Audit ---------- */
#audit-tbody tr { cursor: default; }
#audit-tbody tr:hover { background: none; }

.audit-tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 100px;
  font-weight: 500;
  border: 1px solid var(--border-strong);
  color: var(--text-mid);
}
.audit-tag.create { color: #2C6E4F; border-color: #C8E3D4; background: #F0F9F4; }
.audit-tag.rename { color: #9A6B0D; border-color: #EFDCA8; background: #FCF6E8; }
.audit-tag.delete { color: var(--danger); border-color: #EFC9C5; background: var(--danger-soft); }
.audit-tag.update { color: var(--accent); border-color: #C7D3EA; background: var(--accent-soft); }
.audit-tag.login, .audit-tag.register { color: var(--text-dim); }

/* ---------- Backup tab ---------- */
.backup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .backup-grid { grid-template-columns: 1fr; } }

.backup-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; background: var(--surface); }
.backup-card h3 { margin: 0 0 6px 0; font-size: 14.5px; font-weight: 600; }
.backup-card p { margin: 0 0 16px 0; color: var(--text-mid); font-size: 13px; line-height: 1.55; }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(24, 24, 27, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(24,24,27,0.10);
}
.modal-wide { max-width: 540px; }

.modal h2 { margin: 0 0 18px 0; font-size: 16.5px; font-weight: 600; }

.modal-header-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.modal-header-row h2 { margin: 0; }
.modal-id { font-family: var(--mono); color: var(--text-dim); font-size: 12px; }

form label { display: block; font-size: 12.5px; color: var(--text-mid); margin-bottom: 14px; font-weight: 500; }
form label .hint { color: var(--text-dim); font-weight: 400; }

form input[type="text"], form input[type="email"], form input[type="password"], form textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  outline: none;
  background: var(--surface);
}
form input:focus, form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
form textarea { resize: vertical; font-family: var(--sans); }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

.rename-copy { color: var(--text-mid); font-size: 13.5px; line-height: 1.6; }
.rename-copy strong { color: var(--text); }

.detail-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin: 18px 0 4px 0;
  font-weight: 600;
}
.detail-label:first-of-type { margin-top: 22px; }
.detail-value { margin: 0; color: var(--text); font-size: 13.5px; word-break: break-word; }
.detail-value a { color: var(--accent); }

.alias-list { list-style: none; padding: 0; margin: 4px 0 0 0; font-size: 13px; color: var(--text-mid); }
.alias-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); }
.alias-list li:last-child { border-bottom: none; }
.alias-date { color: var(--text-dim); font-size: 12px; }
.alias-empty { color: var(--text-dim); font-style: italic; }

.form-error { color: var(--danger); font-size: 12.5px; margin: 10px 0 0 0; min-height: 14px; }

/* ---------- Login ---------- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-box { width: 100%; max-width: 340px; }
.login-box .wordmark { font-size: 17px; margin-bottom: 6px; }
.login-box .sub { color: var(--text-dim); font-size: 13px; margin: 0 0 26px 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 200;
}
.toast.error { background: var(--danger); }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .col-info, .col-link { display: none; }
  .page { padding: 18px; }
  .topbar { padding: 16px 18px; flex-wrap: wrap; gap: 10px; }
}
