:root {
  color-scheme: dark;
  --bg: #06101c;
  --bg-soft: #091522;
  --panel: rgba(13, 28, 44, .88);
  --panel-strong: #0e1d2d;
  --line: rgba(169, 194, 218, .12);
  --line-strong: rgba(169, 194, 218, .23);
  --text: #eef5fb;
  --muted: #91a5b8;
  --teal: #5eead4;
  --blue: #8294ff;
  --gold: #f6c86e;
  --pink: #f39ab7;
  --red: #ff7f8d;
  --green: #86efac;
  --shadow: 0 24px 70px rgba(0, 0, 0, .28);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 85% -10%, rgba(74, 95, 175, .22), transparent 38%),
    radial-gradient(circle at 35% 105%, rgba(37, 132, 128, .14), transparent 35%),
    var(--bg);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 14px;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: "Manrope", system-ui, sans-serif; }
h1 { margin-bottom: 0; font-size: clamp(1.55rem, 3vw, 2.1rem); letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: 1.1rem; letter-spacing: -.025em; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 6px; color: #7290a7; font-size: .69rem; font-weight: 700; letter-spacing: .16em; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 230px;
  display: flex;
  flex-direction: column;
  padding: 28px 18px 22px;
  border-right: 1px solid var(--line);
  background: rgba(5, 14, 25, .88);
  backdrop-filter: blur(24px);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.brand strong { display: block; font: 700 1rem/1.1 "Manrope"; letter-spacing: -.02em; }
.brand small { display: block; margin-top: 5px; color: #7290a7; font-size: .56rem; font-weight: 700; letter-spacing: .13em; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto;
  border: 1px solid rgba(94, 234, 212, .3); border-radius: 13px;
  color: var(--teal); background: linear-gradient(145deg, rgba(94, 234, 212, .14), rgba(130, 148, 255, .12));
  box-shadow: inset 0 1px rgba(255,255,255,.08), 0 10px 25px rgba(0,0,0,.2);
  font: 700 .88rem "Manrope";
}
.nav-list { display: grid; gap: 7px; margin-top: 44px; }
.nav-item {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 13px;
  border: 1px solid transparent; border-radius: 12px; color: #8ea2b5; background: transparent;
  cursor: pointer; text-align: left; transition: .18s ease;
}
.nav-item span { width: 22px; color: #6e879c; font-size: 1.05rem; text-align: center; }
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.035); }
.nav-item.active { color: var(--text); border-color: rgba(94,234,212,.13); background: linear-gradient(90deg, rgba(94,234,212,.11), rgba(94,234,212,.025)); box-shadow: inset 3px 0 var(--teal); }
.nav-item.active span { color: var(--teal); }
.sidebar-foot { margin-top: auto; }
.privacy-chip { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.025); }
.privacy-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px rgba(134,239,172,.6); }
.privacy-chip span { color: var(--muted); font-size: .72rem; }
.privacy-chip strong { display: block; margin-top: 2px; color: #c6d5e2; font-size: .69rem; font-weight: 500; }
.sidebar-foot .text-button { margin: 14px 10px 0; }

.workspace { min-height: 100vh; margin-left: 230px; padding: 28px clamp(18px, 3vw, 44px) 60px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 40px;
  padding: 0 16px; border: 1px solid transparent; border-radius: 11px; cursor: pointer;
  font-weight: 650; transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .5; cursor: wait; }
.button-primary { color: #061319; background: linear-gradient(135deg, #79f3df, #64caba); box-shadow: 0 12px 26px rgba(67, 201, 182, .16); }
.button-secondary { border-color: var(--line-strong); color: #c8d5df; background: rgba(255,255,255,.035); }
.button-danger { border-color: rgba(255,127,141,.26); color: #ffadb6; background: rgba(255,127,141,.08); }
.button-full { width: 100%; }
.text-button { padding: 0; border: 0; color: #8da3b7; background: none; cursor: pointer; }
.text-button:hover { color: var(--teal); }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: rgba(255,255,255,.04); cursor: pointer; font-size: 1.45rem; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; color: #9eb0c1; background: rgba(255,255,255,.025); font-size: .72rem; white-space: nowrap; }
.status-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.status-pill.good { color: #a7f3d0; border-color: rgba(94,234,212,.2); background: rgba(94,234,212,.07); }
.status-pill.bad { color: #ffb1ba; border-color: rgba(255,127,141,.25); background: rgba(255,127,141,.07); }

.page-section { display: none; animation: section-in .22s ease both; }
.page-section.active { display: block; }
@keyframes section-in { from { opacity: 0; transform: translateY(5px); } }
.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.metric-card {
  position: relative; overflow: hidden; min-height: 122px; padding: 20px; border: 1px solid var(--line);
  border-radius: 16px; background: linear-gradient(145deg, rgba(17,34,52,.95), rgba(9,22,36,.86));
  box-shadow: 0 14px 45px rgba(0,0,0,.13);
}
.metric-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent); }
.metric-card::after { content: ""; position: absolute; width: 100px; height: 100px; top: -55px; right: -40px; border-radius: 50%; background: var(--accent); opacity: .08; filter: blur(6px); }
.accent-teal { --accent: var(--teal); } .accent-gold { --accent: var(--gold); } .accent-blue { --accent: var(--blue); } .accent-pink { --accent: var(--pink); }
.metric-label { display: block; color: #8ea3b6; font-size: .76rem; }
.metric-card strong { display: block; margin: 9px 0 7px; font: 700 1.75rem/1 "Manrope"; letter-spacing: -.04em; }
.metric-card small { color: #6f879c; }

.overview-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(300px, .75fr); gap: 16px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, rgba(14,29,45,.94), rgba(8,20,33,.91)); box-shadow: var(--shadow); }
.panel:not(.office-panel) { padding: 22px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.office-panel { overflow: hidden; }
.office-panel .panel-head { padding: 22px 22px 0; }
.legend { display: flex; gap: 12px; color: #7790a5; font-size: .68rem; }
.legend span { display: flex; align-items: center; gap: 5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; }
.dot.working { background: var(--teal); }.dot.idle { background: #61788c; }.dot.error { background: var(--red); }
.office-game { position: relative; width: 100%; aspect-ratio: 16/7.4; min-height: 330px; overflow: hidden; background: #081523; }
.office-game canvas { width: 100% !important; height: 100% !important; object-fit: cover; }
.agent-strip { display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--line); background: rgba(4,13,23,.6); }
.agent-mini { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 9px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.agent-mini:nth-child(5n) { border-right: 0; }
.agent-avatar { width: 25px; height: 25px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 8px; color: #07111f; font-size: .62rem; font-weight: 800; background: var(--agent-color); }
.agent-mini span { min-width: 0; }
.agent-mini strong, .agent-mini small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.agent-mini strong { font-size: .69rem; }.agent-mini small { margin-top: 1px; color: #71899d; font-size: .61rem; }
.agent-mini[data-state="working"] { background: rgba(94,234,212,.04); }
.agent-mini[data-state="working"] small { color: var(--teal); }
.agent-mini[data-state="error"] small { color: var(--red); }

.resource-panel { min-width: 0; }
.gauge-list { display: grid; gap: 15px; margin-top: 24px; }
.gauge-row { display: grid; grid-template-columns: 42px 1fr 42px; gap: 10px; align-items: center; color: #8ca1b3; font-size: .7rem; }
.gauge-row strong { color: #c6d3de; font-size: .7rem; text-align: right; }
.gauge { height: 6px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.06); }
.gauge i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), var(--blue)); transition: width .35s ease; }
.resource-summary { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }
.resource-summary span { padding: 0 10px; border-right: 1px solid var(--line); }
.resource-summary span:first-child { padding-left: 0; }.resource-summary span:last-child { border: 0; }
.resource-summary small, .resource-summary strong { display: block; }
.resource-summary small { color: #728a9f; font-size: .63rem; }.resource-summary strong { margin-top: 5px; font-size: .76rem; }
.resource-note { margin: 21px 0 0; padding: 12px; border-radius: 11px; color: #8ca1b3; background: rgba(255,255,255,.025); font-size: .7rem; line-height: 1.45; }
.queue-panel { margin-top: 16px; }
.pipeline { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; color: #8096a8; font-size: .66rem; }
.pipeline span { padding: 6px 9px; border: 1px solid var(--line); border-radius: 99px; background: rgba(255,255,255,.02); }
.pipeline i { height: 1px; flex: 1; background: linear-gradient(90deg, rgba(94,234,212,.35), rgba(130,148,255,.13)); }
.job-list { display: grid; gap: 8px; }
.job-list-scroll { max-height: 525px; overflow: auto; padding-right: 4px; }
.job-row { display: grid; grid-template-columns: minmax(130px, 1fr) minmax(120px, 2fr) 105px; gap: 14px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.018); }
.job-title strong, .job-title small { display: block; }.job-title strong { font-size: .78rem; }.job-title small { margin-top: 3px; color: #71899d; font-size: .65rem; }
.job-progress { height: 5px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.06); }.job-progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--blue)); }
.job-state { color: #8ba1b4; font-size: .69rem; text-align: right; }
.job-state.failed { color: var(--red); }.job-state.completed { color: var(--green); }.job-state.running { color: var(--teal); }
.empty-state { padding: 30px; border: 1px dashed var(--line-strong); border-radius: 14px; color: #7890a4; text-align: center; }

.section-grid { display: grid; gap: 16px; }
.form-layout { grid-template-columns: minmax(380px, .9fr) minmax(420px, 1.1fr); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.form-grid label, .form-stack label { display: grid; gap: 7px; color: #8ea3b7; font-size: .71rem; font-weight: 600; }
.span-2 { grid-column: span 2; }
input, select, textarea {
  width: 100%; min-height: 43px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px;
  outline: 0; color: var(--text); background: rgba(3,12,22,.55); transition: border-color .16s, box-shadow .16s;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: rgba(94,234,212,.55); box-shadow: 0 0 0 3px rgba(94,234,212,.07); }
input[type="checkbox"] { width: 18px; min-height: 18px; accent-color: var(--teal); }
.check-row { display: flex !important; align-items: flex-start; gap: 9px !important; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.018); }
.check-row span { color: #c2d0dc; }.check-row small { display: block; margin-top: 3px; color: #71889c; font-weight: 400; }
.form-actions { display: flex; align-items: center; gap: 15px; padding-top: 3px; }.form-actions span { color: #6f879b; font-size: .65rem; }
.file-drop { padding: 19px; border: 1px dashed var(--line-strong); border-radius: 12px; background: rgba(255,255,255,.018); }.file-drop input { min-height: auto; padding: 0; border: 0; background: none; }.file-drop span { color: #6f879b; font-weight: 400; }
progress { width: 160px; height: 6px; accent-color: var(--teal); }
.table-panel { margin-top: 16px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: #70899e; font-size: .64rem; letter-spacing: .08em; text-transform: uppercase; }
td { color: #a8bac9; font-size: .72rem; }
td strong, td small { display: block; } td strong { color: #d9e4ec; } td small { margin-top: 3px; color: #6c8498; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.table-action { padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; color: #9eb3c4; background: rgba(255,255,255,.025); cursor: pointer; }
.tag { display: inline-flex; padding: 4px 7px; border: 1px solid var(--line); border-radius: 99px; color: #93a8ba; font-size: .63rem; }
.tag.ready, .tag.approved, .tag.exported, .tag.completed { color: #a7f3d0; border-color: rgba(94,234,212,.18); background: rgba(94,234,212,.06); }
.tag.failed, .tag.duplicate { color: #ffadb6; border-color: rgba(255,127,141,.2); background: rgba(255,127,141,.06); }
.tag.awaiting_approval { color: #f9d994; border-color: rgba(246,200,110,.2); background: rgba(246,200,110,.06); }

.clip-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.clip-card { overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.018); }
.clip-thumb { position: relative; aspect-ratio: 16/8; display: grid; place-items: center; background: radial-gradient(circle at 50% 45%, rgba(130,148,255,.16), transparent 35%), linear-gradient(135deg, #0b1c2c, #07111d); }
.clip-thumb::before { content: "9:16"; color: rgba(255,255,255,.14); font: 700 2.3rem "Manrope"; }
.play-button { position: absolute; width: 48px; height: 48px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.19); border-radius: 50%; color: #07111f; background: var(--teal); cursor: pointer; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.clip-body { padding: 15px; }.clip-body h3 { margin: 10px 0 4px; font-size: .88rem; }.clip-body p { margin: 0; color: #7890a4; font-size: .68rem; }
.clip-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }.clip-actions .button { min-height: 33px; padding: 0 10px; font-size: .67rem; }
.system-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.detail-list { display: grid; gap: 0; margin: 18px 0 0; }.detail-list div { display: flex; justify-content: space-between; gap: 20px; padding: 10px 0; border-bottom: 1px solid var(--line); }.detail-list dt { color: #718a9e; }.detail-list dd { margin: 0; color: #c2d1dc; text-align: right; }
.check-list { display: grid; gap: 10px; margin: 18px 0 0; padding: 0; list-style: none; color: #9eb1c0; }.check-list li::before { content: "✓"; margin-right: 9px; color: var(--teal); }

.toast-stack { position: fixed; z-index: 80; top: 18px; right: 22px; display: grid; gap: 8px; width: min(360px, calc(100vw - 30px)); }
.toast { padding: 13px 15px; border: 1px solid var(--line-strong); border-left: 3px solid var(--teal); border-radius: 11px; color: #cbd9e4; background: rgba(9,22,35,.96); box-shadow: var(--shadow); animation: toast-in .2s ease; }.toast.error { border-left-color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateX(12px); } }
.preview-dialog { width: min(470px, calc(100vw - 24px)); padding: 18px; border: 1px solid var(--line-strong); border-radius: 18px; color: var(--text); background: #091624; box-shadow: 0 40px 100px rgba(0,0,0,.5); }.preview-dialog::backdrop { background: rgba(0,6,12,.78); backdrop-filter: blur(8px); }.preview-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }.preview-dialog video { display: block; width: 100%; max-height: 72vh; border-radius: 12px; background: #000; }

.auth-page { display: grid; place-items: center; padding: 30px; }
.auth-shell { width: min(960px, 100%); display: grid; grid-template-columns: 1.2fr .8fr; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 28px; background: rgba(8,21,34,.9); box-shadow: 0 40px 120px rgba(0,0,0,.42); }
.auth-brand { position: relative; min-height: 560px; display: flex; flex-direction: column; justify-content: center; padding: clamp(35px, 6vw, 72px); background: radial-gradient(circle at 15% 20%, rgba(94,234,212,.15), transparent 30%), radial-gradient(circle at 80% 80%, rgba(130,148,255,.18), transparent 33%), #081726; }
.auth-brand::after { content: ""; position: absolute; inset: 20px; border: 1px solid rgba(255,255,255,.045); border-radius: 21px; pointer-events: none; }
.brand-mark-large { width: 58px; height: 58px; margin-bottom: 35px; border-radius: 17px; }
.auth-brand h1 { font-size: clamp(2.25rem, 5vw, 3.5rem); line-height: 1.05; }.auth-brand h1 em { color: var(--teal); font-style: normal; }
.auth-copy { max-width: 520px; margin: 22px 0; color: #8fa6b8; font-size: .95rem; line-height: 1.7; }
.auth-security { display: flex; flex-wrap: wrap; gap: 13px; color: #7790a3; font-size: .68rem; }.auth-security span::first-letter { color: var(--teal); }
.auth-card { display: flex; flex-direction: column; justify-content: center; padding: clamp(30px, 5vw, 55px); }.auth-card h2 { font-size: 1.55rem; }.auth-card .muted { margin-top: 10px; }
.form-stack { display: grid; gap: 16px; margin-top: 30px; }.form-error { margin: 0; padding: 10px 12px; border: 1px solid rgba(255,127,141,.22); border-radius: 9px; color: #ffadb6; background: rgba(255,127,141,.06); font-size: .72rem; }.auth-footnote { margin: 24px 0 0; color: #657e92; font-size: .66rem; text-align: center; }

@media (max-width: 1120px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .overview-grid, .form-layout { grid-template-columns: 1fr; }
  .clip-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .sidebar { inset: auto 0 0; width: auto; height: 68px; flex-direction: row; align-items: center; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); border: 0; border-top: 1px solid var(--line); }
  .sidebar .brand, .sidebar-foot { display: none; }
  .nav-list { width: 100%; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 0; }
  .nav-item { flex-direction: column; gap: 2px; padding: 6px 2px; border-radius: 9px; font-size: .58rem; text-align: center; }
  .nav-item span { width: auto; font-size: .95rem; }.nav-item.active { box-shadow: inset 0 -2px var(--teal); }
  .workspace { margin: 0; padding: 20px 14px 100px; }
  .topbar { align-items: flex-start; }.topbar-actions .status-pill, .topbar-actions .button-secondary { display: none; }
  .office-game { min-height: 300px; aspect-ratio: 4/3; }.agent-strip { grid-template-columns: repeat(2, 1fr); }.agent-mini:nth-child(5n) { border-right: 1px solid var(--line); }.agent-mini:nth-child(2n) { border-right: 0; }
  .system-grid { grid-template-columns: 1fr; }
}
@media (max-width: 590px) {
  .metrics-grid, .clip-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 108px; }
  .topbar-actions .button-primary { padding: 0 11px; font-size: .68rem; }.topbar h1 { font-size: 1.4rem; }
  .panel:not(.office-panel) { padding: 17px; }.office-panel .panel-head { padding: 17px 17px 0; }
  .panel-head { flex-direction: column; }.legend { display: none; }
  .form-grid { grid-template-columns: 1fr; }.span-2 { grid-column: span 1; }
  .pipeline { overflow-x: auto; padding-bottom: 5px; }.pipeline i { min-width: 20px; }.pipeline span { white-space: nowrap; }
  .job-row { grid-template-columns: 1fr; gap: 8px; }.job-state { text-align: left; }
  .resource-summary { grid-template-columns: 1fr; gap: 10px; }.resource-summary span { padding: 0 0 10px; border: 0; border-bottom: 1px solid var(--line); }
  .auth-page { padding: 13px; }.auth-shell { grid-template-columns: 1fr; }.auth-brand { display: none; }.auth-card { min-height: 520px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }
