/* Vmalíčku Inter — expertní a střídmý: tmavě břidlicový panel, světlý podklad, bílé panely s linkou,
   hranaté tvary (4–6 px), jedna modrá jako akcent, čísla v tabulkových číslicích, grafy v kartách.
   Nikde vodorovný scroll; na mobilu menu za ☰ a tabulky složené do bloků. */

@font-face {
  font-family: 'Inter';
  src: url('/static/fonts/inter-latin-ext-wght-normal.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  src: url('/static/fonts/inter-latin-wght-normal.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --rail: #161b26;
  --rail-hi: #222a38;
  --rail-line: #262e3d;
  --rail-text: #c3c9d4;
  --rail-dim: #7f889a;
  --paper: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --head: #f1f3f6;
  --line: #e1e4ea;
  --line-strong: #c9ced8;
  --ink: #141922;
  --ink-2: #485263;
  --ink-3: #6e7889;
  --accent: #2f5fd0;
  --accent-hover: #234cb0;
  --accent-soft: #e8eefb;
  --ok: #18794a;
  --ok-soft: #e3f3ea;
  --warn: #8f5e0d;
  --warn-soft: #fbf0db;
  --fail: #b8322b;
  --fail-soft: #fbe7e5;
  --highlight: #fff4c7;
  /* datové řady (validovaná dvojice z referenční palety): s1 výnosy, s2 náklady */
  --s1: #2a78d6;
  --s2: #eb6834;
  --series: #2a78d6;
  --status-good: #0ca30c;
  --status-critical: #d03b3b;
  --status-warning: #e09a00;
  --focus-ring: 0 0 0 3px rgba(47, 95, 208, 0.28);
  --r-control: 4px;
  --r-panel: 6px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', 'SF Mono', Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: var(--font);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
}
h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0 0 0.5em;
  font-weight: 600;
  letter-spacing: -0.01em;
}
h1 {
  font-size: 1.5rem;
}
h2 {
  font-size: 0.9375rem;
}
h2 small {
  font-weight: 400;
  font-size: 0.8125rem;
}
p {
  margin: 0 0 0.75em;
}
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 3px;
}
hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1rem 0;
}
code {
  font-family: var(--mono);
  font-size: 0.92em;
}
small,
.small {
  font-size: 0.8125rem;
}
.muted {
  color: var(--ink-3);
}
.lead {
  color: var(--ink-2);
}
.nowrap {
  white-space: nowrap;
}
.url {
  word-break: break-all;
}
.error-text {
  color: var(--fail);
}
.neg {
  color: var(--fail);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.icon {
  width: 1.05rem;
  height: 1.05rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.875rem;
  flex: none;
}

/* ---------- rám ---------- */

.shell {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  min-height: 100vh;
}
.topbar {
  display: none;
}
.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--rail);
  color: var(--rail-text);
  border-right: 1px solid #0d1119;
}
.rail-brand,
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}
.rail-brand {
  padding: 1.05rem 1rem 1rem;
  border-bottom: 1px solid var(--rail-line);
}
.rail-brand:hover,
.topbar-brand:hover {
  color: #fff;
  text-decoration: none;
}
.rail-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.nav-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.nav-group-title {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--rail-dim);
  padding: 0 0.6rem 0.3rem;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.6rem;
  border-radius: 4px;
  color: var(--rail-text);
  text-decoration: none;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  text-decoration: none;
}
.nav-item.active {
  background: var(--rail-hi);
  color: #fff;
  box-shadow: inset 2px 0 0 var(--accent);
}
.nav-badge {
  margin-left: auto;
  min-width: 1.3rem;
  padding: 0 0.35rem;
  border-radius: 3px;
  background: #c8372e;
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.25rem;
  font-variant-numeric: tabular-nums;
}
/* Dole v panelu: účet (odkaz) a vedle samostatné tlačítko odhlášení */
.rail-user {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.6rem 0.5rem 0.7rem;
  border-top: 1px solid var(--rail-line);
}
.rail-account {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.5rem;
  border-radius: 4px;
  color: inherit;
  text-decoration: none;
}
.rail-account:hover {
  background: rgba(255, 255, 255, 0.05);
  text-decoration: none;
}
.rail-user .avatar {
  width: 2rem;
  height: 2rem;
  font-size: 0.6875rem;
  background: var(--rail-hi);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.rail-user-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
  line-height: 1.25;
}
.rail-user-name {
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail-user-role {
  color: var(--rail-dim);
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail-logout {
  flex: none;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--rail-dim);
  cursor: pointer;
}
.rail-logout:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}
.rail-logout .icon {
  width: 1.05rem;
  height: 1.05rem;
}

