/* =========================================================================
   C9cast admin — base, primitives, app shell, dashboard, login.
   Colors come ONLY from theme.css tokens. Page-area styles live in
   screens.css (screens/settings/reports…) and content.css (media/playlists…).
   ========================================================================= */

/* ------------------------------------------------------------- base --- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: 1.45;
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
  text-rendering: optimizeLegibility;
}
::selection { background: var(--selection); color: var(--text-primary); }
a { color: var(--text-link); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; color: var(--text-heading); }
p { margin: 0; }
.ic { width: 18px; height: 18px; flex: none; }
button { font: inherit; color: inherit; }
input, select, textarea { caret-color: var(--accent-primary); }
:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }
[hidden] { display: none !important; }
table, .num, .tabular { font-variant-numeric: tabular-nums; }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-full); border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

.muted { color: var(--text-muted); }
.warn-text { color: var(--status-warning-strong); display: inline-flex; align-items: center; gap: 5px; }
.warn-text .ic { width: 14px; height: 14px; }
.small { font-size: var(--fs-xs); }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--font-mono); }
.row { display: flex; align-items: center; gap: var(--space-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: var(--space-3); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* =========================================================== APP SHELL === */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.main { min-width: 0; display: flex; flex-direction: column; }
.content { padding: 0 var(--space-6) var(--space-8); width: 100%; max-width: 1600px; }

/* ---------------------------------------------------------- sidebar --- */
.sidebar {
  position: sticky; top: 0; height: 100vh; z-index: 40;
  display: flex; flex-direction: column;
  /* brand surface: glow over bottom-anchored waves over the navy → royal gradient */
  background:
    var(--glow-sidebar),
    var(--wave-sidebar) left bottom / 100% 62% no-repeat,
    var(--gradient-sidebar);
  background-color: var(--bg-sidebar);
  color: var(--text-sidebar);
  padding: var(--space-4) var(--space-3) var(--space-3);
  overflow: hidden;
}
.sidebar-brand { display: flex; align-items: center; min-height: 44px; padding: 0 var(--space-1); margin-bottom: var(--space-4); }
.sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; margin: 0 calc(var(--space-1) * -1); padding: 0 var(--space-1); scrollbar-color: var(--bg-sidebar-hover) transparent; }

/* brand lockup: [mark] C9cast | [org logo] */
.lockup { display: flex; align-items: center; gap: var(--space-2); min-width: 0; max-width: 100%; color: var(--text-sidebar-strong); }
.lockup:hover { text-decoration: none; }
.lockup-product { display: inline-flex; align-items: center; gap: 8px; flex: none; }
.brand-mark { height: 32px; width: auto; flex: none; display: block; }
.brand-word { height: 16px; width: auto; flex: none; display: block; }
.lockup-divider { width: 1px; height: 20px; background: var(--border-sidebar); flex: none; margin: 0 2px; }
/* Customer logo: max 28px tall / 90px wide, never distorted; shrinks (never overflows) when the sidebar is narrower. */
.org-logo { display: inline-flex; align-items: center; flex: 0 1 auto; min-width: 0; max-width: 90px; height: 28px; overflow: hidden; }
.org-logo img { display: block; max-height: 28px; max-width: 100%; width: auto; height: auto; object-fit: contain; object-position: left center; }
.lockup.on-light .lockup-divider { background: var(--border-default); }

/* nav */
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section { margin: var(--space-5) 0 var(--space-2); padding: 0 var(--space-3); font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-sidebar-muted); }
.nav a, .nav button.nav-link {
  position: relative; display: flex; align-items: center; gap: var(--space-3);
  height: 42px; padding: 0 var(--space-3); border-radius: var(--radius-lg);
  color: var(--text-sidebar); font-weight: 500; font-size: 15px; letter-spacing: -0.005em;
  background: none; border: 0; cursor: pointer; text-align: left; width: 100%;
  transition: background var(--dur-fast), color var(--dur-fast), box-shadow var(--dur-fast);
}
/* thin line icons */
.nav a .ic, .nav button.nav-link .ic { width: 20px; height: 20px; stroke-width: 1.6; color: var(--text-sidebar-muted); transition: color var(--dur-fast); }
.nav a:hover, .nav button.nav-link:hover { background: var(--bg-sidebar-hover); color: var(--text-sidebar-strong); text-decoration: none; }
.nav a:hover .ic, .nav button.nav-link:hover .ic { color: var(--text-sidebar); }
.nav a.active { background: var(--gradient-nav-active); box-shadow: var(--shadow-nav-active); color: var(--text-sidebar-strong); font-weight: 600; }
.nav a.active .ic { color: var(--icon-sidebar-active); stroke-width: 1.8; }
.nav a:focus-visible, .nav button.nav-link:focus-visible, .account-btn:focus-visible { outline: 2px solid var(--icon-sidebar-active); outline-offset: -2px; }
.nav .nav-ext { margin-left: auto; width: 14px; height: 14px; opacity: 0.6; }

/* account panel */
.sidebar-foot { margin-top: var(--space-3); padding-top: var(--space-3); }
.account-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px var(--space-3) 10px 10px; border-radius: var(--radius-lg);
  background: var(--bg-sidebar-raised); border: 1px solid var(--border-sidebar);
  color: var(--text-sidebar-strong); cursor: pointer; text-align: left;
  transition: background var(--dur-fast);
}
.account-btn:hover { background: var(--bg-sidebar-hover); border-color: var(--on-dark-border); }
.account-btn .who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.account-btn .who b { font-size: var(--fs-sm); font-weight: 600; }
.account-btn .who span { font-size: var(--fs-xs); color: var(--text-sidebar-muted); }
.account-btn > .ic { width: 16px; height: 16px; color: var(--text-sidebar-muted); }

.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: inline-grid; place-items: center;
  background: var(--accent-primary-soft); color: var(--accent-primary-text);
  font-weight: 600; font-size: var(--fs-md); border: 0;
}
.avatar.on-dark { background: var(--accent-primary); color: var(--text-on-accent); }

