/* ============================================================
   EIN Portal — App stylesheet
   Tmavé "bordered-grid" UI. Vše dle Figma (kánon); tokeny: tokens.css.
   Pořadí: reset → shell → typografie → komponenty → utility → auth → responsive
   ============================================================ */

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  /* Stabilni misto pro svisly scrollbar (Chrome klasicke scrollbary):
     behem vstupni animace jsou radky tabulek skryte -> stranka je docasne
     kratsi, scrollbar by mizel/objevoval se a cely obsah poskakoval
     o jeho sirku pri kazdem nacteni. Safari (overlay) se netyka. */
  scrollbar-gutter: stable;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--gray-200);
  background: var(--bg-standard);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }   /* zaškrtnutí = brand červená */
img, svg { display: block; max-width: 100%; }
table { border-collapse: collapse; }

/* ============================================================
   APP SHELL (sidebar | topbar / breadcrumb / main)
   div.app: grid [240px 1fr] × [56px 1fr]; sidebar přes oba řádky.
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  grid-area: sidebar;
  position: relative;
  overflow: visible;          /* grafika smí přetékat ven */
  background: var(--bg-dark);
  border-right: var(--stroke-1) solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
/* Brand: logo (✕CSE) | PORTAL — výška 96px = topbar (56) + breadcrumb (40),
   takže spodní linka loga lícuje s breadcrumbem. */
.sidebar__brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-8);
  height: 96px;
  padding: 0 var(--sp-24);
  border-bottom: var(--stroke-1) solid var(--border);
}
.sidebar__logo { width: 94px; height: 36px; flex: none; }
.sidebar__brand-divider { width: 1px; height: 27px; flex: none; background: var(--border-control); }
.sidebar__brand-portal {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: var(--fs-base);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--white);
}
.sidebar__nav { position: relative; z-index: 1; display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-24) var(--sp-12); }
.sidebar__group {
  padding: var(--sp-16) var(--sp-12) var(--sp-8);
  font-size: var(--fs-sm);
  color: var(--gray-500);
}
.sidebar__item {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
  padding: var(--sp-12);
  border-radius: var(--radius-6);
  font-size: var(--fs-dash);          /* text/dashboard 15px */
  line-height: var(--lh-dash);
  color: var(--white-85);
}
.sidebar__item:hover { background: rgba(255,255,255,0.04); }
.sidebar__item-dot {
  width: 8px; height: 8px; flex: none;
  border-radius: var(--radius-4);
  background: var(--gray-300);
}
.sidebar__item-label { border-bottom: var(--stroke-1) solid transparent; }
/* aktivní = červená tečka + červené podtržení (text zůstává světlý) */
.sidebar__item.is-active .sidebar__item-dot { background: var(--accent); }
.sidebar__item.is-active .sidebar__item-label { border-bottom-color: var(--accent); }
/* Dekorační grafika v patičce sidebaru (✕ motiv).
   Zobrazí se jen ≥1400px; sjede pod menu (margin-top:auto → jen pokud je dole
   místo); přetéká doleva (ořez levým okrajem sidebaru přes overflow:hidden). */
/* Dekorace: ukotvená u dna sidebaru, přetéká ven, mimo flow (nenatahuje stránku).
   Zobrazení řeší JS (app.js) — jen ≥1400px a pokud je pod menu místo. */
.sidebar__graphic {
  display: none;
  position: absolute;
  left: -57px;
  bottom: 0;
  width: 297px; max-width: none; height: auto;
  opacity: 0.6;
  pointer-events: none;
  z-index: 0;
}

/* ---------- Topbar ---------- */
.topbar {
  grid-area: topbar;
  background: var(--bg-standard);
  border-bottom: var(--stroke-1) solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--sp-16);
  padding: 0 var(--sp-32);
}
.topbar__env {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 var(--sp-12);
  border: var(--stroke-1) solid var(--accent);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--accent-bright);
  letter-spacing: 0.04em;
}
.topbar__search-form {
  flex: 1;
  max-width: 480px;
  min-width: 0;
  display: flex;
}
.topbar__search {
  flex: 1;
  width: 100%;
  min-width: 0;
  height: 28px;
  padding: 0 var(--sp-12);
  background: var(--surface);
  border: var(--stroke-1) solid var(--border);
  color: var(--gray-200);
  font-size: var(--fs-sm);
}
.topbar__search::placeholder { color: var(--gray-200); }
.topbar__search:focus { outline: none; border-color: var(--border-control); }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: var(--sp-16); }
.topbar__icon-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0;
  color: var(--accent);
  font-size: 13.3px;
}
.topbar__user {
  display: flex; align-items: center; gap: var(--sp-8);
  padding: var(--sp-4) var(--sp-12) var(--sp-4) var(--sp-4);
}
.topbar__avatar {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface);
  color: var(--gray-50);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.topbar__user-name { font-size: var(--fs-sm); color: var(--gray-200); }

/* Mobilní prvky topbaru – skryté na desktopu, zobrazí je @media ≤1023px */
.topbar__burger, .topbar__logo-link, .topbar__search-btn { display: none; }
.topbar__burger {
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  background: transparent; border: 0;
  color: var(--gray-200); font-size: 16px; cursor: pointer;
}
.topbar__logo-link { align-items: center; }
.topbar__logo-m { height: 30px; width: auto; }

/* ---------- Main + breadcrumb + page ---------- */
.main { grid-area: main; overflow: auto; display: flex; flex-direction: column; }
.breadcrumb {
  display: flex; align-items: center; gap: var(--sp-8);
  height: var(--breadcrumb-h);
  padding: 0 var(--sp-32);
  background: var(--bg-standard);
  border-bottom: var(--stroke-1) solid var(--border);
  font-size: var(--fs-sm);
  color: var(--gray-500);
}
.breadcrumb a:hover { color: var(--gray-300); }
.breadcrumb__sep { color: var(--accent-strong); }   /* Figma: separátor rag/red-fg #b91c1c */
.breadcrumb__current { color: var(--gray-300); }

.page {
  display: flex;
  flex-direction: column;
  gap: var(--sp-24);
  padding: var(--sp-32);
  max-width: var(--content-max);
  width: 100%;
}
.page--flush { padding: 0; gap: 0; }   /* dashboard: sekce lepené na sebe linkami */

.page__header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: var(--sp-16);
}
.page__title { font-size: var(--fs-xl); font-weight: 700; color: var(--accent); }
.page__subtitle { font-size: var(--fs-sm); color: var(--gray-500); margin-top: var(--sp-2); }
.page__actions { display: flex; align-items: center; gap: var(--sp-8); }

/* ============================================================
   TYPOGRAFIE — pomocné třídy (text styly z Figmy)
   ============================================================ */
.t-2xl   { font-size: var(--fs-2xl); line-height: var(--lh-2xl); font-weight: 700; }
.t-xl    { font-size: var(--fs-xl);  line-height: var(--lh-xl);  font-weight: 700; }
.t-lg    { font-size: var(--fs-lg);  line-height: var(--lh-lg);  font-weight: 700; }
.t-base  { font-size: var(--fs-base);line-height: var(--lh-base); }
.t-sm    { font-size: var(--fs-sm);  line-height: var(--lh-sm); }
.t-xs    { font-size: var(--fs-xs);  line-height: var(--lh-xs); }
.t-upp {
  font-size: var(--fs-xxs); line-height: var(--lh-xxs);
  font-weight: 700; text-transform: uppercase; letter-spacing: var(--ls-upp);
  color: var(--gray-400);
}
.t-mono  { font-family: var(--font-mono); }
.t-display { font-family: var(--font-display); }
.t-muted { color: var(--gray-500); }
.t-accent { color: var(--accent); }

