/* HakiliGrain UI: tokens first, then layout, then components. */

:root {
  /* Light theme (default). Text colours keep at least 4.5:1 contrast on white. */
  --bg: #f3f1eb;
  --surface: #ffffff;
  --surface-2: #f8f6f1;
  --border: #ddd7ca;
  --text: #161d19;
  --text-2: #444d48;
  --text-3: #5c6560;

  --brand: #1f5136;        /* deep field green */
  --brand-2: #22603e;
  --brand-ink: #ffffff;
  --accent: #c8912f;       /* wheat (decorative) */
  --accent-soft: #f6ead2;

  --ok: #22683e;   --ok-soft: #e1f1e6;
  --low: #8a5200;  --low-soft: #fbeed6;
  --out: #a42a20;  --out-soft: #fbe3df;
  --info: #255282; --info-soft: #e2ecf7;

  --sidebar-bg: #17301f;
  --sidebar-text: #d3ddd6;
  --sidebar-active: #24452f;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 16px rgba(20, 30, 25, .05);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

/* Dark theme: chosen explicitly, or "auto" on a device set to dark mode. */
:root[data-theme="dark"] {
    --bg: #121714;
    --surface: #1a201c;
    --surface-2: #1f2621;
    --border: #2c352f;
    --text: #e8ece9;
    --text-2: #b4bdb7;
    --text-3: #8f9993;
    --brand: #3f8f60;
    --brand-2: #5bb07c;
    --accent: #ddb05a;
    --accent-soft: #3a3020;
    --ok: #6cc28f;   --ok-soft: #1e3427;
    --low: #e8b25a;  --low-soft: #3a2e1a;
    --out: #f08a7f;  --out-soft: #3d2220;
    --info: #8dbbe8; --info-soft: #1d2b3a;
    --sidebar-bg: #0d120f;
    --sidebar-active: #1c2a21;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
      --bg: #121714;
      --surface: #1a201c;
      --surface-2: #1f2621;
      --border: #2c352f;
      --text: #e8ece9;
      --text-2: #b4bdb7;
      --text-3: #8f9993;
      --brand: #3f8f60;
      --brand-2: #5bb07c;
      --accent: #ddb05a;
      --accent-soft: #3a3020;
      --ok: #6cc28f;   --ok-soft: #1e3427;
      --low: #e8b25a;  --low-soft: #3a2e1a;
      --out: #f08a7f;  --out-soft: #3d2220;
      --info: #8dbbe8; --info-soft: #1d2b3a;
      --sidebar-bg: #0d120f;
      --sidebar-active: #1c2a21;
      --shadow: 0 1px 2px rgba(0, 0, 0, .3);
      color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
.muted { color: var(--text-2); font-size: 13px; }
::placeholder { color: var(--text-3); opacity: 1; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  flex: none;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 12px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  color: #fff; font-size: 19px; padding: 4px 10px 22px;
}
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; border-radius: 8px; background: #fff; padding: 3px; }
.brand strong { color: var(--accent); }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); font-weight: 500;
}
.sidebar nav a i { font-size: 18px; opacity: .85; }
.sidebar nav a:hover { background: var(--sidebar-active); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }

