/* Služebníček – střídmý firemní vzhled (barva IDEAL Automotive jen jako akcent), světlý i tmavý režim */
:root {
  --brand: #b0132f;
  --brand-hover: #8f0f26;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --subtle: #f7f8f9;
  --column: #ebedf0;
  --text: #1f2328;
  --muted: #5d6670;
  --faint: #8a939c;
  --line: #d8dce1;
  --line-strong: #c3c9d0;
  --focus: #1f6feb;
  --servis: #cf222e;
  --opraveno: #1a7f37;
  --uzavreno: #6e7781;
  --warn: #9a6700;
  --danger-bg: #ffebe9;
  --radius: 6px;
  --radius-sm: 4px;
  --shadow: 0 1px 2px rgba(31, 35, 40, .06);
  --shadow-pop: 0 8px 28px rgba(31, 35, 40, .18);
  --gutter: 20px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --subtle: #1d2229;
    --column: #13171c;
    --text: #e6e8eb;
    --muted: #9aa4ae;
    --faint: #6f7882;
    --line: #2b313a;
    --line-strong: #3a414b;
    --focus: #4c8dff;
    --servis: #f85149;
    --opraveno: #3fb950;
    --uzavreno: #8b949e;
    --warn: #d29922;
    --danger-bg: #3c1618;
    --shadow: none;
    --shadow-pop: 0 8px 28px rgba(0, 0, 0, .6);
  }
}
/* Logo má černá písmena – v tmavém režimu leží na bílém podkladu */
@media (prefers-color-scheme: dark) {
  .logo, .logo-big { background: #fff; padding: 3px 6px; border-radius: var(--radius-sm); }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex; flex-direction: column;
}
[hidden] { display: none !important; }
a { color: var(--focus); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
code { font-family: Consolas, "Courier New", monospace; font-size: 12.5px; background: var(--subtle); border: 1px solid var(--line); padding: 0 4px; border-radius: 3px; }
.i { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -2px; margin-right: 3px; flex: none; }

/* ---------- tlačítka a formuláře ---------- */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 5px 12px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none;
}
button:hover, .button:hover { background: var(--subtle); text-decoration: none; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
button.ghost { background: var(--surface); }
button.danger { color: var(--servis); border-color: var(--line-strong); background: var(--surface); }
button.danger:hover { background: var(--danger-bg); border-color: var(--servis); }
button:disabled { opacity: .5; cursor: default; }
button.block { width: 100%; min-height: 38px; }
.icon-btn { border-color: transparent; background: transparent; padding: 5px 8px; color: inherit; }
.icon-btn:hover { background: rgba(127, 127, 127, .14); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.small { min-height: 0; padding: 3px; }
.icon-btn.small svg { width: 14px; height: 14px; stroke-width: 2.2; }

label { display: block; margin-bottom: 12px; font-weight: 600; font-size: 13px; color: var(--text); }
input:not([type=checkbox]):not([type=radio]):not([type=color]), select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 6px 9px; min-height: 32px;
  font-weight: 400; font-size: 14px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(31, 111, 235, .15); }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 15px; height: 15px; margin: 0; }
input[type=color] { width: 40px; height: 32px; padding: 2px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); }
textarea { resize: vertical; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.hint { color: var(--muted); font-size: 12.5px; font-weight: 400; margin: 4px 0 12px; }
.error { color: var(--servis); margin: 6px 0; font-weight: 600; }
.ok { color: var(--opraveno); margin: 6px 0; font-weight: 600; }
.ok:empty, .error:empty { display: none; }

.tabs { display: flex; gap: 0; margin: 0 0 16px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; border-radius: 0; background: transparent; color: var(--muted); padding: 8px 14px; min-height: 0; box-shadow: inset 0 -2px 0 transparent; }
.tabs button:hover { background: transparent; color: var(--text); }
.tabs button.active { color: var(--text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--brand); }

/* ---------- obrazovky ---------- */
.screen { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px var(--gutter); }
.screen.app { flex-direction: column; align-items: stretch; justify-content: flex-start; padding: 0; min-height: 0; }

.auth-box {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px 28px 24px; box-shadow: var(--shadow);
}
.auth-box.wizard { width: min(640px, 100%); }
.auth-box h1 { font-size: 20px; margin: 18px 0 20px; }
.auth-box h1 span { display: block; font-size: 13px; font-weight: 400; color: var(--muted); margin-top: 2px; }
.logo-big { display: block; height: 64px; }
.steps { display: flex; gap: 6px; padding: 0; margin: 0 0 20px; list-style: none; counter-reset: step; }
.steps li { flex: 1; font-size: 12px; color: var(--muted); border-top: 3px solid var(--line); padding-top: 6px; counter-increment: step; }
.steps li::before { content: counter(step) ". "; }
.steps li.done { border-color: var(--opraveno); }
.steps li.current { border-color: var(--brand); color: var(--text); font-weight: 600; }
.howto { padding-left: 20px; margin: 10px 0 16px; }
.howto li { margin-bottom: 10px; }

/* ---------- horní lišta ---------- */
.appbar { background: var(--surface); border-top: 3px solid var(--brand); border-bottom: 1px solid var(--line); position: relative; z-index: 3; }
.appbar-row { display: flex; align-items: center; gap: 12px; height: 52px; padding: 0 var(--gutter); }
.logo { height: 34px; flex: none; }
.app-name { font-weight: 600; font-size: 15px; padding-left: 12px; border-left: 1px solid var(--line); white-space: nowrap; }
.appnav { display: flex; align-self: stretch; margin-left: 12px; }
.appnav button {
  border: 0; border-radius: 0; background: transparent; color: var(--muted); padding: 0 14px; min-height: 0; height: 100%;
  box-shadow: inset 0 -2px 0 transparent; font-weight: 500;
}
.appnav button:hover { background: transparent; color: var(--text); }
.appnav button.active { color: var(--text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--brand); }
.search-wrap { flex: 1; display: flex; justify-content: flex-end; min-width: 0; }
#search {
  max-width: 300px; margin: 0; min-height: 32px; padding-left: 30px;
  background: var(--subtle) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%238a939c' stroke-width='2'%3E%3Ccircle cx='6' cy='6' r='4.5'/%3E%3Cpath d='m9.5 9.5 3.5 3.5'/%3E%3C/svg%3E") no-repeat 10px center;
}
.sync { border-color: transparent; background: transparent; color: var(--muted); font-weight: 400; font-size: 13px; padding: 4px 8px; }
.sync:hover { background: rgba(127, 127, 127, .14); }
.sync .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.sync.ok .dot { background: var(--opraveno); }
.sync.err .dot { background: var(--servis); }
.sync.err { color: var(--servis); }
#settingsBtn #userName { font-weight: 500; font-size: 13px; }

