/* =====================================================================
   UK ASSET ERP — design system
   Ported from the "Premium Wealth" reference template.

   Warm off-white ground, one lime accent, 16px radius held rigidly,
   oversized tabular numerals, uppercase micro-labels. Light and dark.

   THREE RULES THAT EXPLAIN EVERY CHOICE BELOW
   -------------------------------------------
   1. Colour carries MEANING, never decoration. The lime accent marks the
      primary action and the micro-labels. --pos / --neg mark direction of
      money and nothing else. A badge is coloured because its state matters
      to a storekeeper at a glance, not to look lively.
   2. 16px radius is a constant. The only deviation is --r-xs on checkboxes
      and the block-grid cells, where 16px on a 30px square reads as a blob.
   3. This is a DENSE ERP, not a magazine. The reference is airy by design;
      tables here carry 25 rows, so row height, cell padding and font sizes
      are tightened from the reference while every colour, radius and
      spacing token is kept exactly.

   MOBILE AND TABLET ARE FIRST-CLASS TARGETS. A site manager uses this outdoors
   on a phone and a storekeeper uses it on an office iPad. The responsive ladder
   is Bootstrap's own, because bootstrap.min.css is vendored here and its
   col-md-* and col-lg-* classes obey it: below 1200px the sidebar is a drawer and
   every table restacks into label/value cards (labels injected from the <th> by
   app.js so they cannot drift); below 992px touch targets go to 44px, typed
   fields to 16px and the type scale up one step; below 768px the layout itself
   goes to one column. See the RESPONSIVE section for what this replaced and
   why.

   Superseded DESIGN-wired.md — see docs/DESIGN.md for why.
   ===================================================================== */

:root {
  color-scheme: light;

  /* ---- ground & surfaces ---- */
  --ground: #F4F4EF;
  --surface: #FFFFFF;
  --surface-2: #FAFAF5;
  --surface-3: #F1F1E9;

  /* ---- ink ---- */
  --ink: #121212;
  --ink-2: #3B3B34;
  --muted: #6C6C62;
  /* NON-TEXT ONLY, and this file now honours that: the three rules that used it
     as a text or glyph colour (.ba-missing, .inbox-report-empty, the
     .form-control hover border) have moved to --muted or --control-line, so
     app.css no longer references this token at all. Kept declared because
     notifications.css:195 still reads it for .notif-time, which measures 2.81:1
     light / 3.39:1 dark at 12px and wants the same substitution -- that file has
     a different writer. Anything reaching for this token for text is a bug;
     app.css:2227 already recorded the same verdict for the disabled flatpickr
     day ("--muted (5.3:1), not --faint (2.7:1): a disabled day still has to be
     legible"). */
  --faint: #9B9B90;

  /* ---- hairlines ---- */
  --line: #E3E3D9;
  --line-strong: #D2D2C6;
  /* --control-line exists because --line-strong was doing two incompatible
     jobs. As a card edge or a table rule 1.5:1 is a deliberate whisper. As the
     ONLY thing drawing the edge of a text input it was a defect: .form-control
     and .erp-card both paint var(--surface), so field and card were the same
     colour and #D2D2C6 on #FFFFFF measured 1.52:1 (dark: #3A392F on #1A1A17,
     1.50:1) where WCAG 1.4.11 asks 3:1 for the boundary of a control. A site
     manager on a 20-field form in daylight could read the labels and not see
     the boxes, so he tapped the label and got nothing.
     #84847A measures 3.78:1 on --surface, 3.61:1 on --surface-2 and 3.33:1 on
     --surface-3 -- the three grounds a control is ever drawn on here -- so the
     edge holds wherever the field lands. Dark #747469 is 3.69:1 / 3.49:1 /
     3.25:1 on the same three. Deliberately NOT applied to card edges: there the
     whisper is the design. */
  --control-line: #84847A;

  /* ---- accent: lime + ink ---- */
  --accent: #D8F34A;
  --accent-press: #C8E43A;
  --accent-ink: #121212;
  --accent-label: #63700F;   /* lime darkened to pass AA as text */
  --accent-soft: #EEF8C4;
  --accent-line: #C6DE72;

  /* ---- the single emphasis card per screen ---- */
  --emph-bg: #121212;
  --emph-ink: #FBFBF6;
  --emph-muted: #9A9A8E;
  --emph-accent: #D8F34A;
  --emph-track: #2A2A25;

  /* ---- direction: never decorative ---- */
  --pos: #2F7A45;  --pos-soft: #E4F1E7;
  --neg: #B3341F;  --neg-soft: #F8E7E3;
  --warn: #8A5A12; --warn-soft: #F6EEDA;

  /* ---- charts ----
     These are read by ERPCharts.readTokens() in static/js/app.js, not by any
     CSS rule, which is the point: Chart.js is styled FROM the design system
     instead of shipping its own palette. A stylesheet audit will report them
     as unused. They are not. */
  --grid: rgba(18,18,18,.06);
  --axis: #6C6C62;
  --series-1: #121212;
  --series-2: #A8C22F;
  --fill-top: rgba(216,243,74,.18);
  --fill-bottom: rgba(216,243,74,0);
  --tip-bg: #121212;
  --tip-ink: #FBFBF6;
  --tip-muted: #9A9A8E;
  /* One hue plus neutrals. A rainbow palette on an expense breakdown makes
     the reader hunt the legend instead of reading the chart. */
  --cat-1: #D8F34A; --cat-2: #A8C22F; --cat-3: #121212;
  --cat-4: #4A4A42; --cat-5: #8E8E82; --cat-6: #D8D8CE;

  /* ---- interaction ---- */
  --focus: #121212;
  --hover: rgba(18,18,18,.04);
  --press: rgba(18,18,18,.07);
  --overlay: rgba(24,24,20,.42);
  --shadow: 0 1px 3px rgba(16,24,40,.06);
  --shadow-pop: 0 1px 3px rgba(16,24,40,.10);

  /* ---- geometry ---- */
  --r: 16px;
  --r-xs: 5px;               /* checkboxes and block-grid cells only */

  /* ---- spacing, 4px base ---- */
  --sp-xxs: 2px;  --sp-xs: 4px;  --sp-sm: 8px;  --sp-md: 12px;
  --sp-lg: 16px;  --sp-xl: 20px; --sp-2xl: 24px; --sp-3xl: 32px; --sp-4xl: 48px;

  --sidebar-width: 260px;
  --topbar-height: 68px;

  /* ---- type ---- */
  /* System stack, deliberately. The reference uses no webfont, and neither
     should this: a site office on a weak connection gets text immediately,
     and there is no 250KB of font to download before the first figure is
     readable. Numerals are made tabular where they line up in columns. */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
               Arial, "Noto Sans", sans-serif;

  /* ---- THE TYPE SCALE ----
     Five text steps, stated once, so a size is a DECISION and not a leftover.
     What was here instead: fourteen distinct sizes between 9px and 16px --
     13px, 13.5px and 14px each doing the same job in a different component --
     with 32 rules at 13px, 19 at 11px and a floor of 9px. This product is read
     by a 40-to-45-year-old with no training, outdoors on a phone or across a
     site-office desk, and the two worst offenders were the two that matter
     most: every value the user TYPED was 13px (one step SMALLER than the prose
     explaining it) and every table column header was 11px uppercase with 0.08em
     tracking, which is the label that says which column you are reading.

     --fs-micro is the FLOOR. Nothing in this stylesheet goes below it.

     The steps are one step apart so the hierarchy survives the raise: a heading
     is still bigger than its body, a caption still smaller. Density is kept by
     the row heights and paddings, which are unchanged -- a table row is still
     56px, it just says what it holds. */
  --fs-micro: 12px;   /* uppercase micro-labels, chips, captions, counts */
  --fs-meta:  13px;   /* column headers, field labels, hints, errors */
  --fs-body:  14px;   /* prose, table cells, typed values -- the default */
  --fs-lead:  15px;   /* the figure or title that leads its card */
  --fs-title: 16px;   /* section and card headings */
  /* Buttons are OFF the phone bump below, deliberately. Their labels are
     white-space:nowrap and run to 40 characters ("Tanlanganlarni 'to'langan'
     deb belgilash") inside a flex:1 row on a 390px screen, so a step up
     overflows the row instead of helping anyone read it -- and the button was
     never the hard thing to see: it is 44px tall with a lime ground. */
  --fs-btn: 14px;

  /* ---- Bootstrap overrides: the radius constant, applied globally ---- */
  --bs-border-radius: var(--r);
  --bs-border-radius-sm: var(--r);
  --bs-border-radius-lg: var(--r);
  --bs-border-radius-xl: var(--r);
  --bs-border-radius-pill: 9999px;
  --bs-body-font-family: var(--font-sans);
  /* Bootstrap's .table resolves cell colour through --bs-table-color ->
     --bs-emphasis-color, which Bootstrap itself sets to #000. We never
     overrode it, so every table cell in the product painted pure black --
     fine in light, invisible on the dark theme's #1A1A17 card. */
  --bs-emphasis-color: var(--ink);
  --bs-emphasis-color-rgb: 18, 18, 18;
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--ground);
  --bs-border-color: var(--line);
  --bs-link-color: var(--ink);
  --bs-link-hover-color: var(--ink);
  --bs-primary: var(--accent);
  --bs-focus-ring-color: rgba(18,18,18,.25);

  /* ---- LEGACY ALIASES ----
     The previous stylesheet's token names, kept pointing at the new palette.
     Any rule or template not yet migrated keeps working instead of falling
     back to an unstyled default. Remove once nothing references them. */
}

:root[data-theme="dark"] {
  --bs-emphasis-color-rgb: 243, 243, 237;
  color-scheme: dark;
  --ground: #121210;
  --surface: #1A1A17;
  --surface-2: #201F1C;
  --surface-3: #26251F;
  --ink: #F3F3ED;
  --ink-2: #D3D3C8;
  --muted: #9E9E92;
  --faint: #6E6E64;
  --line: #2C2B26;
  --line-strong: #3A392F;
  --control-line: #747469;
  --accent: #D8F34A;
  --accent-press: #E2F76C;
  --accent-ink: #121212;
  --accent-label: #D8F34A;
  --accent-soft: #282C10;
  --accent-line: #4A5414;
  /* In dark the emphasis card flips to lime so it still anchors the eye. */
  --emph-bg: #D8F34A;
  --emph-ink: #121212;
  --emph-muted: #4A5410;
  --emph-accent: #121212;
  --emph-track: #B4CC36;
  --pos: #7FCF95;  --pos-soft: #17281B;
  --neg: #F09079;  --neg-soft: #2E1913;
  --warn: #E2B466; --warn-soft: #2B2113;
  --grid: rgba(243,243,237,.07);
  --axis: #8B8B80;
  --series-1: #F3F3ED;
  --series-2: #A8C22F;
  --tip-bg: #26251F;
  --tip-ink: #F3F3ED;
  --tip-muted: #9E9E92;
  --cat-1: #D8F34A; --cat-2: #A9C334; --cat-3: #F3F3ED;
  --cat-4: #8E8E82; --cat-5: #57564D; --cat-6: #32312B;
  --focus: #D8F34A;
  --hover: rgba(243,243,237,.05);
  --press: rgba(243,243,237,.09);
  --overlay: rgba(6,6,5,.62);
  --shadow: 0 1px 3px rgba(8,8,6,.36);
  --shadow-pop: 0 1px 3px rgba(8,8,6,.48);
  --bs-focus-ring-color: rgba(216,243,74,.35);
}

/* =====================================================================
   Reset and primitives
   ===================================================================== */

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

/* Stray absolutely-positioned chrome (dropdowns, hidden modals, toasts)
   must never make the PAGE pan sideways -- the single most common cause of
   a "broken on mobile" report. `clip` rather than `hidden` because it does
   not create a scroll container, so sticky table headers and fixed
   overlays keep working. Tables scroll inside their own wrapper. */
html, body { overflow-x: clip; min-height: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
/* An explicit scale, because without a font-size here every heading fell
   through to Bootstrap's rem scale: a card title rendered at 28px, the exact
   size of the page H1, so the hierarchy inverted on /loyihalar/ and
   /hisobotlar/. The .hN classes are mirrored because the card-title idiom in
   these templates is <h2 class="h5">, and the class outranks the element.
   Four levels, not six -- that is all this product actually uses. */
h1, .h1 { font-size: 28px; font-weight: 650; letter-spacing: -0.025em; }
h2, .h2 { font-size: 19px; font-weight: 650; letter-spacing: -0.015em; }
h3, .h3 { font-size: var(--fs-title); font-weight: 600; }
h4, .h4 { font-size: var(--fs-lead); font-weight: 600; }
h5, .h5 { font-size: var(--fs-lead); font-weight: 600; }
/* h6 was 12.5px -- SMALLER than the body text under it -- and .h6 is a real
   section heading on eight screens ("Ta'minot so'rovlari", "Qaror", "Oldin va
   keyin"). A heading below body size is an inverted hierarchy, so it separates
   itself by weight at the body step instead. */
h6, .h6 { font-size: var(--fs-body); font-weight: 650; }
/* Bootstrap's .small is 0.875em -- RELATIVE, and it is on 80 elements in these
   templates, usually the second line under a value. Inside a table cell it
   resolved to 11.4px and inside a .card-sub to 10.5px, i.e. the scale's floor
   was being undercut by inheritance in the one place a grep of this file could
   never show it. Pinned to a step. (No !important needed: app.css loads after
   bootstrap.min.css, and `small` is listed separately so it keeps its own
   weight against Bootstrap's class.) */
.small, small { font-size: var(--fs-meta); }
p { margin: 0 0 var(--sp-md); }
p:last-child { margin-bottom: 0; }
a { color: var(--ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
svg { display: block; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* --focus is ink, which disappears against the inverted card's ink ground.
   Anything focusable inside it borrows the card's accent instead. */
.is-emphasis :focus-visible { outline-color: var(--emph-accent); }
::selection { background: var(--accent); color: var(--accent-ink); }

/* Numerals that sit in a column must line up. Applied to every money and
   quantity cell; without it "1 250 000" and "980 000" wander. */
.mono, .num, .stat-value, .hero-num,
td.text-end, th.text-end, .erp-table td.text-end {
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}
.mono { font-family: var(--font-sans); }

/* ---- the signature micro-label ---- */
.mlabel {
  font-size: var(--fs-micro);
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-label);
}
/* `.stat-card .stat-label` (0,2,0) used to sit here and beat `.stat-label`
   (0,1,0), so every KPI micro-label on a white card rendered grey and the
   reference's most recognisable colour move appeared nowhere except the one
   inverted card. */
.mlabel--quiet { color: var(--muted); }

/* ---- the signature hero numeral ---- */
.hero-num {
  display: block;
  font-size: 40px;
  line-height: 1.02;
  font-weight: 640;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.hero-num .cur, .hero-num .cents {
  font-size: 24px; font-weight: 500; letter-spacing: -0.01em; color: var(--muted);
}
.hero-num .unit {
  font-size: 20px; font-weight: 500; letter-spacing: 0; color: var(--muted);
  margin-left: var(--sp-xs);
}

/* =====================================================================
   App shell — sidebar 260 · topbar 68 · 12-column content grid

   Measurements below are taken from the reference by rendering it and
   reading computed styles, not estimated. Where a number looks arbitrary
   (22px sidebar top padding, 13px segmented-button radius) it is the
   reference's number and is deliberate.
   ===================================================================== */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100%;
}
.app-main { grid-column: 2; min-width: 0; display: flex; flex-direction: column; }
.main-content { flex: 1; min-width: 0; }
.main-content > .container-fluid > * { margin-bottom: 0 !important; }
/* The shell is a flex column with a 28px gap, so a section that renders
   empty still claims a gap on BOTH sides of itself -- 56px of nothing. A
   permission-gated block that produced no markup did exactly that on the
   project list. */
.main-content > .container-fluid > :empty { display: none; }
.main-content > .container-fluid {
  /* --sp-2xl, not --sp-3xl, and the same value at every width from 992px up.
     The padding used to STEP from 32px to 24px at 1240 and to 20px at 1100,
     and a padding step makes content NARROWER as the window gets WIDER:
     content(1240) = 930px but content(1241) = 915px, so dragging a window one
     pixel wider took 15px off the table inside it. One value removes the
     reversal outright; at the cap below the surplus becomes outer margin,
     which is what it was doing anyway. */
  padding: 28px var(--sp-2xl) 40px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  /* The shell owns the rhythm. Templates also carry Bootstrap mb-4/mb-3 on
     their sections, which stacked on top of this gap and made every section
     break 52px instead of 28. Scoped to DIRECT children so utilities used
     inside a card are untouched; !important because Bootstrap's mb-* are. */

  /* WAS max-width: none, and on the 3440px office monitor that meant a ledger
     row 3116px wide: 3074px of white between a worker's name and the figure
     that pays them, with nothing but a 1.05:1 hover tint to carry the eye
     across it. Auto table layout then inflated every column by ~1.8x, so the
     surplus went to the columns that needed it least.
     1680px is the cap, measured not guessed: content = 1680 - 48 padding - 2
     border = 1630px, which holds every table in the product except the two
     widest reports (salary_report needs ~1830px of nowrap max-content,
     expense_list ~1800px) -- and those already scrolled at 1920px, where the
     old rule gave only 1594px. Above ~2000px they now scroll ~200px instead
     of not scrolling, which is the price of the zebra striping and the frozen
     first column further down being able to do their job at all.
     margin-inline stated explicitly: Bootstrap's own .container-fluid rule is
     (0,1,0) and this one is (0,2,0), so relying on its `margin: auto` would
     work but would not survive anyone reordering the files. */
  max-width: 1680px;
  margin-inline: auto;
}

/* ---- sidebar ---------------------------------------------------------- */

.sidebar {
  grid-column: 1;
  position: sticky; top: 0;
  /* 100dvh, not 100vh. 100vh resolves against the LARGE viewport, so while a
     phone browser's toolbar is showing, the bottom ~60-115px of this element
     sits below what the user can see. .sidebar-foot is pinned to exactly that
     edge by margin-top:auto, and it holds the ONLY logout control in the
     product (templates/components/sidebar.html) -- the topbar offers just an
     avatar link. So a phone user could not sign out at all. The vh line
     stays first as the fallback for browsers without dvh. */
  height: 100vh;
  height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  /* Clear of the home indicator, the same way the mobile form bar already is. */
  padding: 22px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  z-index: 60;
}

/* The brand and the drawer's close control share one row. Without this the X --
   an inline <a> -- dropped below .sidebar-brand, which is display:flex and takes
   a line of its own. Fits the narrowest drawer: 284 - 2x16 padding = 252px of
   content, brand 155px (34 logo + 10 gap + ~95px "QURILISH ERP" + 16px of the
   brand's own padding) + 8px gap + 44px button = 207px, 45px spare at 320px. */
.sidebar-head { display: flex; align-items: flex-start; gap: var(--sp-sm); }
/* The brand was a full-width block; as a flex child it would shrink to its
   ~155px of content and lose the rest of its tap area, which is a regression on
   the phone this change exists for. */
.sidebar-head > .sidebar-brand { flex: 1 1 auto; min-width: 0; }
/* The close control exists only for the drawer; on the permanent desktop rail
   there is nothing to close. Declared here so the drawer block later in the file
   wins by source order. NOT a Bootstrap d-*-none utility on the element: those
   are !important and no Bootstrap breakpoint matches the drawer boundary. */
.sidebar-close { display: none; }

.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; }
.sidebar-brand:hover { text-decoration: none; }
.brand-logo, .sidebar-brand .mark {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r);
  /* --emph-bg/--emph-accent, not --ink/--accent: --ink flips to near-white in
     dark while --accent stays lime, which put the "UK" mark at 1.12:1 and
     made it unreadable. The emph pair is the one that flips together. */
  background: var(--emph-bg); color: var(--emph-accent);
  font-size: 12px; font-weight: 700; letter-spacing: 0.02em;
}
.brand-logo.large, .brand-logo.xl { width: 44px; height: 44px; font-size: 15px; }
.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-title { font-size: var(--fs-lead); font-weight: 650; letter-spacing: -0.01em; color: var(--ink); }
.brand-subtitle {
  font-size: var(--fs-micro); font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
}

/* The sidebar's own search. The reference puts one here as well as in the
   topbar, and it is the field that survives on mobile when the topbar's is
   hidden for space. */
.sidebar-search { position: relative; margin-bottom: 20px; }
.sidebar-search i {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 12px; pointer-events: none;
}
.sidebar-search input {
  width: 100%; height: 38px;
  padding: 0 14px 0 36px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-size: var(--fs-body); color: var(--ink);
}
.sidebar-search input::placeholder { color: var(--muted); }
.sidebar-search kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: var(--fs-micro); color: var(--muted);
  background: var(--surface-3); border: 0; border-radius: 6px;
  padding: 2px 5px; font-family: var(--font-sans);
}

/* min-height and overflow are what actually pin .sidebar-foot, which holds the
   ONLY logout control in the product (one hit for accounts:logout across all 100
   templates, sidebar.html). `margin-top: auto` on .sidebar-foot distributes FREE
   space, and a director's rail content is 2111px tall against a 1280x800
   laptop's ~700px -- there is no free space, so the user card sat below the fold
   on every device, and 1528px down on a 360x640 phone where overlay scrollbars
   give no hint that the rail scrolls at all. Making the NAV the scroller is what
   the comment on .sidebar already believes is happening.
   `min-height: 0` is the load-bearing half: a flex item will not shrink below
   its min-content size without it, so `overflow-y: auto` alone would do nothing.
   .sidebar keeps its own overflow-y so the user dropdown can still flip inside
   the rail. */
.sidebar-nav { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; }
/* A FOLDED group is only its 44px heading row. The 22px under every group and
   the 8px under every label were spacing for an OPEN group -- label, links,
   breathing room -- but they applied to folded ones too, so five folded headings
   stood 78px apart: on a 1366x768 laptop the rail read as scattered labels with
   holes between them, and the open section's links were pushed below the user
   card. Folded headings now stack at their own 44px pitch; only the open group
   keeps room under its last link. */
.sidebar-group { margin-bottom: 0; }
.sidebar-group[open] { margin-bottom: var(--sp-md); }
.sidebar-group + .sidebar-group, .sidebar-link + .sidebar-group { margin-top: 4px; }
.sidebar-group:not([open]) > .sidebar-group-title { margin-bottom: 0; }
.sidebar-group-title,
.sidebar-group > .mlabel {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 0 12px; margin-bottom: 8px;
  background: transparent; border: 0;
  font-size: var(--fs-micro); line-height: 1.2; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
}
/* 44px: this is the only control for collapsing an eleven-link drawer on a
   phone, and it was a 20px strip. */
.sidebar-group-title { min-height: 44px; display: flex; align-items: center; }
/* Older WebKit paints its own disclosure triangle inside a <summary>. It went
   unnoticed while every group was hardcoded `open`; with five of six arriving
   folded it would sit beside the uppercase section label on an iPhone. Chromium
   and Firefox already drop it because .sidebar-group-title is display:flex
   rather than list-item. */
.sidebar-group-title::-webkit-details-marker { display: none; }
.sidebar-chevron { margin-left: auto; font-size: var(--fs-micro); transition: transform .18s ease; }
/* Keyed on the details' own state. The rule this replaces keyed on
   `.sidebar-group-title[aria-expanded="false"]`, which a native <summary> NEVER
   carries -- <details> exposes no ARIA of its own -- so the chevron had never
   once turned and was pure decoration. Now that five of six groups arrive folded
   it is the only thing saying a section has more inside it. */
.sidebar-group:not([open]) > .sidebar-group-title .sidebar-chevron { transform: rotate(-90deg); }
/* SCOPED TO THE OPEN STATE, and that scope is the whole point. As an unscoped
   `.sidebar-links { display: flex }` this rule overrode the UA sheet's
   `display: none` on a closed <details>'s non-summary children on every
   Chromium/WebKit build before ::details-content (2024) -- so a folded group
   PAINTED its 6-9 links and did not hit-test them. That is the "unclickable on
   desktop" bug that made the previous pass conclude groups must always be open.
   The open layout is byte-identical: only .sidebar-link children live in here. */
.sidebar-group[open] > .sidebar-links { display: flex; flex-direction: column; }
/* Belt and braces, and the half that makes the collapse engine-independent: an
   explicit author rule, so the links are hidden whatever a given browser does
   with closed details content. Without both rules together a folded rail renders
   up to 34 visible, unclickable links on an older phone -- worse than the 2252px
   of scrolling it replaces. */
.sidebar-group:not([open]) > .sidebar-links { display: none; }

.sidebar-link {
  display: flex; align-items: center; gap: 11px;
  width: 100%; height: 40px;
  padding: 0 12px; margin-bottom: 2px;
  border-radius: var(--r);
  font-size: var(--fs-body); font-weight: 500;
  color: var(--ink-2);
  transition: background .14s ease, color .14s ease;
}
.sidebar-link:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.sidebar-link i { width: 18px; font-size: 14px; text-align: center; color: var(--muted); flex: none; transition: color .14s ease; }
.sidebar-link:hover i { color: var(--ink); }
/* The active row is a SOLID INK PILL with a lime icon. This is the single
   most recognisable thing about the reference's navigation and the previous
   implementation replaced it with a pale tint, which is what made the whole
   sidebar read as generic. */
.sidebar-link.active,
.sidebar-link[aria-current="page"] {
  background: var(--emph-bg); color: var(--emph-ink); font-weight: 600;
}
/* Same reason as .brand-logo: a lime icon on an --ink pill measured 1.12:1
   once --ink flipped light in the dark theme. */
