/* Rex TV design system — tokens + light polish (no stack migration).
   Reference: sober SaaS tokens inspired by tweakcn/shadcn patterns, native CSS only. */
:root { color-scheme: light; }
html[data-theme="light"] {
  --bg:#f3f5f8;
  --sidebar:#ffffff;
  --surface:#ffffff;
  --surface-2:#eef2f7;
  --border:#e2e8f0;
  --border-strong:#d0d9e6;
  --sidebar-border:#e2e8f0;
  --text:#1c2738;
  --text-strong:#0f1a2b;
  --text-soft:#334155;
  --text-muted:#516079;
  --text-dim:#5b6b84;
  --text-faint:#64748b;
  --text-label:#52647e;
  --accent:#1263d8;
  --accent-hover:#0c4ba9;
  --accent-ink:#fff;
  --teal:#087f5b;
  --blue:#1263d8;
  --red:#b42336;
  --radius-sm:6px;
  --radius-md:9px;
  --radius-lg:12px;
  --shadow-sm:0 1px 2px #0f1a2b0a;
  --shadow-md:0 2px 10px #0f1a2b0c;
  --space-1:4px;
  --space-2:8px;
  --space-3:12px;
  --space-4:16px;
  --space-5:24px;
  --font:"Manrope","Segoe UI",system-ui,-apple-system,sans-serif;
  --text-xs:12px;
  --text-sm:13px;
  --text-md:14px;
  --text-lg:16px;
  --text-xl:20px;
  --text-2xl:28px;
}
html[data-theme="dark"] {
  color-scheme:dark;
  --bg:#0b1018;
  --sidebar:#101722;
  --surface:#141c28;
  --surface-2:#1a2433;
  --border:#243041;
  --border-strong:#314257;
  --sidebar-border:#243041;
  --text:#e8eef7;
  --text-strong:#f5f8fc;
  --text-soft:#c9d4e4;
  --text-muted:#9aabbf;
  --text-dim:#a3afc2;
  --text-faint:#a3afc2;
  --text-label:#98a8bf;
  --shadow-sm:0 1px 2px #0006;
  --shadow-md:0 8px 24px #0005;
}

body,button,input,select,textarea{font-family:var(--font,Manrope,"Segoe UI",system-ui,sans-serif)}
h1,h2,h3{letter-spacing:-.02em;font-weight:700;color:var(--text-strong)}
h1{font-size:clamp(1.45rem,2.2vw,1.85rem)}
h2{font-size:clamp(1.15rem,1.6vw,1.35rem)}
h3{font-size:1.05rem}
.muted,small,.hint{color:var(--text-muted);font-size:var(--text-sm)}

.rex-icon { display:inline-block; flex:none; vertical-align:middle; }
.btn .rex-icon,summary .rex-icon { margin-right:6px; }
.btn {
  gap:6px;
  border-radius:var(--radius-sm);
  min-height:40px;
  font-weight:650;
  font-size:var(--text-md);
  transition:background .12s ease,border-color .12s ease,color .12s ease;
}
.btn:active{transform:translateY(1px)}
.btn-primary{box-shadow:none}

