:root {
  --bg: #f4f6fa; --panel: #ffffff; --ink: #1b2533; --muted: #6b7686; --line: #e2e7ef;
  --navy: #1f3a5f; --accent: #2f6fdf; --accent-soft: #e8f0fd; --ok: #1f9d6a; --warn: #e08a1e;
  --err: #c9413f; --radius: 10px; --shadow: 0 1px 2px rgba(20,30,50,.06), 0 4px 14px rgba(20,30,50,.05);
  --c1:#2f6fdf; --c2:#1f9d6a; --c3:#e08a1e; --c4:#8e5bd8; --c5:#d24f6a; --c6:#1fa3b8; --c7:#7a8699; --c8:#b5952f;
}
@media (prefers-color-scheme: dark) {
  :root { --bg:#0f141c; --panel:#171e29; --ink:#e6ebf2; --muted:#93a0b3; --line:#28323f;
          --navy:#9cc0ff; --accent:#5b8ff0; --accent-soft:#1d2b45; --shadow:none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- layout */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: #16263d; color: #c9d5e6; padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 16px; padding: 4px 10px 18px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--c1); display: grid; place-items: center; font-size: 15px; }
.side a.nav { color: #c9d5e6; padding: 9px 12px; border-radius: 8px; display: flex; gap: 10px; align-items: center; }
.side a.nav:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.side a.nav.active { background: rgba(91,143,240,.22); color: #fff; }
.side .ico { width: 18px; text-align: center; opacity: .85; }
.side .spacer { flex: 1; }
.side form button { width: 100%; background: transparent; color: #c9d5e6; border: 1px solid rgba(255,255,255,.15); }
.main { padding: 22px 28px 40px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.mobile-nav { display: none; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { display: none; }
  .mobile-nav { display: flex; gap: 6px; overflow-x: auto; background: #16263d; padding: 10px 12px; position: sticky; top: 0; z-index: 5; }
  .mobile-nav a { color: #dfe7f3; padding: 6px 10px; border-radius: 6px; white-space: nowrap; font-size: 13px; }
  .mobile-nav a.active { background: rgba(91,143,240,.3); }
  .main { padding: 16px; }
}

/* ---------- cards & grid */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g-main, .g3 { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .g4, .g2 { grid-template-columns: 1fr; } }
.mt { margin-top: 16px; }

.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 26px; font-weight: 700; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.up { color: var(--ok); } .down { color: var(--err); }

.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }
.chart-box.short { height: 200px; }

/* ---------- tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.t tr:hover td { background: rgba(47,111,223,.035); }
.t td.num, .t th.num { text-align: right; white-space: nowrap; }
.t tfoot td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: none; }
.t .desc { max-width: 420px; }

/* ---------- badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.st-vytvoreno { background: #eef0f4; color: #4f5a6b; }
.st-rozpracovano { background: #e5eefc; color: #2257b8; }
.st-k_dodelani { background: #fdf0de; color: #a55f0b; }
.st-hotovo { background: #e1f4ec; color: #157650; }
.kind-projekt { background: #f0e9fb; color: #6a3fb5; }
.kind-zadani { background: #e6f6f8; color: #137d8d; }
.badge.off { background: #f3e3e3; color: #9a3a3a; }
@media (prefers-color-scheme: dark) {
  .st-vytvoreno { background:#2a313c; color:#b9c2cf; } .st-rozpracovano { background:#1d2e4f; color:#8fb3f5; }
  .st-k_dodelani { background:#3b2d16; color:#f0b45e; } .st-hotovo { background:#173628; color:#6fd3a5; }
  .kind-projekt { background:#2d2442; color:#c3a6f2; } .kind-zadani { background:#173439; color:#7fd2de; }
}

.progress { height: 6px; background: var(--line); border-radius: 4px; overflow: hidden; min-width: 70px; }
.progress > span { display: block; height: 100%; background: var(--accent); }
.progress.over > span { background: var(--err); }

/* ---------- forms */
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 80px; resize: vertical; }
input[type=checkbox] { width: auto; margin-right: 6px; }
.check { display: flex; align-items: center; font-weight: 500; color: var(--ink); font-size: 13px; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(12, minmax(0,1fr)); }
.form-grid > * { grid-column: span 12; }
.c2 { grid-column: span 2 !important; } .c3 { grid-column: span 3 !important; } .c4 { grid-column: span 4 !important; }
.c6 { grid-column: span 6 !important; } .c8 { grid-column: span 8 !important; } .c9 { grid-column: span 9 !important; }
@media (max-width: 760px) { .c2,.c3,.c4,.c6,.c8,.c9 { grid-column: span 12 !important; } }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.filters > div { min-width: 150px; }

button, .btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; font-size: 13px; padding: 8px 14px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; text-decoration: none !important; white-space: nowrap; }
button:hover, .btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.07); }
.btn-danger { color: var(--err); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.inline { display: inline; }

.month-nav { display: inline-flex; align-items: center; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.month-nav a { padding: 4px 10px; border-radius: 6px; color: var(--ink); }
.month-nav a:hover { background: var(--accent-soft); text-decoration: none; }
.month-nav strong { padding: 0 8px; min-width: 120px; text-align: center; }

/* ---------- flash */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.flash.ok { background: #e6f5ee; border-color: #b8e2cf; color: #145c3f; }
.flash.error { background: #fbe9e8; border-color: #f0c2bf; color: #8c2b29; }
@media (prefers-color-scheme: dark) { .flash.ok { background:#163326; border-color:#245c43; color:#a9e6c8; } .flash.error { background:#3a1b1b; border-color:#6b2c2c; color:#f3b9b6; } }

/* ---------- auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 10% -10%, #2b4c7a 0%, transparent 60%), #16263d; }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border-radius: 14px; padding: 30px 28px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.auth-card h1 { margin-bottom: 4px; }
.auth-card .field { margin-top: 14px; }
.auth-card button { width: 100%; justify-content: center; margin-top: 20px; padding: 10px; }
.code-input { font-size: 24px; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.qr { background: #fff; padding: 10px; border-radius: 10px; width: 200px; height: 200px; display: block; margin: 14px auto; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--bg); padding: 6px 10px; border-radius: 6px; text-align: center; font-size: 13px; word-break: break-all; }
.steps { padding-left: 18px; color: var(--muted); font-size: 13px; }

.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.statusbar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--line); }
.statusbar span { display: block; height: 100%; }
.dl { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 13px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
.export-card { display: flex; flex-direction: column; gap: 10px; }
.export-card .big { font-size: 30px; }
