/* Back-office. Deliberately darker and plainer than the customer app: a staff
   tool should never be mistaken for the product at a glance, least of all in a
   screenshot or a shared screen. */
:root {
  --bg: #101714;
  --panel: #172019;
  --panel-2: #1d2721;
  --line: #26332c;
  --ink: #e4ede7;
  --ink-soft: #97aca1;
  --ink-faint: #6d8177;
  --accent: #4fc08d;
  --accent-soft: #16301f;
  --warn: #e8b877;
  --danger: #f0928a;
  --info: #86b3f0;
  --radius: 8px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px; line-height: 1.5;
}
button, input, select { font: inherit; color: inherit; }
/* Author `display` beats the UA stylesheet's [hidden] { display: none }, so
   .login { display: grid } left the sign-in card sitting on top of the whole
   app after a successful login. Everything here toggles with the attribute,
   so the attribute has to win. */
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono, td.num, .id { font-family: "Cascadia Mono", Consolas, ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums; }

.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
  padding: 7px 13px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06231a; font-weight: 700; }
.btn.ghost { background: none; }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 340px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 26px; display: flex; flex-direction: column; gap: 8px;
}
.login-card h1 { font-size: 19px; margin: 0; }
.login-card .sub { margin: 0 0 12px; color: var(--ink-soft); font-size: 12.5px; }
.login-card label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); margin-top: 6px; }
.login-card input {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px;
  font-size: 16px;   /* 16px so iOS does not zoom the form on focus */
}
.login-card .btn { margin-top: 14px; }
.err { color: var(--danger); font-size: 12.5px; margin: 10px 0 0; }

/* ---------- shell ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 0 16px; height: 52px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5; flex-wrap: wrap;
}
.logo { font-weight: 700; letter-spacing: -.01em; }
.tabs { display: flex; gap: 2px; margin-inline-end: auto; flex-wrap: wrap; }
.tab {
  background: none; border: none; cursor: pointer; color: var(--ink-soft);
  padding: 8px 11px; border-radius: 6px; font-size: 13px;
}
.tab:hover { color: var(--ink); background: var(--panel-2); }
.tab.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.who { color: var(--ink-faint); font-size: 12.5px; }
main { padding: 18px 16px 60px; max-width: 1400px; margin: 0 auto; }
.loading, .empty { color: var(--ink-faint); padding: 30px 4px; }

h2 { font-size: 17px; margin: 0 0 4px; }
.page-sub { color: var(--ink-soft); font-size: 13px; margin: 0 0 14px; }

/* ---------- filters ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters input, .filters select {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; font-size: 13px;
}
.filters input { min-width: 200px; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; }
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); }
.stat .v { font-size: 23px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 3px; }
.stat.bad .v { color: var(--danger); }
.stat.warn .v { color: var(--warn); }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; min-width: 720px; }
th, td { text-align: left; padding: 9px 13px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint);
  font-weight: 500; background: var(--panel-2);
  /* top: 0, not the topbar's 52px. .tablewrap has overflow-x: auto, which makes
     IT the scroll container, so any offset here pushes the header down inside
     the box and parks it on top of the first row. */
  position: sticky; top: 0; z-index: 1;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--panel-2); }
td.wrap { white-space: normal; }

.pill {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--panel-2); color: var(--ink-soft); border: 1px solid var(--line);
}
.pill.pro { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.starter { background: #17293f; color: var(--info); border-color: transparent; }
.pill.active { color: var(--accent); }
.pill.trial, .pill.trialing { color: var(--warn); }
.pill.past_due, .pill.unpaid, .pill.canceled, .pill.expired { color: var(--danger); }
.flag {
  display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 4px;
  background: #33201f; color: var(--danger); margin-inline-end: 4px;
}
.flag.soft { background: #2f2716; color: var(--warn); }
.dim { color: var(--ink-faint); }

/* ---------- detail ---------- */
.back { margin-bottom: 12px; }
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin-bottom: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-faint); margin: 0 0 9px; font-weight: 600; }
.kv { display: flex; justify-content: space-between; gap: 14px; padding: 3px 0; font-size: 13px; }
.kv .k { color: var(--ink-soft); }
.kv .v { text-align: right; overflow-wrap: anywhere; }

/* ---------- bars ---------- */
.bars { display: flex; align-items: flex-end; gap: 2px; height: 90px; padding: 10px 0; }
.bar { flex: 1; min-width: 2px; background: var(--accent); border-radius: 2px 2px 0 0; opacity: .8; }
.bar:hover { opacity: 1; }

@media (max-width: 640px) {
  .topbar { height: auto; padding: 8px 12px; }
  th { position: static; }
  main { padding: 14px 12px 60px; }
}
