/* ─────────────────────────────────────────────────────────────────────────────
   Warehouse — Stripe-style design system
   Restrained palette · generous whitespace · disciplined hierarchy
   ───────────────────────────────────────────────────────────────────────── */

/* Inter via Google Fonts — fonts.googleapis.com/gstatic.com are in the CSP
   allowlist; rsms.me was NOT and got blocked. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Surfaces — almost no warmth; near-neutral with a tiny blue cast */
  --bg:          #ffffff;
  --bg-subtle:   #f6f8fa;
  --panel:       #ffffff;
  --panel-2:     #f6f8fa;
  --panel-hover: #f1f3f6;
  --border:      #e3e8ee;
  --border-soft: #eef1f5;
  --divider:     #f1f3f6;

  /* Text — Stripe uses near-black with carefully tuned grays */
  --text:        #1a1f36;
  --text-soft:   #3c4257;
  --muted:       #5f6b7d;
  --subtle:      #65707f;
  --faint:       #7e8799;

  /* Brand — forest green */
  --accent:        #1a6b47;
  --accent-hover:  #124d33;
  --accent-soft:   rgba(26, 107, 71, 0.08);
  --accent-ring:   rgba(26, 107, 71, 0.20);

  /* Re-point Bootstrap's "primary" (and links/focus) to the brand green so
     anything not explicitly themed — toggle switches, active tabs, links,
     focus rings, text-primary — comes out green instead of Bootstrap blue. */
  --bs-primary:            #1a6b47;
  --bs-primary-rgb:        26, 107, 71;
  --bs-link-color:         #1a6b47;
  --bs-link-color-rgb:     26, 107, 71;
  --bs-link-hover-color:   #124d33;
  --bs-focus-ring-color:   rgba(26, 107, 71, 0.25);

  /* Semantic — soft, mature */
  --success:       #00744c;
  --success-soft:  rgba(0, 116, 76, 0.10);
  --warning:       #8f5600;
  --warning-soft:  rgba(143, 86, 0, 0.10);
  --danger:        #c41818;
  --danger-soft:   rgba(196, 24, 24, 0.08);
  --info:          #0067cf;
  --info-soft:     rgba(0, 103, 207, 0.10);

  /* Misc */
  --code-fg: #00744c;
  --img-bg:  #f6f8fa;

  /* Geometry */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius:    8px;
  --radius-lg: 12px;

  /* Shadows — almost invisible, layered */
  --shadow-xs: 0 1px 1px rgba(0, 0, 0, 0.02), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow:    0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 8px -2px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 4px 6px -2px rgba(15, 23, 42, 0.05), 0 16px 32px -8px rgba(15, 23, 42, 0.12);

  /* Layout */
  --sidebar-w: 232px;
  --header-h:  56px;
  --content-max: 1280px;
  --content-pad-x: clamp(1.25rem, 3vw, 2.5rem);

  /* Type */
  --font-sans: 'Inter var', 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'JetBrains Mono', Menlo, monospace;
}

[data-bs-theme="dark"] { color-scheme: dark; }
[data-bs-theme="dark"] {
  --bg:          #0a0b0f;
  --bg-subtle:   #0d0f15;
  --panel:       #14171f;
  --panel-2:     #1a1d27;
  --panel-hover: #1f2330;
  --border:      #242938;
  --border-soft: #1d2230;
  --divider:     #1a1f2c;

  --text:        #f5f7fb;
  --text-soft:   #d3d8e1;
  --muted:       #99a1b3;
  --subtle:      #868fa6;
  --faint:       #69738a;

  --accent:        #2ecc82;
  --accent-hover:  #50dba0;
  --accent-soft:   rgba(46, 204, 130, 0.12);
  --accent-ring:   rgba(46, 204, 130, 0.30);

  /* Brand green for Bootstrap "primary" in dark mode (brighter green). */
  --bs-primary:            #2ecc82;
  --bs-primary-rgb:        46, 204, 130;
  --bs-link-color:         #2ecc82;
  --bs-link-color-rgb:     46, 204, 130;
  --bs-link-hover-color:   #50dba0;
  --bs-focus-ring-color:   rgba(46, 204, 130, 0.30);

  --success:       #2bd576;
  --success-soft:  rgba(43, 213, 118, 0.12);
  --warning:       #ffb43d;
  --warning-soft:  rgba(255, 180, 61, 0.14);
  --danger:        #ff5a5a;
  --danger-soft:   rgba(255, 90, 90, 0.14);
  --info:          #4aa3ff;
  --info-soft:     rgba(74, 163, 255, 0.14);

  --code-fg: #2bd576;
  --img-bg:  #1a1d27;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow:    0 4px 8px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 24px 50px -16px rgba(0, 0, 0, 0.7);
}

