* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', sans-serif;
  background: #f1f5f9;
  color: #1e293b;
}
.hidden { display: none !important; }

/* Login */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: #0f172a url('background.jpg') center center / cover no-repeat;
  padding: 20px;
}
.login-box { background: rgba(255,255,255,.96); padding: 40px; border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,.25); width: 320px; text-align: center; }
.login-box-intro { width: 420px; max-width: 90vw; }
.login-box h1 { margin-top: 0; }
.intro-box { margin-top: 20px; padding-top: 16px; border-top: 1px solid #e2e8f0; }
.intro-text { color: #475569; font-size: 13.5px; line-height: 1.55; text-align: left; margin: 0; }
.login-box input { width: 100%; padding: 10px; margin: 12px 0; border: 1px solid #cbd5e1; border-radius: 6px; }
.login-box button { width: 100%; padding: 10px; background: #1a56db; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; }
.hint { color: #64748b; font-size: 13px; }
.error { color: #dc2626; font-size: 13px; }
.login-box-wide { width: 380px; text-align: left; }
.login-box-wide label { display: block; font-size: 12.5px; color: #475569; margin: 10px 0 0; }
.login-box-wide input { margin: 4px 0 0; }
.login-box-wide button { margin-top: 16px; }
.suspended-box { background: #fff7ed; border: 1px solid #fed7aa; border-radius: 8px; padding: 12px; margin-top: 10px; text-align: left; }
.suspended-box p { margin: 0 0 8px; font-size: 13px; color: #7c2d12; }
.suspended-box .modal-actions { margin-top: 0; }

/* Topbar */
.topbar { display: flex; align-items: center; gap: 24px; background: #1e293b; color: #fff; padding: 12px 24px; }
.topbar h1 { font-size: 18px; margin: 0; margin-right: auto; }
.topbar nav { display: flex; gap: 8px; }
.tab-btn { background: none; border: none; color: #cbd5e1; padding: 8px 14px; border-radius: 6px; cursor: pointer; font-size: 14px; position: relative; }
.tab-btn.active, .tab-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.badge-count {
  display: inline-block; background: #dc2626; color: #fff; font-size: 10.5px; font-weight: 700;
  border-radius: 20px; padding: 1px 6px; margin-left: 6px; vertical-align: middle;
}
.btn-ghost { background: none; border: 1px solid rgba(255,255,255,.3); color: #fff; padding: 6px 12px; border-radius: 6px; cursor: pointer; }

.tab-panel { display: none; padding: 24px; }
.tab-panel.active { display: block; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.filters input, .filters select { padding: 9px 10px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 14px; }
.filters input[type="text"] { flex: 1 1 260px; }
.filters input[type="number"] { width: 150px; }
.autocomplete-wrap { position: relative; flex: 1 1 220px; }
.autocomplete-wrap input { width: 100%; }
.suggest-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 20; margin-top: 2px;
  background: #fff; border: 1px solid #cbd5e1; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,.1);
  max-height: 220px; overflow-y: auto;
}
.suggest-item { padding: 8px 10px; font-size: 13px; cursor: pointer; }
.suggest-item:hover { background: #f1f5f9; }
tr.highlight-row td { background: #fef9c3 !important; transition: background .3s; }
#searchBtn { background: #1a56db; color: #fff; border: none; padding: 9px 20px; border-radius: 6px; cursor: pointer; font-weight: 600; }
.note { color: #64748b; font-size: 12.5px; margin: 4px 0 16px; }
.status { font-size: 14px; color: #475569; margin-bottom: 8px; }
.errors { color: #b45309; font-size: 13px; margin-bottom: 8px; }

.filters-secondary { align-items: center; margin-top: -2px; }
.filters-label { font-size: 12.5px; color: #64748b; font-weight: 600; }
#fResultsFulltext { margin-left: auto; padding: 6px 10px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 13px; width: 240px; }
.chk { display: flex; align-items: center; gap: 5px; font-size: 13px; color: #334155; cursor: pointer; }
.chk select { padding: 4px 6px; font-size: 12.5px; }
#loadMoreSentinel { height: 1px; }
#loadMoreServerBtn { display: block; width: 100%; margin: 14px 0; padding: 10px; font-size: 14px; }
#loadMoreServerBtn:disabled { opacity: .6; cursor: default; }

/* Result list */
.cards { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: #fff; border-radius: 10px; padding: 14px 16px; box-shadow: 0 1px 4px rgba(0,0,0,.06);
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.card-main { flex: 1 1 320px; min-width: 0; }
.card h3 { margin: 0 0 4px; font-size: 15.5px; overflow-wrap: break-word; }
.card-title-link { cursor: pointer; }
.card-title-link:hover { text-decoration: underline; color: #1a56db; }
.card .meta { font-size: 13px; color: #475569; margin-bottom: 6px; }
.card .badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { background: #e2e8f0; color: #334155; font-size: 11.5px; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.badge.source { background: #dbeafe; color: #1d4ed8; }
.card-actions { display: flex; gap: 8px; flex-shrink: 0; margin-left: auto; }
.card-actions a, .card-actions button { font-size: 13px; padding: 8px 12px; border-radius: 6px; border: none; cursor: pointer; text-decoration: none; white-space: nowrap; }
.card-actions a { background: #f1f5f9; color: #1e293b; border: 1px solid #cbd5e1; }
.card-actions button { background: #16a34a; color: #fff; }
.card-actions button.btn-in-catalog { background: #64748b; }
.card-actions button.btn-dismiss { background: #fff; color: #b91c1c; border: 1px solid #fecaca; }
.card-actions button.btn-undismiss { background: #fff; color: #1a56db; border: 1px solid #bfdbfe; }
.card.card-dismissed { opacity: .6; }
.uncertain-heading { margin: 24px 0 4px; font-size: 16px; color: #475569; }
.badge.status-badge { font-weight: 600; }
.badge.status-evidence { background: #e2e8f0; color: #334155; }
.badge.status-odeslano { background: #dbeafe; color: #1d4ed8; }
.badge.status-pohovor { background: #fef3c7; color: #92400e; }
.badge.status-nabidka { background: #dcfce7; color: #166534; }
.badge.status-zamitnuto, .badge.status-odmitnuto_mnou { background: #fee2e2; color: #991b1b; }
.badge.status-archiv { background: #f1f5f9; color: #64748b; }

/* Catalog */
.catalog-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
#addManualBtn { background: #1a56db; color: #fff; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; }
#catalogFulltext { flex: 1 1 260px; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 13px; }
.stats { color: #64748b; font-size: 13px; margin-left: auto; }
tr.filter-row th { padding: 4px 6px; background: #f8fafc; }
tr.filter-row input, tr.filter-row select { width: 100%; padding: 4px 6px; font-size: 12px; border: 1px solid #cbd5e1; border-radius: 4px; }
.table-wrap { overflow-x: auto; background: #fff; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid #e2e8f0; text-align: left; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
th { background: #f8fafc; font-size: 11px; text-transform: uppercase; color: #64748b; }
tr:hover td { background: #f8fafc; }
td.notes-cell { white-space: normal; max-width: 260px; }
select.status-select { font-size: 12px; padding: 4px; border-radius: 5px; border: 1px solid #cbd5e1; }
.status-evidence { background: #e2e8f0; }
.status-odeslano { background: #dbeafe; }
.status-pohovor { background: #fef3c7; }
.status-nabidka { background: #dcfce7; }
.status-zamitnuto, .status-odmitnuto_mnou { background: #fee2e2; }
.status-archiv { background: #f1f5f9; }
/* Přepis obecného "td { white-space: nowrap; overflow: hidden; text-overflow:
   ellipsis }" pro sloupec akcí - na užších než FHD obrazovkách se tlačítka
   (Upravit/Poslat žádost/Smazat...) nesmí ořezávat na "...", ale mají se
   zalamovat pod sebe/vedle sebe. */
td.row-actions {
  white-space: normal; max-width: none; overflow: visible; text-overflow: clip;
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
}
.row-actions button { font-size: 12px; padding: 4px 8px; border-radius: 5px; border: 1px solid #cbd5e1; background: #fff; cursor: pointer; margin-right: 4px; }
.row-actions .send-btn { background: #16a34a; color: #fff; border: none; }
.row-actions .del-btn { color: #dc2626; }

/* Přehledy (statistiky) */
.stats-tiles { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 20px; }
.stat-tile {
  flex: 1 1 160px; background: #fff; border-radius: 10px; padding: 16px 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06); display: flex; flex-direction: column; gap: 4px;
}
.stat-tile-value { font-size: 26px; font-weight: 700; color: #1e293b; }
.stat-tile-label { font-size: 12px; color: #64748b; }

.stats-grid { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.stats-box { background: #fff; padding: 22px; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.06); flex: 1 1 360px; min-width: 280px; }
.stats-box-wide { flex: 2 1 520px; }
.stats-box h2 { font-size: 15px; margin: 0 0 4px; }

.bar-chart { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-label { flex: 0 0 110px; font-size: 12.5px; color: #475569; }
.bar-track { flex: 1 1 auto; background: #f1f5f9; border-radius: 4px; height: 16px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; transition: width .3s; }
.bar-value { flex: 0 0 28px; text-align: right; font-size: 12.5px; font-weight: 600; color: #334155; }

.funnel-chart { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.funnel-row { display: flex; align-items: center; gap: 10px; }
.funnel-label { flex: 0 0 90px; font-size: 12.5px; color: #475569; }
.funnel-track { flex: 1 1 auto; background: #f1f5f9; border-radius: 4px; overflow: hidden; }
.funnel-fill {
  height: 24px; border-radius: 4px; color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: flex-end; padding-right: 8px;
  min-width: 24px; transition: width .3s;
}

#waitingTable tr.waiting-warning td { background: #fffbeb; }
#waitingTable tr.waiting-critical td { background: #fef2f2; }

/* Messages */
.messages-list { display: flex; flex-direction: column; gap: 6px; }
.msg-row {
  display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 8px;
  padding: 10px 14px; box-shadow: 0 1px 4px rgba(0,0,0,.06); cursor: pointer; font-size: 13.5px;
}
.msg-row:hover { background: #f8fafc; }
.msg-row.msg-status-unread { font-weight: 600; }
.msg-star { cursor: pointer; color: #eab308; flex: 0 0 auto; }
.msg-star.starred { color: #ca8a04; }
.msg-from { flex: 0 0 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-preview { flex: 1 1 auto; color: #475569; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.msg-date { flex: 0 0 auto; color: #94a3b8; font-size: 12px; font-weight: 400; }
#msgDetailBody, #msgDetailReply { background: #f8fafc; }

/* Settings */
.settings-grid { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.settings-box {
  background: #fff; padding: 24px; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.06);
  flex: 1 1 300px; min-width: 280px; max-width: 100%;
}
.settings-box-wide { flex: 2 1 460px; }
.settings-box h2 { font-size: 16px; margin-top: 0; margin-bottom: 4px; padding-bottom: 10px; border-bottom: 1px solid #e2e8f0; }
.settings-box label { display: block; font-size: 12.5px; color: #475569; margin: 10px 0 0; }
.settings-box input { width: 100%; padding: 9px; margin: 4px 0 0; border: 1px solid #cbd5e1; border-radius: 6px; }
.settings-box textarea {
  width: 100%; margin: 4px 0 0; border: 1px solid #cbd5e1; border-radius: 6px; padding: 9px;
  font-family: inherit; font-size: 13.5px; resize: vertical; min-height: 44px;
}
.settings-box .ta-notes { min-height: 90px; }
.settings-box .ta-message { min-height: 130px; }
.settings-box button { background: #1a56db; color: #fff; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; margin-top: 14px; }
.msg { font-size: 13px; color: #16a34a; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-box { background: #fff; border-radius: 10px; padding: 24px; width: 480px; max-height: 90vh; overflow-y: auto; }
.modal-box h2 { margin-top: 0; }
.modal-box label { display: block; font-size: 12.5px; color: #475569; margin-bottom: 10px; }
.modal-box input, .modal-box select, .modal-box textarea { width: 100%; padding: 8px; margin-top: 4px; border: 1px solid #cbd5e1; border-radius: 6px; font-family: inherit; font-size: 13.5px; }
.modal-actions { display: flex; gap: 10px; margin-top: 12px; }
.modal-actions button { padding: 8px 18px; border-radius: 6px; border: none; cursor: pointer; }
#saveEditBtn { background: #1a56db; color: #fff; }
.btn-cancel { background: #f1f5f9; color: #1e293b; border: 1px solid #cbd5e1; }

/* ── Split-view (detail nabídky vedle výsledků, jen nad 800px) ─── */
.split-container { display: flex; align-items: flex-start; width: 100%; }
.split-left { flex: 1 1 auto; min-width: 0; width: 100%; }
.split-divider {
  flex: 0 0 6px; align-self: stretch; background: #e2e8f0; cursor: col-resize;
  border-radius: 3px; margin: 0 6px;
}
.split-divider:hover { background: #cbd5e1; }
.split-right {
  flex: 0 0 420px; min-width: 280px; max-width: 70vw; align-self: stretch;
  display: flex; flex-direction: column; background: #fff; border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06); padding: 12px; position: sticky; top: 12px;
  /* i když má levý sloupec (výsledky) jen pár položek, panel s detailem musí
     zůstat na celou výšku okna - "align-self: stretch" samo o sobě stretchuje
     jen na výšku nejvyššího souseda ve flex řádku, ne na výšku okna. */
  min-height: calc(100vh - 24px);
  max-height: calc(100vh - 24px);
}
.split-right-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.split-right-header span { font-weight: 600; font-size: 13.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.split-right-header a, .split-right-header button { font-size: 12.5px; padding: 6px 10px; border-radius: 6px; cursor: pointer; text-decoration: none; }
.split-detail-content {
  flex: 1; width: 100%; border: 1px solid #e2e8f0; border-radius: 6px; min-height: 400px;
  padding: 14px 16px; overflow-y: auto; font-size: 13.5px; line-height: 1.55;
}
.split-detail-content p { margin: 0 0 10px; }
.split-detail-content ul { margin: 0 0 10px; padding-left: 20px; }
.split-detail-content li { margin-bottom: 4px; }
.split-detail-content h1, .split-detail-content h2, .split-detail-content h3, .split-detail-content h4 { margin: 14px 0 8px; font-size: 14.5px; }
.split-detail-content .loading, .split-detail-content .error { color: #64748b; font-style: italic; }
#splitDetailFrame { flex: 1; width: 100%; border: 1px solid #e2e8f0; border-radius: 6px; min-height: 400px; }
.link-btn { background: none; border: none; padding: 0; color: #1a56db; text-decoration: underline; cursor: pointer; font-size: inherit; }
.card.card-active { outline: 2px solid #1a56db; }

@media (max-width: 800px) {
  .split-right, .split-divider { display: none !important; }
}

/* ── Mobile ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .topbar h1 { flex: 1 1 100%; margin-right: 0; }
  .topbar nav { flex: 1 1 auto; flex-wrap: wrap; }
  .tab-btn { padding: 7px 10px; font-size: 13px; }

  .tab-panel { padding: 14px; }

  .filters { flex-direction: column; }
  .filters input:not([type="checkbox"]), .filters select, #searchBtn { width: 100%; flex: none; }
  .filters input[type="checkbox"] { width: auto; flex: none; }
  .filters input[type="text"], .filters input[type="number"] { width: 100%; flex: none; }
  .autocomplete-wrap { width: 100%; flex: none; }
  .filters-secondary { flex-direction: column; align-items: flex-start; flex-wrap: nowrap; gap: 10px; }
  .filters-secondary .chk { width: 100%; flex: none; white-space: normal; }
  .filters-secondary .chk select { margin-left: auto; }
  #fResultsFulltext { width: 100%; margin-left: 0; flex: none; }

  .card { flex-direction: column; align-items: stretch; padding: 12px 14px; }
  .card-main { flex: none; width: 100%; }
  .card-actions { margin-left: 0; width: 100%; }
  .card-actions a, .card-actions button { flex: 1; text-align: center; }

  .catalog-toolbar { flex-wrap: wrap; }
  #catalogFulltext { flex: 1 1 100%; margin-left: 0; }
  .stats { margin-left: 0; }

  /* Evidence jako karty (stejný princip jako výsledky vyhledávání) - klasická
     technika "responsive table": tabulka se rozloží na bloky, buňky dostanou
     popisek z data-label a řádek/karta se táhne přes celou šířku. */
  #catalogTable thead { display: none; }
  /* per-sloupcové filtry se na mobilu nahrazují jedním fulltextem výše, ať se
     před každou kartou nezobrazuje 12 vstupních polí */
  #catalogFilterRow { display: none; }
  #catalogTable, #catalogTable tbody, #catalogTable tr, #catalogTable td { display: block; width: 100%; }
  #catalogTable tr {
            background: #fff;
        border-radius: 10px;
        box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
        margin-bottom: 10px;
        padding: 10px 14px;
        box-shadow: -1px -1px 10px inset #005F00;
  }
  #catalogTable td {
    border: none; padding: 6px 0; white-space: normal; max-width: none;
    display: flex; gap: 8px; align-items: flex-start;
  }
  #catalogTable td::before {
    content: attr(data-label); flex: 0 0 100px; font-size: 11px; font-weight: 600;
    text-transform: uppercase; color: #64748b;
  }
  #catalogTable td:empty::before { content: none; }
  #catalogTable td.row-actions { flex-direction: column; }
  #catalogTable td.row-actions::before { flex: none; margin-bottom: 4px; }
  #catalogTable .row-actions button { width: 100%; margin: 2px 0 0; }

  /* settings-grid je flex-wrap řádkový (ne column), ale explicitní
     "flex: none; width: 100%" drží stejnou konvenci jako zbytek appky a
     zaručí jeden sloupec i kdyby .settings-box-wide basis (2 1 460px)
     na úzké obrazovce jinak nechtěně vytvořil dva sloupce vedle sebe. */
  .settings-grid { gap: 14px; }
  .settings-box, .settings-box-wide { flex: none; width: 100%; padding: 18px; }

  .modal-box { width: 92vw; padding: 18px; }

  .login-box-wide { width: 100%; }

  /* Zprávy: stejná past jako u karet výsledků/evidence - řádek "msg-row" je
     na desktopu vodorovný flex; v mobilní sloupcové verzi musí každý sloupec
     dostat "flex: none; width: 100%", jinak by se procentuální/pevné šířky
     přepočítaly na výšku. */
  .msg-row { flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px 14px; }
  .msg-star { flex: none; width: auto; }
  .msg-from { flex: none; width: 100%; white-space: normal; }
  .msg-preview { flex: none; width: 100%; white-space: normal; }
  .msg-date { flex: none; width: 100%; }

  /* Administrace uživatelů - stejná "responsive table" technika jako Evidence. */
  #usersTable thead { display: none; }
  #usersTable, #usersTable tbody, #usersTable tr, #usersTable td { display: block; width: 100%; }
  #usersTable tr { background: #fff; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.06); margin-bottom: 10px; padding: 10px 14px; }
  #usersTable td { border: none; padding: 6px 0; white-space: normal; max-width: none; display: flex; gap: 8px; align-items: flex-start; }
  #usersTable td::before { content: attr(data-label); flex: 0 0 100px; font-size: 11px; font-weight: 600; text-transform: uppercase; color: #64748b; }
  #usersTable td.row-actions { flex-direction: column; }
  #usersTable td.row-actions::before { flex: none; margin-bottom: 4px; }
  #usersTable .row-actions button { width: 100%; margin: 2px 0 0; }

  .catalog-toolbar select { flex: none; width: 100%; }

  /* Přehledy: stejná "flex: none; width: 100%" past jako všude jinde v appce
     - stat-tile/stats-box jsou na desktopu flex-wrap řádkové karty, na mobilu
     musí jít každá na vlastní řádek. Popisek u bar/funnel řádku (pevná šířka
     110px/90px na desktopu) je na úzkém displeji moc těsný, takže se na
     mobilu přepíná z vodorovného řádku na svislé skládání (label nad barem). */
  .stat-tile { flex: none; width: 100%; }
  .stats-box, .stats-box-wide { flex: none; width: 100%; padding: 16px; }
  .bar-row, .funnel-row { flex-direction: column; align-items: stretch; gap: 4px; }
  .bar-label, .funnel-label { flex: none; width: auto; }
  .bar-value { align-self: flex-end; }

  #waitingTable thead { display: none; }
  #waitingTable, #waitingTable tbody, #waitingTable tr, #waitingTable td { display: block; width: 100%; }
  #waitingTable tr { background: #fff; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.06); margin-bottom: 10px; padding: 10px 14px; }
  #waitingTable tr.waiting-warning, #waitingTable tr.waiting-critical { background: transparent; }
  #waitingTable tr.waiting-warning td { background: #fffbeb; }
  #waitingTable tr.waiting-critical td { background: #fef2f2; }
  #waitingTable td { border: none; padding: 6px 0; white-space: normal; max-width: none; display: flex; gap: 8px; align-items: flex-start; }
  #waitingTable td::before { content: attr(data-label); flex: 0 0 100px; font-size: 11px; font-weight: 600; text-transform: uppercase; color: #64748b; }
}