.sidebar-link.active i,
.sidebar-link[aria-current="page"] i { color: var(--emph-accent); }

.nav-count {
  margin-left: auto;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--r);
  background: var(--surface-3); color: var(--muted);
  font-size: var(--fs-micro); font-weight: 600;
  display: grid; place-items: center;
  font-variant-numeric: tabular-nums;
}
.sidebar-link.active .nav-count { background: rgba(255,255,255,.14); color: var(--surface); }
.nav-dot { margin-left: auto; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }
.sidebar-empty { font-size: var(--fs-micro); color: var(--muted); padding: 8px 12px; }

/* The user card pinned to the bottom of the rail. */
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.userbtn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px; border-radius: var(--r);
  background: transparent; border: 0; text-align: left;
}
.userbtn:hover { background: var(--hover); }
.userbtn .ic-chev { margin-left: auto; color: var(--muted); font-size: var(--fs-micro); }
.user-meta { min-width: 0; line-height: 1.3; }
.user-name { font-size: var(--fs-body); font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
.user-role { font-size: var(--fs-micro); color: var(--muted); }

.sidebar-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 55; border: 0; }
.sidebar-backdrop[hidden] { display: none; }

/* ---- topbar ----------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-height);
  /* The topbar is a SIBLING of the content wrapper, not inside it, so once that
     wrapper was capped at 1680px and centred the two stopped lining up: on a
     3440px monitor the search box sat at x=32 while the page title it belongs to
     started at x=1034. This padding tracks the cap instead of a fixed 32px, so
     the hamburger, the search field and the avatar stay in the same columns as
     the content underneath them, while the border-bottom still runs the full
     width of the screen the way a rule under a bar should.
     max() keeps the old value wherever the cap does not engage: below 1680px of
     available width the calc goes negative or small and 32px wins, so every
     laptop, tablet and phone renders byte-identically to before. */
  padding: 0 max(var(--sp-3xl), calc((100% - 1680px) / 2 + var(--sp-2xl)));
  background: var(--ground);
  border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* AI assistant entry: the acid pill. Lifts and glows on hover, the sparkle
   turns half a circle. */
.ai-assist-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 16px 0 13px;
  border: 0; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 0 0 0 rgba(216,243,74,.5), 0 8px 22px -12px rgba(216,243,74,.6);
  font-weight: 600; font-size: var(--fs-body); white-space: nowrap;
  text-decoration: none; cursor: pointer;
  transition: transform .3s cubic-bezier(.22,1,.36,1), box-shadow .4s cubic-bezier(.2,.8,.2,1);
}
.ai-assist-btn:hover {
  color: var(--accent-ink);
  transform: translateY(-2px);
  box-shadow: 0 0 0 6px rgba(216,243,74,.14), 0 14px 30px -12px rgba(216,243,74,.8);
}
.ai-assist-btn:active { transform: scale(.96); }
.ai-assist-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ai-assist-ico { width: 18px; height: 18px; flex: none; transition: transform .6s cubic-bezier(.22,1,.36,1); }
.ai-assist-btn:hover .ai-assist-ico { transform: rotate(180deg) scale(1.15); }
@media (prefers-reduced-motion: reduce) {
  .ai-assist-btn, .ai-assist-ico { transition: none; }
}

.topbar .sidebar-toggle {
  display: none;
  width: 40px; height: 40px;
  align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); color: var(--ink-2);
}
.topbar .sidebar-toggle:hover { background: var(--hover); color: var(--ink); }

.search-form { position: relative; flex: 1; max-width: 360px; min-width: 0; }
.search-form i {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 13px; pointer-events: none;
}
.search-form input {
  width: 100%; height: 40px;
  padding: 0 14px 0 40px;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r);
  font-size: var(--fs-body); color: var(--ink);
}
.search-form input::placeholder { color: var(--muted); }
.search-form input:focus {
  /* --accent-soft is a pale wash: against the topbar it measured 1.1:1, so the
     focus ring was invisible and a keyboard user could not see where they were.
     A real border plus a darker halo replaces it. */
  border-color: var(--focus); outline: 2px solid var(--focus); outline-offset: 1px;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* 40x40, bordered, 16px radius. The lime dot is an ::after so the markup
   stays a plain button. */
.icon-button {
  position: relative;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); color: var(--ink-2);
  transition: background .14s ease, color .14s ease;
}
.icon-button:hover { background: var(--hover); color: var(--ink); }
.icon-button:active { background: var(--press); }
.icon-button.has-dot::after {
  content: ""; position: absolute; top: 9px; right: 9px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); border: 1.5px solid var(--surface);
}
.icon-button .badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: grid; place-items: center;
  border: 1.5px solid var(--ground);
  font-size: var(--fs-micro); font-weight: 700;
}

/* Square-ish, radius 16 — NOT a circle. */
.avatar, .profile-avatar {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r);
  background: var(--accent-soft); color: var(--accent-label);
  font-size: var(--fs-micro); font-weight: 650; letter-spacing: 0.02em;
  overflow: hidden;
}
.avatar img, .profile-avatar img { width: 100%; height: 100%; object-fit: cover; }

.profile-pill {
  display: flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 4px;
  border: 0; border-radius: var(--r); background: transparent;
}
.profile-pill:hover { background: var(--hover); }
.profile-meta { text-align: left; line-height: 1.25; min-width: 0; }
.profile-name { font-size: var(--fs-body); font-weight: 600; letter-spacing: -0.01em; }
.profile-role { font-size: var(--fs-micro); color: var(--muted); }

/* The date-range control in the topbar. */
.daterange {
  display: inline-flex; align-items: center; gap: 9px;
  height: 40px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface);
  font-size: var(--fs-meta); font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.daterange:hover { background: var(--hover); text-decoration: none; }
.daterange i { color: var(--muted); font-size: 12px; }

/* =====================================================================
   Page header — breadcrumb · eyebrow · two-tone headline · actions
   ===================================================================== */

/* A Django {% include %} has no slot, so rather than duplicating the whole
   masthead in 77 templates to get a right-hand action, a page wraps the
   include and its buttons in .page-header-row and the flex lives here. */
.page-header-row {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 28px; flex-wrap: wrap;
}
.page-header-row > .page-header { flex: 1 1 320px; }
.page-header-row > .page-actions { flex: 0 0 auto; }

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 28px; flex-wrap: wrap;
}
.page-header-main { min-width: 0; }
.crumbs {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  font-size: var(--fs-meta); color: var(--muted); margin-bottom: 10px;
}
.crumbs a:hover { color: var(--ink); }
.crumbs .sep { color: var(--muted); font-size: var(--fs-micro); }
.crumbs [aria-current] { color: var(--ink); font-weight: 600; }

.page-eyebrow {
  font-size: var(--fs-micro); line-height: 1.2; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent-label);
  margin-bottom: 6px;
}
.page-title {
  font-size: 28px; font-weight: 650; letter-spacing: -0.025em; line-height: 1.1;
  color: var(--ink);
}
/* The reference's headline is two-tone: the statement in ink, the
   continuation in muted. Written as <em>, restyled to not be italic. */
.page-title em { font-style: normal; color: var(--muted); }
.page-subtitle {
  font-size: var(--fs-body); color: var(--muted); max-width: 62ch; margin-top: 8px;
  line-height: 1.55;
}
.page-subtitle strong { color: var(--ink); font-weight: 600; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Segmented control. Inner radius 13, not 16: a 16px radius on a 32px pill
   inside a 16px container reads as a lozenge. */
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r);
}
.seg a, .seg button {
  height: 32px; padding: 0 14px;
  display: inline-flex; align-items: center;
  border: 0; border-radius: 13px;
  font-size: var(--fs-meta); font-weight: 600; letter-spacing: 0.01em;
  color: var(--muted); background: transparent;
  transition: background .14s ease, color .14s ease;
}
.seg a:hover, .seg button:hover { color: var(--ink); text-decoration: none; }
.seg a.active, .seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
/* A .seg of radios in a form ("Kimga", "Muhimligi"): the radio is hidden and
   its label is the cell, filled with the same pair as the theme switch. The
   Bootstrap .btn-check route painted the chosen cell Bootstrap blue, a colour
   that exists nowhere else in the product. */
.seg input[type="radio"] { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.seg label {
  height: 32px; padding: 0 14px; margin: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 13px; cursor: pointer; white-space: nowrap;
  font-size: var(--fs-meta); font-weight: 600; letter-spacing: 0.01em;
  color: var(--muted); transition: background .14s ease, color .14s ease;
}
.seg label:hover { color: var(--ink); }
.seg input:checked + label { background: var(--emph-bg); color: var(--emph-accent); }
.seg input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg input[value="urgent"]:checked + label { background: var(--neg-soft); color: var(--neg); }
.seg .seg-count { opacity: .7; font-variant-numeric: tabular-nums; }
/* Full width, 40px tall: the height of the inputs beside it in a form row. */
.seg-field { display: flex; width: 100%; }
.seg-quick button[aria-pressed="true"] { background: var(--emph-bg); color: var(--emph-accent); }
/* Status tabs over a list (vazifalar): links, the current one filled like the
   form switches; scrolls sideways on a phone instead of wrapping. */
.seg-tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg-tabs a { white-space: nowrap; gap: 6px; }
.seg-tabs a.active { background: var(--emph-bg); color: var(--emph-accent); }
.seg-tabs .seg-count { opacity: .7; font-variant-numeric: tabular-nums; }
/* Urgent carries a bolt (as on the form) instead of the danger triangle, so it
   does not read as a second "Muddati o'tgan". */
.badge.is-urgent::before { display: none; }
.seg-field label { flex: 1 1 0; min-width: 0; }
.seg-quick { flex-wrap: wrap; }
.seg-quick button { height: 28px; padding: 0 10px; }

/* The theme control. Icon-only cells, so they are square rather than the
   label-width of a normal segment, and the whole control matches the 40px
   height of the icon buttons beside it. */
.theme-seg { padding: 3px; gap: 2px; }
.theme-seg button { width: 32px; height: 32px; padding: 0; justify-content: center; font-size: 13px; }
.theme-seg button[aria-pressed="true"] { background: var(--ink); color: var(--accent); }
/* Dark theme: --ink is near-white, so the filled cell needs the pair that
   flips together -- the same fix the sidebar's active pill needed. */
.theme-seg button[aria-pressed="true"] { background: var(--emph-bg); color: var(--emph-accent); }

/* =====================================================================
   Surfaces — card · card-hd · card-pad · card-ft
   ===================================================================== */

.erp-card, .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  /* Held as a variable so the ruled header below can bleed out to the card
     edge with calc(), and still line up when the breakpoint changes it. */
  --card-pad: 24px;
  padding: var(--card-pad);
}
.erp-card:hover { box-shadow: var(--shadow); transform: none; }
.narrow-card { max-width: 720px; }

/* A card with a ruled header carries no padding of its own; the header,
   body and footer each own theirs. */
.erp-card.is-sectioned, .card.is-sectioned { padding: 0; }
.card-hd {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  margin: 0;
}
.card-hd h2, .card-hd h3, .card-head h3 {
  font-size: var(--fs-title); font-weight: 600; letter-spacing: -0.01em;
}
.card-sub { font-size: var(--fs-meta); color: var(--muted); margin-top: 3px; }
.card-pad { padding: 24px; }
.card-ft {
  padding: 14px 24px; border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  font-size: var(--fs-meta); color: var(--muted);
}
/* Plain cards that only carry a heading keep the old lighter treatment. */
.card-head { margin-bottom: 16px; }

/* The one inverted card per screen. */
.erp-card.is-emphasis, .stat-card.is-emphasis, .kpi.is-emphasis {
  background: var(--emph-bg); border-color: var(--emph-bg); color: var(--emph-ink);
}
.is-emphasis .mlabel, .is-emphasis .stat-label { color: var(--emph-accent); }
.is-emphasis .hero-num, .is-emphasis .stat-value { color: var(--emph-ink); }
.is-emphasis .stat-meta, .is-emphasis .kpi-note { color: var(--emph-muted); }
/* Fill, not border-color: .kpi-icon is borderless, so the old rule was a
   no-op and the tile kept its light --surface-3 ground on an ink card. */
.is-emphasis .kpi-icon { background: var(--emph-track); color: var(--emph-accent); }
/* The sparkline on the inverted card needs its own series colour: the
   default ink line is invisible against an ink ground. */
.is-emphasis .kpi-spark { --series-1: var(--emph-accent); --muted: var(--emph-muted); }

/* =====================================================================
   KPI card — the reference's signature component
   ===================================================================== */

/* auto-fit, not repeat(4): the reference's row happens to hold four cards,
   but half our pages summarise in three. A fixed four-track grid left a
   phantom empty column and squeezed the surviving cards to 264px, which is
   what forced the so'm figure to shrink. auto-fit collapses the empty track,
   so four cards still land on the reference's 264px and three fill the row. */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}
.stats-grid.compact { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.stat-card, .kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
  padding: 22px 22px 16px;
  min-height: 188px;
  min-width: 0;
}
/* A card with only a label and a value has two of the four slots the 188px
   assumes, so holding that height produces 74px of void rather than
   fidelity. The reference never ships a two-slot card; this is the one place
   its measurement should not be copied literally. */
.stat-card:not(:has(.kpi-spark)) { min-height: 104px; }
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
/* Filled, not outlined: a bordered tile adds a fourth border weight to a
   card that already has one, and the reference fills it. */
.kpi-icon {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: var(--r);
  background: var(--surface-3); color: var(--ink-2); font-size: 14px;
}
.kpi-value { margin-top: 2px; }
.kpi-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kpi-note { font-size: var(--fs-meta); color: var(--muted); font-variant-numeric: tabular-nums; }
/* Bled to the card edges: inset 22px each side the trace reads as a small
   picture in a box rather than as the floor of the card. */
.kpi-spark { margin: auto -6px -4px; height: 38px; position: relative; }
.kpi-spark canvas { display: block; width: 100%; height: 38px; }

.stat-label {
  font-size: var(--fs-micro); line-height: 1.2; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent-label);
}
.stat-value {
  font-size: 28px; line-height: 1.05; font-weight: 640; letter-spacing: -0.025em;
  color: var(--ink);
  /* Long figures step the numeral down rather than wrapping -- but they are
     NEVER clipped. An earlier version added overflow:hidden/text-overflow,
     which silently ate the last digits and the so'm suffix off three of the
     four figures on the financial report. A truncated money figure is worse
     than a wrong one: nothing on screen admits anything was dropped. So the
     steps below do the work, and wrapping is the last resort. */
  overflow-wrap: anywhere;
}
/* Thresholds are CONTENT-box widths -- a 264px card measures 218 here, after
   44px of padding and 2px of border -- because that is what @container
   resolves against. The earlier 260/210 pair was written as if they were
   border-box, so they fired far too late to stop the overflow they existed
   to prevent. An 18-character so'm figure needs roughly 11px per character. */
.stat-card { container-type: inline-size; }
@container (max-width: 330px) { .stat-value { font-size: 24px; } }
@container (max-width: 250px) { .stat-value { font-size: 20px; } }
@container (max-width: 190px) { .stat-value { font-size: 17px; } }
.stat-meta { font-size: var(--fs-meta); color: var(--muted); }

/* The reference's KPI cards carry NO coloured edge. Emphasis is the single
   inverted card, and that is the whole point of it: three cards wearing
   three different accent rules is decoration competing with the one signal
   that means something. The modifier classes stay live in 23 templates, so
   they are neutralised here rather than removed from the markup — the
   distinction they draw is already carried by the label and the figure. */
.stat-card.accent, .stat-card.success, .stat-card.danger { box-shadow: var(--shadow); }

.mini-stat { display: flex; flex-direction: column; gap: 4px; padding: 0; min-width: 0; }
.mini-stat > span {
  font-size: var(--fs-micro); font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
}
.mini-stat > strong {
  font-size: 22px; font-weight: 640; letter-spacing: -0.02em; color: var(--ink);
  font-variant-numeric: tabular-nums lining-nums; overflow-wrap: anywhere;
}
.stat-hint { font-size: var(--fs-micro); color: var(--muted); }

/* =====================================================================
   Chips and deltas — direction, never decoration
   ===================================================================== */

.chip, .status-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: var(--r);
  font-size: var(--fs-meta); font-weight: 600; line-height: 1.35;
  font-variant-numeric: tabular-nums;
}
.chip-up { background: var(--pos-soft); color: var(--pos); }
.chip-down { background: var(--neg-soft); color: var(--neg); }
.chip-accent { background: var(--accent-soft); color: var(--accent-label); }
.chip-quiet, .status-chip { background: var(--surface-3); color: var(--muted); }
.status-chip.status-on { background: var(--pos-soft); color: var(--pos); }
.status-off { background: var(--surface-3); color: var(--muted); }
.delta { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-meta); font-weight: 600; font-variant-numeric: tabular-nums; }
.up { color: var(--pos); } .down { color: var(--neg); } .flat { color: var(--muted); }

/* =====================================================================
   Buttons
   ===================================================================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; min-height: 40px; padding: 0 16px;
  border-radius: var(--r);
  font-size: var(--fs-btn); font-weight: 600; letter-spacing: -0.005em;
  white-space: nowrap; border: 1px solid transparent;
  transition: background .14s ease, border-color .14s ease, color .14s ease, opacity .14s ease;
}
.btn:hover { text-decoration: none; }
/* OPACITY IS NOT A DISABLED STATE, it is a contrast reduction applied to
   whatever happens to be behind the element. At .45 the ink label of
   .btn-erp-secondary composited to #949494 on white = 3.03:1, and on the lime
   primary to #949494 on #EDFAAE = 2.73:1 with the button's own edge down at
   1.2:1 -- so the live instance (task_form.html's "Xonadonlarni tanlash",
   disabled until a block is chosen) read as a smudge rather than as a control
   that is not ready yet. Stated colours instead, so the ratio is a number we
   chose: --muted on --surface-3 is 4.67:1 light / 5.68:1 dark for the label and
   --line-strong keeps a visible 1.5:1 edge that deliberately reads weaker than
   an enabled button's. cursor:not-allowed is the second, non-colour half. */
.btn:disabled, .btn.disabled {
  background: var(--surface-3); color: var(--muted); border-color: var(--line-strong);
  opacity: 1; cursor: not-allowed;
}
.btn .ic, .btn i { font-size: 13px; }

/* Five roles, and every Bootstrap alias the templates actually use is mapped
   onto one of them. Three classes in live templates (.btn-outline-success on
   "Excel yuklab olish", -warning, -dark) previously matched NO rule here and
   fell through to a bare .btn: transparent border, no ground, rendering as
   loose text among real buttons. Colour is a role, not decoration, so an
   Excel export is quiet — it does not get its own green because the file
   format has one.

   1 PRIMARY   lime solid    the one action the page exists for
   2 INK       ink solid     a confirm inside an already-committed flow
   3 SECONDARY ink outline   the affirmative of a pair (Filtrlash)
   4 QUIET     hairline      everything else (Tozalash, Excel, Bekor qilish)
   5 DANGER    red outline   destructive
   ...plus GHOST for actions that should read as text. */

/* 1 */
.btn-primary, .btn-erp-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover, .btn-erp-primary:hover { background: var(--accent-press); border-color: var(--accent-press); color: var(--accent-ink); }

/* 2 */
.btn-dark, .btn-ink { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn-dark:hover, .btn-ink:hover { opacity: .88; color: var(--surface); }

/* 3 — a full-strength ink border. Previously identical to QUIET, which threw
   away the distinction every filter bar is drawing between its two buttons. */
.btn-erp-secondary, .btn-outline-primary, .btn-outline-dark {
  background: var(--surface); color: var(--ink); border-color: var(--ink);
}
.btn-erp-secondary:hover, .btn-outline-primary:hover, .btn-outline-dark:hover {
  background: var(--ink); color: var(--surface); border-color: var(--ink);
}

/* 4 */
.btn-secondary, .btn-outline-secondary, .btn-light,
.btn-outline-success, .btn-outline-warning {
  background: var(--surface); color: var(--ink-2); border-color: var(--line-strong);
}
.btn-secondary:hover, .btn-outline-secondary:hover, .btn-light:hover,
.btn-outline-success:hover, .btn-outline-warning:hover {
  background: var(--hover); color: var(--ink); border-color: var(--line-strong);
}

/* ghost */
.btn-link, .btn-ghost { background: transparent; color: var(--ink-2); border-color: transparent; }
.btn-link:hover, .btn-ghost:hover { background: var(--hover); color: var(--ink); }

/* 5 */
.btn-danger, .btn-outline-danger { background: var(--surface); color: var(--neg); border-color: var(--neg); }
.btn-danger:hover, .btn-outline-danger:hover { background: var(--neg-soft); color: var(--neg); }
.btn-success { background: var(--surface); color: var(--pos); border-color: var(--pos); }
.btn-success:hover { background: var(--pos-soft); color: var(--pos); }

/* KEYBOARD FOCUS ERASED THE BUTTON. bootstrap.min.css ships
   `.btn:focus-visible{color:var(--bs-btn-hover-color);
   background-color:var(--bs-btn-hover-bg);border-color:var(--bs-btn-hover-border-color);
   outline:0;box-shadow:var(--bs-btn-focus-box-shadow)}` at (0,2,0), and this
   file's app-wide ring is `:focus-visible` at (0,1,0). Specificity is resolved
   BEFORE source order, so loading app.css second did not help: `outline:0` won
   on all 352 elements carrying .btn.
   For .btn-erp-primary (84 templates) and .btn-erp-secondary the damage was
   total, because those classes are ours and Bootstrap therefore never defines
   --bs-btn-hover-bg / -hover-color / -focus-shadow-rgb for them: each var()
   resolved to a guaranteed-invalid value, so background-color fell back to
   transparent, border-color to transparent and the box-shadow to none. Tab onto
   Saqlash and the lime button ceased to exist -- no fill, no border, no ring --
   at the moment before Enter.
   Fixed by restating the ring at (0,2,0) so it can win, and by restating each
   role's own resting colours on focus so no undefined Bootstrap variable is
   ever read. Placed BEFORE the :active block below so a press still wins while
   the finger or the space bar is down. */
.btn:focus-visible,
.btn-check:focus-visible + .btn,
.page-link:focus-visible,
.nav-link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  box-shadow: none;
}
/* --focus is ink, and the inverted card's ground is ink (lime in dark, where
   --focus is also lime) -- so a ring on a button inside it would be invisible.
   (0,3,0) to outrank the rule above, which is now (0,2,0). */
.is-emphasis .btn:focus-visible { outline-color: var(--emph-accent); }

.btn-primary:focus-visible, .btn-erp-primary:focus-visible {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}
.btn-dark:focus-visible, .btn-ink:focus-visible {
  background: var(--ink); color: var(--surface); border-color: var(--ink);
}
.btn-erp-secondary:focus-visible, .btn-outline-primary:focus-visible, .btn-outline-dark:focus-visible {
  background: var(--surface); color: var(--ink); border-color: var(--ink);
}
.btn-secondary:focus-visible, .btn-outline-secondary:focus-visible, .btn-light:focus-visible,
.btn-outline-success:focus-visible, .btn-outline-warning:focus-visible {
  background: var(--surface); color: var(--ink-2); border-color: var(--line-strong);
}
.btn-link:focus-visible, .btn-ghost:focus-visible {
  background: transparent; color: var(--ink-2); border-color: transparent;
}
.btn-danger:focus-visible, .btn-outline-danger:focus-visible {
  background: var(--surface); color: var(--neg); border-color: var(--neg);
}
.btn-success:focus-visible {
  background: var(--surface); color: var(--pos); border-color: var(--pos);
}

/* Pressed. The reference omits it, so this is a density call, not a fidelity
   gap: a bookkeeper submitting forms all day needs the click acknowledged
   before the navigation lands. */
.btn-primary:active, .btn-erp-primary:active { background: var(--accent-press); border-color: var(--accent-press); }
.btn-erp-secondary:active, .btn-outline-primary:active, .btn-outline-dark:active { background: var(--ink); color: var(--surface); }
.btn-secondary:active, .btn-outline-secondary:active, .btn-light:active,
.btn-outline-success:active, .btn-outline-warning:active,
.btn-link:active, .btn-ghost:active { background: var(--press); }
.btn-dark:active, .btn-ink:active { opacity: .8; }

.btn-sm { height: 32px; min-height: 32px; padding: 0 12px; font-size: var(--fs-meta); }
.btn-lg { height: 46px; min-height: 46px; padding: 0 24px; font-size: var(--fs-lead); }

/* =====================================================================
   Forms
   ===================================================================== */

.form-label { font-size: var(--fs-meta); font-weight: 600; color: var(--ink-2); margin-bottom: 7px; }
.form-control, .form-select {
  width: 100%; height: 40px;
  padding: 0 14px;
  /* background-COLOR, not the shorthand: `background` resets background-image,
     which is where the caret below (and Bootstrap's own) is painted. With the
     shorthand every <select> in the product rendered as flat text with no
     affordance that it opens at all -- including the so'm/USD currency picker,
     which is how a user is supposed to discover the app handles two
     currencies. Same failure as .form-check-input:checked losing its tick. */
  background-color: var(--surface);
  /* --control-line, not --line-strong: the control and the .erp-card behind it
     both paint var(--surface), so this border is the ONLY thing that says a
     field is here, and at 1.52:1 it said nothing. See the token's own note. */
  border: 1px solid var(--control-line);
  border-radius: var(--r);
  color: var(--ink);
  /* 16px: iOS zooms the page when a focused input is smaller. */
  font-size: 16px;
  transition: border-color .14s ease, box-shadow .14s ease;
}
/* 992, NOT 768. This was the only min-width query in the file and it is what
   dropped every field on an iPad from the base 16px to 14px -- and iPadOS
   Safari zooms the page when a focused input is under 16px exactly as iPhone
   Safari does, and never zooms back, so tapping any field on the site iPad left
   the storekeeper panning a zoomed layout one-handed. Bootstrap's lg boundary
   also makes both sides agree: at <= 991.98 a field is 16px and 44px tall, at
   >= 992 it takes the desktop scale. */
