/* Styly aplikace. Barvy, písma a mezery bere z design systému (css/styles.css). */
body { margin: 0; background: var(--color-bg); }
a { color: var(--color-accent-700); }
a:hover { color: var(--color-accent-900); }
button { font-family: var(--font-body); }

/* ---------- Rozvržení ---------- */
/* ---------- Rozvržení ---------- */
.app {
  display: flex;
  min-height: 100vh;
  color: var(--color-text);
  background: var(--color-bg);
  align-items: flex-start;
}

.side {
  width: 250px;
  flex: 0 0 250px;
  position: sticky;
  top: 0;
  height: 100vh;
  max-height: 100vh;
  border-right: 1px solid var(--color-divider);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--color-bg);
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
}

/* Jemný scrollbar pro levý panel */
.side::-webkit-scrollbar {
  width: 4px;
}
.side::-webkit-scrollbar-track {
  background: transparent;
}
.side::-webkit-scrollbar-thumb {
  background: var(--color-neutral-300);
}
.side::-webkit-scrollbar-thumb:hover {
  background: var(--color-neutral-400);
}

.main {
  flex: 1 1 0;
  min-width: 0;
  padding: 28px 32px 64px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px;
  flex-shrink: 0;
}
.brand-logo { width: 38px; height: 38px; object-fit: contain; flex: none; display: block; }
.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand { font-family: var(--font-heading); font-weight: 600; font-size: 20px; letter-spacing: .02em; text-transform: uppercase; line-height: 1.1; }
.brand-sub { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--color-neutral-700); }

.side-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--color-divider);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  color: var(--color-neutral-700);
  flex-shrink: 0;
}
.side-status { display: flex; align-items: center; gap: 8px; }
.sq { width: 7px; height: 7px; background: var(--color-accent); display: inline-block; flex: none; }

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--color-text);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.12s ease, border-color 0.12s ease;
}
.nav-item:hover { background: var(--color-neutral-200); }
.nav-item .badge { font-family: var(--font-body); font-weight: 500; font-size: 11px; color: var(--color-neutral-700); }
.nav-item.is-active { background: var(--color-accent-900); border-color: var(--color-accent-900); color: var(--color-bg); }
.nav-item.is-active .badge { color: var(--color-accent-300); }

.screen { display: flex; flex-direction: column; gap: 26px; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.head h1 { margin: 4px 0 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 24px; align-items: start; }
.span-all { grid-column: 1 / -1; }
.scroll-x { overflow-x: auto; }

/* ---------- Typografie ---------- */
.kicker { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--color-accent-700); }
.label { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--color-neutral-600); }
.muted { color: var(--color-neutral-700); }
.small { font-size: 12px; }
.lead { font-family: var(--font-heading); font-weight: 600; font-size: 24px; line-height: 1.15; text-wrap: pretty; max-width: 900px; }
.body-text { font-size: 15px; line-height: 1.6; color: var(--color-neutral-800); text-wrap: pretty; max-width: 900px; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
h4 { margin: 0; }

/* ---------- Panely (blueprint rámečky) ---------- */
.panel { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.ai-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px 28px; align-items: start; }

/* ---------- KPI mřížka ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); border-top: 1px solid var(--color-divider); border-left: 1px solid var(--color-divider); }
.kpi { padding: 16px 18px; border-right: 1px solid var(--color-divider); border-bottom: 1px solid var(--color-divider); display: flex; flex-direction: column; gap: 4px; }
.kpi-value { font-family: var(--font-heading); font-weight: 600; font-size: 36px; line-height: 1; display: flex; align-items: center; gap: 8px; }
.kpi-value.sm { font-size: 22px; }

/* ---------- Segmentové přepínače ---------- */
.segbar { display: flex; flex-wrap: wrap; border: 1px solid var(--color-divider); width: fit-content; }
.segbar button { padding: 8px 14px; border: 0; border-right: 1px solid var(--color-divider); background: transparent; color: var(--color-text); font-size: 13px; cursor: pointer; display: flex; gap: 6px; }
.segbar button:last-child { border-right: 0; }
.segbar button:hover { background: var(--color-neutral-200); }
.segbar button.is-on { background: var(--color-accent); color: var(--color-bg); }
.segbar button .count { opacity: .7; }
.segbar.sm button { padding: 5px 10px; font-size: 12px; }

/* ---------- Stavy (kritické / pozor / v pořádku) ---------- */
.pill { flex: none; font-size: 11px; padding: 3px 9px; border: 1px solid transparent; white-space: nowrap; }
.dot { width: 7px; height: 7px; flex: none; display: inline-block; }
.t-crit.pill { background: var(--color-accent-900); border-color: var(--color-accent-900); color: var(--color-bg); }
.t-warn.pill { background: transparent; border-color: var(--color-accent); color: var(--color-accent-800); }
.t-ok.pill   { background: var(--color-neutral-200); color: var(--color-neutral-800); }
.t-crit.dot { background: var(--color-accent-900); }
.t-warn.dot { background: var(--color-accent-400); }
.t-ok.dot   { background: var(--color-neutral-300); }
.w-crit { font-weight: 600; } .w-warn { font-weight: 500; }

/* ---------- Karty klientů ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 22px; }
.client-card { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; cursor: pointer; }
.client-card:hover { background: var(--color-neutral-100); }
.cc-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.cc-name { font-family: var(--font-heading); font-weight: 600; font-size: 20px; line-height: 1.15; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.field-val { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.progress-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--color-neutral-700); }
.progress { height: 3px; background: var(--color-neutral-200); }
.progress > div { height: 3px; background: var(--color-accent); }
.empty { padding: 24px; border: 1px dashed var(--color-divider); font-size: 14px; color: var(--color-neutral-700); }

/* ---------- Řádky v panelech ---------- */
.row { display: grid; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--color-neutral-200); font-size: 14px; }
.row-vid { grid-template-columns: 52px 1fr auto; }
.row-inv { grid-template-columns: 1fr auto auto auto; }
.row-file { grid-template-columns: 1fr auto; }
.row-log { grid-template-columns: 64px 1fr; align-items: start; }
.row-toggle { grid-template-columns: 1fr auto; }
.row-team { grid-template-columns: 32px 1fr auto; }
.stack { display: flex; flex-direction: column; gap: 2px; }
.brief { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.brief-item { font-size: 14px; line-height: 1.4; padding-left: 10px; border-left: 1px solid var(--color-accent); }
.brief-item.no { border-left-color: var(--color-neutral-400); color: var(--color-neutral-800); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 14px; }
.kv > span:nth-child(odd) { color: var(--color-neutral-700); }
.avatar { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--color-divider); font-family: var(--font-heading); font-weight: 600; font-size: 14px; }
.risk { cursor: pointer; }
.risk:hover { background: var(--color-neutral-100); }
.clickable { cursor: pointer; }