.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px var(--gutter); background: var(--surface); border-bottom: 1px solid var(--line);
}
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filters select { width: auto; margin: 0; font-size: 13px; padding: 4px 8px; min-height: 30px; }
.toggle { display: flex; gap: 6px; align-items: center; margin: 0 0 0 4px; font-weight: 400; font-size: 13px; white-space: nowrap; cursor: pointer; color: var(--muted); }
.toolbar-actions { display: flex; gap: 8px; }
.column-tabs { display: none; }

/* ---------- tabule ---------- */
.board { flex: 1; min-height: 0; display: flex; gap: 12px; align-items: flex-start; padding: 16px var(--gutter) 24px; overflow-x: auto; }
.column {
  flex: 0 0 292px; max-height: 100%; display: flex; flex-direction: column;
  background: var(--column); border: 1px solid var(--line); border-radius: var(--radius);
}
.column-head {
  display: flex; justify-content: space-between; align-items: center; padding: 10px 12px 8px;
  font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted);
}
.column-head .count { font-weight: 600; color: var(--muted); }
.column { border-top: 2px solid var(--c, var(--line)); }
.stage-name { display: inline-flex; align-items: center; gap: 7px; }
.stage-name::before, .column-tabs button::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--faint)); flex: none; }

.cards { flex: 1; overflow-y: auto; padding: 0 8px 4px; min-height: 40px; }
.cards.drop { background: rgba(31, 111, 235, .06); outline: 1px dashed var(--focus); outline-offset: -2px; }
.empty { color: var(--faint); font-size: 13px; text-align: center; padding: 16px 8px; }
.add-card { margin: 2px 8px 8px; justify-content: flex-start; border-color: transparent; background: transparent; color: var(--muted); }
.add-card:hover { background: rgba(127, 127, 127, .12); color: var(--text); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 9px 11px 8px; margin-bottom: 6px; cursor: pointer; box-shadow: var(--shadow); position: relative;
}
.card:hover { border-color: var(--line-strong); }
.card.dragging { opacity: .4; }
.card.st-uzavreno { opacity: .7; }
.card.pr-critical { border-left: 3px solid var(--servis); }
.card.pr-high { border-left: 3px solid var(--warn); }
.card-head { display: flex; align-items: center; gap: 8px; min-height: 20px; }
.card-id { font-size: 12px; color: var(--faint); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prio { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.prio.pr-critical { color: var(--servis); }
.prio.pr-high { color: var(--warn); }
.avatar {
  margin-left: auto; width: 22px; height: 22px; border-radius: 50%; flex: none;
  background: var(--subtle); border: 1px solid var(--line); color: var(--muted);
  font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.card .title { font-weight: 600; margin: 2px 0 1px; word-break: break-word; }
.card .meta { color: var(--muted); font-size: 12.5px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.facts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px 10px; font-size: 12px; color: var(--faint); }
.facts span { display: inline-flex; align-items: center; white-space: nowrap; }
.facts .late { color: var(--servis); font-weight: 600; }
.facts .warn { color: var(--warn); font-weight: 600; }

/* Stav: neutrální štítek s barevnou tečkou */
.badge {
  --c: var(--servis);
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; white-space: nowrap;
  padding: 1px 7px 1px 6px; border-radius: var(--radius-sm); background: var(--subtle); border: 1px solid var(--line); color: var(--text);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.badge.opraveno { --c: var(--opraveno); }
.badge.uzavreno { --c: var(--uzavreno); }
.tag {
  display: inline-flex; align-items: center; font-size: 12px; font-weight: 500; padding: 1px 7px; border-radius: var(--radius-sm);
  background: var(--subtle); color: var(--muted); white-space: nowrap; border: 1px solid var(--line);
}
.tag.late, .tag.alert, .tag.pr-critical { color: var(--servis); border-color: color-mix(in srgb, var(--servis) 40%, var(--line)); background: var(--danger-bg); }
.tag.warn, .tag.pr-high { color: var(--warn); }

.fab {
  display: none; position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  width: 52px; height: 52px; border-radius: 50%; font-size: 26px; line-height: 1; padding: 0;
  background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: var(--shadow-pop); z-index: 5;
}
.fab:hover { background: var(--brand-hover); }

/* ---------- dialogy ---------- */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; width: min(520px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px); background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop);
}
dialog.wide { width: min(860px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(15, 18, 22, .45); }
dialog h2 { margin: 0 0 14px; font-size: 17px; }
dialog h3 { margin: 18px 0 8px; font-size: 14px; }
dialog .row { display: flex; gap: 8px; }
dialog .row input { flex: 1; }
dialog .row button { margin-top: 4px; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.dialog-head h2 { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.warnbox {
  display: flex; gap: 6px; align-items: flex-start; padding: 8px 10px; margin-top: 10px; font-size: 13px;
  border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--line)); border-left-width: 3px; border-radius: var(--radius-sm); color: var(--warn);
}
.warnbox .i { margin-top: 2px; }
.warnbox.danger { color: var(--servis); border-color: color-mix(in srgb, var(--servis) 45%, var(--line)); background: var(--danger-bg); }

/* Detail karty jako boční panel */
#cardDialog { margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh; width: min(880px, 100vw); border-radius: 0; border-width: 0 0 0 1px; padding: 0; }
#cardDetail { padding: 18px 24px 24px; }
#cardDetail > .dialog-head { position: sticky; top: 0; background: var(--surface); margin: -18px -24px 0; padding: 16px 24px 12px; border-bottom: 1px solid var(--line); z-index: 1; }
.detail-sub { font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.status-buttons { display: flex; flex-wrap: wrap; margin: 14px 0 16px; }
.status-buttons button {
  flex: 1 1 auto; border-radius: 0; margin-left: -1px; font-weight: 500; color: var(--muted); background: var(--surface);
}
.status-buttons button:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.status-buttons button:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.status-buttons button::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--faint)); }
.status-buttons button.active { position: relative; z-index: 1; color: var(--text); font-weight: 600; background: var(--subtle); border-color: var(--text); }
.detail-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 28px; }
.panel { padding: 0 0 6px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.panel:last-child { border-bottom: 0; }
.panel h3 { margin: 0 0 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.lock { font-size: 11px; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--muted); border: 1px solid var(--line); padding: 0 5px; border-radius: 3px; margin-left: 6px; }
.attachments { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; margin-bottom: 10px; }
.att { position: relative; margin: 0; }
.att a { display: block; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--subtle); border: 1px solid var(--line); }
.att img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att .file { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); font-size: 12px; }
.att .file .i { width: 22px; height: 22px; margin: 0; }
.att figcaption { font-size: 11.5px; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-del {
  position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; min-height: 0; padding: 0; border-radius: var(--radius-sm);
  background: rgba(31, 35, 40, .7); border: 0;
}
.att-del svg { width: 12px; height: 12px; stroke: #fff; stroke-width: 2.4; fill: none; }
.upload-btn { margin-bottom: 12px; }
table.history { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 12px; }
table.history th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 4px 6px; border-bottom: 1px solid var(--line-strong); }
table.history td { padding: 6px; border-bottom: 1px solid var(--line); }
table.history tfoot td { border-bottom: 0; padding-top: 8px; }
table.history tr[data-open] { cursor: pointer; }
table.history tr[data-open]:hover td { background: var(--subtle); }
.num { text-align: right; white-space: nowrap; }
.invoice-form { border-top: 1px solid var(--line); padding-top: 12px; }
.invoice-form .actions, #commentForm .actions { margin-top: 8px; }
#commentForm textarea { margin-top: 0; }
.events { list-style: none; padding: 0; margin: 12px 0 0; }
.events li { padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.events .who { font-weight: 600; }
.events .when { color: var(--faint); font-size: 12px; margin-left: 4px; }
.events .msg { margin-top: 2px; color: var(--muted); }
.events li.comment .msg { color: var(--text); white-space: pre-wrap; }
.events li.alert .msg { color: var(--servis); font-weight: 600; }

/* ---------- faktury ---------- */
.invoice-dlg { display: grid; grid-template-columns: 1fr 1.1fr; gap: 24px; }
.invoice-dlg h3 { margin-top: 0; }
.inv-selected { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; }
.inv-selected > .hint { margin: 10px 12px; }
.inv-row { display: grid; grid-template-columns: 1fr 120px auto; gap: 8px; align-items: center; padding: 6px 8px 6px 12px; border-top: 1px solid var(--line); }
.inv-row:first-child { border-top: 0; }
.inv-card { min-width: 0; font-size: 13px; }
.inv-card b, .inv-card .hint { display: block; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-share { margin: 0 !important; text-align: right; }
.inv-sum-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.inv-sum-row .hint { margin: 0; }
.inv-sum-row .error { margin: 0; font-size: 12.5px; }
.inv-candidates { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); margin-top: -6px; }
.inv-candidates > .hint { margin: 10px 12px; }
.inv-candidate {
  display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 10px; text-align: left;
  border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 7px 12px; font-weight: 400; white-space: normal;
}
.inv-candidate:first-child { border-top: 0; }
.inv-candidate .hint { display: block; margin: 0; }
.inv-candidate .add { color: var(--focus); font-weight: 600; font-size: 13px; flex: none; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.page-head h2 { margin: 0; font-size: 18px; }
.page-head .hint { margin: 2px 0 0; }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 14px; overflow-x: auto; }
.inv-table td { vertical-align: top; }
.inv-table .inv-cards a { color: var(--text); }
.inv-table .late { color: var(--servis); font-weight: 600; }
.nowrap { white-space: nowrap; }

/* ---------- nastavení ---------- */
.col-row, .user-row, .stage-row { display: grid; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.col-row { grid-template-columns: 1fr 1.4fr 1.2fr auto auto; }
.user-row { grid-template-columns: 1.1fr 1.5fr auto auto auto auto; }
.stage-row { grid-template-columns: 40px 1fr auto auto auto; }
.col-row input, .stage-row input { margin: 0; }
.col-row label, .user-row label { margin: 0; font-weight: 400; display: flex; gap: 5px; align-items: center; white-space: nowrap; }
.col-row span, .row-buttons { display: flex; gap: 4px; }
.stage-kind { color: var(--muted); white-space: nowrap; }
.stage-row .hint { margin: 0; white-space: nowrap; }
.stage-add { display: grid; grid-template-columns: 1fr auto 40px auto; gap: 8px; align-items: center; margin-top: 14px; }
.stage-add input, .stage-add select { margin: 0; }
.mail-log { font-size: 13px; max-height: 320px; overflow-y: auto; }
.mail-log div { padding: 7px 0; border-bottom: 1px solid var(--line); word-break: break-word; }
.mail-log .bad { color: var(--servis); }

.smtp-test { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px 14px; margin: 6px 0 14px; }
.smtp-test legend { font-weight: 600; padding: 0 6px; }
.smtp-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.smtp-result { margin-top: 12px; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--line); border-left-width: 3px; font-size: 13px; }
.smtp-result.good { border-left-color: var(--opraveno); }
.smtp-result.bad { border-left-color: var(--servis); color: var(--servis); background: var(--danger-bg); }
.smtp-result .hint { display: block; margin: 6px 0 0; }
.smtp-log {
  margin: 10px 0 0; padding: 10px 12px; max-height: 260px; overflow: auto; border-radius: var(--radius-sm);
  background: #161b22; color: #c9d1d9; font: 12px/1.5 Consolas, "Courier New", monospace; white-space: pre-wrap; word-break: break-all;
}

/* ---------- přehled ---------- */
.stats { flex: 1; overflow-y: auto; padding: 20px var(--gutter) 40px; }
.kpis {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1px; margin-bottom: 20px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.kpi { padding: 14px 16px; background: var(--surface); }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { font-size: 24px; font-weight: 600; margin-top: 2px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-note { font-size: 12px; color: var(--faint); margin-top: 2px; }
.kpi.danger .kpi-value, .kpi.danger .kpi-note { color: var(--servis); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.stats-grid .panel { margin: 0; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.bars { display: flex; align-items: flex-end; gap: 12px; height: 160px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; height: 100%; font-size: 12px; color: var(--muted); }
.bar b { color: var(--text); font-weight: 600; font-size: 12px; }
.bar-track { flex: 1; width: 100%; max-width: 36px; display: flex; align-items: flex-end; border-bottom: 1px solid var(--line-strong); }
.bar-fill { width: 100%; min-height: 1px; background: var(--brand); border-radius: 2px 2px 0 0; }
.hbar { display: grid; grid-template-columns: minmax(90px, 150px) 1fr 32px; align-items: center; gap: 10px; padding: 4px 0; font-size: 13px; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 8px; background: var(--subtle); border: 1px solid var(--line); border-radius: 2px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--brand); }
.hbar b { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
ul.list { list-style: none; padding: 0; margin: 0; }
ul.list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
ul.list li:last-child { border-bottom: 0; }
ul.list li[data-open] { cursor: pointer; }
ul.list li[data-open]:hover b { color: var(--focus); }
ul.list .hint { margin: 0; display: block; }

.toast {
  position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); left: 50%; transform: translate(-50%, 120px);
  background: #24292f; color: #fff; padding: 9px 16px; border-radius: var(--radius); transition: transform .2s; z-index: 10;
  max-width: calc(100vw - 32px); box-shadow: var(--shadow-pop); font-size: 13px;
}
.toast.show { transform: translate(-50%, 0); }
.toast.err { background: var(--servis); }

/* ---------- tablet ---------- */
@media (max-width: 1000px) {
  .app-name, #settingsBtn #userName { display: none; }
  .detail-grid { grid-template-columns: 1fr; gap: 0; }
}

/* ---------- mobil: jeden sloupec na obrazovku, přepínání záložkami nebo tahem ---------- */
@media (max-width: 720px) {
  :root { --gutter: 12px; }
  body { font-size: 15px; }
  .hide-sm { display: none !important; }
  .appbar-row { height: auto; flex-wrap: wrap; gap: 4px 8px; padding-top: 8px; padding-bottom: 0; }
  .logo { height: 30px; }
  .appnav { order: 10; flex-basis: 100%; margin: 0; height: 40px; }
  .appnav button { flex: 1; }
  .search-wrap { order: 5; flex-basis: 100%; }
  #search { max-width: none; }
  .sync { margin-left: auto; }
  .sync #syncText { display: none; }
  .toolbar { padding: 8px var(--gutter); }
  .filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; width: 100%; }
  .filters::-webkit-scrollbar { display: none; }
  .filters select { flex: none; }
  .toolbar-actions { display: none; }

  .column-tabs {
    display: flex; gap: 0; overflow-x: auto; padding: 0 var(--gutter); scrollbar-width: none;
    background: var(--surface); border-bottom: 1px solid var(--line);
  }
  .column-tabs::-webkit-scrollbar { display: none; }
  .column-tabs button {
    gap: 6px; flex: none; border: 0; border-radius: 0; background: transparent; color: var(--muted); padding: 10px 12px; min-height: 0;
    box-shadow: inset 0 -2px 0 transparent; font-weight: 500;
  }
  .column-tabs button.active { color: var(--text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--brand); }
  .column-tabs .n { color: var(--faint); margin-left: 5px; font-weight: 400; }

  .board { gap: 0; padding: 10px 0 84px; scroll-snap-type: x mandatory; scrollbar-width: none; align-items: stretch; }
  .board::-webkit-scrollbar { display: none; }
  .column { flex: 0 0 100%; scroll-snap-align: start; background: transparent; border: 0; padding: 0 var(--gutter); max-height: none; }
  .column-head, .add-card { display: none; }
  .cards { padding: 0; overflow: visible; }
  .card { padding: 11px 12px 10px; margin-bottom: 8px; }
  .fab { display: inline-flex; }

  dialog, dialog.wide, #cardDialog {
    width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0;
    border-radius: 0; border: 0; padding: 16px var(--gutter) calc(20px + env(safe-area-inset-bottom));
  }
  #cardDialog { padding: 0; }
  #cardDetail { padding: 16px var(--gutter) 24px; }
  #cardDetail > .dialog-head { margin: -16px calc(-1 * var(--gutter)) 0; padding: 12px var(--gutter) 10px; }
  .grid2 { grid-template-columns: 1fr; }
  .invoice-dlg { grid-template-columns: 1fr; }
  .inv-row { grid-template-columns: 1fr 100px auto; }
  .status-buttons button { flex: 1 1 45%; border-radius: 0 !important; margin: -1px 0 0 -1px; }
  .actions { position: sticky; bottom: 0; background: var(--surface); padding-top: 10px; }
  .invoice-form .actions, #commentForm .actions { position: static; }
  .actions button { flex: 1; }
  .col-row, .user-row { grid-template-columns: 1fr 1fr; }
  .col-row input { grid-column: 1 / -1; }
  .stage-row { grid-template-columns: 40px 1fr; }
  .stage-row .stage-kind, .stage-row .hint { grid-column: 2; }
  .stage-row .row-buttons { grid-column: 1 / -1; }
  .stage-add { grid-template-columns: 1fr 40px; }
  .stage-add select, .stage-add button { grid-column: 1 / -1; }
  .auth-box { padding: 22px 18px; }
  .steps li { font-size: 0; }
  .steps li.current { font-size: 12px; }
  .stats { padding-top: 12px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 20px; }
  .stats-grid { grid-template-columns: 1fr; }
}
