/* IDC Billing — Stripe + Linear inspired design system.
   See DESIGN.md. Theme files (forest/midnight/ocean) override the core
   variables below, so the contract --bg/--card/--ink/--muted/--line/
   --brand/--brand-d/--ok/--warn/--bad must stay intact. New tokens are
   additive and keep their default here across all themes. */
:root {
  --bg: #f6f9fc;          /* canvas-soft */
  --card: #ffffff;        /* canvas */
  --ink: #0d253d;         /* deep navy — body text, never pure black */
  --ink-2: #273951;       /* secondary text */
  --muted: #64748d;       /* helper / caption / table labels */
  --line: #e3e8ee;        /* hairline */
  --line-input: #cdd8e6;  /* cooler input hairline */
  --brand: #533afd;       /* indigo primary — CTAs & links only */
  --brand-d: #4434d4;     /* primary-deep — hover */
  --press: #2e2b8c;       /* primary-press */
  --navy: #1c1e54;        /* brand-dark-900 — app shell */
  --ok: #1a8245;
  --warn: #b45309;
  --bad: #d4314e;
  --radius: 12px;
  --ring: 0 0 0 3px rgba(83, 58, 253, .18);
  --shadow-1: 0 1px 3px rgba(13, 37, 61, .07), 0 1px 2px rgba(13, 37, 61, .04);
  --shadow-2: 0 8px 24px rgba(13, 37, 61, .10), 0 2px 6px rgba(13, 37, 61, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, "SF Pro Display", "Segoe UI", Roboto,
    "PingFang SC", "Microsoft YaHei", sans-serif;
  font-feature-settings: "ss01";
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: rgba(83, 58, 253, .16); }

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-d); text-decoration: underline; }

/* Display tier — thin weight + negative tracking is the brand signature. */
h1, h2, h3, h4 { font-weight: 300; color: var(--ink); margin: 0 0 14px; }
h1 { font-size: 27px; letter-spacing: -.5px; line-height: 1.15; }
h2 { font-size: 20px; letter-spacing: -.2px; margin-bottom: 12px; }
h3 { font-size: 16px; letter-spacing: -.1px; margin-bottom: 8px; font-weight: 400; }
h4 { font-size: 13px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase;
  color: var(--muted); margin: 18px 0 8px; }

