/* styles.css */
/* Global styles and CSS variables */

:root{
  /* light palette (theme tokens) */
  --bg: #f6f7fb;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #475569;

  /* brand + semantic */
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --accent: #059669;
  --accent-hover: #047857;
  --danger: #dc2626;
  --danger-hover: #b91c1c;

  /* surfaces */
  --border: #e2e8f0;
  --header: #ffffff;
  --header-border: #e2e8f0;
  --table-header-bg: #f8fafc;
  --input-bg: #ffffff;
  --input-border: #cbd5e1;

  /* focus + elevation */
  --focus: rgba(29,78,216,.18);
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 20px 60px rgba(0,0,0,.12);

  /* dialog backdrop */
  --overlay: rgba(15,23,42,.45);

  /* dialog sizes */
  --dialog-sm: 420px;
  --dialog-md: 560px;
  --dialog-lg: 720px;
  --dialog-xl: 960px;
  --dialog-2xl: 1200px;
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0; background:var(--bg); color:var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell;
}

/* Top bar */
.topbar{
  position: sticky; top:0; z-index:10;
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 16px; background:var(--header); border-bottom:1px solid var(--header-border);
}
.brand{ display:flex; align-items:center; gap:8px; font-weight:600; }
.brand svg{ fill:var(--primary); }
.nav a{ color:var(--muted); text-decoration:none; margin-left:16px; }
.nav a.active, .nav a:hover{ color:var(--ink); }

/* Layout */
/*
  Layout je sjednocený: vždy 1 sloupec (žádné dělení obrazovky).
  Dřívější dvousloupcový split byl zbytek starého UI a způsoboval
  problémy (úzký pravý panel / prázdný sloupec).
*/
.layout{
  display:grid;
  grid-template-columns: 1fr;
  gap:16px;
  padding:16px;
  max-width:1400px;
  margin:0 auto;
}

.panel{ display:flex; flex-direction:column; gap:16px; }
.panel-header{ display:flex; justify-content:space-between; align-items:center; }
.panel h2{ margin:0; font-size:16px; }

/* CRM view should span full width (both columns) */
#secCrm{
  grid-column: 1 / -1;
}

/* Admin views should span full width (both columns) */
.admin-host{
  grid-column: 1 / -1;
}


/* Cards */
.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius: var(--radius);
  padding:12px;
  box-shadow: var(--shadow-sm);
}
.card.totals .row{ display:flex; justify-content:space-between; padding:8px 0; border-bottom:1px dashed var(--border); }
.card.totals .row:last-child{ border-bottom:0; }
.total-strong{ font-weight:700; color:var(--ink); }

/* Grid helpers */
.grid{ display:grid; grid-template-columns: 1fr 1fr; gap:12px; }
.grid-3{ grid-template-columns: 2fr 1fr auto; }
.grid > *, .grid-3 > * { min-width: 0; }
@media (max-width: 980px){
  .layout{ grid-template-columns: 1fr; }
  .grid, .grid-3{ grid-template-columns: 1fr; }
}

/* Fields & inputs */
.field{ display:flex; flex-direction:column; gap:6px; }
.field > span{ color:var(--muted); font-size:12px; }
.field input, .field select, .field textarea, input.money-input{
  background:var(--input-bg); border:1px solid var(--input-border); color:var(--ink);
  padding:8px 10px; border-radius:8px; outline:none;
}
.field input::placeholder{ color:#9ca3af; }
.field textarea::placeholder{ color:#9ca3af; }
.field input:focus, .field select:focus, .field textarea:focus{
  border-color:#93c5fd; box-shadow: 0 0 0 3px var(--focus);
}

/* Generic input look (for textareas outside .field) */
.input{
  background:var(--input-bg);
  border:1px solid var(--input-border);
  color:var(--ink);
  padding:8px 10px;
  border-radius:8px;
  outline:none;
}
.input:focus{
  border-color:#93c5fd;
  box-shadow: 0 0 0 3px var(--focus);
}

/* Read‑only vzhled polí v Obhlídce */
#secInspection :is(input, select, textarea).is-readonly{
  background: #f7f7f7;
  color: var(--muted);
}

/* Read-only (hlavička obhlídky) */
.field input[readonly],
.field textarea[readonly],
.field select:disabled{
  background:#f7f7f7;
  color: var(--muted);
  box-shadow: none;
}

/* Select nemá readonly → vizuálně ho „zamrazíme“ */
#secInspection select.is-readonly{
  pointer-events: none;   /* neklikatelný */
  cursor: default;
}

/* Nepřehánět focus ring u readonly */
#secInspection :is(input, select, textarea).is-readonly:focus{
  border-color: var(--input-border);
  box-shadow: none;
}


