/* ===========================================================================
   BAREVNÉ PROMĚNNÉ – pojmenované podle ÚČELU (ne podle odstínu), ať se ladí
   snadno. Definované zvlášť pro tmavý a světlý režim. Přepínání řídí atribut
   data-theme na <html>:
     <html data-theme="dark">  nebo  <html data-theme="light">
   Když atribut chybí, použije se tmavý (výchozí) z :root.
   =========================================================================== */
:root,
:root[data-theme="dark"] {
  /* Plochy */
  --color-page-bg:        #0f1419;  /* pozadí celé stránky */
  --color-surface:        #1a212b;  /* panely, karty, topbar */
  --color-surface-raised: #232c38;  /* zvýrazněná plocha (toast, pill, sekundární tlačítko) */
  --color-input-bg:       #0f1419;  /* pozadí vstupních polí */
  --color-border:         #2e3a48;  /* linky, rámečky, oddělovače */

  /* Text */
  --color-text:           #d6dde6;  /* hlavní text */
  --color-text-muted:     #8a97a6;  /* sekundární / tlumený text */
  --color-text-on-accent: #06231f;  /* text na akcentovém tlačítku */
  --color-text-on-danger: #2a0a0a;  /* text na nebezpečném tlačítku */

  /* Významové akcenty */
  --color-accent:         #4fd1c5;  /* primární akcent (odkazy, hodnoty, info) */
  --color-accent-warm:    #f6ad55;  /* teplý akcent (token, pozvánka) */
  --color-danger:         #fc8181;  /* mazání, chyby */
  --color-success:        #48bb78;  /* souhlas, potvrzení */
  --color-text-on-success:#06231f;
  --color-toast-error-text: #ffd9d9; /* text v chybovém toastu */

  /* Stíny a překryv modálu */
  --color-overlay:        rgba(5, 8, 12, .68);
  --shadow-toast:         0 8px 28px rgba(0, 0, 0, .45);
  --shadow-modal:         0 18px 50px rgba(0, 0, 0, .55);

  /* Datagrid */
  --color-grid-header:    #1f2935;  /* pozadí hlavičky tabulky */
  --color-grid-row-alt:   rgba(255, 255, 255, .025); /* sudý řádek (zebra) */
  --color-grid-row-hover: rgba(79, 209, 197, .10);   /* řádek pod kurzorem */
}

/* Geometrie checkboxů – barvově neutrální, společné pro obě témata.
   Ladí se z jednoho místa; barvy si checkbox bere ze sémantických proměnných
   výše (--color-accent, --color-input-bg, --color-border, --color-text-on-accent). */
:root {
  --checkbox-size:    18px;   /* o ~12 % větší než nativní */
  --checkbox-radius:  5px;
  --checkbox-border:  1.5px;

  --menu-font-size:   16px;   /* horní menu + všechna pulldown podmenu */
}

:root[data-theme="light"] {
  --color-page-bg:        #f4f6f9;
  --color-surface:        #ffffff;
  --color-surface-raised: #eef1f5;
  --color-input-bg:       #ffffff;
  --color-border:         #d4dae2;

  --color-text:           #1c2530;
  --color-text-muted:     #5d6b7a;
  --color-text-on-accent: #04201c;
  --color-text-on-danger: #ffffff;

  --color-accent:         #0d9488;  /* tmavší tyrkys pro dostatečný kontrast na bílé */
  --color-accent-warm:    #c2691a;
  --color-danger:         #d64545;
  --color-success:        #2f855a;
  --color-text-on-success:#ffffff;
  --color-toast-error-text: #7a1a1a;

  --color-overlay:        rgba(30, 40, 55, .42);
  --shadow-toast:         0 8px 28px rgba(40, 55, 75, .18);
  --shadow-modal:         0 18px 50px rgba(40, 55, 75, .22);

  /* Datagrid */
  --color-grid-header:    #eef1f5;
  --color-grid-row-alt:   rgba(20, 30, 45, .03);
  --color-grid-row-hover: rgba(13, 148, 136, .08);
}