.sidebar-foot {
  display: flex; align-items: center; gap: 6px;
  border-top: 1px solid rgba(255,255,255,.08); padding-top: 12px;
}
.sidebar-foot form { margin: 0; }
.me { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 6px; border-radius: var(--radius-sm); color: #fff; }
.me:hover, .me.active { background: var(--sidebar-active); text-decoration: none; }
.avatar {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: #1d1606; font-weight: 700;
}
.me-text { display: flex; flex-direction: column; min-width: 0; }
.me-text strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { color: var(--sidebar-text); font-size: 12px; }
.sidebar .icon-btn { color: var(--sidebar-text); }
.sidebar .icon-btn:hover { background: var(--sidebar-active); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 28px; position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
}
.topbar h1 { font-size: 22px; font-weight: 650; flex: 1; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.content { padding: 4px 28px 40px; display: flex; flex-direction: column; gap: 20px; }
.flashes { padding: 0 28px; display: flex; flex-direction: column; gap: 8px; }
.flashes:empty { display: none; }
.scrim { display: none; }

/* ---------- Components ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  min-width: 0;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 16px; font-weight: 650; }
.card-head { flex-wrap: wrap; }
.card-head .btn { white-space: nowrap; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 4px;
}
.kpi-label { color: var(--text-2); font-size: 13px; font-weight: 500; }
.kpi-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi-sub { color: var(--text-3); font-size: 13px; }

.kpi-label .badge { margin-right: 4px; text-transform: capitalize; }

/* ---------- Dashboard ---------- */
.date-strip { display: flex; align-items: center; gap: 14px; }
.date-today { font-weight: 650; font-size: 15px; }
.date-line { flex: 1; height: 1px; background: var(--border); }

.hero-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.hero {
  border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.hero-dark { background: linear-gradient(135deg, var(--sidebar-bg), var(--brand)); color: #fff; }
.hero-light { background: var(--surface); border: 1px solid var(--border); }
.hero-top { display: flex; align-items: center; justify-content: space-between; }
.hero-eyebrow { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; opacity: .85; }
.hero-icon { font-size: 26px; opacity: .55; }
.hero-light .hero-icon { color: var(--accent); opacity: 1; }
.hero-amount { font-size: 34px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.hero-amount small { font-size: 15px; font-weight: 600; opacity: .7; }
.hero-count { font-size: 14px; opacity: .8; }

.hero-details { margin-top: 10px; border-top: 1px solid rgba(127,127,127,.25); padding-top: 10px; }
.hero-details summary { cursor: pointer; font-weight: 600; font-size: 14px; list-style: none; display: flex; align-items: center; gap: 6px; }
.hero-details summary::-webkit-details-marker { display: none; }
.hero-details summary::before { content: "\F285"; font-family: "bootstrap-icons"; font-size: 12px; transition: transform .15s; }
.hero-details[open] summary::before { transform: rotate(90deg); }
.muted-inv { opacity: .65; font-weight: 400; }
.hero-empty { margin: 8px 0 0; font-size: 13px; opacity: .7; }
.mini-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13.5px; }
.mini-table th { text-align: left; font-weight: 600; opacity: .7; padding: 6px 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.mini-table td { padding: 6px 4px; border-top: 1px solid rgba(127,127,127,.2); }
.mini-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.section-head h2 { font-size: 17px; font-weight: 650; }
.section-head a { font-weight: 600; font-size: 14px; }

.stock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.stock-card {
  min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px;
}
.sc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sc-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 16px; }
.stock-ok  .sc-icon { background: var(--ok-soft);  color: var(--ok); }
.stock-low .sc-icon { background: var(--low-soft); color: var(--low); }
.stock-out .sc-icon { background: var(--out-soft); color: var(--out); }
.sc-name { font-weight: 650; font-size: 14.5px; }
.sc-desc { color: var(--text-3); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-qty { margin-top: 6px; color: var(--text-2); font-size: 13px; }
.sc-qty strong { font-size: 24px; font-variant-numeric: tabular-nums; margin-right: 2px; }
.stock-ok  .sc-qty strong { color: var(--ok); }
.stock-low .sc-qty strong { color: var(--low); }
.stock-out .sc-qty strong { color: var(--out); }
.sc-bar { height: 5px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.sc-bar span { display: block; height: 100%; border-radius: inherit; }
.stock-ok  .sc-bar span { background: var(--ok); }
.stock-low .sc-bar span { background: var(--low); }
.stock-out .sc-bar span { background: var(--out); }

.btn-warn { background: var(--accent-soft); border-color: var(--accent); color: var(--low); }
.btn-warn:hover { background: var(--accent-soft); filter: brightness(.97); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); } 100% { box-shadow: 0 0 0 8px transparent; } }
.topbar-actions form { margin: 0; }

/* ---------- Lists & forms ---------- */
.nowrap { white-space: nowrap; }
.grow { flex: 1 1 220px; }
.code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; font-weight: 600; }
.cell-main { font-weight: 550; }
.cell-sub { color: var(--text-3); font-size: 12.5px; }
.row-actions { text-align: right; width: 1%; white-space: nowrap; }
.row-actions form { display: inline; margin: 0; }
.icon-btn.danger:hover { color: var(--out); background: var(--out-soft); }
.hint { margin: 8px 0 0; color: var(--text-2); font-size: 13px; min-height: 1em; }
.link-btn { align-self: flex-start; border: 0; background: none; color: var(--brand-2); font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; padding: 0; margin-top: -6px; }
.link-btn:hover { text-decoration: underline; }
.btn-lg { padding: 12px 18px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
fieldset.field { border: 0; margin: 0; padding: 0; min-width: 0; }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.filters .field { flex: 0 1 160px; }
.filters .field.grow { flex: 1 1 240px; }
.filters-toggle { display: none; }
.filters .field input, .filters .field select { padding: 8px 10px; }
.filter-actions { display: flex; gap: 8px; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; padding-top: 14px; }

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { position: relative; }
.pill input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; }
.pill span {
  display: inline-block; padding: 8px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: 14px;
}
.pill input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.pill input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.text-ok { color: var(--ok); }
.text-low { color: var(--low); }
.text-out { color: var(--out); }
.page-sub { margin: -8px 0 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tabs a {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; margin-bottom: -1px;
  color: var(--text-2); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--brand-2); border-bottom-color: var(--brand-2); }

a.stock-card { color: inherit; transition: transform .12s, box-shadow .12s; }
a.stock-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 6px 20px rgba(20, 30, 25, .1); }

.btn-danger-outline { border-color: var(--out); color: var(--out); background: transparent; }
.btn-danger-outline:hover { background: var(--out-soft); }
.danger-zone {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--border); font-size: 13px;
}

.top-list { display: flex; flex-direction: column; gap: 2px; color: var(--text-2); font-size: 13px; }
.top-list span { display: flex; justify-content: space-between; gap: 8px; }
.cell-main + .badge { margin-left: 6px; }
.info-grid.card { padding: 14px; }

.row-muted td { opacity: .55; }
.pill input:disabled + span { opacity: .45; cursor: not-allowed; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 20px; align-items: start; }
.profile-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.profile-head h2 { font-size: 20px; }
.avatar-lg { width: 56px; height: 56px; font-size: 22px; }
.profile-stats { margin-left: auto; display: flex; gap: 24px; flex-wrap: wrap; }
.profile-stats div { display: flex; flex-direction: column; }
.profile-stats strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.profile-stats span { color: var(--text-3); font-size: 12.5px; }

.report-frame { padding: 0; overflow: hidden; }
.report-frame iframe { display: block; width: 100%; height: calc(100vh - 210px); min-height: 520px; border: 0; }

/* ---------- Receipt print settings ---------- */
.settings-panel { display: flex; flex-direction: column; gap: 20px; }
/* Cards use the full width; long text and lone form fields keep a readable length. */
.settings-panel .hint, .settings-panel p.muted { max-width: 90ch; }
.settings-panel form.stack > .field, .settings-panel form.stack > label.field { max-width: 760px; }
.paper-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.paper-option { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 8px;
  border: 2px solid var(--border); border-radius: var(--radius); cursor: pointer; text-align: center; font-size: 13px; font-weight: 600; }
.paper-option input { position: absolute; opacity: 0; pointer-events: none; }
.paper-option:has(input:checked) { border-color: var(--brand-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-2) 18%, transparent); }
.paper-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.paper-shape { display: block; background: var(--surface-2); border: 1px solid var(--text-3); border-radius: 2px;
  background-image: repeating-linear-gradient(transparent 0 5px, var(--border) 5px 6px); }