/* AND `pointer: fine` on both queries below, because width alone cannot answer
   this question. An iPad in LANDSCAPE is 1024px and an iPad Pro is 1366px, so
   both sit above any width boundary that keeps a phone safe -- and iPadOS Safari
   zooms a focused sub-16px input at those widths exactly as it does at 768.
   Gating on the input device means the 14px scale reaches only what is actually
   driven by a mouse, and every touch screen keeps 16px at every width. A desktop
   with a touch screen also keeps 16px, which is the harmless direction to be
   wrong in. */
@media screen and (min-width: 992px) and (pointer: fine) { .form-control, .form-select { font-size: var(--fs-body); } }
/* Bootstrap's `.input-group-sm > .form-control { font-size: .875rem }` is
   (0,2,0) and outranks the 16px above (0,1,0) whatever the source order, so
   every money box inside an input-group-sm rendered at 14px -- two pixels under
   the threshold at which iOS Safari zooms on focus and never zooms back.
   templates/resources/tool_loan_detail.html still uses the class. The pair
   mirrors the two rules above exactly, so these boxes follow the same
   16px-on-touch / 14px-on-desktop rule as every other field instead of being
   pinned at 16px everywhere. Order is load-bearing: both are (0,2,0), so the
   media query has to come second. */
.input-group-sm > .form-control,
.input-group-sm > .form-select,
.input-group-sm > .input-group-text { font-size: 16px; }

/* ONE SEARCH, NOT TWO. The sidebar and the topbar each carry a form posting to
   core:search, and the topbar's is hidden only below 768px -- so from 1200px up,
   where the rail is permanent, both were on screen about 150px apart, and their
   shortcut hints disagreed (Ctrl+K in one, the Command glyph in the other) so one
   of them was always lying about the keyboard it was read on.

   The topbar keeps it: a global search belongs in the header, it is wider there,
   and that is where a category-fluent user looks first. The sidebar's survives
   only where the rail is a drawer and the topbar's is gone or out of reach.

   This block was, for one commit, spliced into the MIDDLE of the selector list
   above -- an edit anchored on ".input-group-text {" matched inside
   ".input-group-sm > .input-group-text {". A selector list is not forgiving, so
   the whole 16px rule was dropped AND this @media was eaten as its body: the
   quantity boxes fell back to Bootstrap's .875rem, iOS resumed zooming on focus,
   and both search bars stayed on screen. Neither fix had ever applied.
   768px, not 1200px: the topbar's field only hides below 768px, so at tablet
   widths the opened drawer showed a second search box over the first one,
   which was still on the page behind the backdrop. Now exactly one search
   exists at every width. */
@media screen and (min-width: 768px) {
  .sidebar-search { display: none; }
}

/* Bootstrap gives .input-group-text `background-color: var(--bs-tertiary-bg)` and
   `color: var(--bs-body-color)`. This project never sets data-bs-theme, so both
   stay on Bootstrap's LIGHT defaults whatever the user's theme -- a pale box with
   pale text on the dark ground, which measured as the unit chip beside a quantity
   box being simply invisible. The addon is part of the control, so it takes the
   control's own colours: --ink-2 on --surface-3 is 10.19:1.

   One rule, not two: the font-size below used to sit in its own
   `.input-group-text { }` immediately above this, and a second declaration of the
   same selector is a place for the two to drift. */
.input-group-text {
  font-size: 16px;
  background-color: var(--surface-3);
  color: var(--ink-2);
  border-color: var(--control-line, var(--line-strong));
}
@media screen and (min-width: 992px) and (pointer: fine) {
  .input-group-sm > .form-control,
  .input-group-sm > .form-select,
  .input-group-sm > .input-group-text { font-size: var(--fs-body); }
}

/* Nothing capped the shared field row, and templates/components/form_fields.html
   renders every ModelForm in the product through it. At 3440px the card interior
   was 3066px, so a col-md-6 field was 1525px wide by 40px tall to hold an "Ism",
   and the two columns' labels stood 1541px apart.
   1040 = two 504px fields + 2x8 col padding + the 16px g-3 gutter; 504 covers
   the longest value anyone types here (a 60-character address is ~466px) and is
   a deliberate sibling of .narrow-card's 720px above. Binds only above ~1450px:
   at 1280x800 the row is already 906px, so laptops, tablets and phones are
   untouched. */
.form-grid { max-width: 1040px; }
/* A col-12 textarea inside that capped row is still 1024px = ~140 characters
   per line, twice a readable measure for the Izoh/Manzil prose these hold.
   720 = 90 characters x 7.3px + 28px of padding. Never binds below 768px (a
   phone column is 254px), and a textarea is neither select2-wrapped nor inside
   an input-group, so the cap is safe on the control itself. */
.form-grid textarea.form-control { max-width: 720px; }
/* One caret, drawn from the design system rather than Bootstrap's, so it
   follows the theme. Stated as two literals because a background-image SVG
   cannot read currentColor. */
.form-select {
  appearance: none; -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.75 6 6.25 11 1.75' fill='none' stroke='%236C6C62' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  background-size: 12px 8px;
}
:root[data-theme="dark"] .form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.75 6 6.25 11 1.75' fill='none' stroke='%239E9E92' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
/* The file picker's button is a shadow-DOM pseudo-element, so it inherits
   nothing from .form-control and was left as the browser's default chrome:
   a pale grey box with near-white text on the dark theme, unreadable. Styled
   as the quiet button it is. */
input[type="file"].form-control { padding: 0; display: flex; align-items: center; }
input[type="file"].form-control::-webkit-file-upload-button,
input[type="file"].form-control::file-selector-button {
  height: 38px; margin: 0 14px 0 0; padding: 0 14px;
  border: 0; border-right: 1px solid var(--line-strong);
  border-radius: var(--r) 0 0 var(--r);
  background: var(--surface-3); color: var(--ink-2);
  font-family: inherit; font-size: var(--fs-meta); font-weight: 600;
  cursor: pointer;
  transition: background .14s ease, color .14s ease;
}
input[type="file"].form-control::-webkit-file-upload-button:hover,
input[type="file"].form-control::file-selector-button:hover {
  background: var(--hover); color: var(--ink);
}

.form-control::placeholder { color: var(--muted); }

/* Was --faint, which the token block itself labels "decorative / non-text only"
   and which measures 2.81:1 -- LIGHTER than the new resting edge, so hovering a
   field made it HARDER to see. --ink-2 is one step short of the --ink that
   :focus uses, so rest, hover and focus are three distinguishable weights.
   THE ORDER OF THESE THREE RULES IS THE WHOLE MECHANISM: all three are (0,2,0),
   so hover must come first, focus second (a focused field the pointer is also
   resting on must read as focused), and :disabled last -- a disabled <input>
   still matches :hover, because unlike .btn Bootstrap does not put
   pointer-events:none on form controls. */
.form-control:hover, .form-select:hover { border-color: var(--ink-2); }
.form-control:focus, .form-select:focus {
  border-color: var(--ink); outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* A FROZEN FIELD WAS AN UNREADABLE GREY BOX IN DARK THEME.
   bootstrap.min.css ships `.form-control:disabled{background-color:var(--bs-secondary-bg)}`
   and the same for .form-select, both (0,2,0), which outrank this file's
   `.form-control{background-color:var(--surface)}` at (0,1,0) whatever the load
   order. --bs-secondary-bg is #e9ecef on :root; its dark value lives only under
   `[data-bs-theme=dark]`, and this app themes with data-theme -- grep for
   data-bs-theme over templates/ and static/js/ returns nothing. So in dark theme
   a disabled field painted #e9ecef and kept color:var(--ink) #F3F3ED: 1.08:1.
   This is not cosmetic. Six fields are disabled on purpose and every one of them
   is a value the user has to CHECK before saving: the resource's measurement
   unit (apps/resources/forms.py -- frozen because changing it silently
   reinterprets every historical quantity), an approved deal, the worker a
   payslip pays, the currency pair. --ink-2 on --surface-3 measures 9.94:1 light
   and 10.19:1 dark. [readonly] is included because it looks identical to the
   user and Bootstrap styles it differently. --control-line keeps the 3:1 edge so
   the box is still findable, and cursor:not-allowed is the non-colour half of
   "you cannot type here" -- the same class of bug app.css already diagnosed for
   .btn-close, where only that one instance was fixed. */
.form-control:disabled, .form-select:disabled,
.form-control[readonly], .form-select[readonly] {
  background-color: var(--surface-3);
  color: var(--ink-2);
  border-color: var(--control-line);
  opacity: 1;
  cursor: not-allowed;
}
/* [readonly] is the one half of that pair that can still be TABBED TO -- the
   days/hours boxes on bulk_salary_form and attendance_form, switched off for a
   worker whose salary type or attendance does not use them. The rule above sits
   after :focus at equal specificity, so without this a keyboard user landed on a
   readonly box with no indication whatever that they had. (0,3,0). */
.form-control[readonly]:focus, .form-select[readonly]:focus { border-color: var(--ink); }
textarea.form-control { height: auto; min-height: 88px; padding: 11px 14px; }
.form-text { font-size: var(--fs-meta); color: var(--muted); margin-top: 6px; }
.field-error { font-size: var(--fs-meta); color: var(--neg); margin-top: 6px; display: flex; gap: 5px; }
/* A FAILED FIELD HAS TO BE FINDABLE BY SCANNING, not only by reading.
   This rule named .form-control alone, and StyledModelForm gives every
   <select>/<select multiple> the class .form-select instead (apps/core/forms.py)
   -- so on the expense form, whose empty submit returns five invalid fields,
   the two text inputs turned red and the three dropdowns the user actually has
   to fix (Loyiha, Kategoriya, To'lov usuli) looked perfectly fine. Django 5
   writes aria-invalid="true" itself, so the selector is all that was missing.

   The inset ring doubles the edge weight, which is the non-colour half of the
   signal: it survives greyscale, a colour-blind reader and a dimmed phone
   outdoors. Inset rather than a 2px border because these controls are
   border-box at a fixed 40px, so a wider border would shift the text inside
   the field by a pixel as the error appears and disappears. */
.form-control[aria-invalid="true"],
.form-select[aria-invalid="true"],
.is-invalid {
  border-color: var(--neg);
  box-shadow: inset 0 0 0 1px var(--neg);
}
/* ...and the focus halo has to survive the error state. The invalid rule sits
   after :focus and carries the same specificity, so without this line focusing
   a flagged field REPLACED its focus ring with the error ring and a keyboard
   user lost track of where they were. Both, in one shadow. */
.form-control[aria-invalid="true"]:focus,
.form-select[aria-invalid="true"]:focus,
.is-invalid:focus {
  box-shadow: inset 0 0 0 1px var(--neg), 0 0 0 3px var(--accent-soft);
}
/* Check controls own their whole appearance here.
   Bootstrap paints its glyph on the BASE .form-check-input rule via
   background-image: var(--bs-form-check-bg-image). Our rule had the same
   selector and specificity but came later, so the `background:` shorthand
   reset that image to none -- checked AND unchecked. The result was a box
   with no tick and a circle with no dot in BOTH themes. Worse, the checked
   ground was --ink, which flips to near-white in dark, while Bootstrap's
   glyph is a hardcoded white stroke: on a dark theme "on" was a white box
   holding a white tick.

   So the checked state is the lime accent with an ink glyph, and both are
   literal rather than tokens -- deliberately. Lime on ink reads at 15:1 and
   is IDENTICAL in both themes, which is the whole point: the control must
   answer "am I on?" without the reader first working out which theme they
   are in. It is the same signal the theme control and the active nav item
   already use. */
.form-check-input {
  /* 24px, the WCAG 2.5.8 floor, at every width. 18px failed it outright on the
     office iPad, on the one control in the product that decides who gets paid
     (the include_<pk> boxes on bulk_salary_form and the select-all on
     salary_list). 24px and not 44px because the 44px TARGET comes from the
     <label> the payroll boxes are now wrapped in; the box itself only has to
     meet the floor.
     Bootstrap's own gutter is .form-check{padding-left:1.5em} with the input at
     margin-left:-1.5em, and 1.5em resolves against the inherited 14px body step
     = 21px -- so a 24px float sits 3px into the label column and the label's
     first line starts 3px further right than the indent implies. That is the
     whole cost, measured: no row grows, nothing wraps, and at 320px the label
     still has 251px of a 272px card interior. 28px would cost 7px and start
     pushing two-word Uzbek labels onto a second line. */
  width: 24px; height: 24px;
  flex-shrink: 0;
  appearance: none; -webkit-appearance: none;
  /* A checkbox has no label text inside it, so this border IS the control: at
     --line-strong's 1.52:1 an UNCHECKED box was a 24px patch of card. */
  border: 1px solid var(--control-line);
  border-radius: var(--r-xs);
  background-color: var(--surface);
  background-image: none;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  transition: background-color .12s ease, border-color .12s ease;
}
.form-check-input[type="checkbox"] { border-radius: var(--r-xs); }
.form-check-input[type="radio"] { border-radius: 50%; }
/* A checkbox FIELD (components/form_fields.html): box and label on one row, the
   label stretched to a 44px target so a thumb can hit the words, not just the
   24px box. Bootstrap's float-and-negative-margin gutter is undone here; the row
   is a flex line instead. */
.form-check.check-row {
  display: flex; align-items: center; gap: var(--sp-md);
  min-height: 44px; padding-left: 0; margin: 0;
}
.form-check.check-row .form-check-input { float: none; margin: 0; }
/* display:flex above beats the [hidden] the tick-box filter sets (initCheckFilters). */
.form-check.check-row[hidden] { display: none; }
.form-check.check-row .form-check-label {
  flex: 1; display: flex; align-items: center; gap: 4px;
  min-height: 44px; cursor: pointer;
  font-weight: 600; color: var(--ink);
}
/* Beside a text field in the two-column grid, the row lines up with the
   neighbour's INPUT, not with its label above it. */
@media screen and (min-width: 768px) {
  .form-grid > [class*="col-"] > .check-row { margin-top: 26px; }
}
.form-check-input:hover:not(:disabled) { border-color: var(--ink); }

.form-check-input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}
.form-check-input[type="checkbox"]:checked { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23121212' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' d='M3.5 8.5 6.5 11.5 12.5 4.5'/%3E%3C/svg%3E"); }
.form-check-input[type="checkbox"]:indeterminate {
  background-color: var(--accent); border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath stroke='%23121212' stroke-width='2.5' stroke-linecap='round' d='M4.5 8h7'/%3E%3C/svg%3E");
}
.form-check-input[type="radio"]:checked { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='5' fill='%23121212'/%3E%3C/svg%3E"); }
/* THE DOUBLE-PAYMENT GUARD HAD NO VISIBLE BOX. opacity composites the element
   over whatever is behind it, so at .5 the box's 1px border (--line-strong on
   --surface) resolved to #E8E8E2 on #FFFFFF = 1.23:1 light and #2A2A23 on
   #1A1A17 = 1.21:1 dark. That is bulk_salary_form.html's include_<pk> checkbox,
   disabled precisely to stop a worker being paid twice: the accountant saw an
   empty first column and could not tell an unticked row from an unselectable
   one. Explicit colours instead -- --muted as the border is 4.67:1 light /
   5.68:1 dark, and --surface-3 gives the box a filled ground no enabled box has,
   so "unavailable" is carried by fill and cursor as well as by weight. */
.form-check-input:disabled {
  opacity: 1;
  background-color: var(--surface-3);
  border-color: var(--muted);
  cursor: not-allowed;
}
/* ...and a disabled box that is also CHECKED -- an already-paid row -- must
   still show its tick, which the rule above would otherwise have flattened to
   the same grey ground as an unchecked one. (0,3,0), and the :checked rules are
   earlier in the file at equal specificity, so this is the only place it can be
   said. The lime ground is kept rather than dimmed: --accent-line would have put
   the hardcoded ink glyph at 2.29:1 in dark theme (#121212 on #4A5414) where
   --accent holds 15.02:1 in BOTH themes, which is the whole reason the checked
   state was made literal. "Locked" is carried by the --muted ring (5.30:1 light
   / 6.44:1 dark) and by cursor:not-allowed from the rule above. */
.form-check-input:disabled:checked {
  background-color: var(--accent);
  border-color: var(--muted);
}
.form-check-input:focus { box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--ink); }
.form-check-label { font-size: var(--fs-body); }
.input-group > .form-control { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > .form-select:last-child, .input-group > .form-control:last-child {
  border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 0;
}

/* =====================================================================
   Tables — 56px rows, 20px outer gutter, sticky header
   ===================================================================== */

/* A card whose body IS a table carries no padding of its own: in the
   reference the rows run edge to edge and the header rule spans the full
   card width. 24px of padding around a table is the single clearest tell
   that a layout was assembled rather than designed. overflow:hidden lets the
   16px radius clip the first and last rows. */
.erp-card:has(> .table-responsive),
.card:has(> .table-responsive) { padding: 0; }
/* ...but zeroing it for the table's sake strips it from every sibling too,
   and these cards routinely hold an intro paragraph, an add-form or a
   bulk-action bar alongside the table. Hand the gutter back to everything
   that is NOT the table; the rules further down then restate their own band
   for the header, the pager and the form. Done generically rather than by
   listing element types, because each type was being discovered one bug at
   a time (<form> flush on the reference-data screens, <p> flush on the debt
   ledger's history card). */
.erp-card:has(> .table-responsive) > *:not(.table-responsive),
.card:has(> .table-responsive) > *:not(.table-responsive) {
  padding-left: var(--card-pad);
  padding-right: var(--card-pad);
}
.erp-card > .table-responsive:first-child,
.card > .table-responsive:first-child {
  border-top-left-radius: var(--r); border-top-right-radius: var(--r);
}
.erp-card > .table-responsive:last-child,
.card > .table-responsive:last-child {
  border-bottom-left-radius: var(--r); border-bottom-right-radius: var(--r);
}
/* When a heading sits above the table inside the same card, it becomes a
   ruled header rather than floating over the rows. */
.erp-card:has(> .table-responsive) > h2,
.erp-card:has(> .table-responsive) > h3,
.erp-card:has(> .table-responsive) > .card-head,
/* ...and the flex bar these templates use when the header carries a button
   or a select-all, which is the same object with more in it. Without this it
   got no gutter at all: on /ishchilar/ish-haqi/ at 390px the select-all
   checkbox was bisected by the card's left border and the lime bulk button
   hung outside the card entirely. */
.erp-card:has(> .table-responsive) > div.d-flex:first-child,
.erp-card:has(> .table-responsive) > .bulk-bar {
  margin: 0 !important;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
/* The heading-only variants keep the taller band. */
.erp-card:has(> .table-responsive) > h2,
.erp-card:has(> .table-responsive) > h3,
.erp-card:has(> .table-responsive) > .card-head {
  padding: 20px 24px;
}
/* The same ruled header, for a card whose body is not a table. The
   reference's panels read as designed because of this 20/24 head band; ours
   read as assembled without it. Two shapes are covered: the heading as the
   card's first child, and the heading inside the flex row that also holds
   the card's own action button, which is how these templates write a card
   header that has a button in it. The bleed uses --card-pad so it still
   reaches the edge at the mobile padding. */
.erp-card:not(:has(> .table-responsive)) > :is(h2, h3, h4, h5):first-child,
.erp-card:not(:has(> .table-responsive)) > div.d-flex:first-child:has(> :is(h2, h3, h4, h5)),
.erp-card:not(:has(> .table-responsive)) > div.d-flex:first-child:has(> div > :is(h2, h3, h4, h5)) {
  margin: calc(var(--card-pad) * -1) calc(var(--card-pad) * -1) var(--sp-xl);
  padding: 20px var(--card-pad);
  border-bottom: 1px solid var(--line);
}

.erp-card:has(> .table-responsive) > .erp-pagination,
.erp-card:has(> .table-responsive) > .form-text {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  margin: 0;
}
/* Zeroing the card's padding for the table's sake also stripped it from any
   sibling that is NOT a table. On /sozlamalar/malumotnomalar/ each card holds
   a header, an add-form and a table, and the form's fields ran flush into the
   card's border while the header above them sat correctly inset. */
.erp-card:has(> .table-responsive) > form,
.card:has(> .table-responsive) > form,
/* ...and the same card with the nesting the other way up. On the daily tabel the
   <form> is the OUTER element and the card sits INSIDE it, so the submit row is a
   direct child of the CARD and matched nothing above: "Tabelni saqlash" sat hard
   against the card's bottom border with no gap at all, while the table above it
   was correctly full-bleed. Four templates nest this way -- the tabel, the two
   payroll screens and the debt detail -- so it is a shape, not a one-off. Which
   way round a template happens to nest its form is not something the reader of a
   card should be able to see.

   Mobile is untouched: below 992px .form-actions becomes a sticky bar that sets
   its own padding and its own safe-area bottom inset, in a later block. */
.erp-card:has(> .table-responsive) > .form-actions,
.card:has(> .table-responsive) > .form-actions {
  padding: 0 var(--card-pad) var(--card-pad);
}

.table-responsive {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  /* The wrap decision below is made against the CARD width, not the
     viewport, so a narrow table in a narrow card still behaves. */
  container-type: inline-size;
}

/* NOTHING in this product said a table scrolls. There is no ::-webkit-scrollbar
   rule in this file, no mask, no ::after fade, and macOS/iPadOS draw overlay
   scrollbars that are invisible until a scroll is already under way -- so on
   every ledger wider than its card the rightmost money columns (Summa, Qoldiq,
   Foyda) sat behind a gesture with no affordance at all.
   A PERMANENT, STYLED SCROLLBAR is the affordance, not an edge-fade gradient.
   The gradient technique (two cover layers with background-attachment: local
   over two radial shadows) was the first answer and it CANNOT coexist with the
   zebra striping below: a wrapper's background paints beneath every descendant
   background, and once alternate rows are opaque the shadow only shows through
   every other row -- a striped shadow, which reads as a rendering fault rather
   than as an affordance. Naming ::-webkit-scrollbar is what makes WebKit and
   Blink draw a CLASSIC bar instead of the overlay one that stays invisible until
   a scroll is already under way, so the bar is there before the user guesses,
   which is the whole problem. Firefox draws a classic bar already and takes the
   two scrollbar-* properties for the theming.
   Cost, measured: 10px of height under a table that overflows and 10px of width
   beside one that is taller than the height cap. Nothing is drawn when there is
   nothing to scroll, so no card grows. */
/* --control-line, not --line-strong, on the thumb and in scrollbar-color: the
   comment above says the bar has to be there BEFORE the user guesses, and
   #D2D2C6 on the #F1F1E9 track is 1.11:1 -- a 10px stripe the same colour as
   its own groove, which is not there at all. --control-line measures 3.33:1 on
   that track light and 3.25:1 dark. Colour only; the 10px stays 10px. */
.erp-card > .table-responsive,
.card > .table-responsive {
  scrollbar-color: var(--control-line) var(--surface-3);
}
.erp-card > .table-responsive::-webkit-scrollbar,
.card > .table-responsive::-webkit-scrollbar { width: 10px; height: 10px; }
.erp-card > .table-responsive::-webkit-scrollbar-track,
.card > .table-responsive::-webkit-scrollbar-track {
  background: var(--surface-3); border-radius: 9999px;
}
.erp-card > .table-responsive::-webkit-scrollbar-thumb,
.card > .table-responsive::-webkit-scrollbar-thumb {
  background: var(--control-line); border-radius: 9999px;
}
.erp-card > .table-responsive::-webkit-scrollbar-thumb:hover,
.card > .table-responsive::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* THE STICKY HEADER HAD NEVER STUCK ONCE. A specified overflow-x of `auto`
   makes overflow-y COMPUTE to `auto` too, so all 57 of these wrappers are
   scroll containers in BOTH axes -- and a sticky box is offset from its nearest
   scrollport, which is therefore the wrapper and not the viewport. The
   wrapper's height is auto, i.e. exactly the table's height, so its vertical
   scrollable overflow is 0px and `top: 0` had nothing to translate against.
   ERP_PAGE_SIZE is 25 (apps/core/mixins.py) and a row is 56px, so a default
   page is 1400px of figures under a 45px header that leaves the screen at
   about row 12; on reports/salary_report.html that is five adjacent so'm
   columns read with no column label in sight, and ?per_page accepts 200.
   Giving the wrapper a real height is what makes `top: 0` resolve against a box
   that actually scrolls. Scoped to >= 1200px because below that the table is a
   stack of label/value cards -- thead is display:none, there is no header to
   stick, and a nested scroller full of cards would be actively worse. The pager
   is a sibling OUTSIDE this wrapper, so it stays where it was. `screen` is
   explicit so no paper size can accidentally match and clip a printed ledger.
   ONLY ON A TALL SCREEN. On the 1366x768 budget laptop the box was 548px: a
   second scroller inside the page, so the user list showed 9 of 14 people with
   the other five behind a scrollbar macOS does not draw, and every reference
   list on Ma'lumotnomalar was cut off the same way -- two nested scrolls is the
   harder thing for this audience, not a header that scrolls away. Below 900px
   of height the table is part of the page again; the frozen actions column
   keeps the buttons in reach either way. */
@media screen and (min-width: 1200px) and (min-height: 900px) {
  .table-responsive { max-height: calc(100dvh - 220px); overflow: auto; }
}
.table, .erp-table {
  width: 100%; margin: 0;
  border-collapse: separate; border-spacing: 0;
  color: var(--ink);
}
/* NOT a fixed min-width. A blanket 920px floor fixed the ten-column ledgers
   and broke every narrow two-column card on the dashboard, clipping their
   content. `nowrap` alone achieves the same thing without the collateral:
   the table grows to whatever its content needs, narrow tables stay narrow,
   and .table-responsive scrolls only when there is genuinely something to
   scroll to. */
/* Whether a cell may wrap depends on how much room its TABLE has, not on how
   wide the window is: the same markup is a ten-column ledger filling the
   content area and a three-column summary in a 360px dashboard column.
   A container query asks the right question.

   Wide enough (>= 640px): nothing wraps, so rows stay exactly 56px and the
   wrapper scrolls if the columns need more room.
   Narrower: cells wrap, because a scrollbar inside a small summary card is
   worse than two lines of text. */
@container (min-width: 640px) {
  .erp-table tbody td, .erp-table thead th { white-space: nowrap; }
}
/* Figures and dates never wrap, at any width. */
.erp-table td.text-end, .erp-table th.text-end, .erp-table td.mono { white-space: nowrap; }
.erp-table td.wrap, .erp-table td[data-wrap] { white-space: normal; min-width: 180px; }
/* CSS cannot count columns, so a five-column ledger in a 1630px card handed
   ~320px to each cell holding an 11-character figure: Kirim and Chiqim ended up
   a third of a metre apart with white space between them. The two cash-flow
   tables declare .is-narrow and apps/finance/tests_ui_tables.py asserts it is
   on exactly the tables with <= 6 columns. .erp-table is already width:100%,
   so this is min(100%, 1120px) and never binds below 1120px of card -- card
   mode, phones and tablets are untouched and .table-responsive has nothing to
   scroll. */
.erp-table.is-narrow { max-width: 1120px; }
/* A long title gets a bounded column and an ellipsis rather than three lines.
   WAS a flat 260px at every width from 768px to 3440px, which after the 20+14
   of padding left 226px = about 31 Latin characters, and the canonical Uzbek
   full name ("Shoxobiddinov Zaynobiddin Kamoliddin o'g'li") measures 263px at
   14px -- so the one column a storekeeper actually scans was the only column
   that could not use the width, on the very screens that had 1600px spare.
   min(42ch, 420px) is ~328px at the body step and still bounded, so a name fits
   with room and a 90-character project description still cannot eat the row. */
.erp-table td.is-title-cell, .erp-table td:first-child {
  max-width: min(42ch, 420px); overflow: hidden; text-overflow: ellipsis;
}
/* text-overflow does NOT inherit, and it only acts on the block whose own line
   box overflows. Where the cell holds block children -- attendance_form's name
   plus position, user_list, brigade_list -- the clamp above cut the name mid
   glyph with no ellipsis and nothing on screen admitted anything had been
   dropped. A truncation the reader cannot see is worse than a wrapped line. */
.erp-table td.is-title-cell > *,
.erp-table td:first-child > * { overflow: hidden; text-overflow: ellipsis; }
/* ...but a colspan cell is an empty-state MESSAGE, not a column. It is also
   a :first-child, so it took both the 260px clamp and the nowrap from the
   container query -- and white-space inherits, so the paragraph inside could
   not wrap either. Every "nothing found" message in the product was being
   clipped to one ellipsised line. */
.erp-table td[colspan], .table td[colspan] {
  max-width: none; overflow: visible; white-space: normal;
}
.erp-table thead th, .table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface);
  /* 13px and NO tracking. This is the label that tells the user which
     column they are reading, and it was the hardest text on the page: 11px
     uppercase at 0.08em. At 11px the tracking was compensating for the
     size; at 13px the size does that work, and dropping it hands ~8% of
     the width back to a ten-column ledger that would otherwise scroll. */
  font-size: var(--fs-meta); font-weight: 650;
  text-transform: uppercase; color: var(--muted);
  text-align: left; white-space: nowrap;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.erp-table tbody td, .table tbody td,
.erp-table tbody th, .table tbody th {
  /* Colour is set HERE, not on .table: Bootstrap paints cells through
     `.table>:not(caption)>*>*{color:var(--bs-table-color)}`, which outranks
     a colour declared on the table element. */
  color: var(--ink);
  height: 56px; padding: 0 14px;
  border-bottom: 1px solid var(--line); border-top: 0;
  font-size: var(--fs-body); font-weight: 400; vertical-align: middle;
  background: transparent;
}
/* The outer gutter matches the card's, so the first and last columns line up
   with the header above them instead of floating 6px inside it. */
.erp-table th:first-child, .erp-table td:first-child,
.table th:first-child, .table td:first-child { padding-left: 20px; }
.erp-table th:last-child, .erp-table td:last-child,
.table th:last-child, .table td:last-child { padding-right: 20px; }
.erp-table tbody tr:last-child td, .table tbody tr:last-child td { border-bottom: 0; }

/* ZEBRA STRIPING, which this product had none of anywhere (grep table-striped:
   no hits, and `.table > :not(caption) > * > * { box-shadow: none }` below
   would have killed Bootstrap's version anyway). Until the cap above, a row
   could be 3116px wide with a 1.05:1 hover tint as the ONLY thing carrying the
   eye from a worker's name to the figure that pays them; at the capped 1630px
   it is still a third of a metre. A tint that is there before the pointer
   arrives is what lets a reader keep their place.
   Declared on the TR, not the TD, for one reason: the frozen first column below
   needs an OPAQUE background so the columns can slide underneath it, and
   `background: inherit` on that cell then picks up whichever stripe its own row
   is wearing -- one declaration instead of four specificity-matched copies.
   That is also why odd rows are painted --surface explicitly rather than left
   transparent: `inherit` from a transparent row would let the table show
   through the frozen cell. */
.erp-table tbody tr { background: var(--surface); }
.erp-table tbody tr:nth-child(even) { background: var(--surface-2); }
/* --surface-3, not --surface-2: hover has to stay distinguishable FROM the
   zebra tint now that every second row already wears --surface-2. */
.table-hover tbody tr:hover, .erp-table tbody tr:hover { background: var(--surface-3); }

/* The identifying column (Xodim, Kontragent, Nomi, Sana) is the first thing to
   scroll off the left, so on a 1366px laptop a buxgalter scrolling the payroll
   report right to reach Qo'lga oluvchi loses the name the figure belongs to --
   which is how a figure gets read against the wrong worker. Freeze it.
   :not([colspan]) excludes the "topilmadi" empty-state cell, which is also a
   :first-child, spans the whole table and is deliberately exempt from the clamp
   above. thead th is already sticky with top:0 and z-index:2, so its first cell
   needs 3 to sit above both its own row and the frozen body column. */
.erp-table thead th:first-child,
.erp-table tbody td:first-child:not([colspan]) {
  position: sticky; left: 0; background: inherit;
}
.erp-table tbody td:first-child:not([colspan]) { z-index: 1; }
.erp-table thead th:first-child { z-index: 3; background: var(--surface); }
/* The totals row's label ("Jami", "Yakuniy qoldiq") freezes with the column it
   labels. No background declared here on purpose: the tfoot rule below already
   paints --surface-3, which is opaque, and restating it would fight that rule
   for no reason. */
.erp-table tfoot th:first-child, .erp-table tfoot td:first-child {
  position: sticky; left: 0; z-index: 1;
}

.table > :not(caption) > * > * { box-shadow: none; }
/* This rule had never matched a single element. Both tfoots in the product --
   the balance ladder in reports/cash_flow_report.html and the one in
   projects/project_detail.html -- are built from <th>, not <td> (4 tfoot th, 0
   tfoot td across all templates), so the totals row never got its --surface-3
   band, its 650 weight, its --line-strong rule or its 52px height. And because
   `text-align: left` on .erp-table thead th is thead-scoped, th's UA
   `text-align: center` left "Davr boshiga qoldiq" centred across four columns
   with its figure right-aligned. The figure cell is unaffected: it carries
   Bootstrap's .text-end, which is !important. */
.erp-table tfoot td, .table tfoot td,
.erp-table tfoot th, .table tfoot th {
  font-weight: 650; background: var(--surface-3); text-align: left;
  border-top: 1px solid var(--line-strong); height: 52px;
}
.table-actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }
td.text-end, th.text-end { font-variant-numeric: tabular-nums lining-nums; }

/* A ROW'S ACTIONS NEVER SCROLL AWAY. On a 1366x768 laptop 31 tables on 26 pages
   are wider than their card -- the income ledger 1717px in a 1056px card,
   payroll 1857px -- and the actions column is the LAST one, so Ko'rish /
   Tahrirlash / O'chirish sat 300-800px past the right edge, behind a scrollbar
   macOS does not draw until you scroll. It is frozen to the right edge the way
   the identifying column is frozen to the left; the figures between them still
   scroll. Desktop only: below 1200px the same cell is a card's action row.
   td.table-actions is a FLEX box everywhere else, and a flex box inside a table
   is wrapped in an anonymous cell that `sticky` cannot move -- so here it goes
   back to being the cell itself, with the 6px gap restated as a margin. */
@media screen and (min-width: 1200px) {
  .erp-table td.table-actions { display: table-cell; text-align: right; }
  .erp-table td.table-actions > * + * { margin-left: 6px; }
  .erp-table td.table-actions > form { display: inline-block; }
  /* .is-actions is set by initResponsiveTables() on any cell holding nothing
     but buttons, whatever its markup (a bare <td>, a .table-actions div, a
     Bootstrap d-flex wrapper), at every width -- so it catches the shapes the
     two class-based selectors do not, such as the payroll list's. */
  /* width:1% -- the column takes what its buttons need and no more, so a table
     that fits hands the spare width to the data instead of to a wide empty
     band left of the buttons. The header is right-aligned with them: it used
     to float at the column's left edge, over empty space, a button-row away
     from what it labels. */
  .erp-table tbody td.table-actions:last-child,
  .erp-table tbody td:last-child:has(> .table-actions),
  .erp-table tbody td.is-actions:last-child {
    position: sticky; right: 0; z-index: 1; background: inherit;
    box-shadow: inset 1px 0 0 var(--line);
    width: 1%; white-space: nowrap;
  }
  .erp-table:has(> tbody > tr > td.table-actions:last-child, > tbody > tr > td:last-child > .table-actions, > tbody > tr > td.is-actions:last-child) > thead > tr > th:last-child {
    position: sticky; right: 0; z-index: 3; background: var(--surface);
    box-shadow: inset 1px 0 0 var(--line);
    width: 1%; text-align: right;
  }
  /* A row collapsed on a desktop (refreshAllActionMenus: the table overflows)
     holds its primary action and "Yana". The list is positioned against the
     viewport by app.js, so the scroller cannot clip it. */
  .erp-table .actions-more { position: relative; display: inline-flex; vertical-align: middle; }
  .erp-table .actions-more-toggle { gap: 6px; }
  .erp-table .actions-more-list {
    z-index: 1050;
    min-width: 190px;
    display: flex; flex-direction: column;
    padding: 6px; gap: 2px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-pop);
    text-align: left;
  }
  .erp-table .actions-more-list[hidden] { display: none; }
  .erp-table .actions-more-item {
    width: 100%; margin: 0 !important;
    justify-content: flex-start;
    border-color: transparent; background: transparent;
  }
  .erp-table .actions-more-item:hover { background: var(--hover); }
  /* The cue that there IS more: initTableOverflowCue() in app.js marks a
     scroller whose content continues past its right edge, and the frozen
     column then casts a shadow over what is underneath it. Without it the
     frozen column looks like the table simply ends there. */
  .table-responsive.has-more-right .erp-table tbody td.table-actions:last-child,
  .table-responsive.has-more-right .erp-table tbody td:last-child:has(> .table-actions),
  .table-responsive.has-more-right .erp-table tbody td.is-actions:last-child,
  .table-responsive.has-more-right .erp-table:has(> tbody > tr > td.table-actions:last-child, > tbody > tr > td:last-child > .table-actions, > tbody > tr > td.is-actions:last-child) > thead > tr > th:last-child {
    box-shadow: inset 1px 0 0 var(--line-strong), -10px 0 12px -10px rgba(0, 0, 0, .45);
  }
}

