/* ============================================================
   zenno license — design system
   Dark-first command center. One accent, semantic status colors,
   mono for data, grotesque for chrome. No inline styles anywhere.
   ============================================================ */

:root {
  /* Palette — dark (default) */
  --bg: #0a0d13;
  --bg-raised: #10141d;
  --bg-hover: #161b27;
  --bg-inset: #070a0f;
  --border: #1d2432;
  --border-strong: #2a3346;
  --text: #e7ebf2;
  --text-dim: #9aa4b8;
  --text-faint: #5f6a80;

  /* Brand accent */
  --accent: #6e79f4;
  --accent-hover: #8890f7;
  --accent-soft: rgba(110, 121, 244, 0.14);

  /* Semantic status colors */
  --st-active: #2fbf71;
  --st-trial: #3d9df6;
  --st-readonly: #e6a23c;
  --st-suspended: #e5484d;
  --st-free: #c15df3;
  --st-archived: #667085;

  --ok: var(--st-active);
  --warn: var(--st-readonly);
  --danger: var(--st-suspended);

  /* Typography */
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "JetBrains Mono", "SF Mono", Consolas, "Liberation Mono", monospace;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.35);
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

[data-theme="light"] {
  --bg: #f4f5f8;
  --bg-raised: #ffffff;
  --bg-hover: #f0f2f6;
  --bg-inset: #e9ebf1;
  --border: #dfe3ea;
  --border-strong: #c9cfda;
  --text: #171c26;
  --text-dim: #4e586c;
  --text-faint: #8b94a7;
  --accent-soft: rgba(110, 121, 244, 0.12);
  --shadow-pop: 0 8px 24px rgba(20, 30, 60, 0.12);
}

/* ---------- Reset / base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

h1, h2, h3 { font-weight: 650; letter-spacing: -0.02em; margin: 0 0 0.5rem; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.92rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }

.mono, code, pre { font-family: var(--font-mono); font-size: 0.93em; }
.muted { color: var(--text-faint); }
.dim { color: var(--text-dim); }
.nowrap { white-space: nowrap; }

::selection { background: var(--accent-soft); }

:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }

/* ---------- Layout ---------- */

.shell { max-width: 1180px; margin: 0 auto; padding: 0 20px 64px; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.topbar__inner {
  max-width: 1180px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 20px; height: 54px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.brand:hover { color: var(--text); }
.brand__dot { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.brand__muted { color: var(--text-faint); font-weight: 500; }

.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: var(--text-dim); padding: 6px 11px; border-radius: var(--radius-sm);
  font-weight: 500; white-space: nowrap;
}
.nav a:hover { color: var(--text); background: var(--bg-hover); }
.nav a.is-active { color: var(--text); background: var(--bg-hover); }

.topbar__actions { display: flex; align-items: center; gap: 8px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head__sub { color: var(--text-faint); margin-top: 2px; }

/* ---------- Cards ---------- */

.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card--flush { padding: 0; overflow: hidden; }
.card__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.card--flush .card__head { padding: 14px 20px 0; }

.grid { display: grid; gap: 18px; }
.grid--2 { grid-template-columns: 1fr 1fr; }
.grid--sidebar { grid-template-columns: 2fr 1fr; align-items: start; }
@media (max-width: 860px) {
  .grid--2, .grid--sidebar { grid-template-columns: 1fr; }
}

/* ---------- Stat tiles (dashboard headline numbers) ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat {
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px;
}
.stat__label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); font-weight: 600; }
.stat__value { font-family: var(--font-mono); font-size: 1.7rem; font-weight: 600; letter-spacing: -0.03em; margin-top: 2px; line-height: 1.15; }
.stat__value small { font-size: 0.9rem; color: var(--text-faint); font-weight: 500; }
.stat--accent .stat__value { color: var(--accent); }
.stat--ok .stat__value { color: var(--st-active); }
.stat--warn .stat__value { color: var(--st-readonly); }
.stat--danger .stat__value { color: var(--st-suspended); }

/* ---------- Status badges ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  padding: 2px 9px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--active    { color: var(--st-active);    background: color-mix(in srgb, var(--st-active) 12%, transparent);    border-color: color-mix(in srgb, var(--st-active) 35%, transparent); }
.badge--trial     { color: var(--st-trial);     background: color-mix(in srgb, var(--st-trial) 12%, transparent);     border-color: color-mix(in srgb, var(--st-trial) 35%, transparent); }
.badge--readonly  { color: var(--st-readonly);  background: color-mix(in srgb, var(--st-readonly) 12%, transparent);  border-color: color-mix(in srgb, var(--st-readonly) 35%, transparent); }
.badge--suspended { color: var(--st-suspended); background: color-mix(in srgb, var(--st-suspended) 12%, transparent); border-color: color-mix(in srgb, var(--st-suspended) 35%, transparent); }
.badge--free      { color: var(--st-free);      background: color-mix(in srgb, var(--st-free) 12%, transparent);      border-color: color-mix(in srgb, var(--st-free) 35%, transparent); }
.badge--archived  { color: var(--st-archived);  background: color-mix(in srgb, var(--st-archived) 12%, transparent);  border-color: color-mix(in srgb, var(--st-archived) 35%, transparent); }

/* Small informational chips (deadlines, job statuses) */
.chip {
  display: inline-block; font-family: var(--font-mono); font-size: 0.7rem; font-weight: 600;
  padding: 1px 7px; border-radius: 999px; white-space: nowrap;
}
.chip--ok     { color: var(--st-active); background: color-mix(in srgb, var(--st-active) 12%, transparent); }
.chip--warn   { color: var(--st-readonly); background: color-mix(in srgb, var(--st-readonly) 14%, transparent); }
.chip--danger { color: var(--st-suspended); background: color-mix(in srgb, var(--st-suspended) 14%, transparent); }
.chip--job-queued  { color: var(--st-trial); background: color-mix(in srgb, var(--st-trial) 12%, transparent); }
.chip--job-running { color: var(--st-readonly); background: color-mix(in srgb, var(--st-readonly) 14%, transparent); }
.chip--job-done    { color: var(--st-active); background: color-mix(in srgb, var(--st-active) 12%, transparent); }
.chip--job-failed  { color: var(--st-suspended); background: color-mix(in srgb, var(--st-suspended) 14%, transparent); }

/* ---------- Heartbeat pulse ---------- */

.pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: baseline; }
.pulse--live { background: var(--st-active); animation: pulse-soft 2.4s ease-in-out infinite; }
.pulse--dead { background: var(--st-suspended); }
.pulse--none { background: var(--border-strong); }

@keyframes pulse-soft {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--st-active) 45%, transparent); }
  50%      { box-shadow: 0 0 0 5px transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .pulse--live { animation: none; }
}