/* ============================================================
   TLAČÍTKA  (padding 8/15, radius 6, font sm)
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-8);
  padding: 7px 15px;                 /* 7+7 + lh 20 + 2px ramecek = --control-h */
  border: var(--stroke-1) solid transparent;
  border-radius: 0;                  /* Figma: hlavní tlačítka ostré rohy */
  font-size: var(--fs-base);         /* 14/20, Aeonik Regular */
  font-weight: 400;
  line-height: var(--lh-base);
  background: var(--surface);
  border-color: var(--border-control);
  color: var(--gray-300);
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.12); }
.btn:active:not([disabled]) { transform: scale(0.98); }   /* "cvaknuti" pod prstem */
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--white); }
.btn--ghost   { background: transparent; border-color: transparent; color: var(--gray-400); padding: 7px 11px; border-radius: var(--radius-6); }
.btn--ghost:hover { background: rgba(255,255,255,0.06); filter: none; }
.btn--sm { padding: 7px 11px; font-size: var(--fs-xs); border-radius: var(--radius-6); }
.btn--icon { padding: 6px; width: var(--control-h); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
/* focus ring v barve systemu (accent) misto vychoziho modreho UA outline – jen pro klavesnici */
.btn:focus-visible,
.modal__close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn:focus:not(:focus-visible),
.modal__close:focus:not(:focus-visible) { outline: none; }

/* ============================================================
   BADGE / DOT / CHIP
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: var(--sp-4);
  padding: 3px var(--sp-8);
  border-radius: var(--radius-2);
  background: var(--surface);
  color: var(--gray-200);
  font-size: var(--fs-xxs);          /* Figma badge text 11px */
  font-weight: 700;
  line-height: 15px;
  letter-spacing: var(--ls-upp);
  white-space: nowrap;
}
/* obrysové varianty (gray/700 + barevný 0.5px rámeček) */
.badge--outline-red    { border: 0.5px solid var(--accent); }
.badge--outline-yellow { border: 0.5px solid var(--heat-2); }
/* plné varianty (tlumená červená škála) */
.badge--red-1 { background: var(--red-1); color: var(--gray-200); }
.badge--red-2 { background: var(--red-2); color: var(--gray-100); }
.badge--red-3 { background: var(--red-3); color: var(--white); }
.badge--red-4 { background: var(--red-4); color: var(--white); }

.dot { width: 8px; height: 8px; border-radius: var(--radius-4); display: inline-block; flex: none; }
.dot--green  { background: var(--dot-green); }
.dot--orange { background: var(--dot-orange); }
.dot--red    { background: var(--dot-red); }
.dot--grey   { background: var(--dot-grey); }
.dot--heat-1 { background: var(--heat-1); }
.dot--heat-3 { background: var(--heat-3); }
.dot--heat-5 { background: var(--heat-5-solid); }

.chip {
  display: inline-flex; align-items: center; gap: var(--sp-8);
  height: 34px; padding: 0 var(--sp-12);
  background: var(--surface);
  border: var(--stroke-1) solid var(--border-chip);
  color: var(--gray-200);
  font-size: var(--fs-sm);
}
.chip__close { color: var(--gray-400); cursor: pointer; }
.chip__close:hover { color: var(--gray-100); }

/* Pill (topbar role „PM") – gray/700, ostré rohy, 13px Bold uppercase */
.pill {
  display: inline-flex; align-items: center;
  padding: 2px var(--sp-10);
  background: var(--surface);
  color: var(--gray-50);
  font-size: var(--fs-sm); line-height: var(--lh-sm);
  font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase;
}

/* ============================================================
   KARTA + KPI  (bordered-grid: oddělení linkami, ne stínem)
   ============================================================ */
.card {
  background: var(--bg-standard);
  border-bottom: var(--stroke-1) solid var(--border);
  display: flex; flex-direction: column;
  gap: var(--sp-35);
  padding: 24px var(--sp-32) 25px;
}
.card--boxed { border: var(--stroke-1) solid var(--border); }
.card__header { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-16); }
.card__title {
  display: inline-flex; align-items: center;
  border-bottom: var(--stroke-1) solid var(--accent-strong);  /* červené podtržení titulku (rag/red-fg) */
  font-size: 17px;          /* Figma: Aeonik Regular 17/24, bílá */
  line-height: 24px;
  font-weight: 400;
  color: var(--white);
}
.card__body { display: flex; flex-direction: column; }

/* KPI dlaždice – strip. Vnitřní svislé linky = column-gap přes pozadí
   kontejneru (gap je jen mezi buňkami → na okraji žadná linka, nesčítá se s rámem). */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); column-gap: var(--stroke-1); background: var(--border); }
.kpi {
  background: var(--bg-standard);
  border-bottom: var(--stroke-1) solid var(--border);
  display: flex; flex-direction: column; gap: var(--sp-8);
  padding: 20px var(--sp-32) 21px;
}
.kpi__label {
  font-size: var(--fs-xxs); line-height: var(--lh-xxs);
  font-weight: 700; text-transform: uppercase; letter-spacing: var(--ls-upp);
  color: var(--gray-400);
}
.kpi__value {
  font-size: var(--fs-2xl); line-height: var(--lh-2xl);
  font-weight: 700; color: var(--gray-300);
}
.kpi__delta { font-size: var(--fs-sm); line-height: var(--lh-sm); color: var(--gray-500); }  /* Figma: 13px gray/500, bez šipky */
.kpi__delta--up   { color: var(--heat-1); }   /* #86efac (zelená) */
.kpi__delta--warn { color: var(--heat-3); }   /* #fb923c (oranžová – Open Risks, Tasks Due) */
.kpi__delta--down { color: var(--accent-bright); }

/* Dashboard widget grid (12 sloupců). Svislé linky = column-gap přes pozadí
   kontejneru (žádné okrajové bordery → nesčítají se s rámem .app). */
.widgets { display: grid; grid-template-columns: repeat(12, 1fr); column-gap: var(--stroke-1); background: var(--border); }
.widget--3  { grid-column: span 3; }
.widget--4  { grid-column: span 4; }
.widget--5  { grid-column: span 5; }
.widget--6  { grid-column: span 6; }
.widget--7  { grid-column: span 7; }
.widget--8  { grid-column: span 8; }
.widget--12 { grid-column: span 12; }
/* Widgety v řádku se roztáhnou na stejnou výšku; karta uvnitř výšku vyplní,
   aby vodorovná linka (border-bottom) lícovala napříč řádkem. */
.widget { display: flex; flex-direction: column; background: var(--bg-standard); }
.widget > .card { flex: 1 1 auto; }
.widgets > .widget:last-child > .card { border-bottom: 0; } /* spodní hranu kreslí rám / konec obsahu */

/* ============================================================
   GREETING STRIP (dashboard hero)
   ============================================================ */
.greeting {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-16);
  padding: var(--sp-35) var(--sp-32);
  background: var(--bg-dark);
  border-bottom: var(--stroke-1) solid var(--border);
}
.greeting__title {
  font-family: var(--font-display);   /* Inter */
  font-weight: 700;
  font-size: var(--fs-xl);
  color: var(--white);
}
.greeting__meta { display: flex; align-items: center; gap: var(--sp-8); margin-top: var(--sp-2); opacity: var(--opacity-80); font-size: var(--fs-sm); color: var(--gray-200); }
.greeting__role { font-family: var(--font-display); font-weight: 700; color: var(--accent); }

/* ============================================================
   VSTUPNI ANIMACE STRANKY — 3 faze (stage 1/2/3)
   Stage 1 (delay 0):        nadpisy a popisky
   Stage 2 (--stage-2):      data poli a ovladaci prvky
   Stage 3 (--stage-3):      tabulky + grafy (base delay + --d stagger, nize)
   Chrome se neanimuje: .topbar, .breadcrumb, .sidebar, .tabs
   ============================================================ */
/* From-only keyframe + fill backwards: po dobehnuti nezustava zadny
   transform (zadny containing block na .card__body — sticky/dropdowny uvnitr OK). */
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } }

