/* Lite CRM console — dark editorial dashboard. Brand-continuous with lite.work:
   warm-black + ember, Fraunces display / Hanken Grotesk body, hairlines not shadows.
   Density is intentional (this is a dashboard) but the editorial grammar holds. */

:root {
  --void: #14110e;        /* app background */
  --void-2: #1a1610;      /* raised panel */
  --void-3: #201b14;      /* hover / input */
  --ink: #f3eee4;
  --ink-dim: rgba(243, 238, 228, 0.62);
  --ink-faint: rgba(243, 238, 228, 0.40);
  --ember: #f0703f;
  --ember-soft: rgba(240, 112, 63, 0.14);
  --line: rgba(243, 238, 228, 0.12);
  --line-strong: rgba(243, 238, 228, 0.24);
  --green: #7fb06b;       /* approved / positive */
  --red: #d9694f;         /* declined / negative (ember-adjacent, not fire-engine) */
  --amber: #d6a24e;       /* past-due / warning */
  --font-serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-sans: 'Hanken Grotesk', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --sidebar-w: 236px;
  --radius: 3px;          /* the ONE small radius; pills use 999px */
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--void);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'ss01';
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
h1, h2, h3 { font-family: var(--font-serif); font-weight: 400; letter-spacing: -0.01em; margin: 0; }

/* Editorial eyebrow/label */
.kicker {
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 500;
}
.num { font-variant-numeric: tabular-nums; }

/* ---------- Focus + motion ---------- */
:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; border-radius: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ============ Auth screen ============ */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(120% 90% at 50% -10%, #1c1712 0%, var(--void) 60%);
}
.auth-card { width: 100%; max-width: 380px; }
.auth-brand { text-align: center; margin-bottom: 40px; }
.auth-brand .mark { font-family: var(--font-serif); font-size: 30px; letter-spacing: -0.02em; }
.auth-brand .mark b { color: var(--ember); font-weight: 400; }
.auth-brand .welcome { margin-top: 14px; font-size: 13px; color: var(--ink-dim); }
.auth-brand .co { font-family: var(--font-serif); font-size: 20px; display: block; margin-top: 2px; }

/* ============ App shell ============ */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  border-right: 1px solid var(--line); padding: 24px 0; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px; overflow-y: auto;
}
.sidebar .brand { padding: 4px 24px 22px; }
.sidebar .brand .mark { font-family: var(--font-serif); font-size: 21px; letter-spacing: -0.02em; }
.sidebar .brand .mark b { color: var(--ember); font-weight: 400; }
.sidebar .brand .co { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint); margin-top: 6px; }
.navlink {
  display: flex; align-items: center; gap: 10px; padding: 9px 24px; color: var(--ink-dim);
  font-size: 13px; border-left: 2px solid transparent; transition: color 0.18s var(--ease), background 0.18s var(--ease);
}
.navlink:hover { color: var(--ink); background: rgba(243, 238, 228, 0.03); }
.navlink.active { color: var(--ink); border-left-color: var(--ember); background: var(--ember-soft); }
.navlink .dot { width: 5px; height: 5px; border-radius: 999px; background: currentColor; opacity: 0.5; }
.nav-group { margin-top: 18px; padding: 0 24px 8px; }
.sidebar .spacer { flex: 1; }
.sidebar .signout { margin-top: 8px; }

.main { min-width: 0; }
.topbar {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 32px 40px 20px; border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 30px; }
.topbar .sub { color: var(--ink-faint); font-size: 12px; margin-top: 4px; }
.content { padding: 32px 40px 80px; max-width: 1180px; }

/* ============ KPI row ============ */
/* minmax(0,1fr) lets tracks shrink below the big figures' width instead of overflowing. */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.kpi { background: var(--void); padding: 22px 22px 24px; }
.kpi .label { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint); }
.kpi .value { font-family: var(--font-serif); font-size: 34px; margin-top: 12px; letter-spacing: -0.02em; }
.kpi .value.pos { color: var(--ember); }
.kpi .foot { font-size: 12px; color: var(--ink-dim); margin-top: 6px; }

