:root {
  --page: #f9f9f9; --surface: #ffffff; --ink: #191919; --ink-2: #666666; --line: #e7e7e7;
  --accent: #257de0; --s1: #257de0; --s2: #f47230; --good: #0aac23; --warn: #b07800; --crit: #dc3c3d;
  --chip: #f0f0f0; --radius: 10px; color-scheme: light;
}
[data-theme="dark"] {
  --page: #0b0b0b; --surface: #191919; --ink: #efefef; --ink-2: #9c9c9c; --line: #303030;
  --accent: #338ced; --s1: #338ced; --s2: #e76624; --good: #0aac23; --warn: #fbb315; --crit: #eb6263;
  --chip: #262626; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
h1 { font-size: 17px; margin: 0; font-weight: 600; }
h2 { font-size: 15px; margin: 0 0 10px; font-weight: 600; }
h3 { font-size: 14px; margin: 0 0 6px; font-weight: 600; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-box { max-width: 360px; text-align: center; }
.app { display: grid; grid-template-columns: 220px minmax(0, 1fr); grid-template-rows: auto 1fr; min-height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h1 { flex: 1; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 8px; width: 36px; height: 36px; cursor: pointer; }
#menu-btn { display: none; }
.nav { background: var(--surface); border-right: 1px solid var(--line); padding: 8px; overflow-y: auto; }
.nav a { display: block; padding: 7px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--chip); font-weight: 600; }
.nav .group { color: var(--ink-2); font-size: 12px; padding: 12px 10px 4px; text-transform: uppercase; letter-spacing: .04em; }
.main { padding: 16px; max-width: 1100px; width: 100%; min-width: 0; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.card.wide { grid-column: 1 / -1; }
.muted { color: var(--ink-2); font-size: 13px; }
.stat { font-size: 26px; font-weight: 600; line-height: 1.2; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
ul.list { list-style: none; margin: 0; padding: 0; }
ul.list > li { padding: 8px 0; border-top: 1px solid var(--line); }
ul.list > li:first-child { border-top: none; }
.chip { display: inline-block; background: var(--chip); border-radius: 999px; padding: 1px 8px; font-size: 12px; color: var(--ink-2); }
.badge-crit { color: var(--crit); font-weight: 600; }
.badge-good { color: var(--good); font-weight: 600; }
.badge-warn { color: var(--warn); font-weight: 600; }
.btn { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 13px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--crit); }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=search], input[type=time], input[type=number], select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; max-width: 100%; }
textarea { width: 100%; min-height: 70px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-top: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink-2); font-weight: 600; border-top: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(190px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.kanban .col { background: var(--chip); border-radius: var(--radius); padding: 8px; min-height: 120px; }
.kanban .col h3 { display: flex; justify-content: space-between; }
.kanban .card { margin-top: 8px; padding: 10px; }
.week { display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); gap: 8px; overflow-x: auto; }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; min-height: 120px; }
.day.today { border-color: var(--accent); }
.ev { border-left: 3px solid var(--s1); padding: 2px 6px; margin-top: 6px; font-size: 13px; }
.ev.task { border-left-color: var(--s2); }
.bar-track { background: var(--chip); border-radius: 999px; height: 8px; overflow: hidden; margin-top: 4px; }
.bar-fill { background: var(--s1); height: 100%; border-radius: 999px; }
.bar-fill.over { background: var(--crit); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); margin: 4px 0 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart text { fill: var(--ink-2); font-size: 11px; }
svg.chart .grid-line { stroke: var(--line); stroke-width: 1; }
svg.chart .hit { fill: transparent; cursor: pointer; }
.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.15); max-width: 260px; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--surface);
  padding: 8px 14px; border-radius: 8px; z-index: 30; max-width: 90vw; }
.empty { color: var(--ink-2); padding: 8px 0; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  #menu-btn { display: inline-block; }
  .nav { position: fixed; inset: 57px 0 0 0; z-index: 10; border-right: none; display: none; }
  .nav.open { display: block; }
  .main { padding: 12px; }
}
@media (prefers-reduced-motion: no-preference) { .btn, .nav a { transition: background .1s; } }

code { word-break: break-all; font-size: 12px; background: var(--chip); padding: 2px 4px; border-radius: 4px; }
.code-form { display: grid; gap: 10px; margin-top: 16px; justify-items: center; }
.code-form input { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  font-size: 22px; letter-spacing: .35em; text-align: center; width: 9.5em; font-variant-numeric: tabular-nums; }
#code-login .btn { padding: 8px 14px; font-size: 14px; }
#code-msg { min-height: 1.4em; margin-top: 12px; }
.gate-actions { justify-content: center; margin-top: 12px; }