/* ----------------------------------------------------------- topbar --- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--space-3);
  padding: 0 var(--space-6);
  background: var(--bg-app);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur), background var(--dur);
}
.topbar.scrolled { background: var(--bg-surface); border-bottom-color: var(--border-default); }
.topbar .spacer { flex: 1; }
.icon-btn.menu-toggle { display: none; }
.user-btn { display: inline-flex; align-items: center; gap: 6px; padding: 2px 6px 2px 2px; border-radius: var(--radius-full); border: 0; background: none; cursor: pointer; color: var(--text-muted); }
.user-btn:hover { background: var(--bg-surface-pressed); }
.user-btn .ic { width: 16px; height: 16px; }

/* global search */
.gsearch { position: relative; width: min(460px, 100%); }
.gsearch .ic-search { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }
.gsearch input[type=search] {
  height: var(--control-h-lg); padding: 0 52px 0 38px; border-radius: var(--radius-lg);
  background: var(--bg-surface); border: 1px solid var(--border-default); box-shadow: var(--shadow-xs);
}
.gsearch input::-webkit-search-cancel-button { display: none; }
.kbd {
  display: inline-flex; align-items: center; gap: 2px; height: 22px; padding: 0 6px;
  border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  background: var(--bg-surface-subtle); color: var(--text-muted);
  font: 500 11px/1 var(--font-sans);
}
.gsearch .kbd { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.gsearch-panel {
  position: fixed; z-index: 220; width: 520px; max-width: calc(100vw - 32px); max-height: min(70vh, 520px); overflow: auto;
  background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg); padding: var(--space-2);
}
.gs-group { padding: var(--space-2) var(--space-2) 2px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.gs-item { display: flex; align-items: center; gap: var(--space-3); width: 100%; padding: var(--space-2); border: 0; border-radius: var(--radius-md); background: none; text-align: left; cursor: pointer; color: var(--text-primary); }
.gs-item .gs-ic { width: 32px; height: 32px; border-radius: var(--radius-md); display: grid; place-items: center; background: var(--bg-surface-muted); color: var(--text-secondary); flex: none; }
.gs-item .gs-ic .ic { width: 16px; height: 16px; }
.gs-item .gs-sub { font-size: var(--fs-xs); color: var(--text-muted); }
.gs-item.active, .gs-item:hover { background: var(--accent-primary-soft); }
.gs-item.active .gs-ic { background: var(--bg-surface); color: var(--accent-primary); }
.gs-empty { padding: var(--space-6) var(--space-4); text-align: center; color: var(--text-muted); font-size: var(--fs-sm); }
.gs-foot { display: flex; gap: var(--space-4); padding: var(--space-2) var(--space-2) 2px; margin-top: var(--space-1); border-top: 1px solid var(--border-subtle); font-size: var(--fs-xs); color: var(--text-muted); }

/* ------------------------------------------------------ page header --- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); padding: var(--space-4) var(--space-6) var(--space-5); max-width: 1600px; }
.page-header h1 { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; }
.crumbs { color: var(--text-muted); font-size: var(--fs-sm); margin-bottom: var(--space-1); }
.crumbs:empty { display: none; }
.crumbs a { color: var(--text-muted); }
.crumbs a:hover { color: var(--text-primary); }
.app.no-page-header .page-header { display: none; }

.scrim { display: none; }

/* ------------------------------------------------- responsive shell --- */
/* Tablet: icon rail */
@media (max-width: 1199px) and (min-width: 761px) {
  .app { grid-template-columns: var(--sidebar-rail-w) minmax(0, 1fr); }
  .sidebar { padding: var(--space-4) var(--space-2) var(--space-3); }
  .sidebar-brand { justify-content: center; padding: 0; }
  .lockup .brand-word, .lockup .lockup-divider, .lockup .org-logo { display: none; }
  .nav-section { height: 1px; margin: var(--space-3) var(--space-2); padding: 0; background: var(--border-sidebar); font-size: 0; overflow: hidden; }
  .nav a, .nav button.nav-link { justify-content: center; padding: 0; height: 40px; }
  .nav a span, .nav button.nav-link span, .nav .nav-ext { display: none; }
  .account-btn { justify-content: center; padding: 6px; background: none; border-color: transparent; }
  .account-btn .who, .account-btn > .ic { display: none; }
}
/* Mobile: drawer */
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; height: 100dvh; transform: translateX(-100%); transition: transform 220ms var(--ease-out); box-shadow: none; z-index: 60; }
  .app.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: var(--bg-overlay); opacity: 0; pointer-events: none; transition: opacity var(--dur); }
  .app.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .icon-btn.menu-toggle { display: inline-grid; }
  .topbar { padding: 0 var(--space-4); gap: var(--space-2); }
  .gsearch { flex: 1; }
  .gsearch .kbd { display: none; }
  .gsearch input[type=search] { padding-right: 12px; }
  .user-btn .ic { display: none; }
  .page-header { padding: var(--space-3) var(--space-4) var(--space-4); }
  .page-header h1 { font-size: 20px; }
  .content { padding: 0 var(--space-4) var(--space-6); }
  .hide-sm { display: none !important; }
}