/* Buttons */
.actions{ display:flex; gap:8px; align-items:center; }
.btn{
  appearance:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  text-decoration:none;
  user-select:none;
  white-space:nowrap;

  border:1px solid var(--border);
  border-radius:10px;
  padding:8px 12px;
  background:#f1f5f9;
  color:#111827;
  cursor:pointer;
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease, opacity .12s ease, transform .08s ease;
}
.btn:hover{ background:#e2e8f0; }
.btn:active{ transform: translateY(0.5px); }
.btn:disabled, .btn[disabled]{ opacity:.55; cursor:not-allowed; transform:none; }

/* Secondary / light buttons (outline) */
.btn.btn-secondary,
.btn.btn-light{
  background:#fff;
  border-color: var(--border);
}
.btn.btn-secondary:hover,
.btn.btn-light:hover{ background:#f8fafc; }

/* Small buttons */
.btn.btn-sm,
.btn.small{
  padding: 6px 10px;
  font-size: 12px;
}
.btn.primary{
  border-color: var(--primary);
  background: var(--primary);
  color:#fff;
  font-weight:700;
}
.btn.primary:hover{ background: var(--primary-hover); }
.btn.danger{ border-color: var(--danger); background: var(--danger); color:#fff; }
.btn.danger:hover{ background: var(--danger-hover); }

.btn:focus-visible{
  outline:none;
  box-shadow: 0 0 0 3px var(--focus);
}

/* Tables */
.table-wrap{ overflow:auto; border-radius:8px; border:1px solid var(--border); }
.table{ width:100%; border-collapse: collapse; }
.table thead th{
  font-size:12px; color:#475569; text-transform: uppercase; letter-spacing:.04em;
  background:var(--table-header-bg);
}
.table th, .table td{ padding:10px 12px; border-bottom:1px solid var(--border); }
.table tbody tr:hover{ background:#f1f5f9; }

/* Common compact action row inside tables */
.rq-table-actions{ display:flex; justify-content:flex-end; gap:8px; align-items:center; }

#tblQuoteOverview tbody tr{ cursor:pointer; }
#tblQuoteOverview tbody tr.selected{ background:#e0f2fe; }
#tblQuoteOverview tbody tr.selected:hover{ background:#bae6fd; }

.quote-overview-actions{ flex-wrap:wrap; }
.quote-overview-actions input{ flex:1; min-width:180px; padding:8px 10px; border:1px solid var(--border); border-radius:8px; background:#fff; }

/* Přehled nabídek: list má omezenou výšku a vlastní scroll */
#cardQuoteOverview .table-wrap{
  max-height: clamp(220px, 40vh, 520px);
}
#cardQuoteOverview .table-wrap thead th{
  position: sticky;
  top: 0;
  z-index: 2;
}
.table td.right, .right{ text-align:right; }
.table td.center{ text-align:center; }

/* Text helpers */
.muted{ color:var(--muted); }
.meta{ margin: 6px 0 0 0; }

/* Footer */
footer.footer{ padding:10px 16px; border-top:1px solid var(--border); color:var(--muted); background:#ffffff80; backdrop-filter:saturate(120%) blur(2px); }

/* Dialogs */
dialog{ border:none; border-radius: var(--radius); padding:0; background:transparent; }
dialog::backdrop{ background: var(--overlay); }

/*
  Některé dialogy stále používají jako wrapper `.panel` (např. CRM Detail,
  picker CRM v reportu, apod.). Protože samotný `<dialog>` má záměrně
  průhledné pozadí (kvůli `.dialog-card`), tak by `.panel` bez vlastního
  pozadí působil "neviditelně".

  Tohle pravidlo dá `.panel` uvnitř dialogu stejné vizuální vlastnosti
  jako karta.
*/
dialog > .panel{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  max-height: 92vh;
}

/*
  Některé nové dialogy používají jako wrapper `<form class="modal-content">`
  (typicky pro `method="dialog"`). Pokud wrapper nemá pozadí, dialog působí
  průhledně. Tady sjednotíme vzhled s ostatními kartami v dialogu.
*/
dialog > .modal-content{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);

  /* width via size tokens/classes */
  width: min(var(--dialog-width, var(--dialog-md)), 96vw);
  max-height: 92vh;
  display:flex;
  flex-direction:column;

  /* default/fallback: allow scrolling even when dialog is unstructured */
  overflow: auto;
  padding: 14px;
}

/* Structured dialogs use header/body/footer and keep footer reachable */
dialog > .modal-content.dialog-structured{
  padding: 0;
  overflow: hidden;
}

/* Size helpers */
dialog > .modal-content.dialog-sm{ --dialog-width: var(--dialog-sm); }
dialog > .modal-content.dialog-md{ --dialog-width: var(--dialog-md); }
dialog > .modal-content.dialog-lg{ --dialog-width: var(--dialog-lg); }
dialog > .modal-content.dialog-xl{ --dialog-width: var(--dialog-xl); }
dialog > .modal-content.dialog-2xl{ --dialog-width: var(--dialog-2xl); }
dialog > .modal-content.dialog-crm{ --dialog-width: 980px; }

.dialog-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 12px;
  padding: 14px 56px 10px 14px; /* extra right padding to avoid overlap with .dialog-close */
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.dialog-header-actions{
  display:flex;
  align-items:center;
  gap: 8px;
  flex-wrap: wrap;
}

.dialog-title{ margin:0; font-size:16px; font-weight:800; }
.dialog-subtitle{ margin:4px 0 0 0; font-size:12px; color:var(--muted); }
.dialog-section-title{ margin: 14px 0 8px; font-size: 14px; font-weight: 800; }
.dialog-section-title:first-child{ margin-top: 0; }
.dialog-body{
  flex: 1 1 auto;
  padding: 14px;
  overflow: auto;
  min-height: 0;
}
.dialog-footer{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
  background:#fff;
}
.dialog-footer.split{ justify-content: space-between; }
.dialog-footer .left, .dialog-footer .right{ display:flex; gap:8px; align-items:center; }

/* In dialog footers, make non-primary actions look secondary (outline) */
.dialog-footer .btn:not(.primary):not(.danger){ background:#fff; }
.dialog-footer .btn:not(.primary):not(.danger):hover{ background:#f8fafc; }

/* Allow using .dialog-close on modal-content too */
dialog > .modal-content{ position:relative; }

dialog > .panel > .panel-header{ padding: 12px 12px 0 12px; }
dialog > .panel > .panel-body{ padding: 12px; }
.dialog-card{
  background:var(--card);
  border:1px solid var(--border);
  padding:16px;
  border-radius: var(--radius);
  min-width: min(var(--dialog-md), 96vw);
  box-shadow: var(--shadow-lg);
}
menu{ display:flex; justify-content:flex-end; gap:8px; margin:12px 0 0 0; padding:0; }

/* === Collapsible cards === */
.card.collapsible .card-bar{
  display:flex; align-items:center; justify-content:space-between;
  margin:-4px -4px 8px; padding:6px 8px; border-radius:8px;
  background: var(--table-header-bg);
  user-select: none;
}
.card.collapsible .bar-title{ font-weight:600; }

.card.collapsible .toggle{
  display:inline-flex; align-items:center; gap:6px;
  border:1px solid var(--border); background:#f1f5f9; color:#111827;
  padding:4px 8px; border-radius:6px; cursor:pointer;
}
.card.collapsible .toggle:hover{ background:#e2e8f0; }

.card.collapsible .chev{ display:inline-block; transition: transform .15s ease; }
.card.collapsible.collapsed .chev{ transform: rotate(-90deg); }

/* skryj obsah karty, nech jen lištu */
.card.collapsible.collapsed > :not(.card-bar){ display:none !important; }

/* Close button on dialogs */
.dialog-card{ position:relative; }
.dialog-close{
  position:absolute; top:8px; right:8px;
  border:1px solid var(--border);
  background:#fff;
  color:#111827;
  border-radius:10px;
  padding:6px 10px;
  cursor:pointer;
  line-height:1;
}
.dialog-close:hover{ background:#f8fafc; }



#secReportSections .fp-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid #eee;
  user-select: none;
}

#secReportSections .fp-titlebar .bar-title {
  font-weight: 600;
}

#secReportSections .fp-actions .btn { margin-left: 6px; }

#secReportSections .fp-body {
  height: calc(100% - 42px);
  overflow: auto;
  padding: 8px 12px;
}

/* během dragování zobraz kurzor move a vypni text selection */
body.dragging, body.dragging * { cursor: move !important; user-select: none !important; }


/* === Blok Nabídky (toggle) ============================================ */
/*
  Už nechceme žádné dělení obrazovky na 2 sloupce.
  Levý blok "Nabídky" (#secLeft) jde pouze dočasně skrýt/zobrazit (toggle),
  aby šel používat naplno pravý obsah bez split‑screenu.

  Stav řeší třída .left-collapsed na <html> (ukládá se v localStorage).
  Pro zobrazení tlačítka "▶ Nabídky" používáme data-view z routeru.
*/
.left-collapsed #secLeft{
  display: none;
}

/* "Rail" tlačítko pro rozbalení */
.left-rail{
  position: fixed;
  left: 8px;
  top: 96px;                /* pod horní lištu */
  z-index: 10001;
  display: none;            /* ukáže se jen když je sbaleno */
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
  padding: 8px 12px;
}

/* Rail ukazuj jen na obrazovce Nabídek */
.left-collapsed[data-view="quotes"] .left-rail{ display: inline-flex; }

/* drobná úprava btn-light (pokud chceš jemnější vzhled) */
.btn.btn-light{
  background:#fff;
  border-color: var(--border);
}
.btn.btn-light:hover{
  background:#f8fafc;
}

#secReportSections.floating-panel {
  position: fixed;
  top: 72px;
  left: 72px;
  width: 640px;
  height: 460px;
  max-width: 95vw;
  max-height: 88vh;
  /* ▼ DOPLNIT: pevné minimum */
  min-width: 320px;
  min-height: 160px;

  background: #fff;
  border: 1px solid #dadde1;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0,0,0,.2), 0 2px 6px rgba(0,0,0,.12);
  z-index: 9999;
  display: none;
  resize: both;
  overflow: hidden;
}


.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px,1fr));
  gap: 8px;
}
.thumb {
  border: 1px solid #eee; padding: 4px; border-radius: 4px; text-align: center;
}
.thumb img {
  max-width: 100%; height: 100px; object-fit: cover; display: block; margin: 0 auto 4px;
}


