/* VOJO CRM - «Gold Signal». Tokens mirror renew/design/DESIGN.md. Dark is primary; light follows the
   system or the manual toggle (data-theme on <html>). Views live in views.css. */
:root {
  --bg: #0B0B0C; --surface: #131315; --surface-2: #18181B; --surface-3: #1F1F23;
  --line: rgba(240, 230, 210, .08); --line-strong: rgba(240, 230, 210, .16);
  --text: #F0E6D2; --text-2: #A8A091; --text-3: #8C8578;
  --gold: #F5B800; --gold-hi: #FFC94A; --gold-mid: #D4A017; --gold-lo: #8A6A12;
  --gold-text: #FFC94A; --gold-tint: rgba(245, 184, 0, .1); --on-gold: #1A1405;
  --ok: #8FD6A0; --bad: #FF8F7E; --warn: #FFC94A;
  --bad-tint: rgba(255, 143, 126, .12); --ok-tint: rgba(143, 214, 160, .1);
  --focus: #FFC94A; --backdrop: rgba(0, 0, 0, .62);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 24px 48px -28px rgba(0, 0, 0, .8);
  --glow-gold: 0 1px 0 rgba(255, 236, 170, .55) inset, 0 -1px 0 rgba(120, 80, 0, .25) inset, 0 10px 28px -12px rgba(245, 184, 0, .6);
  --ambient: radial-gradient(closest-side, rgba(212, 160, 23, .13), rgba(212, 160, 23, 0));
  --font: Inter, "SF Pro Text", system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #F6F3EC; --surface: #FFFFFF; --surface-2: #FBF9F4; --surface-3: #F1EDE3;
    --line: rgba(23, 21, 15, .09); --line-strong: rgba(23, 21, 15, .2);
    --text: #17150F; --text-2: #5E584C; --text-3: #6F695C;
    --gold-text: #7A5800; --gold-tint: rgba(245, 184, 0, .16); --ok: #1B6B35; --bad: #B3382A; --warn: #7A5800;
    --bad-tint: rgba(179, 56, 42, .09); --ok-tint: rgba(27, 107, 53, .09);
    --focus: #7A5800; --backdrop: rgba(23, 21, 15, .4);
    --shadow: 0 1px 2px rgba(23, 21, 15, .06), 0 18px 36px -24px rgba(23, 21, 15, .25);
    --ambient: radial-gradient(closest-side, rgba(245, 184, 0, .14), rgba(245, 184, 0, 0));
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #F6F3EC; --surface: #FFFFFF; --surface-2: #FBF9F4; --surface-3: #F1EDE3;
  --line: rgba(23, 21, 15, .09); --line-strong: rgba(23, 21, 15, .2);
  --text: #17150F; --text-2: #5E584C; --text-3: #6F695C;
  --gold-text: #7A5800; --gold-tint: rgba(245, 184, 0, .16); --ok: #1B6B35; --bad: #B3382A; --warn: #7A5800;
  --bad-tint: rgba(179, 56, 42, .09); --ok-tint: rgba(27, 107, 53, .09);
  --focus: #7A5800; --backdrop: rgba(23, 21, 15, .4);
  --shadow: 0 1px 2px rgba(23, 21, 15, .06), 0 18px 36px -24px rgba(23, 21, 15, .25);
  --ambient: radial-gradient(closest-side, rgba(245, 184, 0, .14), rgba(245, 184, 0, 0));
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 400 14px/1.5 var(--font); overflow-x: hidden; }
body::before { content: ""; position: fixed; z-index: -1; pointer-events: none; right: -15%; top: -20%; width: 80%; height: 70%; background: var(--ambient); }
h1, h2, h3 { margin: 0; text-wrap: balance; }
h1 { font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; margin-bottom: 10px; letter-spacing: -.005em; }
h3 { font-size: 13px; font-weight: 600; margin: 16px 0 6px; color: var(--text-2); }
p { text-wrap: pretty; }
a { color: var(--gold-text); text-underline-offset: 2px; }
code { font-family: var(--mono); font-size: 12.5px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--text-2); } .error { color: var(--bad); margin: 6px 0 0; min-height: 1em; }
.warn-text { color: var(--warn); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num, .data td.num, .kpi .v, .step strong, .pct { font-variant-numeric: tabular-nums; }

/* ---------- header, tabs ---------- */
.top { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; padding: 12px 20px; background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); position: relative; z-index: 15; /* above sticky tabs (z 5): backdrop-filter makes .top its own stacking context */ }
.top::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold-mid) 20%, var(--gold) 50%, var(--gold-mid) 80%, transparent); opacity: .45; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { height: 26px; width: auto; display: block; }
.logo-light { display: none; }
:root[data-theme="light"] .logo-dark { display: none; } :root[data-theme="light"] .logo-light { display: block; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .logo-dark { display: none; } :root:not([data-theme="dark"]) .logo-light { display: block; }
}
.brand-tag { font: 600 11px/1 var(--mono); letter-spacing: .14em; color: var(--text-3); padding: 4px 7px; border: 1px solid var(--line-strong); border-radius: 6px; }
.top-right { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#status-line { font-size: 12px; }
#whoami { font-weight: 500; color: var(--text); padding: 0 4px; }
.banner { padding: 10px 20px; margin: 0; background: var(--bad-tint); border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 2px; padding: 0 16px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 5; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; background: none; border: 0; padding: 13px 14px; color: var(--text-2); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; min-height: 44px; transition: color .15s var(--ease); }
.tab:hover { color: var(--text); }
.tab::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--gold); transform: scaleX(0); transition: transform .25s var(--ease); box-shadow: 0 0 12px rgba(245, 184, 0, .6); }
.tab[aria-selected="true"], .tab.active { color: var(--text); }
.tab[aria-selected="true"]::after, .tab.active::after { transform: scaleX(1); }
.tab .badge { background: var(--gold); color: var(--on-gold); font-weight: 600; margin-left: 4px; }
main { padding: 20px; max-width: 1440px; margin: 0 auto; }
.panel { animation: rise .35s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ---------- buttons, forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 0 14px; min-height: 36px; font: inherit; font-weight: 500; cursor: pointer; transition: transform .12s var(--ease), background-color .15s, border-color .15s, color .15s, box-shadow .15s; }
.btn:hover { border-color: var(--gold-mid); background: var(--surface-3); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn.primary { background: linear-gradient(180deg, var(--gold-hi), var(--gold)); color: var(--on-gold); border-color: transparent; box-shadow: var(--glow-gold); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); } .btn.danger:hover { border-color: var(--bad); background: var(--bad-tint); }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.icon { width: 36px; padding: 0; } .btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (pointer: coarse) { .btn { min-height: 44px; } .btn.small { min-height: 40px; } .btn.icon { width: 44px; } }
.spinner { display: inline-block; width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
input, select, textarea { background: var(--surface-2); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 8px 11px; min-height: 36px; font: inherit; max-width: 100%; transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:hover, select:hover, textarea:hover { border-color: var(--text-3); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-tint), 0 0 0 1px var(--gold); }
input[type=checkbox] { min-height: 0; width: 16px; height: 16px; accent-color: var(--gold); }
input[type=file] { padding: 5px 8px; }
@media (pointer: coarse) { input, select, textarea { min-height: 44px; font-size: 16px; } }
label { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); }
label input, label select, label textarea { display: block; width: 100%; margin-top: 4px; color: var(--text); font-weight: 400; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters input[type=search] { flex: 1 1 240px; }
.inline { display: inline-flex; gap: 6px; align-items: center; }
.inline input, .inline select { margin: 0; width: auto; }
.stack { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 12px; }
.secret-row { display: grid; grid-template-columns: 1fr 2fr auto; gap: 6px; margin-bottom: 6px; }
.qr { background: #fff; padding: 10px; border-radius: var(--r-md); width: fit-content; margin: 0 auto; } .qr svg { display: block; max-width: 100%; height: auto; }

/* ---------- login / setup ---------- */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); z-index: 10; padding: 16px; overflow: hidden auto; }
.overlay::before { content: ""; position: absolute; inset: -10% -10% auto auto; width: 70vmax; height: 70vmax; background: var(--ambient); pointer-events: none; }
.login-card { position: relative; width: 100%; max-width: 380px; display: grid; gap: 16px; padding: 28px 24px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--shadow); animation: rise .5s var(--ease) both; margin: auto; }
.login-brand { display: grid; gap: 6px; justify-items: center; text-align: center; }
.login-brand .brand-logo { height: 40px; }
.login-title { font-size: 16px; font-weight: 600; margin-top: 6px; }
.login-sub { margin: 0; color: var(--text-2); font-size: 13px; }
.login-card .btn.primary { min-height: 42px; }
.login-card .theme-slot { position: absolute; top: 10px; right: 10px; }
.notice { padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--gold-tint); font-size: 13px; }
.notice.bad { background: var(--bad-tint); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); max-width: 100%; }
table.data { width: 100%; border-collapse: collapse; }
.data th, .data td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data tbody tr:last-child td { border-bottom: 0; }
.data th { color: var(--text-3); font: 600 11px/1.2 var(--mono); letter-spacing: .06em; text-transform: uppercase; position: sticky; top: 0; background: var(--surface-2); }
.data th.sortable { cursor: pointer; user-select: none; } .data th.sortable:hover { color: var(--text); }
.data tbody tr.click { cursor: pointer; transition: background-color .12s; }
.data tbody tr.click:hover { background: var(--surface-3); }
.data td.num { text-align: right; }
.data td.wrap { white-space: normal; min-width: 180px; }
.badge { display: inline-block; padding: 1px 9px; margin: 1px 3px 1px 0; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line); color: var(--text-2); font-size: 12px; line-height: 1.6; }
.badge.t-admin, .badge.role-admin { color: var(--gold-text); background: var(--gold-tint); border-color: transparent; }
.badge.t-paid, .badge.ok { color: var(--ok); background: var(--ok-tint); border-color: transparent; }
.badge.t-admin_grant { color: var(--text); }
.badge.off { color: var(--bad); background: var(--bad-tint); border-color: transparent; }
.st-active { color: var(--ok); } .st-expired, .st-disabled { color: var(--bad); } .st-limited { color: var(--warn); }
.st-active, .st-expired, .st-disabled, .st-limited { font-weight: 500; }