/* ── Base ───────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }

/* Paint the app surface on <html> too, so any inter-page flash (between
   document unload and the next paint) is the app's background colour, not
   pure white. Most pages use the sidebar layout where --bg-subtle is the
   real surface; auth/login pages override on <body>. */
html {
  background: var(--bg-subtle);
  color-scheme: light dark;
}

/* Opt the document into the View Transitions API for cross-page navigations
   in Chromium browsers. Falls back silently elsewhere. */
@view-transition { navigation: auto; }

/* Soft fade-in fallback so even browsers without view-transitions get a
   gentler hand-off than a hard white flash. Kept very short so it doesn't
   feel sluggish. */
@keyframes app-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: no-preference) {
  body { animation: app-fade-in .18s ease-out; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11', 'ss03';
}
@supports (font-variation-settings: normal) {
  body { font-family: 'Inter var', var(--font-sans); }
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  letter-spacing: -0.014em;
  color: var(--text);
  margin: 0;
}
h1 { font-size: 1.75rem; line-height: 1.2; letter-spacing: -0.022em; }
h2 { font-size: 1.375rem; line-height: 1.25; letter-spacing: -0.02em; }
h3 { font-size: 1.125rem; line-height: 1.3; }
h4 { font-size: 1rem; }

p { margin: 0 0 1rem; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color .12s;
}
a:hover { color: var(--accent-hover); }

code, pre, kbd, samp { font-family: var(--font-mono); font-size: 0.92em; }
code { color: var(--code-fg); }

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

/* Strip Bootstrap's loud icon coloring helpers when used inside headings */
h1 i, h2 i, h3 i, h4 i, h5 i,
.page-title i,
.text-primary[class*="bi-"], .text-warning[class*="bi-"],
.text-info[class*="bi-"], .text-success[class*="bi-"] {
  /* Pages still apply text-primary etc., but I want most heading icons
     to feel monochrome. They're allowed to stay colored where deliberate. */
}

/* ── App shell ──────────────────────────────────────────────────────────── */

body.has-sidebar { padding-left: var(--sidebar-w); background: var(--bg-subtle); }

body.has-sidebar main.container,
body.has-sidebar main.container-fluid,
body.has-sidebar > main {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 2.25rem var(--content-pad-x) 4rem;
}

@media (max-width: 992px) {
  body.has-sidebar { padding-left: 0; }
  body.has-sidebar main.container { padding-top: 4.5rem; }
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1030;
  transition: transform .25s cubic-bezier(.4, 0, .2, 1);
}

.app-sidebar-header {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: 1.1rem 1.1rem .9rem;
  min-height: var(--header-h);
}
.app-sidebar-logo {
  width: 26px; height: 26px;
  background: var(--text);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--panel);
}
.app-sidebar-logo svg { width: 16px; height: 16px; }
.app-sidebar-wordmark {
  font-weight: 600;
  font-size: .92rem;
  letter-spacing: -0.012em;
  color: var(--text);
}
.app-sidebar-wordmark .accent { color: var(--accent); }

.app-sidebar-section-label {
  font-size: .68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--subtle);
  padding: 1.1rem 1.25rem .35rem;
}

.app-sidebar-nav {
  display: flex; flex-direction: column;
  padding: 0 .5rem;
  gap: 1px;
}
.app-sidebar-nav.flex-1 { flex: 1; overflow-y: auto; padding-bottom: 1rem; }

