/* FarmShop — editorial paper-craft design system.
 *
 * Aesthetic: ink on warm cream paper, Swiss-grid restraint, dairy-product-label
 * detail. Display in Fraunces (variable serif, optical-size aware), body in
 * IBM Plex Sans, numerals + codes in IBM Plex Mono. One accent (forest green)
 * with restrained amber and oxblood for state. Subtle paper-grain noise.
 */

:root {
  /* Type */
  --font-display: "Fraunces", "Iowan Old Style", "Hoefler Text", Georgia, serif;
  --font-body: "IBM Plex Sans", "Helvetica Neue", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", "SF Mono", ui-monospace, monospace;

  --fs-xs: 0.75rem;     /* 12 */
  --fs-sm: 0.875rem;    /* 14 */
  --fs-base: 1.0625rem; /* 17 — slightly larger for daylight farm-shop legibility */
  --fs-lg: 1.3125rem;   /* 21 */
  --fs-xl: 1.625rem;    /* 26 */
  --fs-2xl: 2.0625rem;  /* 33 */
  --fs-3xl: 2.625rem;   /* 42 */
  --fs-4xl: 3.5rem;     /* 56 — only for hero metrics */

  --lh-tight: 1.1;
  --lh-snug: 1.3;
  --lh-base: 1.55;

  /* Color — pulled from milk + ink + barn herbs, not arbitrary.
   * Light theme is "buttermilk paper"; dark theme (see below) is
   * "midnight ink". Both share the same token names so components
   * never special-case a theme. */
  --paper:        #F4EFE6;  /* warm cream — buttermilk */
  --paper-edge:   #ECE5D7;  /* slightly deeper, for lifts */
  --surface:      #FFFFFF;  /* card */
  --surface-2:    #FBF7EE;  /* slightly raised — popovers, dropdowns */
  --ink:          #1A1714;  /* warm near-black */
  --ink-2:        #3B362F;  /* secondary ink */
  --muted:        #76706A;  /* warm stone, body subtle */
  --rule:         #DCD3C2;  /* hairline rules, faint stone */
  --rule-strong:  #B6AC97;  /* heavier rules for table heads */

  --accent:       #2C5A37;  /* deep forest — herb green */
  --accent-ink:   #173321;  /* darker for hover */
  --accent-soft:  #DDE6DB;  /* tinted background */
  --accent-fg:    #FFFFFF;  /* foreground that sits on --accent */

  --amber:        #A66423;  /* aged cheese / aging milk caramel */
  --amber-ink:    #5A3811;  /* deep amber for warn-notice text */
  --amber-soft:   #F2E4CD;
  --amber-hover:  #8A5219;  /* btn:hover bg */
  --oxblood:      #8B2A2A;  /* danger / waste, deliberate not generic red */
  --oxblood-ink:  #5B1C1C;
  --oxblood-soft: #ECD7D7;
  --oxblood-hover: #6F2222;

  /* Translucent overlays — derived from the paper hue so backdrop
   * blurs read as "this UI lives on the same paper". */
  --paper-veil-92: rgba(244, 239, 230, 0.92);  /* topbar, header */
  --paper-veil-70: rgba(244, 239, 230, 0.70);  /* sidebar */
  --backdrop:      rgba(26, 23, 20, 0.42);     /* drawer backdrop */
  --inset-light:   rgba(255, 255, 255, 0.65);  /* card top highlight */
  --select-chev-stroke: %23173321;             /* SVG-encoded for selects */

  /* Spacing */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;
  --s-8: 4.5rem;

  --radius-1: 2px;   /* small details */
  --radius-2: 4px;   /* buttons, inputs */
  --radius-3: 8px;   /* cards */

  /* Layered shadow system — light theme. Each card gets a hairline
   * top-highlight from --inset-light and a soft drop. Pop layer is
   * for menus, dropdowns, focused dialogs.  */
  --shadow-1:
    inset 0 1px 0 var(--inset-light),
    0 1px 1px rgba(26, 23, 20, 0.04);
  --shadow-2:
    inset 0 1px 0 var(--inset-light),
    0 1px 2px rgba(26, 23, 20, 0.05),
    0 14px 36px -22px rgba(26, 23, 20, 0.22);
  --shadow-pop:
    inset 0 1px 0 var(--inset-light),
    0 4px 14px -4px rgba(26, 23, 20, 0.10),
    0 18px 44px -22px rgba(26, 23, 20, 0.22);
  --shadow-drawer: 0 0 0 1px var(--rule), 0 16px 48px -12px rgba(26, 23, 20, 0.45);

  --ring-focus: 0 0 0 3px var(--accent-soft);

  /* Page-grain — a single SVG turbulence baked into a data URI. The
   * monochrome filter makes it work on top of any --paper tint. */
  --bg-grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.10  0 0 0 0 0.09  0 0 0 0 0.08  0 0 0 0.06 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");

  --content-max: 1520px;
  --sidebar-w: 240px;
  --topbar-h: 56px;

  color-scheme: light;
}

/* ----- Dark theme — midnight ink, sage on navy ----- *
 * Tokens swap by name only; components stay theme-agnostic. The
 * palette is built around a deep prussian-tinted navy so green
 * accents (sage, mint) stay readable while amber and clay-rose
 * carry warmth into the cool shell. */