/* ---------- Kalendář ---------- */
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--color-neutral-800); }
.legend span { display: flex; gap: 6px; align-items: center; }
.legend i { width: 10px; height: 10px; display: inline-block; }
.cal { min-width: 760px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--color-divider); border-left: 1px solid var(--color-divider); }
.cal-wd { padding: 8px 10px; border-right: 1px solid var(--color-divider); border-bottom: 1px solid var(--color-divider); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--color-neutral-700); }
.cal-cell { min-height: 112px; padding: 8px; border-right: 1px solid var(--color-divider); border-bottom: 1px solid var(--color-divider); display: flex; flex-direction: column; gap: 4px; }
.cal-cell.today { background: var(--color-accent-100); }
.cal-day { font-family: var(--font-heading); font-weight: 600; font-size: 16px; }
.cal-cell.out .cal-day { color: var(--color-neutral-500); }
.cal-cell-head { display: flex; justify-content: space-between; align-items: center; }
.cal-add-btn { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; border: 1px dashed var(--color-divider); background: transparent; color: var(--color-neutral-600); cursor: pointer; font-size: 13px; line-height: 1; border-radius: 2px; padding: 0; opacity: 0; transition: opacity .15s; }
.cal-cell:hover .cal-add-btn { opacity: 1; }
.cal-add-btn:hover { background: var(--color-accent); color: var(--color-bg); border-style: solid; }
.ev { text-align: left; font-size: 11px; line-height: 1.3; padding: 3px 6px; border: 1px solid transparent; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-done, .legend .ev-done { background: var(--color-neutral-200); color: var(--color-neutral-800); }
.ev-plan, .legend .ev-plan { background: transparent; border: 1px solid var(--color-accent-400); color: var(--color-accent-800); }
.ev-late, .legend .ev-late { background: var(--color-accent-900); border-color: var(--color-accent-900); color: var(--color-bg); }

/* ---------- Faktura ---------- */
.inv-form { display: flex; flex-direction: column; gap: 18px; }
.items-grid { display: grid; grid-template-columns: 1fr 64px 120px; gap: 8px; }
.items-head { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--color-neutral-600); }
.paper { padding: 32px; display: flex; flex-direction: column; gap: 22px; background: var(--color-neutral-100); }
.paper-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.paper-title { font-family: var(--font-heading); font-weight: 600; font-size: 22px; }
.upper { text-transform: uppercase; letter-spacing: .02em; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; font-size: 13px; line-height: 1.5; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--color-divider); font-size: 14px; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding-top: 12px; font-size: 14px; }
.totals .grand { font-family: var(--font-heading); font-weight: 600; font-size: 20px; padding-top: 6px; }
textarea.mail { min-height: 200px; line-height: 1.5; }