html[data-theme="light"] .card,
html[data-theme="light"] .management-client-card {
  border-radius:var(--radius-md);
  box-shadow:var(--shadow-sm);
  border:1px solid var(--border);
}
html[data-theme="light"] .nav-item { border-radius:var(--radius-sm); }
html[data-theme="light"] .nav-item.active { background:#e8f1ff;color:#0c4ba9; }
html[data-theme="light"] .brand-mark {background:var(--accent);color:#fff;box-shadow:none;}
html[data-theme="light"] .client-server-state[data-state="confirmed"] {background:#edf9f2;border-color:#a8dfc0;color:#16613c;}
html[data-theme="light"] .client-server-state[data-state="waiting"] {background:#fff8e7;border-color:#e8d69f;color:#71540e;}
html[data-theme="light"] .client-server-state[data-state="review"] {background:#fff0f1;border-color:#e6adb6;color:#982138;}
html[data-theme="light"] .client-server-state p {color:inherit;}
html[data-theme="light"] .action-renew {background:#fff8e6;color:#72500c;border-color:#d8b65e;}
html[data-theme="light"] .action-block {background:#fff0f1;color:#a02238;border-color:#e9abb6;}
html[data-theme="light"] .action-unblock {background:#eaf8ef;color:#16623c;border-color:#a7d5b9;}
html[data-theme="light"] .action-connections {background:#f1edff;color:#5635a1;border-color:#c6b6ea;}
html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea {color:var(--text-strong);}
html[data-theme="light"] .alert-error {background:#fff0f1;color:#9c2135;border-color:#e6adb6;}
html[data-theme="light"] .alert-success {background:#edf9f2;color:#16613c;border-color:#a8dfc0;}
html[data-theme="light"] .list-row,
html[data-theme="light"] .client-card,
html[data-theme="light"] .tile {
  background:var(--surface);
  box-shadow:var(--shadow-sm);
  border-radius:var(--radius-md);
  border:1px solid var(--border);
}
html[data-theme="light"] .bubble.mine {background:#e8f1ff;border-color:#c3d8f6;}
html[data-theme="light"] .pill-red,
html[data-theme="light"] .btn-danger,
html[data-theme="light"] .fields strong {color:#a02238;}
html[data-theme="light"] .btn-danger svg {stroke:currentColor;}
html[data-theme="light"] .field input:focus,
html[data-theme="light"] .field select:focus,
html[data-theme="light"] .field textarea:focus {outline-color:color-mix(in srgb,var(--accent) 55%,transparent);}

@media(min-width:861px){
  .sidebar{width:232px;flex-basis:232px;padding:22px 14px}
  .content{padding:24px 28px 40px}
  .sidebar .nav-label{font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--text-faint)}
  .sidebar .nav-item{font-size:14px}
}
@media(max-width:860px){
  .management-page .row-actions>.btn{min-height:44px}
  .rex-icon{width:20px;height:20px}
}

.brand-logo {width:44px;height:44px;object-fit:contain;flex:none;border-radius:var(--radius-sm);background:var(--surface);}
.brand-preview {display:flex;align-items:center;gap:16px;padding:18px;border:1px solid var(--border-strong);border-radius:var(--radius-md);background:var(--surface);}
.brand-preview img {width:80px;height:80px;object-fit:contain;}
html[data-theme] .brand-mark {background:var(--accent);color:#fff;}
html[data-theme="dark"] .content a:not(.btn) {color:color-mix(in srgb,var(--accent),white 45%);}

.owner-nav-group>summary {cursor:pointer;list-style:disclosure-closed;padding-block:5px;}
.owner-nav-group[open]>summary {list-style:disclosure-open;}
.owner-nav-group>summary:focus-visible {outline:2px solid var(--accent);outline-offset:2px;}
@media(min-width:861px){
  .sidebar{position:sticky;top:0;height:100dvh;overflow-y:auto;overscroll-behavior:contain;align-self:flex-start;}
  .sidebar .nav{flex-shrink:0;}
  .sidebar-footer{flex-shrink:0;}
}
[data-brand-form] .form-grid {grid-template-columns:repeat(2,minmax(0,1fr));}
@media(max-width:640px){[data-brand-form] .form-grid{grid-template-columns:minmax(0,1fr);}}

html[data-theme] :is(.management-client-card,.client-card)[data-account-status="active"] {border:2px solid #079455;}
html[data-theme] :is(.management-client-card,.client-card)[data-account-status="inactive"] {border:2px solid #d92d20;}
html[data-theme="dark"] :is(.management-client-card,.client-card)[data-account-status="active"] {border-color:#32d583;}
html[data-theme="dark"] :is(.management-client-card,.client-card)[data-account-status="inactive"] {border-color:#ff6875;}

.sidebar-wallet{display:grid;gap:5px;margin:10px;padding:12px;border:1px solid var(--border,#cbd5e1);border-radius:var(--radius-lg);text-align:center;justify-items:center;align-content:center}
.sidebar-wallet strong{font-size:26px;color:var(--accent,#1263d8);text-align:center;width:100%;line-height:1.15}
.sidebar-wallet span,.sidebar-wallet a{font-size:12px;overflow-wrap:anywhere;text-align:center;width:100%}
.finance-chart{height:220px;display:flex;align-items:end;gap:12px;margin:28px 0 38px}
.finance-chart>div{height:170px;flex:1;min-width:0;display:flex;flex-direction:column;justify-content:end;align-items:center;position:relative}
.finance-chart i{display:block;width:70%;min-height:3px;background:var(--accent,#1263d8);border-radius:6px 6px 0 0}
.finance-chart span{font-size:11px;white-space:nowrap}
.finance-chart small{position:absolute;bottom:-24px;font-size:11px}
@media(max-width:500px){.finance-chart{gap:4px}.finance-chart span{font-size:9px}.financial-dashboard .stats{display:grid;grid-template-columns:1fr}}

.admin-identity{display:grid;gap:4px;margin:8px 14px 14px;font-size:13px;line-height:1.4}
.admin-identity span:last-child{color:var(--accent,#1263d8);font-weight:700}
.owner-nav-group>summary{font-size:13px;text-transform:none;cursor:pointer;padding:12px 10px;letter-spacing:0;display:flex;align-items:center;gap:9px;list-style:none}
.owner-nav-group>summary::-webkit-details-marker{display:none}
.owner-nav-group>summary:after{content:'⌄';margin-left:auto;transition:transform .12s ease}
.owner-nav-group:not([open])>summary:after{transform:rotate(-90deg)}
.owner-nav-group>summary>svg{width:18px;height:18px;flex:none;stroke:currentColor}
.owner-nav-group>.nav-item{margin-left:14px;border-left:1px solid var(--border,#cbd5e1);border-radius:0 7px 7px 0;padding-left:12px}
.owner-nav-group>.nav-item.active{background:var(--accent,#1263d8);color:white}
.owner-nav-group>.nav-item.active svg{stroke:currentColor}
.owner-nav-group{margin-bottom:4px}

/* Tables / status — denser, readable */
table.data, .data-table{width:100%;border-collapse:collapse;font-size:var(--text-sm)}
table.data th, .data-table th{text-align:left;font-size:11px;letter-spacing:.04em;text-transform:uppercase;color:var(--text-faint);padding:10px 12px;border-bottom:1px solid var(--border)}
table.data td, .data-table td{padding:12px;border-bottom:1px solid var(--border);vertical-align:middle}
.status-pill{display:inline-flex;align-items:center;gap:6px;min-height:24px;padding:2px 10px;border-radius:999px;font-size:12px;font-weight:650;border:1px solid var(--border)}

/* Kill decorative continuous motion in the panel shell */
@media (prefers-reduced-motion: reduce) {
  html *, html *::before, html *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