.paper-shape-a4 { width: 42px; height: 59px; }
.paper-shape-a5 { width: 30px; height: 42px; margin-top: 17px; }
.paper-shape-80mm { width: 18px; height: 59px; }
.paper-shape-58mm { width: 13px; height: 59px; }
.logo-row { display: flex; gap: 16px; align-items: center; }
.logo-preview { width: 72px; height: 72px; object-fit: contain; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; padding: 6px; flex: none; }
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 6px 16px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.field .check input, .check input { width: 18px; height: 18px; padding: 0; margin: 0; flex: none; accent-color: var(--brand-2); }
.field input[type=file] { padding: 8px; }

/* ---------- Receipt paper formats ---------- */
.receipt-company { display: flex; gap: 14px; align-items: flex-start; }
.receipt-logo { width: 64px; height: 64px; object-fit: contain; flex: none; }
.receipt-legal { color: var(--text-2); font-size: 12px; }
.receipt.paper-a5 { max-width: 600px; font-size: 13.5px; }
.receipt.paper-a5 .receipt-logo { width: 52px; height: 52px; }
.receipt.paper-thermal { max-width: 320px; padding: 16px 14px; gap: 10px; font-size: 12.5px; }
.receipt.paper-58mm { max-width: 240px; font-size: 11.5px; }
.paper-thermal .receipt-head { flex-direction: column; align-items: center; text-align: center; gap: 8px; padding-bottom: 10px; border-bottom: 1px dashed var(--text-3); }
.paper-thermal .receipt-company { flex-direction: column; align-items: center; gap: 6px; }
.paper-thermal .receipt-logo { width: 48px; height: 48px; }
.paper-thermal .receipt-brand { font-size: 16px; }
.paper-thermal .receipt-meta { align-items: center; text-align: center; }
.paper-thermal .receipt-code { font-size: 13px; }
.paper-thermal .info-grid { grid-template-columns: 1fr; gap: 0; }
.paper-thermal .info-grid div { flex-direction: row; justify-content: space-between; gap: 8px; padding: 2px 0; background: none; border-radius: 0; }
.paper-thermal .info-grid span { font-size: 11px; }
.paper-thermal .info-grid strong { text-align: right; font-weight: 600; }
.paper-thermal .col-price { display: none; }
.paper-thermal .receipt-lines th, .paper-thermal .receipt-lines td { padding: 4px 2px; font-size: inherit; }
.paper-thermal .receipt-lines th { font-size: 10.5px; }
.paper-thermal .table-wrap { margin: 0; padding: 0; }
.paper-thermal .receipt-foot { flex-direction: column; gap: 6px; }
.paper-thermal .receipt-notes { flex: none; }
.paper-thermal .receipt-lines { font-size: inherit; }
.paper-thermal .cell-sub { font-size: .85em; }
.paper-thermal .receipt-foot .totals { flex: none; width: 100%; padding: 6px 0; background: none; border: 0; border-top: 1px dashed var(--text-3); border-radius: 0; }
.paper-thermal .totals .grand { font-size: 14px; }
.paper-thermal .receipt-thanks { padding-top: 8px; font-size: 11.5px; }

/* ---------- Searchable dropdowns (app.js searchableSelect) ---------- */
.combo { position: relative; width: 100%; }
.combo > select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }
.field .combo-input, .combo-input {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 40px 10px 12px;
  text-overflow: ellipsis;
}
.combo-input:focus { border-color: var(--brand-2); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-2) 20%, transparent); }
.combo.combo-invalid .combo-input { border-color: var(--out); }
.combo-toggle {
  position: absolute; top: 0; right: 0; bottom: 0; width: 38px; border: 0; background: none;
  color: var(--text-2); cursor: pointer; display: grid; place-items: center;
}
.combo-toggle i { transition: transform .15s; }
.combo.open .combo-toggle i { transform: rotate(180deg); }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40;
  margin: 0; padding: 4px; list-style: none; max-height: 280px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(20, 30, 25, .16);
}
.combo-list li { padding: 9px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; line-height: 1.35; }
.combo-list li.active { background: color-mix(in srgb, var(--brand-2) 12%, transparent); }
.combo-list li.selected { font-weight: 650; color: var(--brand-2); }
.combo-list li.selected::after { content: " ✓"; }
.combo-list li.combo-placeholder { color: var(--text-3); }
.combo-list .combo-empty { color: var(--text-3); cursor: default; text-align: center; }
.filters .field .combo-input { padding: 8px 40px 8px 10px; }
@media (max-width: 640px) { .filters .field .combo-input { padding: 10px 40px 10px 12px; } }