.app-sidebar-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .4rem .65rem;
  border-radius: var(--radius-xs);
  color: var(--muted);
  font-size: .855rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .1s, color .1s;
  text-decoration: none;
}
.app-sidebar-link:hover {
  background: var(--panel-hover);
  color: var(--text);
}
.app-sidebar-link.active {
  background: var(--panel-hover);
  color: var(--text);
}
.app-sidebar-link.active::before {
  content: '';
  width: 3px;
  height: 14px;
  background: var(--accent);
  border-radius: 2px;
  margin-left: -.65rem;
  margin-right: .25rem;
}
.app-sidebar-link i {
  font-size: 1rem;
  width: 1.05rem;
  text-align: center;
  color: var(--subtle);
}
.app-sidebar-link:hover i, .app-sidebar-link.active i { color: var(--text-soft); }

/* Plan-locked nav items — greyed out, no hover, pointer blocked */
.app-sidebar-link.nav-plan-locked {
  opacity: 0.38;
  pointer-events: none;
  cursor: default;
}
.nav-lock-icon {
  margin-left: auto;
  font-size: 0.65rem !important;
  width: auto !important;
  color: var(--subtle) !important;
  opacity: 0.7;
}

.app-sidebar-footer {
  border-top: 1px solid var(--border-soft);
  padding: .75rem .75rem .9rem;
  display: flex; flex-direction: column; gap: .5rem;
}
.app-sidebar-user {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .35rem .5rem;
}
.app-sidebar-user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--text);
  color: var(--panel);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-size: .72rem;
  letter-spacing: -0.01em;
}
.app-sidebar-user-meta { flex: 1; min-width: 0; }
.app-sidebar-user-name {
  font-size: .82rem; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}
.app-sidebar-user-role {
  font-size: .7rem; color: var(--subtle);
  text-transform: capitalize;
}

.app-sidebar-actions {
  display: flex; gap: .3rem;
}
.app-icon-btn {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: var(--radius-xs);
  padding: .3rem;
  display: flex; align-items: center; justify-content: center;
  font-size: .82rem;
  cursor: pointer;
  transition: all .1s;
}
.app-icon-btn:hover {
  background: var(--panel-hover);
  color: var(--text);
  border-color: var(--border);
}

/* Language switcher dropdown in sidebar */
#lang-switcher {
  font-size: .75rem;
  padding: .25rem .4rem;
  background: var(--panel);
  color: var(--text);
  border-color: var(--border);
  border-radius: var(--radius-xs);
}
#lang-switcher:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-ring);
}

/* Mobile sidebar */
.app-sidebar-toggle {
  display: none;
  position: fixed;
  top: 14px; left: 14px;
  z-index: 1040;
  width: 36px; height: 36px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  align-items: center; justify-content: center;
  color: var(--text);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
}
.app-sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .4);
  z-index: 1029;
  backdrop-filter: blur(2px);
}

@media (max-width: 992px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .app-sidebar-toggle { display: flex; }
  .app-sidebar-backdrop.is-open { display: block; }
}

.app-offline-pill {
  margin: 0 .75rem .5rem;
  font-size: .7rem;
  text-align: center;
  padding: .3rem;
  border-radius: var(--radius-xs);
  background: var(--warning-soft);
  color: var(--warning);
}
.app-offline-pill.d-none { display: none; }

/* ── Page header (replaces <h4 class="fw-bold"> pattern) ───────────────── */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}
.page-title {
  font-size: 1.625rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0;
}
.page-subtitle {
  color: var(--muted);
  font-size: .9rem;
  margin-top: .25rem;
}
.page-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

/* Legacy headings on existing pages — make them feel professional too */
main.container > h4.fw-bold:first-of-type,
main > .container > h4.fw-bold:first-of-type {
  font-size: 1.625rem;
  letter-spacing: -0.02em;
  margin-bottom: 1.5rem;
}
main h4.fw-bold i { display: none; } /* drop colored heading icons */

/* ── Cards / sections ───────────────────────────────────────────────────── */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
  box-shadow: none;
}

.card-header {
  background: transparent;
  border-color: var(--divider);
  padding: 1rem 1.25rem;
  font-weight: 600;
  font-size: .92rem;
  color: var(--text);
  letter-spacing: -0.005em;
}
.card-header.fw-semibold { font-weight: 600; }
.card-header i { color: var(--subtle); }
.card-body { padding: 1.25rem; }
.card-footer {
  background: transparent;
  border-color: var(--divider);
  padding: .85rem 1.25rem;
}