/* Stage 1 — nadpisy a popisky (delay 0; pri first-entrance posunuto tokenem) */
.greeting__title, .greeting__meta,
.page__title, .page__subtitle,
.project-header__title,
.card__title,
.kpi__label {
  animation: fade-up 0.4s var(--ease-enter) backwards;
  animation-delay: var(--stage-1, 0ms);
}

/* Stage 2 — data a ovladaci prvky */
.page__actions,
.project-header__meta,
.table-toolbar,
.table thead,
.kpi__value, .kpi__delta,
.card__body,
.form-grid,
.pagination {
  animation: fade-up 0.45s var(--ease-enter) backwards;
  animation-delay: var(--stage-2);
}

/* Modaly: dialog je display:none az do open — vstupni animace by se
   prehravala pri kazdem otevreni. Guard (dnes jen defenzivni). */
.modal :is(.card__title, .card__body, .table-toolbar, .table thead, .kpi__label,
  .kpi__value, .kpi__delta, .page__title, .page__subtitle, .page__actions, .pagination,
  .form-grid) {
  animation: none;
}

/* Opakovane nacteni STEJNE stranky (reload, filtr, PRG po ulozeni):
   app.js prida `no-entrance` na <html> (sessionStorage porovna pathname)
   -> stage 1/2 + grafy se preskoci, radky tabulek se animuji vzdy
   (feedback na zmenu dat), jen bez stage-3 base delaye. */
.no-entrance :is(.greeting__title, .greeting__meta,
  .page__title, .page__subtitle, .project-header__title, .card__title, .kpi__label,
  .page__actions, .project-header__meta, .table-toolbar, .table thead,
  .kpi__value, .kpi__delta, .card__body, .form-grid, .pagination) {
  animation: none;
}
.no-entrance :is(.bars__bar, .progressbar__fill,
  .gantt__bar, .gantt__milestone, .gantt__bar-label, .gantt__today,
  .phase-step, .risk-matrix__cell) { animation: none; }
/* --sweep je registrovana (@property, initial 0deg) -> fallback ve var() se nikdy
   nepouzije; bez animace nutno nastavit 360deg explicitne, jinak prstenec zmizi */
.no-entrance .donut::before { animation: none; --sweep: 360deg; }
.no-entrance .table tbody tr { animation-delay: calc(var(--d, 0) * 35ms); }

/* Obecny fade (jen opacity) – gantt label, today linka ap. */
@keyframes fade-in { from { opacity: 0; } }

/* ============================================================
   PRVNI NACTENI („blueprint" vstup) — jednou za zalozku.
   app.js prida `first-entrance` na <html> (sessionStorage
   'ein-chrome-played'; jen na strankach se sidebar chrome).
   Sekvence: konstrukcni cary (0–380 ms) → plochy chrome +
   obsahova cast (250–720 ms) → obsah chrome (menu se
   staggerem, 450 ms+) → stage 1/2/3 (posunute tokeny nize).
   ============================================================ */
.first-entrance {
  --stage-1: 1000ms;
  --stage-2: 1120ms;
  --stage-3: 1240ms;
}

/* Vnejsi ram .app (wide ≥1550px): kresli se linearne — vodorovne hrany
   (horni+dolni na ::before) rostou zleva, svisle (leva+prava na ::after)
   shora. Zadna conic maska (v Chrome pulila horni linku artefaktem).
   Realny border je behem kresleni skryty (surface-in) a doleje se
   pod overlayem. */
@media (min-width: 1550px) {
  .first-entrance .app {
    position: relative;
    animation: surface-in 0.3s ease 400ms backwards;
  }
  .first-entrance .app::before,
  .first-entrance .app::after {
    content: ""; position: absolute; inset: -1px; z-index: 5; pointer-events: none;
  }
  .first-entrance .app::before {
    border-top: var(--stroke-1) solid var(--border);
    border-bottom: var(--stroke-1) solid var(--border);
    transform-origin: left;
    animation: line-draw-x 0.42s var(--ease-enter) backwards;
  }
  .first-entrance .app::after {
    border-left: var(--stroke-1) solid var(--border);
    border-right: var(--stroke-1) solid var(--border);
    transform-origin: top;
    animation: line-draw-y 0.42s var(--ease-enter) 120ms backwards;
  }
}

/* Cary: hrana sidebaru roste shora, spodni linka topbaru zleva.
   Realne bordery ploch jsou behem kresleni skryte (from-frame
   surface-in) a doliji se s pozadim — overlay je prekryva 1:1
   (sidebar right:-1px = presne NA borderu, jinak dvojita cara). */
@keyframes line-draw-y { from { transform: scaleY(0); } }
@keyframes line-draw-x { from { transform: scaleX(0); } }
.first-entrance .sidebar::after {
  content: ""; position: absolute; top: 0; right: -1px; width: 1px; height: 100%;
  background: var(--border); z-index: 5;
  transform-origin: top;
  animation: line-draw-y 0.45s var(--ease-enter) 80ms backwards;
}
.first-entrance .topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: var(--border); z-index: 5;
  transform-origin: left;
  animation: line-draw-x 0.45s var(--ease-enter) 200ms backwards;
}

/* Plochy: pozadi + realne bordery chrome se doliji po carach;
   obsahova cast (breadcrumb + panely stranky) nabehne jako celek. */
@keyframes surface-in { from { background-color: transparent; border-color: transparent; } }
.first-entrance .sidebar { animation: surface-in 0.35s ease 500ms backwards; }
.first-entrance .topbar  { position: relative; animation: surface-in 0.35s ease 500ms backwards; }
.first-entrance .main    { animation: fade-in 0.4s ease 560ms backwards; }

/* Obsah chrome: brand + grafika, polozky menu se staggerem, topbar */
.first-entrance :is(.sidebar__brand, .sidebar__graphic) { animation: fade-in 0.35s ease 640ms backwards; }
.first-entrance .sidebar__nav > * {
  animation: fade-up 0.3s var(--ease-enter) backwards;
  animation-delay: calc(680ms + var(--ci, 0) * 35ms);
}
.first-entrance .sidebar__nav > :nth-child(1)  { --ci: 0; }
.first-entrance .sidebar__nav > :nth-child(2)  { --ci: 1; }
.first-entrance .sidebar__nav > :nth-child(3)  { --ci: 2; }
.first-entrance .sidebar__nav > :nth-child(4)  { --ci: 3; }
.first-entrance .sidebar__nav > :nth-child(5)  { --ci: 4; }
.first-entrance .sidebar__nav > :nth-child(6)  { --ci: 5; }
.first-entrance .sidebar__nav > :nth-child(7)  { --ci: 6; }
.first-entrance .sidebar__nav > :nth-child(8)  { --ci: 7; }
.first-entrance .sidebar__nav > :nth-child(9)  { --ci: 8; }
.first-entrance .sidebar__nav > :nth-child(10) { --ci: 9; }
.first-entrance .sidebar__nav > :nth-child(11) { --ci: 10; }
.first-entrance .sidebar__nav > :nth-child(12) { --ci: 11; }
.first-entrance .sidebar__nav > :nth-child(13) { --ci: 12; }
.first-entrance .sidebar__nav > :nth-child(n+14) { --ci: 13; }
.first-entrance .topbar > * { animation: fade-in 0.3s ease 720ms backwards; }

/* Scroll-reveal (IntersectionObserver v app.js): prvky pod ohybem stranky
   maji vstupni animaci pozastavenou; trida se odebere az pri doscrollovani.
   !important prebiji animation shorthand komponent (implicitni play-state). */
.reveal-paused, .reveal-paused::before { animation-play-state: paused !important; }
/* Po odhaleni: zkracene delaye — stage cekani odpada (uzivatel uz scrolluje),
   zustava jen kompresovany --d stagger, at nastup pusobi okamzite. */
.reveal-go, .reveal-go::before { animation-delay: calc(var(--d, 0) * 18ms) !important; }