/* ========================================================= PRIMITIVES === */
/* ---------------------------------------------------------- buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--control-h); padding: 0 14px; border-radius: var(--radius-md);
  border: 1px solid var(--border-strong); background: var(--bg-surface); color: var(--text-primary);
  font-weight: 600; font-size: var(--fs-sm); cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast), box-shadow var(--dur-fast);
}
.btn .ic { width: 16px; height: 16px; }
.btn:hover { background: var(--bg-surface-hover); text-decoration: none; }
.btn:active { background: var(--bg-surface-pressed); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--gradient-primary); border-color: var(--accent-primary); color: var(--text-on-accent); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--gradient-primary-hover); border-color: var(--accent-primary-hover); }
.btn-primary:active { background: var(--accent-primary-active); border-color: var(--accent-primary-active); }
.btn-danger { background: var(--status-danger); border-color: var(--status-danger); color: var(--text-on-accent); }
.btn-danger:hover { background: var(--status-danger-hover); border-color: var(--status-danger-hover); }
.btn-danger-soft { color: var(--status-danger-strong); }
.btn-danger-soft:hover { background: var(--status-danger-soft); border-color: var(--status-danger-border); }
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-surface-pressed); color: var(--text-primary); }
.btn-sm { height: var(--control-h-sm); padding: 0 10px; font-size: var(--fs-xs); }
.btn-lg { height: var(--control-h-lg); padding: 0 18px; font-size: var(--fs-md); }
.btn-block { width: 100%; }
/* split button: [ + Add screen | v ] */
.btn-split { display: inline-flex; }
.btn-split > .btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.btn-split > .btn:last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; padding: 0 9px; border-left-color: var(--on-dark-border); }

.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center; flex: none;
  border-radius: var(--radius-md); border: 0; background: transparent; color: var(--text-secondary);
  cursor: pointer; position: relative; transition: background var(--dur-fast), color var(--dur-fast);
}
.icon-btn:hover { background: var(--bg-surface-pressed); color: var(--text-primary); }
.icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn .pip { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; background: var(--status-danger); border: 2px solid var(--bg-app); border-radius: 50%; }
.topbar.scrolled .icon-btn .pip { border-color: var(--bg-surface); }
.link-btn { background: none; border: 0; color: var(--text-link); cursor: pointer; padding: 0; font-weight: 600; font-size: inherit; }
.link-btn:hover { text-decoration: underline; }
.link-arrow { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); font-weight: 500; }
.link-arrow .ic { width: 14px; height: 14px; transition: transform var(--dur-fast); }
.link-arrow:hover { text-decoration: none; }
.link-arrow:hover .ic { transform: translateX(2px); }

/* ------------------------------------------------------------ forms --- */
label.field { display: block; }
.field > span, .label { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.hint { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 6px; line-height: 1.45; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=date], input[type=time], input[type=datetime-local], input[type=url], input[type=search], select, textarea {
  width: 100%; height: var(--control-h); padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  background: var(--bg-surface); color: var(--text-primary); font: inherit; font-size: var(--fs-md);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: var(--icon-select-chevron);
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
textarea { height: auto; min-height: 84px; padding: 9px 12px; resize: vertical; line-height: 1.5; }
input:hover:not(:disabled):not(:focus), select:hover:not(:disabled):not(:focus), textarea:hover:not(:disabled):not(:focus) { border-color: var(--text-faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--focus-ring); }
input:disabled, select:disabled, textarea:disabled { background: var(--bg-surface-subtle); color: var(--text-faint); cursor: not-allowed; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-error { background: var(--status-danger-soft); color: var(--status-danger-strong); border: 1px solid var(--status-danger-border); padding: 10px 12px; border-radius: var(--radius-md); margin-bottom: var(--space-4); font-size: var(--fs-sm); }
.check { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; user-select: none; }
.check input, input[type=checkbox], input[type=radio] { accent-color: var(--accent-primary); }
.check input { width: 16px; height: 16px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; width: 36px; height: 20px; border-radius: var(--radius-full); background: var(--border-strong); position: relative; cursor: pointer; transition: background var(--dur); margin: 0; flex: none; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--bg-surface); box-shadow: var(--shadow-sm); transition: transform var(--dur) var(--ease-out); }
.switch input:checked { background: var(--accent-primary); }
.switch input:checked::after { transform: translateX(16px); }
.switch input:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
.search { position: relative; display: block; }
.search .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); width: 16px; height: 16px; pointer-events: none; }
.search input { padding-left: 34px; }
.segmented { display: inline-flex; background: var(--bg-surface-muted); border-radius: var(--radius-md); padding: 3px; gap: 2px; }
.segmented button { border: 0; background: transparent; height: 28px; padding: 0 12px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; font-size: var(--fs-sm); color: var(--text-muted); display: inline-flex; align-items: center; gap: 6px; }
.segmented button .ic { width: 16px; height: 16px; }
.segmented button:hover { color: var(--text-primary); }
.segmented button.on { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: var(--radius-sm); background: var(--bg-surface-muted); color: var(--text-secondary); font-size: var(--fs-xs); font-weight: 500; border: 1px solid transparent; }
.chip.on { background: var(--accent-primary-soft); color: var(--accent-primary-text); border-color: var(--accent-primary-border); }
button.chip { cursor: pointer; }
.chip .x { border: 0; background: none; padding: 0; cursor: pointer; color: inherit; display: inline-flex; }
.chip .x .ic { width: 12px; height: 12px; }
.daychips { display: flex; gap: 6px; }
.daychips label { width: 40px; height: 34px; display: grid; place-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius-md); cursor: pointer; font-weight: 600; font-size: var(--fs-xs); user-select: none; background: var(--bg-surface); }
.daychips input { display: none; }
.daychips label:has(input:checked) { background: var(--accent-primary); border-color: var(--accent-primary); color: var(--text-on-accent); }