/* Plain section block — no card chrome */
.section {
  padding: 0 0 2rem;
}
.section-title {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--subtle);
  margin-bottom: .85rem;
}

/* ── Forms ──────────────────────────────────────────────────────────────── */

.form-label {
  font-size: .82rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: .35rem;
  display: block;
}
.form-label .text-danger,
.form-label [class*="text-danger"] { color: var(--danger) !important; }

.form-text {
  font-size: .875rem;
  color: var(--subtle);
  margin-top: .35rem;
}

.form-control, .form-select {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: .5rem .7rem;
  font-size: max(.88rem, 16px); /* ≥16px prevents iOS auto-zoom on focus */
  line-height: 1.4;
  font-family: inherit;
  transition: border-color .1s, box-shadow .1s;
  box-shadow: var(--shadow-xs);
}
.form-control:hover, .form-select:hover { border-color: var(--faint); }
.form-control:focus, .form-select:focus {
  background: var(--panel);
  color: var(--text);
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring), var(--shadow-xs);
}
.form-control::placeholder { color: var(--subtle); opacity: 1; }

.form-control-sm, .form-select-sm { padding: .35rem .55rem; font-size: .82rem; }

textarea.form-control { resize: vertical; min-height: 4rem; }
input[type="file"].form-control { padding: .35rem .5rem; }

/* ── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: .875rem;
  line-height: 1.2;
  padding: .5rem .85rem;
  transition: all .1s;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn-sm { padding: .35rem .65rem; font-size: .8rem; }
.btn-lg { padding: .6rem 1.15rem; font-size: .95rem; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 1px 1px rgba(0,0,0,.05);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}
/* Bootstrap hardcodes the DISABLED background of .btn-primary to its own blue
   (--bs-btn-disabled-bg), which the normal-state green override above doesn't
   touch — so a disabled "Auto-fill"/"Save" button looked blue. Keep it brand
   green, just faded, so disabled still reads as disabled. */
.btn-primary:disabled, .btn-primary.disabled {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  opacity: .5;
}