/* ============ Panels + tables ============ */
.panel { border: 1px solid var(--line); margin-top: 28px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 18px; }
.panel-body { padding: 4px 0; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-weight: 500; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-faint); padding: 12px 20px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 13px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.15s var(--ease); }
tbody tr:hover { background: rgba(243, 238, 228, 0.025); }
td.right, th.right { text-align: right; }
td.mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-dim); }
.faint { color: var(--ink-faint); }

/* ============ Status pills ============ */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; letter-spacing: 0.04em; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line-strong); text-transform: uppercase; }
.pill::before { content: ''; width: 5px; height: 5px; border-radius: 999px; background: currentColor; }
.pill.ok, .pill.paid, .pill.active, .pill.approved, .pill.delivered { color: var(--green); border-color: rgba(127, 176, 107, 0.3); }
.pill.warn, .pill.past_due, .pill.trial, .pill.pending, .pill.partially_refunded, .pill.exported, .pill.shipped { color: var(--amber); border-color: rgba(214, 162, 78, 0.3); }
.pill.bad, .pill.declined, .pill.error, .pill.expired, .pill.canceled, .pill.refunded { color: var(--red); border-color: rgba(217, 105, 79, 0.3); }
.pill.neutral, .pill.paused { color: var(--ink-dim); }

/* ============ Buttons + forms ============ */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: transparent; color: var(--ink); font-size: 13px;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease), color 0.18s var(--ease);
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--ember); border-color: var(--ember); color: #1a0f0a; font-weight: 500; }
.btn.primary:hover { background: #f47f52; border-color: #f47f52; }
.btn.ghost { border-color: transparent; color: var(--ink-dim); padding: 6px 10px; }
.btn.ghost:hover { color: var(--ink); background: var(--void-3); }
.btn.sm { padding: 5px 11px; font-size: 12px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.danger:hover { border-color: var(--red); color: var(--red); }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 7px; }
.input, select.input, textarea.input {
  width: 100%; background: var(--void-3); border: 1px solid var(--line); color: var(--ink);
  padding: 10px 12px; border-radius: var(--radius); font-family: inherit; font-size: 14px; transition: border-color 0.18s var(--ease);
}
.input:focus { border-color: var(--ember); outline: none; }
.input::placeholder { color: var(--ink-faint); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row .field { flex: 1; min-width: 160px; margin-bottom: 0; }

/* ============ Toolbar / filters ============ */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { background: transparent; border: none; color: var(--ink-dim); padding: 7px 13px; font-size: 12px; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: none; }
.seg button.on { background: var(--ember-soft); color: var(--ink); }

/* ============ States ============ */
.empty { text-align: center; padding: 64px 24px; color: var(--ink-faint); }
.empty .big { font-family: var(--font-serif); font-size: 22px; color: var(--ink-dim); margin-bottom: 8px; }
.skel { height: 13px; background: linear-gradient(90deg, var(--void-2), var(--void-3), var(--void-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 2px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--void-2); border: 1px solid var(--line-strong); padding: 12px 20px; border-radius: var(--radius); font-size: 13px; z-index: 60; animation: rise 0.25s var(--ease); }
.toast.err { border-color: rgba(217, 105, 79, 0.5); }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============ Modal ============ */
.scrim { position: fixed; inset: 0; background: rgba(10, 8, 6, 0.7); display: grid; place-items: center; padding: 24px; z-index: 50; animation: fade 0.2s var(--ease); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--void-2); border: 1px solid var(--line-strong); border-radius: var(--radius); width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 20px; }
.modal-body { padding: 24px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* ============ Detail grid ============ */
.dl { display: grid; grid-template-columns: 130px 1fr; gap: 10px 20px; font-size: 13px; }
.dl dt { color: var(--ink-faint); }
.dl dd { margin: 0; }

/* ============ Responsive ============ */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; overflow-x: auto; align-items: center; padding: 12px 8px; }
  .sidebar .brand, .sidebar .nav-group, .sidebar .spacer { display: none; }
  .navlink { border-left: none; border-bottom: 2px solid transparent; padding: 8px 12px; white-space: nowrap; }
  .navlink.active { border-left: none; border-bottom-color: var(--ember); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .value { font-size: 27px; }
  .topbar, .content { padding-left: 20px; padding-right: 20px; }
  .content { overflow-x: auto; }
}
@media (max-width: 460px) { .kpis { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) { .dashsplit { grid-template-columns: 1fr !important; } }