/* [PL-INSP-CSS:FIELD-PHOTOS:BEGIN] */
.photo-strip { display:flex; flex-wrap:wrap; gap:6px; margin-top:6px; }
.photo-strip .ph { position:relative; width:72px; height:72px; }
.photo-strip .ph img { width:100%; height:100%; object-fit:cover; border:1px solid #ddd; border-radius:4px; display:block; }
.photo-strip .ph button.ph-del {
  position:absolute; right:-6px; top:-6px; width:20px; height:20px;
  border:none; border-radius:50%; background:#e53935; color:#fff; cursor:pointer; line-height:20px;
}
/* [PL-INSP-CSS:FIELD-PHOTOS:END] */


/* [PL-INSP-CSS:GALLERY-CAPTION] */
.thumb .caption{
  margin: 6px 0 8px;
  font-size: 12px;
  color: var(--muted);
}


/* Obhlídka – podsekce */
#secInspection #inspSectionsContainer{
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#secInspection .card.subsec .card-bar{
  background: var(--table-header-bg);
}
#secInspection .card.subsec .subsec-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 980px){
  #secInspection .card.subsec .subsec-grid{ grid-template-columns: 1fr; }
}

/* inline kamera u polí obhlídky */
#secInspection .btn-photo { margin-left: 6px; }
#secInspection .field :is(input, select, textarea) + .btn-photo{
  align-self: flex-start;
  margin-top: 4px;
}

