:root {
  --bg: #f6f7f9; --panel: #ffffff; --panel-2: #f1f3f6; --line: #e3e6eb; --text: #0f172a; --muted: #64748b; --faint: #94a3b8;
  --accent: #0f766e; --accent-ink: #ffffff; --danger: #b42318; --warn: #b45309; --ok: #047857;
  --pod: #0e9f9a; --laser: #2563eb; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.08);
  --radius: 10px; --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; letter-spacing: -.01em; } h2 { font-size: 15px; margin: 0 0 10px; } h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 4px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 12px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--danger); } .btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

.sandbox-bar { background: repeating-linear-gradient(45deg, #f59e0b, #f59e0b 12px, #fbbf24 12px, #fbbf24 24px); color: #1c1917; text-align: center; font-weight: 700; font-size: 12px; padding: 5px 12px; letter-spacing: .04em; }
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 27px); }
.shell.live { min-height: 100vh; }
nav.side { background: var(--panel); border-right: 1px solid var(--line); padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.logo { font-weight: 800; font-size: 15px; padding: 4px 10px 14px; letter-spacing: -.01em; }
.logo small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; }
nav.side a { color: var(--text); padding: 7px 10px; border-radius: 7px; display: flex; justify-content: space-between; }
nav.side a:hover { background: var(--panel-2); text-decoration: none; }
nav.side a.on { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-weight: 600; }
nav.side .sep { height: 1px; background: var(--line); margin: 8px 6px; }
nav.side .who { margin-top: auto; padding: 10px; font-size: 12px; color: var(--muted); }
main { padding: 18px 22px 40px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.topbar .grow { flex: 1; }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 7px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.menu-btn { display: none; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.detail { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; } .right { text-align: right; }
.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill.pod { color: var(--pod); border-color: color-mix(in srgb, var(--pod) 35%, transparent); background: color-mix(in srgb, var(--pod) 10%, transparent); }
.pill.laser { color: var(--laser); border-color: color-mix(in srgb, var(--laser) 35%, transparent); background: color-mix(in srgb, var(--laser) 10%, transparent); }
.pill.ok { color: var(--ok); } .pill.warn { color: var(--warn); } .pill.bad { color: var(--danger); }

/* Kanban */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.col { flex: 0 0 256px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 150px); }
.col header { padding: 10px 12px 8px; border-bottom: 1px solid var(--line); }
.col header b { display: block; font-size: 13px; }
.col header span { font-size: 12px; color: var(--muted); }
.col .cards { padding: 8px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 60px; }
.col.drop { outline: 2px dashed var(--accent); outline-offset: -3px; }
.col.won header b { color: var(--ok); } .col.lost header b { color: var(--danger); } .col.stalled header b { color: var(--warn); }
.dcard { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; cursor: grab; box-shadow: var(--shadow); }
.dcard:hover { border-color: var(--faint); }
.dcard .t { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.dcard .m { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; }
.dcard.dragging { opacity: .4; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* Stage stepper */
.stepper { display: flex; gap: 4px; flex-wrap: wrap; }
.stepper button { border: 1px solid var(--line); background: var(--panel); padding: 6px 10px; font-size: 12px; cursor: pointer; border-radius: 6px; color: var(--muted); }
.stepper button.done { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.stepper button.cur { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.stepper button.won.cur { background: var(--ok); border-color: var(--ok); }
.stepper button.lost.cur { background: var(--danger); border-color: var(--danger); color: #fff; }
.stepper button.stalled.cur { background: var(--warn); border-color: var(--warn); color: #1c1917; }

/* Timeline */
.tl { display: flex; flex-direction: column; }
.tl .it { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tl .ic { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; background: var(--panel-2); border: 1px solid var(--line); }
.tl .hd { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.tl .hd b { font-weight: 600; }
.tl .bd { white-space: pre-wrap; color: var(--text); margin-top: 3px; font-size: 13px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }

/* KPI */
.kpi { padding: 14px 16px; }
.kpi .l { font-size: 12px; color: var(--muted); } .kpi .v { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--faint); }
.bars .b { display: grid; grid-template-columns: 150px 1fr 60px; gap: 10px; align-items: center; margin: 6px 0; font-size: 13px; }
.bars .track { background: var(--panel-2); border-radius: 5px; height: 18px; overflow: hidden; }
.bars .fill { background: var(--accent); height: 100%; border-radius: 5px; min-width: 2px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs button { background: none; border: 0; padding: 8px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--text); border-color: var(--accent); font-weight: 600; }

dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; background: var(--panel); color: var(--text); width: min(560px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
dialog .dh { padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 700; }
dialog .db { padding: 16px; display: grid; gap: 12px; max-height: 70vh; overflow: auto; }
dialog .df { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
pre { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow: auto; font-size: 12px; max-height: 360px; white-space: pre-wrap; overflow-wrap: anywhere; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.toast { position: fixed; bottom: 18px; right: 18px; background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 9px; z-index: 50; max-width: 360px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.bad { background: var(--danger); color: #fff; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(380px, 100%); padding: 26px; display: grid; gap: 12px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  nav.side { position: fixed; z-index: 30; left: 0; top: 0; width: 240px; transform: translateX(-100%); transition: transform .2s; }
  nav.side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .menu-btn { display: inline-flex; }
  main { padding: 14px 16px 40px; }
  .detail, .g2, .g3 { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: 1fr 1fr; }
  .bars .b { grid-template-columns: 110px 1fr 44px; }
}