.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover, .btn-success:focus { background: #006d47; border-color: #006d47; color: #fff; }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover, .btn-danger:focus { background: #9b1414; border-color: #9b1414; color: #fff; }

.btn-warning {
  background: var(--warning); border-color: var(--warning); color: #fff;
}
.btn-warning:hover { filter: brightness(.94); color: #fff; }

.btn-outline-primary {
  color: var(--accent); border-color: var(--border); background: var(--panel);
  box-shadow: var(--shadow-xs);
}
.btn-outline-primary:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.btn-outline-secondary {
  color: var(--text); border-color: var(--border); background: var(--panel);
  box-shadow: var(--shadow-xs);
}
.btn-outline-secondary:hover {
  background: var(--panel-hover);
  color: var(--text);
  border-color: var(--faint);
}

/* btn-info was a stray Bootstrap blue/cyan — bring it into the brand green. */
.btn-info {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.btn-info:hover, .btn-info:focus {
  background: var(--accent-hover); border-color: var(--accent-hover); color: #fff;
}

/* Toggle switches & checkboxes: Bootstrap compiles the checked state to a blue,
   so re-point it to the brand green explicitly (the live --bs-primary var alone
   doesn't recolour these reliably). */
.form-check-input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}
.form-check-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 .2rem var(--accent-ring);
}

.btn-outline-danger {
  color: var(--danger); border-color: var(--border); background: var(--panel);
  box-shadow: var(--shadow-xs);
}
.btn-outline-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.btn-outline-warning {
  color: var(--warning); border-color: var(--border); background: var(--panel);
  box-shadow: var(--shadow-xs);
}
.btn-outline-warning:hover { background: var(--warning); color: #fff; border-color: var(--warning); }

.btn-outline-success {
  color: var(--success); border-color: var(--border); background: var(--panel);
  box-shadow: var(--shadow-xs);
}
.btn-outline-success:hover { background: var(--success); color: #fff; border-color: var(--success); }

.btn-link {
  color: var(--accent); text-decoration: none; padding: 0;
  background: transparent; border: 0;
}
.btn-link:hover { color: var(--accent-hover); text-decoration: underline; }

.btn-close { opacity: .5; }
.btn-close:hover { opacity: 1; }

/* ── Badges — subtle, professional ──────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-weight: 500;
  font-size: .72rem;
  padding: .22em .55em;
  border-radius: var(--radius-sm);
  letter-spacing: 0;
  line-height: 1.4;
  border: 1px solid transparent;
}
.badge.bg-primary   { background: var(--accent-soft) !important; color: var(--accent) !important; }
.badge.bg-success   { background: var(--success-soft) !important; color: var(--success) !important; }
.badge.bg-info      { background: var(--info-soft) !important; color: var(--info) !important; }
.badge.bg-warning   { background: var(--warning-soft) !important; color: var(--warning) !important; }
.badge.bg-danger    { background: var(--danger-soft) !important; color: var(--danger) !important; }
.badge.bg-secondary { background: var(--panel-2) !important; color: var(--muted) !important; border-color: var(--border); }
.badge.bg-warning.text-dark { color: var(--warning) !important; }

/* ── Tables ─────────────────────────────────────────────────────────────── */

.table {
  color: var(--text);
  --bs-table-bg: transparent;
  margin: 0;
}
.table > :not(caption) > * > * {
  background: transparent;
  border-bottom: 1px solid var(--divider);
  color: var(--text);
  padding: .75rem 1rem;
  vertical-align: middle;
}
.table > thead > tr > th {
  font-size: .72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--subtle);
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  padding: .55rem 1rem;
}
.table-hover > tbody > tr:hover > * {
  background: var(--panel-hover);
}

/* ── Items table — denser, professional ─────────────────────────────────── */

.items-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.items-table thead th {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .055em;
  color: var(--subtle);
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  text-align: left;
}
.items-table tbody td {
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--divider);
  vertical-align: middle;
  font-size: .88rem;
}
.items-table tbody tr:last-child td { border-bottom: 0; }
.items-table tbody tr { transition: background .08s; cursor: pointer; }
.items-table tbody tr:hover { background: var(--panel-hover); }
.items-table tbody tr.selected { background: var(--accent-soft); }
.items-table .it-name {
  font-weight: 500;
  color: var(--text);
}
.items-table input.item-checkbox-row {
  width: 14px; height: 14px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* View toggle */
.view-toggle {
  display: inline-flex;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  box-shadow: var(--shadow-xs);
}
.view-toggle button {
  border: none;
  background: transparent;
  padding: .3rem .55rem;
  color: var(--muted);
  font-size: .8rem;
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: flex; align-items: center; gap: .3rem;
  font-weight: 500;
}
.view-toggle button:hover { color: var(--text); }
.view-toggle button.active {
  background: var(--panel-2);
  color: var(--text);
}

/* ── Item images — ONE canonical treatment everywhere ───────────────────────
   The same image / no-image look on every page. Images cover their box; every
   no-image placeholder is a neutral grey surface (--panel-2 / --img-bg) with a
   centred grey bi-image icon (--faint). Only the SIZE differs by context
   (list 36px, list-detail 40px, grid square). No white-on-colour, no coloured
   tiles, no initial letters. All theme vars, so dark mode flips automatically. */

.it-thumb {
  width: 36px; height: 36px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--img-bg);
}
.it-thumb-placeholder {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--faint);
  font-size: .9rem;
}

/* ── Item card grid ─────────────────────────────────────────────────────── */

.item-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform .12s, box-shadow .15s, border-color .15s;
}
.item-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  border-color: var(--faint);
}
.item-card-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--img-bg);
}
.item-card-img-placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--panel-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--faint);
  font-size: 1.6rem;
}
.item-grid-placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--panel-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--faint);
  font-size: 1.6rem;
}
.item-thumb-placeholder {
  width: 40px; height: 40px; flex: none;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--faint);
  font-size: .95rem;
}

/* ── List groups ────────────────────────────────────────────────────────── */