[data-theme="dark"] {
  --paper:        #0C1545;  /* deep cobalt-indigo */
  --paper-edge:   #142058;  /* lifted */
  --surface:      #1A2A6E;  /* card — royal indigo */
  --surface-2:    #243A86;  /* popovers, dropdowns, hover lifts */
  --ink:          #F2EBDC;  /* warm cream */
  --ink-2:        #C9C0B0;
  --muted:        #8E96B8;
  --rule:         #20306A;
  --rule-strong:  #3D4F90;

  --accent:       #6FBF94;  /* sage — readable on indigo */
  --accent-ink:   #9DD9B8;  /* lighter for hover */
  --accent-soft:  #1B3528;  /* tinted bg */
  --accent-fg:    #0C1545;  /* dark text on the bright accent */

  --amber:        #DDB066;  /* warmer mustard against navy */
  --amber-ink:    #F0CB8B;
  --amber-soft:   #3A2A12;
  --amber-hover:  #C29142;
  --oxblood:      #E89A9A;  /* clay-rose, not pure red */
  --oxblood-ink:  #F4BFBF;
  --oxblood-soft: #3A1B1B;
  --oxblood-hover: #C97A7A;

  --paper-veil-92: rgba(12, 21, 69, 0.92);
  --paper-veil-70: rgba(12, 21, 69, 0.72);
  --backdrop:      rgba(0, 0, 0, 0.55);
  --inset-light:   rgba(255, 255, 255, 0.05);
  --select-chev-stroke: %239DD9B8;

  --shadow-1:
    inset 0 1px 0 var(--inset-light),
    0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-2:
    inset 0 1px 0 var(--inset-light),
    0 2px 4px rgba(0, 0, 0, 0.35),
    0 22px 48px -22px rgba(0, 0, 0, 0.65);
  --shadow-pop:
    inset 0 1px 0 var(--inset-light),
    0 6px 18px -6px rgba(0, 0, 0, 0.55),
    0 28px 56px -22px rgba(0, 0, 0, 0.65);
  --shadow-drawer:
    0 0 0 1px var(--rule-strong),
    0 22px 56px -12px rgba(0, 0, 0, 0.7);

  --bg-grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.04 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");

  color-scheme: dark;
}

/* ---------- Reset, base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--ink);
  background-color: var(--paper);
  /* Three-light staging: a deeper paper-edge bloom in the top-left
   * (where the eye lands first), a sage halo in the bottom-right
   * (where the page exhales), and a warm amber wash bottom-left
   * (where receipts and primary actions sit). Together they turn
   * the page from a flat field into a quietly lit room. */
  background-image:
    radial-gradient(1100px 720px at 8% -8%,  color-mix(in srgb, var(--paper-edge) 95%, transparent) 0%, transparent 62%),
    radial-gradient(950px 620px at 102% 108%, color-mix(in srgb, var(--accent-soft) 80%, transparent) 0%, transparent 58%),
    radial-gradient(820px 540px at -2% 96%,  color-mix(in srgb, var(--amber-soft) 55%, transparent) 0%, transparent 55%),
    var(--bg-grain);
  background-attachment: fixed;
  font-feature-settings: "ss01", "kern";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.25s ease, color 0.25s ease;
}

a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--accent-ink); }

p { margin: 0 0 var(--s-4); }

::selection { background: var(--accent); color: var(--paper); }

/* ---------- Type ---------- */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--ink);
  margin: 0 0 var(--s-4);
  font-weight: 500;
  line-height: var(--lh-tight);
  letter-spacing: -0.015em;
  font-variation-settings: "opsz" 24, "SOFT" 0, "WONK" 0;
}
h1 { font-size: var(--fs-2xl); font-variation-settings: "opsz" 36, "SOFT" 0; }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); font-weight: 500; }

.eyebrow {
  display: inline-block;
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 var(--s-2);
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: var(--s-4);
  border-bottom: 1px solid var(--rule);
  padding-bottom: var(--s-3);
  margin: var(--s-6) 0 var(--s-5);
}
.section-head h2 { margin: 0; }
.section-head .eyebrow { margin: 0; }

/* Solo eyebrow as section header — no h2 sibling. Used in form pages
 * where the eyebrow text alone (IDENTIFIKACE, KONTAKT, …) is sufficient
 * and a second h2 in display font would be visually redundant. */
.section-head--solo { padding-bottom: var(--s-2); margin: var(--s-5) 0 var(--s-4); }
.section-head--solo .eyebrow { padding-bottom: 0; }

.lede {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-variation-settings: "opsz" 14, "SOFT" 100;
  color: var(--ink-2);
  max-width: 60ch;
}

code, .mono, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.94em;
}

/* ---------- Layout shell ---------- */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  max-width: var(--content-max);
  margin: 0 auto;
}
.shell.shell--full {
  grid-template-columns: minmax(0, 1fr);
}

/* Mobile top bar — hidden on desktop, hamburger + brand on phones. */
.topbar {
  display: none;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--paper-veil-92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-brand {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--ink);
}
.topbar-brand small {
  margin-left: 0.4rem;
  font-family: var(--font-body);
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  vertical-align: 0.18em;
}
.menu-toggle {
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  color: var(--ink);
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-2);
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.menu-toggle:hover { background: var(--paper-edge); border-color: var(--ink); color: var(--ink); }

/* Sidebar — sticky column on desktop, slide-in drawer on mobile. */
.sidebar {
  border-right: 1px solid var(--rule);
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  background-color: var(--paper-veil-70);
  backdrop-filter: blur(8px);
  z-index: 40;
}
.sidebar-inner {
  padding: var(--s-7) var(--s-5) var(--s-5);
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.sidebar .brand {
  display: block;
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: var(--s-5);
  color: var(--ink);
}
.sidebar .brand small {
  display: block;
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: var(--s-2);
  font-weight: 500;
}

/* Backdrop sits BELOW drawer on mobile (z-index 30 < drawer 40). */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  backdrop-filter: blur(2px);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

/* Compact search input inside the sidebar — proportional to the
 * nav link text below it, no decorative icon (it overlapped the
 * placeholder and didn't move with typed text). */
.nav-search-wrap {
  display: block;
  margin: 0 0 var(--s-3);
}
.nav-search-wrap input[type="search"] {
  width: 100%;
  margin-top: 0;
  padding: 0.35rem 0.55rem;
  font-size: var(--fs-sm);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-2);
  color: var(--ink);
}
.nav-search-wrap input[type="search"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: 0;
}
.nav-empty {
  margin: var(--s-3) var(--s-2) 0;
  font-size: var(--fs-xs);
  color: var(--muted);
  font-style: italic;
}

/* Collapsible groups via <details>/<summary>. */
.nav-group {
  margin: 0 0 var(--s-2);
  border-radius: var(--radius-2);
}
.nav-group > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-2);
  font-size: var(--fs-xs);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  border-radius: var(--radius-2);
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover { color: var(--ink); background: var(--paper-edge); }
.nav-group > summary .chev {
  margin-left: auto;
  width: 0.42rem;
  height: 0.42rem;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.18s ease;
  display: inline-block;
}
.nav-group[open] > summary .chev { transform: rotate(45deg); }
.nav {
  list-style: none;
  margin: var(--s-1) 0 var(--s-3);
  padding: 0;
  display: flex;
  flex-direction: column;
}
.nav a {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-2);
  color: var(--ink-2);
  font-size: var(--fs-sm);
  border-radius: var(--radius-2);
  transition: color 0.15s ease, background-color 0.15s ease;
}
.nav a:hover { color: var(--ink); background-color: var(--paper-edge); }
.nav a .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background-color: var(--rule-strong);
  flex-shrink: 0;
}
.nav a:hover .dot { background-color: var(--accent); }