/* =====================================================================
   Badges
   ===================================================================== */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--r);
  font-size: var(--fs-meta); font-weight: 600; white-space: nowrap;
  border: 1px solid transparent;
}
/* !important, reluctantly and deliberately. Bootstrap ships
   `.bg-success{background-color:…!important}`, which beats any plain
   declaration here whatever its specificity. The result was measurable and
   bad: "Faol" rendered as #2F7A45 text on Bootstrap's #198754 — a contrast
   ratio of 1.16:1, i.e. invisible — and Bootstrap's #0D6EFD and #FFC107 were
   appearing in a palette that contains neither colour.
   Scoped to `.badge.bg-*` rather than remapping --bs-success-rgb, because the
   remap would silently repaint alerts, buttons, progress bars and text-bg-*
   as well, and that blast radius is not inspectable. */
.badge.bg-success { background-color: var(--pos-soft) !important; color: var(--pos) !important; }
.badge.bg-danger  { background-color: var(--neg-soft) !important; color: var(--neg) !important; }
.badge.bg-warning { background-color: var(--warn-soft) !important; color: var(--warn) !important; }
.badge.bg-info    { background-color: var(--accent-soft) !important; color: var(--accent-label) !important; }
.badge.bg-primary { background-color: var(--ink) !important; color: var(--surface) !important; }
.badge.bg-secondary, .badge.bg-light { background-color: var(--surface-3) !important; color: var(--muted) !important; }
/* A leading mark, so status is not carried by colour alone — the
   reference's .badge-ok does the same. */
/* Every status badge, not four of six. The mark exists so status is not
   carried by colour alone; excluding bg-primary/secondary/light put two
   different affordances in the same badge row on /loyihalar/. */
/* :not(.rounded-pill) matters. The pill variant is never a status in this
   product -- it is a quantity chip ("12 dona") and the topbar's notification
   COUNT, and giving the count a dot put a stray blob on top of the numeral
   inside an 19x18 circle. A badge that carries a number does not need a
   non-colour cue; it already has one. */
.badge.bg-success:not(.rounded-pill)::before, .badge.bg-danger:not(.rounded-pill)::before,
.badge.bg-warning:not(.rounded-pill)::before, .badge.bg-info:not(.rounded-pill)::before,
.badge.bg-primary:not(.rounded-pill)::before, .badge.bg-secondary:not(.rounded-pill)::before,
.badge.bg-light:not(.rounded-pill)::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; flex: none;
}
/* ...and SIX STATES WEARING THE SAME DOT still separated them by colour alone.
   The dot above says "this badge is a status"; it does not say which status,
   so a reader who cannot separate --pos from --neg, or who is looking at a
   greyscale print of a project report, was back to reading nothing but hue. One
   shape per state, which is the approach notifications.css:150 already takes
   for its four levels ("the level, as a shape and a colour rather than colour
   alone"). The badge's own word (get_status_display: "Faol", "Ochiq",
   "Bekor qilingan") is the third channel and it stays.
   Geometry, not glyphs: a ▲ or a ◆ from the system font stack renders at a
   different size, baseline and weight on every one of the five platforms this
   product is opened on, and half of them substitute an emoji. A clip-path on a
   7px box is identical everywhere.
   7px, up from 5px, costs every status badge exactly 2px of width. Worst case
   measured: "Bekor qilingan" in a phone card row at 320px, where the value side
   of the row has 143px (260px row - a 117px label cap) -- 14 characters at
   --fs-meta 14px/600 is ~106px + 7 shape + 6 flex gap + 20 padding = 139px, so
   it still fits, where a 9px box would not have. */
.badge.bg-danger:not(.rounded-pill)::before {
  border-radius: 0;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);   /* triangle: the alarm shape */
}
.badge.bg-warning:not(.rounded-pill)::before {
  border-radius: 1px;
  transform: rotate(45deg) scale(.82);            /* diamond: needs attention */
}
.badge.bg-info:not(.rounded-pill)::before {
  background: transparent;                        /* ring: under way */
  border: 1.5px solid currentColor;
}
.badge.bg-primary:not(.rounded-pill)::before {
  border-radius: 1px;                             /* square: finished */
}
.badge.bg-secondary:not(.rounded-pill)::before,
.badge.bg-light:not(.rounded-pill)::before {
  height: 3px; border-radius: 1px;                /* bar: neither, dormant */
}
/* bg-success keeps the circle from the rule above -- it is the state a reader
   meets most often, so it is the one that should not have to be learned. */
.badge.rounded-pill { border-radius: 9999px; }

.amount { font-weight: 600; font-variant-numeric: tabular-nums lining-nums; }

/* A phone number is one token, not a sentence. Several of the containers it
   sits in carry overflow-wrap:anywhere for long Uzbek project names, which
   was splitting "+998 71 262 11 22" across two lines mid-number on the
   project cards at 390px. */
.tel { white-space: nowrap; }
.text-success { color: var(--pos) !important; }
.text-danger { color: var(--neg) !important; }
.text-warning { color: var(--warn) !important; }
.text-muted { color: var(--muted) !important; }

/* =====================================================================
   Empty state
   ===================================================================== */

.empty-state { padding: 48px 24px; text-align: center; }
.empty-state-icon {
  width: 52px; height: 52px; margin: 0 auto 16px;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface-2); color: var(--muted); font-size: 19px;
}
/* These are aliased onto the markup the 20 empty states actually use
   (<div class="empty-state"><h5>…</h5><p>…</p>) rather than the templates
   being rewritten to adopt the class names. The designed treatment is what
   matters; which selector carries it is not worth 20 diffs.
   No icon tile: a decorative glyph repeated across 20 unrelated contexts is
   an icon chosen because an icon was available, not because it says
   anything, so .empty-state-icon is left for callers that have a real one. */
.empty-state-title,
.empty-state > h5, .empty-state > h4, .empty-state > h3 {
  font-size: var(--fs-lead); font-weight: 650; margin-bottom: 6px; color: var(--ink);
}
.empty-state-text,
.empty-state > p {
  font-size: var(--fs-body); color: var(--muted); max-width: 50ch; margin: 0 auto 16px;
}
.empty-state > p:last-child { margin-bottom: 0; }

/* =====================================================================
   Detail grid
   ===================================================================== */

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px 28px; }
.detail-grid > div { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.detail-grid > div.full { grid-column: 1 / -1; }
.detail-grid strong {
  display: block;
  font-size: var(--fs-micro); font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
}
.detail-grid span { font-size: var(--fs-body); color: var(--ink); overflow-wrap: anywhere; }

/* =====================================================================
   Alerts, dropdowns, modals, pagination, progress, tabs
   ===================================================================== */

/* THE MEASURE CAP, applied where it was missed. These six components ARE the
   manual for a user who has none: worker_form.html's explanation of the Stavka
   field is 235 characters and rendered as ONE line -- 1716px wide, 413
   characters per line at 3440px, six times a readable measure. The stylesheet
   already caps .page-subtitle at 62ch, .empty-state > p at 50ch and .error-text
   at 52ch, so this is the house number applied to the rest; 72ch is ~525px at
   the body step, one step wider than the subtitle because an alert is a block
   of its own rather than a line under a heading. Still needed after the 1680px
   container cap -- a 1600px alert is 220 characters per line. */
.alert, .soft-alert, .form-text, .card-sub, .stat-meta, .kpi-note { max-width: 72ch; }

/* display: BLOCK. This was a flex row, and a flex container turns every child --
   including each anonymous run of text between two <strong>s -- into a column of
   its own. 43 of the product's 56 alerts are a sentence with bold words in it, so
   "<strong>Diqqat:</strong> ... <strong>qayta kiritilmaydi</strong>. Tizim ..."
   rendered as four side-by-side ribbons, one word per line on a phone, with the
   key phrase cut out of its sentence; the form error summary put its heading
   beside its list. The alerts that really are an icon beside a text block say so
   with Bootstrap's d-flex, which is !important and needs nothing from here. */
.alert {
  border-radius: var(--r); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  padding: 16px 20px; font-size: var(--fs-body);
  display: block;
}
.alert-success { background: var(--pos-soft); border-color: transparent; color: var(--pos); }
.alert-danger { background: var(--neg-soft); border-color: transparent; color: var(--neg); }
.alert-warning { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.alert-info { background: var(--surface); border-color: var(--accent-line); color: var(--ink); }
.soft-alert { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px; font-size: var(--fs-body); }

.dropdown-menu {
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); box-shadow: var(--shadow-pop);
  padding: 6px; font-size: var(--fs-body); color: var(--ink);
}
.dropdown-item { border-radius: var(--r); padding: 9px 12px; color: var(--ink-2); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--hover); color: var(--ink); }
.dropdown-header { font-size: var(--fs-micro); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 8px 12px; }
.dropdown-divider { border-color: var(--line); }

.modal-content { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop); }
.modal-header, .modal-footer { border-color: var(--line); padding: 20px 24px; }
.modal-body { padding: 24px; }
/* Bootstrap inverts .btn-close's black SVG glyph only under
   [data-bs-theme="dark"]. This app themes with data-theme, so the glyph never
   flipped: #000 at opacity .5 on the dark surface #1A1A17 composites to
   #0D0D0C -- 1.12:1, invisible. Stamping data-bs-theme as well would switch
   on Bootstrap's entire dark token set to fix one 16px icon, so the filter is
   applied directly instead. */
.btn-close { opacity: .65; }
.btn-close:hover { opacity: 1; }
:root[data-theme="dark"] .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

/* A modal whose <form> wraps the header, body and footer.

   Bootstrap's .modal-dialog-scrollable only shrinks .modal-body when it is a
   DIRECT flex child of .modal-content. Put a <form> in between -- which the
   assign-task modal must, because its footer holds the submit button -- and
   the chain breaks: the form is a plain block, the body never shrinks, and
   the whole thing overflows the content's max-height. Since .modal-content
   also sets overflow:hidden, the footer is not merely pushed down, it is
   CLIPPED AWAY: on a 12-floor block the "Topshiriqni saqlash" button could
   not be seen, scrolled to, or reached by keyboard.

   Making the form the flex column that .modal-content expected restores it. */
.modal-content > form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.modal-dialog-scrollable .modal-content > form > .modal-body {
  overflow-y: auto;
  min-height: 0;
}
.modal-content > form > .modal-header,
.modal-content > form > .modal-footer { flex: none; }
.modal-backdrop.show { background: var(--overlay); opacity: 1; }

.erp-pagination { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.pagination-summary { font-size: var(--fs-meta); color: var(--muted); font-variant-numeric: tabular-nums; }
.pagination-summary strong { color: var(--ink); font-weight: 600; }
.pagination { gap: 4px; margin: 0; }
.page-link {
  min-width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); color: var(--ink-2);
  font-size: var(--fs-body); font-weight: 500;
}
.page-link:hover { background: var(--hover); color: var(--ink); border-color: var(--line-strong); }
.page-item.active .page-link { background: var(--ink); border-color: var(--ink); color: var(--surface); }
/* "Oldingi" / "Keyingi" at opacity .45 composited --ink-2 over --surface to
   #A7A7A4 = 2.41:1, which reads as ABSENT rather than as unavailable -- so a
   user sitting on page 1 never learns there is a page 2. Stated colours: --muted
   on --surface-3 is 4.67:1 light / 5.68:1 dark, and the filled ground is the
   non-colour half, since an available pager cell is --surface. */
.page-item.disabled .page-link {
  opacity: 1;
  color: var(--muted); background: var(--surface-3); border-color: var(--line);
  cursor: not-allowed;
}

.progress { height: 6px; background: var(--surface-3); border-radius: 9999px; overflow: hidden; }
.progress-bar { background: var(--ink); border-radius: 9999px; }
/* !important, for the same reason .badge needed it: Bootstrap ships
   .bg-success{background-color:…!important}, and an !important author
   declaration beats any non-important one whatever its specificity. Without
   it these four lost and the bars painted Bootstrap's #198754 / #dc3545 /
   #ffc107 / #0dcaf0 -- four colours that exist nowhere in this palette. */
.progress-bar.bg-success { background-color: var(--pos) !important; }
.progress-bar.bg-danger { background-color: var(--neg) !important; }
.progress-bar.bg-warning { background-color: var(--warn) !important; }
.progress-bar.bg-info, .progress-bar.bg-secondary { background-color: var(--accent) !important; }

.nav-tabs { border-bottom: 1px solid var(--line); gap: 4px; }
.nav-tabs .nav-link {
  border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  color: var(--muted); font-size: var(--fs-body); font-weight: 600; padding: 12px 16px;
}
.nav-tabs .nav-link:hover { color: var(--ink); background: transparent; text-decoration: none; }
.nav-tabs .nav-link.active { color: var(--ink); border-bottom-color: var(--accent); background: transparent; }

.search-result-item {
  display: block; padding: 16px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); margin-bottom: 12px;
}
.search-result-item:hover { background: var(--surface-2); border-color: var(--line-strong); text-decoration: none; }