/* ---------- Power BI report list (Paramètres) ---------- */
.report-row { display: flex; gap: 12px; align-items: flex-end; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.report-row > .field:first-child { flex: 0 1 220px; }
.report-row > .field.grow { flex: 1 1 auto; min-width: 0; }
.report-row-actions { display: flex; gap: 4px; padding-bottom: 2px; }
.report-row:has([data-remove-report]:checked) .field { opacity: .45; text-decoration: line-through; }
@media (max-width: 640px) {
  .report-row { flex-wrap: wrap; }
  .report-row > .field:first-child, .report-row > .field.grow { flex: 1 1 100%; }
}

/* ---------- Order edit (Admin) ---------- */
.cell-input { width: 110px; max-width: 100%; text-align: right; font: inherit; font-variant-numeric: tabular-nums; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 9px; }
.cell-input:focus { border-color: var(--brand-2); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-2) 20%, transparent); }
.remove-toggle { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-sm); cursor: pointer; color: var(--text-2); position: relative; }
.remove-toggle input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.remove-toggle:hover { background: var(--out-soft); color: var(--out); }
.remove-toggle:has(input:checked) { background: var(--out); color: #fff; }
.remove-toggle:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.row-removed td:not(.row-actions) { opacity: .4; text-decoration: line-through; }
.subhead { font-size: 14px; font-weight: 650; margin: 18px 0 10px; color: var(--text-2); }

/* ---------- Paramètres ---------- */
.card-head h2 i { color: var(--brand-2); margin-right: 4px; }
.theme-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.theme-option { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 10px; cursor: pointer;
  border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.theme-option input { position: absolute; opacity: 0; pointer-events: none; }
.theme-option:has(input:checked) { border-color: var(--brand-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-2) 18%, transparent); }
.theme-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-label { font-weight: 650; font-size: 14px; }
.theme-hint { color: var(--text-3); font-size: 12px; line-height: 1.3; }
.theme-preview { display: grid; grid-template-columns: 30% 1fr; grid-template-rows: 1fr 1fr; gap: 4px; height: 56px; padding: 5px;
  border-radius: 8px; border: 1px solid var(--border); margin-bottom: 4px; }
.theme-preview span:first-child { grid-row: 1 / 3; border-radius: 4px; background: #17301f; }
.theme-preview span { border-radius: 4px; }
.theme-preview-light { background: #f3f1eb; }
.theme-preview-light span:not(:first-child) { background: #fff; border: 1px solid #ddd7ca; }
.theme-preview-dark { background: #121714; }
.theme-preview-dark span:first-child { background: #0d120f; }
.theme-preview-dark span:not(:first-child) { background: #1f2621; }
.theme-preview-auto { background: linear-gradient(135deg, #f3f1eb 50%, #121714 50%); }
.theme-preview-auto span:not(:first-child) { background: color-mix(in srgb, #fff 55%, #1f2621); }

.setting-list { list-style: none; margin: 0 0 14px; padding: 0; }
.setting-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.setting-list form { margin: 0; }
.setting-list li > .muted { min-width: 92px; text-align: right; }
.setting-list li > form:last-child:not(.inline-edit) { width: 40px; }
.setting-list li:not(:has(.icon-btn))::after { content: ""; width: 40px; flex: none; }
.inline-edit { display: flex; gap: 8px; flex: 1; min-width: 0; }
.inline-edit input { flex: 1; min-width: 0; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; }
.inline-edit input:focus { border-color: var(--brand-2); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-2) 20%, transparent); }

/* ---------- Sale cart ---------- */
.steps { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.step { padding: 5px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--text-3); }
.step.done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.step.current { color: var(--brand-ink); background: var(--brand); border-color: var(--brand); }
.code-pill { margin-left: auto; font-family: ui-monospace, Consolas, monospace; font-size: 13px; font-weight: 600; padding: 5px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--low); }

.cart-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.checkout { position: sticky; top: 84px; }
.add-line { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.add-line .qty { flex: 0 1 150px; }

.totals { margin: 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.totals div { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 14px; }
.totals dt { color: var(--text-2); }
.totals dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; }
.totals .grand { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 9px; font-size: 17px; }
.totals .grand dt { color: var(--text); font-weight: 650; }
.totals .grand dd { color: var(--brand-2); font-weight: 750; }

.modal { border: 0; border-radius: 16px; padding: 22px; width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal::backdrop { background: rgba(10, 20, 15, .45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }

/* ---------- Receipt ---------- */
.receipt { max-width: 860px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; padding: 26px 28px; }
.receipt-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding-bottom: 18px; border-bottom: 2px solid var(--brand); }
.receipt-brand { font-size: 24px; }
.receipt-brand { font-weight: 700; color: var(--brand-2); }
.receipt-meta { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.receipt-type { text-transform: uppercase; letter-spacing: .08em; font-size: 12px; font-weight: 700; color: var(--text-2); }
.receipt-code { font-family: ui-monospace, Consolas, monospace; font-size: 18px; font-weight: 700; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.info-grid div { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.info-grid span { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.receipt-foot { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.receipt-notes { flex: 1 1 260px; }
.receipt-notes p { margin: 0 0 6px; }
.receipt-thanks { margin: 0; padding-top: 14px; border-top: 1px dashed var(--border); text-align: center; color: var(--text-2); font-style: italic; }
.receipt-foot .totals { flex: 0 1 320px; }

@media print {
  .sidebar, .topbar, .flashes, .scrim { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; }
  .receipt { max-width: none; padding: 0; }
}

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.badge-ok  { background: var(--ok-soft);  color: var(--ok); }
.badge-low { background: var(--low-soft); color: var(--low); }
.badge-out { background: var(--out-soft); color: var(--out); }
.badge-info{ background: var(--info-soft);color: var(--info); }

.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-weight: 600; color: var(--text-2); font-size: 12.5px;
  text-transform: uppercase; letter-spacing: .03em;
  padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .empty { text-align: center; color: var(--text-3); padding: 28px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-danger { background: var(--out); border-color: var(--out); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); background: var(--out); }
.btn-block { width: 100%; }
.btn:focus-visible, .icon-btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-2);
  font-size: 20px; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field input, .field select, .field textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand-2); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-2) 20%, transparent); }

.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
}
.alert i { font-size: 17px; }
.alert span { flex: 1; }
.alert-success { background: var(--ok-soft);  color: var(--ok); }
.alert-error   { background: var(--out-soft); color: var(--out); }
.alert-info    { background: var(--info-soft);color: var(--info); }
.alert-close { border: 0; background: none; color: inherit; font-size: 20px; cursor: pointer; line-height: 1; opacity: .7; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-2); }
.empty-state i { font-size: 44px; color: var(--accent); }
.empty-state h2 { margin: 12px 0 6px; color: var(--text); }
.empty-state p { margin: 0 0 18px; }

/* ---------- Login ---------- */
.auth-page {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background:
    radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--brand) 25%, transparent), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 10px 40px rgba(20, 30, 25, .12);
  padding: 32px 28px; display: flex; flex-direction: column; gap: 18px;
}
.auth-brand { text-align: center; }
.auth-brand img { width: 56px; height: 56px; }
.auth-brand h1 { font-size: 24px; margin-top: 8px; font-weight: 500; }
.auth-brand h1 strong { color: var(--accent); }
.auth-brand p { margin: 4px 0 0; color: var(--text-2); font-size: 14px; }
.auth-link { align-self: center; font-size: 14px; font-weight: 600; }
.auth-text { margin: 0; font-size: 14px; line-height: 1.5; color: var(--text-2); }

/* ---------- Responsive ---------- */
.bottom-nav { display: none; }

@media (max-width: 1000px) {
  .hero-row { grid-template-columns: minmax(0, 1fr); }
  .cart-layout { grid-template-columns: minmax(0, 1fr); }
  .checkout { position: static; }
}

/* Tablets and phones: off-canvas sidebar + bottom navigation bar. */
@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 30;
    transform: translateX(-100%); transition: transform .2s ease;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }
  body.sidebar-open { overflow: hidden; }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; }

  .bottom-nav {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
    background: var(--surface); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 12px rgba(20, 30, 25, .06);
  }
  .bottom-nav a, .bottom-nav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 58px; padding: 6px 2px; border: 0; background: none; cursor: pointer;
    color: var(--text-2); font: inherit; font-size: 11.5px; font-weight: 600;
  }
  .bottom-nav i { font-size: 21px; line-height: 1; }
  .bottom-nav a:hover { text-decoration: none; }
  .bottom-nav a.active { color: var(--brand-2); }
  .bottom-nav a.active i { transform: translateY(-1px); }

  .topbar { padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); }
  .topbar h1 { font-size: 19px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .content { padding: 4px 16px calc(84px + env(safe-area-inset-bottom)); gap: 16px; }
  .flashes { padding: 0 16px; }
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .kpi-value { font-size: 21px; }
  .checkout { top: auto; }

  /* 16px inputs stop iOS from zooming into fields; larger touch targets. */
  .field input, .field select, .field textarea { font-size: 16px; }
  .icon-btn { width: 40px; height: 40px; }
  .btn { min-height: 42px; }
}

/* Phones */
@media screen and (max-width: 640px) {
  /* Tables become one card per row: the primary cell is the title, the rest are "label: value" lines. */
  .table-wrap { margin: 0; padding: 0; overflow: visible; }
  .table, .table tbody { display: block; }
  .table thead { display: none; }
  .table tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px;
    padding: 12px 0; border-bottom: 1px solid var(--border);
  }
  .table tbody tr:last-child { border-bottom: 0; }
  .table tbody tr:hover { background: none; }
  .table td {
    grid-column: 1 / -1; display: block; overflow: hidden;
    padding: 3px 0; border: 0; text-align: right; white-space: normal;
  }
  .table td::before {
    content: attr(data-label); float: left; margin-right: 12px;
    color: var(--text-3); font-size: 12.5px; text-align: left;
  }
  .table td.primary,
  .table tr:not(:has(.primary)) > td:first-child {
    grid-row: 1; grid-column: 1; text-align: left; font-size: 15px; padding-bottom: 6px;
  }
  .table td.primary::before,
  .table tr:not(:has(.primary)) > td:first-child::before,
  .table td.row-actions::before,
  .table td.empty::before { content: none; }
  .table td.row-actions { grid-row: 1; grid-column: 2; width: auto; text-align: right; }
  .table td.empty { text-align: center; }

  /* Compact list cards: m-aside = top right (amount), m-aside2 = second line right (status),
     m-sub = second line left, m-meta = small unlabelled line, m-hide = desktop only. */
  .table td.m-hide { display: none; }
  .table td.m-aside { grid-row: 1; grid-column: 2; font-weight: 650; white-space: nowrap; font-size: 15px; }
  .table td.m-aside2 { grid-row: 2; grid-column: 2; }
  .table td.m-sub { grid-row: 2; grid-column: 1; text-align: left; }
  .table td.m-meta { text-align: left; color: var(--text-3); font-size: 13px; padding: 1px 0; }
  .table td.m-aside::before, .table td.m-aside2::before,
  .table td.m-sub::before, .table td.m-meta::before { content: none; }
  .table td.m-aside .cell-sub { font-weight: 400; }
  .table .cell-sub { margin-top: 1px; }
  .table td .badge { white-space: normal; }

  /* Form dialogs open as bottom sheets. */
  .modal {
    width: 100%; max-width: 100%; margin: auto 0 0; max-height: 92vh; overflow-y: auto;
    border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  }

  .filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .filters > * { min-width: 0; }
  .filters .field.grow, .filters .field:has(select), .filter-actions, .filters-toggle { grid-column: 1 / -1; }
  .filters-toggle { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 4px 0; }
  .filters:not(.filters-open) .field.extra { display: none; }
  .filters.filters-open .filters-toggle span::after { content: " ▴"; }
  .filters:not(.filters-open) .filters-toggle span::after { content: " ▾"; }
  .filters .field input, .filters .field select { padding: 10px 12px; }
  .filter-actions .btn { flex: 1; }

  .add-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
  .add-line .grow { grid-column: 1 / -1; }

  .info-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .settings-grid, .stack-lg { gap: 16px; }
  .profile-stats { margin-left: 0; width: 100%; justify-content: space-between; gap: 12px; }
  .danger-zone .btn { width: 100%; }
  .modal-actions .btn { flex: 1; }
  .pagination { justify-content: space-between; }
}

@media (max-width: 520px) {
  .topbar-actions .btn-label { display: none; }
  .topbar-actions .btn { padding: 9px 12px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px 14px; min-width: 0; }
  .kpi-value { font-size: 17px; overflow-wrap: anywhere; }
  .kpi-label, .kpi-sub { font-size: 12.5px; }
  .hero { padding: 16px 18px; }
  .hero-amount { font-size: 28px; }
  .stock-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stock-card { padding: 12px; }
  .sc-qty strong { font-size: 21px; }
  .date-line, .date-strip .muted { display: none; }
  .two-col { grid-template-columns: 1fr; }
  .code-pill { margin-left: 0; }
  .receipt { padding: 18px 16px; }
  .receipt-meta { text-align: left; align-items: flex-start; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .theme-options { gap: 8px; }
  .paper-options { grid-template-columns: 1fr 1fr; }
  .logo-row { align-items: flex-start; }
  .theme-option { padding: 8px; }
  .theme-hint { display: none; }
  .setting-list li { flex-wrap: wrap; row-gap: 4px; }
  .setting-list li > .inline-edit { flex: 1 1 100%; }
  .setting-list li > .muted { min-width: 0; text-align: left; flex: 1; }
  .setting-list li:not(:has(.icon-btn))::after { content: none; }
  .inline-edit .btn { padding: 9px 12px; }
  .inline-edit input { font-size: 16px; }
  .tabs a { white-space: nowrap; }
}

@media print {
  .bottom-nav, .no-print { display: none !important; }
  .receipt .badge { border: 1px solid currentColor; }
  /* Receipt tables always print as tables, even when printing from a phone. */
  .receipt .table thead { display: table-header-group !important; }
  .receipt .table { display: table !important; }
  .receipt .table tbody { display: table-row-group !important; }
  .receipt .table tr { display: table-row !important; }
  .receipt .table td { display: table-cell !important; }
  .receipt .table td::before { content: none !important; }
  .receipt.paper-a5 { font-size: 12px; }
  /* Thermal tickets: compact type so a typical sale fits on a short ticket. */
  .receipt.paper-thermal { width: 76mm; max-width: none; margin: 0; padding: 0; gap: 5px; font-size: 10.5px; line-height: 1.35; color: #000; }
  .receipt.paper-58mm { width: 54mm; font-size: 9.5px; }
  .paper-thermal .receipt-head { gap: 3px; padding-bottom: 5px; }
  .paper-thermal .receipt-company { gap: 3px; }
  .paper-thermal .receipt-logo { width: 34px; height: 34px; }
  .paper-thermal .receipt-brand { font-size: 13px; }
  .paper-thermal .receipt-legal, .paper-thermal .muted { font-size: 9px; }
  .paper-thermal .receipt-type { font-size: 9.5px; }
  .paper-thermal .receipt-code { font-size: 11px; }
  .paper-thermal .badge { font-size: 9px; padding: 0 6px; }
  .paper-thermal .info-grid div { padding: 0; }
  .paper-thermal .info-grid span { font-size: 9px; }
  .paper-thermal .receipt-lines th, .paper-thermal .receipt-lines td { padding: 2px 1px; }
  .paper-thermal .receipt-lines th { font-size: 8.5px; }
  .paper-thermal .receipt-foot { gap: 3px; }
  .paper-thermal .receipt-notes p { margin: 0; }
  .paper-thermal .totals div { padding: 1px 0; font-size: 10.5px; }
  .paper-thermal .totals .grand { font-size: 12px; margin-top: 3px; padding-top: 4px; }
  .paper-thermal .receipt-thanks { padding-top: 5px; font-size: 9.5px; }
  .receipt.paper-thermal, .receipt.paper-thermal * { color: #000 !important; background: transparent !important; box-shadow: none !important; }
  .receipt.paper-thermal .col-price { display: none !important; }
}

/* ---------- Journal des modifications ---------- */
.log-list { list-style: none; margin: 0; padding: 0; }
.log-item { padding: 12px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.log-item:first-child { padding-top: 0; }
.log-item:last-child { border-bottom: 0; padding-bottom: 0; }
.log-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
.log-target { display: inline-flex; gap: 6px; align-items: baseline; min-width: 0; overflow-wrap: anywhere; }
.log-target a, .log-target strong { font-weight: 650; }
.log-when { margin-left: auto; white-space: nowrap; }
.log-summary { color: var(--text-2); font-size: 14px; overflow-wrap: anywhere; }
.log-changes { list-style: none; margin: 0; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface-2);
  display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; }
.log-changes li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; overflow-wrap: anywhere; min-width: 0; }
.log-changes .bi-arrow-right { color: var(--text-3); font-size: 12px; }
.log-field { font-weight: 600; color: var(--text-2); min-width: 140px; }
.log-changes del { color: var(--out); text-decoration: line-through; }
.log-changes ins { color: var(--ok); text-decoration: none; font-weight: 600; }

/* ---------- Alertes de stock ---------- */
.card-alert { border-left: 4px solid var(--low); }
.alert-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.alert-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.alert-list li:first-child { padding-top: 0; }
.alert-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.alert-name { font-weight: 650; }
.alert-facts { color: var(--text-2); font-size: 13.5px; }
.alert-reorder { margin-left: auto; font-size: 13.5px; white-space: nowrap; }
.sc-days { margin-top: 6px; font-size: 12.5px; color: var(--text-2); }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

/* ---------- Rapport du jour ---------- */
.day-nav { display: flex; align-items: flex-end; gap: 6px; }
.day-nav .icon-btn { margin-bottom: 4px; }
.table .total-row td { border-top: 2px solid var(--border); background: var(--surface-2); }

@media (max-width: 640px) {
  .three-col { grid-template-columns: minmax(0, 1fr); }
  .log-when { margin-left: 0; width: 100%; white-space: normal; }
  .log-field { min-width: 0; width: 100%; }
  .alert-reorder { margin-left: 0; }
  .day-nav { flex: 1 1 100%; }
  .day-nav .field { flex: 1; }
}
@media print {
  .card-alert { border-left: 0; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
}
.alert-more { border-top: 1px solid var(--border); margin-top: 10px; }
.alert-more > summary { list-style: none; cursor: pointer; padding-top: 10px; font-weight: 600; color: var(--brand-2); font-size: 14px; }
.alert-more > summary::-webkit-details-marker { display: none; }
.alert-more[open] > summary { padding-bottom: 4px; }
.alert-more .when-open, .alert-more[open] .when-closed { display: none; }
.alert-more[open] .when-open { display: inline; }
.alert-more .alert-list li:first-child { padding-top: 10px; }

/* ---------- Bandeaux système (abonnement, session support) ---------- */
.sys-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 28px 12px; padding: 10px 14px;
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; }
.sys-banner span { flex: 1 1 260px; }
.sys-banner a { font-weight: 650; color: inherit; text-decoration: underline; }
.sys-banner .btn { padding: 5px 12px; font-size: 13px; }
.sys-info    { background: var(--info-soft); color: var(--info); }
.sys-error   { background: var(--out-soft);  color: var(--out); }
.sys-support { background: var(--accent-soft); color: var(--text); border: 1px solid var(--accent); }
.sys-support i { color: var(--accent); font-size: 18px; }
@media (max-width: 860px) { .sys-banner { margin: 0 16px 12px; } }
@media print { .sys-banner { display: none !important; } }

/* ---------- Formule, demandes au support ---------- */
.feature-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 6px 16px; font-size: 14px; }
.feature-list .on i { color: var(--ok); }
.feature-list .off { color: var(--text-3); }
.reply-box { margin-top: 4px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--ok-soft); font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.reply-box strong { color: var(--ok); font-size: 13px; }


/* ---------- Multi-magasins, impression ---------- */
.store-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 12px 16px; }
.store-bar > i { font-size: 18px; color: var(--brand-2); }
.store-bar .field { flex-direction: row; align-items: center; gap: 8px; }
/* Stock page: store, Afficher and Transferts always on one line. */
.filters.store-filter { display: flex; flex-wrap: nowrap; align-items: flex-end; gap: 10px; }
.store-filter .field { flex: 1 1 220px; min-width: 0; max-width: 320px; }
.store-filter .filter-actions, .store-filter > .btn { flex: none; }
.store-filter .filter-actions .btn { flex: none; }
@media (max-width: 640px) {
  .store-filter .field { max-width: none; }
  .store-filter .sf-label { display: none; }
  .store-filter > .btn { padding: 9px 12px; }
}
.store-row { padding: 12px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.store-row:last-of-type { border-bottom: 0; }
.receipt-store { font-weight: 600; font-size: 13px; }
.qty-input { width: 110px; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font: inherit; text-align: right; }
.inline-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
@media print {
  .print-locked .shell, .print-locked .bottom-nav { display: none !important; }
  .print-locked::before { content: "L'impression ne fait pas partie de votre formule. Contactez votre fournisseur pour l'ajouter.";
    display: block; padding: 40px; font: 16px/1.5 sans-serif; text-align: center; }
}

/* Second row of the Paramètres page (sub-items of a tab, e.g. Entreprise). */
.subtabs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -6px; }
.subtabs a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px;
  color: var(--text-2); font-size: 13.5px; font-weight: 600; background: var(--surface); }