/* Scoped to the operator-UI shell so it doesn't clobber Django admin's
 * own .main styling when farmshop.css is loaded inside admin pages. */
.shell .main {
  padding: var(--s-7) var(--s-8) var(--s-8);
  min-width: 0;
}
.shell .main--narrow { max-width: 760px; }

/* ----- Mobile breakpoint ----- */
@media (max-width: 800px) {
  .topbar { display: flex; }
  .shell { grid-template-columns: 1fr; }
  .shell .main { padding: var(--s-5) var(--s-4) var(--s-7); }

  .sidebar {
    position: fixed;
    /* Sit below the topbar so the hamburger stays accessible while open. */
    top: var(--topbar-h);
    left: 0;
    /* Wide enough to actually see the menu — phone widths typically 360–430 px. */
    width: min(92vw, 420px);
    /* Explicit full-height: dvh follows iOS Safari's address-bar collapse,
     * vh is the fallback. bottom: 0 alone wasn't reliably reaching the
     * actual viewport bottom on iOS. */
    height: calc(100vh - var(--topbar-h));
    height: calc(100dvh - var(--topbar-h));
    bottom: auto;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.2, 0.7, 0.2, 1);
    background-color: var(--paper);
    /* Solid drawer — no blur, no translucency on mobile so taps register clearly. */
    backdrop-filter: none;
    box-shadow: var(--shadow-drawer);
    border-right: 0;
  }
  .sidebar-inner {
    padding: var(--s-4) var(--s-5) calc(var(--s-7) + env(safe-area-inset-bottom));
  }
  .sidebar .brand { display: none; } /* topbar already shows the brand */

  /* Bigger group labels and links on phones — easier to scan and tap. */
  .nav-group > summary { font-size: var(--fs-sm); padding: var(--s-3) var(--s-2); }
  .nav-group > summary .chev { width: 0.55rem; height: 0.55rem; }
  .nav a { font-size: var(--fs-base); padding: var(--s-3) var(--s-2); }
  .nav a .dot { width: 7px; height: 7px; }

  .sidebar-backdrop {
    display: block;
    /* Backdrop also starts below the topbar — keeps the hamburger button
     * unobscured and obviously tappable to close. */
    top: var(--topbar-h);
  }

  body.menu-open .sidebar { transform: translateX(0); }
  body.menu-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  body.menu-open { overflow: hidden; }
}

/* ---------- Page header ---------- */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-5);
  margin-bottom: var(--s-6);
  padding-bottom: var(--s-4);
  border-bottom: 1px solid var(--rule);
}
.page-head h1 { margin: 0; }
.page-head .actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* ---------- Buttons ---------- */

/* Buttons explicitly opt in via .btn / [role="button"] — we used to
 * style every <button:not(.unstyled)> globally, which leaked into
 * Django admin once farmshop.css was loaded there. */
.btn, button.btn, [role="button"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 0.55rem 1rem;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-2);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover, [role="button"]:hover {
  background: var(--accent-ink);
  border-color: var(--accent-ink);
  color: var(--paper);
}
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
}
.btn--primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn--ghost, [role="button"].ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule-strong);
}
.btn--ghost:hover {
  background: var(--paper-edge);
  border-color: var(--ink);
  color: var(--ink);
}
.btn--danger { background: var(--oxblood); border-color: var(--oxblood); color: var(--accent-fg); }
.btn--danger:hover { background: var(--oxblood-hover); border-color: var(--oxblood-hover); color: var(--accent-fg); }
/* Amber for "save for later" / non-destructive secondary commits.
 * Sits between primary (commit & finalize) and ghost (cancel/back). */
.btn--amber { background: var(--amber); border-color: var(--amber); color: var(--paper); }
.btn--amber:hover { background: var(--amber-hover); border-color: var(--amber-hover); color: var(--paper); }
.btn--small { padding: 0.35rem 0.7rem; font-size: var(--fs-xs); }
.btn--bare {
  background: transparent;
  color: var(--ink-2);
  border-color: transparent;
  padding: var(--s-1) var(--s-2);
}
.btn--bare:hover { color: var(--ink); background: var(--paper-edge); }

/* ---------- Cards / surfaces ---------- */

.card, article {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-3);
  padding: var(--s-5);
  margin: 0 0 var(--s-4);
  box-shadow: var(--shadow-1);
}
.card--bare { background: transparent; border: 0; box-shadow: none; padding: 0; }

