/* Shared styles for the admin pages (login + root dashboard) */

@font-face {
  font-family: "MazdaType";
  src: url("/assets/MazdaType-Regular-Cuf1ZeB9.woff2") format("woff2");
  font-weight: 400;
}
@font-face {
  font-family: "MazdaType";
  src: url("/assets/MazdaType-Medium-BL-dseJr.woff2") format("woff2");
  font-weight: 500;
}
@font-face {
  font-family: "MazdaType";
  src: url("/assets/MazdaType-Bold-laXp4szL.woff2") format("woff2");
  font-weight: 700;
}

:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #f8f8f7;
  --text: #191919;
  --muted: #6b6b6b;
  --border: #e3e3e0;
  --ink: #101010;
  --accent: #9b1c22;
  --accent-hover: #7f161b;
  --ok: #1d7a46;
  --ok-bg: #e6f4ec;
  --warn: #9a5b00;
  --warn-bg: #fdf1dc;
  --bad: #b3261e;
  --bad-bg: #fbe9e7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

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

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }

/* ---- Brand ---- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 8px; padding: 6px;
  background: #000; border: 1px solid rgba(255, 255, 255, 0.12);
  display: grid; place-items: center; flex-shrink: 0;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-title { font-weight: 700; font-size: 16px; }
.brand-sub { color: var(--muted); font-size: 12px; }

/* ---- Buttons & fields ---- */
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; font-weight: 500;
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: rgba(255, 255, 255, 0.25); color: #fff; }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.08); }
.btn-block { width: 100%; justify-content: center; padding: 10px 14px; }

.field { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
.field input, .input {
  font: inherit; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); color: var(--text);
}
.field input:focus, .input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

.alert { margin: 0; padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.alert-error { background: var(--bad-bg); color: var(--bad); }

/* ---- Login ---- */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--ink); }
.login-card {
  width: 100%; max-width: 360px; background: var(--surface);
  border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}
.login-card .brand { margin-bottom: 4px; }

/* ---- Dashboard layout ---- */
.topbar {
  background: var(--ink); color: #fff;
  padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar .brand-sub { color: rgba(255, 255, 255, 0.6); }
.page { max-width: 1200px; margin: 0 auto; padding: 24px 16px 48px; display: flex; flex-direction: column; gap: 24px; }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head p { margin: 2px 0 0; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }

/* ---- Sync cards ---- */
.sync-card { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.sync-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.badge { font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-neutral { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

.issues { display: flex; flex-direction: column; gap: 6px; }
.issue {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid transparent;
  cursor: pointer; font: inherit; color: inherit; text-align: left; width: 100%;
}
.issue:hover { border-color: var(--border); }
.issue[aria-expanded="true"] { border-color: var(--accent); }
.issue-count { font-weight: 700; font-variant-numeric: tabular-nums; }
.issue-count.bad { color: var(--bad); }
.issue-count.ok { color: var(--ok); }

.detail { margin-top: 4px; }
.detail-note { color: var(--muted); font-size: 12px; margin: 6px 2px; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: top; }
th { background: var(--surface-2); font-weight: 500; color: var(--muted); position: sticky; top: 0; }
tr:last-child td { border-bottom: none; }
tr.row-out-of-sync td { background: var(--bad-bg); }
td.wrap { white-space: normal; min-width: 220px; }
td.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.diff-db { color: var(--bad); }
.diff-hs { color: var(--ok); }
.null { color: #b0b0ad; }
a { color: var(--accent); }

.tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 3px; }
.tab { border: 0; background: transparent; font: inherit; font-weight: 500; padding: 6px 14px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar .input { min-width: 240px; flex: 1; max-width: 360px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); }

.btn-small { padding: 3px 10px; font-size: 12px; }
.btn-done { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-bg); }
.btn-pair { display: inline-flex; gap: 6px; }
.toolbar-actions { display: flex; gap: 8px; }
.sync-progress { margin-bottom: 16px; }
.ok-text { color: var(--ok); }
.bad-text { color: var(--bad); }

.muted { color: var(--muted); }
.loading { color: var(--muted); padding: 24px; text-align: center; }

/* ---- Backup ---- */
.backup-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.backup-row + .backup-row { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.backup-row .label { min-width: 140px; font-weight: 500; }
.status-msg { font-size: 13px; }
.status-msg.ok { color: var(--ok); }
.status-msg.bad { color: var(--bad); }

/* ---- Docs ---- */
.topnav { display: flex; gap: 8px; }
.docs section { scroll-margin-top: 16px; }
.docs h2 { margin-bottom: 10px; }
.docs .sub { font-size: 15px; margin: 18px 0 8px; }
.docs > section > p.muted { margin: -4px 0 10px; }
.toc { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }
.toc a { text-decoration: none; }
.kv { width: 100%; }
.kv th { background: transparent; color: var(--muted); width: 220px; position: static; white-space: normal; }
.kv td { white-space: normal; }
.risk-list p { margin: 0 0 10px; display: flex; gap: 10px; align-items: baseline; }
.risk-list .badge { flex-shrink: 0; }

@media (max-width: 600px) {
  .kv th { width: 120px; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stat-value { font-size: 18px; }
  .topbar { padding: 12px 16px; }
}