/* Flash banner: vjede shora (i pri PRG reloadu – je to feedback na akci);
   .flash--hide = auto-dismiss uspesnych zprav (ridi app.js po 5 s). */
.flash { animation: fade-down 0.35s var(--ease-enter) backwards; }
.flash--hide {
  height: 0 !important; margin: 0; padding-top: 0; padding-bottom: 0;
  border-top-width: 0; border-bottom-width: 0;
  opacity: 0; overflow: hidden;
  transition: height 0.3s ease, margin 0.3s ease, padding 0.3s ease,
              border-width 0.3s ease, opacity 0.25s ease;
}

/* Pozn.: spolecny prefers-reduced-motion blok je na KONCI souboru – musi byt
   za pravidly komponent, jinak pri shodne specificite prohraje kaskadu. */

/* ============================================================
   MEKKE HOVER PRECHODY — sjednocene 0.15s ease
   (hover stavy meni barvu/pozadi; u .btn jas pres filter)
   ============================================================ */
.sidebar__item,
.breadcrumb a,
.chip__close,
.tab,
.table tbody tr,
.modal__close,
.topbar__user-name,
.table thead th.th-sortable,
.search-item {
  transition: background-color 0.15s ease, color 0.15s ease;
}
.btn { transition: background-color 0.15s ease, filter 0.15s ease, transform 0.08s ease; }

/* ============================================================
   GRAFY — donut, bars, phase
   ============================================================ */
/* Vstupni animace grafu (stage 3). --d = index pro stagger, --sweep = uhel reveal donutu. */
@property --sweep { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes bar-grow-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes bar-grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes donut-sweep { from { --sweep: 0deg; } to { --sweep: 360deg; } }

.donut {
  position: relative;
  width: 120px; height: 120px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
}
/* segmenty RAG na ::before (kvuli sweep animaci); přepiš dle reálných dat ve --donut-* proměnných */
.donut::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: conic-gradient(
    var(--heat-1)      0 58.33%,    /* 7/12 green */
    var(--heat-3) 58.33% 83.33%,    /* 3/12 amber */
    var(--heat-5-solid) 83.33% 100%); /* 2/12 red */
  /* hodinovy reveal: viditelny vysek roste 0->360° (fallback 360° = cely donut bez animace) */
  -webkit-mask: conic-gradient(#000 var(--sweep, 360deg), transparent 0);
          mask: conic-gradient(#000 var(--sweep, 360deg), transparent 0);
  animation: donut-sweep 0.9s ease-out both;
  animation-delay: var(--stage-3);
}
.donut::after {
  content: ""; position: absolute; inset: 18px;
  background: var(--surface); border-radius: var(--radius-full);
}
.donut__label { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); }
.donut__value { font-weight: 700; font-size: var(--fs-2xl); line-height: var(--lh-2xl); color: var(--gray-300); }  /* Aeonik Bold 28/36 */
.donut__sub   { font-size: var(--fs-xs); color: var(--gray-300); }

.bars { display: flex; align-items: flex-end; gap: var(--sp-8); height: 160px; }
/* radek popisku pod bary – zrcadli layout .bars (flex:1 + stejny gap), takze kazdy popisek lezi presne pod svym sloupcem */
.bars-labels { display: flex; gap: var(--sp-8); }
.bars-labels > span { flex: 1 1 0; min-width: 0; text-align: center; }
.bars__bar {
  flex: 1 1 0; min-width: 0;
  border-radius: var(--radius-4) var(--radius-4) 0 0;
  background: var(--red-1);
  /* najede zdola, se staggerem mezi sloupci (--d = index sloupce) */
  transform-origin: bottom;
  animation: bar-grow-y 0.55s var(--ease-enter) both;
  animation-delay: calc(var(--stage-3) + var(--d, 0) * 80ms);
}
/* horizontální progress (phase pipeline / % complete) */
.progressbar { position: relative; height: 24px; background: var(--surface); border-radius: var(--radius-4); overflow: hidden; }
.progressbar--thin { height: 6px; }
.progressbar__fill {
  position: absolute; inset: 0 auto 0 0; background: var(--red-4);
  /* najede zleva, se staggerem mezi radky (--d = index radku) */
  transform-origin: left;
  animation: bar-grow-x 0.55s var(--ease-enter) both;
  animation-delay: calc(var(--stage-3) + var(--d, 0) * 80ms);
}
.progressbar__fill--1 { background: var(--red-3); }   /* New */
.progressbar__fill--2 { background: var(--red-4); }   /* In Progress */
.progressbar__fill--3 { background: var(--red-2); }   /* Resolved */
.progressbar__fill--4 { background: var(--red-1); }   /* Cancelled */

/* Hodnotova sytost (linearni): --i (0..100) = hodnota/max; cim vetsi hodnota, tim sytejsi cervena
   (plynule red-1 seda -> red-4 syte cervena). Pouziti: bary i progress fill, kde barva = velikost. */
.bars__bar--scale,
.progressbar__fill--scale {
  background: color-mix(in srgb, var(--red-4) calc(var(--i, 0) * 1%), var(--red-1));
}

/* vodorovné bary se štítkem a počtem (Open Issues by Status) */
.hbars { display: flex; flex-direction: column; gap: var(--sp-12); }
.hbar { display: grid; grid-template-columns: 80px 1fr 28px; align-items: center; gap: var(--sp-12); }
.hbar__label { font-size: var(--fs-sm); font-weight: 700; color: var(--gray-400); }
.hbar__count { text-align: right; font-size: var(--fs-sm); font-weight: 700; color: var(--gray-400); }

/* phase strip – segmenty fází */
.phase-strip { display: flex; gap: var(--sp-2); }
/* Vstupni animace (stage 3): kroky faze se rozsveci zleva doprava (--d pres nth-child) */
.phase-step:nth-child(1) { --d: 0; } .phase-step:nth-child(2) { --d: 1; }
.phase-step:nth-child(3) { --d: 2; } .phase-step:nth-child(4) { --d: 3; }
.phase-step:nth-child(5) { --d: 4; } .phase-step:nth-child(6) { --d: 5; }
.phase-step:nth-child(n+7) { --d: 6; }
.phase-step {
  animation: fade-in 0.35s var(--ease-enter) backwards;
  animation-delay: calc(var(--stage-3) + var(--d, 0) * 70ms);
  flex: 1 1 0; min-width: 0;
  height: 32px;
  display: flex; align-items: center; justify-content: center; gap: var(--sp-6);
  padding: 5px 0 6px;
  background: var(--surface);
  font-size: 10px;                 /* text/xxs_upp */
  line-height: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-upp);
  color: var(--gray-400);
}
.phase-step.is-done    { background: var(--red-2); color: var(--gray-100); }
.phase-step.is-current { background: var(--accent); color: var(--white); }

/* ============================================================
   TABY
   ============================================================ */
.tabs { display: flex; gap: var(--sp-4); padding: 0 33px 0 var(--sp-32); border-bottom: var(--stroke-1) solid var(--border); }
.tab {
  display: inline-flex; align-items: center; gap: var(--sp-8);
  padding: 12px var(--sp-16) 15px;
  border-bottom: var(--stroke-2) solid transparent;
  font-size: var(--fs-sm);
  font-weight: 400;
  color: var(--gray-300);
  background: none; border-left: 0; border-right: 0; border-top: 0;
}
.tab:hover { color: var(--gray-200); }
.tab.is-active { color: var(--white); border-bottom-color: var(--accent); }
.tab__counter {
  padding: 3px 7px;
  background: var(--surface);
  border-radius: var(--radius-2);
  font-size: var(--fs-xxs);
  line-height: 15px;
  font-weight: 700;
  letter-spacing: var(--ls-upp);
  text-transform: uppercase;
  color: var(--gray-200);
}

/* ============================================================
   TABULKA + toolbar + stránkování
   ============================================================ */