/* ===========================================================================
   ROZMĚROVÉ A TYPOGRAFICKÉ PROMĚNNÉ
   =========================================================================== */
:root {
  --radius: 8px;
  /* Systémové fonty – nic se nenačítá z internetu, na každém OS se použije
     nativní UI písmo (San Francisco / Segoe UI / Roboto / Noto …). */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", "Roboto Mono", monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--color-page-bg); color: var(--color-text);
  font-family: var(--font); font-size: 15px; line-height: 1.5;
  transition: background .2s ease, color .2s ease;
  /* Sticky footer: tělo je svislý flex přes celou výšku okna, obsah (.wrap)
     roste a vytlačí patičku dolů. Při delším obsahu se patička posune níž. */
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Topbar --- */
.topbar {
  display: flex; align-items: center; justify-content: flex-start; gap: 18px;
  padding: 0 24px; height: 56px; background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}
.brand { font-weight: 600; font-size: 18px; color: var(--color-text); letter-spacing: .3px; margin-right: auto; }

/* Hamburger: na široké obrazovce skrytý, na úzké je to běžné rozbalovací menu */
.menu-nav { display: none; }
.menu-nav-trigger { padding: 0 9px; }
.hamburger { display: flex; flex-direction: column; gap: 4px; }
.hamburger span {
  display: block; width: 16px; height: 2px;
  background: currentColor; border-radius: 999px;
  transition: transform .18s ease, opacity .18s ease;
}
.menu-nav.open .hamburger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-nav.open .hamburger span:nth-child(2) { opacity: 0; }
.menu-nav.open .hamburger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.nav { display: flex; gap: 18px; align-items: center; }
.nav a { color: var(--color-text-muted); font-size: var(--menu-font-size); }
.nav a:hover { color: var(--color-text); text-decoration: none; }

/* Trvale viditelná skupina menu (vpravý kraj lišty) */
.topbar-menus { display: flex; align-items: center; gap: 8px; }

/* --- Rozbalovací menu v topbaru (jazyk, téma, uživatel) --- */
.menu { position: relative; }
.menu-trigger {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--color-surface-raised); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: 6px;
  height: 30px; padding: 0 10px; cursor: pointer;
  font-family: var(--font); font-size: var(--menu-font-size); line-height: 1;
}
.menu-trigger:hover, .menu.open .menu-trigger { border-color: var(--color-accent); }
.menu-trigger:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.menu-lang .menu-trigger { font-family: var(--mono); font-size: calc(var(--menu-font-size) - 1px); }
.menu-theme .menu-trigger { padding: 0 8px; }
.menu-caret { color: var(--color-text-muted); font-size: .8em; }
.menu-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--color-input-bg); color: var(--color-accent);
  border: 1px solid var(--color-border);
}
.menu-avatar svg { display: block; }
.menu-panel {
  display: none; position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 160px; background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: 8px; padding: 6px;
  z-index: 60; box-shadow: 0 6px 20px var(--color-overlay);
}
.menu.open .menu-panel { display: block; }
.menu-lang-panel { min-width: 80px; }
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  text-align: left; background: none; border: 0;
  color: var(--color-text); font-family: var(--font); font-size: var(--menu-font-size);
  padding: 8px 10px; border-radius: 6px; cursor: pointer; text-decoration: none;
}
.menu-item:hover:not([disabled]) { background: var(--color-surface-raised); text-decoration: none; }
.menu-item.on { color: var(--color-accent); }
.menu-item[disabled] { opacity: .45; cursor: not-allowed; }
.menu-theme-icon { display: inline-block; width: 16px; text-align: center; }
.menu-user-head {
  padding: 8px 10px 10px; margin-bottom: 6px;
  border-bottom: 1px solid var(--color-border);
}
.menu-user-mail { color: var(--color-text); font-size: var(--menu-font-size); word-break: break-all; }
.menu-user-role { color: var(--color-text-muted); font-size: calc(var(--menu-font-size) - 2px); margin-top: 2px; }