/* ---------- Přepínač ---------- */
.toggle { position: relative; width: 38px; height: 20px; border: 1px solid var(--color-divider); background: transparent; cursor: pointer; padding: 0; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; background: var(--color-neutral-500); }
.toggle.is-on { background: var(--color-accent); border-color: var(--color-accent); }
.toggle.is-on::after { left: 21px; background: var(--color-bg); }

/* ---------- Notifikace ---------- */
.toast { position: fixed; right: 24px; bottom: 24px; padding: 12px 16px; background: var(--color-accent-900); color: var(--color-bg); font-size: 14px; box-shadow: var(--shadow-lg); max-width: 360px; z-index: 1100; }

/* ---------- Dialog Modal ---------- */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: safe center;
  /* Dlouhy dialog roluje tady, ne uvnitr sebe – rohove znacky zustanou videt */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 26px 18px;
  background: rgba(29, 31, 32, 0.6);
  backdrop-filter: blur(2px);
  z-index: 1000;
}
.dialog {
  background: var(--color-bg);
  box-shadow: var(--shadow-lg);
  z-index: 1001;
  /* Delsi obsah (napr. detail videa s prehravacem) musi jit odrolovat */
  /* Zadny vlastni scroll: rohove znacky .corner lezi 6px vne ramecku,
     takze by je overflow orezal a zaroven by kvuli nim naskocil posuvnik.
     Dlouhy dialog roluje spolecne s pozadim (.dialog-backdrop). */
  margin: auto;
}

/* Prvky v mrizce se musi umet zmensit, jinak obsah rozsiri dialog */
.dialog-body > .stack { min-width: 0; }
.dialog-body input,
.dialog-body select,
.dialog-body textarea,
.dialog-body video { max-width: 100%; }