.content {
  min-width: 0;
  padding: 1.5rem 2rem 4rem;
}
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}
.page-head h1 {
  margin: 0;
}
.page-desc {
  margin: 0.2rem 0 0;
  color: var(--ink-3);
}
.head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.head-actions form {
  margin: 0;
}
.section-title {
  margin: 1.75rem 0 0.6rem;
  font-size: 0.9375rem;
}
.page-head + .section-title {
  margin-top: 0;
}

/* ---------- panely ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}
.card-alert {
  border-color: #eec2be;
}
.card-flush {
  padding: 0;
  overflow: hidden;
}
.card-pad {
  padding: 1rem 1.1rem 0;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.card-head h2 {
  margin: 0;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1rem;
}
.grid-2 > * {
  min-width: 0;
}
.empty {
  color: var(--ink-3);
  margin: 0.5rem 0;
}
.flash {
  padding: 0.55rem 0.85rem;
  border-radius: var(--r-control);
  background: var(--ok-soft);
  color: var(--ok);
  border: 1px solid #c4e4d1;
  font-weight: 500;
}
.flash-error {
  background: var(--fail-soft);
  color: var(--fail);
  border-color: #efc4bf;
}

/* ---------- čísla nahoře ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.stat {
  display: grid;
  align-content: start;
  gap: 0.15rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  padding: 0.75rem 0.9rem;
  color: var(--ink);
  text-decoration: none;
}
a.stat:hover {
  border-color: var(--line-strong);
  color: var(--ink);
  text-decoration: none;
}
.stat-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--ink-3);
}
.stat-dot {
  display: none;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--fail);
  flex: none;
}
.stat-value {
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.stat-sub {
  font-size: 0.75rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.stat-bad {
  border-color: #eec2be;
}
.stat-bad .stat-value {
  color: var(--fail);
}
.stat-bad .stat-dot {
  display: inline-block;
}
.stats-inline {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* ---------- formuláře a tlačítka ---------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
}
.row > .field {
  flex: 1 1 9rem;
}
.row > .grow {
  flex: 3 1 15rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0;
  min-width: 0;
}
.field > span,
.field > legend {
  font-weight: 500;
  font-size: 0.75rem;
  color: var(--ink-2);
}
.field small {
  font-weight: 400;
  color: var(--ink-3);
}
fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}
input:not([type='checkbox']):not([type='hidden']),
select,
textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  padding: 0.4rem 0.6rem;
  min-height: 2.25rem;
  width: 100%;
  min-width: 0;
}
textarea {
  resize: vertical;
  line-height: 1.55;
}
textarea.mono {
  font-family: var(--mono);
  font-size: 0.8125rem;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
input[type='checkbox'] {
  width: 0.95rem;
  height: 0.95rem;
  accent-color: var(--accent);
  margin: 0;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}
.check-inline {
  align-self: flex-end;
  min-height: 2.25rem;
}
.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  align-items: center;
}
.checks legend {
  margin-bottom: 0.3rem;
}
.checks .small {
  flex-basis: 100%;
}
input.code-input {
  font-family: var(--mono);
  font-size: 1.25rem;
  letter-spacing: 0.25em;
  text-align: center;
}
.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font: inherit;
  font-weight: 500;
  font-size: 0.8125rem;
  line-height: 1.2;
  padding: 0.45rem 0.9rem;
  min-height: 2.25rem;
  border-radius: var(--r-control);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover {
  background: var(--surface-2);
  border-color: #b4bbc8;
  color: var(--ink);
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}
.btn-ghost:hover {
  background: var(--head);
  border-color: transparent;
}
.btn-danger {
  background: transparent;
  border-color: #e6b3ae;
  color: var(--fail);
}
.btn-danger:hover {
  background: var(--fail-soft);
  border-color: var(--fail);
  color: var(--fail);
}
.btn-sm {
  min-height: 1.85rem;
  padding: 0.2rem 0.65rem;
  font-size: 0.8125rem;
}
.btn-xs {
  min-height: 1.6rem;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
}
.btn-block {
  width: 100%;
}
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: var(--r-control);
  cursor: pointer;
  color: inherit;
}
.icon-button:hover {
  background: rgba(255, 255, 255, 0.08);
}
.danger-zone {
  margin-top: 1rem;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  border-bottom: 1px solid var(--line-strong);
  margin-bottom: 1rem;
}
.tabs a {
  padding: 0.45rem 0.85rem;
  color: var(--ink-2);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
}
.tabs a:hover {
  color: var(--ink);
  text-decoration: none;
}
.tabs a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.section-gap {
  margin-top: 0.75rem;
}
.summary-title {
  cursor: pointer;
  font-weight: 600;
}
details[open] > .summary-title {
  margin-bottom: 0.85rem;
}
.sub-title {
  margin-top: 1rem;
}
.mono {
  font-family: var(--mono);
  font-size: 0.8125rem;
}
.snippet {
  margin: 0.4rem 0 0.9rem;
  padding: 0.7rem 0.85rem;
  background: var(--rail);
  color: #e6e9ef;
  border-radius: var(--r-control);
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 0.8125rem;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin: 0 0 1rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 1.85rem;
  padding: 0.1rem 0.65rem;
  border-radius: var(--r-control);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 0.8125rem;
  text-decoration: none;
}
.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}
.chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.chip-sep {
  width: 1px;
  height: 1.2rem;
  background: var(--line-strong);
  margin: 0 0.2rem;
}
.search {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.search input {
  flex: 1 1 14rem;
  width: auto;
}
.year-pick {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--ink-2);
}
.year-pick select {
  width: auto;
  min-height: 1.95rem;
  padding: 0.15rem 0.5rem;
}

/* ---------- štítky a stavy (hranaté, malé) ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  background: var(--head);
  color: var(--ink-2);
}
.pill-dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.badge-ok,
.badge-active {
  background: var(--ok-soft);
  color: var(--ok);
}
.badge-fail,
.badge-disabled {
  background: var(--fail-soft);
  color: var(--fail);
}
.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.badge-info,
.badge-invited,
.badge-doing {
  background: var(--accent-soft);
  color: var(--accent);
}
.badge-neutral {
  background: var(--head);
  color: var(--ink-3);
}
.status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 500;
  font-size: 0.8125rem;
}
.status-warning > span {
  color: var(--status-warning);
}
.status-critical > span {
  color: var(--status-critical);
}
.status-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  padding: 0.5rem 0.8rem;
  border-radius: var(--r-control);
  margin-bottom: 1rem;
}
.status-line.status-good {
  background: var(--ok-soft);
  color: var(--ok);
}
.status-line.status-critical {
  background: var(--fail-soft);
  color: var(--fail);
}
.status-line.status-unknown {
  background: var(--head);
  color: var(--ink-2);
}
.status-line > span {
  color: inherit;
}

/* ---------- seznamy ---------- */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}
.list li:last-child {
  border-bottom: 0;
}
.list li > a,
.list-main {
  overflow-wrap: anywhere;
  color: var(--ink);
}
.list-main {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.list-main a {
  color: var(--ink);
}
.list li > a:hover,
.list-main a:hover {
  color: var(--accent);
}
.list-meta {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.8125rem;
}
.list-meta form {
  display: inline-flex;
}

/* ---------- tabulky ---------- */

.table-wrap {
  width: 100%;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: 0.8125rem;
}
.table th,
.table td {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table th {
  font-weight: 500;
  color: var(--ink-3);
  background: var(--head);
}
.table tr:last-child td {
  border-bottom: 0;
}
.num {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}
.row-settlement td {
  color: var(--ink-3);
  font-style: italic;
}
.row-inactive td {
  color: var(--ink-3);
}
.row-warn td:nth-child(2) {
  color: var(--fail);
}
.row-actions {
  display: flex;
  gap: 0.25rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* Excel: mřížka buněk, šedé záhlaví, součty dole */
.sheet {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  font-variant-numeric: tabular-nums;
  font-size: 0.8125rem;
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  overflow: hidden;
}
.sheet th,
.sheet td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 0.4rem 0.6rem;
  text-align: left;
  vertical-align: middle;
}
.sheet th:last-child,
.sheet td:last-child {
  border-right: 0;
}
.sheet tbody tr:last-child td {
  border-bottom: 0;
}
.sheet thead th {
  background: var(--head);
  font-weight: 500;
  color: var(--ink-3);
  white-space: nowrap;
}
.sheet tbody tr:hover td {
  background: var(--surface-2);
}
.sheet tfoot td {
  border-top: 1px solid var(--line-strong);
  border-bottom: 0;
  background: var(--head);
  font-weight: 600;
}
.sheet .pos {
  color: var(--ok);
  font-weight: 600;
}
.sheet .neg {
  color: var(--fail);
  font-weight: 600;
}
.cell-action {
  width: 1%;
  white-space: nowrap;
}
.cell-action .row-actions {
  flex-wrap: nowrap;
}
/* Užší displej s bočním panelem: tabulky se musí vejít bez vodorovného scrollu */
@media (min-width: 1041px) and (max-width: 1279px) {
  .sheet th,
  .sheet td {
    padding: 0.35rem 0.4rem;
  }
  .sheet thead th {
    white-space: normal;
  }
  .cell-action .row-actions {
    flex-direction: column;
    align-items: flex-end;
  }
}

/* ---------- finance ---------- */

.add-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.6rem 0.7rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.6rem;
}
.add-form .field {
  flex: 1 1 11rem;
}
.add-form .f-date {
  flex: 0 1 10rem;
}
.add-form .f-grow {
  flex: 2 1 13rem;
}
.add-form .f-amount {
  flex: 1 1 15rem;
}
.add-form .f-split {
  flex: 0 1 auto;
}
.add-form .split-cell {
  min-height: 2.25rem;
  align-items: center;
}
.add-form > .btn {
  flex: none;
}
.amount-cell {
  display: flex;
  gap: 0.3rem;
}
.amount-cell input[name='amount'] {
  flex: 1 1 5rem;
}
.amount-cell select {
  flex: 0 0 4.6rem;
  width: 4.6rem;
}
.amount-cell .rate {
  flex: 0 0 4.2rem;
  width: 4.2rem;
}
.split-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.75rem;
}
.data-table {
  margin-top: 0.6rem;
}
.data-table summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 0.8125rem;
}
.data-table .table {
  margin-top: 0.5rem;
}