/* ---------- Disk bars ---------- */

.disk { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.disk__bar { flex: 0 0 64px; height: 5px; border-radius: 3px; background: var(--bg-inset); overflow: hidden; }
.disk__fill { display: block; height: 100%; border-radius: 3px; transition: width 0.4s ease; }
.disk__fill--ok { background: var(--st-active); }
.disk__fill--warn { background: var(--st-readonly); }
.disk__fill--danger { background: var(--st-suspended); }
.disk__label { font-size: 0.78rem; color: var(--text-dim); }

/* Auto-renew marker next to prices */
.renew { color: var(--st-active); font-weight: 700; cursor: default; }

hr.sep { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* ---------- Tables ---------- */

.table-scroll { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 0.86rem;
}
table.data th {
  text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-faint); font-weight: 600; padding: 9px 12px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
  user-select: none;
}
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { color: var(--text-dim); }
table.data th.sorted-asc::after { content: " ▲"; font-size: 0.6rem; }
table.data th.sorted-desc::after { content: " ▼"; font-size: 0.6rem; }
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--bg-hover); }
table.data .cell-main { font-weight: 600; }
table.data .cell-sub { font-size: 0.76rem; color: var(--text-faint); margin-top: 1px; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Client groups on the dashboard ---------- */

details.group { margin-bottom: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-raised); overflow: hidden; }
details.group > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; font-weight: 600;
}
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary::before {
  content: "▸"; color: var(--text-faint); font-size: 0.8rem; transition: transform 0.15s ease;
}
details.group[open] > summary::before { transform: rotate(90deg); }
details.group > summary:hover { background: var(--bg-hover); }
.group__meta { margin-left: auto; display: flex; gap: 14px; align-items: center; font-size: 0.78rem; color: var(--text-faint); font-weight: 500; }
.group__mrr { font-family: var(--font-mono); color: var(--text-dim); }