@media (max-width: 860px) {
  .app {
    flex-direction: column;
  }
  .side {
    width: 100%;
    flex: none;
    position: static;
    height: auto;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--color-divider);
    padding: 16px;
    gap: 14px;
    overflow-y: visible;
  }
  .nav-list {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .nav-item {
    flex: 1 1 130px;
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .main { padding: 20px 16px 48px; }
  .brief, .fields { grid-template-columns: 1fr; }
}


/* ---------- Dokument faktury (podle tištěné předlohy) ---------- */
.invoice-doc {
  background: #fff;
  color: #111;
  padding: 44px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: var(--shadow-lg);
}
.inv-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.inv-title { font-family: var(--font-heading); font-weight: 800; font-size: 44px; letter-spacing: -0.02em; margin: 0; line-height: 1; }
.inv-title span { font-size: 17px; font-weight: 700; letter-spacing: 0; }
.inv-logo { width: 68px; height: 68px; object-fit: contain; flex: none; }
.inv-rule { border-top: 1px solid #111; }
.inv-h { font-family: var(--font-heading); font-weight: 700; font-size: 13px; letter-spacing: 0.04em; margin-bottom: 8px; }
.inv-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.inv-block { padding: 2px 0; }
.inv-dates { margin-top: 16px; }
.inv-table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.inv-table th {
  font-family: var(--font-heading); font-weight: 700; font-size: 12px; letter-spacing: 0.03em;
  text-align: left; padding: 10px 8px; border-top: 1px solid #111; border-bottom: 1px solid #111;
}
.inv-table td { padding: 12px 8px; border-bottom: 1px solid #ddd; }
.inv-table .right, .invoice-doc .right { text-align: right; }
.inv-foot { display: grid; grid-template-columns: 180px 1fr; gap: 28px; align-items: start; margin-top: 10px; }
.inv-qr-box {
  width: 170px; height: 170px; border: 1px solid #111;
  display: flex; align-items: center; justify-content: center; background: #fff;
}
.inv-qr-box img, .inv-qr-box canvas { width: 150px !important; height: 150px !important; }
.inv-qr-label { font-family: var(--font-heading); font-weight: 700; font-size: 13px; text-align: center; margin-top: 8px; }
.inv-sum-row {
  display: flex; justify-content: space-between; gap: 20px;
  font-family: var(--font-heading); font-weight: 700; font-size: 17px;
  padding-bottom: 10px; border-bottom: 1px solid #111;
}
.inv-note { font-size: 10.5px; line-height: 1.5; text-align: center; color: #333; margin-top: 12px; }

@media (max-width: 720px) {
  .invoice-doc { padding: 24px 18px; }
  .inv-title { font-size: 32px; }
  .inv-cols { grid-template-columns: 1fr; }
  .inv-foot { grid-template-columns: 1fr; }
}

/* Tisk: na papír jde jen dokument faktury, celá na jednu A4 */
@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff; }
  body.printing-invoice .app > .side,
  body.printing-invoice .head,
  body.printing-invoice .inv-form,
  body.printing-invoice .toast { display: none !important; }
  body.printing-invoice .app,
  body.printing-invoice .main,
  body.printing-invoice .screen { display: block; padding: 0; margin: 0; }
  body.printing-invoice .grid-panels { display: block !important; gap: 0 !important; }

  body.printing-invoice .invoice-doc {
    box-shadow: none;
    padding: 0;
    gap: 17px;
    font-size: 12.5pt;
    line-height: 1.45;
    page-break-inside: avoid;
    break-inside: avoid;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  /* Šířka A4 po odečtení okrajů je pod mobilním breakpointem – sloupce musí zůstat vedle sebe. */
  body.printing-invoice .inv-cols { grid-template-columns: 1fr 1fr !important; gap: 24px !important; }
  body.printing-invoice .inv-foot { grid-template-columns: 172px 1fr !important; gap: 28px !important; margin-top: 8px; }

  body.printing-invoice .inv-title { font-size: 42pt; }
  body.printing-invoice .inv-title span { font-size: 15pt; }
  body.printing-invoice .inv-logo { width: 68px; height: 68px; }
  body.printing-invoice .inv-h { font-size: 12.5pt; margin-bottom: 8px; }
  body.printing-invoice .inv-dates { margin-top: 15px; }
  body.printing-invoice .inv-table th { padding: 11px 8px; font-size: 11pt; }
  body.printing-invoice .inv-table td { padding: 13px 8px; }
  body.printing-invoice .inv-qr-box { width: 172px; height: 172px; }
  body.printing-invoice .inv-qr-box img,
  body.printing-invoice .inv-qr-box canvas { width: 150px !important; height: 150px !important; }
  body.printing-invoice .inv-qr-label { font-size: 12pt; margin-top: 8px; }
  body.printing-invoice .inv-sum-row { font-size: 21pt; padding-bottom: 10px; }
  body.printing-invoice .inv-note { font-size: 9.5pt; margin-top: 14px; }
}

/* ---------- Posuvník jako měřítko technického výkresu ----------
   Dráha nese rysky po 9 px jako pravítko, jezdec je plný akcentní blok
   s úchopem uprostřed a hranatými konci. Žádné zaoblení. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-accent) var(--color-surface);
}

::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

/* Dráha: podklad + rysky měřítka + dělicí linka */
::-webkit-scrollbar-track {
  background-color: var(--color-surface);
  background-image: repeating-linear-gradient(
    to bottom,
    var(--color-neutral-300) 0, var(--color-neutral-300) 1px,
    transparent 1px, transparent 9px
  );
  border-left: 1px solid var(--color-divider);
}

::-webkit-scrollbar-track:horizontal {
  background-image: repeating-linear-gradient(
    to right,
    var(--color-neutral-300) 0, var(--color-neutral-300) 1px,
    transparent 1px, transparent 9px
  );
  border-left: 0;
  border-top: 1px solid var(--color-divider);
}

/* Jezdec: plný blok s trojicí úchopových rysek uprostřed */
::-webkit-scrollbar-thumb {
  background-color: var(--color-accent);
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.8) 0, rgba(255, 255, 255, 0.8) 1px,
    transparent 1px, transparent 4px
  );
  background-size: 7px 10px;
  background-position: center;
  background-repeat: no-repeat;
  background-clip: padding-box;
  border: 3px solid transparent;
  border-radius: 0;
  min-height: 42px;
}

::-webkit-scrollbar-thumb:horizontal {
  background-image: repeating-linear-gradient(
    to right,
    rgba(255, 255, 255, 0.8) 0, rgba(255, 255, 255, 0.8) 1px,
    transparent 1px, transparent 4px
  );
  background-size: 10px 7px;
  min-height: 0;
  min-width: 42px;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-accent-800, #46678a);
  border-width: 2px;
}

::-webkit-scrollbar-thumb:active {
  background-color: #1d1f20;
}

::-webkit-scrollbar-corner {
  background: var(--color-surface);
}

/* Nad rozostřeným pozadím dialogu by šedé měřítko zaniklo */
.dialog-backdrop::-webkit-scrollbar-track {
  background-color: transparent;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.28) 0, rgba(255, 255, 255, 0.28) 1px,
    transparent 1px, transparent 9px
  );
  border-left: 0;
}
.dialog-backdrop::-webkit-scrollbar-thumb {
  background-color: rgba(242, 242, 243, 0.85);
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(29, 31, 32, 0.45) 0, rgba(29, 31, 32, 0.45) 1px,
    transparent 1px, transparent 4px
  );
}

/* Tabulky: užší lišta, ať neukrajuje z řádků */
.scroll-x::-webkit-scrollbar { height: 11px; }