/* ---------- grafy ---------- */

.chart {
  --plot-h: 160px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 0.6rem;
  margin: 0.25rem 0 0;
}
.chart-h180 {
  --plot-h: 180px;
}
.chart-h120 {
  --plot-h: 120px;
}
.chart-y {
  position: relative;
  height: var(--plot-h);
  min-width: 2.25rem;
}
.chart-y span {
  position: absolute;
  right: 0;
  transform: translateY(-50%);
  font-size: 0.6875rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.t100 {
  top: 0;
}
.t50 {
  top: 50%;
}
.t0 {
  top: 100%;
}
.chart-plot {
  position: relative;
  min-width: 0;
}
.chart-grid {
  position: absolute;
  inset: 0 0 auto;
  height: var(--plot-h);
  pointer-events: none;
}
.chart-grid span {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid var(--line);
}
.chart-grid .t0 {
  border-top-color: var(--line-strong);
}
/* sloupce po měsících */
.chart-cols {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
}
.chart-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  cursor: default;
}
.chart-col:hover {
  background: rgba(47, 95, 208, 0.05);
}
.chart-bar {
  display: block;
  height: var(--plot-h);
  width: auto;
}
.chart-bar .s1 {
  fill: var(--s1);
}
.chart-bar .s2 {
  fill: var(--s2);
}
.chart-x {
  font-size: 0.6875rem;
  color: var(--ink-3);
  padding-bottom: 0.1rem;
}
.chart-col:hover .chart-x {
  color: var(--ink);
}
/* čáry */
.chart-svg {
  position: relative;
  display: block;
  width: 100%;
  height: var(--plot-h);
  overflow: visible;
}
.chart-xrow,
.chart-xlabels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.3rem;
  font-size: 0.6875rem;
  color: var(--ink-3);
}
.viz-line {
  fill: none;
  stroke: var(--series);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.viz-line.s1,
.viz-dot.s1 {
  stroke: var(--s1);
}
.viz-line.s2,
.viz-dot.s2 {
  stroke: var(--s2);
}
.viz-area {
  fill: var(--series);
  fill-opacity: 0.08;
}
.viz-down {
  stroke: var(--status-critical);
  stroke-width: 3;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.viz-dot,
.viz-dot-ring {
  fill: none;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.viz-dot {
  stroke: var(--series);
  stroke-width: 8;
}
.viz-dot-ring {
  stroke: var(--surface);
  stroke-width: 12;
}
.viz-hit {
  fill: transparent;
}
.viz-hit:hover {
  fill: rgba(47, 95, 208, 0.06);
}
/* legenda: značka barvy vedle textu, text vždy v barvě písma */
.chart-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  font-size: 0.8125rem;
  color: var(--ink-2);
}
.chart-legend + .chart {
  margin-top: 1rem;
}
.chart-legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.chart-legend strong {
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.key {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
.key-s1 {
  background: var(--s1);
}
.key-s2 {
  background: var(--s2);
}
.key-line {
  width: 14px;
  height: 3px;
  background: var(--series);
}
.key-down {
  width: 3px;
  height: 10px;
  background: var(--status-critical);
}
.legend {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin: 0.5rem 0 0;
}
/* vodorovné pruhy */
.hbars {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}
.hbars th,
.hbars td {
  padding: 0.35rem 0;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}
.hbars tr:last-child th,
.hbars tr:last-child td {
  border-bottom: 0;
}
.hbars th {
  text-align: left;
  font-weight: 400;
  color: var(--ink-2);
  padding-right: 0.75rem;
  white-space: nowrap;
  width: 1%;
}
.hbar-cell {
  width: 100%;
}
.hbar {
  display: block;
  width: 100%;
  height: 10px;
}
.hbar .s1 {
  fill: var(--s1);
}
.hbar .s2 {
  fill: var(--s2);
}
.hbars td.num {
  padding-left: 0.75rem;
  color: var(--ink);
}

/* ---------- úkoly ---------- */

.quick-add {
  display: grid;
  grid-template-columns: minmax(10rem, 3fr) repeat(3, minmax(7rem, 1fr)) minmax(8.5rem, 1fr) auto;
  gap: 0.5rem;
  padding: 0.7rem;
}
.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  align-items: start;
}
.col {
  background: #e9ebef;
  border-radius: var(--r-panel);
  padding: 0.6rem;
  min-height: 8rem;
}
.col h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  margin: 0.1rem 0.2rem 0.6rem;
}
.count {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--ink-3);
  background: var(--surface);
  border-radius: 3px;
  padding: 0 0.4rem;
  font-variant-numeric: tabular-nums;
}
.task-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  padding: 0.55rem 0.65rem 0.4rem;
  margin-bottom: 0.45rem;
}
.task-card:hover {
  border-color: var(--line-strong);
}
.task-card.prio-high {
  box-shadow: inset 2px 0 0 var(--fail);
}
.col-done .task-card {
  opacity: 0.7;
}
.col-done .task-title {
  text-decoration: line-through;
}
.task-title {
  display: block;
  color: var(--ink);
  font-weight: 500;
  overflow-wrap: anywhere;
}
.task-title:hover {
  color: var(--accent);
}
.task-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.45rem;
  margin-top: 0.35rem;
  font-size: 0.75rem;
}
.task-move {
  display: flex;
  justify-content: space-between;
  gap: 0.25rem;
  margin-top: 0.25rem;
}
.task-move form:only-child {
  margin-left: auto;
}
.col-done .task-move form:only-child {
  margin-left: 0;
}
.tag {
  display: inline-block;
  padding: 0.02rem 0.4rem;
  border-radius: 3px;
  font-size: 0.6875rem;
  font-weight: 600;
  background: var(--head);
  color: var(--ink-2);
  text-decoration: none;
}
.tag-fe {
  background: #e7effb;
  color: #2457b3;
}
.tag-be {
  background: #e4f2ef;
  color: #116457;
}
.tag-product {
  background: #eeebf8;
  color: #5241a5;
}
.tag-infra {
  background: #f8ece4;
  color: #9a4a16;
}
span.prio {
  font-weight: 600;
}
span.prio-high {
  color: var(--fail);
}
span.prio-low {
  color: var(--ink-3);
}
.due {
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.due.overdue {
  color: var(--fail);
  font-weight: 600;
}
.avatar {
  display: inline-grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 4px;
  background: var(--rail);
  color: #fff;
  font-size: 0.625rem;
  font-weight: 600;
  flex: none;
}
.avatar-sm {
  width: 1.35rem;
  height: 1.35rem;
  font-size: 0.5625rem;
  margin-left: auto;
}

/* poznámky k úkolu */
.task-detail {
  align-items: start;
}
.note-count {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.note-count:hover {
  color: var(--accent);
  text-decoration: none;
}
.note-count .icon {
  width: 0.85rem;
  height: 0.85rem;
}
.note-form {
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}
.note-form .actions {
  align-items: center;
}
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}
.timeline li {
  padding: 0 0 0 0.75rem;
  border-left: 2px solid var(--line);
}
.timeline-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem 0.6rem;
  font-size: 0.75rem;
  color: var(--ink-3);
}
.timeline-meta strong {
  color: var(--ink-2);
  font-weight: 600;
}
.timeline-meta form {
  margin-left: auto;
}
.timeline-text {
  margin-top: 0.2rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

/* ---------- systém, metry ---------- */

.meters {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.85rem;
}
.meters li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 1rem;
}
.meters meter,
.meters .small {
  grid-column: 1 / -1;
}
.meter-label {
  font-weight: 500;
}
.meter-value {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
meter {
  width: 100%;
  height: 0.5rem;
  border-radius: 2px;
  background: var(--head);
  border: 0;
}
meter::-webkit-meter-bar {
  background: var(--head);
  border: 0;
  border-radius: 2px;
  height: 0.5rem;
}
meter::-webkit-meter-optimum-value {
  background: var(--accent);
  border-radius: 2px;
}
meter::-webkit-meter-suboptimum-value {
  background: var(--status-warning);
  border-radius: 2px;
}
meter::-webkit-meter-even-less-good-value {
  background: var(--status-critical);
  border-radius: 2px;
}
meter::-moz-meter-bar {
  background: var(--accent);
  border-radius: 2px;
}

/* ---------- analýzy ---------- */

.note-list {
  display: grid;
  gap: 0.6rem;
}
.note-item {
  margin: 0;
}
.note-item h2 {
  margin-bottom: 0.25rem;
}
.note-item h2 a {
  color: var(--ink);
}
.note-item h2 a:hover {
  color: var(--accent);
}
.note-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.75rem;
}
.prose {
  font-size: 0.9375rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.prose h1 {
  font-size: 1.3rem;
}
.prose h2 {
  font-size: 1.1rem;
  margin-top: 1.5em;
}
.prose h3 {
  font-size: 1rem;
  margin-top: 1.25em;
}
.prose > :first-child {
  margin-top: 0;
}
.prose ul,
.prose ol {
  padding-left: 1.4rem;
}
.prose a {
  text-decoration: underline;
}
.prose blockquote {
  margin: 1rem 0;
  padding: 0.25rem 1rem;
  border-left: 3px solid var(--line-strong);
  color: var(--ink-2);
}
.prose pre {
  background: var(--surface-2);
  padding: 0.85rem;
  border-radius: var(--r-control);
  white-space: pre-wrap;
}
.prose table {
  border-collapse: collapse;
  width: 100%;
}
.prose th,
.prose td {
  border: 1px solid var(--line);
  padding: 0.4rem 0.6rem;
}
.prose img {
  max-width: 100%;
}

/* ---------- přihlášení, pozvánka ---------- */

.auth-body {
  min-height: 100vh;
  background: var(--rail);
}
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}
.auth-card {
  width: 100%;
  max-width: 24rem;
  background: var(--surface);
  border-radius: var(--r-panel);
  padding: 1.6rem 1.6rem 1.4rem;
  box-shadow: 0 24px 48px -24px rgba(0, 0, 0, 0.6);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 1rem;
}
.auth-card h1 {
  font-size: 1.375rem;
  margin-bottom: 0.9rem;
}
.auth-card .flash {
  margin-bottom: 1rem;
}
.auth-card form + form {
  margin-top: 0.75rem;
}
.auth-card .muted.small {
  margin: 1rem 0 0;
}
.remember {
  font-size: 0.8125rem;
  color: var(--ink-2);
  flex-wrap: wrap;
}
.totp-setup {
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  background: var(--surface-2);
}
.totp-setup legend {
  font-weight: 600;
  padding: 0 0.3rem;
}
.steps {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--ink-2);
  font-size: 0.8125rem;
}
.qr {
  align-self: center;
  width: 180px;
  padding: 8px;
  background: #fff;
  border-radius: var(--r-control);
  border: 1px solid var(--line);
}
.qr svg {
  display: block;
  width: 100%;
  height: auto;
}
.secret {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  margin: 0;
}
.secret code {
  font-size: 0.9rem;
  user-select: all;
  text-align: center;
}
.codes {
  columns: 2;
  gap: 1rem;
  padding: 0.9rem 0.9rem 0.9rem 2.1rem;
  background: var(--surface-2);
  border-radius: var(--r-control);
  font-family: var(--mono);
}
.codes li {
  margin-bottom: 0.2rem;
}