.table-wrap { background: var(--bg-standard); }
/* Horizontální scroll jen pro tabulku (toolbar/stránkování zůstávají); brání přetékání
   pod pravý rail (heatmapa) na úzkém hlavním sloupci. min-width:0 viz .rail-main. */
.table-scroll { overflow-x: auto; }
.table { width: 100%; font-size: var(--fs-sm); }
.table thead th {
  background: var(--surface);
  text-align: left;
  padding: 13px var(--sp-16);
  font-size: var(--fs-xxs);
  line-height: var(--lh-xxs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-upp);
  color: var(--gray-400);
  white-space: nowrap;
}
.table tbody td {
  padding: 18px var(--sp-16);             /* ≈54px řádek (single-line) */
  border-bottom: var(--stroke-1) solid var(--border);
  color: var(--gray-200);
  vertical-align: middle;
}
.table--lg tbody td { padding: 24px var(--sp-16); }   /* ≈66px řádek (dashboard Open Risks) */
.table tbody tr:hover { background: rgba(255,255,255,0.03); }
/* vstupni animace radku (stage 3) – stagger pres --d nastavuje app.js (bez JS: vsechny najednou, --d=0);
   reduced-motion resi spolecny blok v sekci VSTUPNI ANIMACE STRANKY */
@keyframes row-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.table tbody tr {
  animation: row-in 0.4s ease-out both;
  animation-delay: calc(var(--stage-3) + var(--d, 0) * 35ms);
}
.table__primary { color: var(--gray-200); font-weight: 400; }   /* Figma: #e5e7eb, Aeonik Regular */
.table__muted   { color: var(--gray-300); font-size: var(--fs-sm); }   /* #c0c6ce, 13px */
.table__num     { font-family: var(--font-mono); }

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-12);
  flex-wrap: wrap;
  padding: var(--sp-12) 0;
  border-bottom: var(--stroke-1) solid var(--border);
}
.table-toolbar__filters { display: flex; align-items: center; gap: var(--sp-8); flex-wrap: wrap; }
.table-toolbar__actions { display: flex; align-items: center; gap: var(--sp-8); }

.pagination {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-12);
  padding: var(--sp-12) var(--sp-16);
  border-top: var(--stroke-1) solid var(--border);
  font-size: var(--fs-xs);
  color: var(--gray-400);
}
.pagination__pages { display: flex; gap: var(--sp-4); }
.pagination__page {
  min-width: 28px; height: 28px; padding: 0 var(--sp-12);
  display: inline-flex; align-items: center; justify-content: center;
  border: var(--stroke-1) solid var(--border-control);
  border-radius: var(--radius-4);
  background: transparent;
  color: var(--gray-300);
  font-size: var(--fs-xs);
}
.pagination__page.is-active { background: var(--red-2); border-color: var(--red-2); color: var(--white); }

/* ============================================================
   FORMULÁŘE
   ============================================================ */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); column-gap: var(--sp-24); row-gap: var(--sp-16); }
.form-grid--single { grid-template-columns: 1fr; }
.form-field { display: flex; flex-direction: column; gap: var(--sp-6); }
.form-field--full { grid-column: 1 / -1; }
.form-field__label {
  display: flex; align-items: center; gap: var(--sp-6);
  font-size: var(--fs-sm); line-height: var(--lh-sm);
  color: var(--gray-500);
}
.form-field__required { color: var(--accent-bright); }
.form-field__hint  { font-size: var(--fs-xxs); color: var(--gray-400); }
.form-field__error { font-size: var(--fs-xs); color: var(--accent-bright); }
.form-field__readonly { padding: var(--sp-8) 0; font-size: var(--fs-base); line-height: var(--lh-base); color: var(--gray-300); }
/* (Pozn.: „🔒 derived" indikátor odstraněn – ve Figmě není.) */

.input, .select, .textarea {
  width: 100%;
  padding: 8px 13px;                /* 8+8 + lh 18 + 2px ramecek = --control-h */
  background: var(--surface);
  border: var(--stroke-1) solid var(--border-control);
  border-radius: 0;                 /* Figma: ostré rohy */
  font-family: inherit;
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);        /* jinak by input pocital vysku z line-height:normal */
  color: var(--gray-200);
}
.input::placeholder, .textarea::placeholder { color: var(--gray-500); }
/* Mekky focus: prolinani ramecku + jemny glow v barve akcentu */
.input, .select, .textarea, .select-ui__trigger, .topbar__search {
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(214, 2, 2, 0.15);
}
.input[readonly], .input--readonly { background: var(--bg-dark); color: var(--gray-300); }
.textarea { min-height: 75px; resize: vertical; }
.select {
  appearance: none;
  padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--gray-400) 50%),
                    linear-gradient(135deg, var(--gray-400) 50%, transparent 50%);
  background-position: calc(100% - 16px) 15px, calc(100% - 11px) 15px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.select option { background-color: var(--surface); color: var(--gray-200); }

/* ---------- Custom dropdown (JS – app.js) – nahrazuje nativní rozbalení selectu ---------- */
.select-ui { position: relative; width: 100%; }
.select-ui__native { display: none; }                 /* nativní select skrytý, drží hodnotu */
.select-ui__trigger {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-8);
  padding: 8px 13px;                                   /* = --control-h, shodne s .input */
  background: var(--surface);
  border: var(--stroke-1) solid var(--border-control);
  border-radius: 0;
  color: var(--gray-200);
  font-family: inherit; font-size: var(--fs-sm); line-height: var(--lh-sm);
  text-align: left; cursor: pointer;
}
.select-ui.is-open .select-ui__trigger { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(214, 2, 2, 0.15); }
.select-ui__trigger::after {
  content: "\f078";                                    /* fa-chevron-down */
  font-family: var(--font-icon); font-weight: 900;
  font-size: 10px; color: var(--gray-400); flex: none;
}
.select-ui__value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-ui__panel {
  position: absolute; top: calc(100% + 2px); left: 0; right: 0; z-index: 60;
  background: var(--surface);
  border: var(--stroke-1) solid var(--border-control);
  max-height: 264px; overflow-y: auto;
  box-shadow: 0 10px 28px rgba(0,0,0,0.45);
  /* Rozbaleni/sbaleni zeshora. JS prepina jen [hidden]; misto display
     ridi viditelnost visibility (transition na display se u ne-top-layer
     prvku zasekava), skryty panel neni klikatelny ani v a11y strome. */
  display: block;                 /* prebiji UA [hidden] { display:none } */
  transform-origin: top;
  opacity: 1;
  transform: translateY(0) scaleY(1);
  visibility: visible;
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.select-ui__panel[hidden] {
  opacity: 0;
  transform: translateY(-4px) scaleY(0.96);
  visibility: hidden;
  /* visibility flipne az po dobehnuti fade (delay = duration) */
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0s linear 0.16s;
}
/* Options nabihaji postupne shora (stagger --d nastavuje app.js pri build();
   prvky se pri kazdem otevreni vytvareji znovu, animace se tak prirozene opakuje) */
@keyframes fade-down { from { opacity: 0; transform: translateY(-4px); } }
.select-ui__option {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-8);
  padding: 9px 13px;
  font-size: var(--fs-sm); line-height: var(--lh-sm);
  color: var(--gray-200); cursor: pointer;
  animation: fade-down 0.22s var(--ease-enter) backwards;
  animation-delay: calc(var(--d, 0) * 25ms);
  transition: background-color 0.15s ease;   /* mekci hover/focus */
}
.select-ui__option:hover,
.select-ui__option:focus,
.select-ui__option.is-active { background: rgba(255,255,255,0.07); outline: none; }
.select-ui__option.is-selected { color: var(--accent-light); }
.select-ui__option.is-selected::after {
  content: "\f00c";                                    /* fa-check */
  font-family: var(--font-icon); font-weight: 900; font-size: 11px; flex: none;
}