.wrap { 
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 1000px;
  margin: 0 auto;
  padding: 28px 24px;
  flex: 1 0 auto;          /* sticky footer: obsah vyplní volné místo */
  width: 100%;
}
.foot { text-align: center; color: var(--color-text-muted); padding: 24px; font-size: 13px; flex-shrink: 0; }

/* --- Toast notifikace (dole na obrazovce, nad modály) --- */
.toast-container {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 10px; z-index: 1200;
  width: min(440px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 16px; border-radius: var(--radius);
  background: var(--color-surface-raised); color: var(--color-text);
  border: 1px solid var(--color-border); border-left: 4px solid var(--color-accent);
  box-shadow: var(--shadow-toast); pointer-events: auto;
  animation: toast-in .3s cubic-bezier(.2,.8,.2,1);
}
.toast.info  { border-left-color: var(--color-accent); }
.toast.error { border-left-color: var(--color-danger); }
.toast.error .toast-msg { color: var(--color-toast-error-text); }
.toast.hide { animation: toast-out .3s ease forwards; }
.toast-msg { flex: 1; font-size: 14px; line-height: 1.45; }
.toast-close {
  background: none; border: 0; color: var(--color-text-muted); font-size: 20px;
  line-height: 1; cursor: pointer; padding: 0 2px;
}
.toast-close:hover { color: var(--color-text); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(16px); }
}
@media (prefers-reduced-motion: reduce) {
  .toast, .toast.hide { animation: none; }
}

h1 { font-size: 24px; font-weight: 600; margin: 0 0 18px; }
h2 { font-size: 18px; font-weight: 600; margin: 24px 0 12px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 8px; }

/* --- Úvodní (landing) stránka --- */
.lead { font-size: 16px; line-height: 1.6; color: var(--color-text-muted); margin: 0 0 24px; max-width: 640px; }
.card h3 { color: var(--color-accent); font-size: 14px; margin: 0 0 6px; }
.media { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.media-img { width: 220px; max-width: 100%; display: block; }
.media-text { flex: 1; min-width: 220px; }

.panel { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; width: stretch; }

label { display: block; font-size: 13px; color: var(--color-text-muted); margin: 12px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=number], select {
  width: 100%; padding: 9px 11px; background: var(--color-input-bg); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: 6px; font-family: var(--font); font-size: 14px;
}
input:focus, select:focus { outline: none; border-color: var(--color-accent); }
.form-hint { color: var(--color-text-muted); margin: 4px 0 0; }
/* Překladový formulář: zdroj nahoře, plnošířkový input pod ním. */
.tx-item { padding: 12px 0; border-bottom: 1px solid var(--color-border); }
.tx-item:last-of-type { border-bottom: none; }
.tx-source { color: var(--color-text); margin-bottom: 6px; word-break: break-word; }
.tx-source .tx-label { color: var(--color-text-muted); }
.tx-row { display: flex; align-items: center; gap: 8px; }
.tx-target-label { color: var(--color-text-muted); font-size: 13px; margin: 0; flex: 0 0 auto; }
.tx-input { flex: 1 1 auto; width: auto; min-width: 0; }
.tx-pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 6px 0 14px; }
.tx-pager-info { color: var(--color-text-muted); font-size: 13px; }
.tx-perpage { display: flex; justify-content: center; align-items: center; gap: 8px; margin: 0 0 16px; }
.tx-perpage-label { margin: 0; color: var(--color-text-muted); font-size: 13px; }
.tx-perpage input[type=number] { width: 5rem; }
/* ---------------------------------------------------------------------------
   CHECKBOXY – jednotný vzhled v barvách aplikace, napříč prohlížeči.
   Markup: <label class="checkbox-line"><input type="checkbox"><span>…</span></label>
   Velikost a tvar řídí proměnné --checkbox-* výše, barvy sémantické proměnné.
   --------------------------------------------------------------------------- */
.checkbox-line { display: flex; align-items: center; gap: 8px; margin-top: 12px; cursor: pointer; }
.checkbox-line span { font-size: 14px; color: var(--color-text); }