.grid {
  display: grid;
  gap: var(--s-4);
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

/* ---------- Forms ---------- */

form { display: block; }

/* Editorial small-caps labels — only inside operator-UI shells. Django
 * admin has its own field-label styling we don't want to override. */
.shell label, .auth-card label {
  display: block;
  margin-bottom: var(--s-4);
  font-size: var(--fs-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

/* Form input styling scoped to operator-UI contexts so it doesn't
 * override Django admin's inline forms (admin uses tighter, side-by-side
 * inputs that the global width:100% rule would break). */
.shell input[type="text"], .shell input[type="number"], .shell input[type="date"],
.shell input[type="email"], .shell input[type="password"], .shell input[type="search"],
.shell input[type="tel"], .shell input[type="url"], .shell input:not([type]),
.shell select, .shell textarea,
.auth-card input[type="text"], .auth-card input[type="password"],
.sidebar input[type="search"] {
  display: block;
  width: 100%;
  margin-top: var(--s-2);
  padding: 0.55rem 0.6rem;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-2);
  letter-spacing: normal;
  text-transform: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.shell input:focus, .shell select:focus, .shell textarea:focus,
.auth-card input:focus, .sidebar input[type="search"]:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: var(--ring-focus);
}
.shell input[type="number"] { font-variant-numeric: tabular-nums; }

.shell select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%23889AAA' stroke-width='1.4' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  padding-right: 2rem;
}

.field-row {
  display: grid;
  gap: var(--s-4);
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.shell .help { font-size: var(--fs-xs); color: var(--muted); margin-top: var(--s-1); text-transform: none; letter-spacing: 0; }

/* Sales-form product picker: input fills the row, button stays natural width. */
.product-picker {
  display: flex;
  gap: var(--s-2);
  align-items: stretch;
  margin: var(--s-3) 0;
}
.product-picker input { margin-top: 0; flex: 1 1 auto; min-width: 0; }
.product-picker button { flex: 0 0 auto; }

/* Inline action group inside table cells (receipts list, etc.) */
.row-actions {
  display: inline-flex;
  gap: var(--s-2);
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.row-actions form { margin: 0; }

/* ---------- Tables — editorial, not boxed ----------
 * Scoped to .shell so this styling doesn't override Django admin's
 * tables when farmshop.css is loaded inside the admin shell. */

.shell table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.shell table th {
  text-align: left;
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  padding: var(--s-3) var(--s-2);
  border-bottom: 1px solid var(--rule-strong);
  white-space: nowrap;
}
.shell table td {
  padding: var(--s-3) var(--s-2);
  border-bottom: 1px solid var(--rule);
  color: var(--ink-2);
  vertical-align: top;
}
.shell table tr:last-child td { border-bottom: 0; }
.shell table.tight th, .shell table.tight td { padding: var(--s-2); }

/* Even denser variant for high-row-count list pages — smaller body font,
 * tighter vertical padding. Used by /customers/, /products/, /suppliers/,
 * /categories/, /units/. Combine with `tight` for matching horizontal
 * spacing. Inputs inside cells stay readable because operator forms
 * (sell.html) don't use this variant. */
.shell table.dense { font-size: var(--fs-sm); }
.shell table.dense th { padding: 0.55rem 0.5rem; }
.shell table.dense td { padding: 0.4rem 0.5rem; vertical-align: middle; }
.shell table.dense .btn--small { padding: 0.25rem 0.55rem; }
.shell table.dense .row-actions { gap: var(--s-1); }

.shell table .num {
  font-family: var(--font-mono);
  text-align: right;
  color: var(--ink);
  font-feature-settings: "tnum" 1;
}
.shell table .right { text-align: right; }

/* ---------- Tags / chips for codes, lots, statuses ---------- */

.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 0.18rem 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  background: var(--paper-edge);
  color: var(--ink-2);
  border-radius: var(--radius-1);
  border: 1px solid var(--rule);
}
.tag--accent { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent); }
.tag--amber  { background: var(--amber-soft);  color: var(--amber);     border-color: var(--amber); }
.tag--ox     { background: var(--oxblood-soft); color: var(--oxblood);  border-color: var(--oxblood); }

.tag--status {
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ---------- Quantity readouts ---------- */

.qty {
  font-family: var(--font-mono);
  font-feature-settings: "tnum" 1;
  letter-spacing: -0.01em;
}
.qty .unit {
  margin-left: 0.18em;
  font-size: 0.82em;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.metric {
  display: block;
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  font-variation-settings: "opsz" 144, "SOFT" 0;
  font-weight: 400;
  font-feature-settings: "tnum" 1;
  line-height: 1;
  letter-spacing: -0.02em;
}
.metric .unit {
  font-family: var(--font-body);
  font-size: 0.4em;
  font-weight: 500;
  margin-left: 0.3em;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  vertical-align: 0.6em;
}

/* ---------- Tile cards (dashboard) ---------- */

.tiles {
  display: grid;
  gap: var(--s-4);
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--s-5);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-3);
  padding: var(--s-5);
  min-height: 200px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.tile:hover {
  border-color: var(--rule-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}
.tile h3 { margin: 0; }
.tile .actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.tile .corner {
  position: absolute;
  top: var(--s-4);
  right: var(--s-4);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--muted);
  letter-spacing: 0.1em;
}

/* ---------- Trace timeline (lot lineage) ---------- */

.trace { margin: 0; padding: 0; list-style: none; }
.trace-step {
  position: relative;
  padding: var(--s-4) 0 var(--s-4) var(--s-6);
  border-left: 1px solid var(--rule-strong);
  margin-left: var(--s-2);
}
.trace-step:last-child { border-left-color: transparent; }
.trace-step::before {
  content: "";
  position: absolute;
  left: -5px; top: var(--s-5);
  width: 9px; height: 9px;
  background: var(--ink);
  border-radius: 50%;
}
.trace-step.is-input::before { background: var(--accent); }
.trace-step .step-label {
  display: block;
  font-size: var(--fs-xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--s-1);
}
.trace-step .step-title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  margin-bottom: var(--s-1);
}
.trace-step .step-meta { font-size: var(--fs-sm); color: var(--ink-2); }
.trace-step ul.trace { margin-top: var(--s-3); }

/* ---------- Receipt — the wow moment ---------- */

.receipt {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  padding: var(--s-7) var(--s-6);
  margin: var(--s-5) 0;
  max-width: 640px;
  box-shadow: var(--shadow-2);
}
.receipt::before, .receipt::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 14px;
  background-image: linear-gradient(135deg, transparent 33%, var(--paper) 34%, var(--paper) 66%, transparent 67%);
  background-size: 18px 14px;
}
.receipt::before { top: -14px; }
.receipt::after  { bottom: -14px; transform: scaleY(-1); }
.receipt .crop {
  position: absolute;
  width: 14px; height: 14px;
  border-color: var(--ink);
  border-style: solid;
}
.receipt .crop.tl { top: 8px; left: 8px;  border-width: 1px 0 0 1px; }
.receipt .crop.tr { top: 8px; right: 8px; border-width: 1px 1px 0 0; }
.receipt .crop.bl { bottom: 8px; left: 8px;  border-width: 0 0 1px 1px; }
.receipt .crop.br { bottom: 8px; right: 8px; border-width: 0 1px 1px 0; }