/* ---------- Toolbar: search & filters ---------- */

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.search {
  flex: 1 1 220px; max-width: 340px; position: relative;
}
.search input {
  width: 100%; padding: 8px 12px 8px 32px;
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-family: var(--font-ui); font-size: 0.88rem;
}
.search::before {
  content: "⌕"; position: absolute; left: 10px; top: 50%; transform: translateY(-54%);
  color: var(--text-faint); font-size: 1rem;
}
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-chips a {
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600;
  color: var(--text-dim); padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px;
}
.filter-chips a:hover { border-color: var(--border-strong); color: var(--text); }
.filter-chips a.is-active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-ui); font-size: 0.85rem; font-weight: 600;
  padding: 7px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg-raised); color: var(--text);
  cursor: pointer; transition: background 0.12s ease, border-color 0.12s ease;
  text-decoration: none; line-height: 1.3;
}
.btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-strong); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn--danger { color: var(--st-suspended); border-color: color-mix(in srgb, var(--st-suspended) 45%, transparent); }
.btn--danger:hover { background: color-mix(in srgb, var(--st-suspended) 12%, transparent); color: var(--st-suspended); }
.btn--ghost { border-color: transparent; background: transparent; color: var(--text-dim); }
.btn--ghost:hover { color: var(--text); background: var(--bg-hover); }
.btn--sm { font-size: 0.78rem; padding: 4px 10px; }
.btn--block { width: 100%; justify-content: center; }
.btn--block + .btn--block { margin-top: 8px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Forms ---------- */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-grid .span-2 { grid-column: 1 / -1; }

.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-dim); margin-bottom: 5px;
}
.field input[type="text"], .field input[type="password"], .field input[type="email"],
.field input[type="date"], .field input[type="number"], .field select, .field textarea {
  width: 100%; padding: 8px 11px;
  background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-family: var(--font-ui); font-size: 0.9rem;
  color-scheme: dark;
}
[data-theme="light"] .field input, [data-theme="light"] .field select, [data-theme="light"] .field textarea { color-scheme: light; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field .help-block, .field .hint { font-size: 0.76rem; color: var(--st-suspended); margin-top: 4px; }
.field .hint--info { color: var(--text-faint); }
.field.mono-input input { font-family: var(--font-mono); }
.field--inline { display: flex; align-items: center; gap: 8px; }
.field--inline label { margin: 0; text-transform: none; letter-spacing: 0; font-size: 0.85rem; }

.checkbox-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.checkbox-row:last-child { border-bottom: none; }
.checkbox-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- Flash messages ---------- */

.flash { padding: 11px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 0.88rem; border: 1px solid; }
.flash--success { color: var(--st-active); border-color: color-mix(in srgb, var(--st-active) 35%, transparent); background: color-mix(in srgb, var(--st-active) 8%, transparent); }
.flash--error { color: var(--st-suspended); border-color: color-mix(in srgb, var(--st-suspended) 35%, transparent); background: color-mix(in srgb, var(--st-suspended) 8%, transparent); }

.token-reveal {
  background: var(--bg-inset); border: 1px dashed var(--border-strong); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 16px;
}
.token-reveal code {
  display: block; font-size: 0.95rem; word-break: break-all; margin: 6px 0;
  color: var(--accent); cursor: pointer;
}
.token-reveal .note { font-size: 0.78rem; color: var(--st-readonly); }

/* ---------- Key/value fact grids (tenant & client cards) ---------- */

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px 20px; }
.fact__label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-faint); font-weight: 600; }
.fact__value { font-family: var(--font-mono); font-size: 0.92rem; margin-top: 2px; word-break: break-word; }
.fact__value .badge { font-size: 0.78rem; }

/* ---------- Danger zone ---------- */

.danger-zone { border-color: color-mix(in srgb, var(--st-suspended) 35%, transparent); }
.danger-zone h2 { color: var(--st-suspended); }
.danger-zone .step { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.danger-zone .step:last-child { border-bottom: none; }
.danger-zone .step__num {
  font-family: var(--font-mono); font-weight: 700; color: var(--st-suspended);
  border: 1px solid color-mix(in srgb, var(--st-suspended) 45%, transparent);
  width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 0.8rem;
}

/* ---------- Job output ---------- */

pre.output {
  background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; font-size: 0.8rem; line-height: 1.55; overflow-x: auto;
  max-height: 520px; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
  color: var(--text-dim);
}

/* ---------- Login ---------- */

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; }
.login-card .brand { justify-content: center; margin-bottom: 22px; font-size: 1.1rem; }

/* ---------- Pagination (yii LinkPager) ---------- */

ul.pagination { display: flex; gap: 4px; list-style: none; padding: 0; margin: 16px 0 0; flex-wrap: wrap; }
ul.pagination li a, ul.pagination li span {
  display: block; padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-dim); font-family: var(--font-mono); font-size: 0.8rem;
}
ul.pagination li.active a { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
ul.pagination li a:hover { border-color: var(--border-strong); color: var(--text); }
ul.pagination li.disabled span { opacity: 0.4; }

/* ---------- Theme toggle ---------- */

.theme-toggle {
  background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-dim); width: 32px; height: 32px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.95rem;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* ---------- Charts ---------- */

.chart-box { position: relative; height: 220px; }

/* ---------- Utility ---------- */

.mt-0 { margin-top: 0; }
.mt { margin-top: 14px; }
.mb-0 { margin-bottom: 0; }
.text-right { text-align: right; }
.copyable { cursor: pointer; }
.copyable:active { opacity: 0.6; }
.hidden { display: none !important; }

/* ---------- Mobile ---------- */

@media (max-width: 700px) {
  body { font-size: 13.5px; }
  .shell { padding: 0 12px 48px; }
  .topbar__inner { padding: 0 12px; gap: 12px; }
  .brand__muted { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat__value { font-size: 1.35rem; }
  table.data { font-size: 0.82rem; }
  table.data th, table.data td { padding: 8px 8px; }
  .page-head { align-items: flex-start; flex-direction: column; }
}