.list-group {
  background: transparent;
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.list-group-item {
  background: transparent !important;
  color: inherit !important;
  border-color: var(--divider) !important;
  padding: .85rem 1.25rem;
  font-size: .9rem;
}
.list-group-flush .list-group-item:last-child { border-bottom: 0 !important; }

/* ── Alerts ─────────────────────────────────────────────────────────────── */

.alert {
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: .7rem .9rem;
  font-size: .87rem;
  display: flex;
  gap: .55rem;
  align-items: flex-start;
}
.alert-info       { background: var(--info-soft); color: var(--info); border-color: rgba(0, 103, 207, .20); }
.alert-warning    { background: var(--warning-soft); color: var(--warning); border-color: rgba(143, 86, 0, .20); }
.alert-success    { background: var(--success-soft); color: var(--success); border-color: rgba(0, 116, 76, .20); }
.alert-danger     { background: var(--danger-soft); color: var(--danger); border-color: rgba(196, 24, 24, .20); }
.alert-secondary  { background: var(--panel-2); color: var(--muted); border-color: var(--border); }

/* ── Modals ─────────────────────────────────────────────────────────────── */

dialog.app-dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: calc(100% - 2rem);
  padding: 0;
  box-shadow: var(--shadow-lg);
}
dialog.app-dialog::backdrop {
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(2px);
}
dialog.app-dialog .dlg-head,
dialog.app-dialog .dlg-foot {
  padding: 1rem 1.25rem;
  border-color: var(--divider);
  background: transparent;
}
dialog.app-dialog .dlg-head {
  border-bottom: 1px solid var(--divider);
  display: flex; align-items: center;
}
dialog.app-dialog .dlg-head strong {
  font-weight: 600;
  font-size: 1rem;
}
dialog.app-dialog .dlg-foot {
  border-top: 1px solid var(--divider);
  display: flex; justify-content: flex-end; gap: .5rem;
  background: var(--bg-subtle);
}
dialog.app-dialog .dlg-body { padding: 1.25rem; }

/* ── Drop zone ──────────────────────────────────────────────────────────── */

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  background: var(--panel-2);
  transition: border-color .15s, background .15s;
  position: relative;
  min-height: 180px;
  display: flex; align-items: center; justify-content: center;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.preview-img { max-width: 100%; max-height: 240px; object-fit: contain; border-radius: var(--radius-sm); }

/* ── Skeletons ──────────────────────────────────────────────────────────── */

@keyframes skel-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skel {
  display: inline-block;
  background: linear-gradient(90deg, var(--panel-2) 0%, var(--panel-hover) 50%, var(--panel-2) 100%);
  background-size: 800px 100%;
  animation: skel-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
  color: transparent !important;
  user-select: none;
}
.skel-line { height: .8rem; border-radius: 3px; }
.skel-thumb { width: 36px; height: 36px; border-radius: var(--radius-sm); }
.skel-card { width: 100%; aspect-ratio: 1 / 1; border-radius: var(--radius-lg); }
.skel-pill { width: 60px; height: 18px; border-radius: var(--radius-sm); }

/* ── Empty state ────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 4rem 1.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.empty-state-icon {
  width: 48px; height: 48px;
  margin: 0 auto 1rem;
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  border: 1px solid var(--border);
}
.empty-state h5 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: .35rem;
}
.empty-state p {
  color: var(--muted);
  font-size: .87rem;
  margin-bottom: 1.25rem;
  max-width: 340px;
  margin-left: auto; margin-right: auto;
  line-height: 1.5;
}

/* ── Stat tiles (dashboard) ─────────────────────────────────────────────── */

.stat-tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.35rem;
  display: flex; flex-direction: column; gap: .15rem;
}
.stat-tile-label {
  font-size: .78rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  display: flex; align-items: center; gap: .4rem;
}
.stat-tile-value {
  font-size: 1.875rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.025em;
  margin-top: .35rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat-tile-foot {
  font-size: .78rem;
  color: var(--subtle);
  margin-top: .25rem;
}

/* ── Toast ──────────────────────────────────────────────────────────────── */

#undo-toast {
  position: fixed;
  bottom: 22px;
  left: calc(50% + var(--sidebar-w) / 2);
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: .75rem;
  z-index: 2000;
  font-size: .88rem;
}
@media (max-width: 992px) {
  #undo-toast { left: 50%; }
}

/* ── Bulk bar ───────────────────────────────────────────────────────────── */

#bulk-bar {
  position: sticky;
  bottom: 16px;
  z-index: 10;
  padding: .65rem .9rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-top: 1rem;
}

/* ── Tabs (nav-pills override) ──────────────────────────────────────────── */

