/* ===== Základ ============================================================= */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.45 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.006em;
  transition: background-color 280ms ease, color 280ms ease;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ===== Rozvržení ========================================================== */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 18px 12px 12px;
  background: var(--material);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  border-right: 0.5px solid var(--hairline);
  z-index: 20;
}
/* Logo NEXT REALITY (symbol #logo-next v index.html, zdroj web/img/next-logo.svg) + název aplikace za čarou */
.brand { display: flex; align-items: center; padding: 4px 10px 22px; }
.brand-mark {
  display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 8px;
  background: var(--logo-ink); color: var(--bg); font-weight: 700; font-size: 12.5px; letter-spacing: 0.02em;
  box-shadow: inset 0 -2px 0 var(--logo-gold);
}
.brand-name { font-weight: 650; font-size: 15.5px; letter-spacing: -0.015em; white-space: nowrap; color: var(--ink); margin-left: 10px; line-height: 1.1; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 12px; color: var(--ink-3); padding: 16px 10px 6px; letter-spacing: 0; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  height: 36px; padding: 0 10px; border-radius: 9px;
  color: var(--ink); font-size: 14.5px;
  transition: background-color 120ms ease;
}
.nav a svg.i { color: var(--ink-2); }
.nav a:hover { background: var(--fill-2); }
.nav a:active { background: var(--fill); }
.nav a[aria-current="page"] { background: var(--fill); font-weight: 600; }
.nav a[aria-current="page"] svg.i { color: var(--ink); }
.nav .count { margin-left: auto; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.nav .count.alert { color: var(--bad-text); font-weight: 600; }

.sidebar-foot { margin-top: auto; position: relative; }
.account {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 8px 10px; border-radius: 12px; transition: background-color 120ms ease;
}
.account:hover { background: var(--fill-2); }
.account:active, .account[aria-expanded="true"] { background: var(--fill); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--fill-strong); font-size: 12.5px; font-weight: 600; letter-spacing: 0.01em;
}
.account-name { font-size: 14px; font-weight: 600; line-height: 1.2; }
.account-role { font-size: 12.5px; color: var(--ink-2); line-height: 1.2; }
.account svg.i { margin-left: auto; color: var(--ink-3); }

.main { min-width: 0; display: flex; flex-direction: column; }

/* horní lišta s názvem stránky a filtry */
.toolbar {
  position: sticky; top: 0; z-index: 15;
  padding: 22px 32px 14px;
  background: var(--material);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  transition: box-shadow 200ms ease;
}
.toolbar.scrolled { box-shadow: 0 0.5px 0 var(--hairline); }
.toolbar-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-title { font-size: 28px; line-height: 1.15; font-weight: 700; letter-spacing: -0.022em; margin: 0; }
.page-sub { font-size: 13.5px; color: var(--ink-2); margin-top: 3px; }
.toolbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.filters { display: flex; gap: 10px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.filters .spacer { flex: 1; }
.compare-note { font-size: 13px; color: var(--ink-2); }

.content { padding: 8px 32px 64px; max-width: 1480px; width: 100%; }

/* ===== Ovládací prvky ===================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 14px; border-radius: var(--r-ctl);
  font-size: 14px; font-weight: 550; white-space: nowrap;
  background: var(--fill); color: var(--ink);
  transition: transform 100ms ease-out, background-color 120ms ease, opacity 120ms ease;
}
.btn:hover { background: var(--fill-strong); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { opacity: 0.88; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--fill-2); }
.btn.danger { color: var(--bad-text); }
.btn.danger.solid { background: var(--bad-text); color: var(--surface); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.icon { width: 34px; padding: 0; }
.btn.icon.sm { width: 28px; }
.btn[disabled] { opacity: 0.4; pointer-events: none; }

.segmented {
  display: inline-flex; position: relative; padding: 2px; border-radius: 9px;
  background: var(--fill); isolation: isolate; max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented button {
  position: relative; z-index: 1; height: 28px; padding: 0 12px; border-radius: 7px;
  font-size: 13.5px; font-weight: 500; color: var(--ink); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.segmented button[aria-pressed="true"] { font-weight: 600; }
.segmented .thumb {
  position: absolute; z-index: 0; top: 2px; bottom: 2px; left: 0; border-radius: 7px;
  background: var(--surface); box-shadow: 0 0 0 0.5px var(--hairline), 0 2px 6px rgba(0,0,0,0.08);
  will-change: transform, width;
}
:root[data-theme="dark"] .segmented .thumb { background: #636366; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .segmented .thumb { background: #636366; } }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--ink-2); }
.input, .select {
  height: 38px; padding: 0 12px; border-radius: var(--r-ctl);
  background: var(--fill-2); border: 0.5px solid var(--hairline);
  outline: none; width: 100%; transition: box-shadow 120ms ease, background-color 120ms ease;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; min-height: 72px; }
.input:focus, .select:focus { box-shadow: 0 0 0 3px var(--focus); background: var(--surface); }
.select { appearance: none; -webkit-appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.search { position: relative; }
.search svg.i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-3); }
.search .input { padding-left: 32px; height: 32px; width: 250px; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--fill-2); color: var(--ink-2);
}
.pill svg.i { width: 13px; height: 13px; stroke-width: 2.2; }
.pill.good { background: var(--good-bg); color: var(--good-text); }
.pill.bad { background: var(--bad-bg); color: var(--bad-text); }
.pill.warn { background: var(--warn-bg); color: var(--warn-text); }

.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta svg.i { width: 14px; height: 14px; stroke-width: 2.25; }
.delta.good { color: var(--good-text); }
.delta.bad { color: var(--bad-text); }
.delta.flat { color: var(--ink-2); }

/* ===== Karty a widgety ==================================================== */
.card {
  background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-card);
  padding: 18px 20px 20px; min-width: 0;
}
.card-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 14px; min-height: 22px; }
.card-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.35; }
.card-sub { font-size: 12.5px; color: var(--ink-2); margin-top: 1px; }
.card-head .btn { margin: -4px -8px 0 auto; }
.card-link { margin-left: auto; font-size: 13px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 2px; }
.card-link:hover { color: var(--ink); }
.card-link svg.i { width: 15px; height: 15px; }