/* Figma: sekce jako bordered-grid pruhy (border-b + border-r), lepené na sebe */
.form-section { background: var(--bg-standard); border-bottom: var(--stroke-1) solid var(--border); }
.form-section__header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-16);
  padding: 24px var(--sp-32);
  border-bottom: var(--stroke-1) solid var(--border);
}
.form-section__header--sticky { box-shadow: var(--shadow-panel); }
.form-section__title { font-size: var(--fs-md); font-weight: 700; color: var(--gray-200); }
.form-section__desc  { font-family: var(--font-display); font-size: var(--fs-xs); color: var(--grey-46); margin-top: var(--sp-2); }
.form-section__body  { padding: var(--sp-24) var(--sp-32); }
/* derived indikátor (🔒 derived) + derived hodnota (18px bold) */
.derived-tag { margin-left: var(--sp-4); font-family: var(--font-display); font-size: 10px; font-weight: 400; color: var(--grey-46); }
.derived-value { font-size: var(--fs-lg); font-weight: 700; }

/* ============================================================
   RISK MATICE (5 řádků pravděpodobnost × 3 sloupce dopad)
   ============================================================ */
.risk-matrix {
  display: grid;
  grid-template-columns: 74px repeat(3, minmax(0, 1fr));
  grid-template-rows: 36px repeat(5, 40px);
  gap: var(--sp-2);
}
.risk-matrix__corner { grid-column: 1; grid-row: 1; }
.risk-matrix__col-label,
.risk-matrix__row-label {
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-8);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-upp);
  color: var(--gray-300);
  text-align: center;
}
/* Vstupni animace matice (stage 3): bunky se rozsveci postupne (--d z partialu,
   po radcich), aktivni bunka po usazeni jemne pulzne. Pulz se restartuje i pri
   zivem prepoctu (presun .is-current) – vystreli 950 ms po posledni zmene. */
@keyframes cell-in { from { opacity: 0; transform: scale(0.9); } }
@keyframes cell-pulse { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.06); } }
.risk-matrix__cell {
  display: flex; align-items: center; justify-content: center;
  gap: 1px;
  min-height: 40px;
  padding: var(--sp-8);
  color: var(--gray-900);
  cursor: pointer;
  animation: cell-in 0.3s var(--ease-enter) backwards;
  animation-delay: calc(var(--stage-3) + var(--d, 0) * 30ms);
}
.risk-matrix__num { font-family: var(--font-display); font-weight: 700; font-size: 11px; line-height: 1; }
.risk-matrix__cell--h1 { background: var(--heat-1); }
.risk-matrix__cell--h2 { background: var(--heat-2); }
.risk-matrix__cell--h3 { background: var(--heat-3); }
.risk-matrix__cell--h4 { background: var(--heat-4); color: var(--white); }
.risk-matrix__cell--h5 { background: var(--heat-5); color: var(--white); }
.risk-matrix__cell.is-current {
  border: var(--stroke-2) solid var(--gray-100);
  box-shadow: var(--shadow-cell);
  animation: cell-in 0.3s var(--ease-enter) backwards, cell-pulse 0.45s ease;
  animation-delay: calc(var(--stage-3) + var(--d, 0) * 30ms), 950ms;
}
/* no-entrance (reload stejne stranky): bunky bez vstupu, pulz aktivni bunky zustava */
.no-entrance .risk-matrix__cell.is-current { animation: cell-pulse 0.45s ease 950ms; }
/* first-entrance: pulz az po posunute vstupni sekvenci */
.first-entrance .risk-matrix__cell.is-current { animation-delay: calc(var(--stage-3) + var(--d, 0) * 30ms), 2100ms; }
.risk-matrix__score { font-size: 9px; font-weight: 700; opacity: var(--opacity-70); }

/* Risk score badge */
.risk-score-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: var(--radius-2);
  font-weight: 700; font-size: var(--fs-xxs);   /* 11px */
  color: var(--gray-900);
}
.risk-score-badge--big { width: 36px; height: 36px; font-size: var(--fs-base); }   /* 14px */
.risk-score-badge--h1 { background: var(--heat-1); color: var(--gray-900); }
.risk-score-badge--h2 { background: var(--heat-2); color: var(--gray-900); }
.risk-score-badge--h3 { background: var(--heat-3); color: var(--gray-900); }
.risk-score-badge--h4 { background: var(--heat-4); color: var(--white); }
.risk-score-badge--h5 { background: var(--heat-5); color: var(--white); }

/* ============================================================
   PROJECT HEADER (project details)
   ============================================================ */
.project-header {
  display: flex; flex-direction: column;
  background: var(--bg-dark);
  padding: var(--sp-32);
  border-bottom: var(--stroke-1) solid var(--border);
}
.project-header__top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-16); }
.project-header__title {
  display: flex; align-items: center; gap: var(--sp-12);
  font-size: var(--fs-xl); line-height: 24px; font-weight: 700; color: var(--accent);
}
.project-header__meta {
  display: flex; flex-wrap: wrap; gap: var(--sp-24);
  margin-top: var(--sp-16); padding-top: var(--sp-16);
  border-top: var(--stroke-1) solid var(--border);
}
.project-header__meta-item { display: flex; flex-direction: column; gap: var(--sp-2); }
.project-header__meta-label {
  font-size: var(--fs-xxs); font-weight: 700;
  text-transform: uppercase; letter-spacing: var(--ls-upp);
  color: var(--gray-400);
}
.project-header__meta-value { font-size: var(--fs-sm); line-height: var(--lh-sm); color: var(--gray-300); }

/* Layout s pravým railem (detail + matice/historie) */
/* bordered-grid: bez mezer, oddělené 1px linkami (jako Figma) */
.layout-rail { display: grid; grid-template-columns: minmax(0,1fr) 320px; gap: 0; align-items: stretch; }
.rail-main { display: flex; flex-direction: column; min-width: 0; border-right: var(--stroke-1) solid var(--border); }
.rail { display: flex; flex-direction: column; gap: 0; }

/* ============================================================
   UTILITY
   ============================================================ */
.row   { display: flex; align-items: center; gap: var(--sp-8); }
.row-3 { display: flex; align-items: center; gap: var(--sp-12); }
.row-4 { display: flex; align-items: center; gap: var(--sp-16); }
.stack   { display: flex; flex-direction: column; gap: var(--sp-8); }
.stack-3 { display: flex; flex-direction: column; gap: var(--sp-12); }
.stack-4 { display: flex; flex-direction: column; gap: var(--sp-16); }
.spacer { flex: 1; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }

/* ============================================================
   AUTH STRÁNKY (login / chyby) — mimo Figma scope, zachováno
   ============================================================ */