.nav-pills {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  display: inline-flex;
  gap: 2px;
}
.nav-pills .nav-link {
  padding: .35rem .75rem;
  font-size: .82rem;
  color: var(--muted);
  border-radius: var(--radius-xs);
  font-weight: 500;
  transition: all .1s;
}
.nav-pills .nav-link:hover { color: var(--text); }
.nav-pills .nav-link.active {
  background: var(--panel-2);
  color: var(--text);
  font-weight: 600;
}

/* ── Login / auth ───────────────────────────────────────────────────────── */

.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--panel);
}
.auth-brand {
  background:
    radial-gradient(circle at 20% 20%, rgba(26, 107, 71, 0.28), transparent 55%),
    radial-gradient(circle at 80% 80%, rgba(26, 107, 71, 0.18), transparent 50%),
    linear-gradient(135deg, #0d2b1e 0%, #163d2a 100%);
  color: #fff;
  padding: 3rem 3.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-brand::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 32px 32px;
  mask: radial-gradient(circle at 50% 50%, #000 0%, transparent 80%);
  -webkit-mask: radial-gradient(circle at 50% 50%, #000 0%, transparent 80%);
  pointer-events: none;
}
.auth-brand > * { position: relative; z-index: 1; }

.auth-brand-mark {
  display: flex; align-items: center; gap: .65rem;
  font-size: 1rem; font-weight: 600; letter-spacing: -0.012em;
}
.auth-brand-mark .app-sidebar-logo {
  width: 32px; height: 32px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.14);
  color: #fff;
}
.auth-brand-mark .app-sidebar-logo svg { width: 18px; height: 18px; }
.auth-brand-mark .accent { color: var(--accent); }

.auth-brand-hero h2 {
  color: #fff;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin-bottom: .85rem;
  max-width: 22ch;
}
.auth-brand-hero p {
  color: rgba(255,255,255,.7);
  font-size: 1rem;
  line-height: 1.55;
  max-width: 36ch;
  margin: 0 0 1.75rem;
}
.auth-brand-features {
  display: flex; flex-direction: column; gap: .8rem;
}
.auth-brand-feature {
  display: flex; align-items: center; gap: .75rem;
  color: rgba(255,255,255,.85);
  font-size: .92rem;
}
.auth-brand-feature-icon {
  width: 28px; height: 28px; flex: none;
  background: rgba(26, 107, 71, 0.30);
  color: #7dd4aa;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem;
}

.auth-brand-foot {
  color: rgba(255,255,255,.45);
  font-size: .78rem;
}
.auth-brand-foot .tm { font-size: .7rem; vertical-align: super; opacity: .7; }

.auth-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  background: var(--panel);
  position: relative;
}
.auth-lang-row {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
}
.auth-card {
  max-width: 420px;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 0;
  box-shadow: none;
}
.auth-card h2 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.022em;
  margin-bottom: .35rem;
}
.auth-card .auth-intro {
  color: var(--muted);
  font-size: .92rem;
  margin-bottom: 1.75rem;
}
.auth-form-foot {
  margin-top: 1.5rem;
  text-align: center;
  font-size: .82rem;
  color: var(--subtle);
}
.auth-logo {
  display: flex; align-items: center; gap: .6rem;
  margin-bottom: 1.75rem;
}

@media (max-width: 900px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-brand { padding: 2rem; }
  .auth-brand-hero h2 { font-size: 1.5rem; }
  .auth-brand-foot { display: none; }
  .auth-form-panel { padding: 2rem 1.25rem 3rem; }
}
@media (max-width: 600px) {
  .auth-brand { display: none; }
  .auth-form-panel { padding: 1.5rem 1rem 2rem; }
  .auth-card { max-width: 100%; }
}

/* ── Barcode reader ─────────────────────────────────────────────────────── */

#barcode-reader video { border-radius: var(--radius); }

/* ── Utility tweaks ─────────────────────────────────────────────────────── */

.text-muted { color: var(--muted) !important; }
.text-subtle { color: var(--subtle); }
.text-faint { color: var(--faint); }

.fw-semibold { font-weight: 600 !important; }
.fw-bold { font-weight: 600 !important; }

hr {
  border-color: var(--divider);
  border-top-width: 1px;
  opacity: 1;
  margin: 1.5rem 0;
}

