:root {
  --bg: #f6f5fb; --surface: #ffffff; --surface-2: #efecf7; --line: #e4e0ef; --text: #1d1830; --muted: #6f6789;
  --nav: #160a2e; --nav-text: #cbbcf0; --nav-on: #3a1670; --accent: #6a2bd0;
  --good: #14a061; --warn: #c97700; --bad: #d62450; --idle: #9a93b0;
  --red: var(--bad); --focus: var(--accent);
  --good-bg: #e3f8ee; --warn-bg: #fff1dc; --bad-bg: #ffe5ea; --info-bg: #eee9fb;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0a16; --surface: #17131f; --surface-2: #211b2d; --line: #2e2740; --text: #ece8f5; --muted: #a49cbd;
    --nav: #08050f; --nav-on: #3a1670; --accent: #b58cff;
    --good: #3ad18a; --warn: #ffb547; --bad: #ff6b8b; --idle: #7d7694;
    --good-bg: #123526; --warn-bg: #3a2a10; --bad-bg: #3d1420; --info-bg: #2a1f45;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0a16; --surface: #17131f; --surface-2: #211b2d; --line: #2e2740; --text: #ece8f5; --muted: #a49cbd;
  --nav: #08050f; --nav-on: #3a1670; --accent: #b58cff;
  --good: #3ad18a; --warn: #ffb547; --bad: #ff6b8b; --idle: #7d7694;
  --good-bg: #123526; --warn-bg: #3a2a10; --bad-bg: #3d1420; --info-bg: #2a1f45;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; }
.logo i { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, #19e3ff, #a64dff, #ff3d9a); flex: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: 999px; font: inherit; font-weight: 700;
  border: 1.5px solid var(--line); color: var(--text); background: var(--surface); cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

.gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.gatebox { background: var(--surface); border-radius: 18px; padding: 28px; max-width: 420px; width: 100%; display: grid; gap: 14px; box-shadow: 0 10px 40px #2b145a22; }

.shell { display: flex; min-height: 100vh; }
.nav { width: 220px; background: var(--nav); color: var(--nav-text); padding: 18px 14px; flex: none; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.nav .logo { color: #fff; margin-bottom: 20px; }
.nav nav { display: grid; gap: 3px; }
.nav nav a { color: var(--nav-text); text-decoration: none; padding: 9px 12px; border-radius: 10px; }
.nav nav a.on { background: var(--nav-on); color: #fff; font-weight: 700; }
.navfoot { margin-top: auto; display: grid; gap: 8px; }
.navfoot .muted { color: #8d80b3; }
main { flex: 1; padding: 22px 26px 40px; min-width: 0; }
h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 10px; color: var(--accent); }
.sub { color: var(--muted); margin: 0 0 16px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border-radius: 12px; padding: 12px 14px; box-shadow: 0 2px 10px #2b145a10; }
.kpi small { display: block; color: var(--muted); font-size: 13px; }
.kpi b { font-size: 26px; }
.kpi em { font-style: normal; font-size: 13px; font-weight: 700; margin-left: 4px; }
.up { color: var(--good); } .dn { color: var(--bad); } .mid { color: var(--warn); }

.grid2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 14px; align-items: start; }
.box { background: var(--surface); border-radius: 12px; padding: 14px 16px; box-shadow: 0 2px 10px #2b145a10; margin-bottom: 14px; }
.box ol, .box ul { margin: 0; padding-left: 20px; }
.box li { margin-bottom: 4px; }
.box.red { border-left: 5px solid var(--bad); } .box.green { border-left: 5px solid var(--good); } .box.amber { border-left: 5px solid var(--warn); }

.tblwrap { overflow-x: auto; background: var(--surface); border-radius: 12px; box-shadow: 0 2px 10px #2b145a10; margin-bottom: 14px; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--surface-2); color: var(--muted); font-size: 12.5px; text-align: left; padding: 9px 10px; white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.r, th.r { text-align: right; white-space: nowrap; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--surface-2); }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 7px; vertical-align: middle; }
.dg { background: var(--good); } .da { background: var(--warn); } .dr { background: var(--bad); } .dx { background: var(--idle); }
.chip { display: inline-block; padding: 2px 9px; border-radius: 9px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.c-live { background: var(--good-bg); color: var(--good); } .c-test { background: var(--warn-bg); color: var(--warn); }
.c-research, .c-planned { background: var(--info-bg); color: var(--accent); } .c-dropped { background: var(--bad-bg); color: var(--bad); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chips button { border: 0; cursor: pointer; font: inherit; }
.chips button.on { outline: 2px solid var(--accent); }
.spark { display: block; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 110px; }
.bars span { flex: 1; background: linear-gradient(var(--accent), #6a2bd0); border-radius: 3px 3px 0 0; min-height: 2px; }
.fun { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.fun div { flex: 1; min-width: 90px; background: var(--info-bg); border-radius: 10px; padding: 8px; text-align: center; font-size: 13px; color: var(--muted); }
.fun b { display: block; font-size: 22px; color: var(--text); }
.review { border-bottom: 1px solid var(--line); padding: 10px 0; }
.review:last-child { border-bottom: 0; }
.review .stars { color: #F5B301; letter-spacing: 1px; }
.review p { margin: 4px 0 0; white-space: pre-wrap; word-break: break-word; }
.review p[dir=rtl] { text-align: right; }
.ask { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.ask textarea { flex: 1; min-width: 240px; min-height: 64px; padding: 10px 12px; border-radius: 10px; border: 2px solid var(--accent); background: var(--surface); color: var(--text); font: inherit; }
.ask select { padding: 8px 10px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); font: inherit; }
.kan { display: grid; grid-template-columns: repeat(4, minmax(200px, 1fr)); gap: 12px; overflow-x: auto; }
.kan .col { background: var(--surface-2); border-radius: 12px; padding: 10px; min-height: 120px; }
.kan h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); }
.card { background: var(--surface); border-radius: 10px; padding: 9px 10px; margin-bottom: 8px; font-size: 14px; box-shadow: 0 1px 5px #0000000d; }
.card.need { border-left: 4px solid var(--warn); }
.err { color: var(--bad); }
.note { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; font-size: 14px; }
.focus { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.focus div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; font-size: 14px; }
.focus div.today { background: var(--accent); color: #fff; font-weight: 700; }
.prog { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.prog span { display: block; height: 100%; background: linear-gradient(90deg, var(--good), #19c4a0); border-radius: 99px; }
.nextup { border-left: 5px solid var(--accent); }
.nextup small { color: var(--muted); font-weight: 700; text-transform: uppercase; font-size: 12px; letter-spacing: .5px; }
.nextup ul { margin: 0; padding-left: 20px; }
.rlist { background: var(--surface); border-radius: 12px; box-shadow: 0 2px 10px #2b145a10; margin-bottom: 14px; }
.ritem { display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.ritem:last-child { border-bottom: 0; }
.ritem.click { cursor: pointer; } .ritem.click:hover { background: var(--surface-2); }
.ritem .rnum { width: 22px; color: var(--muted); font-weight: 700; flex: none; }
.ritem .rmain { flex: 1; min-width: 0; }
.ritem .rmain .muted { margin-top: 2px; }
.ritem > .btn, .ritem > .chip { flex: none; }
.donerow .rmain { opacity: .55; }
.roundbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.roundbar textarea { flex: 1; min-width: 220px; min-height: 44px; padding: 8px 10px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); font: inherit; }
.roundbar .grow { flex: 1; }
.glance { border-left: 5px solid var(--accent); }
.glance3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.gl { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.gl.amber { background: var(--warn-bg); } .gl.red { background: var(--bad-bg); }
.gl ul { margin: 0; padding-left: 18px; }
.gl small { display: block; color: var(--muted); font-weight: 700; text-transform: uppercase; font-size: 11.5px; letter-spacing: .4px; margin-bottom: 4px; }
.goal { margin-bottom: 6px; } .goal:last-child { margin-bottom: 0; }
@media (max-width: 860px) { .glance3 { grid-template-columns: 1fr; } }
.h3 { font-size: 14px; margin: 12px 0 6px; color: var(--muted); }
.votes { margin: 0; padding-left: 20px; } .votes li { margin-bottom: 5px; }
.fb .chip { margin-right: 6px; }
.fbbar { display: flex; gap: 8px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.fbbar select { padding: 4px 8px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }
.kan5 { grid-template-columns: repeat(5, minmax(220px, 1fr)); }
.kan .review { background: var(--surface); border-radius: 10px; padding: 9px 10px; margin-bottom: 8px; border: 0; }
.target { margin-bottom: 10px; }
.target .prog { margin-top: 4px; height: 8px; }
.target .x { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; float: right; }
.hist { display: grid; grid-template-columns: 52px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.hist:last-child { border-bottom: 0; }
input[type=text], input[type=url], input[type=number], input[type=date] { padding: 8px 10px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); font: inherit; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .nav { width: auto; height: auto; position: static; padding: 12px 16px; }
  .nav .logo { margin-bottom: 10px; }
  .nav nav { display: flex; overflow-x: auto; gap: 4px; }
  .nav nav a { white-space: nowrap; }
  .navfoot { flex-direction: row; display: flex; flex-wrap: wrap; margin-top: 10px; align-items: center; }
  main { padding: 16px; }
  .grid2 { grid-template-columns: 1fr; }
}
.weeks th, .weeks td { padding: 6px 8px; font-size: 13px; white-space: nowrap; }
.wk-ok { background: #e3f8ee; color: #118650; font-weight: 700; }
.wk-off { background: #ffe5ea; color: #c4183d; font-weight: 700; }
.weeks td:first-child, .weeks th:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.notesbtn { padding: 3px 9px; font-size: 12.5px; white-space: nowrap; margin-left: 4px; }
.notesbtn .nb { font-weight: 700; color: var(--muted); }
.notesbtn .nb.open { color: #b86c00; }
.notesbtn.primary .nb, .notesbtn.primary .nb.open { color: inherit; }
.note-item { display: flex; gap: 12px; background: var(--surface); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; box-shadow: 0 2px 10px #2b145a10; border-left: 4px solid var(--line); }
.note-item.todo, .note-item.waiting { border-left-color: var(--warn); }
.note-item.doing { border-left-color: var(--accent); }
.note-item.done { border-left-color: var(--good); }
.note-when { flex: none; width: 64px; font-size: 12.5px; color: var(--muted); }
.note-body { flex: 1; min-width: 0; }
.note-body p { margin: 4px 0 0; }
.note-body .ok { color: var(--good); font-weight: 600; }
.note-body .wait { color: #b86c00; font-weight: 600; }
.notesbox .note-item { box-shadow: none; background: var(--surface-2); }
.notekpis { grid-template-columns: repeat(4, 1fr); }

.idea-card p { margin: 4px 0; } .idea-card .btn { margin-top: 6px; }
.chips .chip { background: var(--surface-2); color: var(--text); } .chips .chip.on { outline: 2px solid var(--accent); }