.receipt-head {
  text-align: center;
  border-bottom: 1px dashed var(--rule-strong);
  padding-bottom: var(--s-4);
  margin-bottom: var(--s-5);
}
.receipt-head .number {
  font-family: var(--font-mono);
  font-size: var(--fs-lg);
  letter-spacing: 0.1em;
}
.receipt-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-top: 1px solid var(--rule-strong);
  margin-top: var(--s-4);
  padding-top: var(--s-4);
}
.receipt-total .metric { font-size: var(--fs-2xl); }

.qr-frame {
  margin: var(--s-5) auto 0;
  max-width: 280px;
  text-align: center;
}
.qr-frame img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--surface);
  padding: var(--s-3);
  border: 1px solid var(--ink);
}
.qr-frame .payload {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: var(--s-3);
  word-break: break-all;
}

/* ---------- Notices / alerts ---------- */

.notice {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--radius-2);
  margin: 0 0 var(--s-4);
  font-size: var(--fs-sm);
}
.notice--warn   { border-color: var(--amber);   background: var(--amber-soft);   color: var(--amber-ink); }
.notice--danger { border-color: var(--oxblood); background: var(--oxblood-soft); color: var(--oxblood-ink); }

/* ---------- Login (full-bleed centered) ---------- */

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--s-5);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-3);
  padding: var(--s-7) var(--s-6) var(--s-6);
  box-shadow: var(--shadow-2);
}
.auth-card .brand {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: var(--s-2);
}
.auth-card .brand small {
  display: block;
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: var(--s-2);
}

/* ---------- Page-load reveal ---------- */

@keyframes fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.reveal > * {
  animation: fade-up 0.55s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.reveal > *:nth-child(1) { animation-delay: 0.02s; }
.reveal > *:nth-child(2) { animation-delay: 0.08s; }
.reveal > *:nth-child(3) { animation-delay: 0.14s; }
.reveal > *:nth-child(4) { animation-delay: 0.20s; }
.reveal > *:nth-child(5) { animation-delay: 0.26s; }
.reveal > *:nth-child(6) { animation-delay: 0.32s; }

/* HTMX swap fade — applied to swapped fragments */
.htmx-swapping { opacity: 0; transition: opacity 120ms ease; }
.htmx-settling { opacity: 1; transition: opacity 220ms ease; }

/* ---------- Docs (in-app standards / architecture pages) ---------- */

.doc {
  max-width: 920px;
  margin: 0 auto;
}
.doc .lede {
  border-left: 3px solid var(--accent);
  padding-left: var(--s-4);
  margin: var(--s-5) 0 var(--s-6);
}

.doc .toc {
  background: var(--paper-edge);
  border-radius: var(--radius-3);
  padding: var(--s-4) var(--s-5);
  margin: 0 0 var(--s-6);
  display: grid;
  gap: var(--s-1);
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.doc .toc a {
  display: block;
  font-size: var(--fs-sm);
  color: var(--ink-2);
  padding: var(--s-1) 0;
  border-bottom: 1px solid transparent;
}
.doc .toc a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.doc .toc .num {
  display: inline-block;
  width: 1.6em;
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 0.8em;
}

.spec {
  margin: var(--s-6) 0;
  padding: 0 0 0 var(--s-5);
  border-left: 1px solid var(--rule-strong);
}
.spec > .num {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.18em;
  color: var(--muted);
  margin-bottom: var(--s-1);
}
.spec > h2 {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  margin: 0 0 var(--s-3);
}
.spec ul, .spec ol { padding-left: var(--s-5); margin: 0 0 var(--s-3); }
.spec li { margin-bottom: var(--s-2); }
.spec p { margin-bottom: var(--s-3); }
.spec code {
  background: var(--paper-edge);
  padding: 0.08em 0.3em;
  border-radius: var(--radius-1);
}

.severity {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 0.18rem 0.45rem;
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: var(--radius-1);
  border: 1px solid;
}
.severity--easy   { background: var(--accent-soft);  color: var(--accent-ink); border-color: var(--accent); }
.severity--struct { background: var(--amber-soft);   color: var(--amber-ink);  border-color: var(--amber); }
.severity--ok     { background: var(--paper-edge);   color: var(--muted);      border-color: var(--rule-strong); }
.severity--note   { background: var(--surface);      color: var(--ink-2);      border-color: var(--rule-strong); }

.callout {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-2);
  padding: var(--s-4) var(--s-5);
  margin: var(--s-5) 0;
}
.callout--warn   { border-left-color: var(--amber); }
.callout--danger { border-left-color: var(--oxblood); }
.callout .lbl {
  display: block;
  font-size: var(--fs-xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--s-1);
}

.field-rules {
  display: grid;
  gap: var(--s-2);
  margin: var(--s-4) 0;
  grid-template-columns: max-content 1fr;
  align-items: start;
}
.field-rules dt {
  font-family: var(--font-mono);
  font-size: 0.92em;
  color: var(--ink);
  background: var(--paper-edge);
  padding: 0.12rem 0.5rem;
  border-radius: var(--radius-1);
  white-space: nowrap;
}
.field-rules dd {
  margin: 0;
  color: var(--ink-2);
  font-size: var(--fs-sm);
}

/* ---------- Production process flow ---------- */

.flow {
  list-style: none;
  margin: var(--s-5) 0;
  padding: 0;
  position: relative;
}
.flow > li {
  position: relative;
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: var(--s-4);
  padding-bottom: var(--s-5);
}
.flow > li::before {
  content: "";
  position: absolute;
  left: 27px;
  top: 56px;
  bottom: -8px;
  width: 2px;
  background: var(--rule-strong);
}
.flow > li:last-child::before { display: none; }

.flow .step-num {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--ink);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-variation-settings: "opsz" 36, "SOFT" 0;
  line-height: 1;
  color: var(--ink);
  z-index: 1;
}
.flow > li.is-input .step-num   { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
.flow > li.is-byprod .step-num  { border-color: var(--amber);  color: var(--amber);      background: var(--amber-soft); }
.flow > li.is-output .step-num  { border-color: var(--ink);    color: var(--paper);      background: var(--ink); }

.flow .step-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-3);
  padding: var(--s-4) var(--s-5);
  box-shadow: var(--shadow-1);
}
.flow .step-card h3 {
  margin: 0 0 var(--s-2);
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-variation-settings: "opsz" 14, "SOFT" 0;
}
.flow .step-card p { margin: 0 0 var(--s-2); color: var(--ink-2); font-size: var(--fs-sm); }
.flow .step-card .params {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin: var(--s-2) 0;
}
.flow .step-card .params .tag { font-size: 0.72rem; }
.flow .step-card .map {
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px dashed var(--rule);
  font-size: var(--fs-xs);
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: baseline;
}
.flow .step-card .map .lbl {
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  font-size: 0.72rem;
}
.flow .step-card .map code {
  background: var(--paper-edge);
  padding: 0.06rem 0.3rem;
  border-radius: var(--radius-1);
  font-family: var(--font-mono);
  color: var(--ink-2);
}

