:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --ink: #0f172a;
  --ink-2: #475569;
  --muted: #94a3b8;
  --line: #e2e8f0;
  --brand: #1d4ed8;
  --brand-ink: #ffffff;
  --brand-soft: #e0e7ff;
  --good: #047857; --good-bg: #d1fae5;
  --warn: #b45309; --warn-bg: #fef3c7;
  --bad: #b91c1c;  --bad-bg: #fee2e2;
  --info: #1e40af; --info-bg: #dbeafe;
  --neutral: #334155; --neutral-bg: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120; --panel: #111a2e; --panel-2: #0f1729; --ink: #e5e9f2; --ink-2: #a8b3c7; --muted: #64748b;
    --line: #1f2a44; --brand: #3b82f6; --brand-soft: #1e293b;
    --good: #34d399; --good-bg: #052e22; --warn: #fbbf24; --warn-bg: #2f2306; --bad: #f87171; --bad-bg: #3a1010;
    --info: #93c5fd; --info-bg: #10224a; --neutral: #cbd5e1; --neutral-bg: #1e293b;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
small, .muted { color: var(--muted); }
code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: 12.5px; }
pre { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow-x: auto; font-size: 12.5px; }

.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 10px; }
.brand .logo { width: 36px; height: 36px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font: 22px Georgia, serif; }
.brand strong { display: block; font-size: 15px; }
.brand small { display: block; font-size: 12px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.sidebar nav a:hover { background: var(--panel-2); text-decoration: none; color: var(--ink); }
.sidebar nav a.active { background: var(--brand-soft); color: var(--brand); }
.sidebar .ico { width: 20px; text-align: center; }
.sidebar .pill { margin-left: auto; background: var(--bad); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; }
.me { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 8px 0; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.me small { display: block; }

.main { padding: 20px 28px 40px; min-width: 0; }
.topbar { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.topbar h1 { font-size: 22px; }
.topbar .sub { margin: 4px 0 0; color: var(--ink-2); }
.topbar .today { margin-left: auto; color: var(--ink-2); white-space: nowrap; padding-top: 4px; }
.menu-btn { display: none; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px; padding: 4px 10px; font-size: 18px; }
.foot { margin-top: 32px; color: var(--muted); font-size: 12px; }

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; border: 1px solid transparent; }
.flash.ok { background: var(--good-bg); color: var(--good); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }
.flash.err { background: var(--bad-bg); color: var(--bad); }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.card > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card > header .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi .n { font-size: 28px; font-weight: 700; letter-spacing: -.5px; }
.kpi .l { color: var(--ink-2); font-size: 13px; }
.kpi .s { color: var(--muted); font-size: 12px; }
.kpi.alert .n { color: var(--bad); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--panel); position: sticky; top: 0; }
tr:hover td { background: var(--panel-2); }
td.nowrap, th.nowrap { white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.compact td, .compact th { padding: 6px 8px; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.neutral { background: var(--neutral-bg); color: var(--neutral); }
.badge.muted { background: transparent; color: var(--muted); border: 1px solid var(--line); }

.due { font-weight: 600; white-space: nowrap; }
.due.overdue { color: var(--bad); }
.due.urgent { color: var(--bad); }
.due.soon { color: var(--warn); }
.due.later { color: var(--ink-2); font-weight: 500; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot.overdue, .dot.urgent { background: var(--bad); }
.dot.soon { background: var(--warn); }
.dot.later { background: var(--muted); }

.prob { position: relative; display: inline-flex; align-items: center; width: 92px; height: 18px; background: var(--neutral-bg); border-radius: 999px; overflow: hidden; vertical-align: middle; }
.prob span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; }
.prob.good span { background: var(--good); opacity: .35; }
.prob.warn span { background: var(--warn); opacity: .35; }
.prob.bad span { background: var(--bad); opacity: .3; }
.prob b { position: relative; margin-left: 8px; font-size: 12px; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink); padding: 7px 14px; border-radius: 8px; font: 600 13px var(--font); cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.link { border: 0; background: none; color: var(--brand); padding: 0; }
.inline { display: inline; }

form.stack { display: grid; gap: 12px; }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.fields .wide { grid-column: 1 / -1; }
label { display: grid; gap: 4px; font-weight: 600; font-size: 12.5px; color: var(--ink-2); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=url], 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: 14px var(--font);
}
textarea { min-height: 90px; resize: vertical; }
textarea.essay { min-height: 460px; font: 15px/1.7 Georgia, "Times New Roman", serif; padding: 16px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
.filters label { min-width: 150px; }
.filters input[type=search] { min-width: 220px; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 9px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .meta { color: var(--muted); font-size: 12px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); background: var(--panel); font-weight: 500; }
.tabs a.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.tabs a:hover { text-decoration: none; }

.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); font-size: 12.5px; }
.kv dd { margin: 0; }
.note { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 10px 14px; }
.note.info { background: var(--info-bg); color: var(--info); }
.empty { color: var(--muted); padding: 16px 0; text-align: center; }
.counter { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.counter.over { color: var(--bad); font-weight: 700; }
.timeline-month { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.right { text-align: right; }
.mt { margin-top: 16px; }
.hide { display: none; }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 20; left: -270px; width: 260px; transition: left .2s; box-shadow: var(--shadow); }
  .sidebar.open { left: 0; }
  .menu-btn { display: inline-block; }
  .main { padding: 14px 16px 32px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .topbar .today { display: none; }
  .kv { grid-template-columns: 1fr; }
}
@media print { .sidebar, .menu-btn, .btn, form.filters { display: none !important; } .shell { display: block; } .card { box-shadow: none; } }