.error-code { font-size: 52px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.error-title { font-size: 19px; font-weight: 650; margin: 12px 0 8px; }
.error-text { font-size: var(--fs-body); color: var(--muted); max-width: 52ch; margin: 0 auto 20px; }
.error-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* --ink-2, not --muted: on the pink danger ground --muted measured 4.43:1, under
   the 4.5 floor for 13px text, on all seventeen delete pages -- the one label
   telling the reader WHAT kind of record they are about to destroy. */
.delete-warning { background: var(--neg-soft); border-radius: var(--r); padding: 16px 20px; margin-bottom: var(--sp-lg); }
.delete-target-type { font-size: var(--fs-micro); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); }
.delete-target-label { font-size: var(--fs-title); font-weight: 650; color: var(--ink); }
/* Date and project under the name: what tells two same-titled rows apart. */
.delete-target-meta { margin-top: 2px; font-size: var(--fs-meta); color: var(--ink-2); }
.calculator-result { background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: var(--r); padding: 20px; }

.notification-menu { width: min(360px, calc(100vw - 32px)); max-height: 60vh; overflow-y: auto; }

/* =====================================================================
   Block grid — the building map (Residence > Block > apartment)
   ===================================================================== */

.cell-grid-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: var(--sp-sm); }
.cell-grid { border-collapse: separate; border-spacing: 3px; margin: 0; }
.cell-grid td { padding: 0; }
.cell-grid-floor {
  font-size: var(--fs-micro); font-weight: 650; letter-spacing: 0.06em;
  color: var(--muted); text-align: right;
  padding-right: var(--sp-sm); white-space: nowrap; user-select: none;
}
.cell-grid.is-selectable .cell-grid-floor { cursor: pointer; }
.cell-grid.is-selectable .cell-grid-floor:hover { color: var(--ink); text-decoration: underline; }

.cell {
  display: inline-flex; align-items: center; justify-content: center;
  /* 44px IS THE BASE, not the exception. It used to be 32px with a 44px rescue
     only below 680px, so the single most-tapped control in the product shrank
     on every device above that: iPad portrait 768, iPad mini 744, iPad landscape
     1024, and any modern phone rotated to landscape (844, 932) -- which is
     exactly what you do to see more flats per row. A bare <button class="cell">
     is also not in the 44px touch list, which names .btn/.page-link/.form-*, so
     nothing else reached it. With border-spacing: 3px the pitch was 35px and a
     32px target is ~8.5mm, under an adult fingertip; app.js's own pointer
     handler allows SLOP = 10px of travel, which is 31% of a 32px cell.
     Room check at the narrowest device that gains: at 768px the card gives
     678px, and a 12-flat floor at 44px is 28 (floor label) + 14x3 (border
     spacing) + 12x44 = 598px -- 80px spare. 14 flats needs 692px, 14px over,
     and .cell-grid-scroll already has overflow-x: auto for that. */
  width: 44px; height: 44px;
  /* --r-xs, not --r: a 16px radius on a 32px square reads as a circle and
     the grid stops looking like a building. */
  border-radius: var(--r-xs);
  /* This hairline IS the building: an unassigned cell is --surface on a
     --surface card, so --line-strong's 1.52:1 left a 44px grid of nothing to aim
     at -- the flat number inside it is --fs-micro, so there was no edge and
     barely any glyph. --control-line is 3.78:1 light / 3.69:1 dark, still 1px,
     so none of the width arithmetic above moves. */
  border: 1px solid var(--control-line);
  background: var(--surface);
  color: var(--muted);
  font-size: var(--fs-micro); font-variant-numeric: tabular-nums;
  line-height: 1; padding: 0;
}
/* Already given to a brigade: solid ink, so an occupied building reads as a
   filled silhouette from across the room. */
.cell.is-assigned { background: var(--ink); border-color: var(--ink); color: var(--surface); }
/* Two brigades in one flat is legitimate (plasterers and electricians), so
   it is surfaced rather than prevented. */
.cell.is-shared {
  background: repeating-linear-gradient(45deg, var(--ink), var(--ink) 3px,
              var(--surface-3) 3px, var(--surface-3) 6px);
  border-color: var(--ink); color: transparent;
}
.cell-legend { width: 16px; height: 16px; vertical-align: -3px; margin-right: var(--sp-xxs); }

/* The read-only map is now interactive too: every cell opens the detail
   panel, so it gets the same affordances as the picker's cells. */
[data-cell-map] .cell { cursor: pointer; font: inherit; }
[data-cell-map] .cell:hover { border-color: var(--ink); }
[data-cell-map] .cell:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.cell.is-active {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--ink);
}

/* The task form's committed selection: a count, the block it belongs to, and
   the chosen flats as chips. Replaces a text input you typed "3-1,3-2" into. */
.cells-summary {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-md); flex-wrap: wrap;
  padding: var(--sp-md) var(--sp-lg);
  border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--surface);
}
.cells-summary-text { font-size: var(--fs-body); color: var(--ink-2); }
.cells-summary-text strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.cells-summary-block { color: var(--muted); }
.cells-chosen { display: flex; flex-wrap: wrap; gap: 4px; margin-top: var(--sp-sm); }
.cell-chip {
  font-size: var(--fs-micro); font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 2px 7px; border-radius: var(--r-xs);
  background: var(--surface-3); color: var(--ink-2);
}

/* The "who is working here" panel under the map. */
.cell-info {
  margin-top: var(--sp-lg);
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  padding: var(--sp-lg);
}
.cell-info-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-md); margin-bottom: var(--sp-md);
}
.cell-info-head h3 { font-size: var(--fs-body); font-weight: 650; margin: 0; }
.cell-info-empty { font-size: var(--fs-body); color: var(--muted); margin: 0; }
.cell-info-task {
  display: flex; flex-direction: column; gap: 3px;
  padding: var(--sp-md) 0;
  border-top: 1px solid var(--line);
}
.cell-info-task:first-child { padding-top: 0; border-top: 0; }
.cell-info-brigade {
  font-size: var(--fs-micro); font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent-label);
}
.cell-info-title { font-size: var(--fs-body); font-weight: 600; color: var(--ink); }
.cell-info-title:hover { text-decoration: underline; }
.cell-info-meta { display: flex; align-items: center; gap: var(--sp-sm); margin-top: 2px; }
.cell-info-progress { font-size: var(--fs-meta); color: var(--muted); font-variant-numeric: tabular-nums; }
.icon-button-sm { width: 30px; height: 30px; font-size: 12px; }

.cell-grid.is-selectable .cell { cursor: pointer; }
.cell-grid.is-selectable .cell:hover { border-color: var(--ink); }
.cell-grid.is-selectable .cell:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.cell.is-selected {
  background: var(--accent); border-color: var(--accent);
  color: var(--accent-ink); font-weight: 700;
}
.cell.is-assigned.is-selected {
  background: var(--accent); border-color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--ink);
}

/* =====================================================================
   RESPONSIVE — 1200 / 992 / 768 / 576, i.e. Bootstrap's xl / lg / md / sm

   WHAT THIS REPLACED, and why it had to go. There were SEVEN hand-picked
   viewport breakpoints here -- 1240, 1100, 860, 767.98, 680, 560, 430 -- while
   bootstrap.min.css is vendored alongside with its own five (576, 768, 992,
   1200, 1400) and every col-md-* and col-lg-* in the templates obeys THOSE. Two
   ladders that never lined up produced the bugs three auditors filed
   independently:

     * 768-1099px -- the WHOLE tablet class, both iPad orientations -- was
       served by desktop rules. Tables stayed tables in a 726px card needing
       1806px, so Summa and the Tahrirlash/O'chirish buttons were off-screen
       with no scrollbar drawn on a touch device; every field and button was
       40px, not 44px; and 768px iPad portrait was one hundredth of a pixel
       outside the only handheld boundary in the file, so it rendered SMALLER
       text than a 767px phone held at the same distance by the same clerk.
     * Content width did not increase monotonically with viewport width. The
       260px rail returned at 1101px while the padding step at 1240 moved the
       other way, so content(1100) = 1058px but content(1101) = 791px and you
       needed 1384px to get back what 1100px gave you -- with 1280 and 1366,
       the two commonest laptop widths, inside the bad band.

   FOUR BOUNDARIES NOW, all Bootstrap's:
     1200 (xl) -- the permanent rail arrives, and tables stay tables.
      992 (lg) -- the finger boundary: 44px targets, 16px fields, bumped type.
      768 (md) -- phone layout: one-column detail grids, two-up KPIs.
      576 (sm) -- narrow phone: one-column KPIs, label-left figure-right.
   The padding step is gone (one value from 992 up, see .main-content >
   .container-fluid), 680 and 560 and 430 are folded into 576, and 860 is folded
   into 768. Container queries stay container queries: they ask about the CARD,
   which is the right question and cannot fight a viewport ladder.

   THE ONE RESIDUAL REVERSAL, stated rather than hidden: content(1199) = 1157px
   and content(1200) = 890px, because a 260px rail cannot appear without costing
   260px. It is now a single step at a single Bootstrap boundary instead of two
   steps at two invented ones, and its consequence -- a ledger that no longer
   fits -- is what the frozen first column, the zebra striping and the scroll
   shadows above exist to survive. Removing it outright needs an icon-width rail,
   which is a navigation decision, not a layout one.
   ===================================================================== */

/* ---------------------------------------------------------------------
   1200 — THE RAIL GOES, AND TABLES BECOME CARDS

   A 9-column table cannot be read at 390px, and it cannot be read in the 726px
   a 768px iPad gives it either. Horizontal scroll is the usual answer and it is
   the wrong one: it hides exactly the columns that matter (Miqdor, Qoldiq,
   Foyda) behind a gesture nobody discovers. Every row restacks into a
   label/value card instead. The labels are injected from the <th> at runtime by
   app.js -- at EVERY width, so CSS alone decides -- so they can never drift out
   of step with the header.
   Card mode ends at the same 1200px as the rail deliberately: below it there is
   no permanent sidebar either, so one boundary switches the whole layout
   between compact and full instead of three switching parts of it.
   --------------------------------------------------------------------- */

@media screen and (max-width: 1199.98px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .app-main { grid-column: 1; }
  .sidebar {
    position: fixed; left: 0; top: 0;
    width: 284px;
    height: 100vh;
    height: 100dvh;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform .24s cubic-bezier(.3,.8,.4,1), visibility 0s linear .24s;
  }
  body.nav-open .sidebar,
  .sidebar.is-open {
    transform: none; visibility: visible;
    transition: transform .24s cubic-bezier(.3,.8,.4,1), visibility 0s;
    box-shadow: var(--shadow-pop);
  }
  .topbar .sidebar-toggle { display: inline-flex; }
  .topbar { padding: 0 var(--sp-xl); }
  .main-content > .container-fluid { padding: var(--sp-xl) var(--sp-xl) var(--sp-4xl); }

  /* The drawer sits ABOVE the backdrop (z-index 60 against 55), so on a 320px
     phone the only dismiss target was a 36px ribbon of dimmed page -- below the
     44px floor this stylesheet sets for the whole app, and nothing marks dim
     space as a control. The hamburger the user just pressed is at x=12..52,
     underneath the panel; .app-main is inert while the drawer is open so it
     cannot be pressed again; there is no swipe handler and Escape needs a
     keyboard. Values mirror .topbar .sidebar-toggle exactly so the open and
     close controls read as one pair. */
  .sidebar-close {
    display: inline-flex; align-items: center; justify-content: center;
    flex: none; width: 44px; height: 44px; margin-left: auto;
    border: 1px solid var(--line); border-radius: var(--r);
    background: var(--surface); color: var(--ink-2);
  }
  .sidebar-close:hover { background: var(--hover); color: var(--ink); }

  /* auto-fit, not repeat(2). At 768px the content column is 728px and the grid's
     gap is 20px, so auto-fit gives 3 tracks (3x220 + 2x20 = 700 <= 728; a 4th
     would need 940) and the three KPI tiles on /xarajatlar/ take ONE 104px row
     instead of two rows plus a gap -- 124px back out of the 873.5px that put the
     first expense row at or below an iPad's fold, and 104px back on the
     five-tile debt ledger.
     The three orphan rules that used to live here are deleted rather than moved:
     they were written for a 2-track grid, and with 3 tracks a third-and-last
     tile matches :last-child:nth-child(odd) and gets thrown onto a full-width
     SECOND row -- strictly worse than the hole they existed to prevent. auto-fit
     collapses trailing empty tracks, so it needs no orphan rule. The phone block
     re-declares all three verbatim, so <= 767.98 is unaffected. */
  .stats-grid, .stats-grid.compact { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

  .erp-table.as-cards { display: block; overflow: visible; min-width: 0; width: 100%; }
  .erp-table.as-cards tbody td, .erp-table.as-cards thead th { white-space: normal; }
  .erp-table.as-cards td:first-child, .erp-table.as-cards td.is-title-cell { max-width: none; overflow: visible; }
  /* ...and the ellipsis the desktop clamp puts on the cell's block CHILDREN has
     to come off with it. A card heading must wrap: truncating "Shoxobiddinov
     Zaynobiddin Kamoliddin o'g'li" to fit 260px of card is how two workers end
     up looking like the same worker. */
  .erp-table.as-cards td:first-child > *,
  .erp-table.as-cards td.is-title-cell > * { overflow: visible; text-overflow: clip; }
  /* overflow-x: visible, so there is no scroll container and therefore no
     scrollbar to style -- the affordance up the file is a no-op here, which is
     correct: a card stack has nothing to scroll sideways to. It also lets the
     .actions-more-list dropdown escape the wrapper instead of being clipped. */
  .table-responsive:has(> .erp-table.as-cards) { overflow-x: visible; }
  .erp-table.as-cards thead { display: none; }
  .erp-table.as-cards tbody,
  .erp-table.as-cards tr,
  .erp-table.as-cards td { display: block; width: 100%; }

  .erp-table.as-cards tr {
    display: flex; flex-direction: column;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: var(--sp-lg);
    margin-bottom: var(--sp-md);
  }
  .erp-table.as-cards tr:hover td { background: transparent; }

  .erp-table.as-cards td {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: var(--sp-lg);
    height: auto;
    padding: 5px 0;
    border: 0;
    font-size: var(--fs-body);
  }
  /* The label, injected by app.js from the matching <th>. */
  .erp-table.as-cards td::before {
    content: attr(data-label);
    /* WAS `flex: none`, i.e. flex 0 0 auto, so the injected label's used width
       IS its max-content and it could never give -- the value is an anonymous
       flex item and the only thing that could. At 320px the card row is 260px
       (320 - 24 container - 2 card border - 2 row border - 32 row padding); a
       30-character Uzbek label took 244px and left 40px, and money() joins
       thousands groups with a plain ASCII space, so "45 000 000 so'm" rendered
       as four stacked lines -- a different number, with no header row to fall
       back on because thead is display:none here. A 34-character label pushed
       its value clean past the screen edge into html{overflow-x:clip}, where
       there is no scroll to go and get it. 45% of 260px = 117px for the label. */
    flex: 0 1 auto; max-width: 45%;
    /* ...but never below its longest WORD. `overflow-wrap: anywhere` with
       `min-width: 0` let a long value squeeze a short label into pieces --
       "XODI / M", "BONU / S", "JOYLASHU / V" -- which reads as garbage, not as a
       column name. `anywhere` also counts toward min-content (`break-word` does
       not), so both had to change for min-content to mean "one word". A long
       multi-word label still wraps between words. */
    min-width: min-content; overflow-wrap: break-word;
    /* The <th> is display:none here, so this IS the column header on a
       phone and it gets the header's treatment: the scale's floor and no
       tracking. */
    font-size: var(--fs-micro); font-weight: 650;
    text-transform: uppercase; color: var(--muted);
  }
  /* A cell with more than one child was laid out as [label][a][b] across a
     296px card, which is how "Perforator Bosch - 1 dona" ended up wrapped to
     three words a line beside "Hozir brigadada: 0 dona". Rich cells stack;
     simple ones keep the compact label-left / value-right pairing. */
  /* NOT an action cell: those hold several buttons and must stay a row.
     Without the exclusion a <td class="table-actions"> matched here and its
     buttons became a centred vertical pile -- three rows of chrome pushing the
     next card down. */
  .erp-table.as-cards td:has(> * + *):not(.table-actions):not(.is-actions) {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
  }

  /* A cell whose content is a FIELD is not a label/value pair either, and the
     rule above does not catch it: a <td> holding one <select> has a single
     child, so it kept the compact [label] .......... [control] row. That is the
     wrong shape for the one screen in this product that exists to be TYPED INTO
     on a phone -- the daily tabel, where a prorab standing on site sets Holat,
     Soat and Izoh for every worker in the crew. Pushed to the right of its own
     label inside a 326px card, each control was competing with the label for
     width (both are shrinkable flex items), so the three fields on a card ended
     up different widths depending on how long their label happened to be:
     "Soat" left its input wide and "Bo'lim" left its select narrow, on the same
     card, for no reason the user can see.

     A field stacks: label on its own line, control across the full width of the
     card. Checkboxes and radios are deliberately excluded -- a tick box stretched
     to 326px is a worse control than a small one, and the bulk-payroll screen's
     include_<pk> boxes are exactly that. */
  .erp-table.as-cards td:has(> input:not([type="checkbox"]):not([type="radio"])),
  .erp-table.as-cards td:has(> select),
  .erp-table.as-cards td:has(> textarea) {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding-top: 7px;
    padding-bottom: 7px;
  }

  /* The label stops being a shrinkable sibling once the cell is a column, so it
     needs its alignment stated: it inherits text-align from the cell, and the
     money cells set text-align:right on theirs. */
  .erp-table.as-cards td:has(> input:not([type="checkbox"]):not([type="radio"]))::before,
  .erp-table.as-cards td:has(> select)::before,
  .erp-table.as-cards td:has(> textarea)::before {
    text-align: left;
  }

  /* Bootstrap already sets width:100% on .form-control/.form-select, but as a
     flex item that is a BASIS the row was free to shrink. In a column it is the
     used width, and the bare element selectors cover a control that carries
     neither class. */
  .erp-table.as-cards td > .form-control,
  .erp-table.as-cards td > .form-select,
  .erp-table.as-cards td > input:not([type="checkbox"]):not([type="radio"]),
  .erp-table.as-cards td > select,
  .erp-table.as-cards td > textarea {
    width: 100%;
  }

  .erp-table.as-cards td:empty { display: none; }
  /* Class names below are the ones app.js actually applies in
     initResponsiveTables(): is-title, is-actions, is-empty, is-money. */

  /* The identifying cell becomes the card's title, above the label list. */
  .erp-table.as-cards td.is-title {
    order: -1;
    flex-direction: column; align-items: stretch; gap: 2px;
    padding-bottom: var(--sp-md); margin-bottom: var(--sp-sm);
    border-bottom: 1px solid var(--line);
    font-size: var(--fs-lead); font-weight: 650;
  }
  .erp-table.as-cards td.is-title::before { display: none; }
  /* A card title reads left, always. The cell keeps whatever alignment it had
     as a table column -- the debt ledger's title column is the payment amount
     and carries .text-end -- which left the heading hanging off the right edge
     of its own card.
     !important because Bootstrap's .text-end is itself !important, so no
     amount of specificity reaches it. */
  .erp-table.as-cards td.is-title { text-align: left !important; }

  /* An empty field is not worth a line on a 390px screen: "Ilova —" and
     "Kvitansiya —" added four dead rows to every expense card. */
  .erp-table.as-cards td.is-empty { display: none; }

  /* The figure matters more than its label, so it gets the weight. */
  .erp-table.as-cards td.is-money {
    font-size: var(--fs-lead); font-weight: 650;
    font-variant-numeric: tabular-nums lining-nums;
  }

  /* Actions drop to the bottom and go full width, because a 28px icon
     button in a card corner is not a target on a phone. */
  .erp-table.as-cards td.is-actions {
    order: 99;
    margin-top: var(--sp-md); padding-top: var(--sp-md);
    border-top: 1px solid var(--line);
  }
  .erp-table.as-cards td.is-actions::before { display: none; }
  /* One row: the first action, then the rest behind a menu (collapseActions()
     in app.js builds it). Five labelled buttons cannot share 296px -- at 360px
     "Tahrirlash" alone is ~103px -- so the row used to overflow and clip
     "O'chirish" off every card. Wrapping them instead buried the card's own
     content under three rows of controls. */
  /* Matches both shapes: the td itself, or a div inside it. */
  .erp-table.as-cards .table-actions {
    flex-direction: row;
    justify-content: flex-start;
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    width: 100%;
    flex-wrap: nowrap;
  }

  /* The primary action takes the room that is left; the menu button is fixed. */
  .erp-table.as-cards .table-actions .actions-primary {
    flex: 1 1 auto;
    min-width: 0;
  }

  .erp-table.as-cards .actions-more { position: relative; flex: 0 0 auto; }

  /* "Yana" plus a chevron, not a 44px square of three dots. */
  .erp-table.as-cards .actions-more-toggle {
    width: auto;
    padding: 0 14px;
    gap: 6px;
  }

  /* Anchored to the right edge so a menu on a card near the screen edge cannot
     itself become the thing that overflows. */
  .erp-table.as-cards .actions-more-list {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 30;
    min-width: 176px;
    display: flex;
    flex-direction: column;
    padding: 6px;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-pop);
  }

  .erp-table.as-cards .actions-more-list[hidden] { display: none; }

  /* Full-width rows inside the menu, each keeping its own colour so the
     destructive one still reads as destructive. */
  .erp-table.as-cards .actions-more-item {
    width: 100%;
    justify-content: flex-start;
    border-color: transparent;
    background: transparent;
    min-height: 44px;
  }

  .erp-table.as-cards .actions-more-item:hover { background: var(--hover); }

  /* THE COMPACT CARD (opt-in: a <th data-card> on the table, see
     initResponsiveTables). Title and key figure share the first line, the
     status sits under the figure, quiet meta lines under the title, and every
     column tagged "hide" stays in the record Ko'rish opens. Untagged columns
     keep their full label/value line across both tracks. order still applies
     to grid placement: title -1, figure (usually .is-money) 0, actions 99. */
  .erp-table.as-cards.has-card-roles tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: var(--sp-md);
    row-gap: 2px;
    align-items: baseline;
    grid-auto-flow: row dense;
  }
  .erp-table.as-cards.has-card-roles tbody td { grid-column: 1 / -1; }
  .erp-table.as-cards.has-card-roles td.is-title {
    grid-column: 1;
    border-bottom: 0; padding-bottom: 0; margin-bottom: 0;
  }
  .erp-table.as-cards.has-card-roles td.card-figure {
    grid-column: 2; grid-row: 1;
    justify-self: end; white-space: nowrap;
    font-weight: 650; font-size: var(--fs-lead);
    padding: 0;
  }
  /* The entered-currency chip ("68 000 $") drops under its figure: beside it,
     it widened the figure track until the title broke into single words. */
  .erp-table.as-cards.has-card-roles td.card-figure { flex-direction: column; align-items: flex-end; row-gap: 2px; }
  .erp-table.as-cards.has-card-roles td.card-figure > .badge { align-self: flex-end; margin-left: 0; }
  .erp-table.as-cards.has-card-roles td.card-status { grid-column: 2; justify-self: end; padding: 0; }
  .erp-table.as-cards.has-card-roles td.card-meta {
    grid-column: 1;
    padding: 0;
    font-size: var(--fs-meta); color: var(--muted);
  }
  .erp-table.as-cards.has-card-roles td.card-figure::before,
  .erp-table.as-cards.has-card-roles td.card-status::before,
  .erp-table.as-cards.has-card-roles td.card-meta::before { display: none; }
  .erp-table.as-cards.has-card-roles td.card-hide { display: none; }
  .erp-table.as-cards.has-card-roles td.is-actions { grid-column: 1 / -1; margin-top: var(--sp-sm); }

  /* A record's name is what people tap first, and as a link it was a 24px
     line; the row around it becomes the 44px target. */
  .erp-table.as-cards td.is-title > a:only-child { display: flex; align-items: center; min-height: 44px; }

  /* A title cell holding only "—" gets a heading on the card (app.js sets
     data-untitled); the dash itself is hidden there and nowhere else. */
  /* display:block, so the zero-size dash and the word share one line and the
     word sets the baseline the figure beside it aligns to. */
  .erp-table.as-cards td.is-title.is-untitled { font-size: 0; display: block; }
  .erp-table.as-cards td.is-title.is-untitled::after {
    content: attr(data-untitled);
    font-size: var(--fs-lead); color: var(--muted);
  }

  /* TWO CARDS PER ROW where the table has the room: on an iPad or a 1024px
     laptop every card spanned ~920px, its labels 900px from their values, and
     the income list ran 7000px. Asked of the table's own width (.table-
     responsive is the container), so a table in a narrow side card stays one
     column. A table with form rows that attach to the card above them -- the
     tool-loan page -- keeps one column, or a form would land beside its card. */
  @container (min-width: 700px) {
    .erp-table.as-cards:not(:has(tr[data-card-skip])) tbody {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: var(--sp-md);
    }
    .erp-table.as-cards:not(:has(tr[data-card-skip])) tbody > tr { margin-bottom: 0; }
  }

  /* Zebra striping means nothing once a row is a card: each <tr> already has
     its own --surface ground, a border and a shadow, so an unscoped stripe
     painted --surface-2 cells inside every second card. Written as an override
     rather than as :not(.as-cards) on the zebra selector up the file on
     purpose -- :not() would raise that selector above the hover rule and hover
     would stop working on a desktop. */
  .erp-table.as-cards tbody tr:nth-child(even),
  .erp-table.as-cards tbody tr:hover { background: var(--surface); }
  /* The frozen first column is a desktop device; inside a card it would pin the
     title to the left edge of a box that never scrolls sideways. */
  .erp-table.as-cards tbody td:first-child { position: static; }

  /* The FIGURE gets the whole row to itself. Keyed on .text-end and not on
     .is-money deliberately: .text-end is what the templates now put on every
     figure column, whereas .is-money comes from app.js's
     /money|summa|miqdor|jami|foyda|narx/i guess at the label, which misses
     Kirim, Chiqim, Sof oqim, Qoldiq and Yig'ilgan sof oqim outright. With the
     label on its own line the figure has the full 260px, so a 25-character
     so'm amount at ~9.6px per tabular character is 240px and nowrap can no
     longer overflow -- which it COULD if the label were capped and the figure
     left on the same line (127px of budget against a 142px "1 250 400 000
     so'm"). :not(.is-title) is load-bearing: the debt ledger's title column
     carries .text-end and nowrap on a card heading would clip it.
     WRAP, not column: as a column EVERY figure took a line of its own, so a
     count of "3" or "5 dona" sat alone at the far right of the line under its
     label, a card's height spent on one digit. Now the figure stays beside its
     label when the two fit, and only a figure that cannot fit drops to its own
     line -- right-aligned, by justify-content, under a label that grows to fill
     the line above. nowrap still means a figure is never broken. */
  .erp-table.as-cards tbody td.text-end:not(.is-title):not(.is-actions) {
    flex-wrap: wrap; justify-content: flex-end;
    column-gap: var(--sp-lg); row-gap: 2px;
    white-space: nowrap;
  }
  /* text-align:left because these cells inherit .text-end's right alignment,
     and a right-aligned label sitting above a right-aligned figure reads as two
     figures. */
  .erp-table.as-cards tbody td.text-end:not(.is-title):not(.is-actions)::before {
    flex: 1 1 auto; max-width: none; text-align: left;
    /* white-space is inherited, so the nowrap that protects the FIGURE would
       also reach the label -- and a 34-character Uzbek column name is ~272px at
       the micro step against 260px of card. The figure needs nowrap; the label
       needs to wrap. */
    white-space: normal;
  }
  /* On a money table the amount belongs directly under the title, not as the
     seventh line of an expense card under six descriptive fields. .is-title is
     already order:-1 and .is-actions already order:99, so this only moves the
     figure up. */
  .erp-table.as-cards td { order: 1; }
  .erp-table.as-cards td.is-money { order: 0; }

  /* THE TOTALS ROW. .erp-table.as-cards is display:block while tfoot keeps
     display:table-footer-group, so its rows went through CSS's anonymous-table
     fixup inside a block whose children are already display:flex, instead of
     becoming the label/value cards the rows above them are. And because every
     row gets a card's border, radius, shadow and --surface ground, the three
     summary rows of the balance ladder were indistinguishable from three more
     months of data: "Yakuniy qoldiq" read as a fourth month. */
  .erp-table.as-cards tfoot { display: block; }
  .erp-table.as-cards tfoot th { display: block; width: 100%; }
  .erp-table.as-cards tfoot tr { background: var(--surface-3); border-color: var(--line-strong); }

  /* collapseActions() in app.js only builds the one-plus-menu row below 768px
     (ACTIONS_COLLAPSE_BELOW), and a row with fewer than three buttons is never
     collapsed at all -- so between 768 and 1199, and on any two-button row,
     `flex-wrap: nowrap` above would push the last action past the card edge.
     Keyed on the absence of .actions-more, which is the element the collapse
     creates, so the two cases cannot disagree. */
  .erp-table.as-cards .table-actions:not(:has(.actions-more)) { flex-wrap: wrap; }

}

