/* ==========================================================================
   CRM Ratajovi — design tokens
   ========================================================================== */
:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --subtle: #eef2f6;
  --concealed: #f9fafb;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #4b5563;
  --text-3: #64748b;
  --field-line: #8792a2;
  --done: #237f42;
  --brand: #4f46e5;
  --brand-strong: #4338ca;
  --brand-soft: #eef2ff;
  --on-brand: #ffffff;
  --focus: rgb(99 102 241 / 40%);
  --ok-bg: #e3f4e6; --ok-fg: #1f6b35; --ok-line: #b9e2c2;
  --row-packed: #edf8ef; --row-packed-hover: #e2f3e5; --row-packed-line: #c6e7cd;
  --row-unpaid: #fdecea; --row-unpaid-hover: #fbe0dc; --row-unpaid-line: #f3c4bd;
  --err-bg: #fde8e6; --err-fg: #a4241c; --err-line: #f5c2bd;
  --qty-fg: #c0261b;
  --warn-bg: #fef9c3; --warn-fg: #c2410c; --warn-line: #fde047;

  --s-new-bg: #e5eefc; --s-new-fg: #1e4fae;
  --s-in_progress-bg: #cffafe; --s-in_progress-fg: #0e7490;
  --s-packed-bg: #ebe5fb; --s-packed-fg: #5537ad;
  --s-review-bg: #fde2df; --s-review-fg: #ad2419;
  --s-cancelled-bg: #eef2f6; --s-cancelled-fg: #64748b;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / 5%), 0 1px 1px rgb(15 23 42 / 3%);
  --shadow: 0 1px 2px rgb(15 23 42 / 5%), 0 8px 24px -6px rgb(15 23 42 / 10%);
  --shadow-lg: 0 12px 40px -8px rgb(15 23 42 / 22%);
  --topbar-h: 60px;
  --side-w: 68px;
  --tabbar-h: 64px;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23848fa0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: oklch(27.8% .033 256.848); /* #1e293b */
  --surface: #253247;
  --surface-2: #2a384d;
  --subtle: #334155;
  --concealed: #43536b;
  --line: #3a4a61;
  --line-strong: #4f6079;
  --text: #f1f5f9;
  --text-2: #b4c0d0;
  --text-3: #a0acbe;
  --field-line: #74859e;
  --brand: #a5b4fc;
  --brand-strong: #c7d2fe;
  --brand-soft: rgb(129 140 248 / 16%);
  --on-brand: #1e1b4b;
  --focus: rgb(165 180 252 / 45%);
  --ok-bg: rgb(52 168 83 / 16%); --ok-fg: #8fdca5; --ok-line: rgb(52 168 83 / 35%);
  --row-packed: rgb(52 168 83 / 11%); --row-packed-hover: rgb(52 168 83 / 16%); --row-packed-line: rgb(52 168 83 / 32%);
  --row-unpaid: rgb(235 87 70 / 13%); --row-unpaid-hover: rgb(235 87 70 / 19%); --row-unpaid-line: rgb(235 87 70 / 36%);
  --err-bg: rgb(235 87 70 / 16%); --err-fg: #ffb2a8; --err-line: rgb(235 87 70 / 38%);
  --qty-fg: #ff6f61;
  --warn-bg: #334155; --warn-fg: #fdba74; --warn-line: rgb(250 204 21 / 45%);

  --s-new-bg: rgb(80 140 245 / 18%); --s-new-fg: #a9c8ff;
  --s-in_progress-bg: rgb(34 211 238 / 16%); --s-in_progress-fg: #67e8f9;
  --s-packed-bg: rgb(150 120 245 / 20%); --s-packed-fg: #c8b8ff;
  --s-review-bg: rgb(235 87 70 / 20%); --s-review-fg: #ffaea4;
  --s-cancelled-bg: rgb(148 163 184 / 16%); --s-cancelled-fg: #b4c0d0;

  --shadow-sm: 0 1px 2px rgb(2 6 23 / 30%);
  --shadow: 0 1px 2px rgb(2 6 23 / 30%), 0 8px 24px -6px rgb(2 6 23 / 40%);
  --shadow-lg: 0 16px 48px -8px rgb(0 0 0 / 60%);
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--text); background: var(--bg);
  font: 15.5px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
[id] { scroll-margin-top: calc(var(--topbar-h) + 1rem); }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.015em; }
h1 { font-size: clamp(1.45rem, 1.1rem + 1.1vw, 1.9rem); font-weight: 720; letter-spacing: -.025em; }
h2 { font-size: 1.1rem; font-weight: 680; }
p { margin: 0; }
a { color: var(--brand); text-underline-offset: .18em; }
a:hover { color: var(--brand-strong); }
code { padding: .05rem .35rem; font: .84em/1.4 var(--mono); color: var(--text); background: var(--subtle); border-radius: 5px; overflow-wrap: anywhere; }
img { max-width: 100%; }
.icon { width: 1.15em; height: 1.15em; flex: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 1rem; top: -4rem; z-index: 100; padding: .6rem 1rem; color: var(--on-brand); background: var(--brand); border-radius: var(--radius-sm); font-weight: 650; text-decoration: none; }
.skip-link:focus { top: .75rem; }
.muted, .sub, .note { color: var(--text-2); }
.lead { max-width: 72ch; margin: 0 0 1.25rem; color: var(--text-2); }
.scope { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: -.5rem 0 1.25rem; color: var(--text-2); font-size: .85rem; font-weight: 600; }
.note { margin-top: .75rem; font-size: .85rem; }
.unknown { color: var(--warn-fg); font-weight: 650; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Top bar & navigation
   ========================================================================== */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(160%) blur(12px); backdrop-filter: saturate(160%) blur(12px);
}
.topbar-inner { display: flex; align-items: center; gap: 1.25rem; width: min(100%, 1440px); height: var(--topbar-h); margin: 0 auto; padding: 0 clamp(1rem, 3vw, 2rem); }
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: .2rem; color: var(--text); text-decoration: none; flex: none; }
.brand:hover { color: var(--text); }
.brand-logo { display: block; font-size: 1.05rem; font-weight: 700; line-height: 1.1; white-space: nowrap; }
.brand-sub { color: var(--text-2); font-size: .74rem; font-weight: 550; line-height: 1; letter-spacing: 0; }
.topbar-actions { display: flex; align-items: center; gap: .4rem; margin-left: auto; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; color: var(--text-2); background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer; }
.icon-btn:hover { color: var(--text); background: var(--subtle); }
.icon-btn .icon { width: 20px; height: 20px; }
.theme-toggle .icon:nth-of-type(2) { display: none; }
:root[data-theme="dark"] .theme-toggle .icon:nth-of-type(1) { display: none; }
:root[data-theme="dark"] .theme-toggle .icon:nth-of-type(2) { display: block; }

/* Side menu (desktop): a strip of icons; on hover or keyboard focus it widens over the page and shows the names. */
.nav-side { display: none; }
@media (min-width: 1080px) {
  body.has-user { --topbar-h: 0px; padding-left: var(--side-w); }
  body.has-user .topbar { display: none; }
  .nav-side {
    position: fixed; inset: 0 auto 0 0; z-index: 60; display: flex; flex-direction: column; gap: .5rem;
    width: var(--side-w); padding: .75rem 10px; overflow: hidden;
    background: var(--surface); border-right: 1px solid var(--line);
    transition: width .18s ease, box-shadow .18s ease;
  }
  .nav-side:hover, .nav-side:focus-within { width: 240px; box-shadow: var(--shadow-lg); }
  .side-brand { display: flex; align-items: center; gap: .75rem; min-height: 52px; padding: 0 6px; color: var(--text); text-decoration: none; border-radius: var(--radius-sm); }
  .side-brand:hover { color: var(--text); }
  .side-mark { flex: none; width: 36px; height: 36px; border-radius: 9px; }
  .side-label { display: flex; flex-direction: column; gap: .2rem; }
  .side-label .brand-logo { font-size: .95rem; }
  .side-links { display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; overflow: hidden auto; scrollbar-width: none; }
  .side-sep { flex: none; height: 1px; margin: .45rem 8px; background: var(--line); }
  .side-foot { display: flex; flex-direction: column; gap: 2px; padding-top: .5rem; border-top: 1px solid var(--line); }
  .side-foot form { margin: 0; }
  .side-link {
    display: flex; align-items: center; gap: .9rem; width: 100%; min-height: 44px; padding: .35rem 14px;
    color: var(--text-2); background: transparent; border: 0; border-radius: var(--radius-sm);
    font: inherit; font-size: .92rem; font-weight: 600; text-align: left; text-decoration: none; white-space: nowrap; cursor: pointer;
    transition: background-color .15s, color .15s;
  }
  .side-link:hover { color: var(--text); background: var(--subtle); }
  .side-link[aria-current="page"] { color: var(--brand-strong); background: var(--brand-soft); }
  .side-link .icon { width: 20px; height: 20px; }
  .side-label, .side-link > span { min-width: 0; opacity: 0; transition: opacity .12s; }
  .nav-side:hover :is(.side-label, .side-link > span), .nav-side:focus-within :is(.side-label, .side-link > span) { opacity: 1; transition-delay: .06s; }
  .side-user { display: flex; flex-direction: column; overflow: hidden; line-height: 1.25; text-overflow: ellipsis; }
  .side-user small { color: var(--text-2); font-size: .76rem; font-weight: 550; }
}
@media (prefers-reduced-motion: reduce) {
  .nav-side, .side-label, .side-link > span { transition: none; }
}