input[type=checkbox] {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  position: relative; flex: 0 0 auto;
  width: var(--checkbox-size); height: var(--checkbox-size); margin: 0;
  border: var(--checkbox-border) solid var(--color-border);
  border-radius: var(--checkbox-radius);
  background: var(--color-input-bg);
  cursor: pointer; vertical-align: middle;
  transition: background .12s, border-color .12s;
}
input[type=checkbox]:hover { border-color: var(--color-accent); }
input[type=checkbox]:checked {
  background: var(--color-accent); border-color: var(--color-accent);
}
input[type=checkbox]:focus-visible {
  outline: 2px solid var(--color-accent); outline-offset: 2px;
}
input[type=checkbox]:disabled { opacity: .45; cursor: not-allowed; }

/* Zaškrtávací fajfka (border-trick = funguje i ve starších prohlížečích).
   Horní hrot mírně přesahuje pravý horní roh pole. */
input[type=checkbox]::after {
  content: ""; position: absolute; box-sizing: border-box;
  left: 49%; top: 42%; width: 7px; height: 14px;
  border: solid var(--color-text-on-accent); border-width: 0 2.5px 2.5px 0;
  transform: translate(-50%, -60%) rotate(42deg);
  opacity: 0; transition: opacity .1s;
}
input[type=checkbox]:checked::after { opacity: 1; }

.btn {
  display: inline-block; padding: 9px 18px; border: 0; border-radius: 6px;
  background: var(--color-accent); color: var(--color-text-on-accent); font-weight: 600; cursor: pointer;
  font-size: 14px; font-family: var(--font);
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn[disabled], .btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn[disabled]:hover, .btn:disabled:hover { filter: none; text-decoration: none; }
.btn.secondary { background: var(--color-surface-raised); color: var(--color-text); border: 1px solid var(--color-border); }
.btn.danger { background: var(--color-danger); color: var(--color-text-on-danger); }
.btn.success { background: var(--color-success); color: var(--color-text-on-success); }
.btn.sm { padding: 5px 12px; font-size: 13px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--color-border); }
th { color: var(--color-text-muted); font-weight: 500; font-size: 13px; }
code, .mono { font-family: var(--mono); font-size: 13px; }
.token { font-family: var(--mono); font-size: 12px; color: var(--color-accent-warm); word-break: break-all; }

.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 720px) { .cols-2, .cols-3 { grid-template-columns: 1fr; } }

.card {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius);
  padding: 18px;
}
.card .value { font-family: var(--mono); font-size: 28px; color: var(--color-accent); }
.card .unit { font-size: 16px; color: var(--color-text-muted); }
.card .label { font-size: 13px; color: var(--color-text-muted); margin-bottom: 6px; }
.card .ts { font-size: 11px; color: var(--color-text-muted); margin-top: 8px; }

.muted { color: var(--color-text-muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; width: stretch; }
.row.gap-sm { gap: 6px; }
.row.between { justify-content: space-between; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--color-surface-raised); color: var(--color-text-muted); }
.pill.public { color: var(--color-accent); }
.pill.invite { color: var(--color-accent-warm); }

/* Tabulky na malých displejích posuneme do vodorovného scrollu. */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ===========================================================================
   UTILITY TŘÍDY (nahrazují inline styly v šablonách)
   =========================================================================== */
.no-margin   { margin: 0 !important; }
.full        { width: 100%; }              /* plná šířka i při .wrap align-items:center */
.mt-1        { margin-top: 12px; }
.mt-2        { margin-top: 14px; }
.mt-3        { margin-top: 16px; }
.mt-4        { margin-top: 18px; }
.table-mt    { margin-top: 12px; }          /* odsazení tabulky pod hlavičkou panelu */
.hidden      { display: none; }
.selectable  { user-select: all; }
.text-accent { color: var(--color-accent); }

/* Omezení šířky panelů/formulářů */
.narrow      { max-width: 420px; }
.narrow-lg   { max-width: 480px; }
.field-md    { max-width: 280px; }
.field-sm    { max-width: 200px; }