.subtabs a:hover { text-decoration: none; color: var(--text); }
.subtabs a.active { border-color: var(--brand-2); background: var(--ok-soft); color: var(--brand-2); }
@media (max-width: 640px) { .subtabs { margin-top: -4px; } .subtabs a { padding: 6px 10px; font-size: 13px; } }

/* ---------- Reduced sidebar (button "Réduire le menu", computers and tablets only) ---------- */
.sidebar { transition: width .18s ease, padding .18s ease; }
.sidebar-toggle {
  display: flex; align-items: center; gap: 12px; width: 100%; margin: 8px 0 10px; padding: 9px 12px;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--sidebar-text);
  font: inherit; font-size: 13.5px; cursor: pointer; text-align: left;
}
.sidebar-toggle:hover { background: var(--sidebar-active); color: #fff; }
.sidebar-toggle i { font-size: 16px; transition: transform .18s ease; }
@media (min-width: 861px) {
  html.sidebar-collapsed .sidebar { width: 72px; padding: 18px 10px; }
  html.sidebar-collapsed .brand { justify-content: center; padding: 4px 0 22px; }
  html.sidebar-collapsed .brand > span,
  html.sidebar-collapsed .sidebar nav a > span:not(.nav-count),
  html.sidebar-collapsed .sidebar-toggle span,
  html.sidebar-collapsed .me-text { display: none; }
  html.sidebar-collapsed .sidebar nav a { justify-content: center; padding: 11px 0; position: relative; }
  html.sidebar-collapsed .sidebar nav a .nav-count { position: absolute; top: 2px; right: 4px; min-width: 18px; padding: 0 5px; font-size: 11px; }
  html.sidebar-collapsed .sidebar-toggle { justify-content: center; padding: 9px 0; }
  html.sidebar-collapsed .sidebar-toggle i { transform: rotate(180deg); }
  html.sidebar-collapsed .sidebar-foot { flex-direction: column; gap: 4px; }
  html.sidebar-collapsed .me { flex: none; justify-content: center; }
  /* Reduced menu: no log-out icon (log out from the expanded menu or the profile page). */
  html.sidebar-collapsed .sidebar-foot form { display: none; }
}
@media (max-width: 860px) { .sidebar-toggle { display: none; } }

/* Support conversations */
.client-msg { margin-top: 4px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 14px;
  display: flex; flex-direction: column; gap: 4px; border-left: 3px solid var(--border); }
.client-msg strong { color: var(--text-2); font-size: 13px; }
.thread-reply { display: flex; gap: 8px; align-items: flex-end; margin-top: 6px; }
.thread-reply textarea { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: inherit; resize: vertical; background: var(--surface); color: var(--text); }
@media (max-width: 640px) { .thread-reply { flex-direction: column; align-items: stretch; } }

/* Rôles et permissions */
.role-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
.role-item { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--border);
  border-radius: 999px; color: var(--text); text-decoration: none; font-weight: 600; font-size: 14px; background: var(--surface); }