/* ---------------------------------------------------------------------
   992 — THE FINGER BOUNDARY (Bootstrap lg)

   Everything in this block used to live at 767.98px, which meant an iPad --
   the office device for a buxgalter and the site device for a storekeeper --
   got desktop measurements on a touch screen: every button and every field
   40px instead of 44, the type scale back down to 12/13/14/15px so a 768px
   tablet rendered SMALLER text than a 767px phone, and a form's save row a
   scroll away from the last field touched. 991.98 is Bootstrap's lg boundary:
   every phone and every tablet in portrait, stopping where a real pointer is a
   fair assumption.
   --------------------------------------------------------------------- */

@media screen and (max-width: 991.98px) {
  /* ---- THE TOUCH TYPE BUMP ----
     The touch block further down raises control HEIGHTS to 44px and left every
     font size exactly where the desktop put it, so a phone held at arm's length
     in daylight -- and an iPad held across a site-office desk -- showed the same
     12 and 13px text as a 27" monitor at 60cm. Each
     text step goes up one. Nothing else in this block changes: the row heights,
     paddings and card widths are the same, because the problem was never
     density -- it was that the text inside the density was sized for a desk.

     The display steps are NOT bumped: they are already large, and the rules
     below deliberately SHRINK them, because a 40px numeral does not fit a
     390px card. --fs-btn is not bumped either, for the reason given where it
     is declared. */
  :root {
    --fs-micro: 13px;
    --fs-meta:  14px;
    --fs-body:  15px;
    --fs-lead:  16px;
  }
  /* >= 16px on ANYTHING THE USER TYPES INTO. Below 16px iOS Safari zooms the
     whole page on focus and never zooms back, leaving the prorab panning a
     390px viewport one-handed to find the save button. .form-control and
     .form-select already declare 16px and only drop to the scale above 992px;
     these two are the typed surfaces that are neither of those classes, so no
     rule had ever reached them. (select2's replacement DOM is handled after the
     vendor layer, where its own later rules cannot outrank the fix.) */
  .sidebar-search input,
  .topbar .search-form input { font-size: 16px; }
  /* The drawer's field is the only search on a phone; 38px was the last
     control at the top of the drawer under the touch floor. */
  .sidebar-search input { height: 44px; }

  /* Touch targets. 44px is the Apple/WCAG floor and the difference between
     "tap" and "tap three times" for someone wearing gloves on a site. */
  .btn, .page-link, .form-control, .form-select, .sidebar-link,
  .icon-button, .sidebar-toggle {
    min-height: 44px;
  }
  /* 44px, not 38px. The comment eight lines up names 44px as the floor and then
     the most-tapped button class in the app was set below it. A prorab misses a
     38px target often enough to notice, one-handed, outdoors. */
  .btn-sm { min-height: 44px; padding: 0 14px; }
  /* The topbar's own controls were the last ones under that floor, and they are
     on every page: the two theme cells 32x32 and 2px apart (a gloved tap lands
     on the neighbour), the avatar 34x34, the bell 40 wide -- the min-height
     above reached its height only. */
  .theme-seg { padding: 0; gap: 0; }
  .theme-seg button { width: 44px; height: 44px; }
  .icon-button { width: 44px; }
  .topbar .avatar { width: 44px; height: 44px; }
  .ai-assist-btn { height: 44px; }

  /* A form's submit row sticks to the bottom of the viewport. On a 20-field
     form the buttons were a scroll away from the last field the user
     touched, which reads as "there is no save button". */
  .form-actions {
    position: sticky; bottom: 0; z-index: 20;
    display: flex; gap: var(--sp-sm);
    /* app.js swaps a submit button's label for a spinner plus "Saqlanmoqda..."
       while saving. At 320px this row's content box is 272px; the saving state
       is 16 spinner + 8 gap + ~111 of 14-character label + 32 padding = 167px
       and "Bekor qilish" is ~127px, so 167 + 8 + 127 = 302 > 272 and on the two
       forms whose row is a bare `d-flex gap-2` the cancel button was pushed off
       the right edge for the duration of every save. Rows that fit are
       untouched: Saqlash ~87 + Bekor qilish ~127 + 8 = 222 < 272. */
    flex-wrap: wrap;
    /* --card-pad on BOTH the bleed and the side padding, not a hardcoded 16px.
       The bar bleeds sideways to meet its card's gutter, and 16px only equalled
       --card-pad in the old 768px block: at 768-991 the card pad is 24px, so the
       bar stopped 8px short of the card edge, and below 576px the pad drops to
       12px, so the bar overhung its card's rounded border by 4px on each side
       (bar x=9..311 inside a card at x=12..308 -- inside the viewport, but
       visibly through the card edge). Tying both to the variable makes the pair
       correct at every breakpoint instead of at one of them. The fallback covers
       a .form-actions that is not inside a card, where the custom property is
       undefined and the whole declaration would otherwise be dropped. */
    padding: var(--sp-md) var(--card-pad, var(--sp-lg));
    margin: var(--sp-lg) calc(-1 * var(--card-pad, var(--sp-lg))) calc(-1 * var(--card-pad, var(--sp-lg)));
    background: var(--surface);
    border-top: 1px solid var(--line);
    /* Clears the iOS home indicator. */
    padding-bottom: calc(var(--sp-md) + env(safe-area-inset-bottom, 0px));
  }
}

/* ---------------------------------------------------------------------
   768 — PHONE LAYOUT (Bootstrap md)

   Not sizes, shapes: one-column detail grids, two-up KPIs, a 16px card gutter
   and the page actions taking a full-width row of their own. These are the
   rules that are wrong on a tablet, which is why the touch and type rules
   above no longer sit here with them.
   --------------------------------------------------------------------- */

@media screen and (max-width: 767.98px) {
  /* Folded in from what used to be its own @media screen and (max-width: 860px). The
     topbar search goes; it is duplicated at the top of the drawer, where there
     is room for it to be usable rather than a 90px stub. Raised from 860 to 768
     because at 768px the topbar has 728px to spend and needs 226px of chrome
     (40 toggle + 12 gap + 162 right cluster + 12 gap), so the 360px search box
     fits with 142px to spare -- it was being hidden on a tablet for no reason. */
  .topbar .search-form { display: none; }
  .profile-meta { display: none; }

  .main-content > .container-fluid { padding: var(--sp-lg) var(--sp-lg) var(--sp-4xl); }
  .page-title { font-size: 22px; }
  .page-header { gap: var(--sp-md); }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  /* TWO up, not one. Four full-width KPI cards is ~440px of scrolling
     before the first row of actual data -- on the page the user opened to
     see that data. Two columns halves it and the figures stay legible. */
  .stats-grid, .stats-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-md);
  }
  /* The one emphasis card keeps the full width: it is the headline. */
  .stats-grid > .is-emphasis { grid-column: 1 / -1; }
  /* The 104px floor is a desktop measurement. Here the label and value sit on
     one line, so it became ~60px of void per card -- 180px of scrolling before
     the data on a page opened to see the data. */
  .stat-card:not(:has(.kpi-spark)) { min-height: 0; }
  /* An odd number of cards leaves the last one sitting next to a gap.
     Let it span instead -- a half-empty final row reads as a missing card.
     When an .is-emphasis card is present it already spans a whole row, which
     flips the parity of everything after it, so the orphan is the EVEN one.
     The dashboard is exactly this case: emphasis first, then three. */
  .stats-grid > .stat-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .stats-grid:has(> .is-emphasis) > .stat-card:last-child:nth-child(odd) { grid-column: auto; }
  .stats-grid:has(> .is-emphasis) > .stat-card:last-child:nth-child(even) { grid-column: 1 / -1; }

  /* The same treatment for the Bootstrap-column variant of a KPI row. */
  .row > [class*="col-md-3"]:has(.mini-stat),
  .row > [class*="col-lg-3"]:has(.mini-stat),
  .row > [class*="col-md-4"]:has(.mini-stat) {
    flex: 0 0 50%; max-width: 50%;
  }
  .mini-stat > strong { font-size: 17px; }
  /* Update the VARIABLE, not just the padding: the full-bleed card header
     bleeds by calc(var(--card-pad) * -1), so changing one without the other
     left the header band and its rule hanging 8px past both card edges,
     outside the corner radius. */
  .erp-card, .card { --card-pad: var(--sp-lg); padding: var(--card-pad); }
  .stat-card { padding: var(--sp-lg); }
  .stat-value { font-size: 24px; }
  .detail-grid { grid-template-columns: minmax(0, 1fr); gap: var(--sp-md); }

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

  .erp-pagination { justify-content: center; }
  .modal-body, .modal-header, .modal-footer { padding: var(--sp-lg); }
  .notification-menu { width: calc(100vw - 32px); }
}

/* ---------------------------------------------------------------------
   576 — NARROW PHONE (Bootstrap sm)

   Three blocks used to live here: 680 for the block-grid cell, 560 for the
   topbar's padding and 430 for everything else. The 680 one is gone entirely --
   44px is now the base size for .cell at every width, which is what it should
   always have been -- and the other two are one block at Bootstrap's sm
   boundary. What that changes for the 431-575px band (a phone in a split view,
   an old 480px handset): KPI tiles go to one column, which at 543px of content
   is a FIX rather than a loss, because two 265px tiles cannot hold an
   18-character so'm figure at 24px; and the topbar loses 8px of padding and 8px
   of height. Nothing in the band gets narrower than it was.
   --------------------------------------------------------------------- */

@media screen and (max-width: 575.98px) {
  .topbar { height: 60px; padding: 0 var(--sp-md); gap: 6px; }
  .ai-assist-btn { width: 44px; height: 44px; padding: 0; justify-content: center; }
  .ai-assist-label { display: none; }
  .main-content > .container-fluid { padding: var(--sp-md) var(--sp-md) var(--sp-4xl); }
  .erp-card, .card { --card-pad: var(--sp-md); }
  .erp-card, .card, .stat-card { padding: var(--card-pad, var(--sp-md)); }
  /* NO .form-actions override here. The sticky bar's bleed and side padding are
     both tied to var(--card-pad) in the 992 block, so redeclaring --card-pad
     above is all that is needed to keep the bar flush with the card's gutter at
     this breakpoint -- which is the bug this block used to have, a 4px overhang
     through the card's rounded border on every form in the app. */
  .page-title { font-size: 20px; }
  .stat-value { font-size: 22px; }
  .hero-num { font-size: 32px; }
  .hero-num .cur, .hero-num .cents { font-size: 20px; }
  .cell { font-size: 13px; }
  .cell-grid { border-spacing: 2px; }
  /* One column again: "2 892 099 360 so'm" is 18 characters and will not fit
     171px at any legible size. Narrower is the wrong lever here.

     SHORTER is the right one. The label and the figure go side by side, so a
     KPI costs ~56px of height instead of ~110px -- four of them stop being a
     440px wall between the user and the data they opened the page for. */
  .stats-grid, .stats-grid.compact { grid-template-columns: minmax(0, 1fr); gap: var(--sp-sm); }
  .row > [class*="col-md-3"]:has(.mini-stat),
  .row > [class*="col-lg-3"]:has(.mini-stat),
  .row > [class*="col-md-4"]:has(.mini-stat) { flex: 0 0 100%; max-width: 100%; }

  .erp-card:has(> .mini-stat) { padding: var(--sp-md) var(--sp-lg); }
  .mini-stat {
    flex-direction: row; align-items: baseline;
    justify-content: space-between; gap: var(--sp-md);
    padding: 0;
  }
  .mini-stat > span { flex: none; }
  .mini-stat > strong { font-size: 16px; text-align: right; }

  /* Label left, figure right -- but ONLY for the two-slot summary card.
     :not(:has(.kpi-spark)) is load-bearing: the dashboard's KPI has four
     slots (kpi-top, kpi-value, kpi-meta, kpi-spark) and this grid auto-placed
     them into a 2x2, which put the figure in a 64px column on the right, the
     note back on the left and the sparkline squeezed to 76px in the corner.
     The emphasis card is excluded for the same reason it always was: it is
     the headline and keeps its stacked layout. */
  .stat-card:not(.is-emphasis):not(:has(.kpi-spark)) {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: baseline;
    column-gap: var(--sp-md);
    padding: var(--sp-md) var(--sp-lg);
  }
  .stat-card:not(.is-emphasis):not(:has(.kpi-spark)) .stat-label { grid-column: 1; margin: 0; }
  .stat-card:not(.is-emphasis):not(:has(.kpi-spark)) .stat-value { grid-column: 2; grid-row: 1; font-size: 17px; text-align: right; }
  .stat-card:not(.is-emphasis):not(:has(.kpi-spark)) .stat-meta { grid-column: 1 / -1; margin-top: 2px; }

  /* The four-slot KPI keeps its stack, just tighter: the 188px desktop floor
     leaves a void once the card is 366px wide instead of 264. */
  .stat-card:has(.kpi-spark), .kpi:has(.kpi-spark) {
    min-height: 0;
    padding: var(--sp-lg) var(--sp-lg) var(--sp-md);
    gap: 10px;
  }
  .stat-card:has(.kpi-spark) .kpi-spark { height: 34px; margin: 4px -6px -2px; }
  .stat-card:has(.kpi-spark) .kpi-spark canvas { height: 34px; }
}

/* REDUCED MOTION, STATED ONCE INSTEAD OF PER COMPONENT.
   This block used to name nine selectors, and a transition is added to a
   component every time one is written: .sidebar-chevron's rotate, .sidebar-link
   i's colour, .seg's ground, the file-picker button, .form-check-input and
   .photo-drop were all outside the list, and so was every vendor transition the
   five third-party sheets ship. A user who has asked their OS to stop animation
   has asked once, for everything; an allow-list is a promise this file cannot
   keep. The universal selector is the only form that survives the next
   component.
   Duration rather than `transition: none`, and delay zeroed with it, because the
   drawer's `transition: transform .24s, visibility 0s linear .24s` hides itself
   with a DELAY -- kill the duration and leave the delay and the panel would stay
   visible for a quarter of a second after it had finished not-moving.
   .01ms rather than 0s so transitionend still fires: nothing in static/js/app.js
   waits on one today, but a zeroed transition silently drops the event and that
   is a trap for whoever adds the first listener. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    transition-delay: 0s !important;
  }
  html { scroll-behavior: auto !important; }
  /* The one exception, and it is an exception because here the motion IS the
     message: app.js swaps a submit button's label for this spinner plus
     "Saqlanmoqda..." and it is the only thing saying the upload is still going
     on a bad site connection. Slowed to two seconds rather than stopped -- a
     frozen spinner reads as a crashed page, which is the failure this whole
     indicator exists to prevent. */
  .spinner-border, .spinner-grow {
    animation-duration: 2s !important;
    animation-iteration-count: infinite !important;
  }
}

/* =====================================================================
   Print — a report handed across a desk
   ===================================================================== */

@media print {
  /* THE PAYSLIP CAME OUT OF THE PRINTER BLANK, and nothing said so.
     A media query adds NO specificity, so `:root` here is (0,1,0) while the dark
     palette is declared on `:root[data-theme="dark"]` = (0,2,0). The dark tokens
     therefore WON inside @media print, and the sheet below then forces
     `body { background: #fff !important }`: --ink #F3F3ED on #FFFFFF paper is
     1.06:1. Every figure on the payslip, the cheque and every report printed as
     white-on-white -- right layout, right page count, no numbers -- and dark is
     the default for anyone whose OS is in dark mode, which base.html resolves
     before first paint. The accountant reprints it and blames the toner.
     Fixed by matching the dark selector's specificity so the reset wins in both
     themes, and by restating EVERY token the printed sheets read rather than the
     five that were here: the payslip's rules are --line, its totals rule and its
     signature lines are --ink, its captions --muted, and the report tables use
     --surface-3, --pos, --neg and --warn. Paper values, not screen values:
     #000 on #fff is 21:1, #333 is 12.63:1, #555 is 7.46:1, and the three
     direction colours are darkened to 8.0-8.7:1 because ink on paper cannot
     borrow a soft background the way the screen badges do. */
  :root, :root[data-theme="dark"] {
    color-scheme: light;
    --ground: #fff; --surface: #fff; --surface-2: #fff; --surface-3: #f2f2f2;
    --ink: #000; --ink-2: #222; --muted: #333; --faint: #555;
    --line: #999; --line-strong: #666; --control-line: #666;
    --emph-bg: #fff; --emph-ink: #000; --emph-muted: #333; --emph-accent: #000;
    --emph-track: #ddd;
    --pos: #1a5c30; --neg: #8c2718; --warn: #6a4408;
    --pos-soft: #fff; --neg-soft: #fff; --warn-soft: #fff;
    --accent-soft: #fff; --accent-label: #333; --accent-ink: #000;
    --shadow: none; --shadow-pop: none;
  }
  /* The single inverted KPI card per screen is `background: var(--emph-bg)` with
     `border-color: var(--emph-bg)`, which in dark theme is LIME -- so even with
     the tokens fixed the card had to be told to stop being a solid block on
     paper, where a filled tile costs toner and buys nothing. */
  .erp-card.is-emphasis, .stat-card.is-emphasis, .kpi.is-emphasis {
    background: #fff !important; color: #000 !important; border-color: #999 !important;
  }
  .is-emphasis .mlabel, .is-emphasis .stat-label,
  .is-emphasis .hero-num, .is-emphasis .stat-value { color: #000 !important; }
  .is-emphasis .stat-meta, .is-emphasis .kpi-note { color: #333 !important; }
  /* A badge is a coloured GROUND with text on it, and Chrome and Safari print
     with background graphics OFF by default: the ground is dropped and the text
     kept. .badge.bg-primary is `color: var(--surface) !important` on
     `background-color: var(--ink) !important` -- white text, no ground, i.e. a
     blank space where "Tugatilgan" should be on the project report. On paper
     every badge becomes an outlined chip instead, and the per-state SHAPE added
     above is what still separates the six states once the hue is gone.
     Enumerated rather than written as a plain `.badge`, because the screen rules
     are `.badge.bg-success { ... !important }` at (0,2,0): two !important
     declarations are decided by specificity, so a (0,1,0) `.badge` here would
     have lost to every one of them and this rule would have done nothing.
     border-COLOR, not the border shorthand, so the 1px the base rule already
     reserves is re-coloured rather than re-declared and no chip changes size. */
  .badge.bg-success, .badge.bg-danger, .badge.bg-warning, .badge.bg-info,
  .badge.bg-primary, .badge.bg-secondary, .badge.bg-light {
    background-color: #fff !important; color: #000 !important;
    border-color: #666 !important;
  }
  .sidebar, .sidebar-backdrop, .topbar, .page-actions,
  .erp-pagination, .no-print, .form-actions, .crumbs,
  .fbar-panel, .fbar-active, .table-actions { display: none !important; }
  /* Grid/flex shells and clipped viewports interfere with page fragmentation. */
  html, body { overflow: visible !important; }
  .app-shell, .app-main, .main-content { display: block !important; }
  .app-shell { grid-template-columns: minmax(0, 1fr) !important; }
  .app-main { grid-column: 1 !important; }
  .main-content > .container-fluid { padding: 0 !important; }
  /* 11px stays, and is the ONE size in this file below the screen scale's
     floor. Paper is a different medium: it is read at 100% with no viewport to
     zoom, a 96dpi 11px renders at about 8pt, and the sheets that print here are
     the wide ones -- the financial report and the ish-haqi ledger, ten columns
     of figures that have to land inside A4. Raising this is what pushes a
     column off the page, which costs the reader the whole number rather than a
     point of size. The cheque and the payslip, which ARE read closely, set
     their own pt sizes below. */
  body { background: #fff !important; font-size: 11px; }
  .erp-card, .card, .stat-card {
    box-shadow: none !important;
    border: 1px solid #999 !important;
    break-inside: avoid; page-break-inside: avoid;
    padding: var(--sp-md) !important;
  }
  /* Paper has no scrollport and no pointer. The wrapper's height cap and the
     frozen first column are both screen devices, and left in place the cap would
     CLIP a 25-row ledger at the first page. max-height is already screen-scoped
     up the file; restated here because a clipped printed ledger is not a defect
     anyone would notice until the sheet was already across a desk. */
  .erp-card:has(table), .card:has(table) {
    break-inside: auto; page-break-inside: auto;
  }
  .table-responsive { max-height: none !important; overflow: visible !important; }
  .erp-table { width: 100% !important; min-width: 0 !important; table-layout: auto; }
  .erp-table thead { display: table-header-group; }
  /* Totals belong after the final row, not repeated at the foot of every page. */
  .erp-table tfoot { display: table-row-group; }
  .erp-table th, .erp-table td {
    white-space: normal !important; overflow-wrap: anywhere;
    max-width: none !important; overflow: visible !important;
  }
  .erp-table td > * { max-width: none; overflow: visible !important; text-overflow: clip; }
  .erp-table thead th, .erp-table tbody td:first-child,
  .erp-table tfoot th:first-child, .erp-table tfoot td:first-child { position: static; }
  .erp-table thead th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* The zebra tint is a screen aid for a 1630px row; on A4 it is a grey wash
     that most office printers render as mud behind the figures. */
  .erp-table tbody tr, .erp-table tbody tr:nth-child(even) { background: #fff !important; }
  .erp-table tbody td { height: auto; padding: 4px 6px; }
  .erp-table tr { break-inside: avoid; page-break-inside: avoid; }
  a[href]::after { content: "" !important; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important; }
}

/* =====================================================================
   Screen-specific components

   Everything here is a surface the templates name that has no equivalent in
   the reference: the login shell, error pages, the payslip and cheque, the
   bulk-payroll grid, and the filter panel app.js builds at runtime. They
   reuse the primitives above rather than introducing new geometry.
   ===================================================================== */

/* ---- filter panel, built by app.js so it has no markup to style ---- */
/* The card keeps its own padding until app.js wraps it; only the wrapped
   state hands padding over to the toggle and the panel. Zeroing it
   unconditionally left the fields flush against the card edge on every page
   where the wrap did not happen. */
.erp-card.has-filter-toggle { padding: 8px; }
.filter-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; height: 44px; padding: 0 12px;
  border: 0; border-radius: var(--r);
  background: transparent; color: var(--ink);
  font-size: var(--fs-body); font-weight: 600;
}
.filter-toggle:hover { background: var(--hover); }
.filter-toggle[aria-expanded="true"] { background: var(--surface-3); }
.filter-count {
  /* matches .nav-count; these are one component */
  min-width: 22px; height: 22px; padding: 0 7px;
  display: inline-grid; place-items: center;
  border-radius: var(--r);
  background: var(--accent); color: var(--accent-ink);
  font-size: var(--fs-micro); font-weight: 700;
}
.filter-panel { padding: 12px 12px 4px; }
.filter-panel[hidden] { display: none; }

/* ---- guest shell: login and password screens ---- */
.guest-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--ground); }
.guest-card {
  width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow); padding: 32px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.guest-lede { font-size: var(--fs-body); color: var(--muted); margin-bottom: 22px; line-height: 1.55; }
.guest-footnote { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); font-size: var(--fs-meta); color: var(--muted); }

