:root {
  --bg: #f4f6f9; --panel: #ffffff; --ink: #0f172a; --muted: #5b6577; --line: #e3e7ee; --soft: #eef2f7;
  --accent: #1e3a5f; --accent-2: #2f5d8f; --accent-ink: #ffffff;
  --ok: #1f8a4c; --ok-bg: #e3f5ea; --warn: #b45309; --warn-bg: #fdf1dc; --bad: #c02626; --bad-bg: #fde6e6;
  --hold: #64748b; --hold-bg: #eef1f5; --done: #475569; --done-bg: #e8ecf1;
  --radius: 10px; --shadow: 0 1px 2px rgba(15,23,42,.05), 0 1px 8px rgba(15,23,42,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --panel: #151b24; --ink: #e6ebf2; --muted: #9aa6b8; --line: #263041; --soft: #1b2330;
    --accent: #7fb0e6; --accent-2: #a3c6ee; --accent-ink: #0d1117;
    --ok: #4ccb84; --ok-bg: #12301f; --warn: #f0b04f; --warn-bg: #33270f; --bad: #f07272; --bad-bg: #3a1717;
    --hold: #9aa6b8; --hold-bg: #1f2733; --done: #b4bfcf; --done-bg: #1f2733;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14.5px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 0 0 .5rem; }
small, .muted { color: var(--muted); }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

/* layout */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--accent); color: var(--accent-ink); padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .side { background: #111823; color: var(--ink); border-right: 1px solid var(--line); } }
.brand { font-weight: 700; font-size: 1.05rem; padding: 4px 10px 16px; display: flex; gap: 9px; align-items: center; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: rgba(255,255,255,.18); display: grid; place-items: center; font-size: 14px; }
.side a.nav { color: inherit; opacity: .86; padding: 8px 10px; border-radius: 8px; display: flex; gap: 10px; align-items: center; }
.side a.nav:hover { background: rgba(255,255,255,.1); text-decoration: none; opacity: 1; }
.side a.nav.on { background: rgba(255,255,255,.16); opacity: 1; font-weight: 600; }
.side .grow { flex: 1; }
.side .who { font-size: .85rem; opacity: .85; padding: 8px 10px; border-top: 1px solid rgba(255,255,255,.15); }
.side .who form { display: inline; }
.side .langs a { color: inherit; opacity: .7; margin-right: 8px; font-size: .82rem; }
.side .langs a.on { opacity: 1; font-weight: 700; }
.linkbtn { background: none; border: 0; color: inherit; padding: 0; font: inherit; cursor: pointer; text-decoration: underline; opacity: .85; }
.main { padding: 26px 30px 60px; min-width: 0; max-width: 1400px; }
.topbar { display: none; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }

@media (max-width: 860px) {
  .tile .val { font-size: 1.35rem; }
  .meta { grid-template-columns: 1fr 1fr; }
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 30; transform: translateX(-105%); transition: transform .2s; height: 100%; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--accent); color: var(--accent-ink); position: sticky; top: 0; z-index: 20; }
  .topbar button { background: none; border: 0; color: inherit; font-size: 22px; cursor: pointer; padding: 0 4px; }
  .main { padding: 18px 16px 50px; }
}

/* surfaces */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: 2fr 1fr; }
.grid > *, .stack > * { min-width: 0; }
@media (max-width: 1050px) { .g2, .g3 { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: 16px; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); color: var(--ink); display: block; }
a.tile:hover { text-decoration: none; border-color: var(--accent-2); }
.tile .lbl { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tile .val { font-size: 1.7rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile.ok .val { color: var(--ok); } .tile.warn .val { color: var(--warn); } .tile.bad .val { color: var(--bad); }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.b-ok { color: var(--ok); background: var(--ok-bg); } .b-warn { color: var(--warn); background: var(--warn-bg); }
.b-bad { color: var(--bad); background: var(--bad-bg); } .b-hold { color: var(--hold); background: var(--hold-bg); }
.b-done { color: var(--done); background: var(--done-bg); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--soft); color: var(--muted); font-size: .78rem; white-space: nowrap; }
.pill.High { color: var(--bad); background: var(--bad-bg); }

/* progress */
.bar { height: 7px; background: var(--soft); border-radius: 99px; overflow: hidden; min-width: 70px; }
.bar > i { display: block; height: 100%; background: var(--accent-2); border-radius: 99px; }
.bar.ok > i { background: var(--ok); } .bar.warn > i { background: var(--warn); } .bar.bad > i { background: var(--bad); }
.prog { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; font-size: .85rem; }

/* tables */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--soft); }
tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.rowlink td:first-child a { font-weight: 600; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 9px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; justify-content: space-between; align-items: baseline; }
.list li:last-child { border-bottom: 0; }
.empty { color: var(--muted); padding: 10px 0; }