/* multi-select */
.ms { position: relative; }
.ms-control { min-height: var(--control-h); border: 1px solid var(--border-strong); border-radius: var(--radius-md); padding: 3px 34px 3px 6px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; cursor: text; background: var(--bg-surface); position: relative; box-shadow: var(--shadow-xs); }
.ms-control:focus-within { border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--focus-ring); }
.ms-control input { border: 0 !important; box-shadow: none !important; height: 28px; flex: 1; min-width: 100px; padding: 0 4px; }
.ms-control .ms-caret { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.ms-list { position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; right: 0; max-height: 240px; overflow: auto; background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 4px; }
.ms-opt { display: flex; align-items: center; gap: var(--space-2); padding: 7px 9px; border-radius: var(--radius-sm); cursor: pointer; }
.ms-opt:hover, .ms-opt.active { background: var(--bg-surface-hover); }
.ms-empty { padding: 10px; color: var(--text-muted); font-size: var(--fs-sm); }

/* ------------------------------------------------------------ cards --- */
.card { background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-xl); box-shadow: var(--shadow-xs); min-width: 0; }
.card-pad { padding: var(--space-5); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 56px; padding: var(--space-3) var(--space-5); border-bottom: 1px solid var(--border-subtle); }
.card-head h3 { font-size: 17px; font-weight: 650; letter-spacing: -0.015em; }
.card-head .small, .card-head a.small { font-size: var(--fs-sm); }
.card-head.flush { border-bottom: 0; padding-bottom: 0; min-height: 0; padding-top: var(--space-5); }
.card-title { font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.grid { display: grid; gap: var(--space-4); }
.grid-dash { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
@media (max-width: 1100px) { .span-3, .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; } }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: var(--space-4); }
.toolbar .search { width: 280px; max-width: 100%; }
.toolbar select { width: auto; min-width: 140px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); }
.page-head p { margin: 4px 0 0; color: var(--text-muted); }

/* ----------------------------------------------------------- tables --- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th { text-align: left; font-size: var(--fs-xs); font-weight: 500; color: var(--text-muted); padding: 10px 16px; background: var(--bg-surface-subtle); border-bottom: 1px solid var(--border-default); white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; font-size: var(--fs-sm); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--dur-fast); }
.table tbody tr:hover td { background: var(--bg-surface-hover); }
.table tr.selected td { background: var(--accent-primary-soft); }
.table .w-check { width: 44px; }
.table .w-act { width: 52px; text-align: right; }
.table .clickable { cursor: pointer; }
.cell-title { font-weight: 600; color: var(--text-primary); font-size: var(--fs-sm); }
a.cell-title:hover { color: var(--accent-primary); text-decoration: none; }
.cell-sub { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }
.table-foot { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-top: 1px solid var(--border-subtle); color: var(--text-muted); font-size: var(--fs-sm); }

/* ------------------------------------------------------------ badges --- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px;
  border-radius: var(--radius-full); font-size: var(--fs-xs); font-weight: 500; white-space: nowrap;
  background: var(--status-neutral-soft); color: var(--status-neutral-strong);
  border: 1px solid var(--status-neutral-border);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge .ic { width: 13px; height: 13px; }
.badge-playing, .badge-ready, .badge-success { background: var(--status-success-soft); color: var(--status-success-strong); border-color: var(--status-success-border); }
.badge-playing .dot, .badge-ready .dot { background: var(--status-success-fill); }
.badge-online, .badge-processing, .badge-scheduled, .badge-info { background: var(--status-info-soft); color: var(--status-info-strong); border-color: var(--status-info-border); }
.badge-online .dot { background: var(--status-info-fill); }
.badge-offline, .badge-failed, .badge-danger { background: var(--status-danger-soft); color: var(--status-danger-strong); border-color: var(--status-danger-border); }
.badge-offline .dot { background: var(--status-danger-fill); }
.badge-unassigned, .badge-warn { background: var(--status-warning-soft); color: var(--status-warning-strong); border-color: var(--status-warning-border); }
.badge-unassigned .dot { background: var(--status-warning-fill); }
.badge-paused, .badge-expired, .badge-neutral, .badge-signedout { background: var(--status-neutral-soft); color: var(--status-neutral-strong); border-color: var(--status-neutral-border); }
.badge-expired { color: var(--text-muted); }
.badge-processing .spin { width: 10px; height: 10px; border-width: 1.5px; }
.count-pill { display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 6px; border-radius: var(--radius-full); background: var(--bg-surface-muted); color: var(--text-secondary); font-size: var(--fs-xs); font-weight: 500; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------- thumbs --- */
.thumb { display: inline-grid; place-items: center; background: var(--bg-surface-muted); border-radius: var(--radius-sm); overflow: hidden; flex: none; color: var(--text-muted); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-sm { width: 40px; height: 28px; }
.thumb-md { width: 64px; height: 40px; }
.thumb-lg { width: 120px; height: 68px; }
.thumb-icon .ic { width: 18px; height: 18px; }
.thumb-broken { background: var(--bg-surface-muted); }

/* ------------------------------------------------------------- modal --- */
.modal-backdrop { position: fixed; inset: 0; background: var(--bg-overlay); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px; overflow-y: auto; animation: fade var(--dur) ease; }
.modal-backdrop.closing { opacity: 0; transition: opacity 150ms; }
.modal { background: var(--bg-surface); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); border: 1px solid var(--border-default); width: 100%; max-width: 560px; display: flex; flex-direction: column; animation: pop 200ms var(--ease-out); }
.modal-sm { max-width: 420px; }
.modal-lg { max-width: 820px; }
.modal-xl { max-width: 1100px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-5) var(--space-6) var(--space-2); }
.modal-head h2 { font-size: var(--fs-xl); font-weight: 600; }
.modal-body { padding: var(--space-3) var(--space-6) var(--space-5); }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border-subtle); background: var(--bg-surface-subtle); border-radius: 0 0 var(--radius-xl) var(--radius-xl); }
.confirm-text { margin: 4px 0; color: var(--text-secondary); line-height: 1.55; }
@media (max-width: 640px) { .modal-head { padding: var(--space-4) var(--space-4) var(--space-2); } .modal-body { padding: var(--space-3) var(--space-4) var(--space-4); } .modal-foot { padding: var(--space-3) var(--space-4); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(6px) scale(0.985); opacity: 0; } }

/* -------------------------------------------------------------- menu --- */
.menu { position: absolute; z-index: 200; min-width: 208px; background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 4px; animation: pop 140ms var(--ease-out); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border: 0; background: none; border-radius: var(--radius-sm); cursor: pointer; text-align: left; color: var(--text-primary); font-size: var(--fs-sm); font-weight: 500; }
.menu-item:hover, .menu-item:focus { background: var(--bg-surface-hover); outline: none; }
.menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--focus-ring); }
.menu-item .ic { width: 16px; height: 16px; color: var(--text-muted); }
.menu-item.danger, .menu-item.danger .ic { color: var(--status-danger-strong); }
.menu-item.danger:hover { background: var(--status-danger-soft); }
.menu-item:disabled { opacity: 0.55; cursor: default; background: none; }
.menu-divider { height: 1px; background: var(--border-subtle); margin: 4px 2px; }