.grid-widgets {
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: stretch;
}
.widget { position: relative; grid-column: span 1; touch-action: auto; }
.widget[data-size="m"] { grid-column: span 2; }
.widget[data-size="l"] { grid-column: span 4; }
.widget .card { height: 100%; }
.widget .w-menu { opacity: 0; transition: opacity 120ms ease; }
.widget:hover .w-menu, .widget:focus-within .w-menu { opacity: 1; }
@media (hover: none) { .widget .w-menu { opacity: 1; } }

/* režim úprav */
.editing .widget { cursor: grab; touch-action: none; }
.editing .widget > .card { box-shadow: 0 0 0 1px var(--hairline-strong), 0 1px 2px rgba(0,0,0,0.04); }
.editing .widget .w-body { pointer-events: none; }
.editing .widget .w-menu { opacity: 1; }
.w-remove {
  position: absolute; top: -8px; left: -8px; z-index: 3; width: 24px; height: 24px; border-radius: 50%;
  display: none; place-items: center; background: var(--ink); color: var(--bg);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2); transition: transform 100ms ease-out;
}
.w-remove svg.i { width: 14px; height: 14px; stroke-width: 2.6; }
.w-remove:active { transform: scale(0.9); }
.editing .w-remove { display: grid; }
.widget.dragging { position: fixed; z-index: 100; margin: 0; cursor: grabbing; pointer-events: none; }
.widget.dragging > .card { box-shadow: var(--shadow-lift); }
.widget-placeholder { border-radius: var(--r-card); background: var(--fill-2); box-shadow: inset 0 0 0 1px var(--hairline); }
.edit-bar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 14px; padding: 10px 12px 10px 16px;
  border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-card); font-size: 14px;
}
.edit-bar .muted { flex: 1; }

/* KPI */
.kpi-value { font-size: 30px; line-height: 1.1; font-weight: 650; letter-spacing: -0.026em; white-space: nowrap; }
.kpi-value .unit { font-size: 0.6em; font-weight: 600; color: var(--ink-2); margin-left: 3px; letter-spacing: -0.01em; }
.kpi-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.kpi-prev { font-size: 12.5px; color: var(--ink-2); }
.kpi-spark { margin-top: 14px; height: 36px; }
.kpi-split { margin-top: 14px; display: grid; gap: 6px; }
.kpi-split-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.kpi-split-row .v { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--ink-2); }