/* ---------- dialogs, toasts ---------- */
dialog { background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--r-lg); padding: 20px; width: min(900px, 96vw); max-height: 92dvh; box-shadow: var(--shadow); overscroll-behavior: contain; }
dialog.narrow { width: min(460px, 96vw); }
dialog[open] { animation: pop .22s var(--ease) both; }
dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(3px); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.dialog-head h2 { margin: 0; }
.dialog-foot { margin-top: 14px; display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.secret { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0; }
.secret code { background: var(--surface-3); border: 1px solid var(--line); padding: 3px 8px; border-radius: 6px; word-break: break-all; }
.secret.big code { font-size: 15px; padding: 10px 12px; flex: 1 1 240px; user-select: all; color: var(--gold-text); }
#toasts { position: fixed; z-index: 50; right: 16px; bottom: 16px; display: grid; gap: 8px; width: min(360px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; padding: 11px 14px; background: var(--surface-3); border: 1px solid var(--line-strong); border-left: 3px solid var(--gold); border-radius: var(--r-md); box-shadow: var(--shadow); animation: rise .25s var(--ease) both; }
.toast.bad { border-left-color: var(--bad); } .toast.ok { border-left-color: var(--ok); }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
@media (max-width: 600px) { #toasts { right: 16px; left: 16px; width: auto; } }

@media (max-width: 700px) {
  .top { padding: 10px 14px; } main { padding: 14px 12px; } .tabs { padding: 0 6px; }
  .secret-row { grid-template-columns: 1fr; }
  dialog { padding: 16px; border-radius: var(--r-md); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .spinner { animation: spin 1.6s linear infinite !important; animation-iteration-count: infinite !important; animation-duration: 1.6s !important; }
}