/* ------------------------------------------------------------- toast --- */
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 300; display: flex; flex-direction: column; gap: var(--space-2); }
.toast { display: flex; align-items: center; gap: 10px; background: var(--bg-inverse); color: var(--text-inverse); padding: 12px 14px; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); max-width: 420px; font-size: var(--fs-sm); font-weight: 500; animation: pop 200ms var(--ease-out); transition: opacity 300ms, transform 300ms; }
.toast .ic { width: 18px; height: 18px; }
.toast-success .ic { color: var(--toast-success); }
.toast-error .ic { color: var(--toast-error); }
.toast-info .ic { color: var(--toast-info); }
.toast.out { opacity: 0; transform: translateY(6px); }
@media (max-width: 760px) { #toasts { left: 16px; right: 16px; bottom: 16px; } .toast { max-width: none; } }

/* ----------------------------------------------------------- misc ui --- */
.spin { width: 13px; height: 13px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; display: inline-block; animation: rot 0.7s linear infinite; flex: none; }
@keyframes rot { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 48px; color: var(--text-muted); }
.skel { display: block; background: var(--bg-surface-muted); border-radius: var(--radius-sm); position: relative; overflow: hidden; }
.skel::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: var(--gradient-shimmer); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .skel::after { animation: none; } *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; } }
.empty { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty .empty-ic { width: 48px; height: 48px; border-radius: var(--radius-xl); background: var(--bg-surface-muted); color: var(--text-secondary); display: grid; place-items: center; margin: 0 auto 14px; border: 1px solid var(--border-default); }
.empty .empty-ic .ic { width: 22px; height: 22px; }
.empty h3 { color: var(--text-primary); font-size: var(--fs-lg); margin-bottom: 6px; }
.empty p { margin: 0 auto 16px; max-width: 420px; line-height: 1.55; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-lg); font-size: var(--fs-sm); line-height: 1.5; border: 1px solid; }
.alert .ic { margin-top: 1px; width: 18px; height: 18px; }
.alert-warn { background: var(--status-warning-soft); color: var(--status-warning-strong); border-color: var(--status-warning-border); }
.alert-error { background: var(--status-danger-soft); color: var(--status-danger-strong); border-color: var(--status-danger-border); }
.alert-info { background: var(--status-info-soft); color: var(--status-info-strong); border-color: var(--status-info-border); }
.alert-success { background: var(--status-success-soft); color: var(--status-success-strong); border-color: var(--status-success-border); }
.bulkbar { position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 15; display: flex; align-items: center; gap: 10px; background: var(--bg-inverse); color: var(--text-inverse); padding: 8px 14px; border-radius: var(--radius-lg); margin-bottom: var(--space-3); box-shadow: var(--shadow-lg); }
.bulkbar .btn { height: var(--control-h-sm); background: var(--on-dark-subtle); border-color: var(--on-dark-border); color: var(--text-inverse); box-shadow: none; }
.bulkbar .btn:hover { background: var(--on-dark-border); }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: var(--space-2) 14px; font-size: var(--fs-sm); }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; word-break: break-word; }

/* tabs (underline) */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border-default); margin-bottom: var(--space-4); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button, .tabs a { display: inline-flex; align-items: center; gap: var(--space-2); border: 0; background: none; height: 40px; padding: 0 var(--space-3); cursor: pointer; font-weight: 500; font-size: var(--fs-sm); color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; transition: color var(--dur-fast), border-color var(--dur-fast); }
.tabs button:hover, .tabs a:hover { color: var(--text-primary); text-decoration: none; }
.tabs .on { color: var(--accent-primary-text); border-bottom-color: var(--accent-primary); font-weight: 600; }
.tabs .on .count-pill { background: var(--accent-primary-soft); color: var(--accent-primary-text); }
.tabs button:focus-visible, .tabs a:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--focus-ring); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }

