:root {
  --bg: #f3f5f8; --panel: #fff; --ink: #1c2230; --muted: #6b7386; --line: #e3e7ee;
  --lime: #8fce00; --lime-dark: #3f6b00; --side: #12161f; --side-ink: #b9c1d1;
  --red: #d93a44; --orange: #f5a623; --blue: #2f7de1; --green: #1f9d57; --purple: #8e5bd6; --pink: #e0569b; --teal: #17a2a2;
  --s-todo: #b9bfc7; --s-working: #f5a623; --s-review: #8e5bd6; --s-stuck: #e5484d; --s-done: #2fbf71;
  --radius: 12px; --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 4px 14px rgba(20, 30, 50, .05);
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1rem; margin: 0 0 .75rem; }
h2.section { margin: 1.2rem 0 .6rem; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ---------- shell */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 1.1rem .8rem; display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side a { color: var(--side-ink); display: flex; align-items: center; gap: .65rem; padding: .5rem .7rem; border-radius: 9px; }
.side a:hover { background: #1e2533; color: #fff; text-decoration: none; }
.side a.on { background: var(--lime); color: #11150b; font-weight: 600; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
.side small { display: block; opacity: .7; font-weight: 400; font-size: .78rem; }
.side-foot { border-top: 1px solid #252d3c; padding-top: .7rem; }
.brand { font-weight: 700; font-size: 1.15rem; color: #fff !important; padding: .3rem .7rem !important; }
.brand:hover { background: none !important; }
.brand-dot { width: 16px; height: 16px; border-radius: 5px; background: var(--lime); display: inline-block; transform: rotate(45deg); }
.brand-lg { display: flex; align-items: center; gap: .6rem; color: var(--ink) !important; font-size: 1.3rem; margin-bottom: .5rem; padding: 0 !important; }
.main { padding: 1.6rem 2rem 3rem; min-width: 0; max-width: 1500px; }
.page-head { margin-bottom: 1.2rem; }
.page-head p { margin: .15rem 0 0; color: var(--muted); }
.auth { min-height: 100vh; display: grid; place-content: center; padding: 1rem; background: radial-gradient(circle at 20% 10%, #e9f7c9, var(--bg) 55%); }
.auth-card { width: min(380px, 92vw); display: grid; gap: .8rem; padding: 1.6rem; }
.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #dfe6f3; color: #2b3852; font-size: .72rem; font-weight: 700; flex: none; vertical-align: middle; }
.side .avatar { background: var(--lime); color: #11150b; }

/* ---------- cards and layout */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1rem; overflow-x: auto; box-shadow: var(--shadow); }
.narrow { max-width: 680px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.cols > .card { margin-bottom: 0; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { margin: 0; color: var(--ink); display: block; border-top: 4px solid var(--line); }
a.stat:hover, a.tile:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 6px 20px rgba(20, 30, 50, .1); }
a.stat, a.tile { transition: transform .12s ease, box-shadow .12s ease; }
.stat span { display: block; color: var(--muted); font-size: .85rem; }
.stat strong { font-size: 1.7rem; letter-spacing: -.02em; }
.stat small { display: block; color: var(--muted); }
.stat.accent strong { font-size: 1.35rem; white-space: nowrap; }
.stats { align-items: stretch; }
.c-lime { border-top-color: var(--lime); } .c-blue { border-top-color: var(--blue); } .c-red { border-top-color: var(--red); }
.c-orange { border-top-color: var(--orange); } .c-purple { border-top-color: var(--purple); }
.stat.accent { background: var(--side); color: #fff; border-top-color: var(--lime); }
.stat.accent span, .stat.accent small { color: #aeb7c9; } .stat.accent strong { color: var(--lime); }
.tile { display: grid; gap: .35rem; color: var(--ink); margin: 0; }
.board-tile { border-left: 5px solid var(--lime); }
details.card summary { cursor: pointer; font-weight: 600; margin-bottom: .6rem; }
details.card > form { margin-bottom: .9rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; color: var(--muted); font-weight: 600; white-space: nowrap; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfd; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted, .meta, .hint { color: var(--muted); }
.meta, .hint { font-size: .85rem; }
.empty { color: var(--muted); margin: .5rem 0; }
.pos { color: var(--green); } .neg, .overdue { color: var(--red); }
.overdue { font-weight: 600; }
.more { float: right; font-weight: 400; font-size: .85rem; }

/* ---------- forms */
label { display: grid; gap: .25rem; font-size: .85rem; color: var(--muted); flex: 1; min-width: 0; }
input, select, textarea { font: inherit; color: var(--ink); padding: .5rem .6rem; border: 1px solid #cdd3de; border-radius: 8px; background: #fff; width: 100%; }
input[type="checkbox"] { width: auto; }
input[type="file"] { padding: .35rem; }
.check-row { display: flex; align-items: center; gap: .5rem; color: var(--ink); }
textarea { resize: vertical; }
.stack { display: grid; gap: .8rem; }
.row { display: flex; gap: .8rem; flex-wrap: wrap; }
.row > label { min-width: 140px; }
.inline { display: flex; gap: .4rem; align-items: center; }
.inline input, .inline select { width: auto; min-width: 0; }
.add-item { margin-top: .6rem; } .add-item input { flex: 1; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.toolbar { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filters { display: flex; gap: .4rem; flex-wrap: wrap; }
.filters input, .filters select { width: auto; }

.btn { font: inherit; display: inline-block; padding: .5rem .9rem; border-radius: 8px; border: 1px solid #cdd3de; background: #fff; color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink); text-decoration: none; }
.btn.primary { background: var(--lime); border-color: var(--lime); color: #11150b; font-weight: 600; }
.btn.primary:hover { background: #9fdc10; }
.btn.active { background: var(--side); color: #fff; border-color: var(--side); }
.btn.danger { color: var(--red); border-color: #efc0c3; }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
.link { font: inherit; background: none; border: 0; color: var(--muted); cursor: pointer; padding: .2rem .4rem; }
.link:hover { color: var(--red); }
.side .link { color: var(--side-ink); padding: .5rem .7rem; }
.tabs { display: flex; gap: .2rem; border-bottom: 2px solid var(--line); }
.tabs a { padding: .45rem .9rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tabs a.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--lime); }
.tabs a:hover { text-decoration: none; color: var(--ink); }

.badge { display: inline-block; padding: .05rem .5rem; border-radius: 99px; font-size: .78rem; font-weight: 600; background: #e8ecf3; color: #3b4458; white-space: nowrap; }
.b-sev4 { background: #fde0e0; color: #9b1c1c; } .b-sev3 { background: #ffe8cc; color: #8a4b00; }
.b-sev2 { background: #fff6c7; color: #6b5800; } .b-sev1 { background: #e3eef9; color: #1d4f80; }
.b-st-open { background: #e3eef9; color: #1d4f80; } .b-st-in_progress { background: #ece3fb; color: #55309a; }
.b-st-resolved, .b-pr-active { background: #dff3df; color: #1e5c22; }
.b-pr-paused { background: #fff6c7; color: #6b5800; }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.flash-ok { background: #eef9dc; border-color: #c2e58a; }
.flash-err { background: #fdecec; border-color: #f0b4b4; color: #7d1717; }
.toast { position: fixed; right: 1.2rem; bottom: 1.2rem; background: var(--side); color: #fff; padding: .55rem 1rem; border-radius: 9px; opacity: 0; transform: translateY(8px); transition: opacity .15s, transform .15s; pointer-events: none; }
.toast.show { opacity: 1; transform: none; }
.toast.bad { background: var(--red); }

progress { width: 100%; height: 8px; appearance: none; border: 0; border-radius: 99px; overflow: hidden; background: #e7ebf2; vertical-align: middle; }
progress::-webkit-progress-bar { background: #e7ebf2; }
progress::-webkit-progress-value { background: var(--lime); }
progress::-moz-progress-bar { background: var(--lime); }
progress.wide { margin-bottom: 1rem; }
td progress { width: 90px; }

/* ---------- status colours (boards) */
.s-todo { fill: var(--s-todo); background-color: var(--s-todo); } .s-working { fill: var(--s-working); background-color: var(--s-working); }
.s-review { fill: var(--s-review); background-color: var(--s-review); } .s-stuck { fill: var(--s-stuck); background-color: var(--s-stuck); }
.s-done { fill: var(--s-done); background-color: var(--s-done); } .s-empty { fill: #e7ebf2; }
.battery { width: 100%; height: 10px; border-radius: 99px; display: block; overflow: hidden; }
.battery-wrap { display: grid; gap: .3rem; margin-bottom: 1.2rem; }
.pill-static { display: inline-block; color: #fff; padding: .15rem .6rem; border-radius: 6px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.pill-static.s-todo { color: #2a2f3a; }
select.pill { border: 0; color: #fff; font-weight: 600; text-align: center; text-align-last: center; cursor: pointer; border-radius: 6px; min-width: 130px; }
select.pill option { background: #fff; color: var(--ink); }
select.pill[data-v="todo"] { background: var(--s-todo); color: #2a2f3a; } select.pill[data-v="working"] { background: var(--s-working); color: #3a2600; }
select.pill[data-v="review"] { background: var(--s-review); } select.pill[data-v="stuck"] { background: var(--s-stuck); }
select.pill[data-v="done"] { background: var(--s-done); color: #06331b; }
select.prio { min-width: 96px; }
select.prio[data-v="4"] { background: #c62828; color: #fff; } select.prio[data-v="3"] { background: #ef6c00; color: #fff; }
select.prio[data-v="2"] { background: #f4c430; color: #3d2f00; } select.prio[data-v="1"] { background: #cfd8e3; color: #2a3446; }

.group { margin-bottom: 1.4rem; }
.group-head { display: flex; align-items: center; gap: 1rem; margin-bottom: .4rem; }
.group-head h2 { margin: 0; font-size: 1.05rem; }
.group-battery { width: 160px; }
.count { color: var(--muted); font-weight: 400; font-size: .85rem; }
.board-table { padding: 0 0 .6rem; border-left: 5px solid var(--lime); margin-bottom: 0; }
.board-table .add-item { padding: 0 .6rem; }
.board-table td { padding: .3rem .5rem; }
.board-table td input, .board-table td select:not(.pill) { border-color: transparent; background: transparent; padding: .35rem .4rem; }
.board-table td input:hover, .board-table td select:not(.pill):hover, .board-table td input:focus { border-color: #cdd3de; background: #fff; }
.cell-title { min-width: 260px; width: 45%; }
.board-table td select[name="owner_id"] { min-width: 150px; }
.board-table .add-item { padding-top: .6rem; } .cell-title input { font-weight: 500; }
.board-table input.overdue { color: var(--red); }
.g-lime h2 { color: var(--lime-dark); } .g-lime .board-table { border-left-color: var(--lime); }
.g-blue h2 { color: var(--blue); } .g-blue .board-table { border-left-color: var(--blue); }
.g-purple h2 { color: var(--purple); } .g-purple .board-table { border-left-color: var(--purple); }
.g-orange h2 { color: #b76e00; } .g-orange .board-table { border-left-color: var(--orange); }
.g-pink h2 { color: var(--pink); } .g-pink .board-table { border-left-color: var(--pink); }
.g-teal h2 { color: var(--teal); } .g-teal .board-table { border-left-color: var(--teal); }

.kanban { display: grid; grid-template-columns: repeat(5, minmax(210px, 1fr)); gap: .8rem; overflow-x: auto; padding-bottom: .5rem; align-items: start; }
.lane { background: #e9edf3; border-radius: var(--radius); min-height: 220px; border: 2px solid transparent; }
.lane.over { border-color: var(--blue); background: #dfe9f8; }
.lane-head { margin: 0; padding: .5rem .8rem; border-radius: 10px 10px 0 0; color: #fff; font-size: .9rem; }
.lane-head.s-todo, .lane-head.s-working, .lane-head.s-done { color: #1c2230; }
.lane-head .count { color: inherit; opacity: .8; }
.lane-body { padding: .6rem; display: grid; gap: .5rem; min-height: 160px; align-content: start; }
.kcard { background: #fff; border-radius: 9px; padding: .6rem .7rem; box-shadow: var(--shadow); cursor: grab; display: grid; gap: .4rem; }
.kcard.dragging { opacity: .4; }
.kcard a { color: var(--ink); font-weight: 500; }
.kmeta { display: flex; align-items: center; gap: .5rem; font-size: .8rem; }
.kmeta .avatar { margin-left: auto; }

/* ---------- lists */
.checks, .plain { list-style: none; margin: 0; padding: 0; }
.checks li { display: flex; align-items: center; gap: .7rem; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.checks li:last-child { border-bottom: 0; }
.checks .label { flex: 1; }
.checks .done .label { color: var(--muted); text-decoration: line-through; }
.check { width: 26px; height: 26px; border-radius: 7px; border: 2px solid #aab2c2; background: #fff; cursor: pointer; font-weight: 700; line-height: 1; color: #11150b; }
.check[aria-pressed="true"] { background: var(--lime); border-color: var(--lime); }
.plain li { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.plain li:last-child { border-bottom: 0; }
.plain .meta { margin-left: .4rem; }
.plain progress, .plain .battery { display: block; margin-top: .35rem; }

.prose { overflow-wrap: anywhere; margin: .6rem 0; }
.comment { margin-bottom: .6rem; }
dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: .3rem .9rem; }
dt { color: var(--muted); } dd { margin: 0; }
.pager { color: var(--muted); display: flex; gap: 1rem; }

/* ---------- charts and insights */
.chart { width: 100%; height: auto; display: block; }
.chart.line { height: 180px; }
.chart-dates { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); margin-top: .2rem; } .chart.spark { height: 56px; }
.chart .axis { stroke: var(--line); }
.chart .tick { font-size: 11px; fill: var(--muted); }
.chart .area { fill: rgba(143, 206, 0, .18); }
.chart .stroke { fill: none; stroke: #6aa000; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.chart .hit { fill: transparent; } .chart .hit:hover { fill: rgba(47, 125, 225, .12); }
.bar.income, .bar.resolved { fill: var(--lime); }
.bar.expense { fill: #39425a; }
.bar.opened, .bar.open { fill: var(--blue); }
.legend { font-size: .85rem; color: var(--muted); margin: 0 0 .4rem; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin: 0 .3rem 0 .6rem; }
.key:first-child { margin-left: 0; }
.key.income, .key.resolved { background: var(--lime); } .key.expense { background: #39425a; } .key.opened { background: var(--blue); }
.delta { font-size: .82rem; font-weight: 700; padding: .05rem .4rem; border-radius: 6px; white-space: nowrap; }
.delta.up { color: #14693a; background: #dcf5e6; } .delta.down { color: #a1242c; background: #fde3e4; } .delta.flat { color: var(--muted); background: #eceff4; }
.metric-head { display: flex; justify-content: space-between; align-items: start; margin-bottom: .4rem; }
.metric-head h2 { margin-bottom: .2rem; }
.big { font-size: 1.7rem; letter-spacing: -.02em; margin-right: .4rem; }
.breakdown { margin-top: .6rem; font-size: .9rem; } .breakdown td { padding: .25rem .4rem; border: 0; }
.bar-cell { width: 40%; } .bar-cell progress { width: 100%; }
.highlights { border-left: 5px solid var(--lime); }
.pulse { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.pulse strong { font-size: 1.3rem; display: inline-block; margin-right: .3rem; }
.pulse .meta { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { border: 0; padding: 0; display: flex; align-items: center; }
  .main { padding: 1rem; }
  .split { grid-template-columns: 1fr; }
  .cols { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.nowrap { white-space: nowrap; }