/* forms */
label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-2); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 80px; resize: vertical; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 14px; }
.fgrid .wide { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); font-size: .9rem; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: var(--accent-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.sm { padding: 4px 9px; font-size: .82rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters > * { width: auto; }
.filters input[type=search] { min-width: 220px; }
details.inline > summary { cursor: pointer; list-style: none; display: inline-flex; }
details.inline > summary::-webkit-details-marker { display: none; }
details.inline[open] > summary { margin-bottom: 10px; }
details.panel { border: 1px dashed var(--line); border-radius: 8px; padding: 10px 12px; margin-top: 8px; }

/* flash */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-weight: 500; }
.flash.ok { background: var(--ok-bg); color: var(--ok); } .flash.error { background: var(--bad-bg); color: var(--bad); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }

/* project page */
.phead { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 18px; margin-top: 14px; }
.meta div span { display: block; font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.reasons { margin: 10px 0 0; padding-left: 18px; color: var(--warn); }
.reasons.bad { color: var(--bad); }
.ms-done td { color: var(--muted); }
.ms-done td.msname { text-decoration: line-through; }
.late { color: var(--bad); font-weight: 600; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed .who { font-size: .8rem; color: var(--muted); }
.feed .txt { white-space: pre-wrap; }
.feed li.change .txt, .feed li.system .txt { color: var(--muted); font-size: .9rem; }

/* auth pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 400px; padding: 26px; }
.auth h1 { margin-bottom: 4px; }
.auth .fgrid { grid-template-columns: 1fr; }
.qr { background: #fff; border-radius: 8px; padding: 8px; display: inline-block; border: 1px solid var(--line); }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 1.05rem; letter-spacing: .06em; background: var(--soft); padding: 8px 10px; border-radius: 8px; word-break: break-all; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-family: ui-monospace, Consolas, monospace; font-size: 1.05rem; }
.codes span { background: var(--soft); padding: 6px 10px; border-radius: 6px; text-align: center; }
.otp { font-size: 1.5rem !important; letter-spacing: .3em; text-align: center; font-family: ui-monospace, Consolas, monospace; }

/* gantt */
.gantt { overflow-x: auto; }
.gantt svg text { font-family: inherit; }
.g-ws { font-weight: 700; font-size: 12.5px; fill: var(--accent-2); }
.g-wsbg { fill: var(--soft); }
.g-pl { font-size: 12px; fill: var(--ink); }
.g-mo { font-size: 11px; fill: var(--muted); }
.g-grid { stroke: var(--line); }
.g-today { stroke: var(--bad); stroke-dasharray: 4 3; stroke-width: 1.5; }
.g-tl { font-size: 11px; fill: var(--bad); }
.g-hit { fill: transparent; }
.g-row:hover .g-hit { fill: var(--soft); }
.g-ms { fill: var(--panel); stroke: var(--ink); stroke-width: 1.2; }
.g-ms-done { fill: var(--hold); stroke: var(--ink); stroke-width: 1; }
.g-ms-late { fill: var(--bad); stroke: var(--ink); stroke-width: 1; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.ws-bars .row { display: grid; grid-template-columns: minmax(120px, 1fr) 2fr 32px; gap: 10px; align-items: center; padding: 5px 0; font-size: .88rem; }
.stack-bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--soft); }
.stack-bar i { display: block; height: 100%; }
.stack-bar i + i { border-left: 2px solid var(--panel); }
.sb-ok { background: var(--ok); } .sb-warn { background: var(--warn); } .sb-bad { background: var(--bad); } .sb-hold { background: var(--hold); }
.token { font-family: ui-monospace, Consolas, monospace; background: var(--soft); padding: 10px; border-radius: 8px; word-break: break-all; }
