:root {
  color-scheme: light;
  --accent: #f18c15;
  --accent-dark: #db7713;
  --accent-soft: #fdf1e3;
  --bg: #ededee;
  --card: #ffffff;
  --ink: #17191c;
  --ink-2: #52514e;
  --muted: #898781;
  --line: #e6e7e9;
  --sidebar: #17191c;
  --danger: #c02626;
  --danger-soft: #fdeaea;
  --good: #1e7a4f;
  --good-soft: #e5f5ec;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --shadow: 0 6px 24px rgba(23, 25, 28, .06);
  /* kategorické sloty grafů (validovaná paleta) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --other: #b2b6bc;
  font-family: Poppins, system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --accent-soft: #3a2a17;
    --bg: #0d0d0d;
    --card: #1a1a19;
    --ink: #f4f4f2;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --line: #2c2c2a;
    --sidebar: #000;
    --danger-soft: #3b1a1a;
    --good: #0ca30c;
    --good-soft: #15291a;
    --grid: #2c2c2a;
    --axis: #383835;
    --shadow: none;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --other: #5c5f64;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --accent-soft: #3a2a17; --bg: #0d0d0d; --card: #1a1a19; --ink: #f4f4f2; --ink-2: #c3c2b7;
  --line: #2c2c2a; --sidebar: #000; --danger-soft: #3b1a1a; --good: #0ca30c; --good-soft: #15291a;
  --grid: #2c2c2a; --axis: #383835; --shadow: none;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --other: #5c5f64;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: var(--accent-dark); }
#app { display: flex; min-height: 100vh; gap: 16px; padding: 16px; }
#sidebar {
  width: 220px; flex-shrink: 0; background: var(--sidebar); border-radius: 26px; padding: 18px 12px;
  display: flex; flex-direction: column; position: sticky; top: 16px; height: calc(100vh - 32px); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 16px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 12px; }
.brand .logo { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, #f7a03c, #f18c15 55%, #db7713); display: grid; place-items: center; font-weight: 600; }
.brand b { display: block; font-weight: 600; }
.brand small { font-size: 9px; letter-spacing: .16em; color: var(--accent); }
#nav { display: flex; flex-direction: column; gap: 3px; }
#nav a { color: rgba(255,255,255,.75); text-decoration: none; padding: 10px 12px; border-radius: 12px; font-weight: 500; font-size: 13px; }
#nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
#nav a.active { background: var(--accent); color: #fff; font-weight: 600; }
#me-box { margin-top: auto; font-size: 12px; color: rgba(255,255,255,.6); padding: 8px; }
#me-box b { color: #fff; display: block; font-weight: 500; }
main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 16px; }

.card { background: var(--card); border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 12px; font-size: 17px; font-weight: 600; }
.card h3 { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.tiles { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12.5px; margin: 4px 0 10px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=url], input[type=password], input[type=date], input[type=time], input[type=month], input[type=search], select, textarea {
  background: var(--bg); border: 1.5px solid transparent; border-radius: 10px; padding: 9px 12px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); background: var(--card); }
button {
  background: var(--accent); color: #fff; border: 0; border-radius: 999px; padding: 9px 18px; font-weight: 600; cursor: pointer;
}
button:hover { background: var(--accent-dark); }
button.secondary { background: var(--bg); color: var(--ink); }
button.secondary:hover { background: var(--line); }
button.ghost { background: transparent; color: var(--ink-2); padding: 6px 10px; }
button.ghost:hover { background: var(--bg); }
button.danger { background: var(--danger-soft); color: var(--danger); }
button.small { padding: 5px 12px; font-size: 12.5px; }
button:disabled { opacity: .5; cursor: default; }
label { display: block; font-size: 12px; font-weight: 500; color: var(--ink-2); margin: 10px 0 4px; }

/* časovač nahoře */
#timerbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
#timerbar .desc { flex: 1 1 220px; }
#timerbar select { flex: 0 1 260px; }
#timerbar .elapsed { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 96px; text-align: right; }
#timerbar .running-info { flex: 1; min-width: 0; }
#timerbar .running-info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#timerbar button.stop { background: var(--danger); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; background: var(--other); }
.pulse { animation: pulse 1.6s infinite; background: var(--danger); }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

/* záznamy */
.day { margin-top: 14px; }
.day-head { display: flex; justify-content: space-between; font-weight: 600; font-size: 13px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.entry { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 12px; align-items: center; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.entry:hover { background: var(--bg); }
.entry .what { min-width: 0; }
.entry .what b { font-weight: 500; }
.entry .what small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry .actions { display: flex; gap: 2px; }
.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--ink-2); margin: 2px 4px 2px 0; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); margin: 2px 4px 2px 0; }
.chip button { background: none; color: var(--ink-2); padding: 0 2px; font-size: 13px; }