code, pre, .mono {
  font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
code { background: #eef1f6; padding: 2px 6px; border-radius: 5px; font-size: .9em; }
pre { background: #0d253d; color: #e8edf5; padding: 14px 16px; border-radius: 10px;
  overflow: auto; font-size: 13px; line-height: 1.5; }
pre code { background: none; padding: 0; color: inherit; }

/* ---------- Top bar (public) ---------- */
.topbar {
  background: var(--navy); color: #fff; padding: 0 24px;
  display: flex; align-items: center; height: 58px; gap: 22px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .15);
}
.topbar .brand { font-weight: 600; font-size: 16px; color: #fff; letter-spacing: -.2px; }
.topbar nav { display: flex; gap: 18px; flex: 1; flex-wrap: wrap; }
.topbar nav a { color: #c3c8e6; font-size: 13px; }
.topbar nav a:hover { color: #fff; text-decoration: none; }
.topbar .right { display: flex; gap: 14px; align-items: center; }
.topbar .right a { color: #c3c8e6; font-size: 13px; }
.topbar .right a:hover { color: #fff; text-decoration: none; }

.wrap { max-width: 1080px; margin: 28px auto; padding: 0 24px; }
.wrap-wide { max-width: 1280px; }

/* ---------- Admin shell ---------- */
.admin-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 222px; flex-shrink: 0; padding: 14px 0;
  background: linear-gradient(180deg, #1c1e54 0%, #141537 100%);
  color: #aeb4d6;
  position: sticky; top: 0; align-self: flex-start; height: 100vh; overflow-y: auto;
}
.sidebar .logo {
  color: #fff; font-weight: 600; padding: 6px 20px 16px; font-size: 15px;
  letter-spacing: -.2px; display: flex; align-items: center; gap: 9px;
}
.sidebar .logo::before {
  content: ""; width: 9px; height: 9px; border-radius: 3px;
  background: var(--brand); box-shadow: 0 0 0 3px rgba(83, 58, 253, .25);
}
.sidebar a {
  display: block; padding: 8px 20px; color: #aeb4d6; font-size: 13px;
  border-left: 3px solid transparent; transition: background .12s, color .12s;
}
.sidebar a:hover { background: rgba(255, 255, 255, .05); color: #fff; text-decoration: none; }
.sidebar a.active {
  background: rgba(83, 58, 253, .20); color: #fff; border-left-color: var(--brand);
}
.admin-main { flex: 1; padding: 28px 34px; min-width: 0; }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow-1);
}
.grid { display: grid; gap: 16px; }
.grid-1 { grid-template-columns: 1fr; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---------- Stat / KPI tiles ---------- */
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-1);
}
.stat .n {
  font-size: 28px; font-weight: 300; letter-spacing: -.5px; color: var(--ink);
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.stat .l {
  color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; font-weight: 600; margin-top: 4px;
}

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); }
th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600;
}
td { font-size: 14px; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td, .table-card tr:hover td { background: #f7f9fc; }
.table-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-1);
}
.table-card table { margin: 0; }
.table-card th, .table-card td { padding-left: 18px; padding-right: 18px; }
.table-card .hd {
  padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 500;
  font-size: 15px; letter-spacing: -.1px;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .01em; line-height: 1.5;
}
.badge.ok { background: #e3f6ea; color: #137a3e; }
.badge.warn { background: #fdf0d9; color: #9a5b09; }
.badge.bad { background: #fde4e8; color: #be2741; }
.badge.muted { background: #eceef3; color: #54627a; }

/* ---------- Forms ---------- */
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 5px; font-weight: 600; }
input, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-input); border-radius: 6px;
  font-size: 14px; font-family: inherit; color: var(--ink); background: #fff;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: var(--ring);
}
input::placeholder, textarea::placeholder { color: #9aa6b8; }
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.form-row { display: flex; gap: 14px; }
.form-row > div { flex: 1; }
@media (max-width: 640px) { .form-row { flex-direction: column; gap: 0; } }

/* ---------- Buttons — tight pills are the brand ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 999px; border: 1px solid var(--brand);
  background: var(--brand); color: #fff; font-size: 14px; font-weight: 500;
  font-family: inherit; line-height: 1; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--brand-d); border-color: var(--brand-d); color: #fff; text-decoration: none; }
.btn:active { background: var(--press); border-color: var(--press); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn.ghost { background: #fff; color: var(--brand); }
.btn.ghost:hover { background: #f4f3ff; color: var(--brand-d); }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: #b9293f; border-color: #b9293f; }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.ok:hover { background: #146b38; border-color: #146b38; }
.btn.muted { background: #fff; color: var(--ink-2); border-color: var(--line-input); }
.btn.muted:hover { background: #f3f5f9; color: var(--ink); }
.btn.sm { padding: 5px 12px; font-size: 12.5px; }

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.right { text-align: right; }
.flash {
  padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13.5px;
  border: 1px solid transparent; box-shadow: var(--shadow-1);
}
.flash.ok { background: #e8f7ee; color: #136636; border-color: #c5ebd3; }
.flash.err { background: #fdeaed; color: #97233a; border-color: #f6ccd4; }
.price {
  font-size: 26px; font-weight: 300; letter-spacing: -.6px; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.price small { font-size: 13px; color: var(--muted); font-weight: 400; letter-spacing: 0; }

/* Hero — atmospheric gradient-mesh panel (white text). */
.hero {
  position: relative; overflow: hidden; color: #fff; border: none;
  border-radius: 16px; padding: 52px 40px; margin-bottom: 20px;
  background:
    radial-gradient(60% 120% at 14% 8%, rgba(249, 107, 238, .42), transparent 60%),
    radial-gradient(46% 100% at 88% 0%, rgba(234, 34, 97, .38), transparent 56%),
    radial-gradient(90% 150% at 50% 130%, rgba(83, 58, 253, .55), transparent 62%),
    linear-gradient(135deg, #1c1e54 0%, #2e2b8c 55%, #533afd 100%);
  box-shadow: var(--shadow-2);
}
.hero h1 { color: #fff; font-size: 34px; letter-spacing: -.8px; margin-bottom: 10px; }
.hero p { color: rgba(255, 255, 255, .88); font-size: 16px; margin: 0 0 20px; max-width: 60ch; }
.hero .btn.ghost { background: #fff; color: var(--press); border-color: #fff; }
.hero .btn.ghost:hover { background: #eef0ff; color: var(--press); }

.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.pagehead h1 { margin: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chips a {
  display: inline-block; padding: 5px 14px; border: 1px solid var(--line); border-radius: 999px;
  font-size: 12.5px; background: #fff; color: var(--muted); transition: all .12s;
}
.chips a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.chips a.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.chips a.active:hover { color: #fff; }

.msg-list .msg { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; box-shadow: var(--shadow-1); }
.msg-list .msg .mh { background: #f6f8fb; padding: 9px 16px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
.msg-list .msg .mh.staff { background: #f1f0ff; color: var(--press); }
.msg-list .msg .mb { padding: 16px; }

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

/* ---------- Responsive shell ---------- */
@media (max-width: 760px) {
  .admin-shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static; display: flex; flex-wrap: wrap;
    gap: 2px; padding: 10px;
  }
  .sidebar .logo { width: 100%; }
  .sidebar a { border-left: none; border-radius: 6px; padding: 6px 10px; }
  .sidebar a.active { border-left: none; }
  .admin-main { padding: 18px; }
  .topbar { height: auto; padding: 10px 16px; flex-wrap: wrap; }
}