/* ---- error pages ---- */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--ground); }
.error-shell { width: 100%; max-width: 560px; }
.error-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
  padding: 48px 32px; text-align: center;
}
.error-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 22px; }

/* ---- dashboard chart cards ---- */
.dashboard-chart-card { display: flex; flex-direction: column; }
.dashboard-chart-wrap { position: relative; flex: 1; min-height: 210px; }
.dashboard-chart-wrap-line { height: 300px; }
.dashboard-chart-wrap-donut { height: 300px; }
.chart-empty { display: grid; place-items: center; min-height: 200px; color: var(--muted); font-size: var(--fs-body); text-align: center; }

/* ---- record cards ---- */
.project-card, .resource-card, .worker-card, .profile-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow); padding: 20px;
}
.project-code { font-size: var(--fs-micro); font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.resource-icon, .worker-avatar {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r);
  background: var(--surface-3); color: var(--ink-2);
  font-size: 13px; font-weight: 650; overflow: hidden;
}
.worker-avatar img { width: 100%; height: 100%; object-fit: cover; }
.search-summary { font-size: var(--fs-body); color: var(--muted); }
.ledger { display: flex; flex-direction: column; gap: 8px; }
.confirm-facts { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 20px; }
.setup-box { background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: var(--r); padding: 16px 20px; }
.currency-note { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px; font-size: var(--fs-meta); color: var(--muted); }
/* 1.5em, not 17px. This box is empty until ERPMoney fills it, and the whole
   point of the height is that the form does not JUMP when it does -- so the
   reservation has to track the text size, which it now no longer does on its
   own: at the scale's body step the filled line is 20px and on a phone 22px. */
.money-preview { min-height: 1.5em; }
.done-mark { color: var(--pos); }

/* ---- reports hub ---- */
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.report-link { display: block; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.report-link:hover { border-color: var(--line-strong); background: var(--surface-2); text-decoration: none; }

/* ---- area calculator ---- */
.shape-preview { display: grid; place-items: center; padding: 16px; background: var(--surface-2); border-radius: var(--r); }
.shape-box { width: 110px; height: 78px; border: 2px solid var(--ink); border-radius: var(--r-xs); }

/* ---- payroll: payslip, cheque, bulk grid ---- */
.payslip, .cheque-sheet { max-width: 820px; }
.payslip-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.payslip-table { width: 100%; }
.payslip-table td { padding: 9px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-body); }
.payslip-table .subtotal td { font-weight: 600; }
.payslip-table .total td, .cheque-total-row td {
  border-top: 2px solid var(--ink); border-bottom: 0;
  font-weight: 700; font-size: var(--fs-lead); padding-top: 12px;
}
.payslip-sign, .cheque-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-top: 32px; }
.payslip-sign div, .cheque-sign-line { border-top: 1px solid var(--ink); padding-top: 5px; font-size: var(--fs-meta); color: var(--muted); }
.salary-select { max-width: 320px; }
.attendance-status { min-width: 132px; }
.attendance-hours { max-width: 84px; }

/* ---- a card's standing explanation, folded ------------------------------- */

/* Policy prose that every card on a detail page used to open with. It is right
   for the first read and dead space for every read after, so it folds: the
   question stays visible as a question, the answer is one tap away. A <details>
   rather than a hover tooltip because the people who most need it are on a
   phone, which has no hover. */
.card-note { margin: 0 0 var(--sp-md); }

/* A small outline button (.btn-sm .btn-outline-secondary in the template), so the
   question reads as something to press, not as a caption. */
.card-note > summary { list-style: none; user-select: none; cursor: pointer; gap: 7px; }
.card-note > summary::-webkit-details-marker { display: none; }
.card-note[open] > summary { background: var(--surface-3); }

.card-note > p {
  margin: var(--sp-sm) 0 0;
  max-width: 68ch;
  font-size: var(--fs-meta);
  line-height: 1.55;
  color: var(--ink-2);
}

/* ===========================================================================
   TOOL LOAN DETAIL
   =========================================================================== */

/* ---- the loan at a glance ------------------------------------------------- */

/* A strip under the title, not a column down the side. As a col-lg-4 card it
   printed seven facts at equal weight, took a third of the width from the tools,
   history and debts, and left a dead block below itself as tall as everything it
   squeezed. The due date -- the fact a loan is opened for -- was fifth of seven. */
.summary-strip, .loan-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-lg) var(--sp-3xl);
}

.summary-strip-lead, .loan-summary-lead {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-sm) var(--sp-md);
}

.summary-due, .loan-due { margin: 0; font-size: var(--fs-body); color: var(--ink-2); }
.loan-due strong {
  color: var(--ink);
  font-size: var(--fs-lead);
  font-weight: 650;
  font-variant-numeric: tabular-nums lining-nums;
}

/* Overdue says so in words as well as colour. */
.loan-due.is-overdue, .loan-due.is-overdue strong { color: var(--neg); }
.loan-due-flag {
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--neg-soft);
  color: var(--neg);
  font-size: var(--fs-meta);
  font-weight: 600;
}

/* Reference facts at reading size, label above value -- not uppercase
   micro-labels stacked down a column. */
.fact-list, .loan-facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-md) var(--sp-2xl);
  margin: 0;
}
.fact-list > div, .loan-facts > div { min-width: 0; }
.fact-list dt, .loan-facts dt {
  font-size: var(--fs-meta);
  font-weight: 400;
  color: var(--muted);
}
.fact-list dd, .loan-facts dd { margin: 0; font-size: var(--fs-body); color: var(--ink); }

.loan-notes {
  flex: 1 1 100%;
  margin: 0;
  padding-top: var(--sp-md);
  border-top: 1px solid var(--line);
  font-size: var(--fs-body);
  color: var(--ink-2);
}

/* One column for everything below, so the history and debt tables get the full
   width and fit without scrolling. */
.loan-body { display: flex; flex-direction: column; gap: var(--sp-2xl); }
.loan-body > .erp-card { margin-bottom: 0 !important; }

.empty-line, .loan-empty-line {
  margin: 0;
  padding: var(--sp-md) 0 var(--sp-xs);
  font-size: var(--fs-body);
  color: var(--muted);
}

/* Generic names for the loan-page rules above that had none, so any detail page
   can lead with its key date or figure -- and say in words when it is late --
   without borrowing the loan's class names. Standalone rules on purpose: the
   loan selectors are left exactly as they are. */
.summary-due strong {
  color: var(--ink);
  font-size: var(--fs-lead);
  font-weight: 650;
  font-variant-numeric: tabular-nums lining-nums;
}
.summary-due.is-overdue, .summary-due.is-overdue strong { color: var(--neg); }
.summary-due-flag {
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--neg-soft);
  color: var(--neg);
  font-size: var(--fs-meta);
  font-weight: 600;
}
.summary-notes {
  flex: 1 1 100%;
  margin: 0;
  padding-top: var(--sp-md);
  border-top: 1px solid var(--line);
  font-size: var(--fs-body);
  color: var(--ink-2);
}
.detail-body { display: flex; flex-direction: column; gap: var(--sp-2xl); }
.detail-body > .erp-card { margin-bottom: 0 !important; }

/* A second, quieter line inside a table cell -- a project over its category, a
   name over its role -- so two related columns can share one and a ledger fits
   its card instead of scrolling. --muted is the secondary-text floor. */
/* ---- compact filter bar (app.js initFilterBars; the owner's design 3) ----
   One row -- search, "Filtr (N)", the active-filter summary, the page's
   shortcuts -- and a panel that opens OVER the content below it on a desktop
   instead of pushing the list down. The filter card used to be 200-300px tall
   on every list. */
form.fbar { position: relative; }
.fbar-row { display: flex; align-items: center; gap: var(--sp-sm); flex-wrap: wrap; }
.fbar-search { flex: 0 1 340px; min-width: 200px; }
.fbar-search .form-control { width: 100%; }
.fbar-toggle { gap: 8px; }
.fbar-toggle[aria-expanded="true"] { background: var(--surface-3); border-color: var(--ink-2); }
.fbar-count {
  min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: var(--emph-bg); color: var(--emph-accent);
  font-size: var(--fs-micro); font-weight: 700; font-variant-numeric: tabular-nums;
}
.fbar-actions { display: flex; flex-wrap: wrap; gap: var(--sp-sm); margin-left: auto; }
.fbar-panel {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 35;
  width: min(900px, 100%);
  padding: var(--sp-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: 0 18px 40px -14px rgba(16, 16, 12, .30);
}
:root[data-theme="dark"] .fbar-panel { box-shadow: 0 18px 44px -12px rgba(0, 0, 0, .65); }
.fbar-panel[hidden] { display: none; }
/* In the page header (where app.js puts it when the page has one): the bar
   sits beside the page's own buttons and the panel drops from the right
   edge, under them. The card the form came from is hidden. */
.fbar-source { display: none !important; }
.fbar-host { position: relative; }
/* Sized so a full set -- search, Filtr, two shortcuts, the primary button --
   fits beside the title on a 1366px laptop (1042px of content). The title
   block may shrink to 240px and wrap its subtitle instead of pushing the
   buttons onto a line of their own. */
.page-actions .fbar-search { flex: 0 1 220px; min-width: 140px; }
/* ONE LINE, always, from tablet width up: beside the title when the set fits,
   otherwise the whole set drops under the title as a single row. Wrapping
   inside the block left "+ Yangi resurs" alone on a second line in a window
   under 1200px. Spaced with margins, not gap: a margin counts toward the
   block's width the same way in every engine, where Safari has sized
   flex-gap boxes short. The search may shrink if the row is still too wide. */
@media screen and (min-width: 768px) {
  .fbar-host > .page-actions { flex-wrap: nowrap; column-gap: 0; flex: 0 1 auto; min-width: 0; max-width: 100%; }
  .fbar-host > .page-actions > * + * { margin-left: 10px; }
}
.fbar-host > .page-header-main, .fbar-host > .page-header { flex: 1 1 240px; min-width: 0; }
/* A view switch (Jadval / Kartalar) marks the current view without the lime
   accent, which belongs to the page's one primary action. */
.btn.btn-outline-secondary[aria-current="true"] { background: var(--surface-3); border-color: var(--ink-2); color: var(--ink); }
.fbar-host > .fbar-panel { left: auto; right: 0; }
.fbar-seg button { height: 34px; }
/* "Amaldagi filtr: ..." -- one quiet line, only while a filter is on. */
.fbar-active { margin: calc(var(--sp-lg) * -1) 0 0; font-size: var(--fs-meta); color: var(--muted); }
.fbar-active strong { color: var(--ink-2); font-weight: 600; }
.fbar-active a { margin-left: var(--sp-sm); color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
/* The fields keep their template columns' markup; inside the panel they share
   an even grid instead of the 2/3/4-of-12 widths they had across the card. */
.fbar-panel > .row > * { flex: 0 0 auto; width: 33.3333%; }
.fbar-panel .form-label { display: block; }
/* flatpickr's static wrapper is inline-block, which set a date field's label
   and its box side by side, the box at its 150px intrinsic width. */
.fbar-panel .flatpickr-wrapper { display: block; width: 100%; }
.fbar-panel .flatpickr-wrapper > .form-control, .fbar-panel input.form-control { width: 100%; }
.fbar-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--sp-md); }
.fbar-preset {
  height: 34px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 12px;
  background: transparent; color: var(--ink-2);
  font-size: var(--fs-meta); font-weight: 600; cursor: pointer;
}
.fbar-preset:hover { background: var(--hover); }
.fbar-preset[aria-pressed="true"] { background: var(--emph-bg); border-color: var(--emph-bg); color: var(--emph-ink); }
.fbar-foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-sm);
  margin-top: var(--sp-lg); padding-top: var(--sp-md);
  border-top: 1px solid var(--line);
}
.fbar-spacer { flex: 1; }
@media screen and (max-width: 991.98px) {
  .fbar-panel > .row > * { width: 50%; }
  .fbar-preset { height: 44px; }
}
/* A phone has no room to float a panel over: it opens in the card, under the
   bar, one field per line. */
@media screen and (max-width: 767.98px) {
  .fbar-search { flex: 1 1 100%; }
  .fbar-host > .page-actions { width: 100%; }
  /* Search (or the period switch) and Filtr share the first row on a phone --
     a row saved on every list -- and the page's buttons wrap under them,
     sharing their rows. The 150px is Filtr with its count plus the gap, so
     nothing else fits on that first row. */
  .page-actions > .fbar-search,
  .page-actions > .fbar-seg { flex: 1 1 calc(100% - 150px); min-width: 0; }
  .page-actions > .fbar-toggle { flex: 0 0 auto; }
  .fbar-host > .page-actions > .btn:not(.fbar-toggle) { flex: 1 1 auto; justify-content: center; }
  .fbar-host > .fbar-panel { flex: 1 1 100%; margin-top: 0; }
  .fbar-seg button { flex: 1 1 0; height: 44px; justify-content: center; padding: 0 6px; }
  .fbar-toggle { flex: 1 1 auto; justify-content: center; }
  .fbar-panel { position: static; width: auto; margin-top: var(--sp-md); padding: var(--sp-md); box-shadow: none; }
  .fbar-panel > .row > * { width: 100%; }
  .fbar-foot .btn { flex: 1 1 auto; justify-content: center; }
  .fbar-presets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .fbar-preset { padding: 0 2px; white-space: nowrap; }
  .fbar-spacer { display: none; }
}

/* components/filter_actions.html: one pair, side by side, wrapping on a phone. */
.filter-actions { display: flex; flex-wrap: wrap; gap: var(--sp-sm); align-items: center; }

.erp-table .cell-sub {
  display: block;
  margin-top: 2px;
  font-size: var(--fs-meta);
  color: var(--muted);
  white-space: normal;
}
/* An actions column takes what its buttons need, and its header sits over them. */
.erp-table th.actions-cell, .erp-table td.actions-cell { width: 1%; white-space: nowrap; }
.erp-table th.actions-cell { text-align: right; }

/* ---- the tools, as a table ----------------------------------------------- */

/* A table again, now that the card is full width: the figures line up in columns
   so tools compare at a glance, and the actions have a column of their own. The
   numbers are right-aligned and tabular so a column of quantities reads as one. */
.loan-table td.mono, .loan-table th.text-end { font-variant-numeric: tabular-nums lining-nums; }
.loan-table .is-lost { color: var(--neg); }
.loan-outstanding strong { color: var(--ink); font-weight: 650; }
.loan-line-name { font-weight: 600; color: var(--ink); text-decoration: none; }
.loan-line-name:hover { text-decoration: underline; }
.loan-line-unitprice { font-size: var(--fs-meta); color: var(--muted); white-space: nowrap; }
.loan-row.is-settled td { color: var(--muted); }

/* The actions: three real buttons on ONE line. The column shrinks to exactly what
   they need (width:1% + nowrap is the table idiom for "fit content") and the data
   columns, which have the slack, give it up -- auto layout otherwise split the
   width evenly and wrapped "Yo'qoldi" onto a second line. */
.loan-actions-cell { width: 1%; white-space: nowrap; }
/* Headers wrap, figures do not. "TAXMINIY JAVOBGARLIK" and "BRIGADADA QOLGAN" are
   twice as wide as the values under them, and as nowrap uppercase they were what
   pushed the action column off the card's right edge. Two lines of header cost
   nothing; a clipped button costs the action. */
/* (0,2,2): .erp-table th.text-end is (0,2,1) and sets nowrap, so a plainer
   selector here lost on exactly the right-aligned headers that needed it. */
.erp-table.loan-table thead th { white-space: normal; vertical-align: bottom; line-height: 1.3; }
.loan-actions { display: flex; flex-wrap: nowrap; gap: var(--sp-sm); align-items: center; }
.loan-actions form { margin: 0; }
.loan-line-return { white-space: nowrap; }
/* Below 1440px six data columns and three buttons do not share a 970px card on
   one line -- measured at 1280, the third button ran off the edge. The actions
   stack in their column instead, same width, primary on top: a taller row is a
   fair price; a button you cannot see is not. */
@media screen and (min-width: 1200px) and (max-width: 1439.98px) {
  .loan-actions { flex-direction: column; align-items: stretch; }
  .loan-actions .btn { width: 100%; }
}

/* An open door looks pressed, so the reader can see which form below is its. */
.loan-door[aria-expanded="true"] { background: var(--surface-3); }
.loan-door.btn-outline-danger[aria-expanded="true"] { background: var(--neg-soft); }

/* ---- the exception forms: full-width rows, never inside a cell ----------- */

/* A form inside a cell makes the whole row as tall as the form -- what broke this
   table before. Each form is its own row under its tool, with no zebra stripe and
   no row hover, so it reads as belonging to the row above rather than as data. */
.loan-table tr.loan-forms > td {
  padding: var(--sp-sm) var(--sp-lg) var(--sp-lg) !important;
  background: transparent !important;
  border-top: 0;
}
.loan-table tbody tr.loan-forms:hover > td { background: transparent !important; }

/* The form is a tinted well sized to its content: label above, then field and
   button on one line, so it reads as a sentence. */
.loan-more-body {
  max-width: 520px;
  padding: var(--sp-lg);
  border-radius: var(--r);
  background: var(--surface-2);
}
.loan-forms.is-danger .loan-more-body { background: var(--neg-soft); }

.loan-more-body form {
  display: grid;
  grid-template-columns: minmax(0, 220px) auto;
  justify-content: start;
  align-items: end;
  gap: var(--sp-sm) var(--sp-md);
}
.loan-more-body .form-label {
  grid-column: 1 / -1;
  margin: 0;
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--ink);
}
.loan-field-max { margin-left: 6px; color: var(--muted); font-weight: 400; font-size: var(--fs-meta); }
.loan-more-body .input-group { grid-column: 1; }
.loan-field-submit { grid-column: 2; white-space: nowrap; }

/* The write-off reads top to bottom in the order it is decided: how many, why,
   what it will do, then the button that commits it. */
.loan-forms.is-danger .loan-more-body form { grid-template-columns: minmax(0, 380px); }
.loan-forms.is-danger .loan-more-body form > * { grid-column: 1; }
.loan-forms.is-danger .loan-field-submit { justify-self: start; }
.loan-writeoff-note {
  margin: 0;
  font-size: var(--fs-meta);
  line-height: 1.45;
  color: var(--neg);
}

/* Filled, not outlined: app.css styles .btn-danger and .btn-outline-danger
   identically, so the destructive submit needs its own fill. Dark ink on the
   light dark-theme red (8.00:1), white on the dark light-theme red (6.13:1). */
.loan-forms.is-danger .loan-field-submit { background: var(--neg); border-color: var(--neg); color: #fff; }
:root[data-theme="dark"] .loan-forms.is-danger .loan-field-submit { color: var(--accent-ink); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .loan-forms.is-danger .loan-field-submit { color: var(--accent-ink); }
}
.loan-forms.is-danger .loan-field-submit:hover { filter: brightness(1.08); }

/* ---- restacked into cards (below 1200px) --------------------------------- */
@media screen and (max-width: 1199.98px) {
  /* Label left, figure right, ONE line. The shared card rule gives every .text-end
     cell a whole row to itself, which suits one long money figure and wastes five
     lines here on "1 dona", "0 dona", "0 dona"... -- doubling the card's height. */
  /* Quantities only -- the liability cell holds two lines and keeps the stacked
     layout. Same shape as the shared rule plus .loan-table: (0,6,2) over (0,5,2). */
  .erp-table.loan-table.as-cards tbody td.loan-qty:not(.is-title):not(.is-actions) {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    text-align: right;
  }
  /* The actions become one full-width set at the foot of the tool's card. */
  .loan-table.as-cards td.loan-actions-cell { display: block; width: auto; white-space: normal; }
  .loan-table.as-cards td.loan-actions-cell::before { display: none; }
  .loan-table.as-cards .loan-actions { flex-direction: column; align-items: stretch; }
  .loan-table.as-cards .loan-actions .btn { width: 100%; }
  /* A form row joins its tool's card instead of standing as a card of its own. */
  .loan-table.as-cards tr.loan-forms {
    margin-top: calc(var(--sp-md) * -1);
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-top: 0;
    box-shadow: none;
  }
  .loan-table.as-cards tr.loan-forms > td { display: block; padding: 0 !important; }
  .loan-table.as-cards tr.loan-forms > td::before { display: none; }
  .loan-more-body { max-width: none; }
}

/* ---- phone ---------------------------------------------------------------- */
@media screen and (max-width: 575.98px) {
  .summary-strip, .loan-summary { gap: var(--sp-md); }
  .fact-list, .loan-facts { gap: var(--sp-sm) var(--sp-xl); }
  .loan-more-body form,
  .loan-forms.is-danger .loan-more-body form { grid-template-columns: minmax(0, 1fr); }
  .loan-more-body form > * { grid-column: 1 !important; }
  .loan-field-submit { width: 100%; }
}

/* THE TABEL ON A PHONE. Scoped with :has(.attendance-status) rather than a class
   in the template, because this shape is wanted for exactly one table and adding
   a modifier would invite it being copied onto tables that do not want it.

   Two things were wrong once the card layout stacked the fields. The hours box
   kept the 84px cap above -- right in a desktop row where it sits beside its
   neighbours, and wrong in a card, where it left one field stranded narrow
   between two full-width ones and read as unfinished rather than deliberate.
   And every field on its own line ran a worker's card to ~550px, so a phone
   showed TWO workers of a crew that is usually twenty: the prorab scrolls the
   whole screen to mark one person, twenty times, standing on site.

   Holat and Soat pair on one line -- they are the two halves of one answer ("was
   he in, and for how long") and neither needs full width. That is one row back
   per worker, ~90px, which is the difference between two cards per screen and
   three. Izoh keeps its own line: it is free text and the only field here anyone
   types a sentence into. */
@media screen and (max-width: 991.98px) {
  .erp-table.as-cards:has(.attendance-status) tr {
    flex-flow: row wrap;
    column-gap: var(--sp-md);
  }

  /* Everything full width by default, so any cell this rule does not name keeps
     the behaviour it had. */
  .erp-table.as-cards:has(.attendance-status) td {
    flex: 1 1 100%;
    min-width: 0;
  }

  /* 56 + 32 = 88, so the pair fits with room to spare at the 320px floor. The
     sum, with the values actually in this file: 320 viewport - 24 container
     (--sp-md 12px a side) = 296 for the table, - 32 card padding (--sp-lg 16px a
     side) - 2 border = 262px of card interior. The bases are 146.7px and 83.8px,
     + the 12px column-gap = 242.5px, leaving ~19px that flex-grow shares out.
     Soat therefore lands at ~92px -- WIDER than the 84px cap it had on the
     desktop row it came from, not narrower -- and Holat at ~158px, which still
     shows "Belgilanmasin" at 16px. */
  .erp-table.as-cards:has(.attendance-status) td:has(> .attendance-status) {
    flex: 1 1 56%;
  }
  .erp-table.as-cards:has(.attendance-status) td:has(> .attendance-hours) {
    flex: 1 1 32%;
  }

  /* The cell is the width constraint now, so the desktop cap has to let go or
     the input sits narrow inside its own column. */
  .erp-table.as-cards:has(.attendance-status) .attendance-hours {
    max-width: none;
    width: 100%;
  }
}
.bulk-row td { vertical-align: middle; }
.bulk-include { width: 44px; }
.bulk-days, .bulk-hours { max-width: 84px; }
.bulk-bonus, .bulk-deduction { max-width: 132px; }
.bulk-net { font-weight: 650; font-variant-numeric: tabular-nums; }

/* A row whose record is switched off. Muted, not hidden -- the record is
   still there and still has to be findable. */
.erp-table tbody tr.row-inactive td { color: var(--muted); }
.erp-table tbody tr.row-inactive td:first-child { position: relative; }
.erp-table tbody tr.row-inactive .is-title { text-decoration: line-through; text-decoration-color: var(--line-strong); }

/* ---- print-only chrome ---- */
/* SCOPED to the store. `.toast-message` is two different things: the
   server-rendered data carrier inside #message-store (already hidden by its
   own .d-none at base.html:66) AND the element toastr builds for a live
   toast's body (messageClass:"toast-message"). toastr's own stylesheet sets
   only word-wrap on it, and app.css loads last, so an unscoped display:none
   here hid the body of every toast in the product -- each one rendered as
   the constant title "UK Asset" with no message under it. */
.print-only, .payslip-print-only { display: none; }
#message-store .toast-message { display: none; }
.print-header { margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--ink); }
.print-header h1 { font-size: 15pt; font-weight: 650; letter-spacing: -0.01em; margin: 0; }
.print-meta { margin-top: 5px; font-size: 9pt; color: var(--muted); }