.hero-value { font-size: 44px; line-height: 1.04; font-weight: 650; letter-spacing: -0.032em; }
.hero-meta { display: flex; gap: 18px; margin-top: 12px; flex-wrap: wrap; }
.hero-meta div { font-size: 13px; color: var(--ink-2); }
.hero-meta b { display: block; font-size: 17px; color: var(--ink); font-weight: 600; letter-spacing: -0.012em; font-variant-numeric: tabular-nums; }
.composition { margin-top: 18px; }
.composition-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; gap: 2px; background: var(--surface); }
.composition-bar span { display: block; height: 100%; }
.composition-legend { display: flex; gap: 14px; margin-top: 10px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.composition-legend span { display: inline-flex; align-items: center; gap: 6px; }

/* seznamy */
.list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 0.5px solid var(--hairline);
  min-height: 48px;
}
.list-row:first-child { border-top: 0; padding-top: 2px; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .t { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .s { font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .v { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
a.list-row { margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: 10px; }
a.list-row:hover { background: var(--fill-2); }
.list-row + a.list-row, a.list-row + .list-row { border-top-color: var(--hairline); }
.alert-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.alert-icon svg.i { width: 16px; height: 16px; stroke-width: 2; }
.alert-icon.critical { background: var(--bad-bg); color: var(--bad-text); }
.alert-icon.warning { background: var(--warn-bg); color: var(--warn-text); }
.alert-icon.info { background: var(--fill); color: var(--ink-2); }

/* ===== Grafy ============================================================== */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font-size: 11px; fill: var(--ink-3); font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .hl-band { fill: var(--fill-2); }
.chart .hover-col { fill: var(--fill-2); opacity: 0; }
.chart .hover-col.on { opacity: 1; }
.chart .crosshair { stroke: var(--ink-4); stroke-width: 1; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .marker { stroke: var(--surface); stroke-width: 2; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.tooltip {
  position: fixed; z-index: 200; pointer-events: none; min-width: 150px;
  padding: 10px 12px; border-radius: 12px; font-size: 12.5px;
  background: var(--material-thick); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow-pop); opacity: 0; transform: translateY(4px) scale(0.98);
  transition: opacity 120ms ease, transform 160ms var(--ease-out);
}
.tooltip.on { opacity: 1; transform: none; }
.tooltip .tt-title { font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; color: var(--ink-2); line-height: 1.7; }
.tooltip .tt-row b { margin-left: auto; padding-left: 14px; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.tooltip .tt-total { border-top: 0.5px solid var(--hairline); margin-top: 4px; padding-top: 4px; }

.donut-wrap { display: flex; align-items: center; gap: 22px; }
.donut-wrap .chart { width: 152px; flex: none; }
.donut-wrap .donut-legend { flex: 1; min-width: 0; display: grid; gap: 2px; }
.donut-legend-row { display: flex; align-items: center; gap: 9px; padding: 6px 8px; margin: 0 -8px; border-radius: 8px; font-size: 13.5px; transition: background-color 100ms ease; }
.donut-legend-row.on { background: var(--fill-2); }
.donut-legend-row .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend-row .v { font-variant-numeric: tabular-nums; font-weight: 600; }
.donut-legend-row .sh { font-variant-numeric: tabular-nums; color: var(--ink-2); width: 46px; text-align: right; }
.donut-center-v { font-size: 17px; font-weight: 650; fill: var(--ink) !important; letter-spacing: -0.02em; }
.donut-center-l { font-size: 11px; }

.hbars { display: grid; gap: 11px; }
.hbar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; font-size: 13.5px; align-items: baseline; }
.hbar-row .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.hbar-row .v small { font-weight: 500; color: var(--ink-2); margin-left: 6px; font-size: 12px; }
.hbar-track { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--fill-2); overflow: hidden; }
.hbar-track span { display: block; height: 100%; border-radius: 3px; background: var(--data-neutral); transform-origin: left; }

.table-view { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-view th, .table-view td { padding: 6px 0; border-top: 0.5px solid var(--hairline); text-align: right; font-variant-numeric: tabular-nums; }
.table-view th { color: var(--ink-2); font-weight: 500; }
.table-view th:first-child, .table-view td:first-child { text-align: left; }

/* ===== Tabulky ============================================================ */
.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th {
  position: sticky; top: 0; text-align: left; font-weight: 500; font-size: 12.5px; color: var(--ink-2);
  padding: 12px 14px 9px; border-bottom: 0.5px solid var(--hairline); background: var(--surface); white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 0.5px solid var(--hairline); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tbody tr.click { cursor: pointer; transition: background-color 100ms ease; }
.table tbody tr.click:hover td { background: var(--fill-2); }
.table .sub { display: block; font-size: 12.5px; color: var(--ink-2); }
.amount-pos { color: var(--good-text); }
.center-tag { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }

/* výsledovka */
.pnl th.r, .pnl td.r { min-width: 120px; }
.pnl td:first-child, .pnl th:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 230px; }
.pnl tr.group td { font-weight: 600; background: var(--surface-2); }
.pnl tr.group td:first-child { background: var(--surface-2); }
.pnl tr.group button { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.pnl tr.group button svg.i { width: 15px; height: 15px; transition: transform 220ms var(--ease-out); color: var(--ink-3); }
.pnl tr.group.collapsed button svg.i { transform: rotate(-90deg); }
.pnl tr.child td:first-child { padding-left: 42px; }
.pnl tr.total td { font-weight: 650; border-top: 0.5px solid var(--hairline-strong); }
.pnl tr.result td { font-size: 15.5px; font-weight: 700; background: var(--surface-2); }
.pnl tr.result td:first-child { background: var(--surface-2); }
.pnl tr.margin td { color: var(--ink-2); font-size: 13px; }
.pnl .col-total { background: var(--fill-2); }
.pnl tr.group td.col-total, .pnl tr.result td.col-total { background: var(--fill); }

/* souhrnné dlaždice na podstránkách */
.stat-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.stat { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-card); padding: 16px 18px; min-width: 0; }
.stat-l { font-size: 13px; color: var(--ink-2); }
.stat-v { font-size: 24px; font-weight: 650; letter-spacing: -0.022em; margin-top: 4px; white-space: nowrap; }
.stat-s { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; display: flex; gap: 6px; align-items: center; }
.stat.button { text-align: left; transition: transform 100ms ease-out, box-shadow 160ms ease; }
.stat.button:active { transform: scale(0.985); }
.stat.button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }

.two-col { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--gap); margin-bottom: var(--gap); }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.stack { display: grid; gap: var(--gap); }

.flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr; align-items: center; gap: 10px; }
.flow-step .stat-l { white-space: nowrap; }
.flow-op { font-size: 20px; color: var(--ink-3); font-weight: 300; text-align: center; }

/* ===== Plovoucí vrstvy ==================================================== */
.popover {
  position: fixed; z-index: 160; min-width: 270px; padding: 6px; border-radius: 14px;
  background: var(--material-thick); -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  box-shadow: var(--shadow-pop);
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px; border-radius: 8px;
  font-size: 14px; text-align: left;
}
.menu-item:hover { background: var(--fill); }
.menu-item svg.i { width: 17px; height: 17px; color: var(--ink-2); }
.menu-item .check { margin-left: auto; color: var(--ink); }
.menu-sep { height: 0.5px; background: var(--hairline); margin: 6px 4px; }
.menu-label { font-size: 12px; color: var(--ink-3); padding: 6px 10px 4px; }
.menu-block { padding: 4px 6px 6px; }
.menu-block .segmented { width: 100%; }
.menu-block .segmented button { flex: 1; justify-content: center; }

.scrim { position: fixed; inset: 0; z-index: 140; background: var(--scrim); opacity: 0; transition: opacity 260ms ease; }
.scrim.on { opacity: 1; }
.sheet {
  position: fixed; z-index: 150; top: 12px; right: 12px; bottom: 12px; width: min(480px, calc(100vw - 24px));
  display: flex; flex-direction: column; border-radius: 22px; overflow: hidden;
  background: var(--surface); box-shadow: var(--shadow-lift);
  will-change: transform;
}
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 18px 18px 10px 22px; }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; flex: 1; }
.sheet-body { flex: 1; overflow-y: auto; padding: 6px 22px 22px; }
.sheet-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 22px 18px; border-top: 0.5px solid var(--hairline); }
.foot-ask { flex: 1; display: flex; gap: 8px; align-items: flex-start; margin: 0; font-size: 14px; font-weight: 600; color: var(--bad-text); }
.foot-ask > span { display: flex; flex-direction: column; gap: 2px; }
.foot-ask .faint { font-weight: 400; font-size: 13px; }
.foot-ask .i { flex: none; margin-top: 2px; }
@media (max-width: 600px) { .sheet-foot:has(.foot-ask) { flex-wrap: wrap; } .foot-ask { flex-basis: 100%; } }
.sheet .grab { display: none; }
.form-grid { display: grid; gap: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { color: var(--bad-text); font-size: 13px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 10px 14px; font-size: 14px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-weight: 500; }

.toast {
  position: fixed; z-index: 300; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0;
  display: flex; align-items: center; gap: 10px; padding: 11px 18px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent); font-size: 14px; font-weight: 550;
  box-shadow: var(--shadow-pop); transition: opacity 200ms ease, transform 320ms var(--ease-out);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast svg.i { width: 17px; height: 17px; }

/* katalog widgetů */
.catalog { display: grid; gap: 8px; }
.catalog-item {
  display: flex; align-items: center; gap: 14px; text-align: left; padding: 12px 14px; border-radius: 14px;
  background: var(--fill-2); transition: background-color 120ms ease, transform 100ms ease-out;
}
.catalog-item:hover { background: var(--fill); }
.catalog-item:active { transform: scale(0.985); }
.catalog-item .ci-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--surface); box-shadow: var(--shadow-card); flex: none; }
.catalog-item .t { font-weight: 600; font-size: 14.5px; }
.catalog-item .s { font-size: 13px; color: var(--ink-2); }
.catalog-item .added { margin-left: auto; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.section-title { font-size: 17px; font-weight: 650; letter-spacing: -0.014em; margin: 26px 0 10px; }
.section-title:first-child { margin-top: 4px; }

/* nastavení */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start; }
.settings-nav { position: sticky; top: 150px; display: grid; gap: 2px; }
.settings-nav a { padding: 8px 12px; border-radius: 9px; font-size: 14.5px; }
.settings-nav a:hover { background: var(--fill-2); }
.settings-nav a[aria-current="true"] { background: var(--fill); font-weight: 600; }
.settings-section { margin-bottom: 30px; scroll-margin-top: 140px; }
.settings-section > h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 4px; }
.settings-section > p { color: var(--ink-2); margin: 0 0 14px; font-size: 14px; max-width: 64ch; }
.group-card { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-card); padding: 4px 18px; }
.group-card .list-row { padding: 12px 0; }
.switch { position: relative; width: 44px; height: 26px; border-radius: 13px; background: var(--fill-strong); flex: none; transition: background-color 200ms ease; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.2); transition: transform 260ms var(--ease-out); }
.switch[aria-checked="true"] { background: var(--good); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px; border-radius: var(--r-card);
  background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--hairline-strong); text-align: center; color: var(--ink-2); font-size: 14px;
  transition: box-shadow 160ms ease, background-color 160ms ease;
}
.dropzone.over { box-shadow: inset 0 0 0 2px var(--ink); background: var(--fill-2); }
.dropzone b { color: var(--ink); font-size: 15px; }
.empty { padding: 34px 10px; text-align: center; color: var(--ink-2); font-size: 14px; }