.progress { height: 8px; background: var(--bg-surface-muted); border-radius: var(--radius-full); overflow: hidden; }
.progress > span { display: block; height: 100%; min-width: 4px; background: var(--accent-primary); border-radius: var(--radius-full); transition: width var(--dur) var(--ease-out); }
.progress > span.bar-warn { background: var(--status-warning-fill); }
.progress > span.bar-danger { background: var(--status-danger-fill); }
.statbar { display: flex; gap: 3px; height: 12px; border-radius: var(--radius-full); overflow: hidden; background: var(--bg-surface-muted); }
.statbar span { display: block; height: 100%; border-radius: 2px; min-width: 6px; }
.statbar span:first-child { border-radius: var(--radius-full) 2px 2px var(--radius-full); }
.statbar span:last-child { border-radius: 2px var(--radius-full) var(--radius-full) 2px; }
.statbar span:only-child { border-radius: var(--radius-full); }
.c-playing { background: var(--status-success-fill); }
.c-online { background: var(--status-info-fill); }
.c-offline { background: var(--status-danger-fill); }
.c-unassigned { background: var(--status-warning-fill); }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 640px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile { border: 1px solid var(--border-default); border-radius: var(--radius-lg); padding: 12px; cursor: pointer; background: var(--bg-surface); text-align: left; color: inherit; }
.tile:hover { border-color: var(--border-strong); background: var(--bg-surface-hover); text-decoration: none; }
.tile .tile-label { display: flex; align-items: center; gap: 7px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); }
.tile .tile-label i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.tile .tile-value { font-size: 26px; font-weight: 650; margin-top: 4px; }
.big-number { font-size: 32px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; gap: 10px; padding: 10px var(--space-5); border-bottom: 1px solid var(--border-subtle); font-size: var(--fs-sm); }
.activity li:last-child { border-bottom: 0; }
.activity .who { width: 28px; height: 28px; border-radius: 50%; background: var(--bg-surface-muted); display: grid; place-items: center; font-weight: 600; font-size: var(--fs-xs); color: var(--text-secondary); flex: none; }
.activity .who.screen { background: var(--status-info-soft); color: var(--status-info-strong); }
.activity .who.system { background: var(--status-neutral-soft); color: var(--status-neutral); }
.activity time { color: var(--text-muted); font-size: var(--fs-xs); }
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: var(--radius-xl); padding: 32px 20px; text-align: center; color: var(--text-muted); cursor: pointer; background: var(--bg-surface-subtle); transition: border-color var(--dur-fast), background var(--dur-fast); }
.dropzone:hover { border-color: var(--text-faint); }
.dropzone.over { border-color: var(--accent-primary); background: var(--accent-primary-soft); }
.dropzone .ic { width: 28px; height: 28px; color: var(--accent-primary); }
.uplist { margin-top: 14px; display: flex; flex-direction: column; gap: var(--space-2); max-height: 280px; overflow: auto; }
.upitem { border: 1px solid var(--border-default); border-radius: var(--radius-md); padding: 9px 11px; }
.upitem .row-between { font-size: var(--fs-sm); }
.popover { position: absolute; z-index: 150; width: 380px; max-width: calc(100vw - 24px); background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); overflow: hidden; animation: pop 160ms var(--ease-out); }
.popover .activity { max-height: 420px; overflow: auto; }
.code-input { font-family: var(--font-mono); font-size: 30px !important; height: 58px !important; letter-spacing: 0.35em; text-align: center; text-transform: uppercase; font-weight: 700; }
.preview-frame { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: var(--radius-lg); background: var(--bg-media); display: block; }
.copybox { display: flex; gap: 6px; align-items: center; background: var(--bg-surface-subtle); border: 1px solid var(--border-default); border-radius: var(--radius-md); padding: 6px 6px 6px 10px; font-family: var(--font-mono); font-size: var(--fs-sm); }

/* editor (playlist) shared bits */
.editor { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: var(--space-4); align-items: start; }
@media (max-width: 1100px) { .editor { grid-template-columns: 1fr; } }
.items { list-style: none; margin: 0; padding: var(--space-2); display: flex; flex-direction: column; gap: 6px; min-height: 80px; }
.item { display: flex; align-items: center; gap: 10px; padding: var(--space-2) 10px; border: 1px solid var(--border-default); border-radius: var(--radius-lg); background: var(--bg-surface); }
.item.dragging { opacity: 0.45; }
.item.drop-before { box-shadow: 0 -3px 0 var(--accent-primary); }
.item.drop-after { box-shadow: 0 3px 0 var(--accent-primary); }
.item.hidden-item { background: var(--bg-surface-subtle); opacity: 0.75; }
.item .handle { cursor: grab; color: var(--text-muted); display: grid; place-items: center; width: 22px; }
.item .pos { width: 22px; text-align: center; font-weight: 600; color: var(--text-muted); font-size: var(--fs-xs); }
.item .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: var(--fs-xs); color: var(--text-muted); margin-top: 3px; }
.item .meta select, .item .meta input { height: 28px; font-size: var(--fs-xs); padding: 0 7px; width: auto; }
.item .meta select { padding-right: 26px; background-position: right 6px center; background-size: 14px; }
.item .meta input.dur { width: 64px; }
.item .meta .unit { margin-left: -4px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 14px; max-height: 380px; overflow: auto; }
.lib-card { border: 1px solid var(--border-default); border-radius: var(--radius-lg); overflow: hidden; background: var(--bg-surface); cursor: pointer; text-align: left; padding: 0; display: flex; flex-direction: column; }
.lib-card:hover { border-color: var(--accent-primary-border); }
.lib-card:disabled { cursor: not-allowed; opacity: 0.55; }
.lib-card .thumb { width: 100%; height: 84px; border-radius: 0; }
.lib-card .lib-meta { padding: 7px 9px; font-size: var(--fs-xs); }
.lib-card .lib-name { font-weight: 600; font-size: var(--fs-sm); color: var(--text-primary); }
.pick-list { max-height: 360px; overflow: auto; border: 1px solid var(--border-default); border-radius: var(--radius-lg); }
.pick { display: flex; align-items: center; gap: var(--space-3); padding: 10px 12px; border-bottom: 1px solid var(--border-subtle); cursor: pointer; }
.pick:last-child { border-bottom: 0; }
.pick:hover { background: var(--bg-surface-hover); }
.pick input { width: 16px; height: 16px; }
.pick .order { margin-left: auto; font-weight: 600; color: var(--accent-primary); }

/* ========================================================= DASHBOARD === */
.dash { display: flex; flex-direction: column; gap: var(--space-4); }
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); padding: var(--space-4) 0 var(--space-2); }
.dash-head h1 { font-size: var(--fs-page); font-weight: 700; letter-spacing: -0.022em; line-height: 1.15; }
.dash-head p { margin-top: 6px; color: var(--text-muted); font-size: 17px; letter-spacing: -0.005em; }
.dash-head-right { display: flex; align-items: center; gap: var(--space-5); }
.clock { text-align: right; line-height: 1.2; }
.clock .clock-date { font-size: var(--fs-xs); color: var(--text-muted); }
.clock .clock-time { font-size: 20px; font-weight: 700; color: var(--text-heading); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; margin-top: 2px; }

