:root {
  --bg: #f4f5f9; --card: #fff; --ink: #1c2030; --muted: #68708a; --line: #e1e4ee;
  --red: #d93a3a; --red-d: #b82c2c; --yellow: #ffcb05; --blue: #2a5fb4; --green: #12824a; --bar: #257de0;
  --r: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14161d; --card: #1e212b; --ink: #eef0f6; --muted: #9aa1b8; --line: #2e3240; --blue: #7fb0ff; --green: #4ccb86; --bar: #338ced; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--blue); }
h1 { font-size: 1.35rem; margin: 0 0 12px; }
h2 { font-size: 1.05rem; margin: 22px 0 8px; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.right { text-align: right; } .plus { color: var(--green); } .minus { color: var(--red); }

#top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top)); background: var(--red); color: #fff; }
#top .brand { display: flex; gap: 8px; align-items: center; color: #fff; font-weight: 700; text-decoration: none; }
#who { font-size: .85rem; opacity: .9; }
main { max-width: 980px; margin: 0 auto; padding: 14px 12px calc(96px + env(safe-area-inset-bottom)); }

#nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#nav a { flex: 1; text-align: center; padding: 7px 2px 8px; font-size: .72rem; color: var(--muted); text-decoration: none; }
#nav a span { display: block; height: 26px; }
#nav a span svg { display: block; margin: 0 auto; }
#nav a.on { color: var(--red); font-weight: 700; }
#nav a.add span { width: 44px; height: 44px; padding: 10px; margin: -20px auto 2px; border-radius: 50%;
  background: var(--yellow); color: #1c2030; font-weight: 700; box-shadow: 0 2px 8px rgba(0,0,0,.25); }

.box { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
label { display: block; font-size: .85rem; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
input[type=checkbox] { width: auto; margin-right: 6px; }
label.check { display: flex; align-items: center; color: var(--ink); font-size: 1rem; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
button, .btn { display: inline-block; padding: 10px 16px; border: 0; border-radius: 10px; background: var(--red); color: #fff;
  font-weight: 600; cursor: pointer; text-decoration: none; text-align: center; }
button:active, .btn:active { background: var(--red-d); }
button.sec, .btn.sec { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
button.wide { width: 100%; margin-top: 14px; }
button:disabled { opacity: .5; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.chips button { padding: 6px 12px; border-radius: 99px; background: var(--card); color: var(--ink); border: 1px solid var(--line); font-weight: 500; font-size: .9rem; }
.chips button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; text-decoration: none; color: var(--ink);
  display: flex; flex-direction: column; position: relative; padding: 0; text-align: left; font-weight: 400; }
.tile:active { background: var(--card); }
.tile .pic { aspect-ratio: 5 / 7; background: var(--line); display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.tile .pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .t { padding: 6px 8px 8px; font-size: .8rem; line-height: 1.25; }
.tile .t b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .86rem; }
.tile .t .muted { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { position: absolute; top: 6px; left: 6px; background: var(--ink); color: var(--bg); font-size: .68rem; font-weight: 700; padding: 2px 7px; border-radius: 99px; }

.detail { display: grid; grid-template-columns: minmax(120px, 220px) 1fr; gap: 14px; align-items: start; }
.detail img.big { width: 100%; border-radius: 12px; display: block; background: var(--line); }
@media (max-width: 520px) { .detail { grid-template-columns: 1fr; } .detail img.big { max-width: 240px; margin: 0 auto; } }
dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; }
dt { color: var(--muted); font-size: .88rem; } dd { margin: 0; text-align: right; font-weight: 600; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.kpi .v { font-size: 1.3rem; font-weight: 700; } .kpi .l { font-size: .8rem; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-weight: 500; font-size: .8rem; }
td.right, th.right { text-align: right; }

/* sloupcový graf: jedna řada, jedna barva, popisky v barvě textu */
.chart { display: flex; align-items: flex-end; gap: 2px; height: 150px; border-bottom: 1px solid var(--line); padding-top: 18px; }
.chart .col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; min-width: 0; }
.chart .bar { width: 70%; max-width: 30px; background: var(--bar); border-radius: 4px 4px 0 0; min-height: 0; }
.chart .col:hover .bar, .chart .col:focus .bar { filter: brightness(1.15); }
.chart .tip { position: absolute; bottom: 100%; white-space: nowrap; font-size: .7rem; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; display: none; z-index: 2; }
.chart .col:hover .tip, .chart .col:focus .tip, .chart .col.max .tip { display: block; }
.axis { display: flex; gap: 2px; font-size: .68rem; color: var(--muted); margin-top: 3px; }
.axis span { flex: 1; text-align: center; min-width: 0; overflow: hidden; }

#toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 9;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; max-width: 90vw; font-size: .92rem; }
#toast.err { background: var(--red); color: #fff; }
.login { max-width: 380px; margin: 8vh auto 0; }
.login img { display: block; margin: 0 auto 10px; }
.preview { width: 96px; border-radius: 8px; display: block; }