/* statistiky */
.tile .label { font-size: 12px; color: var(--muted); }
.tile .value { font-size: 28px; font-weight: 600; margin-top: 4px; }
.tile .sub { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 340px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; background: var(--bg); border-radius: 999px; padding: 3px; flex-wrap: wrap; }
.seg button { background: transparent; color: var(--ink-2); padding: 6px 12px; font-weight: 500; font-size: 12.5px; }
.seg button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-wrap { overflow-x: auto; }
.bar-cell { display: flex; align-items: center; gap: 8px; }
.bar-cell .bar { height: 8px; border-radius: 0 4px 4px 0; background: var(--s1); min-width: 2px; }

/* projekty */
.company { margin-bottom: 18px; }
.company > h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.project { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.project-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.project-head b { font-size: 15px; font-weight: 600; }
.project .meta { font-size: 12px; color: var(--muted); }
.project .line { margin-top: 8px; font-size: 12.5px; }
.project .line > span:first-child { color: var(--muted); display: inline-block; min-width: 64px; }

/* git */
.commit { display: grid; grid-template-columns: 70px minmax(0, 1fr) auto; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line); font-size: 13px; }
.commit code { color: var(--muted); }
.commit .msg { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* přihlášení */
body.login-mode #sidebar, body.login-mode #timerbar { display: none !important; }
body.login-mode main { align-items: center; justify-content: center; min-height: calc(100vh - 32px); }
.login { width: 100%; max-width: 380px; padding: 28px; }
.login .brand { color: var(--ink); border: 0; padding: 0 0 18px; }
.login input:not([type=checkbox]) { width: 100%; }
.login-error { color: var(--danger); font-size: 13px; min-height: 1em; margin: 12px 0 0; }

/* modál + toast */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--card); border-radius: 18px; padding: 22px; width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; }
.modal h2 { margin: 0 0 6px; font-size: 17px; }
.modal .row.end { justify-content: flex-end; margin-top: 18px; }
.modal input, .modal select, .modal textarea { width: 100%; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--card); padding: 10px 18px; border-radius: 999px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; }
#toast.show { opacity: 1; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.notice { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; font-size: 13px; margin-bottom: 12px; }
pre.worklog { white-space: pre-wrap; background: var(--bg); border-radius: 12px; padding: 14px; font-size: 12.5px; max-height: 420px; overflow: auto; }

@media (max-width: 860px) {
  #app { flex-direction: column; padding: 16px; }
  #sidebar { width: auto; height: auto; position: static; border-radius: 18px; padding: 12px; }
  .brand { border: 0; padding-bottom: 8px; margin: 0; }
  #nav { flex-direction: row; overflow-x: auto; }
  #nav a { white-space: nowrap; }
  #me-box { display: none; }
  .entry { grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; }
  .entry .when { display: none; }
  .grid.two { grid-template-columns: 1fr; }
  #timerbar select { flex: 1 1 100%; }
}
@media print {
  #sidebar, #timerbar, .no-print { display: none !important; }
  #app { padding: 0; }
  .card { box-shadow: none; }
}