/* Bottom tab bar (phones & tablets) */
.nav-bottom { display: none; }
@media (max-width: 1079px) {
  body.has-user { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .nav-bottom {
    position: fixed; inset: auto 0 0 0; z-index: 50; display: grid; grid-template-columns: repeat(4, 1fr);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 0 .25rem env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 92%, transparent); border-top: 1px solid var(--line);
    -webkit-backdrop-filter: saturate(160%) blur(12px); backdrop-filter: saturate(160%) blur(12px);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem;
    height: var(--tabbar-h); color: var(--text-2); font-size: .72rem; font-weight: 650; text-decoration: none;
    list-style: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .tab::-webkit-details-marker { display: none; }
  .tab .icon { width: 44px; height: 28px; padding: 3px 11px; border-radius: 999px; transition: background-color .15s; }
  .tab[aria-current="page"], .tab[data-active="true"], .tab-more[open] > .tab { color: var(--brand-strong); }
  .tab[aria-current="page"] .icon, .tab[data-active="true"] .icon, .tab-more[open] > .tab .icon { background: var(--brand-soft); }
  .tab:hover { color: var(--text); }
  .more-menu {
    position: absolute; right: .5rem; bottom: calc(100% + .5rem); width: min(290px, calc(100vw - 1rem));
    padding: .4rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  }
  .more-user { display: flex; flex-direction: column; padding: .6rem .75rem .7rem; margin-bottom: .3rem; font-weight: 680; border-bottom: 1px solid var(--line); }
  .more-user span { color: var(--text-2); font-size: .8rem; font-weight: 550; }
  .more-link {
    display: flex; align-items: center; gap: .75rem; width: 100%; min-height: 46px; padding: .5rem .75rem;
    color: var(--text); background: transparent; border: 0; border-radius: var(--radius-sm); font: inherit; font-weight: 600; text-align: left; text-decoration: none; cursor: pointer;
  }
  .more-link:hover { color: var(--text); background: var(--subtle); }
  .more-link[aria-current="page"] { color: var(--brand-strong); background: var(--brand-soft); }
  .more-link .icon { width: 20px; height: 20px; color: var(--text-2); }
  .more-menu form { margin: .3rem 0 0; padding-top: .3rem; border-top: 1px solid var(--line); }
}

/* ==========================================================================
   Page layout
   ========================================================================== */
.page { width: min(100%, 1440px); margin: 0 auto; padding: clamp(1.25rem, 2.5vw, 2rem) clamp(1rem, 3vw, 2rem) 3rem; }
.page-head { display: grid; gap: .35rem; margin-bottom: 1.25rem; }
.page-title { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; }
.page-actions { display: flex; align-items: flex-start; gap: .5rem; margin-left: auto; }
.import-form { display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; margin: 0; }
.import-info { color: var(--text-2); font-size: .78rem; }
.import-form.is-busy .btn { opacity: .75; cursor: progress; }
.import-form.is-busy .icon { animation: pulse 1s ease-in-out infinite; }
.import-fallback { margin-top: .35rem; }
.shop-state { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; }
.shop-badge { display: inline-flex; align-items: center; padding: .1rem .5rem; color: var(--text-2); background: var(--subtle); border-radius: 999px; font-size: .75rem; font-weight: 650; white-space: nowrap; text-decoration: none; }
a.shop-badge:hover { color: var(--text); }
.shop-unpaid { color: var(--surface); background: var(--qty-fg); } /* solid, so it stands out on the red row */
.paid-dot { display: inline-block; width: .6rem; height: .6rem; margin-left: .4rem; border-radius: 50%; background: var(--done); vertical-align: .05em; }
.shop-cancelled { color: var(--err-fg); background: var(--err-bg); }
/* zaslat.cz shipment state: waiting for the courier, on its way, delivered, cancelled, missing at zaslat.cz. */
.ship-wait { color: var(--warn-fg); background: var(--warn-bg); }
.ship-go { color: var(--s-new-fg); background: var(--s-new-bg); }
.ship-ok { color: var(--ok-fg); background: var(--ok-bg); }
.ship-off { color: var(--s-cancelled-fg); background: var(--s-cancelled-bg); }
.ship-none, .ship-damaged { color: var(--err-fg); background: var(--err-bg); }
.shop-wholesale { color: var(--s-in_progress-fg); background: var(--s-in_progress-bg); }
.channel-table tbody th { padding: .75rem 1rem; color: var(--text); background: none; border-bottom: 1px solid var(--line); font-size: .93rem; letter-spacing: 0; text-transform: none; }
.channel-table tbody tr:last-child th { border-bottom: 0; }
@keyframes pulse { 50% { opacity: .3; } }
.back-link { display: inline-flex; align-items: center; gap: .2rem; width: fit-content; margin-left: -.3rem; padding: .2rem .3rem; color: var(--text-2); border-radius: 6px; font-size: .88rem; font-weight: 600; text-decoration: none; }
.back-link:hover { color: var(--brand-strong); }
.page-auth { width: min(100%, 440px); padding-top: clamp(2rem, 9vh, 5rem); }
.page-auth .page-head { text-align: center; }
.page-auth .page-title { justify-content: center; }
.auth-form { display: grid; gap: 1rem; padding: 1.5rem; }
.auth-lead { color: var(--text-2); text-align: center; }

/* ==========================================================================
   Surfaces
   ========================================================================== */
.panel { margin: 0 0 1rem; padding: 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel-title { margin-bottom: .9rem; font-size: .8rem; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; }
.panel.narrow { max-width: 560px; }
.section-title { display: flex; align-items: center; gap: .5rem; margin: 0 0 .75rem; }
.count { padding: .05rem .5rem; color: var(--text-2); background: var(--subtle); border-radius: 999px; font-size: .78rem; font-weight: 650; }
.empty { padding: 2.5rem 1rem; color: var(--text-2); text-align: center; background: var(--surface-2); border: 1.5px dashed var(--line-strong); border-radius: var(--radius); }
.panel.disclosure { padding: 0; }
.disclosure > summary { display: flex; align-items: center; gap: .55rem; padding: .95rem 1.25rem; color: var(--brand-strong); font-weight: 680; list-style: none; cursor: pointer; border-radius: var(--radius); }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary:hover { background: var(--surface-2); }
.disclosure > summary .icon { transition: transform .2s; }
.disclosure[open] > summary { border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
.disclosure[open] > summary .icon { transform: rotate(45deg); }
.disclosure > :not(summary) { margin: 1.1rem 1.25rem; }
.disclosure > .note { margin-top: -.4rem; }

/* Notices */
.notice { display: flex; align-items: flex-start; gap: .7rem; margin: 0 0 1rem; padding: .85rem 1rem; border: 1px solid; border-radius: var(--radius-sm); font-weight: 520; }
.notice .icon { width: 20px; height: 20px; margin-top: .05rem; }
.notice-success { color: var(--ok-fg); background: var(--ok-bg); border-color: var(--ok-line); }
.notice-error { color: var(--err-fg); background: var(--err-bg); border-color: var(--err-line); }
.notice-warn { color: var(--warn-fg); background: var(--warn-bg); border-color: var(--warn-line); }
.error { padding: .85rem 1rem; color: var(--err-fg); background: var(--err-bg); border: 1px solid var(--err-line); border-radius: var(--radius-sm); }

/* Badges & status colours */
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .18rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 680; line-height: 1.4; white-space: nowrap; }
.badge[class*=" s-"]::before, .dot { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.dot { display: inline-block; flex: none; }
.s-new { --s-bg: var(--s-new-bg); --s-fg: var(--s-new-fg); }
.s-in_progress { --s-bg: var(--s-in_progress-bg); --s-fg: var(--s-in_progress-fg); }
.s-packed { --s-bg: var(--s-packed-bg); --s-fg: var(--s-packed-fg); }
.s-review { --s-bg: var(--s-review-bg); --s-fg: var(--s-review-fg); }
.s-cancelled { --s-bg: var(--s-cancelled-bg); --s-fg: var(--s-cancelled-fg); }
.badge[class*=" s-"] { color: var(--s-fg); background: var(--s-bg); }
.dot[class*=" s-"] { background: var(--s-fg); }
.badge-ok { color: var(--ok-fg); background: var(--ok-bg); }
.badge-muted { color: var(--s-cancelled-fg); background: var(--s-cancelled-bg); }

/* ==========================================================================
   Controls
   ========================================================================== */
button { font: inherit; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: .55rem .8rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--field-line); border-radius: var(--radius-sm); font: inherit; font-size: max(16px, .95rem);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--text-3); }
input:hover, select:hover, textarea:hover { border-color: var(--text-2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus); }
select { padding-right: 2.2rem; appearance: none; background-image: var(--chevron); background-repeat: no-repeat; background-position: right .75rem center; cursor: pointer; }
input[type="number"] { font-variant-numeric: tabular-nums; }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field-label { color: var(--text-2); font-size: .82rem; font-weight: 650; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 44px; padding: 0 1.05rem;
  color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font-weight: 650; line-height: 1.2; text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s, transform .1s;
}
.btn:hover { color: var(--text); background: var(--subtle); }
.btn:active { transform: translateY(1px); }
.btn-primary { color: var(--on-brand); background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { color: var(--on-brand); background: var(--brand-strong); border-color: var(--brand-strong); }
.btn-secondary { background: var(--surface); }
.btn-ghost { color: var(--text-2); background: transparent; border-color: transparent; }
.btn-ghost:hover { color: var(--text); background: var(--subtle); }
.btn-sm { min-height: 36px; padding: 0 .8rem; font-size: .86rem; }
.btn-block { width: 100%; }
.btn .icon { width: 18px; height: 18px; }
.input-suffix { display: flex; align-items: stretch; }
.input-suffix input { max-width: 8rem; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-suffix span { display: flex; align-items: center; padding: 0 .85rem; color: var(--text-2); background: var(--subtle); border: 1px solid var(--field-line); border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-weight: 600; }
.stack { display: grid; gap: .9rem; }
.stack .note { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: .9rem; align-items: end; }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; grid-column: 1 / -1; }
@media (min-width: 720px) { .form-grid .field-wide { grid-column: span 2; } }

/* Inline edit: select/input with a save button that app.js reveals once the value changes */
.inline-edit { display: flex; align-items: center; gap: .4rem; margin: 0; }
.inline-edit select, .inline-edit input { min-height: 38px; padding-top: .35rem; padding-bottom: .35rem; font-size: .9rem; }
/* Space stays reserved so revealing the button does not shift the layout. */
.js .inline-edit .save-btn { visibility: hidden; }
.js .inline-edit.is-dirty .save-btn { visibility: visible; }
.inline-edit.is-saving { opacity: .55; pointer-events: none; }
.status-select { width: auto; min-width: 11.5rem; color: var(--s-fg); background-color: var(--s-bg); border-color: transparent; font-weight: 680; }
.status-select:hover { border-color: var(--s-fg); }
.status-select option { color: var(--text); background: var(--surface); font-weight: 500; }
.maker-select { min-width: 10rem; max-width: 15rem; }
.maker-pick { position: relative; display: inline-flex; align-items: center; gap: .3rem; min-width: 38px; height: 34px; padding: 0 .55rem; color: var(--text-3); border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer; }
.maker-pick:hover, .maker-pick:focus-within { color: var(--brand-strong); background: var(--brand-soft); border-color: var(--line); }
.maker-pick:focus-within { box-shadow: 0 0 0 3px var(--focus); }
.maker-pick.is-set { color: var(--brand-strong); }
.maker-pick .icon { width: 15px; height: 15px; }
.maker-initials { font-size: .8rem; font-weight: 700; letter-spacing: .02em; }
.maker-pick .maker-select { position: absolute; inset: 0; width: 100%; min-width: 0; max-width: none; min-height: 0; height: 100%; padding: 0; opacity: 0; cursor: pointer; }
.js .maker-compact .save-btn { display: none; }
.rate-form { justify-content: flex-end; }
.rate-form input { width: 5.5rem; text-align: right; }

/* ==========================================================================
   Plan dashboard
   ========================================================================== */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .85rem; }
.kpi {
  display: grid; grid-template-rows: auto auto auto 1fr; gap: .15rem; padding: 1rem 1.15rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); text-decoration: none;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
a.kpi:hover { color: var(--text); border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.kpi-label { display: flex; align-items: center; gap: .45rem; color: var(--text-2); font-size: .85rem; font-weight: 650; }
.kpi-value { font-size: 1.9rem; font-weight: 750; line-height: 1.15; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--text-2); font-size: .82rem; }
.kpi-accent { background: var(--brand-soft); border-color: transparent; }
.kpi-warn { background: var(--s-review-bg); border-color: transparent; }
.kpi-warn .kpi-value, .kpi-warn .kpi-label { color: var(--s-review-fg); }
.kpi-accent .kpi-value { color: var(--brand-strong); }
.kpis + .note { margin: .6rem 0 0; }
.workload { margin: 1rem 0 0; }
.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.perf-makers { margin-top: 1rem; }
.perf-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .75rem; }
.perf-head .panel-title { margin: 0; }
.perf-periods { display: flex; flex-wrap: wrap; gap: .4rem; }
.stats-periods { margin: 0 0 1rem; }
.stats-section { margin-top: 1rem; }
.stats-section .table-wrap { box-shadow: none; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 28rem), 1fr)); gap: 0 1rem; align-items: start; }
.stats-grid .workload-list li { grid-template-columns: minmax(6.5rem, 9rem) minmax(0, 1fr) minmax(9rem, auto); }
.month-nav { display: flex; align-items: center; gap: .5rem; }
.month-label { min-width: 8.5rem; font-weight: 650; text-align: center; }
.page-tabs { margin-bottom: 1rem; }
.form-grid .field-full { grid-column: 1 / -1; }
.partner-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); gap: .75rem; margin: 0; padding: 0; list-style: none; }
.partner-card { display: grid; gap: .3rem; margin: 0; color: inherit; text-decoration: none; }
.partner-card:hover { border-color: var(--brand); }
.partner-card.is-inactive { opacity: .6; }
.partner-name { font-size: 1.1rem; font-weight: 700; }
/* Partner price list: a readable column, not the whole screen width. */
.page-partner .page-head, .page-partner > .notice, .page-partner > .panel, .page-partner > .empty { max-width: 920px; margin-left: auto; margin-right: auto; }
.partner-summary { display: grid; gap: .9rem; }
.partner-facts { display: flex; flex-wrap: wrap; gap: .75rem 2.5rem; margin: 0; }
.partner-facts dt { color: var(--text-2); font-size: .8rem; font-weight: 650; }
.partner-facts dd { margin: .15rem 0 0; font-size: 1.05rem; font-weight: 700; }
.partner-facts .partner-note { flex-basis: 100%; }
.partner-facts .partner-note dd { font-weight: 500; }
.partner-edit > summary { display: inline-flex; align-items: center; gap: .45rem; color: var(--brand-strong); font-weight: 650; cursor: pointer; }
.partner-edit > summary .icon { width: 1.1rem; height: 1.1rem; }
.partner-edit[open] > summary { margin-bottom: .9rem; }
.partner-add { display: grid; grid-template-columns: minmax(0, 1fr) 11rem auto; align-items: end; gap: .75rem; }
.partner-add .panel-title { grid-column: 1 / -1; margin: 0; }
.partner-add .input-suffix input { width: 100%; max-width: none; }
.partner-add .btn { min-height: 42px; }
.partner-prices .panel-title { margin-bottom: .6rem; }
.partner-prices .table-wrap { margin: 0 -.25rem; border: 0; box-shadow: none; background: transparent; }
.wholesale-table th:nth-child(2), .wholesale-table th:nth-child(3) { width: 11rem; }
.wholesale-table th:last-child { width: 3rem; }
.wholesale-table td { vertical-align: middle; }
.wholesale-table .c-price .price-form { justify-content: flex-end; }
.wholesale-table .c-price .input-suffix input { width: 6rem; text-align: right; font-size: 1.15rem; font-weight: 800; color: var(--text); }
.wholesale-table .c-price .input-suffix span { font-weight: 700; }
.js .wholesale-table .price-form:not(.is-dirty) .save-btn { display: none; }
.wholesale-table .c-profit strong { color: var(--text-2); font-size: .92rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.wholesale-table .c-profit .sub { color: var(--text-2); font-size: .78rem; }
.wholesale-table .is-negative, .wholesale-table .c-profit strong.is-negative { color: var(--err-fg); }
.remove-btn { width: 2.25rem; height: 2.25rem; color: var(--text-2); font-size: 1rem; }
.remove-btn:hover { color: var(--err-fg); background: var(--err-bg); }
.purchase-periods { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.purchase-subtitle { margin: 1.4rem 0 .6rem; font-size: 1rem; }
.purchase-table td { vertical-align: top; }
.purchase-table .c-actions { width: 1%; text-align: right; }
.expense-form { margin-bottom: 1rem; }
.expense-wrap { margin-top: .25rem; }
.expense-table tfoot th { padding-top: .7rem; border-top: 1px solid var(--line-strong); font-variant-numeric: tabular-nums; }
.expense-table .c-actions { width: 1%; text-align: right; }
.cost-list { display: grid; gap: .55rem; margin: .9rem 0 0; padding: 0; list-style: none; }
.cost-form { flex-wrap: wrap; }
.cost-name { flex: 1 1 10rem; min-width: 0; font-weight: 650; overflow-wrap: anywhere; }
.cost-form .input-suffix input { width: 5.5rem; }
.money-trend th, .money-trend td { white-space: nowrap; font-variant-numeric: tabular-nums; }
.money-trend .is-negative { color: var(--err-fg); }
/* Obrat a zisk (money.php): toolbar, tiles and the bar chart from barChartSvg(); the hover bubble comes from app.js. */
:root {
  --c-revenue: #6366f1; --c-revenue-2: #a5b4fc;
  --c-net: #10b981; --c-net-2: #6ee7b7;
  --c-orders: #0ea5e9; --c-orders-2: #7dd3fc;
  --c-costs: #f59e0b;
  --c-loss: #f43f5e;
  --c-up: #059669; --c-up-bg: rgb(16 185 129 / 12%);
  --c-down: #e11d48; --c-down-bg: rgb(244 63 94 / 11%);
}
:root[data-theme="dark"] {
  --c-revenue: #818cf8; --c-revenue-2: #4f46e5;
  --c-net: #34d399; --c-net-2: #059669;
  --c-orders: #38bdf8; --c-orders-2: #0284c7;
  --c-costs: #fbbf24;
  --c-loss: #fb7185;
  --c-up: #6ee7b7; --c-up-bg: rgb(52 211 153 / 14%);
  --c-down: #fda4af; --c-down-bg: rgb(251 113 133 / 14%);
}
.page-money .page-head { margin-bottom: .9rem; }
.page-money .page-title { gap: .6rem 1rem; }
.page-money .page-title .page-tabs { margin: 0; }
.page-money .page-actions { align-items: center; }
.money-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .6rem; }
.period-nav { display: inline-flex; align-items: center; gap: .15rem; padding: .2rem; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow-sm); }
.period-arrow { display: grid; place-items: center; width: 2rem; height: 2rem; color: var(--text-2); font-size: 1.25rem; line-height: 1; text-decoration: none; border-radius: 999px; transition: background .12s, color .12s; }
a.period-arrow:hover { color: var(--text); background: var(--subtle); }
.period-arrow.is-disabled { opacity: .3; }
.period-label { min-width: 5.5rem; padding: 0 .4rem; font-weight: 720; text-align: center; font-variant-numeric: tabular-nums; }
.period-back { color: var(--text-2); font-size: .9rem; font-weight: 600; text-decoration: none; }
.period-back:hover { color: var(--text); }
.segmented { display: inline-flex; gap: .15rem; padding: .2rem; background: var(--subtle); border-radius: 999px; }
.segment { padding: .42rem .95rem; color: var(--text-2); font-size: .9rem; font-weight: 650; text-decoration: none; border-radius: 999px; transition: background .12s, color .12s; }
.segment:hover { color: var(--text); }
.segment[aria-current="page"] { color: var(--text); background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / 12%); }
.segment-revenue[aria-current="page"] { color: var(--c-revenue); }
.segment-net[aria-current="page"] { color: var(--c-net); }
.segment-orders[aria-current="page"] { color: var(--c-orders); }
.money-kpis { margin-bottom: .9rem; }
.money-kpis .kpi { grid-template-rows: auto auto auto; padding: .65rem 1rem; gap: .1rem; }
.money-kpis .kpi-value { font-size: clamp(1.15rem, 4.6vw, 1.45rem); }
.money-kpis .kpi-value.is-negative { color: var(--c-loss); }
.money-kpis .kpi-sub { font-size: .78rem; }
.kpi-dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--text-3); }
.kpi-revenue .kpi-dot { background: var(--c-revenue); }
.kpi-profit .kpi-dot { background: var(--c-net-2); }
.kpi-costs .kpi-dot { background: var(--c-costs); }
.kpi-net .kpi-dot { background: var(--c-net); }
.kpi-net { border-color: color-mix(in srgb, var(--c-net) 40%, var(--line)); }
.trend { display: inline-block; padding: 0 .35rem; font-weight: 700; border-radius: 999px; font-variant-numeric: tabular-nums; }
.trend.is-up { color: var(--c-up); background: var(--c-up-bg); }
.trend.is-down { color: var(--c-down); background: var(--c-down-bg); }
.chart-card { padding: 1rem 1.1rem .8rem; }
.chart-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .3rem 1rem; margin-bottom: .3rem; }
.chart-title { margin: 0; font-size: 1rem; font-weight: 720; }
.chart-legend { display: flex; gap: 1rem; margin: 0; color: var(--text-2); font-size: .82rem; }
.legend-item { display: inline-flex; align-items: center; gap: .4rem; }
.legend-bar { width: .8rem; height: .8rem; border-radius: 3px; background: var(--c-revenue); }
.chart-net .legend-bar { background: var(--c-net); }
.chart-orders .legend-bar { background: var(--c-orders); }
.legend-compare { width: .8rem; height: .8rem; border: 1.5px dashed var(--text-3); border-radius: 3px; }
.chart-box { position: relative; }
.chart { display: block; width: 100%; height: auto; max-height: 460px; font-family: inherit; overflow: visible; }
.chart-medium, .chart-narrow, .chart-narrow-note { display: none; }
@media (max-width: 1099px) {
  .chart-wide { display: none; }
  .chart-medium { display: block; }
}
.money-main { display: flex; flex-direction: column; }
@media (max-width: 639px) {
  .money-main .chart-card { order: -1; }
  .money-kpis .kpi { padding: .65rem .8rem; }
  .money-kpis .kpi-label { font-size: .78rem; }
  .money-kpis .kpi-sub [title] { display: none; }
  .chart-medium { display: none; }
  .chart-narrow { display: block; max-height: none; }
  .chart-narrow-note { display: inline; }
  .money-toolbar { justify-content: stretch; }
  .segmented { flex: 1 1 100%; }
  .segment { flex: 1; text-align: center; }
}
.chart-revenue .chart-stop-1 { stop-color: var(--c-revenue); }
.chart-revenue .chart-stop-2 { stop-color: var(--c-revenue-2); }
.chart-net .chart-stop-1 { stop-color: var(--c-net); }
.chart-net .chart-stop-2 { stop-color: var(--c-net-2); }
.chart-orders .chart-stop-1 { stop-color: var(--c-orders); }
.chart-orders .chart-stop-2 { stop-color: var(--c-orders-2); }
.chart-grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.chart-zero { stroke: var(--line-strong); stroke-width: 1.2; }
.chart-axis { fill: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart-label { fill: var(--text-2); font-size: 13px; }
.chart-value { fill: var(--text); font-size: 12.5px; font-weight: 680; font-variant-numeric: tabular-nums; }
.chart-value.is-negative { fill: var(--c-loss); }
.chart-narrow .chart-axis, .chart-narrow .chart-label { font-size: 11px; }
.chart-narrow .chart-value { font-size: 10.5px; }
.chart-bar { transition: opacity .15s; }
.chart-bar.is-negative { fill: var(--c-loss); }
.chart-compare { fill: none; stroke: var(--text-3); stroke-width: 1.3; stroke-dasharray: 4 3; opacity: .7; }
.chart-hit { fill: transparent; pointer-events: all; transition: fill .12s; }
.chart-col { cursor: pointer; outline: none; }
.chart-col:hover .chart-hit, .chart-col:focus-visible .chart-hit, .chart-col.is-active .chart-hit { fill: color-mix(in srgb, var(--text) 6%, transparent); }
.chart-box:has(.chart-col:hover) .chart-col:not(:hover) .chart-bar { opacity: .55; }
.chart-tip {
  position: absolute; z-index: 5; min-width: 10rem; padding: .55rem .7rem; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow-lg); font-size: .82rem; line-height: 1.45; pointer-events: none; font-variant-numeric: tabular-nums;
}
.chart-tip[hidden] { display: none; }
.chart-tip strong { display: block; margin-bottom: .15rem; font-size: .88rem; }
.chart-tip .tip-hint { margin-top: .25rem; color: var(--text-3); font-size: .75rem; }
.chart-note { margin: .4rem 0 0; color: var(--text-3); font-size: .8rem; }
.money-trend a { font-weight: 650; }
@media (max-width: 719px) {
  .money-trend th:nth-child(2), .money-trend td:nth-child(2), .money-trend th:nth-child(4), .money-trend td:nth-child(4), .money-trend th:nth-child(5), .money-trend td:nth-child(5) { display: none; }
}
.stats-product { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.stats-thumb { display: block; flex: none; width: 36px; height: 36px; object-fit: contain; background: var(--subtle); border-radius: 8px; }
.stats-name { display: block; font-weight: 650; }
.stats-code { color: var(--text-2); font-size: .78rem; }
.stats-share-col { width: 28%; }
.sort-link { color: inherit; text-decoration: none; }
.sort-link:hover { color: var(--text); text-decoration: underline; }
.sort-link.is-active { color: var(--text); }
.stats-share { display: grid; grid-template-columns: minmax(4rem, 1fr) 3.6rem; align-items: center; gap: .6rem; font-size: .85rem; font-variant-numeric: tabular-nums; text-align: right; }
.stats-share progress { height: 8px; }
@media (max-width: 719px) {
  .stats-table th:first-child, .stats-table td:first-child, .stats-table th:nth-child(4), .stats-table td:nth-child(4), .stats-table .stats-share-col { display: none; }
  .data-table.stats-table th, .data-table.stats-table td { padding: .6rem .35rem; }
  .data-table.stats-table th { letter-spacing: 0; }
  .stats-table td.num { font-size: .85rem; white-space: nowrap; }
  .stats-table .stats-thumb { display: none; }
  .stats-grid .workload-list li { grid-template-columns: minmax(0, 1fr) auto; }
}
.workload-list { display: grid; gap: .6rem; margin: 0; padding: 0; list-style: none; }
.workload-list li { display: grid; grid-template-columns: minmax(8rem, 12rem) minmax(0, 1fr) minmax(12rem, auto); align-items: center; gap: .9rem; }
.workload-name { overflow: hidden; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
a.workload-name { color: var(--text); text-decoration: none; }
a.workload-name:hover { color: var(--brand); text-decoration: underline; }
.workload progress, .stats-share progress { width: 100%; height: 10px; appearance: none; border: 0; border-radius: 999px; background: var(--subtle); overflow: hidden; }
:is(.workload, .stats-share) progress::-webkit-progress-bar { background: var(--subtle); border-radius: 999px; }
:is(.workload, .stats-share) progress::-webkit-progress-value { background: var(--brand); border-radius: 999px; }
:is(.workload, .stats-share) progress::-moz-progress-bar { background: var(--brand); border-radius: 999px; }
.workload-value { color: var(--text-2); font-size: .85rem; white-space: nowrap; }
.workload-value strong { color: var(--text); }
.workload .note { margin-top: .75rem; }

/* Tisk etiket */
.label-group { margin-top: 1.25rem; }
.label-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .75rem; margin: .5rem 0 0; padding: 0; list-style: none; }
.label-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; align-items: center; gap: .1rem .85rem; height: 100%;
  padding: .85rem 1rem; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); text-decoration: none; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.label-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.pdf-icon { position: relative; grid-row: 1 / 3; display: block; width: 2.6rem; height: 2.6rem; color: #d93025; }
.pdf-icon svg { width: 100%; height: 100%; }
.pdf-icon span { position: absolute; left: 0; bottom: .35rem; padding: .05rem .25rem; color: #fff; background: #d93025; border-radius: 3px; font-size: .58rem; font-weight: 800; letter-spacing: .03em; }
.label-name { align-self: end; font-weight: 650; line-height: 1.25; }
.label-size { align-self: start; color: var(--text-2); font-size: .8rem; }
.kpi-carriers { align-self: end; display: flex; flex-wrap: wrap; gap: .3rem .6rem; margin-top: .45rem; padding-top: .5rem; border-top: 1px solid var(--line); }
.kpi-carrier { display: inline-flex; align-items: center; gap: .3rem; color: var(--text); font-size: .8rem; font-variant-numeric: tabular-nums; }
.kpi-carrier .carrier-other { color: var(--text-2); font-size: .75rem; }

/* ==========================================================================
   Toolbar
   ========================================================================== */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 1.5rem 0 .6rem; }
.toolbar .field { flex: 0 1 13rem; }
.toolbar .field-search { position: relative; flex: 1 1 18rem; }
.field-search .icon { position: absolute; left: .8rem; top: 50%; width: 18px; height: 18px; color: var(--text-3); transform: translateY(-50%); pointer-events: none; }
.field-search input { padding-left: 2.5rem; }
.toolbar-actions { display: flex; flex: none; gap: .4rem; }
/* From tablet width up the search, both selects and the button stay on one row; the fields shrink instead. */
@media (min-width: 720px) {
  .toolbar { flex-wrap: nowrap; }
  .toolbar .field { flex: 0 1 12rem; min-width: 8.5rem; }
  .toolbar .field-search { flex: 1 1 16rem; min-width: 9rem; }
}
.check { display: flex; align-items: center; gap: .55rem; color: var(--text-2); font-size: .92rem; cursor: pointer; }
.check input { width: 20px; height: 20px; min-height: 0; margin: 0; padding: 0; accent-color: var(--brand); }
.toolbar-compact { justify-content: space-between; margin-top: 0; }
.toolbar-compact .field-search { flex: 0 1 24rem; }
.result-count { margin: 0 0 .6rem; color: var(--text-2); font-size: .85rem; }
.toolbar-compact .result-count { margin: 0; }
.list-meta { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .25rem 1rem; margin: 0 0 .6rem; }
.list-meta .result-count { margin: 0; }
.per-page { display: flex; align-items: center; gap: .15rem; margin: 0; color: var(--text-2); font-size: .85rem; }
.per-page > span:first-child { margin-right: .35rem; }
.per-page-option { min-width: 2.2rem; padding: .15rem .45rem; border-radius: 6px; color: var(--text-2); font-weight: 650; text-align: center; text-decoration: none; }
a.per-page-option:hover { color: var(--text); background: var(--subtle); }
.per-page-option[aria-current] { color: var(--brand-strong); background: var(--brand-soft); }

/* Pager under the order list */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .5rem; margin: 1.1rem 0 0; }
.pager-pages { display: flex; align-items: center; gap: .25rem; }
.pager-page { display: inline-grid; place-items: center; min-width: 36px; height: 36px; padding: 0 .4rem; color: var(--text); border-radius: var(--radius-sm); font-weight: 650; font-variant-numeric: tabular-nums; text-decoration: none; }
a.pager-page:hover { color: var(--text); background: var(--subtle); }
.pager-page[aria-current="page"] { color: var(--on-brand); background: var(--brand); }
.pager-gap { color: var(--text-3); padding: 0 .15rem; }
.pager-next .icon { transform: rotate(180deg); }
.pager-step.is-disabled { opacity: .45; pointer-events: none; }
@media (max-width: 479px) {
  .pager-step span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .pager-step { width: 36px; padding: 0; }
}

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.data-table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.data-table th { padding: .7rem 1rem; color: var(--text-2); background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: .76rem; font-weight: 700; letter-spacing: .05em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table th.num { text-align: right; }
.data-table td { padding: .75rem 1rem; vertical-align: middle; border-bottom: 1px solid var(--line); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background-color .12s; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tfoot td { padding: .75rem 1rem; color: var(--text-2); background: var(--surface-2); border-top: 1px solid var(--line); font-weight: 600; }
.sub { display: block; margin-top: .1rem; font-size: .82rem; }
.sub-inline { color: var(--text-2); font-size: .85em; }
.is-inactive .product-name, .is-inactive .product-thumb { opacity: .55; }

.order-link { color: var(--text); font-size: 1rem; font-weight: 700; text-decoration: none; font-variant-numeric: tabular-nums; white-space: nowrap; }
.orders-table .c-items, .orders-table .c-time, .orders-table .sub { white-space: nowrap; }
.order-link:hover { color: var(--brand); text-decoration: underline; }
.order-peek {
  position: fixed; z-index: 60; width: max-content; max-width: min(26rem, calc(100vw - 16px)); max-height: 60vh; overflow: hidden auto;
  padding: .65rem .75rem; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); pointer-events: none;
}
.order-peek[hidden] { display: none; }
.peek-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding-bottom: .45rem; margin-bottom: .35rem; border-bottom: 1px solid var(--line); }
.peek-head span { color: var(--text-2); font-size: .8rem; white-space: nowrap; }
.peek-note { margin: 0; font-size: .9rem; line-height: 1.45; white-space: normal; overflow-wrap: anywhere; }
.peek-empty { margin: 0; color: var(--text-2); font-size: .85rem; }
.peek-items { display: grid; gap: .4rem; margin: 0; padding: 0; list-style: none; }
.peek-items li { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: .6rem; }
.peek-items img, .peek-noimg { width: 32px; height: 32px; border-radius: 6px; object-fit: cover; background: var(--subtle); }
.peek-text { display: grid; min-width: 0; }
.peek-name { font-size: .88rem; font-weight: 650; line-height: 1.25; }
.peek-meta { color: var(--text-2); font-size: .75rem; }
.peek-marks { display: flex; flex-wrap: wrap; gap: .1rem .6rem; color: var(--s-in_progress-fg, var(--text-2)); font-size: .72rem; font-weight: 650; }
.peek-packed { color: var(--s-packed-fg, var(--text-2)); }
.peek-qty { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.orders-table .c-time strong { font-weight: 700; }
.age { display: inline-flex; align-items: center; gap: .2rem; margin-left: .35rem; padding: 0 .4rem; border-radius: 999px; font-size: .75rem; font-weight: 650; }
.age .icon { width: 12px; height: 12px; }
.age-0 { color: var(--text-3); padding-left: 0; margin-left: .15rem; }
.age-1 { color: var(--warn-fg); background: var(--warn-bg); }
.age-2 { color: var(--err-fg); background: var(--err-bg); }
.customer-name { display: block; font-weight: 650; line-height: 1.3; }
.c-customer { min-width: 11rem; max-width: 18rem; }
.shipping { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem .45rem; margin-top: .2rem; color: var(--text-2); font-size: .82rem; line-height: 1.3; }
.shipping-name { min-width: 0; }
.shipping-detail { flex-basis: 100%; color: var(--text-3); font-size: .78rem; }
.carrier-badge { flex: none; padding: .05rem .4rem; color: var(--carrier-fg, #fff); background: var(--carrier-bg, #64748b); border-radius: 4px; font-size: .7rem; font-weight: 800; letter-spacing: .02em; white-space: nowrap; }
/* Carrier colours as variables, so the pickup rows on Plán can share them with the badges. */
.carrier-gls { --carrier-fg: #ffd100; --carrier-bg: #061ab1; }
.carrier-ppl { --carrier-fg: #ffd400; --carrier-bg: #00458a; }
.carrier-zasilkovna { --carrier-bg: #ba1b02; }
.carrier-dpd { --carrier-bg: #dc0032; }
.carrier-ceska-posta, .carrier-balikovna { --carrier-fg: #002776; --carrier-bg: #ffcc00; }
.carrier-wedo { --carrier-bg: #e4002b; }
.carrier-onebox { --carrier-bg: #177a45; }
.carrier-geis { --carrier-bg: #004f9f; }
.carrier-dhl { --carrier-fg: #d40511; --carrier-bg: #ffcc00; }
.carrier-ups { --carrier-fg: #ffb500; --carrier-bg: #351c15; }
.carrier-osobni-odber { color: var(--on-brand); background: var(--brand); }
.meta.meta-stacked div { flex-direction: column; gap: .15rem; }
.meta.meta-stacked dd { text-align: left; }
.meta.meta-stacked .customer-name { font-size: 1.05rem; }
.order-note { display: flex; align-items: flex-start; gap: .3rem; max-width: 18rem; margin-top: .3rem; color: var(--brand-strong); font-size: .8rem; font-weight: 600; line-height: 1.35; white-space: normal; }
.order-note .icon { width: 14px; height: 14px; margin-top: .05rem; }
.customer-note { display: flex; align-items: flex-start; gap: .3rem; max-width: 18rem; margin-top: .3rem; color: var(--text-2); font-size: .8rem; font-style: italic; line-height: 1.35; white-space: normal; }
.customer-note .icon { width: 14px; height: 14px; margin-top: .05rem; flex: none; }
.customer-note-full { white-space: normal; font-style: italic; }
.note-own { color: var(--err-fg); font-weight: 700; }
.c-select { width: 1%; padding-right: 0 !important; }
.c-select input { width: 20px; height: 20px; min-height: 0; margin: 0; padding: 0; accent-color: var(--brand); cursor: pointer; vertical-align: middle; }
/* Packed orders are done in the workshop: light green rows (a ticked row still wins). */
.data-table tbody tr.row-packed { background: var(--row-packed); }
.data-table tbody tr.row-packed:hover { background: var(--row-packed-hover); }
.data-table tbody tr.row-unpaid { background: var(--row-unpaid); }
.data-table tbody tr.row-unpaid:hover { background: var(--row-unpaid-hover); }
.data-table tbody tr.is-selected { background: var(--brand-soft); }

/* Bulk bar: a plain panel without JS; with JS it floats at the bottom once something is ticked. */
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; margin: 1rem 0 0; padding: .75rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.bulk-bar .field { flex: 0 1 13rem; }
.bulk-count { font-weight: 700; }
.bulk-ready .bulk-bar { position: fixed; left: 50%; bottom: 1rem; z-index: 45; width: min(calc(100% - 2rem), 70rem); transform: translateX(-50%); box-shadow: var(--shadow-lg); }
.bulk-ready .bulk-bar:not(.has-selection) { display: none; }
.bulk-ready .bulk-bar .bulk-count { margin-right: auto; }
.bulk-ready .bulk-note { display: none; }
.note-form { flex-direction: column; align-items: stretch; }
.note-form textarea { min-height: 5.5rem; resize: vertical; font-size: .92rem; }
.note-form .save-btn { align-self: flex-end; }
.js .note-form .save-btn { display: none; visibility: visible; }
.js .note-form.is-dirty .save-btn { display: inline-flex; }
.print-only { display: none; }
.items-table .print-check-col { width: 4.2rem; padding-left: .4rem; padding-right: .4rem; text-align: center; }
.items-table th.print-check-col { font-size: .66rem; letter-spacing: .02em; }
.items-table .c-product { min-width: 12rem; }
.item-toggle { display: inline-flex; }
.check-btn { display: inline-grid; place-items: center; width: 2.4rem; height: 2.4rem; padding: 0; color: transparent; background: var(--surface); border: 2px solid var(--line-strong); border-radius: 8px; cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
.check-btn .icon { width: 1.35rem; height: 1.35rem; stroke-width: 3; }
.check-btn:hover { border-color: var(--ok-fg); }
.check-btn[aria-pressed="true"] { color: #fff; background: var(--done); border-color: var(--done); }
.check-btn:disabled { opacity: .6; cursor: progress; }
.check-text { display: none; }
.item-focus { display: grid; gap: .6rem; margin-bottom: .9rem; }
.item-note, .item-pager { display: none; }
/* Stopwatches: buttons of the current state only. */
.timer { display: grid; gap: .5rem; margin: 0; }
.timer-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.timer-title { display: inline-flex; align-items: center; gap: .4rem; color: var(--text-2); font-weight: 650; }
.timer-title .icon { width: 1.1rem; height: 1.1rem; }
.timer-face { font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.timer[data-state="running"] .timer-face { color: var(--ok-fg); }
.timer[data-state="paused"] .timer-face { color: var(--warn-fg); }
.timer-buttons { display: flex; flex-wrap: wrap; gap: .4rem; }
.timer-buttons .btn { display: none; }
.timer[data-state="idle"] .timer-start,
.timer[data-state="running"] .timer-pause, .timer[data-state="running"] .timer-stop, .timer[data-state="running"] .timer-cancel,
.timer[data-state="paused"] .timer-resume, .timer[data-state="paused"] .timer-stop, .timer[data-state="paused"] .timer-cancel { display: inline-flex; }
.timer-last { margin: 0; color: var(--text-2); font-size: .9rem; }
.timer-last:empty { display: none; }
.item-focus > .timer { grid-template-columns: minmax(0, 1fr) auto; align-items: center; padding: .8rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.item-focus > .timer .timer-last { grid-column: 1 / -1; }
.items-table .c-timer { min-width: 8.5rem; }
.js .items-table .c-rate .inline-edit:not(.is-dirty) .save-btn { display: none; }
.items-table .c-rate .rate-form input { width: 4.5rem; }
/* Min/ks on the order detail: a grey empty field until tapped (app.js adds is-revealed). */
.js .rate-concealed:not(.is-revealed) input { color: transparent; background: var(--concealed); border-color: var(--line); cursor: pointer; }
.js .rate-concealed:not(.is-revealed) input::placeholder { color: transparent; }
.items-table .c-timer .timer { gap: .3rem; }
.items-table .c-timer .timer-face { font-size: 1.15rem; }
.items-table .c-timer .timer-buttons { gap: .25rem; }
.items-table .c-timer .timer-buttons .btn { min-height: 2.1rem; padding: .25rem .55rem; font-size: .85rem; }
.items-table .c-timer .timer-title { display: none; }
.measured { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .35rem .6rem; margin: .4rem 0 0; }
.measured-text { display: inline-flex; align-items: center; gap: .3rem; color: var(--ok-fg); font-size: .85rem; font-weight: 650; white-space: nowrap; }
.measured-text .icon { width: 1rem; height: 1rem; }
.measured-block { justify-content: flex-start; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.measure-table .c-actions { width: 1%; text-align: right; }
.item-progress { display: block; margin-top: .15rem; color: var(--ok-fg); font-size: .76rem; font-weight: 650; }
.notice-ok { color: var(--ok-fg); background: var(--ok-bg); border-color: var(--ok-line); }
.notice .notice-action { margin-left: auto; }
.print-box.is-checked { display: inline-grid; place-items: center; font-weight: 800; line-height: 1; }
.print-sheet { margin-top: 1.25rem; padding: 1rem 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.print-sheet-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.print-qr { display: flex; flex-direction: column; align-items: center; gap: .15rem; margin: 0 0 0 auto; }
.print-qr .qr-code { display: block; width: 84px; height: 84px; }
.print-qr figcaption { color: var(--text-2); font-size: .68rem; white-space: nowrap; }
.btn-lg { min-height: 3.4rem; font-size: 1.15rem; }
.btn-lg .icon { width: 24px; height: 24px; }
.scan-panel { display: grid; gap: .6rem; margin: 0 0 1rem; padding: 1rem 1.1rem; background: var(--brand-soft); border: 1px solid var(--brand); border-radius: var(--radius); }
.scan-panel p { margin: 0; }
.scan-hint { color: var(--text-2); font-size: .85rem; }
.scan-done { grid-template-columns: auto 1fr; align-items: center; color: var(--s-packed-fg); background: var(--s-packed-bg); border-color: transparent; }
.scan-done .icon { width: 32px; height: 32px; }
.scan-done strong { display: block; font-size: 1.2rem; }
.scan-done span { color: var(--text-2); font-size: .85rem; }
.scan-warn { background: var(--s-review-bg); border-color: transparent; }
.print-sheet .print-meta { display: flex; flex-wrap: wrap; gap: .3rem 1.4rem; margin-bottom: .75rem; font-size: .9rem; }
.print-sheet .print-note { margin-bottom: .75rem; padding: .5rem .7rem; background: var(--warn-bg); border-radius: var(--radius-sm); }
.print-items { width: 100%; border-collapse: collapse; }
.print-items th, .print-items td { padding: .45rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.print-items th { color: var(--text-2); font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.print-items .num { text-align: right; white-space: nowrap; }
.print-items .c-product { min-width: 0; }
.print-items .print-check-col { width: 4.5rem; text-align: center; font-size: .75rem; }
.print-sheet .print-box { display: inline-block; width: 1.3rem; height: 1.3rem; border: 2px solid var(--line-strong); border-radius: 4px; }
.print-sheet .print-sign { display: flex; flex-wrap: wrap; gap: .5rem 2rem; margin-top: 1rem; color: var(--text-2); font-size: .85rem; }
.bulk-print[hidden] { display: none; }
.batch-start { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin-top: 1rem; }
.batch-start p { flex: 1 1 16rem; }
.print-items tfoot td { padding-top: .6rem; font-weight: 700; border-bottom: 0; }
.batch-summary .c-orders { color: var(--text-2); font-size: .8rem; }
@media screen and (max-width: 600px) {
  .print-sheet { padding: .8rem .7rem; }
  .print-items .product-thumb { display: none; }
  .print-items th, .print-items td { padding: .45rem .3rem; }
  .print-items .print-check-col { width: 3.4rem; font-size: .6rem; letter-spacing: 0; }
}
.orders-table .c-status .inline-edit, .orders-table .c-maker .inline-edit { flex-wrap: nowrap; }

.c-product { display: flex; align-items: center; gap: .8rem; min-width: 16rem; }
/* In a real table row the cell must stay a table cell (a flex <td> breaks the row lines and the vertical centring);
   the picture and the text sit side by side as inline blocks instead. Phones turn rows into cards and keep the flex. */
@media (min-width: 720px) {
  .data-table td.c-product { display: table-cell; white-space: nowrap; }
  .data-table td.c-product > .product-thumb { display: inline-block; margin-right: .8rem; vertical-align: middle; }
  .data-table td.c-product > .product-info { display: inline-flex; max-width: calc(100% - 52px - .8rem); vertical-align: middle; white-space: normal; }
}
.product-thumb { display: block; flex: none; width: 52px; height: 52px; object-fit: contain; background: var(--subtle); border-radius: 10px; }
.product-thumb-empty { display: grid; place-items: center; color: var(--text-3); }
.product-thumb-empty .icon { width: 22px; height: 22px; }
.product-info { display: flex; flex-direction: column; min-width: 0; }
.product-name { font-weight: 650; line-height: 1.3; }
.items-table .c-qty strong, .summary-table .c-qty strong { font-size: 1.02rem; }
.audit-table { font-size: .87rem; }
.audit-table .c-time { white-space: nowrap; color: var(--text-2); }
.audit-table .c-change { max-width: 34rem; }
.audit-table .c-change code { background: transparent; padding: 0; color: var(--text-2); }
.users-table .c-user .product-name { display: block; }
.products-table .c-actions { position: relative; width: 1%; text-align: right; }
.products-table .c-product { min-width: 18rem; }
.products-table .c-money { color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.products-table .c-rate .rate-form input { width: 4.5rem; }
/* Real margin: green from 60 %, orange from 30 %, red below, grey while a price is missing. */
.margin-badge { display: inline-block; min-width: 3.6rem; padding: .18rem .65rem; border-radius: 999px; font-size: .86rem; font-weight: 750; text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
.margin-hi { color: var(--ok-fg); background: var(--ok-bg); }
.margin-mid { color: var(--warn-fg); background: var(--warn-bg); }
.margin-lo { color: var(--err-fg); background: var(--err-bg); }
.margin-na { color: var(--s-cancelled-fg); background: var(--s-cancelled-bg); font-size: .78rem; font-weight: 650; }
.products-table .group-row th { padding: 1.1rem 1rem .5rem; background: var(--surface-2); color: var(--brand-strong); font-size: .78rem; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; text-align: left; }
.products-table tbody .group-row:hover { background: var(--surface-2); }
.group-count { margin-left: .5rem; padding: .05rem .45rem; border-radius: 999px; background: var(--subtle); color: var(--text-2); font-size: .72rem; letter-spacing: 0; }
/* On wide screens the products table fits without side scrolling, so its header can stick under the top bar. */
@media (min-width: 1100px) {
  .table-wrap:has(.products-table) { overflow: visible; }
  .products-table thead th { position: sticky; top: var(--topbar-h); z-index: 5; box-shadow: 0 1px 0 var(--line); }
  .products-table thead th:first-child { border-top-left-radius: var(--radius); }
  .products-table thead th:last-child { border-top-right-radius: var(--radius); }
}

/* ==========================================================================
   Order detail
   ========================================================================== */
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; }
.detail-side { position: sticky; top: calc(var(--topbar-h) + 1rem); display: grid; gap: 1rem; }
.detail-side .panel { margin: 0; }
.detail-side .field + .field { margin-top: .9rem; }
.detail-side .inline-edit select { flex: 1; min-width: 0; max-width: none; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin: 0; }
.stats dt { color: var(--text-2); font-size: .8rem; font-weight: 600; }
.stats dd { margin: .1rem 0 0; font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stats-total dd { color: var(--brand-strong); }
.money-meta dd { font-variant-numeric: tabular-nums; white-space: nowrap; }
.money-meta .money-total { margin-top: .25rem; padding-top: .6rem; border-top: 1px solid var(--line-strong); border-bottom: 0; }
.money-meta .money-total dd strong { color: var(--brand-strong); font-size: 1.1rem; }
.money-form { margin-top: 1rem; }
.money-form .btn { justify-self: start; }
.field-hint { display: block; margin-top: .3rem; color: var(--text-2); font-size: .8rem; }
.order-price { display: block; margin-top: .1rem; font-weight: 650; font-size: .88rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.order-price-head { display: inline-block; margin: 0; padding: .15rem .6rem; border-radius: 999px; background: var(--subtle); font-size: .95rem; }
.meta { display: grid; margin: 0; }
.meta div { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-bottom: 1px dashed var(--line); }
.meta div:last-child { border-bottom: 0; padding-bottom: 0; }
.meta div:first-child { padding-top: 0; }
.meta dt { color: var(--text-2); }
.meta dd { margin: 0; font-weight: 600; text-align: right; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1100px) {
  .detail-layout { grid-template-columns: minmax(0, 1fr) 300px; }
}
@media (max-width: 1023px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
  .detail-layout { grid-template-columns: 1fr; }
  .detail-side { position: static; order: -1; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
}

/* Order list → cards */
@media (max-width: 1079px) {
  .orders-table, .orders-table tbody { display: block; }
  .orders-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-wrap:has(.orders-table) { overflow: visible; background: transparent; border: 0; box-shadow: none; }
  .orders-table tbody { display: grid; gap: .7rem; }
  .orders-table tr {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "select order status" "select order maker" "customer customer customer" "items items time";
    gap: .6rem 1rem; padding: .95rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  }
  .orders-table tbody tr:hover { background: var(--surface); }
  .orders-table tbody tr.row-packed, .orders-table tbody tr.row-packed:hover { background: var(--row-packed); border-color: var(--row-packed-line); }
  .orders-table tbody tr.row-unpaid, .orders-table tbody tr.row-unpaid:hover { background: var(--row-unpaid); border-color: var(--row-unpaid-line); }
  .orders-table td { padding: 0; border: 0; }
  .orders-table .c-order { grid-area: order; align-self: center; }
  .orders-table .c-select { grid-area: select; align-self: start; padding-top: .15rem !important; }
  .orders-table thead .c-select { display: none; }
  .orders-table .c-order { min-width: 0; }
  .orders-table .c-order .sub { white-space: normal; }
  .orders-table tbody tr.is-selected { background: var(--brand-soft); border-color: var(--brand); }
  .bulk-ready .bulk-bar { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + .5rem); }
  .orders-table .c-status { grid-area: status; justify-self: end; align-self: start; }
  .orders-table .c-items { grid-area: items; font-size: .9rem; }
  .orders-table .c-customer { grid-area: customer; max-width: none; min-width: 0; }
  .orders-table .c-time { grid-area: time; }
  .orders-table .c-maker { grid-area: maker; justify-self: end; align-self: start; }
  .orders-table .status-select { min-width: 0; max-width: 11rem; padding-left: .7rem; font-size: .85rem; }
  .orders-table .c-status .inline-edit { flex-direction: column; align-items: flex-end; }
  .js .orders-table .c-status .save-btn { display: none; }
  .js .orders-table .c-status .is-dirty .save-btn { display: inline-flex; }
}
@media (min-width: 720px) and (max-width: 1079px) {
  .orders-table tbody { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}

/* The quantity to make stands out in red on the order detail (screen only; the printout stays black). */
@media screen { .page-detail .items-table .c-qty strong { color: var(--qty-fg); } }
@media (max-width: 719px) {
  body { font-size: 15px; }
  .page-actions { flex-direction: column; align-items: stretch; width: 100%; margin-left: 0; }
  .import-form { width: 100%; align-items: stretch; }
  .import-info { text-align: center; }
  .workload-list li { grid-template-columns: minmax(0, 1fr) auto; gap: .3rem .75rem; }
  .workload progress { grid-column: 1 / -1; grid-row: 2; }
  .bulk-bar .field { flex: 1 1 calc(50% - .5rem); }
  .bulk-ready .bulk-bar.has-selection { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; width: calc(100% - 1rem); padding: .6rem .65rem .65rem; }
  .bulk-ready .bulk-bar .bulk-count { grid-column: 1; grid-row: 1; align-self: center; margin: 0; }
  .bulk-ready .bulk-bar .bulk-clear { grid-column: 2; grid-row: 1; justify-self: end; padding: 0 .5rem; }
  .bulk-ready .bulk-bar .field { grid-row: 2; }
  .bulk-ready .bulk-bar select { min-height: 40px; font-size: 16px; }
  .bulk-ready .bulk-bar .btn-primary { grid-column: 1 / -1; grid-row: 3; }
  .bulk-ready .bulk-bar .bulk-print { grid-row: 4; }
  .page { padding-top: 1rem; }
  .topbar-inner { gap: .75rem; }
  .brand-sub { display: none; }
  .brand-logo { font-size: 1.15rem; }
  .kpi { padding: .8rem .9rem; }
  .kpi-value { font-size: 1.55rem; }
  .toolbar { margin-top: 1.1rem; }
  .toolbar .field { flex: 1 1 calc(50% - .25rem); }
  .toolbar .field-search { flex-basis: 100%; }
  .toolbar .field-search { flex: 1 1 60%; order: 0; }
  .toolbar-actions { flex: 0 0 auto; order: 1; }
  .toolbar .field:not(.field-search) { order: 2; }
  .toolbar-compact .field-search { flex: 1 1 100%; }
  .panel { padding: 1rem; }
  .disclosure > summary { padding: .9rem 1rem; }
  .disclosure > :not(summary) { margin: 1rem; }
  .stats dd { font-size: 1rem; }

  /* Generic tables → stacked cards */
  .items-table, .products-table, .users-table, .audit-table,
  .items-table tbody, .products-table tbody, .users-table tbody, .audit-table tbody { display: block; }
  .items-table thead, .products-table thead, .users-table thead, .audit-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-wrap:has(.items-table, .products-table, .users-table, .audit-table) { overflow: visible; background: transparent; border: 0; box-shadow: none; }
  .items-table tbody, .products-table tbody, .users-table tbody, .audit-table tbody { display: grid; gap: .6rem; }
  .items-table tr, .products-table tr, .users-table tr, .audit-table tr {
    display: grid; gap: .5rem .75rem; padding: .85rem .95rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  }
  .items-table tr[hidden], .products-table tr[hidden] { display: none; }
  .items-table tbody tr:hover, .products-table tbody tr:hover, .users-table tbody tr:hover, .audit-table tbody tr:hover { background: var(--surface); }
  .items-table td, .products-table td, .users-table td, .audit-table td { padding: 0; border: 0; text-align: left; }
  .c-product { min-width: 0; }
  .product-thumb { width: 48px; height: 48px; }

  /* Order detail on a phone: one item per screen, swiped sideways, with two big tick buttons.
     The card height (--item-card-h) is set by app.js to fill the screen below the pager. */
  .detail-side { order: 1; }
  .page-detail .page-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .page-detail .section-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .item-focus { display: grid; gap: .6rem; margin-bottom: .6rem; scroll-margin-top: calc(var(--topbar-h) + .5rem); }
  .item-note { display: flex; gap: .6rem; margin: 0; padding: .8rem 1rem; color: var(--warn-fg); background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--radius); font-size: 1.1rem; font-weight: 600; line-height: 1.35; }
  .item-note .icon { flex: none; width: 1.4rem; height: 1.4rem; margin-top: .05rem; }
  .item-pager { display: grid; grid-template-columns: 3.5rem 1fr 3.5rem; align-items: center; gap: .6rem; }
  .item-pager .btn { min-height: 3.25rem; padding: 0; font-size: 1.9rem; line-height: 1; }
  .item-pager .btn:disabled { opacity: .35; }
  .item-pager-pos { font-size: 1.2rem; font-weight: 700; text-align: center; }
  .item-pager-pos strong { font-size: 1.45rem; }

  .page-detail .items-table tbody { display: flex; gap: .75rem; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scrollbar-width: none; }
  .page-detail .items-table tbody::-webkit-scrollbar { display: none; }
  .page-detail .items-table tr {
    flex: 0 0 100%; scroll-snap-align: start; scroll-snap-stop: always;
    height: var(--item-card-h, calc(100dvh - var(--topbar-h) - var(--tabbar-h) - env(safe-area-inset-bottom) - 6rem));
    grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto minmax(auto, 1fr) auto auto auto;
    gap: .9rem 1rem; padding: 1.1rem;
  }
  .page-detail .items-table .c-product { grid-column: 1 / -1; grid-row: 1; padding-bottom: .9rem; border-bottom: 1px solid var(--line); }
  .page-detail .items-table .c-product .product-thumb { width: 72px; height: 72px; border-radius: 12px; }
  .page-detail .items-table .c-product .product-name { font-size: 1.85rem; line-height: 1.15; }
  .page-detail .items-table .c-product .sub { margin-top: .35rem; font-size: 1.05rem; }
  .page-detail .items-table .c-product code { font-size: 1rem; }
  .page-detail .items-table td[data-label]::before { margin-bottom: .15rem; font-size: 1rem; font-weight: 600; }
  /* The quantity is what the bench needs: big, in the middle of the free space; the price sits under it. */
  .page-detail .items-table .c-qty { grid-column: 1 / -1; grid-row: 2; align-self: center; font-size: 1.6rem; font-weight: 700; text-align: center; }
  .page-detail .items-table .c-qty strong { font-size: 5rem; line-height: 1; }
  .page-detail .items-table .c-price-col { grid-column: 1 / -1; grid-row: 3; font-size: 1.1rem; font-weight: 600; text-align: center; }
  .page-detail .items-table .c-price-col::before { display: inline; margin-right: .4rem; }
  /* The norm and planned time stay on the computer; the card keeps what is needed at the bench. */
  .page-detail .items-table .c-rate, .page-detail .items-table .c-line { display: none; }
  .page-detail .items-table .c-rate .rate-form { flex-wrap: wrap; }
  .page-detail .items-table .c-rate .rate-form input { width: 6rem; min-height: 44px; font-size: 1.1rem; }
  .js .page-detail .items-table .c-rate .inline-edit:not(.is-dirty) .save-btn { display: none; }
  .page-detail .items-table .c-produced, .page-detail .items-table .c-packed { grid-column: 1 / -1; width: auto; padding: 0; border: 0; text-align: left; }
  .page-detail .items-table .c-timer { grid-column: 1 / -1; grid-row: 4; min-width: 0; padding: .55rem .6rem; background: var(--subtle); border-radius: 14px; }
  /* Vyrobeno and Zabaleno side by side, icon above the word. */
  .page-detail .items-table .c-produced { grid-column: 1; grid-row: 5; }
  .page-detail .items-table .c-packed { grid-column: 2; grid-row: 5; }
  /* Stopwatch in one row: the face, then the buttons of the current state. */
  .page-detail .timer { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: .4rem .6rem; }
  .page-detail .timer-head { flex-direction: column; align-items: flex-start; gap: 0; }
  .page-detail .timer-title, .page-detail .items-table .c-timer .timer-title { display: inline-flex; font-size: 1rem; }
  .page-detail .timer-title .icon { display: none; }
  .page-detail .timer-face { font-size: 1.9rem; line-height: 1.1; }
  .page-detail .timer-buttons { flex-wrap: nowrap; }
  .page-detail .timer-buttons .btn { flex: 1 1 0; min-width: 0; min-height: 3.1rem; padding: 0 .5rem; font-size: 1.1rem; font-weight: 700; }
  .page-detail .timer-buttons .timer-cancel { flex: 0 0 2.9rem; font-size: 1.3rem; }
  .page-detail .timer-last { grid-column: 1 / -1; font-size: 1rem; }
  .page-detail .item-focus > .timer { grid-template-columns: auto minmax(0, 1fr); padding: .55rem .7rem; }
  .page-detail .items-table .c-produced::before, .page-detail .items-table .c-packed::before { display: none !important; }
  .page-detail .items-table .item-toggle, .page-detail .items-table .check-btn { width: 100%; height: 100%; }
  .page-detail .items-table .check-btn { display: flex; align-items: center; justify-content: center; gap: .45rem; min-width: 0; min-height: 4.25rem; padding: .4rem; color: var(--text); border-width: 3px; border-radius: 16px; font-size: 1.25rem; font-weight: 800; }
  .page-detail .items-table .check-btn .icon { flex: none; width: 2rem; height: 2rem; padding: .3rem; color: transparent; border: 3px solid var(--line-strong); border-radius: 10px; box-sizing: border-box; stroke-width: 3.5; }
  .page-detail .items-table .check-btn[aria-pressed="true"] { color: #fff; }
  .page-detail .items-table .check-btn[aria-pressed="true"] .icon { color: #fff; border-color: rgb(255 255 255 / 75%); }
  .page-detail .items-table .check-text { display: inline; }

  /* Smaller screens or bigger system text: app.js steps data-fit up until the card fits. */
  .detail-main[data-fit] .item-focus { gap: .45rem; margin-bottom: .45rem; }
  .detail-main[data-fit] .item-pager .btn { min-height: 2.75rem; }
  .detail-main[data-fit] .items-table tr { gap: .6rem .8rem; padding: .8rem; }
  .detail-main[data-fit] .items-table .c-product { padding-bottom: .6rem; }
  .detail-main[data-fit] .items-table .c-product .product-thumb { width: 52px; height: 52px; }
  .detail-main[data-fit] .items-table .c-product .product-name { font-size: 1.55rem; }
  .detail-main[data-fit] .items-table .c-qty strong { font-size: 4rem; }
  .detail-main[data-fit] .items-table .c-qty { font-size: 1.3rem; }
  .detail-main[data-fit] .timer-face { font-size: 1.6rem; }
  .detail-main[data-fit] .timer-buttons .btn { min-height: 2.75rem; }
  .detail-main[data-fit] .items-table .check-btn { min-height: 3.5rem; gap: .4rem; font-size: 1.25rem; }
  .detail-main[data-fit] .items-table .check-btn .icon { width: 2rem; height: 2rem; }

  .detail-main[data-fit="2"] .items-table .c-product .product-thumb,
  .detail-main[data-fit="3"] .items-table .c-product .product-thumb { display: none; }
  .detail-main[data-fit="2"] .items-table td[data-label]::before,
  .detail-main[data-fit="3"] .items-table td[data-label]::before { display: none; }
  .detail-main[data-fit="2"] .timer-last, .detail-main[data-fit="3"] .timer-last { display: none; }
  .detail-main[data-fit="2"] .item-note, .detail-main[data-fit="3"] .item-note { padding: .5rem .75rem; font-size: 1rem; }

  .detail-main[data-fit="3"] .items-table tr { gap: .45rem .6rem; padding: .6rem; }
  .detail-main[data-fit="3"] .items-table .c-product .product-name { font-size: 1.3rem; }
  .detail-main[data-fit="3"] .items-table .c-qty strong { font-size: 3rem; }
  .detail-main[data-fit="3"] .timer-title { display: none !important; }
  .detail-main[data-fit="3"] .timer-face { font-size: 1.35rem; }
  .detail-main[data-fit="3"] .timer-buttons .btn { min-height: 2.5rem; font-size: 1rem; }
  .detail-main[data-fit="3"] .item-focus > .timer, .detail-main[data-fit="3"] .items-table .c-timer { padding: .35rem .5rem; }
  .detail-main[data-fit="3"] .items-table .check-btn { min-height: 2.9rem; font-size: 1.1rem; }
  .detail-main[data-fit="3"] .item-pager .btn { min-height: 2.5rem; }
  .items-table td[data-label]::before { content: attr(data-label); display: block; color: var(--text-2); font-size: .75rem; font-weight: 650; }
  .items-table .c-rate .rate-form { justify-content: flex-start; }

  .products-table tr { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .products-table .c-product, .products-table .c-rate { grid-column: 1 / -1; }
  .products-table .c-money, .products-table .c-margin { padding-top: .55rem; border-top: 1px solid var(--line); }
  .products-table .c-money::before, .products-table .c-margin::before { content: attr(data-label); display: block; margin-bottom: .15rem; color: var(--text-2); font-size: .75rem; font-weight: 650; }
  .products-table .c-money { color: var(--text); font-weight: 650; }
  .products-table .c-rate { display: flex; align-items: center; gap: .6rem; }
  .products-table .c-rate::before { content: attr(data-label); color: var(--text-2); font-size: .8rem; font-weight: 650; white-space: nowrap; }
  .products-table .c-rate .rate-form { justify-content: flex-start; }
  .products-table .c-actions { width: auto; }
  .products-table .group-row { display: block; padding: .6rem .1rem 0; background: transparent; border: 0; box-shadow: none; }
  .products-table .group-row th { display: block; padding: 0; background: transparent; }
  .products-table .c-actions { grid-column: 1 / -1; text-align: left; margin: 0 -.5rem -.35rem; }
  .partner-add { grid-template-columns: 1fr; }
  .partner-add select, .partner-add .input-suffix input { min-height: 48px; font-size: 1.05rem; }
  .partner-add .btn { min-height: 3rem; font-size: 1.05rem; }
  .wholesale-table, .wholesale-table tbody { display: block; }
  .wholesale-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .wholesale-table tbody { display: grid; gap: .6rem; }
  .wholesale-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .6rem .75rem; padding: .85rem .95rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
  .wholesale-table td { padding: 0; border: 0; }
  .wholesale-table .c-product { grid-column: 1; grid-row: 1; }
  .wholesale-table .c-remove { grid-column: 2; grid-row: 1; align-self: start; }
  .wholesale-table .c-price { grid-column: 1; grid-row: 2; }
  .wholesale-table .c-price .price-form { justify-content: flex-start; }
  .wholesale-table .c-price .input-suffix input { width: 6.5rem; min-height: 46px; font-size: 1.1rem; }
  .wholesale-table .c-profit { grid-column: 2; grid-row: 2; align-self: center; text-align: right; }
  .wholesale-table .c-profit::before { content: 'Zisk za kus'; display: block; color: var(--text-2); font-size: .78rem; font-weight: 650; }

  .users-table tr { grid-template-columns: minmax(0, 1fr) auto; }
  .users-table .c-user { grid-column: 1; }
  .users-table .c-state { grid-column: 2; grid-row: 1; align-self: start; }
  .users-table .c-role { grid-column: 1 / -1; color: var(--text-2); font-size: .88rem; }
  .users-table .c-manage { grid-column: 1 / -1; padding-top: .6rem; border-top: 1px solid var(--line); }
  .users-table .inline-edit { flex-wrap: wrap; }
  .users-table .inline-edit select { flex: 1 1 8rem; }

  .audit-table tr { grid-template-columns: minmax(0, 1fr) auto; gap: .25rem .75rem; }
  .audit-table .c-action { grid-column: 1; grid-row: 1; }
  .audit-table .c-time { grid-column: 2; grid-row: 1; font-size: .8rem; }
  .audit-table .c-actor, .audit-table .c-entity { font-size: .85rem; color: var(--text-2); }
  .audit-table .c-entity { text-align: right; }
  .audit-table .c-change { grid-column: 1 / -1; max-width: none; }

  .summary-table th, .summary-table td, .summary-table tfoot td { padding: .65rem .75rem; }
  .summary-table .c-code { white-space: nowrap; }

  .form-actions .btn { flex: 1; }

  /* Retail vs wholesale: one card per channel, the four numbers in a 2×2 grid with their labels. */
  .table-wrap:has(.channel-table) { overflow: visible; border: 0; box-shadow: none; background: transparent; }
  .channel-table, .channel-table tbody { display: block; }
  .channel-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .channel-table tbody { display: grid; gap: .6rem; }
  .channel-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem .9rem; padding: .85rem .95rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); }
  .channel-table tbody tr:hover { background: var(--surface-2); }
  .channel-table tbody th { grid-column: 1 / -1; padding: 0; border: 0; font-size: 1rem; font-weight: 700; }
  .channel-table td { padding: 0; border: 0; text-align: left; font-weight: 700; }
  .channel-table td::before { content: attr(data-label); display: block; color: var(--text-2); font-size: .75rem; font-weight: 650; }

  /* Fingers, not a mouse pointer: every remaining small control gets a 44px target. */
  .btn-sm, .pager-page, .icon-btn, .remove-btn { min-height: 44px; min-width: 44px; }
  .per-page-option { display: inline-grid; place-items: center; min-width: 44px; min-height: 44px; }
  .inline-edit select, .inline-edit input { min-height: 44px; }
  .bulk-ready .bulk-bar .bulk-clear { min-height: 44px; }
  .back-link { min-height: 44px; }
  .orders-table .c-select input { width: 28px; height: 28px; }
  /* Bigger tap area for the order number without moving the card layout. */
  .orders-table .order-link { display: inline-flex; align-items: center; min-height: 44px; margin: -11px 0; }
}

@media (max-width: 339px) {
  .kpis { gap: .5rem; }
  .kpi-value { font-size: 1.35rem; }
  .orders-table tr { grid-template-columns: auto 1fr; grid-template-areas: "select order" "status maker" "customer customer" "items items" "time time"; }
  .orders-table .c-status { justify-self: start; }
  .orders-table .c-status .inline-edit { flex-direction: row; }
  .orders-table .c-time { text-align: left; }
}

/* ==========================================================================
   Print (order sheet for the workshop, production summary)
   ========================================================================== */
@media print {
  @page { margin: 12mm; }
  :root { --text: #000; --text-2: #333; --line: #999; --surface: #fff; --surface-2: #fff; --subtle: #eee; --bg: #fff; }
  html, body { background: #fff !important; color: #000; font-size: 11pt; }
  body.has-user { padding: 0; }
  .topbar, .nav-bottom, .nav-side, .skip-link, .back-link, .page-actions, .notice, .detail-side, .toolbar, .bulk-bar,
  .no-print, .note, form, .save-btn, .kpis, .workload, .order-peek { display: none !important; }
  .print-only { display: revert; }
  .page { width: 100%; padding: 0; }
  .page-head { margin-bottom: 4mm; }
  h1 { font-size: 20pt; }
  .badge { border: 1px solid #000; color: #000 !important; background: none !important; }
  .carrier-badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-meta { display: flex; flex-wrap: wrap; gap: 2mm 8mm; margin-bottom: 4mm; font-size: 10pt; }
  .print-note { margin-bottom: 4mm; padding: 2mm 3mm; border: 1px solid #000; }
  .detail-layout { display: block; }
  .section-title .count { border: 1px solid #999; }
  .table-wrap { overflow: visible; border: 0; box-shadow: none; border-radius: 0; }
  .data-table { display: table; width: 100%; border-collapse: collapse; }
  .data-table tbody { display: table-row-group; }
  .data-table thead { display: table-header-group; position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .data-table tr { display: table-row; padding: 0; border: 0; box-shadow: none; break-inside: avoid; }
  .data-table th, .data-table td { display: table-cell; padding: 2.5mm 2mm; border-bottom: 1px solid #999; background: none !important; color: #000; }
  .data-table td[data-label]::before { content: none; }
  .items-table .c-rate, .items-table .c-line, .items-table .c-price-col, .items-table .c-timer, .item-focus { display: none; }
  .items-table .c-qty strong { font-size: 14pt; }
  .product-thumb { display: inline-block; width: 18mm; height: 18mm; margin-right: 3mm; vertical-align: middle; }
  .product-info { display: inline-flex; vertical-align: middle; }
  .print-check-col { width: 9mm; text-align: center; }
  .items-table .print-check-col { width: 18mm; font-size: 9pt; }
  .print-box { display: inline-block; width: 6mm; height: 6mm; border: 1.5px solid #000; border-radius: 1mm; }
  .print-batch .page-head, .print-batch > .note { display: none !important; }
  .print-sheet { margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: none; }
  .print-sheet + .print-sheet { break-before: page; }
  .print-sheet-head { margin-bottom: 4mm; }
  .print-sheet-head h2 { font-size: 20pt; }
  .print-qr .qr-code { width: 26mm; height: 26mm; }
  .print-qr figcaption { color: #000; font-size: 7pt; }
  .print-qr-wrap { float: right; margin: 0 0 2mm 4mm; }
  .scan-panel { display: none; }
  .print-sheet .print-note { background: none; border-radius: 0; }
  .print-items th, .print-items td { padding: 2.5mm 2mm; border-bottom: 1px solid #999; color: #000; }
  .print-items th { font-size: 9pt; text-transform: uppercase; }
  .print-items .print-check-col { width: 18mm; font-size: 9pt; }
  .print-sheet .print-box { width: 6mm; height: 6mm; border: 1.5px solid #000; border-radius: 1mm; }
  .print-sheet .print-sign { color: #000; }
  .print-sign { display: flex; flex-wrap: wrap; gap: 6mm 12mm; margin-top: 10mm; font-size: 10pt; }
  code { background: none; padding: 0; }
  a { color: #000; text-decoration: none; }
}

/* Less motion: states still change instantly, nothing slides or blinks; the import shows a calm dimmed icon instead of pulsing. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation: none !important; }
  .btn:active, a.kpi:hover, .label-card:hover { transform: none; }
  .import-form.is-busy .icon { opacity: .45; }
}

/* Plán: courier pickups */
.pickup-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; padding: .6rem .8rem; margin: 0 0 .5rem; border-radius: var(--radius-sm); }
.pickup-ok { color: var(--ok-fg); background: var(--ok-bg); }
.pickup-warn { color: var(--warn-fg); background: var(--warn-bg); border: 1px solid var(--warn-line); font-weight: 600; }
/* Each carrier's row in its badge colours and lettering; the order button is the same colours swapped. */
.pickup-row.pickup-carrier { color: var(--carrier-fg, #fff); background: var(--carrier-bg, #64748b); border: 0; font-weight: 800; letter-spacing: .02em; }
.pickup-carrier.pickup-warn > span::before { content: "\26A0\FE0E\00A0"; }
.pickup-carrier .btn, .pickup-carrier .btn:hover { color: var(--carrier-bg, #64748b); background: var(--carrier-fg, #fff); border-color: var(--carrier-fg, #fff); font-weight: 800; }
.pickup-carrier .btn:hover { filter: brightness(1.08); }
.pickup-push { margin-top: .4rem; }
.pickup-push[hidden] { display: none; }
@media (max-width: 719px) { .pickup-row .btn { flex: 1 1 100%; } }

/* Plán / Objednávky: bank payments that did not pay an order by themselves */
.bank-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; padding: .6rem .8rem; margin: 0 0 .5rem;
  color: var(--warn-fg); background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--radius-sm); }
.bank-info { flex: 1 1 18rem; min-width: 0; overflow-wrap: anywhere; }
.bank-reason { font-weight: 600; }
.bank-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.bank-actions .field input { width: 11rem; }
@media (max-width: 719px) { .bank-actions, .bank-actions .field, .bank-actions .field input { flex: 1 1 100%; width: 100%; } }