/* ===========================================================================
   EDITOR HODNOT SENZORU (sensor/values) – řádek polí s možností zalomení
   =========================================================================== */
.value-editor-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: flex-end;          /* vstupy zarovnané na společnou spodní hranu */
  padding: 14px 0;
  border-bottom: 1px solid var(--color-border);
}
.value-editor-row:last-child { border-bottom: 0; padding-bottom: 0; }

/* Pole = popisek nad vstupem; ruší blokový margin globálního <label> */
.value-field { margin: 0; min-width: 0; flex: 0 0 auto; }
.value-field-label { font-size: 13px; color: var(--color-text-muted); margin-bottom: 4px; min-height: 1.15em; }
.value-static { padding: 9px 0; }

/* Vstupy/selecty vyplní šířku svého sloupce (přebíjí globální width:100%) */
.value-editor-row input,
.value-editor-row select { width: 100%; }

/* Šířky jednotlivých sloupců (px = základ, name/user-name dorovnávají zbytek) */
.value-field-name      { flex: 1 1 150px; }
.value-field-user-name { flex: 1 1 150px; }
.value-field-type      { flex: 0 0 120px; }
.value-field-unit      { flex: 0 0 72px; }
.value-field-number    { flex: 0 0 78px; }
.value-field-readonly  { flex: 0 0 96px; }
.value-field-actions   { flex: 0 0 auto; margin-left: auto; }

