/* Studio panel: dark first, light from the system setting. No framework, no build step. */
:root {
  --bg: #090a0f;
  --bg-glow: radial-gradient(1200px 600px at 85% -10%, rgba(110, 86, 255, .16), transparent 60%),
             radial-gradient(900px 500px at -10% 110%, rgba(47, 140, 255, .10), transparent 60%);
  --surface: #11131b;
  --surface-2: #171a25;
  --surface-3: #1e2230;
  --line: rgba(255, 255, 255, .07);
  --line-strong: rgba(255, 255, 255, .13);
  --text: #eceef6;
  --text-2: #b7bdd0;
  --muted: #7d859c;
  --accent: #7c5cff;
  --accent-2: #2f8cff;
  --accent-grad: linear-gradient(135deg, #7c5cff 0%, #4f6bff 50%, #2f8cff 100%);
  --accent-soft: rgba(124, 92, 255, .14);
  --ok: #34c88f;
  --ok-soft: rgba(52, 200, 143, .14);
  --warn: #f5b544;
  --warn-soft: rgba(245, 181, 68, .14);
  --bad: #ff5d6c;
  --bad-soft: rgba(255, 93, 108, .14);
  --info: #4aa8ff;
  --info-soft: rgba(74, 168, 255, .14);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 20px 40px -24px rgba(0, 0, 0, .6);
  --sidebar: 252px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6fa;
    --bg-glow: radial-gradient(1200px 600px at 85% -10%, rgba(124, 92, 255, .10), transparent 60%),
               radial-gradient(900px 500px at -10% 110%, rgba(47, 140, 255, .07), transparent 60%);
    --surface: #ffffff;
    --surface-2: #f7f8fc;
    --surface-3: #eef0f6;
    --line: rgba(15, 20, 40, .08);
    --line-strong: rgba(15, 20, 40, .14);
    --text: #12141c;
    --text-2: #3d4356;
    --muted: #6b7286;
    --accent-soft: rgba(124, 92, 255, .10);
    --shadow: 0 1px 2px rgba(15, 20, 40, .04), 0 12px 32px -20px rgba(15, 20, 40, .25);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  background-image: var(--bg-glow);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.5 var(--font);
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img, video, svg { display: block; max-width: 100%; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; line-height: 1.2; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ----------------------------------------------------------------- app shell */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 6px;
  padding: 22px 14px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 20px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--accent-grad);
  display: grid; place-items: center; box-shadow: 0 8px 22px -8px rgba(124, 92, 255, .7);
}
.brand-mark svg { width: 18px; height: 18px; color: #fff; }
.brand-name { font-weight: 700; letter-spacing: -.02em; font-size: 16px; }
.brand-sub { color: var(--muted); font-size: 12px; margin-top: -2px; }
.nav-label { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--text-2); font-weight: 500; font-size: 14px;
  transition: background .15s, color .15s;
}
.nav a svg { width: 18px; height: 18px; opacity: .8; flex: none; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--text); }
.nav a.active svg { color: var(--accent); opacity: 1; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; }
.me { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff;
  background: linear-gradient(135deg, #ff8a5c, #ff5d9e);
}
.avatar.alt { background: linear-gradient(135deg, #2fd6b4, #2f8cff); }
.me-name { font-weight: 600; font-size: 14px; line-height: 1.2; }
.me-role { color: var(--muted); font-size: 12px; }
.linkbtn { background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.linkbtn:hover { color: var(--text); background: var(--surface-2); }

.main { min-width: 0; padding: 30px clamp(16px, 4vw, 44px) 60px; }
.topbar { display: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 26px; }
.page-head p { color: var(--muted); margin-top: 6px; }
.crumbs { color: var(--muted); font-size: 13px; margin-bottom: 8px; display: flex; gap: 6px; align-items: center; }
.crumbs a:hover { color: var(--text); }

/* mobile drawer (no JavaScript: a checkbox opens it) */
#nav-toggle { display: none; }
@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(84vw, 300px);
    transform: translateX(-102%); transition: transform .22s ease;
    background: var(--surface);
  }
  #nav-toggle:checked ~ .shell .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .5); }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 30; padding: 12px 16px;
    background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
  }
  .topbar label { cursor: pointer; padding: 6px; border-radius: 8px; }
  .topbar label svg { width: 22px; height: 22px; }
  .main { padding-top: 20px; }
  h1 { font-size: 22px; }
}

/* ----------------------------------------------------------------- building blocks */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head p { color: var(--muted); font-size: 13px; margin-top: 3px; }
.stack { display: grid; gap: 18px; }
.grid { display: grid; gap: 18px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .cols-main { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .cols-2, .cols-3 { grid-template-columns: 1fr; } }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; border: 0; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { position: relative; overflow: hidden; }
.stat::after {
  content: ""; position: absolute; inset: auto -30% -60% auto; width: 160px; height: 160px; border-radius: 50%;
  background: var(--accent-soft); filter: blur(10px); pointer-events: none;
}
.stat-label { color: var(--muted); font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.stat-label svg { width: 16px; height: 16px; color: var(--accent); }
.stat-value { font-size: 30px; font-weight: 700; letter-spacing: -.03em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 15px; color: var(--muted); font-weight: 600; margin-left: 3px; }
.stat-foot { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* buttons and inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 15px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--text); font: 600 14px var(--font); cursor: pointer;
  transition: transform .06s, background .15s, border-color .15s, box-shadow .15s; white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-3); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent-grad); border-color: transparent; color: #fff; box-shadow: 0 10px 24px -12px rgba(124, 92, 255, .9); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; height: 44px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .help { font-size: 12px; color: var(--muted); }
.field .err { font-size: 13px; color: var(--bad); }
input[type=text], input[type=password], input[type=email], input[type=search], input[type=number], select, textarea {
  width: 100%; height: 42px; padding: 0 13px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
  font: 15px var(--font); outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 11px 13px; resize: vertical; min-height: 84px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
input[type=file] { font: 14px var(--font); color: var(--text-2); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-2); }
.color-field { display: flex; gap: 10px; align-items: center; }
.color-field input[type=color] { width: 42px; height: 42px; padding: 0; border: 1px solid var(--line-strong); border-radius: 10px; background: none; cursor: pointer; flex: none; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.toolbar input[type=search] { max-width: 320px; }
.toolbar select { width: auto; min-width: 150px; }

/* pills and tabs */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 99px;
  font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.plain::before { display: none; }
.pill.live::before { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.tabs { display: inline-flex; padding: 4px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.tabs a { padding: 6px 13px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted); }
.tabs a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding: 0 12px 10px; white-space: nowrap; }
td { padding: 13px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.person { display: flex; align-items: center; gap: 11px; min-width: 180px; }
.person .avatar { width: 32px; height: 32px; font-size: 12px; }
.bar-cell { min-width: 120px; }
.meter { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 99px; background: var(--accent-grad); }

/* chart */
.chart { position: relative; height: 180px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart .bar { fill: url(#barGrad); transition: opacity .15s; }
.chart .bar.zero { fill: var(--surface-3); }
.chart g:hover .bar { opacity: .75; }
.chart-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 8px; }

/* video grid */
.videos { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; }
.video-card { display: block; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); overflow: hidden; box-shadow: var(--shadow); transition: transform .18s ease, border-color .18s; }
.video-card:hover { transform: translateY(-3px); border-color: var(--line-strong); }
.cover { position: relative; aspect-ratio: 9 / 13; background: var(--surface-3); overflow: hidden; }
.cover img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; }
.cover .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); background:
  radial-gradient(circle at 30% 20%, var(--accent-soft), transparent 55%), var(--surface-2); }
.cover .ph svg { width: 34px; height: 34px; opacity: .6; }
.cover .pill { position: absolute; z-index: 2; top: 10px; left: 10px; backdrop-filter: blur(8px); }
.cover .dur { position: absolute; z-index: 2; bottom: 10px; right: 10px; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; color: #fff; background: rgba(0, 0, 0, .55); backdrop-filter: blur(6px); }
.video-meta { padding: 13px 14px 15px; }
.video-meta h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.video-meta .muted { font-size: 13px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.player { border-radius: var(--radius); overflow: hidden; background: #000; border: 1px solid var(--line); }
.player video { width: 100%; max-height: 72vh; margin: 0 auto; background: #000; }

/* lists */
.list { display: grid; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; padding-top: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-tile { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex: none; }
.icon-tile svg { width: 18px; height: 18px; }
.icon-tile.accent { background: var(--accent-soft); color: var(--accent); }
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--line); border-radius: 2px; }
.tl-item { position: relative; padding: 0 0 16px; }
.tl-item::before { content: ""; position: absolute; left: -19px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.tl-item.sys::before { border-color: var(--muted); }

.swatches { display: flex; gap: 8px; }
.swatch { width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--line-strong); }
.client-card { display: flex; gap: 14px; align-items: center; }
.client-logo { width: 52px; height: 52px; border-radius: 14px; flex: none; display: grid; place-items: center; overflow: hidden; font-weight: 800; font-size: 18px; color: #fff; }
.client-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }

/* copy box */
.copybox { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 13px; border-radius: 11px; border: 1px solid var(--line-strong); background: var(--surface-2); }
.copybox code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.steps { counter-reset: step; display: grid; gap: 18px; }
.step { position: relative; padding-left: 46px; }
.step::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: -2px; width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff; background: var(--accent-grad);
}
.step h3 { margin-bottom: 4px; }
.step p { color: var(--text-2); font-size: 14px; }

/* empty states, banners, messages */
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty .icon-tile { margin: 0 auto 14px; width: 52px; height: 52px; border-radius: 15px; }
.empty .icon-tile svg { width: 24px; height: 24px; }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.banner { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--line); background:
  linear-gradient(120deg, var(--accent-soft), transparent 70%), var(--surface); margin-bottom: 18px; }
.banner .grow { flex: 1; min-width: 200px; }
.messages { position: fixed; z-index: 60; right: 18px; bottom: 18px; display: grid; gap: 10px; max-width: min(420px, calc(100vw - 36px)); }
.toast { padding: 13px 16px; border-radius: 12px; background: var(--surface-3); border: 1px solid var(--line-strong); box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .6); font-size: 14px; animation: toast-in .25s ease; }
.toast.success { border-left: 3px solid var(--ok); }
.toast.error { border-left: 3px solid var(--bad); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.pagination { display: flex; gap: 8px; justify-content: center; margin-top: 22px; }

/* auth screens */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(420px, 100%); }
.auth-card .brand { justify-content: center; padding-bottom: 26px; }
.auth-card .card { padding: 28px; }
.auth-card h1 { font-size: 22px; text-align: center; }
.auth-card .lead { text-align: center; color: var(--muted); margin: 8px 0 22px; font-size: 14px; }
.form-error { padding: 11px 13px; border-radius: 10px; background: var(--bad-soft); color: var(--bad); font-size: 14px; margin-bottom: 16px; }
.consent-app { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 6px 0 20px; }
.consent-app .icon-tile { width: 52px; height: 52px; border-radius: 15px; }
.consent-app .icon-tile svg { width: 24px; height: 24px; }
.consent-list { display: grid; gap: 10px; margin: 0 0 22px; padding: 0; list-style: none; font-size: 14px; color: var(--text-2); }
.consent-list li { display: flex; gap: 10px; align-items: flex-start; }
.consent-list svg { width: 18px; height: 18px; color: var(--ok); flex: none; margin-top: 1px; }
.linkbtn.row { display: flex; align-items: center; gap: 8px; width: 100%; }
.linkbtn svg { width: 16px; height: 16px; flex: none; }
.center-note { text-align: center; margin-top: 18px; }