.customer-header { margin: 8px 0 12px; line-height: 1.3; }
.customer-header .muted { color: var(--muted-text, #6b7280); }

/* --- Top nav --- */
#app-nav { position: sticky; top: 0; z-index: 1000; }
.topnav { display: flex; align-items: center; gap: 1rem; background: #f8f9fa; border-bottom: 1px solid #e5e7eb; padding: .5rem 1rem; }
.topnav .nav-brand a { text-decoration: none; font-weight: 600; color: #111827; }
.topnav .nav-burger { margin-left: auto; display: none; background: transparent; border: 1px solid #e5e7eb; padding: .25rem .5rem; border-radius: .25rem; }
.topnav .nav-list { list-style: none; display: flex; gap: .5rem; margin: 0; padding: 0; flex-wrap: wrap; }
.nav-item { position: relative; }
.nav-link, .dropdown-item { display: block; padding: .5rem .75rem; text-decoration: none; color: #111827; border-radius: .375rem; }
.nav-link:hover, .dropdown-item:hover { background: #eef2ff; }
.nav-link.active, .dropdown-item.active { background: #e0e7ff; font-weight: 600; }
.dropdown-menu { position: absolute; left: 0; top: 100%; min-width: 220px; background: white; border: 1px solid #e5e7eb; border-radius: .375rem; padding: .25rem 0; display: none; box-shadow: 0 10px 20px rgba(0,0,0,.06); }
.nav-item.dropdown.open > .dropdown-menu { display: block; }
@media (max-width: 768px) {
  .topnav { flex-wrap: wrap; }
  .topnav .nav-burger { display: inline-block; }
  .topnav.open .nav-list { display: block; width: 100%; }
  .nav-list { display: none; }
  .dropdown-menu { position: static; border: 0; box-shadow: none; }
}

/* Global nav nahoře */
#global-nav { position: sticky; top: 0; z-index: 1100; }

/* Starý topbar zůstane pod ním – většinou není třeba nic měnit */

/* === ANCHOR: NAV_ENHANCE (BEGIN) === */

/* -------------------------------------------------------------------------
   Hamburger menu (always collapsed by default)
   ------------------------------------------------------------------------- */

/* Hlavička může zalomit na více řádků (brand + burger, pak rozbalené menu). */
#app-nav.topbar{ flex-wrap: wrap; }

/* Burger je vždy vidět. */
#app-nav .topbar-burger{
  margin-left: auto;
  display: inline-block;
  background: transparent;
  border: 1px solid #e5e7eb;
  padding: .25rem .55rem;
  border-radius: .375rem;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

/* Navigace: defaultně schovaná (menu je „zavřené“). */
#app-nav .nav{ width: 100%; }
#app-nav:not(.open) .nav{ display: none; }

/* Otevřený stav: zobraď jako „drawer“ (svisle, celá šířka). */
#app-nav.open .nav{
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0,0,0,.08);
}

/* Zruš globální odsazování odkazů v .nav (ve „drawer“ režimu by to rušilo). */
#app-nav .nav a{ margin-left: 0; }

/* Skupiny v hamburger menu */
#app-nav .nav.nav-drawer .nav-section{
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#app-nav .nav.nav-drawer .nav-section-title{
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 2px 4px;
}

/* Položky */
#app-nav .nav.nav-drawer .nav-link,
#app-nav.open .nav > a{
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: #111827;
}
#app-nav .nav.nav-drawer .nav-link:hover,
#app-nav.open .nav > a:hover{ background: #eef2ff; }
#app-nav .nav.nav-drawer .nav-link.active,
#app-nav.open .nav > a.active{ background: #e0e7ff; font-weight: 600; }

/* Uživatelská část (jméno + odhlášení) */
#app-nav .nav.nav-drawer .nav-user{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
#app-nav .nav.nav-drawer .nav-user #navLogout{
  border: 1px solid var(--border);
  background: #f1f5f9;
  padding: 8px 10px;
  border-radius: 10px;
}
#app-nav .nav.nav-drawer .nav-user #navLogout:hover{ background:#e2e8f0; }

/* Dropdowny (ponecháno pro kompatibilitu; v drawer režimu se chovají jako vnořené položky) */
#app-nav .nav .nav-item{
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .25rem;
}
#app-nav .nav .nav-caret{
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: .9em;
  padding: 2px 4px;
}
#app-nav .nav .dropdown-menu{
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  min-width: 220px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  box-shadow: 0 10px 20px rgba(0,0,0,.06);
  padding: 4px 0;
  display: none;
  z-index: 1200;
}
#app-nav .nav .dropdown-menu li{ list-style: none; }
#app-nav .nav .dropdown-menu .dropdown-item{
  display: block;
  padding: 8px 12px;
  text-decoration: none;
  color: #374151;
}
#app-nav .nav .dropdown-menu .dropdown-item:hover{ background: #eef2ff; }
#app-nav .nav .nav-item.open > .dropdown-menu{ display: block; }

/* Přístupnost: focus ring pro ovládací prvky v nav */
#app-nav .topbar-burger:focus-visible,
#app-nav .nav .nav-caret:focus-visible,
#app-nav .nav a:focus-visible{
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* -------------------------------------------------------------------------
   Desktop menu
   - na desktopu je menu vždy viditelné (bez nutnosti klikat na burger)
   - sekce se renderují jako dropdowny v topbaru (viz nav.enhance.js)
   ------------------------------------------------------------------------- */
@media (min-width: 981px){
  /* na desktopu nezalamujeme header – držíme brand + menu v jedné řadě */
  #app-nav.topbar{ flex-wrap: nowrap; }

  /* burger schovej (mobilní drawer není potřeba) */
  #app-nav .topbar-burger{ display: none; }

  /* navigace je vždy vidět */
  #app-nav .nav{ display: flex !important; width: auto; }
  #app-nav:not(.open) .nav{ display: flex !important; }

  /* vypni drawer "card" styling i když by někdo omylem přidal .open */
  #app-nav.open .nav{
    margin-top: 0;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }

  /* desktop layout pro menu */
  #app-nav .nav.nav-desktop{
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }

  /* skupiny (dropdown header) */
  #app-nav .nav.nav-desktop .nav-item.dropdown > a{
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 10px;
    color: #374151;
    text-decoration: none;
    font-weight: 600;
  }
  #app-nav .nav.nav-desktop .nav-item.dropdown > a:hover{ background: #eef2ff; color: #111827; }
  #app-nav .nav.nav-desktop .nav-item.dropdown > a.active{ background: #e0e7ff; color: #111827; }

  #app-nav .nav.nav-desktop .nav-caret{
    padding: 2px 6px;
    border-radius: 8px;
  }
  #app-nav .nav.nav-desktop .nav-caret:hover{ background: #eef2ff; }

  /* dropdown menu na desktopu */
  #app-nav .nav.nav-desktop .dropdown-menu{
    top: calc(100% + 6px);
  }

  /* user area posuň doprava */
  #app-nav .nav.nav-desktop .nav-user{
    margin-left: auto;
    border-top: 0;
    padding-top: 0;
    gap: 12px;
  }
  #app-nav .nav.nav-desktop .nav-user #navLogout{
    background: #f1f5f9;
  }
}
/* === ANCHOR: NAV_ENHANCE (END) === */