dl.row dt { font-weight: 500; color: var(--muted); }
dl.row dd { color: var(--text); }

/* Disable Bootstrap's heavy text-primary coloring for icons in section headers — they look childish */
.card-header i.text-primary,
.card-header i.text-warning,
.card-header i.text-success,
.card-header i.text-info {
  color: var(--subtle) !important;
}

/* Keep deliberate semantic icon colors at smaller, contextual sizes */
.badge i { color: inherit !important; }
.alert i { color: inherit !important; }

/* Focus ring */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.form-control:focus-visible,
.form-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--accent-ring), var(--shadow-xs);
  border-color: var(--accent);
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--accent-ring);
}

/* Windows High-Contrast Mode: box-shadows vanish, so force a system-colored
   outline that respects the user's forced-colors palette. */
@media (forced-colors: active) {
  :focus-visible {
    outline: 2px solid Highlight;
  }
}

/* Skip link */
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 9999;
  padding: .55rem 1rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: .9rem;
  text-decoration: none;
  transform: translateY(-120%);
  transition: transform .15s;
}
.skip-link:focus {
  transform: translateY(0);
  outline: 3px solid var(--accent-ring);
  outline-offset: 2px;
}

/* ── Plan usage banner ──────────────────────────────────────────────────── */
.plan-banner--warning {
  background: #fef9c3;
  border-bottom: 1px solid #fde047;
  color: #713f12;
  font-size: 0.875rem;
}
.plan-banner--limit {
  background: #fef2f2;
  border-bottom: 1px solid #fca5a5;
  color: #7f1d1d;
  font-size: 0.875rem;
}
[data-bs-theme="dark"] .plan-banner--warning {
  background: #2d2200;
  border-bottom-color: #7a5c00;
  color: #fde68a;
}
[data-bs-theme="dark"] .plan-banner--limit {
  background: #2d0a0a;
  border-bottom-color: #7f1d1d;
  color: #fca5a5;
}

/* ── Mobile bottom navigation bar ──────────────────────────────────────── */
.app-bottom-nav {
  display: none;
}
@media (max-width: 992px) {
  .app-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 1035;
    background: var(--panel);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 12px rgba(15,23,42,.07);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .app-bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: .6rem .25rem .5rem;
    color: var(--muted);
    text-decoration: none;
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .01em;
    min-height: 56px;
    transition: color .15s;
    -webkit-tap-highlight-color: transparent;
  }
  .app-bottom-nav-item i {
    font-size: 1.35rem;
    line-height: 1;
  }
  .app-bottom-nav-item.active,
  .app-bottom-nav-item:active {
    color: var(--accent);
  }
  .app-bottom-nav-item:hover { color: var(--accent); }

  /* Push page content above the bottom nav */
  body.has-sidebar main.container,
  body.has-sidebar main.container-fluid,
  body.has-sidebar > main {
    padding-bottom: calc(4rem + env(safe-area-inset-bottom, 0px));
  }

  /* Larger touch targets for all buttons on mobile */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }

  /* Full-width action buttons at bottom of forms */
  .mobile-full { width: 100% !important; }

  /* Better card spacing on small screens */
  .card { border-radius: var(--radius-sm); }
  .container { padding-left: .9rem; padding-right: .9rem; }

  /* Flash notifications clear of bottom nav */
  #flash-stack { bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px)) !important; top: auto !important; }
}

@media (max-width: 480px) {
  /* Stack form button rows on small phones */
  .d-flex.gap-2.justify-content-end {
    flex-direction: column-reverse;
  }
  .d-flex.gap-2.justify-content-end .btn {
    width: 100%;
  }
  /* Bigger page titles on small screens */
  .page-title { font-size: 1.4rem; }
}

/* ── Print ──────────────────────────────────────────────────────────────── */
@media print {
  .app-sidebar, .app-sidebar-toggle, .app-bottom-nav, .no-print, button { display: none !important; }
  body.has-sidebar { padding-left: 0 !important; background: #fff !important; }
  body { background: #fff !important; color: #000 !important; }
  .card { border: none !important; box-shadow: none !important; }
}

@keyframes flashIn {
  from { opacity: 0; transform: translateX(1rem); }
  to   { opacity: 1; transform: translateX(0); }
}