.role-item small { color: var(--text-3); font-weight: 600; }
.role-item.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.role-item.active small { color: inherit; opacity: .8; }
.role-locked { background: var(--surface-2); color: var(--text-2); cursor: default; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.perm-group { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px 12px; margin: 0;
  display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.perm-group legend { font-weight: 650; padding: 0 4px; }
.perm-group .check small { color: var(--text-3); }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Charges et salaires */
.card-warn { border-left: 4px solid var(--low); }
.pending-list { display: flex; flex-direction: column; gap: 8px; }
.pending-item { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface-2); }
.pending-item > div:first-child { flex: 1 1 220px; min-width: 0; }
.amount-input { width: 140px; max-width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: inherit; text-align: right; background: var(--surface); color: var(--text); }
.month-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.month-nav > strong { font-size: 17px; min-width: 150px; text-align: center; }
.month-nav form { margin-left: auto; }
.check-col { width: 36px; }
.table.statement td { padding: 10px 12px; }
.table.statement td.indent { padding-left: 28px; }
.table.statement tr.grand td { font-size: 17px; border-top: 2px solid var(--text-3); }
.text-ok { color: var(--ok); }
.row-muted td { opacity: .65; }
.category-list { display: flex; flex-direction: column; gap: 8px; }
.category-row input[name=name] { flex: 1 1 220px; min-width: 0; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font: inherit; background: var(--surface); color: var(--text); }
.hero-extra { display: inline-block; margin-top: 8px; font-size: 13px; font-weight: 600; color: inherit; opacity: .9; }
@media (max-width: 640px) { .amount-input { width: 100%; } .month-nav form { margin-left: 0; } }
.inline-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.plain-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }

/* Sidebar group (RH): a native <details>, open on its own pages */
.nav-group summary {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); font-weight: 500; cursor: pointer; list-style: none; user-select: none;
}
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary > i:first-child { font-size: 18px; opacity: .85; }
.nav-group summary:hover { background: var(--sidebar-active); color: #fff; }
.nav-group summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.nav-group summary.has-active { color: #fff; }
.nav-caret { margin-left: auto; font-size: 12px; transition: transform .15s; }
.nav-group[open] .nav-caret { transform: rotate(180deg); }
.nav-sub { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 4px 14px; padding-left: 10px; border-left: 1px solid rgba(255, 255, 255, .14); }
.sidebar .nav-sub a { padding: 8px 12px; font-size: 14px; }
@media (min-width: 861px) {
  /* Reduced sidebar: no group header, its entries show as plain icons. */
  html.sidebar-collapsed .nav-group summary { display: none; }
  html.sidebar-collapsed .nav-sub { margin: 0; padding: 0; border: 0; }
  html.sidebar-collapsed .sidebar .nav-sub a { padding: 11px 0; }
}

/* Sidebar: still scrolls (wheel, touchpad, finger, keyboard), without a visible scroll bar. */
.sidebar, .sidebar nav { scrollbar-width: none; -ms-overflow-style: none; }
.sidebar::-webkit-scrollbar, .sidebar nav::-webkit-scrollbar { display: none; }
/* A soft fade at the bottom hints that the menu goes on; the extra space lets the last entry scroll clear of it. */
.sidebar nav { padding-bottom: 24px;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
          mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent); }