.login-page { display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: var(--sp-16); }
.login-card { background: var(--bg-standard); border: var(--stroke-1) solid var(--border); padding: var(--sp-32); width: 100%; max-width: 400px; }
.login-card-wide { max-width: 600px; }
.login-card h1 { text-align: center; margin-bottom: var(--sp-24); color: var(--gray-50); font-size: var(--fs-xl); }
.form-group { margin-bottom: var(--sp-16); }
.form-group label { display: block; margin-bottom: var(--sp-4); font-weight: 500; font-size: var(--fs-sm); color: var(--gray-300); }
.form-group input { width: 100%; padding: 9px 13px; border: var(--stroke-1) solid var(--border-control); background: var(--surface); color: var(--gray-200); font-size: var(--fs-base); }
.form-group input:focus { outline: none; border-color: var(--accent); }
.alert { padding: var(--sp-12) var(--sp-16); margin-bottom: var(--sp-16); font-size: var(--fs-sm); border: var(--stroke-1) solid transparent; }
.alert-error { background: rgba(220,38,38,0.12); border-color: var(--accent); color: var(--heat-4); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1023px) {
  /* Mobil/tablet: sidebar → hamburger overlay; topbar = jediný header */
  .app { display: block; }
  .topbar { position: sticky; top: 0; z-index: 30; padding: 0 var(--sp-16); }
  .topbar__burger, .topbar__search-btn { display: inline-flex; }
  .topbar__logo-link { display: flex; }
  .topbar__env, .topbar__search-form { display: none; }
  .topbar__user-name, .topbar__user .pill, .topbar__user form { display: none; }  /* nech jen avatar */

  /* Hledání: ikona v topbaru rozbalí celořádkový vyhledávací pruh pod headerem */
  .topbar.search-open .topbar__search-form {
    display: flex;
    position: absolute;
    left: 0; right: 0; top: 100%;
    max-width: none;
    padding: var(--sp-8) var(--sp-16);
    background: var(--bg-standard);
    border-bottom: var(--stroke-1) solid var(--border);
    z-index: 31;
  }
  .topbar.search-open .topbar__search { height: 36px; }

  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; right: 0;
    max-height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
    z-index: 40;
    display: none;
    border-right: 0;
    border-bottom: var(--stroke-1) solid var(--border);
    box-shadow: 0 12px 28px rgba(0,0,0,0.5);
  }
  .app.nav-open .sidebar { display: block; }
  .sidebar__brand { display: none; }

  .rail-main { border-right: 0; }
  .layout-rail { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .widget--3, .widget--4, .widget--6, .widget--8 { grid-column: span 6; }
}
@media (max-width: 767px) {
  .form-grid { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: 1fr; }
  .widget--3, .widget--4, .widget--5, .widget--6, .widget--7, .widget--8, .widget--12 { grid-column: span 12; }
  .page { padding: var(--sp-16); }
}

/* ============================================================
   WIDE (≥ 1400px) — centrovaný rámovaný app shell
   Rám je jediná linka na okraji; vnitřní mřížka kreslí linky přes
   column-gap (KPI/widgety), takže se s rámem nesčítají.
   ============================================================ */
@media (min-width: 1550px) {
  .app {
    max-width: 1550px;
    margin: 70px auto;
    min-height: calc(100vh - 200px);
    border: var(--stroke-1) solid var(--border);
  }
}

/* ============================================================
   Flash zpravy (success/error) – banner nad obsahem stranky
   ============================================================ */
.flash {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  margin: 0 0 var(--sp-16);
  padding: var(--sp-12) var(--sp-16);
  border: var(--stroke-1) solid var(--border);
  border-left-width: 3px;
  background: var(--surface);
  color: var(--gray-200);
  font-family: var(--font-display);
  font-size: var(--fs-sm);
}
.flash--success { border-left-color: var(--rag-green-fg, #16a34a); }
.flash--error   { border-left-color: var(--accent); color: var(--accent-light); }
.flash__icon { flex: none; }

/* Chyba u formularoveho pole + chybovy stav inputu */
.form-field__error {
  font-family: var(--font-display);
  font-size: var(--fs-xxs);
  color: var(--accent-light);
}
.input.is-error,
.select.is-error,
.textarea.is-error { border-color: var(--accent); }

/* ============================================================
   Modal / dialog – native <dialog>, laden do bordered-grid tematu
   ============================================================ */
.modal {
  width: min(680px, calc(100vw - 2 * var(--sp-32)));
  max-height: calc(100vh - 2 * var(--sp-32));
  /* nativni <dialog> se centruje pres margin:auto + inset:0; globalni reset (margin:0) to jinak prebije a modal spadne do leveho horniho rohu */
  margin: auto;
  inset: 0;
  padding: 0;
  border: var(--stroke-1) solid var(--border);
  background: var(--bg-standard);
  color: var(--gray-200);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  /* Otevirani/zavirani animace – ciste CSS pro native <dialog>.
     transition-behavior: allow-discrete drzi prvek v top-layeru i pri .close(),
     takze prechod dobehne i pri zavirani (app.js menit netreba). */
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition:
    opacity 0.16s ease,
    transform 0.16s ease,
    overlay 0.16s ease allow-discrete,
    display 0.16s ease allow-discrete;
}
.modal[open] {
  opacity: 1;
  transform: translateY(0) scale(1);
}
/* vychozi stav pri vstupu do top-layeru – z nej se animuje na [open] */
@starting-style {
  .modal[open] {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}
.modal::backdrop {
  background-color: rgba(0, 0, 0, 0);
  transition:
    background-color 0.16s ease,
    overlay 0.16s ease allow-discrete,
    display 0.16s ease allow-discrete;
}
.modal[open]::backdrop { background-color: rgba(0, 0, 0, 0.6); }
@starting-style {
  .modal[open]::backdrop { background-color: rgba(0, 0, 0, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .modal,
  .modal::backdrop,
  .select-ui__panel,
  .select-ui__panel[hidden] { transition: none; }
}
.modal__form { display: flex; flex-direction: column; max-height: calc(100vh - 2 * var(--sp-32)); }
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-16);
  padding: var(--sp-16) var(--sp-24);
  border-bottom: var(--stroke-1) solid var(--border);
}
.modal__title { font-family: var(--font-display); font-weight: 700; color: var(--gray-50); }
.modal__desc { font-size: var(--fs-xxs); color: var(--gray-400); margin-top: var(--sp-2); }
.modal__close {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--gray-400);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: var(--sp-4);
}
.modal__close:hover { color: var(--gray-200); }
/* dialog dostava focus jen kvuli presunu z × (viz app.js openModal) – bez ringu */
.modal:focus { outline: none; }
.modal__body { padding: var(--sp-24); overflow-y: auto; }
.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-8);
  padding: var(--sp-16) var(--sp-24);
  border-top: var(--stroke-1) solid var(--border);
}
.modal__footer--spread { justify-content: space-between; }
.modal__confirm-text { color: var(--gray-300); font-size: var(--fs-sm); }

/* ============================================================
   Reports (S16) – rozcestník dlaždic
   ============================================================ */
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-16);
}
.report-tile { display: block; transition: border-color 0.15s ease; }   /* sjednoceno s hover prechody */
.report-tile:hover { border-color: var(--border-control); }
.report-tile__icon {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface);
  color: var(--accent-bright);
  font-size: 16px;
  margin-bottom: var(--sp-12);
}
.report-tile__title { font-weight: 700; color: var(--gray-50); margin-bottom: var(--sp-4); }
.report-tile__desc { font-size: var(--fs-sm); color: var(--gray-400); }

/* ============================================================
   Error stránky (S18) – standalone, bez sidebaru
   ============================================================ */
.error-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-32);
  background: var(--bg-standard);
}
.error-card { width: 100%; max-width: 520px; }
.error-code {
  font-family: var(--font-display, var(--font-sans));
  font-size: 56px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.error-title { font-size: var(--fs-xl); font-weight: 700; color: var(--gray-50); }
.error-detail {
  width: 100%;
  max-height: 220px;
  overflow: auto;
  text-align: left;
  padding: var(--sp-12);
  background: var(--bg-dark);
  border: var(--stroke-1) solid var(--border);
  color: var(--gray-400);
  font-size: var(--fs-xs);
  white-space: pre-wrap;
}
.topbar__user-link:hover .topbar__user-name { color: var(--gray-50); }

/* ============================================================
   Gantt (S4) – server-rendered CSS timeline (Schedule tab)
   ============================================================ */
.gantt { --gantt-left: 240px; font-family: var(--font-display, var(--font-sans)); }
.gantt__head {
  display: grid;
  grid-template-columns: var(--gantt-left) 1fr;
  border-bottom: var(--stroke-1) solid var(--border);
}
.gantt__left-head, .gantt__row-left { padding: var(--sp-8) var(--sp-12); }
.gantt__left-head { font-size: var(--fs-xs); text-transform: uppercase; color: var(--gray-400); }
.gantt__timeline { position: relative; height: 32px; }
.gantt__month {
  position: absolute; top: var(--sp-8); transform: translateX(1px);
  font-size: var(--fs-xxs); color: var(--gray-400); white-space: nowrap;
  border-left: var(--stroke-1) solid var(--border); padding-left: 4px;
}
.gantt__body { position: relative; }
.gantt__grid { position: absolute; left: var(--gantt-left); right: 0; top: 0; bottom: 0; z-index: 0; pointer-events: none; }
.gantt__gridline { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--border); opacity: 0.5; }
.gantt__today {
  position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); opacity: 0.8;
  animation: fade-in 0.5s ease backwards;
  animation-delay: calc(var(--stage-3) + 300ms);
}
.gantt__row {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: var(--gantt-left) 1fr;
  height: 34px; align-items: center;
  border-bottom: var(--stroke-1) solid var(--border);
}
.gantt__row-left { display: flex; align-items: center; min-width: 0; }
.gantt__task-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); color: var(--gray-200); }
.gantt__row-track { position: relative; height: 100%; }
/* Vstupni animace Ganttu (stage 3): bary rostou zleva se staggerem --d (index
   radku z sablony), milniky naskoci, popisek dofadne az po dorusteni baru.
   Keyframy skladaji cely transform vc. centrovani (translateY/translate). */