/* Dlouhý technický název hodnoty ořízneme (plný je v title) */
.value-field-name .value-static { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Modální dialogy (vždy vycentrované na střed obrazovky) --- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1100;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: var(--color-overlay); backdrop-filter: blur(2px);
  opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility .2s ease;
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  width: min(460px, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 22px 22px 20px;
  box-shadow: var(--shadow-modal);
  transform: translateY(12px) scale(.98); transition: transform .2s cubic-bezier(.2,.8,.2,1);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal-head h2 { margin: 0; }
.modal-close {
  background: none; border: 0; color: var(--color-text-muted); font-size: 24px; line-height: 1;
  cursor: pointer; padding: 0 4px;
}
.modal-close:hover { color: var(--color-text); }
.modal-body { margin-top: 6px; }
.modal-body p { color: var(--color-text-muted); margin: 0 0 4px; }
.modal-form { margin: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
@media (prefers-reduced-motion: reduce) {
  .modal-overlay, .modal { transition: none; }
}

/* --- Responsivita --- */
@media (max-width: 720px) {
  body { font-size: 16px; }
  /* Úzká obrazovka: řádek brand | hamburger (uprostřed) | menu (vpravo).
     Hlavní odkazy se sklopí do hamburgeru pod lištu; menu zůstávají v liště. */
  .topbar {
    flex-wrap: wrap; align-items: center; height: auto;
    padding: 10px 16px; gap: 10px;
  }
  .brand { font-size: 17px; margin-right: 0; order: 1; flex: 0 0 auto; }
  .menu-nav { display: block; order: 2; flex: 0 0 auto; margin: 0 auto; }
  .topbar-menus { order: 3; flex: 0 0 auto; gap: 6px; }
  .nav { display: none; }
  .wrap { padding: 18px 16px; }
  .panel { padding: 16px; }
  h1 { font-size: 21px; }
  h2 { font-size: 17px; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .btn { padding: 11px 18px; }
  .btn.sm { padding: 8px 14px; }
  form.row { flex-direction: column; align-items: stretch; }
  form.row select, form.row input, form.row .btn { max-width: none !important; width: 100%; }
  .toast-container { bottom: 12px; width: calc(100vw - 24px); }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
}

@media (max-width: 420px) {
  /* Velmi úzká obrazovka: stáhnout mezery, ať se vše vejde do řádku. */
  .topbar { padding: 10px 12px; gap: 8px; }
  .brand { font-size: 16px; }
  .topbar-menus { gap: 4px; }
  .menu-trigger { padding: 0 8px; }
  .menu-user-panel { min-width: 200px; }
}

@media (max-width: 380px) {
  .wrap { padding: 14px 12px; }
}

/* ===========================================================================
   DATAGRID
   =========================================================================== */
.datagrid { margin-bottom: 18px; }
.datagrid-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.datagrid-search {
  width: auto; min-width: 200px; max-width: 320px;
  padding: 8px 11px; background: var(--color-input-bg); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: 6px; font-size: 14px;
}
.datagrid-search:focus { outline: none; border-color: var(--color-accent); }
.datagrid-spacer { flex: 1; }
.datagrid-perpage-label { color: var(--color-text-muted); font-size: 13px; display: flex; align-items: center; gap: 6px; margin: 0; }
.datagrid-perpage { width: auto; padding: 5px 8px; }

/* Podklad gridu: ohraničená plocha se zaoblením; .table-wrap kolem tabulky
   zajistí vodorovný scroll, takže data se radši posunou než zalomí. */
.datagrid .table-wrap {
  border: 1px solid var(--color-border); border-radius: var(--radius);
  overflow-x: auto;
}
.datagrid-table { border-collapse: collapse; width: 100%; }

/* Hlavička – odlišené pozadí, drží nahoře při scrollu obsahu. */
.datagrid-table thead th {
  background: var(--color-grid-header);
  position: sticky; top: 0; z-index: 1;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.datagrid-table th.sortable { cursor: pointer; user-select: none; }
.datagrid-table th.sortable:hover { color: var(--color-text); }
.sort-ind { color: var(--color-accent); }

/* Buňky se NEzalamují, dokud to jde; dlouhý text se elegantně ořízne
   (…) a celý je vidět v titulku/po rozšíření okna. Scroll řeší .table-wrap. */
.datagrid-table td {
  white-space: nowrap;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Buňky s akčními tlačítky se nesmí ořezávat. */
.datagrid-table td.cell-actions { overflow: visible; max-width: none; }

/* Zebra pruhování + zvýraznění řádku pod kurzorem. */
.datagrid-body tr:nth-child(even) { background: var(--color-grid-row-alt); }
.datagrid-body tr:hover { background: var(--color-grid-row-hover); }
.datagrid-body td { border-bottom: 1px solid var(--color-border); }
.datagrid-body tr:last-child td { border-bottom: 0; }

.datagrid-loading { text-align: center; padding: 22px; white-space: normal; }

.datagrid-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px; gap: 12px; flex-wrap: wrap;
}
.datagrid-pager { display: flex; align-items: center; gap: 10px; }
.datagrid-pager .btn[disabled] { opacity: .4; cursor: default; }
.datagrid-info, .datagrid-pageinfo { font-size: 13px; }

@media (max-width: 720px) {
  .datagrid-toolbar { flex-wrap: wrap; }
  .datagrid-search { max-width: none; flex: 1; }
}

/* ===========================================================================
   DASHBOARD BLOCKS
   =========================================================================== */
textarea {
  width: 100%; min-height: 90px; padding: 9px 11px;
  background: var(--color-input-bg); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: 6px;
  font-family: var(--font); font-size: 14px; resize: vertical;
}
textarea:focus { outline: none; border-color: var(--color-accent); }

.dashboard-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.dashboard-title-row h1 {
  min-width: 0;
  margin: 0;
  text-align: center;
}
.dashboard-title-nav {
  display: flex;
  justify-content: flex-start;
}
.dashboard-title-nav--right { justify-content: flex-end; }
.dashboard-nav-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
}
.dashboard-nav-arrow:hover,
.dashboard-nav-arrow:focus {
  border-color: var(--color-accent);
  color: var(--color-accent);
  text-decoration: none;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
}
.dashboard-block {
  grid-column: span 4;
  min-height: 150px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px;
  overflow: hidden;
}
.dashboard-block--span-3 { grid-column: span 3; }
.dashboard-block--span-4 { grid-column: span 4; }
.dashboard-block--span-6 { grid-column: span 6; }
.dashboard-block--span-8 { grid-column: span 8; }
.dashboard-block--span-12 { grid-column: span 12; }
.dashboard-block--height-1 { min-height: 150px; }
.dashboard-block--height-2 { min-height: 230px; }
.dashboard-block--height-3 { min-height: 310px; }
.dashboard-block--height-4 { min-height: 390px; }
.dashboard-block--heading { display: flex; align-items: center; min-height: auto; }
.dashboard-text-align-left { text-align: left; }
.dashboard-text-align-center { text-align: center; }
.dashboard-text-align-right { text-align: right; }
.dashboard-text-content {
  width: 100%;
  margin: 0;
  white-space: pre-line;
  color: var(--color-text);
}
.dashboard-text-content--heading { font-size: 24px; font-weight: 600; }
.dashboard-text-content--subheading { font-size: 18px; font-weight: 600; color: var(--color-text-muted); }
.dashboard-text-content--paragraph { line-height: 1.5; }
.dashboard-value-title {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}
.dashboard-default-value { margin-bottom: 6px; }
.dashboard-value {
  font-family: var(--mono);
  font-size: 28px;
  color: var(--color-accent);
}
.dashboard-unit {
  margin-left: 4px;
  font-size: 16px;
  color: var(--color-text-muted);
}
.dashboard-sparkline {
  width: 100%;
  max-width: 100%;
  display: block;
}
.dashboard-timestamp {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 8px;
}
.dashboard-render-target {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  min-height: 90px;
}
.dashboard-gauge-canvas,
.dashboard-temperature-canvas {
  display: block;
  margin: 0 auto;
  max-width: 100%;
}
.dashboard-fluid-container {
  display: flex;
  justify-content: center;
  min-height: 220px;
}
.dashboard-apex-chart {
  min-height: 260px;
}

.dashboard-block-order-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.dashboard-block-order-toolbar p { margin: 0; }
.dashboard-block-editor-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.dashboard-block-editor-card {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px;
  transition: box-shadow .16s ease, border-color .16s ease, opacity .16s ease;
}
.dashboard-block-editor-card.dragging {
  opacity: .96;
  border-color: var(--color-accent);
  box-shadow: var(--shadow-toast);
  pointer-events: none;
  cursor: grabbing;
  will-change: transform;
}
.dashboard-block-drop-placeholder {
  border: 2px dashed var(--color-accent);
  border-radius: var(--radius);
  background: var(--color-surface);
  opacity: .72;
}

.dashboard-block-editor-list.saving-order .dashboard-block-editor-card {
  transition: opacity .15s ease, box-shadow .16s ease, border-color .16s ease;
}
.dashboard-block-editor-form { margin: 0; }
.dashboard-block-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.dashboard-block-editor-title {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.dashboard-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: grab;
  line-height: 1;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  -webkit-tap-highlight-color: transparent;
}
.dashboard-drag-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.dashboard-drag-handle * { pointer-events: none; }
html.dashboard-drag-active,
html.dashboard-drag-active body,
html.dashboard-drag-active * {
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-touch-callout: none !important;
}
html.dashboard-drag-active {
  touch-action: none;
}
html.dashboard-drag-active body {
  overscroll-behavior: none;
}
.dashboard-drag-handle:hover,
.dashboard-drag-handle:focus {
  color: var(--color-text);
  border-color: var(--color-accent);
}
.dashboard-drag-handle:active { cursor: grabbing; }
.dashboard-display-type-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}
.dashboard-display-type-field { min-width: 0; }

.dashboard-config-action-cell.hidden,
.dashboard-config-action-cell[hidden] {
  display: none !important;
}

.dashboard-config-action-cell {
  display: flex;
  justify-content: flex-end;
  padding-bottom: 2px;
}
.dashboard-config-modal { width: min(680px, 100%); }
.dashboard-config-section h3 { margin: 14px 0 10px; }
.dashboard-config-subsection { margin-top: 18px; }
.dashboard-config-subsection h4 { margin: 0 0 8px; }
.dashboard-config-field-grid { margin-top: 8px; }
.dashboard-config-field { min-width: 0; }
.dashboard-highlight-list { display: grid; gap: 10px; margin-top: 10px; }
.dashboard-highlight-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 86px auto;
  gap: 10px;
  align-items: end;
}
.dashboard-highlight-field { min-width: 0; }
.dashboard-highlight-color-field input[type="color"] { min-height: 42px; padding: 4px; }
.dashboard-highlight-remove { white-space: nowrap; }
.dashboard-text-config-line { align-items: end; }
.dashboard-checkbox-field { display: flex; align-items: end; min-height: 64px; }
.dashboard-source-label { margin: 8px 0 0; }
.dashboard-add-block-form { margin: 0; }
.dashboard-form-action-cell {
  display: flex;
  align-items: end;
}

@media (max-width: 900px) {
  .dashboard-block--span-3,
  .dashboard-block--span-4 { grid-column: span 6; }
  .dashboard-block-editor-list { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-block,
  .dashboard-block--span-3,
  .dashboard-block--span-4,
  .dashboard-block--span-6,
  .dashboard-block--span-8,
  .dashboard-block--span-12 {
    grid-column: 1 / -1;
  }
  .dashboard-block-order-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .dashboard-drag-handle {
    width: 46px;
    height: 46px;
  }
  .dashboard-drag-icon {
    width: 25px;
    height: 25px;
  }
  .dashboard-title-row {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    gap: 8px;
  }
  .dashboard-nav-arrow {
    width: 40px;
    height: 40px;
    font-size: 22px;
  }
  .dashboard-display-type-line { grid-template-columns: 1fr; }
  .dashboard-highlight-row { grid-template-columns: 1fr; }
  .dashboard-highlight-remove { width: 100%; }
  .dashboard-config-action-cell { justify-content: stretch; }
  .dashboard-config-action-cell .btn { width: 100%; }
  .dashboard-form-action-cell { align-items: stretch; }
  .dashboard-form-action-cell .btn { width: 100%; }
}

/* ===========================================================================
   SENSOR EXPORT
   =========================================================================== */
.sensor-export-progress {
  display: block;
  width: 100%;
  height: 18px;
  margin-top: 14px;
  accent-color: var(--color-accent);
}
.sensor-export-progress::-webkit-progress-bar {
  background: var(--color-surface-raised);
  border-radius: 999px;
}
.sensor-export-progress::-webkit-progress-value {
  background: var(--color-accent);
  border-radius: 999px;
}
.sensor-export-progress::-moz-progress-bar {
  background: var(--color-accent);
  border-radius: 999px;
}
.sensor-export-percent {
  margin: 8px 0 0;
  color: var(--color-text-muted);
  font-family: var(--mono);
  text-align: right;
}
/* ---------------------------------------------------------------------------
   SMLOUVY (accord) – blokující dialog souhlasu + plné znění
   --------------------------------------------------------------------------- */
/* Blokující overlay: vlastní třída (ne .modal-overlay), aby ho nešlo zavřít
   křížkem ani klávesou Esc – uživatel musí zvolit Souhlasím/Nesouhlasím. */
.accord-overlay {
  position: fixed; inset: 0; z-index: 1100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: var(--color-overlay); backdrop-filter: blur(2px);
}
.accord-modal { width: min(560px, 100%); }
.accord-whatsnew {
  margin: 10px 0; padding: 12px 14px;
  background: var(--color-surface-raised); border-radius: var(--radius);
  color: var(--color-text); line-height: 1.5;
}
.accord-whatsnew :first-child { margin-top: 0; }
.accord-whatsnew :last-child { margin-bottom: 0; }
.accord-fulllink { margin-top: 12px; }

/* Plné znění smlouvy – běžné stránkové styly z app.css */
.accord-full { max-width: 820px; }
.accord-text { line-height: 1.6; color: var(--color-text); }
.accord-text h1, .accord-text h2, .accord-text h3 { color: var(--color-text); }
.accord-text a { color: var(--color-accent); }