/* ALERT_STYLE_PATCH */
.table td.alert-note{ color:#a62; font-style:italic; max-width:24rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* === Mobile-first card lists (CRM, obhlídky, administrace) ================ */
.list-cards{ display:flex; flex-direction:column; gap:10px; }
.list-card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 8px 20px rgba(15,23,42,.06);
}
.list-card .lc-title{ font-weight: 700; }
.list-card .lc-meta{ color: var(--muted); font-size: 13px; margin-top: 4px; }
.list-card .lc-actions{ display:flex; flex-wrap:wrap; gap:8px; margin-top:10px; }

/* Hide mobile card lists by default (shown only on small screens) */
.crm-list,
.insp-list,
.admin-list,
.tpl-list,
.crm-pick-list{
  display: none;
}

@media (max-width: 900px){
  .panel-header{ flex-direction: column; align-items: stretch; gap: 10px; }
  .panel-header .actions{ width: 100%; }
  .actions{ flex-wrap: wrap; }
  .actions :is(input, select){ flex: 1 1 220px; min-width: 0; }

  /* CRM */
  #crmTableWrap{ display: none; }
  .crm-list{ display: flex; }

  /* Inspections report */
  #inspTableWrap{ display: none; }
  .insp-list{ display: flex; }

  /* CRM picker dialog */
  #crmPickTableWrap{ display: none; }
  .crm-pick-list{ display: flex; }

  /* Admin */
  #usersTableWrap,
  #customersTableWrap{
    display: none;
  }
  .admin-list{ display: flex; }

  /* Templates */
  #tplTableWrap{ display: none; }
  .tpl-list{ display: flex; }
}

/* === Global loading overlay ============================================= */
#loading-overlay{
  position: fixed; inset: 0; display: none;
  align-items: center; justify-content: center;
  background: rgba(255,255,255,.6);
  backdrop-filter: blur(2px);
  z-index: 10000;
}
#loading-overlay.show{ display: flex; }
#loading-overlay .spinner{
  width: 44px; height: 44px; border-radius: 50%;
  border: 4px solid var(--border); border-top-color: var(--primary);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Page drawer (filters/settings "ousko") ============================ */
:root{
  --page-drawer-width: 380px;
  --page-drawer-handle-w: 34px;
}

.page-drawer-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease;
  z-index: 1490;
}
.page-drawer-backdrop.show{
  opacity: 1;
  pointer-events: auto;
}