.module-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.5rem;
  border-radius: var(--radius-1);
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid;
}
.module-pill--inv     { background: var(--accent-soft);  color: var(--accent-ink); border-color: var(--accent); }
.module-pill--cat     { background: var(--paper-edge);   color: var(--ink);        border-color: var(--rule-strong); }
.module-pill--prod    { background: var(--amber-soft);   color: var(--amber-ink);  border-color: var(--amber); }
.module-pill--future  { background: var(--surface);      color: var(--muted);      border-color: var(--rule-strong); border-style: dashed; }

.line-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-3);
  padding: var(--s-5) var(--s-6);
  margin: var(--s-5) 0;
  box-shadow: var(--shadow-1);
  border-top: 4px solid var(--rule-strong);  /* default; overrides per produkt below */
}

/* Barevné rozlišení 7 výrob. Pruh nahoře + ikona, jinak čistý layout. */
.line-card[data-produkt="mleko"]      { border-top-color: #5C8FB8; }   /* mléčně modrá */
.line-card[data-produkt="cerstvy"]    { border-top-color: var(--accent); }      /* sage zelená */
.line-card[data-produkt="tvaroh"]     { border-top-color: #A8B57F; }   /* světlá olivová */
.line-card[data-produkt="syr-gril"]   { border-top-color: var(--amber); }       /* zlato-amber */
.line-card[data-produkt="jogurt"]     { border-top-color: #D4A6A6; }   /* světlá růžová */
.line-card[data-produkt="kefir"]      { border-top-color: #6FBFA8; }   /* mátová */
.line-card[data-produkt="pasta"]      { border-top-color: var(--oxblood); }     /* cihlová */
.line-card[data-produkt="provoz"]     { border-top-color: var(--ink); }         /* tmavá pro souhrn */

.line-card .vyroba-eyebrow {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  margin: 0 0 var(--s-1);
}
.line-card .vyroba-eyebrow .num {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.18em;
  color: var(--muted);
  text-transform: uppercase;
}
.line-card .vyroba-eyebrow .badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.5rem;
  border-radius: var(--radius-1);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid;
}
.line-card[data-produkt="mleko"]    .badge { background: rgba(92,143,184,0.12); color: #2F5577; border-color: #5C8FB8; }
.line-card[data-produkt="cerstvy"]  .badge { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent); }
.line-card[data-produkt="tvaroh"]   .badge { background: rgba(168,181,127,0.18); color: #4F5C2A; border-color: #A8B57F; }
.line-card[data-produkt="syr-gril"] .badge { background: var(--amber-soft); color: var(--amber-ink); border-color: var(--amber); }
.line-card[data-produkt="jogurt"]   .badge { background: rgba(212,166,166,0.20); color: #6E3B3B; border-color: #D4A6A6; }
.line-card[data-produkt="kefir"]    .badge { background: rgba(111,191,168,0.15); color: #2A5A47; border-color: #6FBFA8; }
.line-card[data-produkt="pasta"]    .badge { background: var(--oxblood-soft); color: var(--oxblood-ink); border-color: var(--oxblood); }
.line-card[data-produkt="provoz"]   .badge { background: var(--paper-edge); color: var(--ink); border-color: var(--rule-strong); }

[data-theme="dark"] .line-card[data-produkt="mleko"]    .badge { background: rgba(92,143,184,0.22); color: #B8D4EC; }
[data-theme="dark"] .line-card[data-produkt="tvaroh"]   .badge { background: rgba(168,181,127,0.25); color: #D8E0B6; }
[data-theme="dark"] .line-card[data-produkt="jogurt"]   .badge { background: rgba(212,166,166,0.25); color: #F0CECE; }
[data-theme="dark"] .line-card[data-produkt="kefir"]    .badge { background: rgba(111,191,168,0.20); color: #B6E0D2; }

/* Per-produkt --produkt-color pro flow markers + spojovací linky */
.line-card[data-produkt="mleko"]    { --produkt-color: #5C8FB8; }
.line-card[data-produkt="cerstvy"]  { --produkt-color: var(--accent); }
.line-card[data-produkt="tvaroh"]   { --produkt-color: #A8B57F; }
.line-card[data-produkt="syr-gril"] { --produkt-color: var(--amber); }
.line-card[data-produkt="jogurt"]   { --produkt-color: #D4A6A6; }
.line-card[data-produkt="kefir"]    { --produkt-color: #6FBFA8; }
.line-card[data-produkt="pasta"]    { --produkt-color: var(--oxblood); }
.line-card[data-produkt="provoz"]   { --produkt-color: var(--ink); }

/* Vertikální timeline výrobních kroků uvnitř line-card */
.line-card .vyroba-flow {
  list-style: none;
  margin: var(--s-5) 0 0;
  padding: 0;
}
.line-card .vyroba-flow > li {
  position: relative;
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: var(--s-4);
  padding: 0 0 var(--s-4) 0;
}
.line-card .vyroba-flow > li::before {
  content: "";
  position: absolute;
  left: 21px;
  top: 44px;
  bottom: 0;
  width: 2px;
  background: linear-gradient(
    to bottom,
    color-mix(in srgb, var(--produkt-color, var(--rule-strong)) 50%, transparent) 0%,
    color-mix(in srgb, var(--produkt-color, var(--rule-strong)) 22%, transparent) 100%
  );
}
.line-card .vyroba-flow > li:last-child {
  padding-bottom: 0;
}
.line-card .vyroba-flow > li:last-child::before {
  display: none;
}

.line-card .vyroba-flow .step-num {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--produkt-color, var(--rule-strong));
  color: var(--produkt-color, var(--ink));
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 500;
  position: relative;
  z-index: 1;
  box-shadow: 0 0 0 4px var(--surface);
  transition: transform 0.15s ease;
}
.line-card .vyroba-flow > li:hover .step-num {
  transform: scale(1.06);
  background: color-mix(in srgb, var(--produkt-color, var(--rule-strong)) 12%, var(--surface));
}

.line-card .vyroba-flow .step-card {
  padding: 0.5rem 0 0;
  min-width: 0;
}
.line-card .vyroba-flow .step-title {
  font-weight: 500;
  color: var(--ink);
  margin: 0 0 0.2rem;
  font-size: var(--fs-base);
  letter-spacing: -0.005em;
}
.line-card .vyroba-flow .step-body {
  color: var(--ink-2);
  font-size: var(--fs-sm);
  line-height: 1.5;
  margin: 0;
}
.line-card .vyroba-flow .step-body .param {
  display: inline-flex;
  align-items: center;
  padding: 0.05rem 0.42rem;
  margin: 0 0.1rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: color-mix(in srgb, var(--produkt-color, var(--rule-strong)) 14%, var(--surface));
  color: var(--ink);
  border-radius: var(--radius-1);
  white-space: nowrap;
}

.line-card blockquote {
  margin: var(--s-3) 0 var(--s-4);
  padding: var(--s-3) var(--s-4);
  background: var(--paper-edge);
  border-left: 3px solid var(--rule-strong);
  border-radius: var(--radius-2);
  color: var(--ink-2);
  font-size: var(--fs-sm);
  font-style: italic;
}
.line-card[data-produkt="syr-gril"] blockquote { border-left-color: var(--amber); }
.line-card[data-produkt="kefir"]    blockquote { border-left-color: #6FBFA8; }
.line-card[data-produkt="pasta"]    blockquote { border-left-color: var(--oxblood); }

.line-card .post-section {
  margin: var(--s-5) 0 0;
  padding-top: var(--s-4);
  border-top: 1px dashed var(--rule);
}
.line-card .post-section h3 {
  margin: 0 0 var(--s-2);
  font-family: var(--font-display);
  font-size: var(--fs-lg);
}

/* TOC pro produkční stránku — kompaktní karty s barevným tečkovaným indikátorem.
 * `grid-auto-rows: 1fr` srovná všechny řádky na výšku nejvyšší karty;
 * `min-height` zajistí konzistentní velikost i v posledním (kratším) řádku. */
.vyroba-toc {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  grid-auto-rows: 1fr;
  gap: var(--s-2);
  margin: var(--s-5) 0 var(--s-6);
  padding: 0;
  list-style: none;
}
.vyroba-toc > li { display: contents; }
.vyroba-toc a {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3);
  min-height: 3.1rem;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-2);
  font-size: var(--fs-sm);
  color: var(--ink-2);
  text-decoration: none;
  transition: border-color 0.12s ease, transform 0.12s ease;
}
.vyroba-toc a:hover { border-color: var(--rule-strong); color: var(--ink); transform: translateY(-1px); }
.vyroba-toc a::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--rule-strong);
  flex-shrink: 0;
}
.vyroba-toc a[href="#mleko"]::before    { background: #5C8FB8; }
.vyroba-toc a[href="#cerstvy"]::before  { background: var(--accent); }
.vyroba-toc a[href="#tvaroh"]::before   { background: #A8B57F; }
.vyroba-toc a[href="#syr-gril"]::before { background: var(--amber); }
.vyroba-toc a[href="#jogurt"]::before   { background: #D4A6A6; }
.vyroba-toc a[href="#kefir"]::before    { background: #6FBFA8; }
.vyroba-toc a[href="#pasta"]::before    { background: var(--oxblood); }
.vyroba-toc a[href="#provoz"]::before   { background: var(--ink); }
.line-card .lede { margin-top: 0; }
.line-card h2 {
  margin: 0 0 var(--s-3);
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-variation-settings: "opsz" 36, "SOFT" 0;
  letter-spacing: -0.015em;
}
.line-card .meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--s-3);
  margin: var(--s-4) 0 var(--s-5);
  padding: var(--s-3) var(--s-4);
  background: var(--paper-edge);
  border-radius: var(--radius-2);
  font-size: var(--fs-sm);
}
.line-card .meta .k { color: var(--muted); font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; }
.line-card .meta .v { color: var(--ink); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  margin: var(--s-3) 0;
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.legend-item { display: inline-flex; align-items: center; gap: var(--s-2); }
.legend-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--surface);
  border: 2px solid;
}
.legend-dot--inv    { border-color: var(--accent); background: var(--accent-soft); }
.legend-dot--byprod { border-color: var(--amber);  background: var(--amber-soft); }
.legend-dot--output { border-color: var(--ink);    background: var(--ink); }

/* ---------- Print stylesheet ----------
 * Strips all chrome (topbar, sidebar, page header, action buttons,
 * notices, navigation) and prints just the .receipt element centered
 * on the page. Triggered via window.print() from the Tisk button on
 * the receipt detail page.
 */
@media print {
  /* Reset paper texture + accent colors so we don't waste ink. */
  body {
    background: #fff !important;
    background-image: none !important;
    color: #000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body::before, body::after { display: none !important; }

  /* Anything that isn't the receipt is chrome — hide it. */
  .topbar,
  .sidebar,
  .sidebar-backdrop,
  .page-head,
  .actions,
  .notice,
  nav, footer,
  .reveal > .notice {
    display: none !important;
  }

  /* Reset the shell so the receipt isn't constrained by the grid. */
  .shell {
    display: block !important;
    max-width: none !important;
    margin: 0 !important;
  }
  .shell .main, main {
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
  }

  /* The receipt itself: simple ink-on-white card, no shadow / blur.
   * Compact paddings + tighter rows so ~10 items + QR fit on a single
   * A4 page. */
  .receipt {
    box-shadow: none !important;
    margin: 0 auto !important;
    max-width: 18cm !important;
    padding: 0.8rem 1.2rem !important;
    border: 1px solid #000 !important;
    page-break-inside: avoid;
    background: #fff !important;
  }
  /* Decorative perforations + crop marks: skip in print. */
  .receipt::before, .receipt::after { display: none !important; }
  .receipt .crop { display: none !important; }

  /* Compact header — receipt number + date in one tight block. */
  .receipt-head {
    padding-bottom: 0.4rem !important;
    margin-bottom: 0.5rem !important;
  }
  .receipt-head .number { font-size: 0.95rem !important; }

  /* Customer + note row pulled tight. */
  .receipt > .field-row {
    margin-bottom: 0.4rem !important;
    gap: 0.5rem !important;
  }
  .receipt > .field-row .eyebrow { margin-bottom: 0 !important; font-size: 0.6rem !important; }

  /* Section header above the items table. */
  .receipt .section-head {
    margin: 0.3rem 0 0.25rem !important;
    padding-bottom: 0.2rem !important;
  }

  /* Items table — tight rows, smaller text, 10+ rows fit. */
  .receipt table {
    font-size: 0.78rem !important;
    line-height: 1.25 !important;
  }
  .receipt table th, .receipt table td {
    padding: 0.18rem 0.4rem !important;
  }
  .receipt table th {
    font-size: 0.6rem !important;
  }

  /* Total — compact, but keep the metric readable. */
  .receipt-total {
    margin-top: 0.4rem !important;
    padding-top: 0.3rem !important;
  }
  .receipt-total .metric { font-size: 1.15rem !important; }

  /* Smaller QR — 110 px is comfortably scannable for SPD payloads. */
  .qr-frame {
    margin-top: 0.5rem !important;
    max-width: 110px !important;
  }
  .qr-frame img { border: 1px solid #000 !important; padding: 4px !important; }
  .qr-frame .eyebrow { font-size: 0.55rem !important; }
  /* Payload string is for screen verification — drop it in print to save space. */
  .qr-frame .payload { display: none !important; }

  /* Inline animations off. */
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }

  /* Force black ink on text + borders. */
  .receipt, .receipt * {
    color: #000 !important;
    border-color: #000 !important;
  }
}

/* ---------- Listy s navigací (`/customers/`, `/products/`, /receipts/, …) ----------
 * Společný kontejner: hlavní karta (border + radius), uvnitř hutná
 * tabulka, dole sticky paginace, která se drží ve viewportu, takže
 * uživatel nikdy nemusí scrollovat dolů jen kvůli "Další stránka". */

.list-shell {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-3);
  box-shadow: var(--shadow-1);
  overflow: hidden;          /* round-corner clip pro table head */
  margin-bottom: var(--s-4);
}
/* Pager žije *uvnitř* list-shell; aby sticky fungovalo přes table,
 * vypneme overflow:hidden na shellu jen když je vidět pager. Detail níže. */
.list-shell:has(.list-pager) { overflow: visible; }

.list-shell table.list-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-sm);
}
.list-shell table.list-table thead th {
  text-align: left;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.5rem 0.6rem;
  background: var(--paper-edge);
  border-bottom: 1px solid var(--rule-strong);
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}
.list-shell table.list-table tbody td {
  padding: 0.32rem 0.6rem;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-2);
  vertical-align: middle;
  line-height: 1.35;
}
.list-shell table.list-table tbody tr:last-child td { border-bottom: 0; }
.list-shell table.list-table tbody tr:hover td { background: color-mix(in srgb, var(--paper-edge) 50%, transparent); }
.list-shell table.list-table .num,
.list-shell table.list-table .right { text-align: right; }
.list-shell table.list-table .num { font-family: var(--font-mono); color: var(--ink); }
.list-shell table.list-table .btn--small { padding: 0.18rem 0.5rem; font-size: 0.72rem; }
.list-shell table.list-table .row-actions { gap: var(--s-1); }
.list-shell table.list-table .tag { font-size: 0.7rem; padding: 0.1rem 0.38rem; }

/* ----- Sticky pager — vždy vidět dole ve viewportu ----- */
.list-pager {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
  padding: 0.55rem 0.9rem;
  background: var(--paper-veil-92);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--rule);
  border-bottom-left-radius: var(--radius-3);
  border-bottom-right-radius: var(--radius-3);
  box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.04), 0 -10px 22px -16px rgba(0, 0, 0, 0.20);
}
.list-pager .summary {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--muted);
  letter-spacing: 0.04em;
}
.list-pager .controls {
  display: inline-flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  align-items: center;
}
.list-pager .controls a, .list-pager .controls span.curr {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.9rem;
  height: 1.7rem;
  padding: 0 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-2);
  color: var(--ink-2);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}
.list-pager .controls a:hover { border-color: var(--ink); color: var(--ink); }
.list-pager .controls span.curr {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  font-weight: 500;
}
.list-pager .controls .gap {
  display: inline-flex;
  align-items: center;
  height: 1.7rem;
  padding: 0 0.2rem;
  color: var(--muted);
  font-family: var(--font-mono);
}

/* Empty state uvnitř list-shell */
.list-shell .empty-state {
  padding: var(--s-7) var(--s-5);
  text-align: center;
  color: var(--muted);
  font-style: italic;
  font-family: var(--font-display);
}

/* ---------- Theme toggle ----------
 * Two square chip-buttons: sun + moon. The active one is filled with
 * --ink, inactive ones are bare. Lives at the foot of the sidebar on
 * desktop and inside the topbar on mobile. */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  box-shadow: var(--shadow-1);
}
.theme-toggle button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.theme-toggle button:hover { color: var(--ink); }
.theme-toggle button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}
.theme-toggle svg { width: 15px; height: 15px; }

.sidebar-foot {
  margin-top: var(--s-5);
  padding-top: var(--s-4);
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}
.sidebar-foot .label {
  font-size: var(--fs-xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

/* In the mobile topbar — keep it compact, push to the right edge.  */
.topbar .theme-toggle {
  margin-left: auto;
}

/* ---------- Utilities ---------- */

.row { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted { color: var(--muted); }
.right { text-align: right; }
.no-wrap { white-space: nowrap; }
.divider { height: 1px; background: var(--rule); margin: var(--s-5) 0; border: 0; }
.stack > * + * { margin-top: var(--s-4); }
.stack-tight > * + * { margin-top: var(--s-2); }
.empty {
  text-align: center;
  padding: var(--s-7) var(--s-4);
  color: var(--muted);
  font-style: italic;
  font-family: var(--font-display);
  font-variation-settings: "opsz" 14, "SOFT" 100;
}