/* ---------- menší obrazovky (žádný vodorovný scroll) ---------- */

@media (max-width: 1100px) {
  .quick-add {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .quick-add input[name='title'] {
    grid-column: 1 / -1;
  }
}

/* Tabulky se pod 1040 px skládají do bloků (9 sloupců se vedle bočního panelu nevejde): řádek = karta, buňka = „popisek: hodnota“. */
@media (max-width: 1040px) {
  .sheet,
  .sheet tbody,
  .sheet tfoot,
  .sheet tr,
  .sheet td {
    display: block;
    width: 100%;
  }
  .sheet {
    border: 0;
    background: none;
    border-radius: 0;
    overflow: visible;
  }
  .sheet thead,
  .hide-sm {
    display: none !important;
  }
  .sheet tr {
    border: 1px solid var(--line);
    border-radius: var(--r-panel);
    background: var(--surface);
    margin-bottom: 0.45rem;
    padding: 0.35rem 0.65rem;
  }
  .sheet tfoot tr {
    background: var(--head);
  }
  .sheet td {
    border: 0 !important;
    padding: 0.2rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    text-align: right;
    background: none !important;
  }
  .sheet td[data-label]:empty {
    display: none;
  }
  .sheet td[data-label]::before {
    content: attr(data-label);
    font-weight: 500;
    color: var(--ink-3);
    text-align: left;
    flex: none;
  }
  .sheet td > * {
    min-width: 0;
  }
  .cell-action {
    width: 100%;
    justify-content: flex-end !important;
  }
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .topbar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 0.5rem 0.75rem;
    background: var(--rail);
    color: #fff;
  }
  .rail {
    display: none;
    position: fixed;
    inset: 3.1rem 0 0 0;
    height: auto;
    z-index: 19;
  }
  .nav-toggle:checked ~ .shell .rail {
    display: flex;
  }
  .nav-toggle:focus-visible ~ .shell .topbar .icon-button {
    box-shadow: 0 0 0 3px rgba(47, 95, 208, 0.6);
  }
  .rail-brand {
    display: none;
  }
  .content {
    padding: 1.1rem 1rem 3rem;
  }
  .grid-2,
  .board {
    grid-template-columns: minmax(0, 1fr);
  }
  h1 {
    font-size: 1.3rem;
  }
}

@media (max-width: 520px) {
  .quick-add {
    grid-template-columns: minmax(0, 1fr);
  }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }
  .stat-value {
    font-size: 1.15rem;
  }
  .card {
    padding: 0.85rem;
  }
  .card-pad {
    padding: 0.85rem 0.85rem 0;
  }
  .codes {
    columns: 1;
  }
  .auth-card {
    padding: 1.2rem;
  }
  /* u 12 měsíců na mobilu jen každý druhý popisek */
  .chart-cols .chart-col:nth-child(odd) .chart-x {
    visibility: hidden;
  }
}