/* ===== Mobil: horní lišta s burger menu ================================== */
.mobilebar { display: none; }

/* ===== Responzivita ======================================================= */
@media (max-width: 1240px) {
  .grid-widgets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .widget[data-size="l"] { grid-column: span 2; }
  .stat-strip:not(.flow) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 1000px) {
  .flow { grid-template-columns: 1fr 1fr; }
  .flow-op { display: none; }
  .three-col { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  :root { --gap: 12px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  /* Burger menu: postranní panel se na mobilu vysouvá zleva (pružinou z main.js), včetně účtu dole. */
  .mobilebar {
    display: flex; align-items: center; gap: 6px; position: sticky; top: 0; z-index: 25;
    padding: calc(6px + env(safe-area-inset-top)) 12px 6px 6px;
    background: var(--material); -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
    box-shadow: 0 0.5px 0 var(--hairline);
  }
  .mobilebar .brand { padding: 0; }
  .burger { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: var(--ink); }
  .burger svg.i { width: 24px; height: 24px; }
  .burger:active, .burger[aria-expanded="true"] { background: var(--fill-2); }
  .sidebar {
    position: fixed; z-index: 150; top: 0; bottom: 0; left: 0; height: auto; width: min(300px, 86vw);
    padding: calc(18px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
    background: var(--surface); border-right: 0; box-shadow: var(--shadow-pop);
    transform: translate3d(-105%, 0, 0); visibility: hidden; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
  }
  .sidebar.drawer-open { visibility: visible; transform: none; }   /* pružina po doběhnutí smaže inline posun */
  .sidebar .nav a { height: 44px; font-size: 16px; }
  .sidebar .account { padding: 10px; }
  .toolbar { position: relative; padding: 14px 16px 10px; }
  .toolbar-row { flex-wrap: nowrap; align-items: flex-start; }
  .toolbar-row > div:first-child { min-width: 0; }
  .toolbar-actions .btn span { display: none; }
  .toolbar-actions .btn { width: 34px; padding: 0; }
  .toolbar-actions .btn.primary span { display: inline; }
  .toolbar-actions .btn.primary { width: auto; padding: 0 14px; }
  .page-title { font-size: 26px; }
  .page-sub { font-size: 13px; }
  .content { padding: 4px 16px calc(40px + env(safe-area-inset-bottom)); }
  .filters { margin-top: 12px; gap: 8px; }
  .filters > * { max-width: 100%; }
  .filters .spacer, .compare-note { display: none; }
  .search .input { width: 160px; }
  .card { padding: 15px 16px 16px; }
  .kpi-value { font-size: 23px; }
  .hero-value { font-size: 36px; }
  .widget[data-size="s"] .kpi-spark { display: none; }
  .widget[data-size="s"] .kpi-split-row { flex-wrap: wrap; row-gap: 2px; }
  .widget[data-size="s"] .kpi-split-row .v { margin-left: 0; }
  .widget[data-size="s"] .card-title { font-size: 14px; }
  .donut-wrap { flex-direction: column; align-items: stretch; }
  .donut-wrap .chart { margin: 0 auto; }
  .settings { grid-template-columns: 1fr; gap: 12px; }
  .settings-nav { position: static; display: flex; overflow-x: auto; scrollbar-width: none; }
  .settings-nav a { white-space: nowrap; }
  .table th:first-child, .table td:first-child { padding-left: 16px; }
  .table th:last-child, .table td:last-child { padding-right: 16px; }
  .hide-m { display: none; }
  .sheet { top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 92vh; border-radius: 22px 22px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .sheet .grab { display: block; width: 36px; height: 5px; border-radius: 3px; background: var(--fill-strong); margin: 8px auto -4px; flex: none; }
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .stat-v { font-size: 20px; }
  .stat { padding: 13px 14px; }
  .kv { grid-template-columns: 110px 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}
@media print {
  .sidebar, .mobilebar, .toolbar-actions, .w-menu { display: none !important; }
  .app { grid-template-columns: 1fr; }
}

/* ===== Provoz: poptávky a kalendář ======================================== */
svg.i.flip { transform: scaleX(-1); }
.flowbar { display: flex; gap: 4px; margin: 0 0 6px; }
.flowbar span { flex: 1; font-size: 11.5px; color: var(--ink-3); padding-top: 8px; border-top: 3px solid var(--fill); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flowbar span.done { border-top-color: var(--ink-3); color: var(--ink-2); }
.flowbar span.on { border-top-color: var(--ink); color: var(--ink); font-weight: 600; }
.quote { margin: 0; padding: 12px 14px; border-left: 3px solid var(--hairline-strong); background: var(--fill-2); border-radius: 0 10px 10px 0; font-size: 14px; color: var(--ink-2); }
.timeline { display: grid; gap: 6px; font-size: 13.5px; }
.timeline > div { padding-left: 14px; position: relative; }
.timeline > div::before { content: ""; position: absolute; left: 0; top: 8px; width: 6px; height: 6px; border-radius: 50%; background: var(--ink-4); }
.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-title { margin: 0 6px; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; min-width: 150px; text-align: center; }
.cal-card { padding: 0; overflow: hidden; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-dow { padding: 10px 10px 8px; font-size: 12px; color: var(--ink-3); border-bottom: 0.5px solid var(--hairline); }
.cal-day { min-height: 112px; padding: 6px; border-right: 0.5px solid var(--hairline); border-bottom: 0.5px solid var(--hairline); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.out { background: var(--surface-2); }
.cal-day.out .cal-n { color: var(--ink-4); }
.cal-n { font-size: 12.5px; font-weight: 600; color: var(--ink-2); padding: 2px 4px; align-self: flex-start; border-radius: 6px; }
.cal-day.today .cal-n { background: var(--accent); color: var(--on-accent); }
.cal-ev { text-align: left; font-size: 12px; line-height: 1.3; padding: 5px 7px; border-radius: 7px; background: color-mix(in srgb, var(--c) 13%, transparent); border-left: 3px solid var(--c); color: var(--ink); min-width: 0; transition: background-color 120ms ease; }
.cal-ev:hover { background: color-mix(in srgb, var(--c) 22%, transparent); }
.cal-ev span { display: block; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-ev.tent { background: transparent; border: 1px dashed var(--c); border-left-width: 3px; border-left-style: solid; }
.cal-tent { display: inline-block; width: 14px; height: 10px; border: 1px dashed var(--ink-3); border-radius: 3px; }
@media (max-width: 860px) {
  .cal-day { min-height: 72px; padding: 3px; }
  .cal-ev { font-size: 0; padding: 0; height: 6px; border-left-width: 0; background: var(--c); }
  .cal-ev.tent { background: transparent; border: 1px dashed var(--c); }
  .flowbar span { font-size: 0; }
}

/* ===== NEXT AI Hub: Fakturace, Call centrum, Chytře bydlím =================== */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.grid-2 .span-2 { grid-column: 1 / -1; }
.note-card { display: flex; gap: 14px; align-items: center; margin-bottom: var(--gap); }
.note-card .t { font-weight: 600; font-size: 14.5px; }
.note-card .s { font-size: 13.5px; color: var(--ink-2); margin-top: 2px; max-width: 80ch; }
.note-card .s a { text-decoration: underline; text-underline-offset: 2px; }
.table th.check, .table td.check { width: 34px; padding-right: 0; }
.table input[type="checkbox"], .draft input[type="checkbox"], .check-line input { width: 17px; height: 17px; accent-color: var(--accent); }
.draft-list { display: grid; gap: 14px; }
.draft { display: grid; gap: 8px; padding: 12px; border-radius: 14px; background: var(--fill-2); }
.draft-head { display: flex; gap: 10px; align-items: center; font-size: 14px; cursor: pointer; }
.draft textarea { font-size: 13.5px; line-height: 1.45; }
.spacer { flex: 1; }
.hint { font-size: 12px; color: var(--ink-3); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-row[hidden], [data-only][hidden] { display: none; }
.check-line { display: flex; gap: 8px; align-items: center; height: 38px; font-size: 14px; color: var(--ink); }

.chb-layout { display: grid; grid-template-columns: minmax(330px, 400px) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.chb-side { position: sticky; top: 150px; }
.chb-side, .chb-form { min-width: 0; }
.chb-form .segmented { width: 100%; max-width: 100%; }
.chb-form .segmented button { flex: 1 1 0; min-width: 0; justify-content: center; text-align: center; white-space: normal; line-height: 1.15; height: auto; min-height: 28px; padding: 5px 8px; }
.chb-sum { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; padding: 12px 14px; border-radius: 14px; background: var(--fill-2); }
.chb-sum span { display: block; font-size: 12px; color: var(--ink-2); }
.chb-sum b { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.chb-sum .pill { grid-column: 1 / -1; justify-self: start; white-space: normal; }
.chb-stage { min-width: 0; }
.chb-stage-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 13px; }
.chb-preview { overflow-x: auto; padding-bottom: 8px; }

@media (max-width: 1100px) {
  .chb-layout { grid-template-columns: minmax(0, 1fr); }
  .chb-side { position: static; }
}
@media (max-width: 860px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .note-card { flex-wrap: wrap; }
  .form-row { grid-template-columns: minmax(0, 1fr); }
  .chb-stage-bar [data-zoom] { display: none; }
}

/* ===== Pronájem prostor: týdenní kalendář místností ====================== */
.rcal { display: grid; grid-template-columns: 112px repeat(7, minmax(0, 1fr)); }
.rcal-corner, .rcal-day { padding: 10px 8px 8px; font-size: 12.5px; color: var(--ink-2); border-bottom: 0.5px solid var(--hairline); }
.rcal-day span { color: var(--ink-3); }
.rcal-day.today { color: var(--ink); font-weight: 650; }
.rcal-day.today span { color: var(--ink); }
.rcal-room { display: block; padding: 10px 10px; border-bottom: 0.5px solid var(--hairline); border-right: 0.5px solid var(--hairline); font-size: 13.5px; }
.rcal-room .dot { margin-right: 6px; }
.rcal-room small { display: block; margin-top: 2px; }
.rcal-room small { color: var(--ink-3); font-size: 11.5px; }
.rcal-cell { min-height: 96px; padding: 5px; display: flex; flex-direction: column; gap: 4px; border-bottom: 0.5px solid var(--hairline); border-right: 0.5px solid var(--hairline); min-width: 0; }
.rcal-cell:last-child { border-right: 0; }
.rcal-cell.we, .rcal-day.we { background: var(--surface-2); }
.cal-ev.via { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--c) 14%, transparent) 0 5px, transparent 5px 10px); border-left-style: dotted; color: var(--ink-2); }
.rcal-via-key { display: inline-block; width: 16px; height: 10px; margin-right: 6px; vertical-align: -1px; background: repeating-linear-gradient(135deg, var(--ink-4) 0 3px, transparent 3px 6px); border-radius: 2px; }
.note-inline { margin: -4px 0 14px; padding: 10px 12px; border-radius: 12px; background: var(--warn-bg); color: var(--warn-text); font-size: 13.5px; display: flex; gap: 8px; align-items: flex-start; }
.note-inline svg.i { width: 16px; height: 16px; flex: none; margin-top: 2px; }
@media (max-width: 860px) {
  .rcal { grid-template-columns: 64px repeat(7, minmax(110px, 1fr)); overflow-x: auto; }
  .cal-card:has(.rcal) { overflow-x: auto; }
  .rcal { width: max-content; min-width: 100%; }
}

/* ===== Uživatelé a oprávnění (převzato z BTN APP) ===== */
.perm-list { display: grid; }
.perm-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 0.5px solid var(--hairline); }
.perm-row:first-child { border-top: 0; }
.perm-row .grow { flex: 1; min-width: 0; }
.perm-row .t { font-size: 14px; font-weight: 500; }
.perm-row .s { font-size: 12px; color: var(--ink-3); }
.perm-row .segmented { flex: none; }
@media (max-width: 520px) { .perm-row { flex-direction: column; align-items: stretch; gap: 6px; } }

/* ---------- Asistent (převzato z BTN APP) ---------- */
.ai-off { display: flex; gap: 14px; align-items: flex-start; max-width: 640px; }
.ai-off p { margin: 6px 0 0; font-size: 14px; }
.ai-log { display: flex; flex-direction: column; gap: 22px; padding: 8px 0 24px; }
.ai-intro { margin: auto 0; padding: 24px 0 32px; }
.ai-intro h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 6px; }
.ai-intro > p { margin: 0 0 20px; font-size: 14.5px; max-width: 560px; }
.ai-samples { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ai-sample {
  display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 12px 14px; border-radius: 14px;
  background: var(--surface); box-shadow: var(--shadow-card); font-size: 14px; line-height: 1.4;
  transition: background-color 120ms ease, transform 120ms ease;
}
.ai-sample:hover { background: var(--surface-2); }
.ai-sample:active { transform: scale(0.98); }
.ai-sample svg.i { color: var(--ink-3); margin-top: 1px; }

.ai-msg.user { display: flex; justify-content: flex-end; }
.ai-bubble { max-width: 78%; padding: 10px 14px; border-radius: 18px 18px 6px 18px; background: var(--fill); font-size: 15px; overflow-wrap: anywhere; }
.ai-msg.bot { position: relative; }
.ai-actions { display: flex; gap: 4px; margin: 6px 0 0 -10px; opacity: 0.75; transition: opacity 120ms ease; }
.ai-msg.bot:hover .ai-actions { opacity: 1; }
.ai-msg.pending .ai-actions { display: none; }
.ai-work { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink-2); padding: 4px 0; }
.ai-dots { display: inline-flex; gap: 4px; }
.ai-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: ai-dot 1.2s infinite ease-in-out; }
.ai-dots i:nth-child(2) { animation-delay: 0.15s; }
.ai-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes ai-dot { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
.ai-err { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--bad-bg); color: var(--bad-text); font-size: 14px; }

/* text odpovědi */
.md { font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 10px; }
.md h2 { font-size: 20px; letter-spacing: -0.015em; margin: 18px 0 8px; }
.md h3 { font-size: 16.5px; margin: 18px 0 6px; }
.md h4, .md h5 { font-size: 15px; margin: 14px 0 4px; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md li { margin: 3px 0; }
.md strong { font-weight: 600; }
.md code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--fill-2); padding: 1px 5px; border-radius: 5px; }
.md hr { border: 0; border-top: 0.5px solid var(--hairline-strong); margin: 16px 0; }
.md blockquote { margin: 10px 0; padding: 8px 12px; border-left: 3px solid var(--hairline-strong); background: var(--fill-2); border-radius: 0 10px 10px 0; color: var(--ink-2); }
.md-table { overflow-x: auto; margin: 6px 0 14px; border-radius: 12px; box-shadow: var(--shadow-card); background: var(--surface); }
.md table { border-collapse: collapse; width: 100%; font-size: 14px; }
.md th, .md td { padding: 8px 12px; text-align: left; border-top: 0.5px solid var(--hairline); white-space: nowrap; }
.md td:first-child, .md th:first-child { white-space: normal; min-width: 140px; }
.md thead th { border-top: 0; font-size: 12.5px; font-weight: 600; color: var(--ink-2); background: var(--surface-2); }
.md .r { text-align: right; font-variant-numeric: tabular-nums; }

/* psací pole */
.ai-composer { position: sticky; bottom: 0; padding: 10px 0 16px; background: linear-gradient(to bottom, transparent, var(--bg) 18px); }
.ai-box { display: flex; align-items: flex-end; gap: 8px; padding: 8px 8px 8px 16px; border-radius: 22px; background: var(--surface); box-shadow: var(--shadow-pop); }
.ai-box:focus-within { box-shadow: var(--shadow-pop), 0 0 0 3px var(--focus); }
.ai-box textarea { flex: 1; border: 0; outline: 0; resize: none; background: transparent; padding: 7px 0; font-size: 15.5px; line-height: 1.45; max-height: 220px; }
.ai-bar { display: flex; align-items: center; gap: 6px; }
.ai-send { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); transition: opacity 120ms ease, transform 120ms ease; }
.ai-send:active { transform: scale(0.92); }
.ai-send[disabled] { opacity: 0.35; }
.ai-send svg.i { stroke-width: 2.2; }
.ai-usage { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; }
.ai-usage:hover { background: var(--fill-2); }
.ai-usage svg { transform: rotate(-90deg); }
.ai-usage circle { fill: none; stroke-width: 4; }
.ai-usage .track { stroke: var(--fill-strong); }
.ai-usage .fill { stroke: var(--ink-2); stroke-linecap: round; stroke-dasharray: 0 100; transition: stroke-dasharray 400ms var(--ease-out); }
.ai-usage[data-level="warn"] .fill { stroke: var(--warn); }
.ai-usage[data-level="bad"] .fill { stroke: var(--bad); }
.ai-usage-pop { padding: 12px 14px; width: 290px; display: grid; gap: 8px; }
.ai-usage-pop .t { font-weight: 600; font-size: 14px; }
.ai-usage-pop p { margin: 0; font-size: 13px; }
.ai-usage-pop .bar { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.ai-usage-pop .bar span { display: block; height: 100%; background: var(--ink-2); border-radius: 3px; }
.ai-usage-pop .bar[data-level="warn"] span { background: var(--warn); }
.ai-usage-pop .bar[data-level="bad"] span { background: var(--bad); }
.ai-usage-pop .btn { justify-self: start; }
.ai-note { display: flex; gap: 6px; align-items: flex-start; margin: 8px 6px 0; font-size: 12px; color: var(--ink-3); line-height: 1.4; }
.ai-note svg.i { width: 14px; height: 14px; margin-top: 1px; }
.ai-hist .ai-hist-open { text-align: left; min-width: 0; }
@media (max-width: 860px) {
  .ai { min-height: calc(100vh - 230px); }
  .ai-samples { grid-template-columns: 1fr; }
  .ai-bubble { max-width: 88%; }
  .ai-composer { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .ai-note { font-size: 11.5px; }
}
@media print {
  .ai-composer, .ai-actions { display: none !important; }
}



.ai { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; min-height: calc(100vh - 150px); }

/* ---------- VST: výsledky středisek (kladné doprava, záporné doleva) ---------- */
.diverge { display: grid; gap: 2px; }
.diverge-row { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 5px 4px; border-radius: 8px; font-size: 13.5px; }
.diverge-row:hover { background: var(--fill-2); }
.diverge-row .lbl { display: flex; align-items: center; gap: 7px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diverge-row .bar { position: relative; height: 10px; }
.diverge-row .bar::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--axis); }
.diverge-row .bar span { position: absolute; top: 0; height: 100%; border-radius: 4px; }
.diverge-row .bar .pos { left: calc(50% + 1px); background: var(--data-in); }
.diverge-row .bar .neg { right: calc(50% + 1px); background: var(--data-out); }
.diverge-row .v { font-variant-numeric: tabular-nums; color: var(--ink-2); min-width: 96px; text-align: right; }

/* automaty */
.vend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--gap); }
.fill-bar { height: 8px; border-radius: 4px; background: var(--fill); overflow: hidden; margin: 2px 0 12px; }
.fill-bar span { display: block; height: 100%; border-radius: 4px; background: var(--data-in); }
.vend.low .fill-bar span { background: var(--warn); }
.vend.offline .fill-bar span { background: var(--bad); }
.kv-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 13.5px; border-top: 0.5px solid var(--hairline); }
.kv-row span { color: var(--ink-2); }
.kv-row b { font-weight: 550; text-align: right; font-variant-numeric: tabular-nums; }

/* sledovatelnost */
.trace-search { display: flex; gap: 10px; align-items: center; padding: 12px; }
.trace-search .search { flex: 1; }
.trace-search .input { width: 100%; font-size: 16px; }
.chain { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.chain li { display: grid; grid-template-columns: 18px 1fr; gap: 10px; padding-bottom: 14px; position: relative; }
.chain li::before { content: ""; position: absolute; left: 6px; top: 14px; bottom: 0; width: 1.5px; background: var(--hairline-strong); }
.chain li:last-child::before { display: none; }
.chain-dot { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--ink); background: var(--surface); margin-top: 3px; }
.chain .t { font-weight: 600; font-size: 14px; }
.chain .s { font-size: 13px; color: var(--ink-2); }

/* analýza: rozpad marže zvířete */
.wf { display: grid; gap: 8px; }
.wf-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr) auto; gap: 12px; align-items: center; font-size: 13.5px; }
.wf-row .track { position: relative; height: 14px; }
.wf-row .track span { position: absolute; top: 0; height: 100%; border-radius: 4px; }
.wf-row .in { background: var(--data-in); }
.wf-row .out { background: var(--data-out); }
.wf-row .total { background: var(--ink); }
.wf-row .v { font-variant-numeric: tabular-nums; min-width: 96px; text-align: right; }
@media (max-width: 860px) {
  .diverge-row { grid-template-columns: minmax(0, 1fr) 80px auto; }
  .wf-row { grid-template-columns: 1fr auto; }
  .wf-row .track { grid-column: 1 / -1; order: 3; }
  .trace-search { flex-direction: column; align-items: stretch; }
}

/* nastavení: zdroje dat */
.src-row { align-items: flex-start; }
.src-meta { text-align: right; max-width: 230px; display: grid; gap: 4px; justify-items: end; }
.src-more { margin-top: 6px; font-size: 13px; color: var(--ink-2); }
.src-more summary { cursor: pointer; color: var(--ink); font-size: 13px; }
.src-more p { margin: 6px 0 0; }
@media (max-width: 860px) { .src-row { flex-wrap: wrap; } .src-meta { text-align: left; justify-items: start; max-width: none; width: 100%; padding-left: 44px; } }
