:root {
  color-scheme: dark;
  --bg: #07100e;
  --surface: #0d1815;
  --surface-2: #12211d;
  --line: rgba(185, 255, 218, 0.12);
  --text: #edf9f2;
  --muted: #87a69a;
  --mint: #9cf7c4;
  --blue: #7eabff;
  --amber: #ffcf66;
  --red: #ff8c91;
  --radius: 20px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-width: 300px; min-height: 100vh; color: var(--text); background: radial-gradient(circle at 85% -10%, rgba(80, 143, 255, .18), transparent 36rem), radial-gradient(circle at -15% 15%, rgba(106, 255, 183, .12), transparent 30rem), var(--bg); }
button, input, select, textarea { font: inherit; }
button { touch-action: manipulation; }
.app { width: min(1180px, 100%); margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(40px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(135deg, var(--mint), var(--blue)); box-shadow: 0 0 32px rgba(132, 237, 196, .22); position: relative; }
.brand-mark::after { content: ""; position: absolute; inset: 8px 7px; border: 5px solid #0a1512; border-right: 0; }
.brand { min-width: 0; }
.brand strong { display: block; font-size: 15px; letter-spacing: -.02em; }
.brand span { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: rgba(255,255,255,.03); border-radius: 999px; padding: 8px 10px; color: var(--muted); font-size: 11px; }
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px rgba(255,140,145,.09); }
.status-pill.online::before { background: var(--mint); box-shadow: 0 0 0 4px rgba(156,247,196,.09); }
.icon-button, .button { border: 1px solid var(--line); color: var(--text); background: rgba(255,255,255,.035); border-radius: 12px; min-height: 44px; padding: 0 14px; cursor: pointer; }
.icon-button { width: 44px; padding: 0; }
.button:hover, .icon-button:hover { border-color: rgba(156,247,196,.32); background: rgba(156,247,196,.07); }
.button.primary { color: #06110d; border-color: transparent; background: linear-gradient(135deg, var(--mint), #75dca9); font-weight: 750; }
.button.blue { border-color: rgba(126,171,255,.35); background: rgba(126,171,255,.10); color: #dbe7ff; }
.button.danger { border-color: rgba(255,140,145,.25); color: #ffd4d6; }
.button.small { min-height: 36px; padding: 0 11px; font-size: 11px; }
.button:disabled { opacity: .42; cursor: not-allowed; }
.hero { margin: 22px 0 18px; display: grid; gap: 9px; }
.eyebrow { color: var(--mint); text-transform: uppercase; letter-spacing: .14em; font-size: 10px; font-weight: 800; }
h1 { font-size: clamp(29px, 7vw, 52px); line-height: .98; letter-spacing: -.055em; margin: 0; max-width: 760px; }
.hero p { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 2px 0 0; max-width: 720px; }
.device-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 18px 0; }
.device-row .field { flex: 1 1 220px; }
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(150deg, rgba(255,255,255,.045), rgba(255,255,255,.018)); box-shadow: 0 20px 80px rgba(0,0,0,.16); overflow: hidden; }
.card.span-12 { grid-column: span 12; }
.card.span-8 { grid-column: span 8; }
.card.span-7 { grid-column: span 7; }
.card.span-6 { grid-column: span 6; }
.card.span-5 { grid-column: span 5; }
.card.span-4 { grid-column: span 4; }
.card-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 17px; border-bottom: 1px solid var(--line); }
.card-head h2 { margin: 0; font-size: 14px; letter-spacing: -.02em; }
.card-head p { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.card-head .button { margin-left: auto; }
.card-body { padding: 17px; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.metric { min-height: 96px; border: 1px solid var(--line); border-radius: 16px; padding: 13px; background: rgba(255,255,255,.025); }
.metric span { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.metric strong { display: block; margin-top: 13px; font-size: 24px; letter-spacing: -.045em; }
.metric small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.project-list { display: grid; gap: 10px; }
.project { border: 1px solid var(--line); background: rgba(255,255,255,.025); border-radius: 16px; padding: 14px; }
.project-top { display: flex; align-items: flex-start; gap: 10px; }
.project-top > div { min-width: 0; }
.project h3 { font-size: 14px; margin: 0; }
.project p { color: var(--muted); font-size: 11px; line-height: 1.5; margin: 5px 0 0; }
.badge { margin-left: auto; flex: none; border-radius: 999px; padding: 5px 8px; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; background: rgba(126,171,255,.1); color: #bcd1ff; }
.badge.blocked { background: rgba(255,140,145,.1); color: #ffb7bb; }
.badge.complete { background: rgba(156,247,196,.1); color: var(--mint); }
.project-meta { display: flex; flex-wrap: wrap; gap: 7px 12px; color: var(--muted); font-size: 10px; margin: 12px 0; }
.remote-benchmark { margin: 0 0 12px; padding: 11px; border: 1px solid rgba(156,247,196,.10); border-radius: 13px; background: rgba(9,19,15,.72); }
.empty-benchmark { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; }
.empty-benchmark strong { color: #9eb1a9; }
.benchmark-head { display: grid; grid-template-columns: 52px minmax(0,1fr); gap: 10px; align-items: center; }
.benchmark-number { width: 50px; height: 50px; display: grid; place-content: center; text-align: center; border-radius: 50%; border: 4px solid rgba(126,171,255,.3); }
.benchmark-number strong { font-size: 17px; line-height: 1; }
.benchmark-number span { margin-top: 2px; color: var(--muted); font-size: 7px; }
.benchmark-number.blocked { border-color: rgba(255,140,145,.4); }
.benchmark-number.complete { border-color: rgba(156,247,196,.42); }
.benchmark-number.warning { border-color: rgba(255,201,126,.4); }
.benchmark-head > div:last-child > span { color: var(--muted); font-size: 8px; text-transform: uppercase; letter-spacing: .06em; }
.benchmark-head h4 { margin: 3px 0 2px; font-size: 11px; }
.benchmark-head small { color: var(--muted); font-size: 8.5px; }
.benchmark-bar { position: relative; height: 5px; margin-top: 10px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.06); }
.benchmark-bar span, .benchmark-bar i { position: absolute; top: 0; height: 100%; }
.benchmark-bar span { left: 0; background: linear-gradient(90deg, var(--blue), var(--mint)); }
.benchmark-bar i { background: repeating-linear-gradient(135deg, rgba(255,201,126,.9) 0 3px, rgba(255,201,126,.35) 3px 6px); }
.benchmark-gaps { display: grid; gap: 6px; padding: 0; margin: 10px 0 0; list-style: none; }
.benchmark-gaps li { display: grid; grid-template-columns: 18px minmax(0,1fr) auto; gap: 7px; align-items: start; color: var(--muted); font-size: 9px; }
.benchmark-gaps li > span { color: #ffc97e; font-weight: 800; }
.benchmark-gaps strong, .benchmark-gaps small { display: block; }
.benchmark-gaps strong { color: #d8e9e1; font-size: 9px; }
.benchmark-gaps small { margin-top: 2px; color: var(--muted); line-height: 1.35; }
.benchmark-gaps b { color: var(--muted); font-size: 8px; white-space: nowrap; }
.project-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.chat-preview { margin-top: 12px; padding: 11px; border-radius: 12px; background: #09130f; border: 1px solid rgba(255,255,255,.04); }
.chat-preview span { color: var(--mint); font-size: 9px; text-transform: uppercase; letter-spacing: .09em; }
.chat-preview p { white-space: pre-wrap; overflow-wrap: anywhere; }
.field { display: grid; gap: 6px; }
.field label { color: #b9cec5; font-size: 10px; font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; color: var(--text); background: #09130f; border: 1px solid var(--line); border-radius: 12px; outline: none; padding: 11px 12px; min-height: 42px; }
.field textarea { min-height: 116px; resize: vertical; line-height: 1.5; }
.field textarea.master { min-height: 240px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: rgba(156,247,196,.55); box-shadow: 0 0 0 3px rgba(156,247,196,.06); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.field.full, .form-actions.full { grid-column: 1 / -1; }
.check { grid-column: 1 / -1; display: flex; align-items: flex-start; gap: 9px; color: var(--muted); font-size: 11px; }
.check input { margin-top: 2px; accent-color: var(--mint); }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 2px; }
.command-list { display: grid; gap: 8px; }
.command { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 6px 12px; border-bottom: 1px solid var(--line); padding: 9px 0; }
.command:last-child { border: 0; }
.command strong { font-size: 11px; overflow-wrap: anywhere; }
.command span, .command small { color: var(--muted); font-size: 9px; }
.command .ok { color: var(--mint); }
.command .failed { color: var(--red); }
.operator-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr); gap: 16px; }
.operator-chat { min-height: 240px; max-height: 520px; overflow: auto; display: flex; flex-direction: column; gap: 10px; padding: 3px; }
.message { width: min(86%, 720px); border: 1px solid var(--line); border-radius: 16px 16px 16px 5px; padding: 11px 13px; background: #09130f; }
.message.user { align-self: flex-end; border-radius: 16px 16px 5px 16px; background: rgba(126,171,255,.09); border-color: rgba(126,171,255,.18); }
.message strong { display: block; font-size: 9px; color: var(--mint); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.message.user strong { color: #bcd1ff; }
.message p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11px; line-height: 1.6; }
.message small { display: block; color: var(--muted); margin-top: 7px; font-size: 9px; }
.operator-form { align-self: start; border: 1px solid var(--line); border-radius: 16px; padding: 13px; background: rgba(255,255,255,.02); }
.empty { color: var(--muted); text-align: center; padding: 28px 12px; font-size: 12px; line-height: 1.6; }
.pair-code { display: grid; place-items: center; gap: 8px; border: 1px dashed rgba(156,247,196,.4); border-radius: 15px; padding: 20px; margin-top: 12px; background: rgba(156,247,196,.04); }
.pair-code strong { color: var(--mint); font: 800 27px ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .08em; }
.pair-code span { color: var(--muted); font-size: 10px; text-align: center; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(430px, 100%); border: 1px solid var(--line); background: rgba(9,20,17,.86); backdrop-filter: blur(22px); border-radius: 28px; padding: 26px; box-shadow: 0 28px 100px rgba(0,0,0,.42); }
.login-card .brand-mark { margin-bottom: 30px; }
.login-card h1 { font-size: 38px; }
.login-card p { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 12px 0 24px; }
.login-card .button { width: 100%; margin-top: 12px; }
.error-box { border: 1px solid rgba(255,140,145,.25); color: #ffd1d4; background: rgba(255,140,145,.07); border-radius: 12px; padding: 10px 12px; font-size: 11px; margin: 12px 0; }
.offline-banner { position: sticky; top: 8px; z-index: 5; padding: 10px 13px; border-radius: 12px; color: #ffe9b5; border: 1px solid rgba(255,207,102,.25); background: rgba(45,34,13,.95); font-size: 11px; margin-bottom: 12px; }
.toast-region { position: fixed; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); z-index: 20; display: grid; gap: 8px; width: min(340px, calc(100% - 28px)); }
.toast { border: 1px solid rgba(156,247,196,.25); border-radius: 14px; padding: 11px 13px; background: #10211b; box-shadow: 0 16px 50px rgba(0,0,0,.38); font-size: 11px; }
.toast strong { display: block; margin-bottom: 3px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

@media (max-width: 820px) {
  .card.span-8, .card.span-7, .card.span-6, .card.span-5, .card.span-4 { grid-column: span 12; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .operator-layout { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .button.small { min-height: 44px; }
  .app { padding-left: 12px; padding-right: 12px; }
  .topbar { align-items: flex-start; }
  .brand span { display: none; }
  .status-pill { max-width: 115px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hero { margin-top: 28px; }
  .metrics { gap: 8px; }
  .metric { min-height: 84px; }
  .metric strong { font-size: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full, .form-actions.full { grid-column: auto; }
  .check { grid-column: auto; }
  .form-actions { position: sticky; bottom: max(8px, env(safe-area-inset-bottom)); z-index: 2; padding: 8px; margin: 0 -8px -8px; background: rgba(13,24,21,.94); backdrop-filter: blur(15px); border-radius: 14px; }
  .form-actions .button { flex: 1; }
  .login-card { padding: 22px; }
}