/* KPI row */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-4); }
.kpi { position: relative; display: flex; flex-direction: column; padding: var(--space-4) var(--space-5) var(--space-4); box-shadow: var(--shadow-sm); color: inherit; transition: border-color var(--dur-fast), box-shadow var(--dur-fast); }
a.kpi:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.kpi-head { display: flex; align-items: center; gap: 10px; }
.kpi-head h3 { font-size: 15px; font-weight: 600; }
.kpi-body { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-3); }
.kpi-value { font-size: var(--fs-kpi); font-weight: 700; color: var(--text-heading); letter-spacing: -0.035em; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-foot { display: flex; align-items: baseline; gap: 6px; margin-top: 10px; font-size: var(--fs-sm); color: var(--text-muted); white-space: nowrap; }
.kpi-foot b { font-weight: 700; font-size: 15px; }
.kpi-foot .ic { width: 14px; height: 14px; align-self: center; }

.ic-chip { width: 34px; height: 34px; border-radius: var(--radius-lg); display: grid; place-items: center; flex: none; background: var(--bg-surface-muted); color: var(--text-secondary); }
.ic-chip .ic { width: 17px; height: 17px; }
.ic-chip.round { border-radius: 50%; }
.tone-accent { background: var(--accent-primary-soft); color: var(--accent-primary); }
.tone-success { background: var(--status-success-soft); color: var(--status-success); }
.tone-info { background: var(--status-info-soft); color: var(--status-info); }
.tone-warning { background: var(--status-warning-soft); color: var(--status-warning); }
.tone-danger { background: var(--status-danger-soft); color: var(--status-danger); }
.tone-neutral { background: var(--status-neutral-soft); color: var(--status-neutral); }
.t-success { color: var(--status-success); }
.t-info { color: var(--status-info); }
.t-warning { color: var(--status-warning); }
.t-danger { color: var(--status-danger); }
.t-muted { color: var(--text-muted); }

/* donut */
.donut { width: 58px; height: 58px; flex: none; transform: rotate(-90deg); }
.donut circle { fill: none; stroke-width: 7; }
.donut .d-track { stroke: var(--bg-surface-muted); }
.donut .d-arc { stroke-linecap: round; transition: stroke-dasharray 400ms var(--ease-out); }
.donut.success .d-arc { stroke: var(--status-success-fill); }
.donut.info .d-arc { stroke: var(--status-info-fill); }
.donut.danger .d-arc { stroke: var(--status-danger-fill); }
.donut.warning .d-arc { stroke: var(--status-warning-fill); }

/* row 2 */
.dash-row { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(300px, 0.95fr); gap: var(--space-4); align-items: stretch; }
.dash-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 0.42fr); gap: var(--space-4); align-items: start; }
.dash-main > .dash-left, .dash-main > .dash-right { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.dash-left .health-storage { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--space-4); }

.health .card-pad { display: flex; flex-direction: column; gap: var(--space-5); height: calc(100% - 56px); }
.health-legend { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); }
.health-legend a { color: inherit; display: block; border-radius: var(--radius-md); padding: 2px 4px; margin: -2px -4px; }
.health-legend a:hover { text-decoration: none; background: var(--bg-surface-hover); }
.hl-top { display: flex; align-items: center; gap: var(--space-2); font-size: 18px; font-weight: 650; color: var(--text-heading); font-variant-numeric: tabular-nums; }
.hl-top i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.hl-label { font-size: var(--fs-sm); color: var(--text-muted); margin: 2px 0 0 18px; }
.health .btn { margin-top: auto; justify-content: space-between; height: var(--control-h-lg); font-size: var(--fs-md); }
.health .btn .ic { width: 18px; height: 18px; }

.storage-card .card-pad { display: flex; flex-direction: column; gap: var(--space-4); }
.storage-value { display: flex; align-items: baseline; gap: 6px; }
.storage-value b { font-size: 28px; font-weight: 700; color: var(--text-heading); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.storage-value span { font-size: var(--fs-lg); color: var(--text-muted); }
.storage-bar { display: flex; align-items: center; gap: var(--space-3); }
.storage-bar .progress { flex: 1; }
.storage-bar .pct { font-size: var(--fs-sm); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); color: var(--text-muted); }
.legend div { display: flex; align-items: center; gap: var(--space-2); }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend b { font-weight: 500; color: var(--text-secondary); margin-left: 2px; }
.lg-used { background: var(--accent-primary); }
.lg-free { background: var(--border-strong); }

/* setup checklist */
.setup-list { list-style: none; margin: 0; padding: var(--space-2) var(--space-3) var(--space-3); }
.setup-step { display: flex; align-items: flex-start; gap: var(--space-3); padding: 10px var(--space-2); border-radius: var(--radius-md); color: inherit; }
a.setup-step:hover { background: var(--bg-surface-hover); text-decoration: none; }
.setup-step .ss-ic { width: 24px; height: 24px; margin-top: 1px; flex: none; color: var(--border-strong); }
.setup-step.done .ss-ic { color: var(--status-success-fill); }
.setup-step b { display: block; font-size: var(--fs-md); font-weight: 650; color: var(--text-primary); }
.setup-step span { display: block; font-size: var(--fs-sm); color: var(--text-muted); margin-top: 1px; }
.setup-step.done b { color: var(--text-primary); }
.setup-step .ss-go { margin-left: auto; align-self: center; color: var(--accent-primary); font-size: var(--fs-xs); font-weight: 600; display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }
.setup-step .ss-go .ic { width: 14px; height: 14px; }
.setup-progress { height: 4px; margin: 0 var(--space-5); border-radius: var(--radius-full); background: var(--bg-surface-muted); overflow: hidden; }
.setup-progress span { display: block; height: 100%; background: var(--status-success-fill); border-radius: var(--radius-full); }

