/* SiteVitals — hosting & billing audit */
:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --ink: #111827;
  --ink-2: #4b5563;
  --ink-3: #6b7280;
  --line: #e5e7eb;
  --line-2: #d1d5db;
  --head: #1b1f24;
  --head-2: #262b31;
  --accent: #0b84c6;
  --accent-ink: #ffffff;
  --accent-soft: #e3f2fb;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --muted-soft: #f3f4f6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(17,24,39,.06), 0 4px 16px rgba(17,24,39,.06);
  /* flag tints (row backgrounds) + swatches */
  --flag-red: #fde2e1;     --sw-red: #dc2626;
  --flag-orange: #fdebd8;  --sw-orange: #ea7a17;
  --flag-yellow: #fef6c9;  --sw-yellow: #d4a80b;
  --flag-green: #dff3e4;   --sw-green: #16a34a;
  --flag-blue: #dcecf9;    --sw-blue: #2563eb;
  --flag-purple: #ece3fa;  --sw-purple: #7c3aed;
  --flag-gray: #e9eaec;    --sw-gray: #6b7280;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 48px; color: var(--ink-3); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── Brand ─────────────────────────────────────────────── */
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.brand b { color: var(--accent); font-weight: 700; }
.brand-mark { width: 22px; height: 22px; border-radius: 50%; border: 4px solid #e9eaec; border-top-color: var(--accent); border-right-color: var(--accent); }

/* ── Buttons & inputs ──────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:hover { background: #f9fafb; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #0973ad; }
.btn-danger { color: var(--bad); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.input, .select { height: 34px; border: 1px solid var(--line-2); border-radius: 8px; padding: 0 10px; background: var(--panel); min-width: 0; }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; }

/* ── Auth ──────────────────────────────────────────────── */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--head); }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border-radius: 14px; padding: 32px 28px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.auth-card h1 { font-size: 20px; margin: 24px 0 6px; }
.auth-card p { color: var(--ink-2); line-height: 1.5; margin: 0 0 16px; }
.auth-sub { margin: 4px 0 0 32px !important; font-size: 13px; color: var(--ink-3) !important; }
.auth-form label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.auth-form input { width: 100%; height: 40px; border: 1px solid var(--line-2); border-radius: 8px; padding: 0 12px; margin-bottom: 14px; }
.auth-form .btn, .auth-card form .btn { height: 40px; }
.auth-foot { font-size: 12px; margin-top: 18px !important; color: var(--ink-3) !important; }
.notice { padding: 10px 12px; border-radius: 8px; margin: 16px 0 0; font-size: 13px; line-height: 1.45; }
.notice-ok { background: var(--ok-soft); color: #14532d; }
.notice-info { background: var(--accent-soft); color: #0c4a6e; }
.notice-error { background: var(--bad-soft); color: #7f1d1d; }

/* ── App frame ─────────────────────────────────────────── */
.topbar { background: var(--head); color: #f3f4f6; display: flex; align-items: center; gap: 24px; padding: 0 20px; height: 56px; position: sticky; top: 0; z-index: 30; }
.topbar .brand { font-size: 18px; }
.topbar .brand-mark { border-color: #3a4048; border-top-color: var(--accent); border-right-color: var(--accent); }
.nav { display: flex; gap: 2px; height: 100%; }
.nav button { background: none; border: 0; color: #aeb4bc; padding: 0 12px; cursor: pointer; height: 100%; border-bottom: 2px solid transparent; font-weight: 500; }
.nav button:hover { color: #fff; }
.nav button[aria-current="page"] { color: #fff; border-bottom-color: var(--accent); }
.topbar .who { margin-left: auto; display: flex; align-items: center; gap: 12px; color: #aeb4bc; font-size: 13px; }
.topbar .who .btn { background: transparent; color: #e5e7eb; border-color: #3a4048; }
.main { padding: 20px; max-width: 1800px; margin: 0 auto; }

/* ── KPIs ──────────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; text-align: left; cursor: pointer; }
.kpi:hover { border-color: var(--line-2); }
.kpi[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.kpi .k-label { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.kpi .k-value { font-size: 22px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .k-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.kpi.k-bad .k-value { color: var(--bad); }
.kpi.k-warn .k-value { color: var(--warn); }

/* ── Server chips ──────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--panel); cursor: pointer; font-size: 13px; }
.chip .n { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--head); color: #fff; border-color: var(--head); }
.chip[aria-pressed="true"] .n { color: #aeb4bc; }

/* ── Toolbar ───────────────────────────────────────────── */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.toolbar .search { flex: 1 1 240px; max-width: 340px; }
.toolbar .spacer { flex: 1; }
.toolbar .select { max-width: 190px; }
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow);
  min-width: 270px; padding: 6px; z-index: 40; }
.menu-list button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.menu-list button:hover { background: var(--muted-soft); }
.menu-list small { display: block; color: var(--ink-3); font-size: 12px; }
.menu-note { font-size: 12px; color: var(--ink-3); padding: 6px 10px 4px; border-top: 1px solid var(--line); margin-top: 4px; }

.bulkbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--head); color: #fff; padding: 8px 12px; border-radius: var(--radius); margin-bottom: 10px; }
.bulkbar .select, .bulkbar .input { height: 30px; background: #fff; color: var(--ink); }
.bulkbar .btn { height: 30px; }
.bulkbar .count { font-weight: 600; margin-right: 6px; }

/* ── Table ─────────────────────────────────────────────── */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 290px); min-height: 320px; }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 1400px; }
.grid th { position: sticky; top: 0; z-index: 2; background: #f9fafb; text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-2);
  padding: 9px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; user-select: none; }
.grid th.sortable { cursor: pointer; }
.grid th.sortable:hover { color: var(--ink); }
.grid th .arrow { color: var(--accent); margin-left: 3px; }
.grid td { padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; background: var(--panel); }
/* Keep select / flag / domain visible while scrolling right to the billing columns */
.grid th:nth-child(-n+3), .grid td:nth-child(-n+3) { position: sticky; z-index: 1; }
.grid th:nth-child(-n+3) { z-index: 3; }
.grid th:nth-child(1), .grid td:nth-child(1) { left: 0; width: 34px; min-width: 34px; }
.grid th:nth-child(2), .grid td:nth-child(2) { left: 34px; width: 40px; min-width: 40px; }
.grid th:nth-child(3), .grid td:nth-child(3) { left: 74px; box-shadow: inset -1px 0 0 var(--line); }
.grid tbody tr:hover td { background-image: linear-gradient(rgba(17,24,39,.025), rgba(17,24,39,.025)); }
.grid td.c-check, .grid th.c-check { width: 34px; text-align: center; }
.grid td.c-domain { font-weight: 550; max-width: 240px; min-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.grid .domain-link { background: none; border: 0; padding: 0; color: var(--ink); cursor: pointer; font-weight: 600; text-align: left; }
.grid .domain-link:hover { color: var(--accent); text-decoration: underline; }
.grid .ext { color: var(--ink-3); text-decoration: none; margin-left: 4px; font-size: 12px; }
.grid .cell { height: 30px; border: 1px solid transparent; border-radius: 6px; background: transparent; padding: 0 6px; width: 100%; }
.grid .cell:hover { border-color: var(--line-2); background: rgba(255,255,255,.7); }
.grid .cell:focus { border-color: var(--accent); background: #fff; outline: none; }
.grid .cell.saving { border-color: #93c5fd; }
.grid .cell.saved { border-color: #86efac; }
.grid .cell.err { border-color: var(--bad); background: var(--bad-soft); }
.grid .w-client { min-width: 180px; } .grid .w-group { min-width: 160px; } .grid .w-bill { width: 82px; }
.grid .w-type { width: 140px; } .grid .w-amt { width: 96px; text-align: right; font-variant-numeric: tabular-nums; }
.grid .w-inv { width: 100px; } .grid .w-date { width: 136px; } .grid .w-notes { min-width: 200px; }
.grid td.c-paid { text-align: center; }
.grid input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.grid tr.f-red td { background: var(--flag-red); } .grid tr.f-orange td { background: var(--flag-orange); }
.grid tr.f-yellow td { background: var(--flag-yellow); } .grid tr.f-green td { background: var(--flag-green); }
.grid tr.f-blue td { background: var(--flag-blue); } .grid tr.f-purple td { background: var(--flag-purple); }
.grid tr.f-gray td { background: var(--flag-gray); color: var(--ink-2); }
.grid tr.sel td { box-shadow: inset 0 1px 0 #93c5fd, inset 0 -1px 0 #93c5fd; }
.empty { padding: 48px; text-align: center; color: var(--ink-3); }

/* flag picker */
.flag { position: relative; }
.flag-btn { width: 24px; height: 24px; border-radius: 50%; border: 1px dashed var(--line-2); background: transparent; cursor: pointer; display: block; }
.flag-btn.has { border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.12); }
.sw-red { background: var(--sw-red); } .sw-orange { background: var(--sw-orange); } .sw-yellow { background: var(--sw-yellow); }
.sw-green { background: var(--sw-green); } .sw-blue { background: var(--sw-blue); } .sw-purple { background: var(--sw-purple); } .sw-gray { background: var(--sw-gray); }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; margin-right: 6px; }
.dot-none { border: 1px dashed var(--ink-3); }
.flag-pop { position: absolute; left: 0; top: 28px; z-index: 20; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; min-width: 210px; }
.flag-pop button { display: flex; align-items: center; width: 100%; background: none; border: 0; padding: 7px 8px; border-radius: 6px; cursor: pointer; text-align: left; }
.flag-pop button:hover { background: var(--muted-soft); }

/* status badges */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.b-ours { background: var(--accent-soft); color: #075985; }
.b-cf { background: var(--warn-soft); color: #92400e; }
.b-moved { background: var(--bad-soft); color: #991b1b; }
.b-confirmed { background: #e5e7eb; color: #374151; }
.status-cell { display: flex; align-items: center; gap: 6px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: 12px; font-weight: 600; }
.link-btn:hover { text-decoration: underline; }

/* ── Drawer ────────────────────────────────────────────── */
.drawer-bg { position: fixed; inset: 0; background: rgba(17,24,39,.35); z-index: 50; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--panel); z-index: 51; overflow-y: auto; box-shadow: -10px 0 40px rgba(0,0,0,.15); }
.drawer header { position: sticky; top: 0; background: var(--panel); padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; gap: 12px; z-index: 2; }
.drawer header h2 { margin: 0; font-size: 18px; word-break: break-all; }
.drawer header .sub { color: var(--ink-3); font-size: 13px; margin-top: 2px; }
.drawer header .close { margin-left: auto; }
.drawer section { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; word-break: break-word; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); font-weight: 600; }
.form-grid .full { grid-column: 1 / -1; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.timeline li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.timeline .when { color: var(--ink-3); font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--ink-3); }

/* ── Panels (servers / settings / users / activity) ────── */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 4px; font-size: 16px; }
.panel > p { margin: 0 0 14px; color: var(--ink-2); line-height: 1.5; }
.plain { width: 100%; border-collapse: collapse; font-size: 13px; }
.plain th { text-align: left; font-size: 12px; color: var(--ink-3); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); }
.plain td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.plain td.num, .plain th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.color-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.color-row .input { width: 240px; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; }
.feed-url { width: 100%; }

/* ── Toast / progress ──────────────────────────────────── */
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--head); color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; max-width: min(640px, calc(100vw - 32px)); display: flex; gap: 12px; align-items: center; }
.toast.err { background: var(--bad); }
.toast .btn { height: 26px; background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }
.progress { width: 160px; height: 6px; background: rgba(255,255,255,.2); border-radius: 3px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); }

@media (max-width: 760px) {
  .topbar { gap: 12px; padding: 0 12px; overflow-x: auto; }
  .topbar .who span { display: none; }
  .main { padding: 12px 16px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .toolbar .search { max-width: none; flex-basis: 100%; }
  .table-wrap { max-height: none; }
  .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
}