@keyframes gantt-grow { from { transform: translateY(-50%) scaleX(0); } }
@keyframes gantt-milestone-in { from { transform: translate(-50%, -50%) rotate(45deg) scale(0); opacity: 0; } }
.gantt__bar {
  position: absolute; top: 50%; transform: translateY(-50%);
  height: 16px; min-width: 4px; border-radius: var(--radius-2);
  display: flex; align-items: center; overflow: hidden;
  transform-origin: left;
  animation: gantt-grow 0.5s var(--ease-enter) backwards;
  animation-delay: calc(var(--stage-3) + var(--d, 0) * 40ms);
}
.gantt__bar-label {
  font-size: 9px; color: rgba(255,255,255,0.9); padding: 0 4px; white-space: nowrap;
  animation: fade-in 0.3s ease backwards;
  animation-delay: calc(var(--stage-3) + var(--d, 0) * 40ms + 350ms);
}
.gantt__bar--green { background: var(--success, #2e7d32); }
.gantt__bar--amber { background: #c9851f; }
.gantt__bar--red   { background: var(--accent); }
.gantt__milestone {
  position: absolute; top: 50%; width: 12px; height: 12px;
  transform: translate(-50%, -50%) rotate(45deg);
  background: var(--accent-bright); border: 1px solid var(--gray-50);
  animation: gantt-milestone-in 0.4s var(--ease-enter) backwards;
  animation-delay: calc(var(--stage-3) + var(--d, 0) * 40ms);
}
.gantt__swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; margin-right: 2px; }

/* ============================================================
   Řaditelné tabulky (klik na hlavičku sloupce)
   ============================================================ */
.table thead th.th-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.table thead th.th-sortable:hover { color: var(--gray-200); }
/* Misto pro indikator se rezervuje vzdy (i nesorted), aby sloupec pri zobrazeni/skryti ▲/▼ neposkakoval */
.table thead th.th-sortable::after {
    content: "▲";
    display: inline-block;
    width: 8px;
    margin-left: 4px;
    font-size: 8px;
    text-align: center;
    color: transparent;
}
.table thead th.is-sorted-asc::after { content: "▲"; color: var(--accent-bright); }
.table thead th.is-sorted-desc::after { content: "▼"; color: var(--accent-bright); }

/* ============================================================
   Risk register — pevné šířky sloupců (12 sloupců → fixed layout)
   Risk text dostane nejvíc místa, krátká čísla/Score jen co potřebují.
   Při užším kontejneru .table-scroll horizontálně roluje (min-width).
   ============================================================ */
.table--risks { table-layout: fixed; min-width: 1300px; }
.table--risks col.c-risk    { width: 240px; }
.table--risks col.c-project { width: 110px; }
.table--risks col.c-prob    { width: 70px; }
.table--risks col.c-label   { width: 88px; }   /* KPI, Impact */
.table--risks col.c-score   { width: 70px; }
.table--risks col.c-money   { width: 96px; }   /* Cost, Likely, Res. Likely, Reduction */
.table--risks col.c-status  { width: 104px; }
.table--risks col.c-owner   { width: 130px; }
/* Krátké hodnoty drž na jednom řádku; Risk / Project (ID) / Owner se smí zalomit */
.table--risks tbody td { white-space: nowrap; }
.table--risks tbody td:first-child,
.table--risks tbody td:nth-child(2),
.table--risks tbody td:last-child { white-space: normal; overflow-wrap: anywhere; }

/* ---------- Global search results ---------- */
.search-group { margin-bottom: var(--sp-24); }
.search-group__head {
  display: flex; align-items: center; gap: var(--sp-12);
  padding: var(--sp-12) 0 var(--sp-8);
}
.search-group__title {
  display: inline-flex; align-items: center; gap: var(--sp-8);
  font-size: var(--fs-sm); font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--gray-50);
}
.search-group__title i { color: var(--accent); }
.search-list { border: var(--stroke-1) solid var(--border); background: var(--bg-standard); }
.search-item {
  display: flex; align-items: center; gap: var(--sp-12);
  padding: var(--sp-12) var(--sp-16);
  border-bottom: var(--stroke-1) solid var(--border);
  text-decoration: none; color: var(--gray-50);
}
.search-item:last-child { border-bottom: 0; }
.search-item:hover { background: var(--surface); }
.search-item__main { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; flex: 1; }
.search-item__title { font-size: var(--fs-md); color: var(--gray-50); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-item__sub { font-size: var(--fs-xs); color: var(--gray-200); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-item__arrow { color: var(--gray-200); font-size: var(--fs-xs); }
.search-group__all {
  display: inline-block; margin-top: var(--sp-8);
  font-size: var(--fs-sm); color: var(--accent-bright); text-decoration: none;
}
.search-group__all:hover { text-decoration: underline; }
.search-empty {
  text-align: center; padding: var(--sp-32);
  border: var(--stroke-1) solid var(--border); background: var(--bg-standard);
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-8);
}
.search-empty__icon { font-size: 28px; color: var(--gray-200); }
.search-empty__title { font-size: var(--fs-md); color: var(--gray-50); }
.search-empty__hint { font-size: var(--fs-sm); color: var(--gray-200); }

/* ============================================================
   PREFERS-REDUCED-MOTION — spolecny blok pro vsechny vstupni
   animace. MUSI byt na konci souboru (za pravidly komponent),
   jinak pri shodne specificite prohraje kaskadu.
   Hover/focus prechody (barvy) zustavaji – nejsou pohyb.
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .greeting__title, .greeting__meta,
  .page__title, .page__subtitle,
  .project-header__title, .card__title, .kpi__label,
  .page__actions, .project-header__meta, .table-toolbar, .table thead,
  .kpi__value, .kpi__delta, .card__body, .form-grid, .pagination,
  .bars__bar, .progressbar__fill, .donut::before,
  .table tbody tr,
  .select-ui__option,
  .flash,
  .phase-step,
  .risk-matrix__cell, .risk-matrix__cell.is-current,
  .gantt__bar, .gantt__milestone, .gantt__bar-label, .gantt__today {
    animation: none;
  }
  /* --sweep ma @property initial 0deg -> bez animace nastavit plny kruh explicitne */
  .donut::before { --sweep: 360deg; }
  /* first-entrance (blueprint vstup): vse staticke, kreslici overlay cary pryc */
  .first-entrance .app,
  .first-entrance .sidebar, .first-entrance .topbar, .first-entrance .main,
  .first-entrance :is(.sidebar__brand, .sidebar__graphic),
  .first-entrance .sidebar__nav > *,
  .first-entrance .topbar > *,
  .first-entrance .risk-matrix__cell.is-current {
    animation: none;
  }
  .first-entrance .app::before,
  .first-entrance .app::after,
  .first-entrance .sidebar::after,
  .first-entrance .topbar::after { content: none; }
}