/* screens card */
.screens-card .card-head { border-bottom: 0; }
.screens-card .tabs { padding: 0 var(--space-5); margin-bottom: 0; }
.screens-card .sc-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: var(--space-4) var(--space-5); }
.screens-card .sc-tools .search { width: 220px; }
.screens-card .sc-tools select { width: auto; min-width: 128px; }
.screens-card .sc-tools .segmented { margin-left: auto; }
.screens-card .table-shell { margin: 0 var(--space-5) var(--space-5); border: 1px solid var(--border-default); border-radius: var(--radius-lg); overflow: hidden; }
.screens-card .table-shell .table-wrap { max-height: 520px; overflow: auto; }
.screen-cell { display: flex; align-items: center; gap: var(--space-3); min-width: 200px; }
.screen-thumb { width: 52px; height: 32px; border-radius: var(--radius-xs); background: var(--bg-surface-muted); border: 1px solid var(--border-default); overflow: hidden; display: grid; place-items: center; color: var(--text-faint); flex: none; }
.screen-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.screen-thumb .ic { width: 16px; height: 16px; }
.screen-cell .cell-sub { white-space: nowrap; }
.np-cell .cell-title { font-weight: 500; }
.np-cell .cell-sub { font-variant-numeric: tabular-nums; }
.screens-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-3); padding: 0 var(--space-5) var(--space-5); }
.screen-tile { display: flex; flex-direction: column; border: 1px solid var(--border-default); border-radius: var(--radius-lg); overflow: hidden; background: var(--bg-surface); color: inherit; transition: border-color var(--dur-fast), box-shadow var(--dur-fast); }
.screen-tile:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.screen-tile .st-media { aspect-ratio: 16 / 9; background: var(--bg-surface-muted); display: grid; place-items: center; color: var(--text-faint); position: relative; }
.screen-tile .st-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.screen-tile .st-media .badge { position: absolute; left: 8px; top: 8px; }
.screen-tile .st-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.screen-tile .st-meta { display: flex; justify-content: space-between; gap: var(--space-2); font-size: var(--fs-xs); color: var(--text-muted); margin-top: 4px; }

/* side cards */
.feed { list-style: none; margin: 0; padding: var(--space-1) 0; }
.feed li > a, .feed li > div { display: flex; align-items: flex-start; gap: var(--space-3); padding: 10px var(--space-5); color: inherit; }
.feed li + li > a, .feed li + li > div { border-top: 1px solid var(--border-subtle); }
.feed li > a:hover { background: var(--bg-surface-hover); text-decoration: none; }
.feed .f-text { flex: 1; min-width: 0; font-size: var(--fs-sm); color: var(--text-primary); line-height: 1.4; }
.feed .f-sub { display: block; font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }
.feed .f-title { display: block; font-weight: 600; font-size: var(--fs-sm); }
.feed .ic-chip { width: 30px; height: 30px; }
.feed .ic-chip .ic { width: 15px; height: 15px; }
.feed .f-chev { width: 16px; height: 16px; color: var(--text-faint); align-self: center; }
.all-clear { display: flex; gap: var(--space-3); align-items: center; padding: var(--space-4) var(--space-5) var(--space-5); }
.all-clear b { display: block; font-size: var(--fs-sm); }
.all-clear span { font-size: var(--fs-xs); color: var(--text-muted); }

/* responsive dashboard */
@media (max-width: 1440px) {
  .kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .kpi { padding: var(--space-4); }
  .donut { width: 48px; height: 48px; }
}
@media (max-width: 1320px) {
  .dash-main { grid-template-columns: minmax(0, 1fr); }
  .dash-main > .dash-right { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .dash-main > .dash-right > .setup-card { grid-column: 1 / -1; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .screens-card .table th.th-loc, .screens-card .table td.td-loc { display: none; }
}
@media (max-width: 900px) {
  .dash-left .health-storage { grid-template-columns: minmax(0, 1fr); }
  .dash-main > .dash-right { grid-template-columns: minmax(0, 1fr); }
  .dash-head { flex-direction: column; align-items: flex-start; }
  .dash-head-right { width: 100%; justify-content: space-between; }
  .clock { text-align: left; }
}
@media (max-width: 760px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
  .kpis .kpi:first-child { grid-column: 1 / -1; }
  .kpi .donut { display: none; }
  .kpi-foot { white-space: normal; flex-wrap: wrap; }
  .screens-card .table-shell .table-wrap { max-height: none; overflow: visible; }
  .dash-head h1 { font-size: 24px; }
  .dash-head p { font-size: var(--fs-md); }
  .kpi-value { font-size: 26px; }
  .health-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: var(--space-4); }
  .screens-card .card-head .link-arrow { display: none; }
  .screens-card .sc-tools { padding: var(--space-3) var(--space-4); }
  .screens-card .sc-tools .search { width: 100%; }
  .screens-card .sc-tools select { flex: 1 1 calc(33% - 10px); min-width: 0; }
  .screens-card .sc-tools .segmented { display: none; }
  .screens-card .tabs { padding: 0 var(--space-4); }
  .screens-card .table-shell { margin: 0 var(--space-4) var(--space-4); border: 0; border-radius: 0; overflow: visible; }
  /* table → stacked list */
  .screens-card .table thead { display: none; }
  .screens-card .table, .screens-card .table tbody { display: block; }
  .screens-card .table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; padding: 12px; border: 1px solid var(--border-default); border-radius: var(--radius-lg); margin-bottom: var(--space-2); }
  .screens-card .table td { display: block; padding: 0; border: 0; background: none !important; }
  .screens-card .table td.td-screen { grid-column: 1; }
  .screens-card .table td.td-status { grid-column: 2; grid-row: 1; justify-self: end; align-self: center; }
  .screens-card .table td.td-np { grid-column: 1 / -1; }
  .screens-card .table td.td-group, .screens-card .table td.td-loc { display: none; }
  .screens-card .table td.td-seen { grid-column: 1; font-size: var(--fs-xs); color: var(--text-muted); }
  .screens-card .table td.td-seen::before { content: 'Last seen '; }
  .screens-card .table td.w-act { grid-column: 2; grid-row: 3; text-align: right; }
  .screens-card .table td.w-act .icon-btn { width: 32px; height: 32px; }
}

/* ============================================================== PRINT === */
.print-only { display: none; }
@media print {
  .sidebar, .topbar, .tabs, .no-print, .toolbar .segmented, #toasts, .bulkbar, .page-header .no-print { display: none !important; }
  .app { display: block; }
  .content { padding: 0; max-width: none; }
  .print-only { display: block; margin-bottom: 12px; }
  .card { box-shadow: none; break-inside: avoid; }
  .table-wrap { overflow: visible; }
  .table th { position: static; }
  body { background: var(--bg-surface); }
}