/* =====================================================================
   Vendor layer

   Five third-party stylesheets ship into this page (select2, flatpickr,
   toastr, DataTables, and sweetalert2 which injects its own at runtime).
   Each arrives with its own palette, radius and control height: select2's
   closed control is 28px tall with a 4px radius and a #AAA border, against
   this system's 40px / 16px / --line-strong. Left alone they are the single
   loudest tell that the interface was assembled from parts, and in dark
   theme several of them render as pure-white boxes -- the brightest thing
   on the screen.

   Nothing here restyles a vendor's behaviour, only its surface, and every
   value comes from a token so both themes follow automatically.
   ===================================================================== */

/* ---- select2: make the closed control indistinguishable from an input -- */
/* --control-line throughout, for the same reason .form-control needed it: the
   point of this block is that the closed select2 box is indistinguishable from a
   native field, so it has to inherit the field's 3:1 boundary too, not the
   1.52:1 card hairline. */
.select2-container--default .select2-selection--single {
  height: 40px; font-size: var(--fs-body);
  background: var(--surface);
  border: 1px solid var(--control-line);
  border-radius: var(--r);
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 38px; padding-left: 14px; padding-right: 34px;
  color: var(--ink); font-size: var(--fs-body);
}
.select2-container--default .select2-selection--single .select2-selection__placeholder { color: var(--muted); }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 38px; right: 8px; }
/* A LOCKED Select2 is the same frozen-field case as .form-select:disabled above,
   and it had the same bug by another route: select2.min.css paints
   `.select2-container--disabled .select2-selection--single{background-color:#eee}`
   at (0,3,0), over the (0,2,0) --surface rule here, so in dark theme the worker a
   payslip pays rendered as near-white text on a light grey box. Same treatment as
   the native field: --ink-2 on --surface-3, the 3:1 edge kept. */
.select2-container--default.select2-container--disabled .select2-selection--single,
.select2-container--default.select2-container--disabled .select2-selection--multiple {
  background-color: var(--surface-3);
  border-color: var(--control-line);
  cursor: not-allowed;
}
.select2-container--default.select2-container--disabled .select2-selection__rendered { color: var(--ink-2); }
.select2-container--default .select2-selection--single .select2-selection__arrow b { border-top-color: var(--muted); }
.select2-container--default.select2-container--open .select2-selection--single { border-color: var(--ink); }
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default .select2-selection--single:focus {
  border-color: var(--ink); box-shadow: 0 0 0 3px var(--accent-soft);
}
.select2-container--default .select2-selection--multiple {
  min-height: 40px; background: var(--surface);
  border: 1px solid var(--control-line); border-radius: var(--r);
}
.select2-container--default .select2-selection--multiple .select2-selection__choice {
  background: var(--surface-3); border: 1px solid var(--line);
  border-radius: var(--r-xs); color: var(--ink); font-size: var(--fs-micro);
}
.select2-dropdown {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.select2-container--default .select2-search--dropdown .select2-search__field {
  height: 34px; padding: 0 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--control-line); border-radius: var(--r-xs);
  font-size: var(--fs-body);
}
.select2-container--default .select2-results__option {
  padding: 9px 14px; font-size: var(--fs-body); color: var(--ink);
}
.select2-container--default .select2-results__option--highlighted[aria-selected],
.select2-container--default .select2-results__option--highlighted {
  background: var(--hover); color: var(--ink);
}
.select2-container--default .select2-results__option[aria-selected="true"] {
  background: var(--ink); color: var(--surface);
}
/* The error border has to reach the control the user can actually SEE. Django
   writes aria-invalid on the <select>, select2 hides that select and builds its
   own DOM as the select's next sibling, so the widened .form-select rule up in
   Forms painted an invisible element. "Loyiha" is the field this matters for:
   it fails validation constantly and it has more than eight options, which is
   exactly the threshold at which initSelects() replaces it (app.js). */
select[aria-invalid="true"] + .select2-container .select2-selection--single,
select[aria-invalid="true"] + .select2-container .select2-selection--multiple {
  border-color: var(--neg);
  box-shadow: inset 0 0 0 1px var(--neg);
}

/* ---- flatpickr ------------------------------------------------------- */
/* flatpickr.min.css ships `.flatpickr-wrapper { display: inline-block }` and
   nothing here overrode it, so every date field in every ModelForm was a
   shrink-to-fit ~188px box (the input's default size=20) while the fields above
   and below it filled the 504px column -- the one control in the grid that did
   not line up. Scoped to .form-grid deliberately: the 36 hand-written date
   inputs in list filter bars sit in other layouts this must not disturb. It also
   shrinks the static calendar's overhang on a phone rather than widening it. */
.form-grid .flatpickr-wrapper { display: block; }
/* The exact twin of the select2 fix above, for the other wrapped widget. Django
   writes aria-invalid="true" on the date input; flatpickr then sets THAT input to
   type="hidden" and appends its visible replacement (class "form-control input")
   as the immediate next sibling inside .flatpickr-wrapper -- verified in the
   vendored 4.6.13: `l.appendChild(w.element), w.altInput && l.appendChild(
   w.altInput)`. So `.form-control[aria-invalid="true"]` up in Forms was painting
   an element that is not rendered, and AN INVALID DATE FIELD DID NOT TURN RED:
   the one control the user has to go back and fix was the only one not marked.
   The `input[type="hidden"]` half is what keeps the selector precise -- no other
   sibling pair in the product matches it, because hidden form fields are emitted
   before the first visible wrapper div. */
input[type="hidden"][aria-invalid="true"] + input.form-control {
  border-color: var(--neg);
  box-shadow: inset 0 0 0 1px var(--neg);
}
/* Same reason the plain controls needed their own pair: the invalid rule sits
   after :focus with equal specificity, so without this line focusing the flagged
   date field REPLACES its error ring with the focus ring and a keyboard user
   loses the error state. Must stay immediately after the rule above. */
input[type="hidden"][aria-invalid="true"] + input.form-control:focus {
  box-shadow: inset 0 0 0 1px var(--neg), 0 0 0 3px var(--accent-soft);
}
.flatpickr-calendar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-pop);
}
.flatpickr-calendar.arrowTop::before, .flatpickr-calendar.arrowTop::after,
.flatpickr-calendar.arrowBottom::before, .flatpickr-calendar.arrowBottom::after { display: none; }
.flatpickr-months, .flatpickr-month { background: var(--surface); color: var(--ink); fill: var(--ink); }
.flatpickr-current-month input.cur-year, .flatpickr-current-month .cur-month { color: var(--ink); font-weight: 600; }
.flatpickr-months .flatpickr-prev-month svg, .flatpickr-months .flatpickr-next-month svg { fill: var(--ink-2); }
.flatpickr-weekday { color: var(--muted); font-size: var(--fs-micro); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.flatpickr-day { color: var(--ink); border-radius: var(--r-xs); border-color: transparent; }
.flatpickr-day:hover { background: var(--hover); border-color: transparent; }
.flatpickr-day.today { border-color: var(--line-strong); }
.flatpickr-day.selected, .flatpickr-day.selected:hover,
.flatpickr-day.startRange, .flatpickr-day.endRange {
  background: var(--ink); border-color: var(--ink); color: var(--surface);
}
.flatpickr-day.inRange { background: var(--surface-3); border-color: var(--surface-3); box-shadow: none; }
/* --muted (5.3:1), not --faint (2.7:1): a disabled day still has to be legible
   enough to read the number you are not allowed to pick. */
.flatpickr-day.flatpickr-disabled, .flatpickr-day.prevMonthDay, .flatpickr-day.nextMonthDay { color: var(--muted); }

/* ---- toastr: four vendor hues replaced by the system's own ----------- */
#toast-container > div {
  opacity: 1;
  padding: 14px 18px 14px 46px;
  border-radius: var(--r);
  box-shadow: var(--shadow-pop);
  background-color: var(--emph-bg);
  color: var(--emph-ink);
  font-size: var(--fs-body);
  background-position: 16px center;
}
#toast-container > div:hover { box-shadow: var(--shadow-pop); opacity: 1; }
#toast-container > .toast-success { border-left: 3px solid var(--pos); }
#toast-container > .toast-error   { border-left: 3px solid var(--neg); }
#toast-container > .toast-warning { border-left: 3px solid var(--warn); }
#toast-container > .toast-info    { border-left: 3px solid var(--accent); }
#toast-container > div .toast-title { font-weight: 650; }
#toast-container > div .toast-message { color: var(--emph-muted); }
.toast-progress { background: var(--accent); opacity: .7; }

/* --emph-bg is LIME in the dark theme, and toastr ships near-white (#DBDBDB)
   PNG icons that assume a dark ground. White on lime measures 1.11:1 -- the
   icon was invisible -- and the level colours fared no better against it
   (--pos 1.50:1, --warn 1.54:1, --neg 1.88:1), so a toast in the dark theme
   carried NO working severity cue at all: not the icon, not the edge.
   A raised dark chip instead: the icon reads at 11.1:1 and every level colour
   between 6.5 and 8.2:1. The border is what separates it from the page, which
   the ground alone does not (1.22:1). */
:root[data-theme="dark"] #toast-container > div {
  background-color: var(--surface-3);
  color: var(--ink);
  border: 1px solid var(--line-strong);
}
:root[data-theme="dark"] #toast-container > div .toast-message { color: var(--ink-2); }

/* ---- DataTables ------------------------------------------------------ */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  height: 36px; padding: 0 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--control-line); border-radius: var(--r);
  font-size: var(--fs-body);
}
.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus {
  border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px var(--accent-soft);
}
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter { font-size: var(--fs-meta); color: var(--muted); }
table.dataTable thead th.sorting:after, table.dataTable thead th.sorting_asc:after,
table.dataTable thead th.sorting_desc:after { color: var(--muted); }

/* ---- sweetalert2 (injects its stylesheet at runtime) ----------------- */
.swal2-popup {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-pop);
  font-family: var(--font-sans);
}
.swal2-title { color: var(--ink); font-size: 19px; font-weight: 650; letter-spacing: -0.015em; }
.swal2-html-container { color: var(--muted); font-size: var(--fs-body); }
.swal2-actions { gap: 8px; }
.swal2-styled.swal2-confirm {
  background: var(--neg); color: var(--surface);
  border-radius: var(--r); height: 40px; padding: 0 18px;
  font-size: var(--fs-btn); font-weight: 600; box-shadow: none;
}
.swal2-styled.swal2-cancel {
  background: var(--surface); color: var(--ink-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r); height: 40px; padding: 0 18px;
  font-size: var(--fs-btn); font-weight: 600; box-shadow: none;
}
.swal2-styled:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; box-shadow: none; }

/* ---- the vendor layer on a touch screen -------------------------------
   Everything above is a desktop measurement, and the vendor DOM inherits
   nothing from .form-control -- so not one of this stylesheet's mobile rules
   ever reached it. select2 in particular is the control the prorab meets most
   (initSelects() mounts it on any select with more than eight options, which on
   his own pages is Bo'lim, Xodim and Lavozim): a 40px target against this
   file's own 44px floor, with a 13px search box that is focused the moment the
   dropdown opens, i.e. below the 16px at which iOS Safari zooms the page in and
   leaves it there.

   Stated HERE, after the vendor rules, and not in the 992px block up the file:
   an earlier @media rule loses to a later plain rule of the same specificity no
   matter how narrow the screen is, so the block up there would have been
   overwritten by the desktop values below it.

   991.98, not 767.98: every rule in this block is a 44px/16px touch sizing rule,
   so it belongs entirely on the finger side of the lg boundary. Until now, on a
   tablet the select2 box went back to 40px, the dataTables filter to 40px and
   the delete dialog's DESTRUCTIVE confirm button to 40px -- the single worst
   place in the product to miss by 4px. */
@media screen and (max-width: 991.98px) {
  .select2-container--default .select2-selection--single { height: 44px; }
  .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 42px; font-size: 16px;
  }
  .select2-container--default .select2-selection--single .select2-selection__arrow { height: 42px; }
  .select2-container--default .select2-selection--multiple { min-height: 44px; }
  .select2-container--default .select2-search--dropdown .select2-search__field {
    height: 44px; font-size: 16px;
  }
  /* An option in an open dropdown is a tap target like any other: 16px of text
     plus 12px of padding lands at 46px, above the floor. */
  .select2-container--default .select2-results__option { padding: 12px 14px; font-size: 16px; }
  .dataTables_wrapper .dataTables_filter input,
  .dataTables_wrapper .dataTables_length select { height: 44px; font-size: 16px; }
  /* The delete confirmation. Its two buttons were 40px, and one of them is
     destructive -- the single worst place in the product to miss by 4px. */
  .swal2-styled.swal2-confirm, .swal2-styled.swal2-cancel { height: 44px; }
}

/* ---------------------------------------------------------------- ish hisoboti
   Phone-first: the prorab is on scaffolding with one hand free, so the capture
   targets are full-width and tall rather than a 20px file input.

   Uses the app's own tokens (--line, --surface-2, --muted, --accent). The first
   version of this block invented --border-color / --surface-muted / --text-muted,
   none of which exist here, so every rule silently fell back to a hardcoded
   light grey -- which on the dark theme painted pale boxes onto a dark page. */

.photo-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-xs);
  width: 100%;
  min-height: 104px;
  padding: var(--sp-lg);
  /* This dashed edge is the entire affordance -- there is no other mark saying
     "tap here to add a photo" -- and --line-strong put it at 1.49:1 on
     --surface-2 light / 1.44:1 dark, i.e. a target that did not look like one.
     --control-line is 3.61:1 / 3.49:1 on that same ground. Colour only: the
     width stays 2px, so the 104px min-height and the 120px phone override are
     untouched. */
  border: 2px dashed var(--control-line);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  transition: border-color .15s ease, background .15s ease;
}

.photo-drop:hover { background: var(--hover); }

/* The file input now sits OUTSIDE its label (a label-wrapped input cannot be
   visually-hidden without taking the label's own hit area with it), so
   :focus-within no longer fires and a keyboard user would get no focus ring at
   all on the page's primary action. :has() styles the label from its sibling. */
/* --ink, not --accent-ink. --accent-ink is hardcoded #121212 in BOTH themes,
   and in dark --accent-soft is #282C10, so the pair measured 1.30:1: the drop
   zone went unreadable the instant a thumb landed on it. --ink is #F3F3ED in
   dark = 12.93:1 on the same wash, and in light --ink and --accent-ink are the
   same #121212, so light output is unchanged byte for byte (16.82:1). */
.photo-drop:has(~ input:focus-visible),
.photo-drop:active,
.photo-drop:focus-within {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--ink);
}

.photo-drop.is-primary {
  border-style: solid;
  border-color: var(--accent-line);
}

/* THE CONFIRMATION THAT THE PHOTOS ATTACHED. This is the state the prorab is
   left looking at outdoors after picking files, and in dark theme all four of
   the declarations below painted --accent-ink #121212 on --accent-soft #282C10 =
   1.30:1 -- so "Oldin"/"Keyin", the camera glyph and the "N ta rasm tanlandi"
   line that app.js writes into .photo-drop-hint were all invisible, and he could
   not tell WHICH of the two targets he had just filled. Same substitution
   throughout: --ink is 12.93:1 on that wash in dark and identical to
   --accent-ink in light, so nothing about the light theme moves. */
.photo-drop.has-files {
  border-style: solid;
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--ink);
}

.photo-drop i { font-size: 1.375rem; color: var(--muted); }
.photo-drop.has-files i { color: var(--ink); }
.photo-drop-title { font-weight: 600; }
/* HARDCODED rem, so it could not follow the type scale. The scale's own comment
   says --fs-micro is the FLOOR and nothing in this stylesheet goes below it, and
   the phone block raises that floor a step (12/13/14/15 -> 13/14/15/16) so the
   prorab outdoors gets one size up. A literal .75rem / .8125rem / .875rem cannot
   participate in either, so on a phone these five strings rendered 12-14px
   against a 13px floor and 15px body -- the caption that says which photo is
   Oldin ended up SMALLER than the prose beside it, on the product's single most
   important mobile path. Mapped to the step each one already equalled at the
   base size, so desktop output is unchanged to the pixel and only the phone
   moves, by 1px, inside containers whose height is auto. */
.photo-drop-hint { font-size: var(--fs-meta); color: var(--muted); }
.photo-drop.has-files .photo-drop-hint { color: var(--ink); }

.photo-preview {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-sm);
  margin-top: var(--sp-sm);
}

.photo-preview img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--r-xs);
  border: 1px solid var(--line);
}

.report-entry {
  padding: var(--sp-lg) 0;
  border-top: 1px solid var(--line);
}

.report-entry:last-child { padding-bottom: 0; }

.report-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--sp-sm);
  margin-top: var(--sp-sm);
}

.report-photo { margin: 0; }

.report-photo img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--r-xs);
  border: 1px solid var(--line);
  background: var(--surface-2);
}

/* `.is-before` is emitted by the template and had NO rule in either stylesheet
   -- a dead class. Colour only, never width: the img already carries
   `border: 1px solid var(--line)` and the reset makes it border-box, so a darker
   frame on the Oldin cells costs zero reflow in the 2-column phone grid, where a
   wider border would eat 2px of a 132px cell. */
.report-photo.is-before img { border-color: var(--ink-2); }

/* Once the ordering is fixed in the template the CAPTION is the only thing
   carrying Oldin against Keyin, and it was .75rem of grey -- 12px, the weakest
   text on the page, contradicting a pair the reader has already mis-read. A
   solid chip is legible at a glance in the 2-column phone grid. No layout risk:
   inline-block inside a figure with margin:0, in a grid cell whose height is set
   by the 4/3 image above it. */
.report-photo figcaption {
  display: inline-block;
  margin-top: var(--sp-xxs);
  padding: 1px 8px;
  border-radius: 9999px;
  background: var(--surface-3);
  color: var(--ink);
  font-size: var(--fs-micro);
  font-weight: 600;
}

/* The upload bar the prorab watches for the length of an upload, on a new
   markup hook (_work_reports.html, `.report-upload … data-report-progress`).
   .progress is 6px, which is right for a table sparkline and too thin outdoors
   in daylight on the one screen where the wait is measured in minutes. Scoped so
   nothing else moves; at 320px the card gives 272px of width and four extra
   pixels of height cannot overflow anything. */
.report-upload .progress { height: 10px; }

/* The tap-to-enlarge dialog on work_report_detail.html. sweetalert2 constrains
   the image's WIDTH to the popup and nothing else, so an untouched 3024x4032
   phone photo opens taller than the viewport and scrolls inside the dialog --
   which is the thing the enlargement existed to avoid. */
.swal2-image.ba-zoom-image {
  max-width: 92vw;
  max-height: 82vh;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* The deal reads as the multiplication it is, not three unrelated numbers. */
.deal-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--sp-sm);
  font-size: 1.0625rem;
}

.deal-op { color: var(--muted); }
.deal-total { font-size: 1.25rem; }

.deal-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-sm);
  padding: var(--sp-md) var(--sp-lg);
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}

.deal-preview strong { font-size: 1.125rem; }

@media screen and (max-width: 575.98px) {
  /* Two per row: a 150px min would drop these to one column and turn a
     six-photo report into six full-width scrolls. */
  .report-photos { grid-template-columns: repeat(2, 1fr); gap: var(--sp-xs); }

  .photo-drop { min-height: 120px; }

  /* The multiplication wraps rather than overflowing a 360px screen, and the
     total sits on its own line where it can be read. */
  .deal-line { font-size: 1rem; gap: var(--sp-xs); }
  .deal-total { flex-basis: 100%; font-size: 1.25rem; margin-top: var(--sp-xs); }

  .report-form .btn { width: 100%; }
}

/* ------------------------------------------------------ tasdiqlash markazi */

.inbox-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-md) 0;
  border-top: 1px solid var(--line);
}

.inbox-row:first-of-type { border-top: 0; }
.inbox-main { flex: 1 1 260px; min-width: 0; }
.inbox-title { font-weight: 600; }
.inbox-meta { font-size: var(--fs-meta); color: var(--muted); }

.inbox-actions {
  display: flex;
  gap: var(--sp-sm);
  flex-wrap: wrap;
}

.inbox-reports {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--sp-md);
}

.inbox-report {
  display: flex;
  gap: var(--sp-md);
  align-items: center;
  padding: var(--sp-sm);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: inherit;
  text-decoration: none;
}

.inbox-report:hover { background: var(--hover); }

.inbox-report-thumbs { display: flex; gap: 2px; flex: 0 0 auto; }

.inbox-report-thumbs img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: var(--r-xs);
  border: 1px solid var(--line);
}

.inbox-report-empty {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--r-xs);
  background: var(--surface-2);
  /* --faint is declared "decorative / non-text only" in the token block and it
     was being used for the GLYPH that says an approval row has no photo at all:
     2.81:1 light / 3.39:1 dark. --muted is 5.07:1 / 6.09:1 on --surface-2. */
  color: var(--muted);
}

.inbox-report-body { min-width: 0; }

/* ----------------------------------------------------------- oldin / keyin
   The pair is the unit. Side by side on a desktop with the arrow between them;
   stacked on a phone, where two 160px-wide photos would show nothing useful --
   the arrow rotates so the sequence still reads top-to-bottom. */

.ba-pair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-lg) 0;
  border-top: 1px solid var(--line);
  /* Capped at 1400px each side is (1400 - 24 gap - 18 arrow)/2 = 679px wide and
     509px tall at 4/3, so before, after and both captions sit inside the ~1300px
     viewport of a 2560x1440 office monitor instead of becoming a 12 400px mural.
     At 1280-1536px laptop widths the cap never engages -- the pair is already
     ~1500px of content at most -- so nothing changes there. */
  max-width: 1400px;
  margin-inline: auto;
}

.ba-pair:first-of-type { border-top: 0; padding-top: 0; }
.ba-side { margin: 0; min-width: 0; }

.ba-side img {
  width: 100%;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface-2);
  display: block;
  /* An UNCONSTRAINED phone photo. Before the container cap each pair cell was
     1513px wide at 3440px, so an untouched 3024x4032 camera file rendered
     1513 x 2017px -- taller than any screen in the device list -- and at 2560px
     it was 1073 x 1431px against ~1300px of viewport, so a single photo did not
     fit, let alone the pair the page is named for.
     contain, not cover: this is the uncropped review view a director approves a
     report from, and contain also fixes the mismatched heights that
     align-items:center produces when one side is portrait and the other
     landscape. .report-photo img already constrains this way -- the partial did
     and the page the owner asked for did not. */
  aspect-ratio: 4 / 3;
  object-fit: contain;
  max-height: 60vh;
}

.ba-side figcaption {
  font-size: var(--fs-meta);
  color: var(--muted);
  margin-top: var(--sp-xs);
  text-align: center;
}

/* THE LINE THAT SAYS A PHOTO WAS NEVER SENT, at 14px in a token the file itself
   marks "decorative / non-text only": #9B9B90 on --surface is 2.81:1 (2.68:1 on
   --surface-2; dark #6E6E64 on #1A1A17 is 3.39:1), where AA wants 4.5:1 and the
   3:1 large-text allowance does not reach 14px/400. Inside a dashed 4:3 box that
   otherwise reads as "still loading", so the director concludes the image failed
   to load rather than that the prorab never took it -- and approves work he has
   not seen. --muted is 5.30:1 light / 6.44:1 dark and is what every other
   secondary string in the product already uses. The dashed edge goes to
   --control-line for the same reason: at 1.52:1 the empty slot had no outline,
   so there was nothing to say a photo was expected here. */
.ba-missing {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  border: 1px dashed var(--control-line);
  border-radius: var(--r);
  color: var(--muted);
  font-size: var(--fs-body);
  text-align: center;
  padding: var(--sp-md);
}

.ba-arrow { color: var(--muted); font-size: 1.25rem; }

@media screen and (max-width: 767.98px) {
  .ba-pair { grid-template-columns: 1fr; gap: var(--sp-sm); }
  .ba-arrow { transform: rotate(90deg); justify-self: center; }
  .inbox-actions { width: 100%; }
  .inbox-actions .btn { flex: 1 1 0; }
}

/* RESTACKED ROWS INSIDE A CARD. Below 1200px app.js turns each table row into its
   own bordered, rounded, shadowed card -- and a card holding a table has
   padding: 0 so the table can run edge to edge. So every restacked row was drawn
   FLUSH against its parent card's border: a card on a card with no gap between
   them, on every list page on every phone. The rows get the card's own inset. */
@media screen and (max-width: 1199.98px) {
  .erp-card > .table-responsive:has(> .erp-table.as-cards),
  .card > .table-responsive:has(> .erp-table.as-cards) {
    padding: 0 var(--card-pad, var(--sp-md)) var(--card-pad, var(--sp-md));
  }
  /* A badge used as a card's title is a label, not a bar: the title cell is a
     stretched flex column, which pulled "Qarzga berildi" across the full width. */
  .erp-table.as-cards td .badge { align-self: flex-start; width: fit-content; }
}
