:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f0eee9;
  --text: #1d1c1a;
  --muted: #6b6862;
  --line: #e2dfd8;
  --accent: #4b45c6;
  --accent-soft: #e9e8fb;
  --good: #1f7a4d;
  --good-soft: #e3f3ea;
  --warn: #9a6100;
  --warn-soft: #fbefd9;
  --bad: #b3261e;
  --bad-soft: #fbe5e3;
  /* platform colours */
  --p-github: #24292f;
  --p-cloudflare: #c2560c;
  --p-vercel: #111111;
  --p-supabase: #1b7f55;
  --p-drive: #1a66d2;
  --p-claude: #b85a35;
  --p-sites: #6a3fb5;
  --p-local: #6b6862;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151514; --surface: #1e1e1c; --surface-2: #272725; --text: #ecebe7; --muted: #a09d96; --line: #34332f;
    --accent: #9d98ff; --accent-soft: #2b2a4a; --good: #6fd19e; --good-soft: #1c3428; --warn: #f0b75c; --warn-soft: #3a2e17;
    --bad: #ff8a80; --bad-soft: #3d1f1d; --p-github: #c9d1d9; --p-vercel: #e6e6e6; --p-cloudflare: #f38020; --p-supabase: #3ecf8e;
    --p-drive: #6ea8fe; --p-claude: #e08a63; --p-sites: #b493f0; --p-local: #a09d96; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151514; --surface: #1e1e1c; --surface-2: #272725; --text: #ecebe7; --muted: #a09d96; --line: #34332f;
  --accent: #9d98ff; --accent-soft: #2b2a4a; --good: #6fd19e; --good-soft: #1c3428; --warn: #f0b75c; --warn-soft: #3a2e17;
  --bad: #ff8a80; --bad-soft: #3d1f1d; --p-github: #c9d1d9; --p-vercel: #e6e6e6; --p-cloudflare: #f38020; --p-supabase: #3ecf8e;
  --p-drive: #6ea8fe; --p-claude: #e08a63; --p-sites: #b493f0; --p-local: #a09d96; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 Inter, system-ui, sans-serif; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }

.top { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); padding: 16px 24px 0; }
.brand { display: flex; gap: 12px; align-items: center; }
.mark { color: var(--accent); font-size: 22px; }
h1 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
.sub { margin: 0; color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; margin-top: 12px; scrollbar-width: none; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; white-space: nowrap; color: var(--muted); cursor: pointer; font-weight: 500; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs .count { font-size: 11px; background: var(--surface-2); border-radius: 99px; padding: 1px 7px; margin-left: 4px; }

.view { max-width: 1240px; margin: 0 auto; padding: 24px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.toolbar h2 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.toolbar .meta { color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 14px; cursor: pointer; font-weight: 500; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #111; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #111; } }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: progress; }
input[type="search"], .field input, .field select, .field textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 10px; width: 100%;
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input[type="search"] { max-width: 280px; }
.filters select { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 10px; }

.sources { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: -4px 0 16px; font-size: 13px; color: var(--muted); }
.mode { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; border-radius: 4px; padding: 2px 6px; }
.mode.auto { background: var(--good-soft); color: var(--good); }
.mode.claude { background: var(--warn-soft); color: var(--warn); }
.mode.manual { background: var(--surface-2); color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tr.archived { opacity: .5; }
.t-title { font-weight: 600; }
.t-sub { color: var(--muted); font-size: 13px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

.status { display: inline-block; font-size: 12px; font-weight: 500; border-radius: 99px; padding: 2px 9px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.status.good { background: var(--good-soft); color: var(--good); }
.status.warn { background: var(--warn-soft); color: var(--warn); }
.status.bad { background: var(--bad-soft); color: var(--bad); }
.status.accent { background: var(--accent-soft); color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; white-space: nowrap; text-decoration: none; color: var(--text); background: var(--surface); }
.chip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.chip b { font-weight: 600; color: var(--muted); font-size: 11px; }
.chip.missing { border-style: dashed; color: var(--bad); }

/* overview */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { padding: 14px 16px; cursor: pointer; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .foot { color: var(--muted); font-size: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.panel { padding: 16px 18px; }
.panel h3 { margin: 0 0 10px; font-size: 15px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.list li:last-child { border-bottom: 0; }
.list .when { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.roles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.role { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.role .name { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.role .name i { width: 10px; height: 10px; border-radius: 3px; }
.role p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

/* dialog */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(760px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.35); }
.m-head { padding: 18px 20px 6px; }
.m-head h3 { margin: 0; font-size: 18px; }
.m-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.m-body { padding: 10px 20px; max-height: 64vh; overflow: auto; }
.m-foot { display: flex; justify-content: space-between; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field.wide { grid-column: 1 / -1; }
.field textarea { min-height: 70px; resize: vertical; }
.op { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.op:last-child { border-bottom: 0; }
.op .kind { font-size: 11px; font-weight: 700; text-transform: uppercase; }
.op .kind.add { color: var(--good); } .op .kind.update { color: var(--accent); } .op .kind.missing { color: var(--warn); }
.diff { font-size: 13px; color: var(--muted); margin-top: 3px; }
.diff del { color: var(--bad); } .diff ins { color: var(--good); text-decoration: none; }
.warnbox { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 10px; }
.note { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 13px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 20; }

@media (max-width: 760px) {
  .top { padding: 12px 16px 0; }
  .view { padding: 16px; }
  .grid2, .form-grid { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}