.page-drawer-handle{
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: var(--page-drawer-handle-w);
  height: 110px;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-direction: column;
  border: 1px solid var(--border);
  border-right: 0;
  border-radius: 14px 0 0 14px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  z-index: 1495;
}
.page-drawer-handle:hover{ background:#f8fafc; }
.page-drawer-handle:focus-visible{ outline:2px solid var(--primary); outline-offset:2px; }
.page-drawer-handle-icon{ font-size: 16px; line-height: 1; }
.page-drawer-handle-badge{
  display: inline-flex;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  background: #e0e7ff;
  color: #1e3a8a;
  border: 1px solid #c7d2fe;
}

.page-drawer{
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: var(--page-drawer-width);
  max-width: 92vw;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transform: translateX(102%);
  transition: transform .18s ease;
  z-index: 1500;
}
.page-drawer.open{ transform: translateX(0); }

.page-drawer-header{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 12px 10px 12px;
  border-bottom: 1px solid var(--border);
}
.page-drawer-title{ font-size: 14px; font-weight: 800; }
.page-drawer-subtitle{ margin-top: 3px; font-size: 12px; color: var(--muted); }
.page-drawer-actions{ display:flex; align-items:center; gap: 8px; }
.page-drawer-actions .btn{ padding: 6px 10px; border-radius: 10px; }
.page-drawer-actions .btn.active{ background:#e0e7ff; border-color:#c7d2fe; }

.page-drawer-body{
  padding: 12px;
  overflow: auto;
  flex: 1;
}
.page-drawer-footer{
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Drawer section helpers (reusable) */
.pd-section{ padding: 10px 10px; border: 1px solid var(--border); border-radius: 12px; background:#fff; }
.pd-section + .pd-section{ margin-top: 10px; }
.pd-section-title{ font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.pd-chk{ display:flex; align-items:center; gap:8px; margin: 6px 0; }
.pd-chk input{ width: 16px; height: 16px; }
.pd-row{ display:flex; gap:8px; flex-wrap: wrap; }
.pd-row .btn{ flex: 1 1 auto; }
.pd-field{ display:flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.pd-field > span{ font-size: 12px; color: var(--muted); }
.pd-field input{ padding: 10px 12px; border:1px solid var(--input-border); border-radius: 12px; background: var(--input-bg); }
.pd-hint{ margin-top: 8px; font-size: 12px; color: var(--muted); }

/* Pinned mode: make room for drawer (desktop only) */
body.page-drawer-pinned-open #app-view,
body.page-drawer-pinned-open main.layout.container{
  padding-right: calc(16px + var(--page-drawer-width));
}
@media (max-width: 1099px){
  body.page-drawer-pinned-open #app-view,
  body.page-drawer-pinned-open main.layout.container{ padding-right: 16px; }
}

/* === Quote Builder ===================================================== */
.qb-layout{ display: grid; grid-template-columns: 1fr; gap: 12px; }
.qb-sidebar{ border-right: 0; padding-right: 0; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.qb-section-list{ display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; max-height: 180px; overflow: auto; }
.qb-section{ display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: #fff; cursor: pointer; }
.qb-section.active{ background: #f5f7fb; border-color: #d7dbe6; }
.qb-section .meta{ font-size: 12px; opacity: .75; }
.qb-section-actions{ display: flex; gap: 6px; }
.qb-section-actions button{ padding: 4px 8px; }
.qb-table td input[type="number"],
.qb-table td input[type="text"],
.qb-table td select{ width: 100%; }
.qb-table td.actions{ white-space: nowrap; }


/* Quote builder: make item name readable and allow horizontal scroll */
#qbItemsTable{ min-width: 1280px; }
#qbItemsTable th:nth-child(2),
#qbItemsTable td:nth-child(2){ min-width: 320px; }
#qbItemsTable td{ vertical-align: top; }

/* Sortable column headers */
#qbItemsTable th[data-sort-key]{ user-select: none; }
#qbItemsTable th[data-sort-key]:hover{ background: #eef1f7; }
#qbItemsTable .sort-arrow{ font-size: 11px; margin-left: 2px; opacity: 0.3; }
#qbItemsTable .sort-arrow sup{ font-size: 9px; color: var(--primary, #1d4ed8); }

/* Column drag & drop */
#qbItemsTable th[draggable]{ cursor: grab; }
#qbItemsTable th.col-dragging{ opacity: 0.4; background: #dbeafe; }
#qbItemsTable th.col-drag-over{ border-left: 3px solid var(--primary, #1d4ed8); }

/* Right align numeric inputs in quote builder */
.qb-table td input[type="number"]{ text-align: right; }

/* Quote Builder: compact mode (toggle via PageDrawer) */
body.qb-compact #qbItemsTable th,
body.qb-compact #qbItemsTable td{
  padding: 6px 8px;
}
body.qb-compact .qb-section{ padding: 6px 8px; }
body.qb-compact .btn.btn-icon{ padding: 3px 7px; }

/* Kit origin tag */
.qb-kit-tag{
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid #ddd;
  border-radius: 999px;
  font-size: 12px;
  background: #f8f8f8;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Quote Builder: name cell (readable text + inline rename) */
.qb-item-name-row{ display:flex; align-items:flex-start; gap:8px; }
.qb-name-label{ font-weight:600; white-space:normal; word-break:break-word; }
.btn.btn-icon{ padding: 4px 8px; line-height: 1.1; }
.qb-name-edit{ width:100%; }
.qb-item-sub code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}

/* === Quote Template Editor ============================================= */
.qt-grid{ display: grid; grid-template-columns: 1fr; gap: 12px; }
.qt-sidebar{ border-right: 0; padding-right: 0; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.qt-section-list{ display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; max-height: 180px; overflow: auto; }
.qt-section{ display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: #fff; cursor: pointer; }
.qt-section.active{ background: #f5f7fb; border-color: #d7dbe6; }
.qt-section .meta{ font-size: 12px; opacity: .75; }
.qt-table td input[type="number"],
.qt-table td input[type="text"],
.qt-table td select{ width: 100%; }


/* ===== Voice dictation (Realtime STT) ===== */
.voice-status{ font-size:12px; color:#667085; align-self:center; }
.voice-status.on{ color:#b42318; font-weight:600; }
.btn-voice.is-recording{ border-color:#fda4af; }
.mic-btn{ margin:6px 0 8px; align-self:flex-end; font-size:12px; border:1px solid #d0d5dd; background:#fff; border-radius:999px; padding:4px 10px; cursor:pointer; }
.mic-btn:hover{ background:#f9fafb; }
.voice-target{ outline:2px solid rgba(37,99,235,.35); outline-offset:2px; }



/* ===== AI Drawer (right side panel in quote builder) ================== */
.qb-layout.has-ai-drawer{
  grid-template-columns: 1fr;
}
@media (min-width: 900px){
  .qb-layout.has-ai-drawer{
    grid-template-columns: auto 420px;
    grid-template-rows: auto 1fr;
  }
  .qb-layout.has-ai-drawer > .qb-sidebar{
    grid-column: 1 / -1;
  }
  .qb-layout.has-ai-drawer > .qb-main{
    grid-column: 1;
    min-width: 0;
    overflow-x: auto;
  }
  .qb-layout.has-ai-drawer > .qb-ai-drawer{
    grid-column: 2;
    grid-row: 2;
  }
}
.qb-ai-drawer{
  border-left: 1px solid var(--border);
  background: #fafbfc;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  min-height: 400px;
  position: sticky;
  top: 80px;
}
.qb-ai-drawer-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.qb-ai-drawer-messages{
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.qb-ai-drawer-messages:empty::before{
  content: 'Napiš zprávu a AI agent ti pomůže s nabídkou.';
  color: #98a2b3;
  font-size: 13px;
  text-align: center;
  margin-top: 40px;
}
.qb-drawer-msg{
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 95%;
}
.qb-drawer-msg.user{
  background: #e0edff;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}
.qb-drawer-msg.assistant{
  background: #fff;
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}
.qb-ai-drawer-input{
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: #fff;
}
.qb-ai-drawer-input textarea{
  width: 100%;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  margin-bottom: 6px;
}
.qb-drawer-actions{
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(0,0,0,.08);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.qb-drawer-actions span{
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  background: #f0f4f8;
  color: #475569;
  white-space: nowrap;
}
/* Thinking steps bubble */
.qb-drawer-thinking{
  background: #f8fafc !important;
  border: 1px dashed #cbd5e1 !important;
  padding: 10px 14px !important;
}
.qb-drawer-step{
  font-size: 13px;
  padding: 4px 0;
  color: #94a3b8;
}
.qb-drawer-step.done{
  color: #16a34a;
}
.qb-drawer-step.active{
  color: #1d4ed8;
  font-weight: 600;
}
.qb-drawer-step.active::before{
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid #1d4ed8;
  border-top-color: transparent;
  border-radius: 50%;
  animation: drawerSpin 0.7s linear infinite;
  margin-right: 6px;
  vertical-align: middle;
}
@keyframes drawerSpin{
  to{ transform: rotate(360deg); }
}

/* ===== AI tvorba nabídky (chat) ======================================= */

/* AI dialog is structured: header + body + footer */
.ai-chat-modal.dialog-structured{ --dialog-width: var(--dialog-2xl); }

/* Header controls */
.ai-chat-header-right{
  display:flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  text-align: right;
}
.ai-chat-header-actions{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.ai-chat-toggle{ display:flex; align-items:center; gap:6px; font-size:12px; margin:0; }
.ai-chat-status{ font-size:12px; white-space:nowrap; }

/* Body layout
   - desktop: internal scrolling happens in the two columns
   - mobile: body scroll is enabled (stacked layout)
*/
.ai-chat-body{ overflow: hidden; }

.ai-chat-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;

  height: 100%;
  min-height: 0;

  /* Keep a single row that can shrink (enables nested overflow:auto) */
  grid-template-rows: minmax(0, 1fr);
  align-content: stretch;
}
@media (max-width: 1100px){
  .ai-chat-body{ overflow: auto; }
  .ai-chat-grid{
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    height: auto;
  }
}

.ai-chat-col{ min-height: 0; }

/* Left: chat pane */
.ai-chat-pane{
  display:flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.ai-chat-pane-header{ display:flex; justify-content:space-between; gap:10px; align-items:center; flex-wrap:wrap; }
.ai-chat-tip{ font-size:12px; margin-top:6px; }
.ai-chat-transcript{
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  margin-top: 10px;
  padding: 10px;
}
.ai-chat-input-wrap{ display:block; margin-top: 10px; }
.ai-chat-input-label{ font-size:12px; margin-bottom: 6px; }
#qbAiChatInput{ width: 100%; resize: vertical; }
.ai-chat-pane-footer{ display:flex; justify-content:flex-end; gap:8px; margin-top: 10px; }

/* Chat messages (no inline styles in JS) */
.ai-chat-msg{
  margin: 6px 0;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.ai-chat-msg.ai{ background: #f6f8ff; border-color: #dde3ff; }
.ai-chat-msg.user{ background: #f8fafc; border-color: #e2e8f0; }
.ai-chat-msg-role{ font-size:12px; margin-bottom:4px; }
.ai-chat-pre{ white-space: pre-wrap; }

/* Right: results */
.ai-chat-right{
  height: 100%;
  overflow: auto;
  padding-right: 2px;
}
@media (max-width: 1100px){
  .ai-chat-right{ height:auto; overflow: visible; padding-right: 0; }
}

.ai-chat-empty{
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: #fff;
}

.ai-chat-stack{
  display:flex;
  flex-direction: column;
  gap: 12px;
}
/* hidden until aiChatRenderAi() */
#qbAiChatAiCard{ display: none; }

.ai-chat-card-head{ display:flex; justify-content:space-between; gap:10px; align-items:center; flex-wrap:wrap; }
.ai-chat-card-actions{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; justify-content:flex-end; }
.ai-chat-help{ font-size:12px; margin-top:6px; }
.ai-chat-block{ margin-top: 10px; }

/* Action cards (quick actions based on AI output) */
.ai-action-cards{
  display:flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}
.ai-action-card{
  display:flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fafafa;
}
.ai-action-title{ font-weight: 800; }
.ai-action-desc{ font-size: 12px; margin-top: 4px; }
.ai-action-buttons{ display:flex; gap: 8px; flex-wrap: wrap; align-items:center; justify-content:flex-end; }


/* Tabs */
.ai-chat-tabs{ gap: 6px; }
.ai-chat-tab-panels{ margin-top: 10px; }
.ai-chat-tab-panel{ display:none; }
.ai-chat-tab-panel[data-ai-tab-panel="items"]{ display:block; }
.ai-chat-tab-btn.active{
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px var(--focus);
}

/* Apply section */
.ai-chat-subsection{
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.ai-chat-card > .ai-chat-subsection:first-of-type{
  margin-top: 10px;
  padding-top: 0;
  border-top: 0;
}
.ai-chat-subtitle{ font-size:12px; margin-bottom:6px; }
.ai-chat-apply-row{ display:flex; gap:10px; align-items:flex-end; flex-wrap:wrap; }
.ai-chat-field{ display:flex; flex-direction:column; gap:6px; font-size:12px; }
.ai-chat-field > span{ color: var(--muted); font-size:12px; }
#qbAiChatApplySectionSelect{ min-width: 220px; }
.ai-chat-check{ display:flex; align-items:center; gap:6px; font-size:12px; margin:0 0 4px 0; }
.ai-chat-apply-actions{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.ai-chat-variants-help{ font-size:12px; margin-top: 8px; }

.ai-chat-subsection-split{ display:flex; justify-content:space-between; gap:10px; align-items:flex-start; flex-wrap:wrap; }
.ai-chat-subsection-actions{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; justify-content:flex-end; }

/* Notes select sizing (removes inline min-width from JS) */
select.ai-note-eid{ min-width: 260px; }
@media (max-width: 700px){
  select.ai-note-eid{ min-width: 0; width: 100%; }
}

/* Questions UI */
.ai-q-item{
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-top: 10px;
  background: #fff;
}
.ai-q-text{ font-weight: 800; }
.ai-q-answer{ width: 100%; margin-top: 8px; }

/* Log */
#qbAiChatLog{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  padding: 10px;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
}
.ai-log-line{ display:flex; gap:8px; align-items:baseline; margin: 0 0 6px 0; }
.ai-log-ts{ color: var(--muted); min-width: 70px; }
.ai-log-type{ min-width: 64px; font-weight: 800; }
.ai-log-type.err{ color: var(--danger); }
.ai-log-type.ok{ color: var(--accent); }

/* Advanced (details) */
.ai-chat-advanced{
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  padding: 10px 12px;
}
.ai-chat-advanced summary{ cursor: pointer; }
.ai-chat-advanced > :not(summary){ margin-top: 10px; }
.ai-chat-advanced-sub{ margin-top: 10px; }
.ai-chat-advanced-sub summary{ cursor: pointer; }
.ai-chat-advanced-sub > :not(summary){ margin-top: 8px; }
.ai-chat-meta{ margin-top: 10px; font-size: 12px; }
.ai-chat-advanced-block{ margin-top: 10px; }
.ai-chat-advanced-sub .table-wrap{ margin-top: 8px; }

/* Fullscreen toggle (JS adds .ai-chat-fullscreen on the modal form) */
.ai-chat-modal.ai-chat-fullscreen{
  width: 98vw !important;
  max-width: none !important;
  height: 94vh;
  max-height: 94vh;
}

/* In fullscreen (desktop), keep internal scroll (left transcript, right column) */
.ai-chat-modal.ai-chat-fullscreen .ai-chat-body{ overflow: hidden; }

/* In fullscreen (mobile/stacked), allow body scroll */
@media (max-width: 1100px){
  .ai-chat-modal.ai-chat-fullscreen .ai-chat-body{ overflow: auto; }
}

/* Bigger input toggle (JS adds .ai-chat-big-input on the modal form) */
.ai-chat-modal.ai-chat-big-input #qbAiChatInput{ min-height: 220px; }


/* === Quote Request (MPA) compact view ================================ */
body.rq-compact .table th,
body.rq-compact .table td{
  padding: 6px 8px;
}
body.rq-compact .rq-table-actions .btn{
  padding: 4px 8px;
}
body.rq-compact .rq-kv .kv{
  padding: 8px;
}

/* Quote Request docs: small AI status line */
.rq-doc-ai{
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}
.rq-doc-ai .ok{ color: #166534; }
.rq-doc-ai .warn{ color: #92400e; }
.rq-doc-ai .err{ color: #991b1b; }

/* === Quote Requests (Kanban) compact view ============================= */
body.qr-compact .qr-card{
  padding: 8px;
}
body.qr-compact .qr-card .meta{
  font-size: 11px;
}
body.qr-compact .qr-col{
  min-width: 260px;
  flex: 0 0 280px;
}

/* ── Currency badges ── */
.badge-fx{
  display:inline-block;
  font-size:10px;
  padding:1px 4px;
  border-radius:3px;
  background:var(--c-accent-bg, #e8f4fd);
  color:var(--c-accent, #1976d2);
  margin-left:4px;
  vertical-align:middle;
  cursor:help;
  font-weight:600;
  letter-spacing:.3px;
}
.badge-fx-manual{
  background:#fff3e0;
  color:#e65100;
}
.badge-fx-refresh{
  background:#e8f5e9;
  color:#2e7d32;
}

/* ── Quote Params Dialog Redesign ── */
.qp-card{
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.qp-card:last-child{ margin-bottom: 0; }
.qp-card-header{
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
}
.qp-card-icon{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  font-size: 15px;
  flex-shrink: 0;
}
.qp-card-icon.base{ background: #dbeafe; }
.qp-card-icon.distances{ background: #fef3c7; }
.qp-card-icon.battery{ background: #d1fae5; }
.qp-card-icon.transport{ background: #fce7f3; }
.qp-card-icon.hardware{ background: #e0e7ff; }
.qp-card-icon.option_fire{ background: #fee2e2; }
.qp-card-icon.roof{ background: #ccfbf1; }
.qp-card-icon.other{ background: #f1f5f9; }

.qp-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
}
@media(max-width:600px){
  .qp-grid{ grid-template-columns: 1fr; }
}
.qp-field{
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.qp-field label{
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}
.qp-field input[type="number"]{
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--input-bg);
  transition: border-color .15s, box-shadow .15s;
}
.qp-field input[type="number"]:focus{
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus);
}
.qp-field input[type="number"].qp-readonly{
  background: #f1f5f9;
  color: var(--muted);
  cursor: not-allowed;
}
.qp-field input[type="number"].qp-required{
  border-color: var(--primary);
}
.qp-field input[type="number"].qp-required:invalid,
.qp-field input[type="number"].qp-required-empty{
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(220,38,38,.12);
}
.qp-help{
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
  margin-top: 1px;
}

.qp-badge{
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .2px;
  line-height: 16px;
  white-space: nowrap;
  vertical-align: middle;
}
.qp-badge-template{ background: #dbeafe; color: #1e40af; }
.qp-badge-manual{ background: #fef3c7; color: #92400e; }
.qp-badge-calc{ background: #d1fae5; color: #065f46; }
.qp-badge-default{ background: #f1f5f9; color: #64748b; }

.qp-required-star{
  color: var(--danger);
  font-weight: 700;
  font-size: 13px;
}

/* Roof calc section */
.qp-roof-section{
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.qp-roof-summary{
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 8px;
  font-size: 12px;
}
.qp-roof-summary .stat{
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.qp-roof-summary .stat .val{
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
}
.qp-roof-summary .stat .lbl{
  color: var(--muted);
  font-size: 11px;
}
.qp-roof-form{
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #99f6e4;
}
.qp-roof-form .seg-row{
  display: grid;
  grid-template-columns: 1fr 160px 80px 80px 36px;
  gap: 6px;
  align-items: end;
  margin-bottom: 6px;
}
@media(max-width:700px){
  .qp-roof-form .seg-row{
    grid-template-columns: 1fr 1fr;
  }
}
.qp-roof-form label{
  font-size: 11px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.qp-roof-form input,
.qp-roof-form select{
  padding: 5px 6px;
  border: 1px solid var(--input-border);
  border-radius: 5px;
  font-size: 12px;
}
.qp-roof-form .btn-xs{
  padding: 4px 6px;
  font-size: 12px;
  min-width: auto;
}

/* Recalc kits section in params dialog */
.qp-recalc-section{
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.qp-recalc-header{
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.qp-recalc-header strong{ font-size: 13px; }
.qp-recalc-list{
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.qp-recalc-list label{
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
