/* app.css — Equipeo, the one application screen. Web client and desktop client share it. */
@import url('vendor/fonts/dm.css');
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* Any class setting `display` beats the browser's own [hidden] rule, and an element toggled by the
   attribute then stays on screen. */
[hidden] { display: none !important; }

/* Dark palette first, light on top: the tokens name what a colour means (late / done / waiting / running /
   idle), not what it is. shared/palette.js reads them for what is drawn on a canvas. */
:root {
  --logo-bg:     #f8fafc;
  --bg:          #0f172a;
  --surface:     #1a2332;
  --surface2:    #1e2d42;
  --border:      #2d3f55;
  --accent:      #2563eb;
  --accent-h:    #1d4ed8;
  --accent-light:#1e2d42;
  --text:        #e2e8f0;
  --text-muted:  #94a3b8;
  --ink-good:      #34d399;
  --ink-warn:      #d97706;
  --ink-bad:       #dc2626;
  --ink-progress:  #2563eb;
  --ink-idle:      #94a3b8;
  --fill-good:     #6ee7b7;
  --fill-progress: #93c5fd;
  --fill-bad:      #fca5a5;
  --fill-none:     #e2e7ed;
  --ink-review:    #7c3aed;
  --ink-update:    #0891b2;
  --ink-cancelled: #6b7280;
  --on-accent:     #ffffff;
  --band-bg:       #1a2332;
  --series-1: #3b82f6; --series-2: #f59e0b; --series-3: #10b981; --series-4: #a855f7;
  --series-5: #ec4899; --series-6: #14b8a6; --series-7: #84cc16; --series-8: #f97316;
  --overlay:       rgba(0, 0, 0, .6);
  --shadow:        rgba(0, 0, 0, .4);
  --radius:        10px;
}
:root[data-theme="light"] {
  --logo-bg:     transparent;
  --bg:          #f4f6f9;
  --surface:     #ffffff;
  --surface2:    #f1f5f9;
  --border:      #e2e8f0;
  --accent-light:#e8f0fe;
  --text:        #0f172a;
  --text-muted:  #64748b;
  --ink-good:    #059669;
  --overlay:     rgba(15, 23, 42, .45);
  --shadow:      rgba(15, 23, 42, .18);
}

/* Scrollbars: thin, on no track, dimmed until the pointer is on them. */
::-webkit-scrollbar { height: 11px; width: 11px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { border: 3px solid transparent; border-radius: 999px; background: color-mix(in srgb, var(--text-muted) 38%, transparent) padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: color-mix(in srgb, var(--text-muted) 70%, transparent); }

body { font-family: 'DM Sans', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 13px; min-height: 100vh; }

/* ── UPDATE BANNER ──────────────────────────────────── */
.update-banner { display: flex; align-items: center; justify-content: center; gap: 12px; background: var(--accent); color: var(--on-accent); padding: 8px 16px; font-size: 13px; flex-wrap: wrap; }
.update-banner-btn { background: color-mix(in srgb, var(--on-accent) 20%, transparent); border: none; color: var(--on-accent); padding: 3px 12px; border-radius: 4px; cursor: pointer; font-size: 12px; font-family: inherit; }
.update-banner-x { background: none; border: none; color: var(--on-accent); cursor: pointer; font-size: 16px; line-height: 1; }
@media (pointer: coarse) { .update-banner-btn, .update-banner-x { min-height: 40px; min-width: 40px; } }

/* ── HEADER: logo · base · tabs · actions ───────────── */
.app-header {
  position: sticky; top: 0; z-index: 200;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 0 20px;
  height: 60px;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
}
.app-logo { display: flex; align-items: center; font-size: 18px; font-weight: 700; letter-spacing: -0.5px; color: var(--text); white-space: nowrap; }
.app-logo span { color: var(--accent); }
.app-logo-mark { width: 28px; height: 28px; margin-right: 9px; }
.app-version-badge { font-size: 11px; font-weight: 400; color: var(--text-muted); margin-left: 6px; letter-spacing: 0; cursor: pointer; }
.app-version-badge:hover { text-decoration-line: underline; color: var(--accent); }
.app-version-badge:empty { display: none; }
/* The organisation's logo (Administration › Organisation), drawn for paper: on the dark palette it keeps a light ground. */
.org-logo { height: 32px; max-width: 140px; object-fit: contain; margin-left: 14px; padding: 2px 5px; border-radius: 5px; background: var(--logo-bg); }
.org-logo-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 6px; }
.org-logo-preview { max-height: 64px; max-width: 220px; object-fit: contain; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--logo-bg); }

/* The base selected at the head of the screen (PLAN §6): the unit of scope and of the local copy. */
.head-scope { display: flex; align-items: center; gap: 8px; }
.head-scope label { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); }
.head-scope .settings-text-input { width: auto; min-width: 160px; padding: 6px 10px; }

.nav-tabs-wrap { display: flex; align-items: stretch; min-width: 0; height: 100%; }
.nav-tabs { display: flex; align-items: stretch; height: 100%; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.nav-tabs::-webkit-scrollbar { height: 0; }
.nav-scroll { flex-shrink: 0; width: 22px; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; align-self: center; height: 28px; color: var(--text-muted); font-size: 15px; line-height: 1; cursor: pointer; }
.nav-scroll:hover { color: var(--text); border-color: var(--accent); }
.nav-back { flex-shrink: 0; width: 30px; height: 28px; align-self: center; margin-right: 6px; background: transparent; border: 1px solid var(--border); border-radius: 6px; color: var(--text-muted); font-size: 15px; line-height: 1; cursor: pointer; }
.nav-back:hover { color: var(--text); border-color: var(--accent); }
.nav-tab {
  padding: 0 14px; height: 100%; display: flex; align-items: center;
  background: transparent; border: none; border-bottom: 3px solid transparent;
  color: var(--text-muted); font-family: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap; flex-shrink: 0; transition: color .15s, border-color .15s;
}
.nav-tab:hover { color: var(--text); }
.nav-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.header-right { display: flex; align-items: center; gap: 8px; }
.header-divider { flex-shrink: 0; width: 1px; height: 22px; background: var(--border); }
#btn-login { display: inline-block; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.sync-status { display: inline-block; min-width: 14px; text-align: right; font-size: 11px; color: var(--text-muted); white-space: nowrap; cursor: pointer; }
.sync-status[data-state="syncing"] { color: var(--accent); }
.sync-status[data-state="synced"] { color: var(--ink-good); }
.sync-status[data-state="error"], .sync-status[data-state="conflict"] { color: var(--ink-bad); }
.sync-status[data-state="update"]  { color: var(--ink-warn); }

/* The menus under the header's buttons (account). */
.hdr-menu { position: fixed; z-index: 9999; min-width: 230px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 28px color-mix(in srgb, var(--shadow) 35%, transparent); animation: menu-in .12s ease-out; }
@keyframes menu-in {
  from { transform: translateY(-4px); opacity: 0; }
}
.hdr-menu button { display: block; width: 100%; text-align: left; padding: 8px 12px; border: none; border-radius: 6px; background: none; color: var(--text); font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; transition: background .12s, color .12s, box-shadow .12s, padding-left .12s; }
.hdr-menu button:hover, .hdr-menu button:focus-visible { outline: none; background: color-mix(in srgb, var(--accent) 22%, transparent); box-shadow: inset 3px 0 0 var(--accent); padding-left: 16px; }
.hdr-menu-head { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px 6px; font-size: 13px; }
.hdr-menu-head span { color: var(--text-muted); font-size: 11px; }
.hdr-menu-sep { height: 1px; margin: 4px 0; background: var(--border); }

.btn-gear { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; flex-shrink: 0; border: 1px solid var(--border); border-radius: 9px; background: var(--surface2); color: var(--text); font-size: 18px; line-height: 1; cursor: pointer; transition: background .15s, border-color .15s, color .15s, transform .2s; }
.btn-gear:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); transform: rotate(40deg); }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 7px; border: none; cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 500; transition: background .15s, opacity .15s; white-space: nowrap; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-h); }
.btn-secondary { border: 1px solid var(--border); background: var(--surface2); color: var(--text); }
.btn-secondary:hover { background: var(--border); }
.btn-ghost { border: 1px solid transparent; background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-danger { border: 1px solid color-mix(in srgb, var(--ink-bad) 45%, transparent); background: color-mix(in srgb, var(--ink-bad) 14%, transparent); color: var(--ink-bad); }
.btn-danger:hover { background: color-mix(in srgb, var(--ink-bad) 28%, transparent); }
.btn-danger-ghost { color: var(--text-muted); background: transparent; }
.btn-danger-ghost:hover { background: color-mix(in srgb, var(--ink-bad) 14%, transparent); color: var(--ink-bad); }
.btn:disabled { pointer-events: none; cursor: default; opacity: .45; }
.btn-sm   { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px; width: 30px; height: 30px; justify-content: center; }
.btn svg  { width: 13px; height: 13px; }

/* Segmented control: one pill holding the options of a choice. */
.seg { display: inline-flex; gap: 2px; padding: 2px; background: var(--surface2); border: 1px solid var(--border); border-radius: 999px; flex-shrink: 0; }
.seg button { display: inline-flex; align-items: center; border: none; background: transparent; color: var(--text-muted); font: inherit; font-size: 12px; font-weight: 500; line-height: 1; padding: 6px 12px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.on { color: var(--on-accent); background: var(--accent); }

/* ── PAGES ───────────────────────────────────────────── */
.page { display: none; padding: 20px 24px; max-width: 1500px; margin: 0 auto; }
#page-inventory { max-width: none; }
.page.active { display: block; }
.page-title { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }

/* ── PANELS AND TABLES (the chrome every screen shares) ── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.panel-header { padding: 10px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface2); }
.panel-title { font-weight: 600; font-size: 13px; }
.panel-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.panel-body { padding: 14px 16px; }
.table-note { padding: 7px 16px; font-size: 12px; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: pre-wrap; outline: none; }
.table-note:focus { background: var(--accent-light); }
.table-note:empty::before { content: attr(data-placeholder); opacity: .5; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; table-layout: fixed; }
.data-table th { text-align: left; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface2); position: relative; }
.data-table td { padding: 7px 10px; vertical-align: middle; border-bottom: 1px solid var(--border); color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.data-table tbody tr:hover td { background: var(--surface2); }
.data-table tr.row-picked td { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.cell-input { width: 100%; border: none; background: transparent; color: var(--text); font: inherit; padding: 6px 10px; }
/* The handle straddles the border it moves — except the last one, which would widen what its panel scrolls. */
.col-resize-handle { position: absolute; right: -4px; top: 0; z-index: 1; width: 9px; height: 100%; cursor: col-resize; touch-action: none; }
th:last-child > .col-resize-handle { right: 0; width: 5px; }
.col-resize-handle::after { content: ''; position: absolute; left: 50%; top: 0; width: 2px; height: 100%; margin-left: -1px; }
th:last-child > .col-resize-handle::after { left: auto; right: 0; margin: 0; }
.col-resize-handle:hover::after, .col-resize-handle:active::after { background: var(--accent); }
.col-resizing { cursor: col-resize; user-select: none; }
.col-moving { cursor: grabbing; user-select: none; }
.col-moving .th-sort { cursor: grabbing; }
th.col-dragged { opacity: .45; }
th.col-drop-before { box-shadow: inset 3px 0 0 var(--accent); }
th.col-drop-after { box-shadow: inset -3px 0 0 var(--accent); }
.row-pick { cursor: pointer; }
/* Badge cells: five tones, the palette of every status column. */
.cell-none, .cell-wip, .cell-ok, .cell-warn, .cell-ko { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.cell-none { background: color-mix(in srgb, var(--ink-idle) 18%, transparent); color: var(--text-muted); }
.cell-wip  { background: color-mix(in srgb, var(--ink-progress) 18%, transparent); color: color-mix(in srgb, var(--ink-progress) 70%, var(--text)); }
.cell-ok   { background: color-mix(in srgb, var(--ink-good) 18%, transparent); color: color-mix(in srgb, var(--ink-good) 70%, var(--text)); }
.cell-warn { background: color-mix(in srgb, var(--ink-warn) 18%, transparent); color: color-mix(in srgb, var(--ink-warn) 70%, var(--text)); }
.cell-ko   { background: color-mix(in srgb, var(--ink-bad) 18%, transparent); color: color-mix(in srgb, var(--ink-bad) 70%, var(--text)); }

/* The figure card every tab shows (kpiCard): a label, the value, then what it means. */
.kpi-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; text-align: center; color: var(--text); font: inherit; }
.kpi-link { cursor: pointer; }
.kpi-link:hover { border-color: var(--accent); }
.kpi-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.kpi-value { font-size: 22px; font-weight: 700; line-height: 1.25; margin: 2px 0; }
.kpi-value small { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.kpi-sub { font-size: 11px; color: var(--text-muted); }
.kpi-bar { display: flex; width: 100%; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin: 6px 0 2px; position: relative; }
.kpi-bar > span { height: 100%; display: block; }
.kpi-bar-mark { position: absolute; top: -2px; width: 2px; height: 10px; background: var(--text); }
.tone-good .kpi-value { color: var(--ink-good); }
.tone-bad .kpi-value { color: var(--ink-bad); }
.tone-warn .kpi-value { color: var(--ink-warn); }
.tone-progress .kpi-value { color: var(--ink-progress); }

/* Multi-select filter dropdown (filter-dd.js) */
.pf-filter-select { font-size: 12px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); cursor: pointer; font-family: inherit; }
.pf-filter-select.cal-filter-on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.cal-dd { position: fixed; z-index: 9999; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 28px color-mix(in srgb, var(--shadow) 35%, transparent); min-width: 170px; max-width: calc(100vw - 16px); max-height: 340px; overflow-y: auto; padding: 4px; }
.cal-dd label { display: flex; align-items: center; gap: 8px; padding: 5px 10px; font-size: 12px; color: var(--text); cursor: pointer; overflow-wrap: anywhere; user-select: none; border-radius: 4px; }
.cal-dd label[hidden] { display: none; }
.cal-dd-search { position: sticky; top: 0; z-index: 1; width: 100%; box-sizing: border-box; margin-bottom: 4px; padding: 5px 8px; font-size: 12px; box-shadow: 0 -4px 0 var(--surface); }
.cal-dd .cal-dd-all { border-bottom: 1px solid var(--border); border-radius: 0; font-weight: 600; }
.cal-dd-empty { padding: 6px 10px; color: var(--text-muted); font-size: 12px; }
.cal-dd label:hover { background: var(--surface2); }

/* ── FORMS, MODALS ───────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: var(--overlay); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 12px; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 26px; width: 100%; max-width: 500px; max-height: calc(100vh - 24px); overflow-y: auto; }
.modal h3 { font-size: 17px; margin-bottom: 12px; }
/* Dense rows inside a modal: a form shows whole on a laptop screen as far as it can. */
.modal .form-row { margin-bottom: 8px; }
.modal .form-row label { margin-bottom: 3px; }
.modal .form-row input, .modal .form-row select { padding: 5px 10px; }
.modal .form-section { margin: 12px 0 8px; padding-top: 10px; }
.modal .modal-footer { margin-top: 14px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 5px; }
.form-row input, .form-row select, .form-row textarea { width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; color: var(--text); font-family: inherit; font-size: 13px; outline: none; transition: border-color .15s; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { border-color: var(--accent); }
.form-2col { gap: 12px; display: grid; grid-template-columns: 1fr 1fr; }
.form-error { color: var(--ink-bad); font-size: 13px; margin-bottom: 10px; }
.modal-footer { margin-top: 20px; display: flex; gap: 8px; justify-content: flex-end; }

.settings-section-title { margin-bottom: 6px; color: var(--text); font-size: 13px; font-weight: 600; }
.settings-subtitle { margin: 10px 0 4px; color: var(--text); font-size: 12px; font-weight: 500; }
.settings-section { margin-bottom: 20px; }
.settings-hint { margin-bottom: 10px; color: var(--text-muted); font-size: 12px; line-height: 1.5; }
.settings-text-input { width: 100%; padding: 7px 10px; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; font-size: 13px; color: var(--text); font-family: inherit; }
.settings-text-input:focus { border-color: var(--accent); outline: none; }
.settings-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.toggle-switch input { width: 0; height: 0; opacity: 0; }
.toggle-knob { position: absolute; inset: 0; border-radius: 22px; background: var(--border); cursor: pointer; transition: background .2s; }
.toggle-switch input:checked + .toggle-knob { background: var(--accent); }
.toggle-knob::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--on-accent); transition: transform .2s; }
.toggle-switch input:checked + .toggle-knob::after { transform: translateX(18px); }
.modal-settings { max-width: 860px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 30px; align-items: start; }
.settings-col { min-width: 0; }
.settings-col + .settings-col { border-left: 1px solid var(--border); padding-left: 30px; }
.settings-version-section { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 4px; }
.settings-version-text { font-size: 12px; color: var(--text-muted); }
.update-notes { display: block; margin-top: 8px; font-size: 11px; color: var(--text-muted); white-space: pre-wrap; max-height: 120px; overflow-y: auto; background: var(--surface2); border-radius: 4px; padding: 6px 8px; font-family: 'DM Mono', monospace; }
.update-notes:empty { display: none; }
/* ── Movements, the ledger (lot 4) ── */
.nav-badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 6px; border-radius: 999px; background: var(--ink-bad); color: #fff; font-size: 10.5px; line-height: 18px; text-align: center; font-weight: 600; }
.mv-period { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.mv-period input { width: 138px; padding: 6px 8px; }
.mv-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.mv-seg button { padding: 6px 10px; min-height: 32px; font-size: 12px; background: var(--surface); color: var(--text-muted); border: none; border-left: 1px solid var(--border); cursor: pointer; }
.mv-seg button:first-child { border-left: none; }
.mv-seg button.active { background: var(--accent); color: #fff; }
#mv-type-filter { width: auto; min-width: 160px; max-width: 230px; padding: 6px 8px; }
.mv-item-name, .mv-item-code { display: block; overflow: hidden; text-overflow: ellipsis; }
.mv-item-code { font-weight: 400; color: var(--text-muted); }
.mv-late { color: var(--ink-bad); font-weight: 600; font-size: 11.5px; white-space: nowrap; }
.mv-due { color: var(--text-muted); font-size: 11.5px; white-space: nowrap; }
.mv-item-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface2); font-size: 13px; }
.mv-item-list { display: flex; flex-direction: column; gap: 4px; max-height: 120px; overflow-y: auto; margin-bottom: 12px; }
.mv-item-list .mv-item-line { margin-bottom: 0; }
.mv-effect { margin: 0 0 12px; font-size: 12.5px; color: var(--text-muted); }
.mv-pick-list { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; margin-bottom: 12px; }
.mv-pick-item { justify-content: flex-start; gap: 8px; text-align: left; }
.ledger-head { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.ledger-list li { cursor: pointer; align-items: center; }
.ledger-list li:hover { background: var(--surface2); }
.ledger-list .btn-icon { margin-left: auto; }
/* A proposal's standing (2026-10-05): a sentence, not a chip — it wraps at 360 px. */
.mv-approval { display: block; white-space: normal; border-radius: 8px; padding: 8px 12px; margin: 0 0 12px; font-size: 12.5px; }
.ledger-list li.mv-rejected { opacity: .6; }

/* The equipment card: one column of fields, as before, until the screen is wide enough for two panes —
   the fields in three columns on the left, the notes, the qualification, the ledger and the history on the
   right — so the card shows whole without scrolling. */
.modal-item { max-width: 780px; }
@media (min-width: 1100px) {
  .modal-item { max-width: 1280px; }
  #item-form { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 0 28px; align-items: start; }
  .item-main .item-grid { grid-template-columns: repeat(3, 1fr); }
  .item-side .hist-list { max-height: 200px; }
}
@media (min-width: 1360px) {
  #item-form { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
  .item-main .item-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 940px) {
  .settings-col + .settings-col { border-left: 0; padding-left: 0; }
  .settings-grid { grid-template-columns: 1fr; }
}

/* Users admin — inside the Administration tab. */
.ua-head { gap: 8px; align-items: center; display: flex; }
.ua-list { border-top: 1px solid var(--border); }
.ua-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.ua-who { flex: 1 1 240px; min-width: 0; }
.ua-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; }
.ua-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 2px; color: var(--text-muted); font-size: 11px; }
.ua-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px; }
.ua-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ua-count { color: var(--text-muted); font-size: 12px; font-weight: 400; }
.ua-login { color: var(--text-muted); font-size: 12px; }
.ua-badge { padding: 0 7px; border: 1px solid currentColor; border-radius: 999px; font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.ua-ko { color: var(--ink-bad); }
.ua-wait { color: var(--ink-warn); }
.ua-search { flex: 0 1 260px; width: auto; margin-left: auto; padding: 5px 9px; font-size: 12px; font-weight: 400; }
.ua-role { font-size: 12px; padding: 4px 6px; width: auto; }
.ua-edit .settings-text-input { width: auto; flex: 1 1 140px; }
.ua-row:hover { background: var(--surface2); }
.ua-off .ua-meta, .ua-off .ua-name strong { opacity: .6; }
.ua-create { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ua-create .settings-text-input { flex: 1 1 140px; width: auto; }
.ua-code { margin-top: 10px; font-size: 13px; }
.ua-code code { font-size: 14px; user-select: all; background: var(--surface2); padding: 2px 8px; border-radius: 4px; }
.ua-code-actions { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Scopes editor */
.sc-list { display: flex; flex-direction: column; gap: 6px; }
.sc-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) minmax(0, 190px) auto; gap: 8px; align-items: center; }
.sc-row .settings-text-input { width: 100%; }
.sc-row label { display: flex; align-items: center; gap: 5px; font-size: 12px; white-space: nowrap; cursor: pointer; }
.sc-row-3 { grid-template-columns: 150px minmax(0, 1fr) minmax(0, 190px); }
.ua-first-label { margin: 10px 0 4px; font-size: 12px; color: var(--text-muted); }
.ua-create-go { margin-top: 8px; }
.dl-form .panel-body { display: flex; flex-direction: column; gap: 8px; }
.dl-label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text-muted); }
.dl-dates { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.dl-group { margin-top: 14px; }
.dl-group-title { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.dl-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 4px; border-top: 1px solid var(--border); }
.dl-what { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.dl-what span { font-size: 12px; color: var(--text-muted); }
.dl-running { color: var(--ink-good); }
.dl-future { color: var(--ink-warn); }
.dl-spent, .dl-revoked { color: var(--text-muted); }

/* Administration → Rôles (PLAN §4.1): roles in columns, the labels held at the left; one role at a time on a phone. */
.rl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.rl-bar #rl-new { width: 220px; max-width: 100%; }
.rl-pick { display: none; align-items: center; gap: 6px; font-size: 12px; }
.rl-scroll { overflow-x: auto; }
.rl-matrix { border-collapse: collapse; font-size: 13px; }
.rl-matrix th, .rl-matrix td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.rl-matrix tbody th { text-align: left; font-weight: 400; position: sticky; left: 0; background: var(--surface); min-width: 260px; }
.rl-matrix thead th { vertical-align: top; min-width: 150px; text-align: center; }
.rl-matrix td { text-align: center; }
.rl-matrix input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
/* A box another right brings stays plainly ticked; one a tab cannot take is faded. */
.rl-matrix input[type="checkbox"]:disabled { cursor: not-allowed; }
.rl-matrix input[type="checkbox"]:disabled:not(:checked) { opacity: .45; }
.rl-cell { display: flex; align-items: center; justify-content: center; min-height: 32px; cursor: pointer; }
.rl-group th { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); padding-top: 14px; }
.rl-name { width: 100%; min-width: 110px; font-weight: 600; text-align: center; }

/* Administration › Licence. */
.lic-id { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.lic-id code { font-size: 13px; word-break: break-all; user-select: all; }
.lic-table { border-collapse: collapse; font-size: 13px; margin: 8px 0; width: 100%; max-width: 800px; }
.lic-table th, .lic-table td { padding: 8px; border-bottom: 1px solid var(--border); text-align: left; }
.lic-table th { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.lic-table td > span[class] { padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.lic-switch button:disabled { opacity: .4; cursor: not-allowed; }
@media (max-width: 767px) {
  .lic-table tr { display: grid; grid-template-columns: 1fr auto auto; align-items: center; border-bottom: 1px solid var(--border); }
  .lic-table th, .lic-table td { border-bottom: none; }
  .lic-table th:nth-child(4) { display: none; }
  .lic-table td:nth-child(4) { grid-column: 1 / -1; padding-top: 0; }
  .lic-switch { display: flex; }
  .lic-switch button { flex: 1; justify-content: center; min-height: 40px; }
}
.lic-history-title { margin: 16px 0 4px; font-size: 13px; }
.lic-history { margin: 0; padding-left: 18px; font-size: 13px; }
.lic-history li { margin: 4px 0; }
.rl-used { display: block; font-size: 11px; color: var(--text-muted); font-weight: 400; margin-top: 2px; }
@media (max-width: 767px) {
  .rl-pick { display: flex; flex: 1 1 100%; }
  .rl-pick select { flex: 1; }
  .rl-bar #rl-new { flex: 1; width: auto; }
  .rl-matrix { width: 100%; }
  .rl-matrix [data-col]:not(.on) { display: none; }
  .rl-matrix tbody th { min-width: 0; }
  .rl-matrix td { width: 56px; padding: 0; }
  .rl-cell { min-height: 44px; }
  .rl-matrix input[type="checkbox"] { width: 26px; height: 26px; }
}

/* Release notes: title and footer stay put, the versions scroll. */
.modal-release-notes { display: flex; flex-direction: column; max-width: 760px; overflow: hidden; }
.release-notes { border-top: 1px solid var(--border); overflow-y: auto; min-height: 0; flex: 1; }
.modal-release-notes h3 { margin-bottom: 12px; }
.rn-version { padding: 10px 4px; border-bottom: 1px solid var(--border); }
.rn-version summary { font-size: 14px; cursor: pointer; }
.rn-date { margin-left: 10px; color: var(--text-muted); font-size: 12px; }
.rn-installed { margin-left: 10px; padding: 1px 8px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 11px; }
.rn-version h5 { margin: 14px 0 6px; color: var(--text-muted); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.rn-version li { line-height: 1.55; font-size: 13px; margin: 5px 0; }
.rn-version ul { padding-left: 20px; }
.rn-version code { padding: 0 4px; border-radius: 4px; background: var(--surface2); font-size: 12px; }
.rn-note { margin-top: 10px; padding-left: 10px; border-left: 3px solid var(--border); color: var(--text-muted); font-size: 13px; }

/* ── CONFIRM DIALOG, TOASTS ──────────────────────────── */
.confirm-overlay { position: fixed; inset: 0; background: var(--overlay); display: none; align-items: center; justify-content: center; z-index: 1100; }
.confirm-overlay.open { display: flex; }
.confirm-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; max-width: 380px; width: 100%; }
.confirm-footer { gap: 8px; justify-content: flex-end; display: flex; }
.confirm-box p { margin-bottom: 20px; color: var(--text-muted); font-size: 13px; }
.confirm-box h4 { margin-bottom: 8px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 20px; font-size: 13px; color: var(--text); box-shadow: 0 4px 20px var(--shadow); display: none; z-index: 2000; }
.toast.show { display: block; }
.undo-toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px 8px 16px; font-size: 13px; color: var(--text); box-shadow: 0 4px 20px var(--shadow); z-index: 2000; }

/* ── ADMINISTRATION SECTIONS, REFERENTIAL LISTS ─────── */
.admin-nav { margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.admin-nav::-webkit-scrollbar { height: 0; }
.ref-off td { color: var(--text-muted); }
.ref-stamp { margin: 4px 0 0; }
.input-code, .form-row .input-code { text-transform: uppercase; font-family: 'DM Mono', monospace; }
.input-code::placeholder { text-transform: none; font-family: 'DM Sans', system-ui, sans-serif; }
.check-row { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 13px; cursor: pointer; }
.check-line { display: flex; gap: 6px 20px; flex-wrap: wrap; }
.check-line .check-row { margin-bottom: 0; }
.rule-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 12px; align-items: end; }
.rule-grid .check-row { grid-column: 1 / -1; }
.panel-body .settings-section-title { margin-top: 18px; }
.panel-body code { font-family: 'DM Mono', monospace; font-size: 12.5px; background: var(--surface2); padding: 1px 7px; border-radius: 4px; color: var(--text); }
.panel-body .form-error { display: inline; margin: 0 0 0 6px; font-size: 12px; }
.modal-footer-split { justify-content: space-between; }
.modal-footer-main { display: flex; gap: 8px; margin-left: auto; }

/* ── THE TABLE (table.js, PLAN §6) ───────────────────── */
.tbl-top { flex-wrap: wrap; }
.tbl-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.tbl-search { flex: 0 1 300px; width: auto; }
.tbl-view { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 12px; color: var(--text-muted); }
.tbl-view-select { width: auto; max-width: 280px; min-width: 150px; padding: 6px 8px; }
/* The filters are the header's second row; the panel and its button are the phone's (a card has no header). */
.tbl-filter-toggle, .tbl-filters { display: none; }
.tbl-filter-row th { padding: 0 4px 6px; }
.tbl-col-filter { padding: 4px 8px; font-size: 12px; font-weight: 400; letter-spacing: 0; text-transform: none; background: var(--surface); }
.tbl-filter-row .cal-filter-btn, .tbl-filter-field .cal-filter-btn { width: 100%; min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 4px 8px; font-weight: 400; letter-spacing: 0; text-transform: none; }
.tbl-selbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 16px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--accent) 10%, transparent); font-size: 12.5px; }
.tbl-selbar .check-row { margin: 0; }
.tbl-summary { padding: 7px 16px; font-size: 12px; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.tbl-summary:empty, .tbl-more:empty { display: none; }
/* Many columns scroll inside the panel, never the page. */
.tbl-scroll { overflow-x: auto; }
.tbl th { padding: 0; }
.th-sort { display: block; width: 100%; padding: 8px 10px; border: none; background: none; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.th-sort:hover, .th-sort:focus-visible { color: var(--text); outline: none; }
.tbl-col-amount .th-sort, .tbl-col-number .th-sort, .tbl td.num { text-align: right; }
.tbl td { white-space: nowrap; }
.tbl .tbl-pick { width: 40px; padding: 0 0 0 12px; }
.tbl-row { cursor: pointer; }
.tbl-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tbl-name { font-weight: 600; }
.tbl-none td { color: var(--text-muted); padding: 14px 16px; }
.tbl-more { padding: 10px 16px; text-align: center; }

/* ── INVENTORY (PLAN §6) ─────────────────────────────── */
.inv-code { font-family: 'DM Mono', monospace; font-size: 12px; }
.inv-flag { font-size: 11px; color: var(--ink-warn); }
.row-pick { width: 16px; height: 16px; cursor: pointer; }

/* The equipment card: the rule's three conditions as the form is filled, then the journal's lines. */
.form-section { margin: 18px 0 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.qual-box { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--surface2); margin-bottom: 14px; }
.qual-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; font-size: 12px; color: var(--text-muted); }
.qual-list { list-style: none; font-size: 13px; line-height: 1.7; }
.qual-yes { color: var(--ink-good); }
.qual-no, .qual-off { color: var(--text-muted); }
.qual-note { margin-top: 6px; font-size: 12px; color: var(--ink-warn); }
.hist-list { list-style: none; max-height: 240px; overflow-y: auto; margin-bottom: 10px; border-top: 1px solid var(--border); font-size: 12.5px; }
.hist-list li { display: flex; gap: 4px 12px; flex-wrap: wrap; padding: 6px 2px; border-bottom: 1px solid var(--border); }
.hist-when, .hist-who { color: var(--text-muted); white-space: nowrap; }
.hist-what { flex: 1 1 220px; overflow-wrap: anywhere; }

/* Excel import: the sheet's first rows, its columns against the fields, what the import will do. */
.imp-preview { overflow-x: auto; margin-bottom: 14px; border: 1px solid var(--border); border-radius: 8px; }
.imp-prev { width: 100%; border-collapse: collapse; font-size: 11.5px; white-space: nowrap; }
.imp-prev tr { cursor: pointer; }
.imp-prev td { max-width: 180px; padding: 4px 8px; border-bottom: 1px solid var(--border); overflow: hidden; text-overflow: ellipsis; }
.imp-prev tr:hover td { background: var(--surface2); }
.imp-prev-num { width: 1%; color: var(--text-muted); }
.imp-prev-head td { background: color-mix(in srgb, var(--accent) 16%, transparent); font-weight: 600; }
.imp-prev-skip td { color: var(--text-muted); text-decoration: line-through; }
.imp-mapping { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 18px; margin-bottom: 14px; }
.imp-map-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: center; }
.imp-map-col { display: flex; flex-direction: column; min-width: 0; font-size: 12.5px; }
.imp-map-col strong, .imp-map-sample { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-map-sample { min-height: 1em; font-size: 11px; color: var(--text-muted); }
.imp-summary { list-style: none; font-size: 13px; line-height: 1.7; }
.imp-summary li::before { content: '• '; color: var(--text-muted); }
.imp-warn { color: var(--ink-warn); }

/* The organisation's free columns. */
.cols-free-row { display: grid; grid-template-columns: minmax(0, 1.2fr) 140px minmax(0, 1.2fr) auto; gap: 6px; align-items: center; margin-bottom: 6px; }

/* ── SYNC CONFLICTS ──────────────────────────────────── */
.conflict-row { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; background: var(--surface2); }
.conflict-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; margin-bottom: 6px; }
.conflict-by { margin-left: auto; font-size: 11px; color: var(--text-muted); }
.conflict-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-bottom: 8px; }
.conflict-table th { text-align: left; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; padding: 4px 8px; border-bottom: 1px solid var(--border); }
.conflict-table td { padding: 5px 8px; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
.conflict-table td:first-child { font-weight: 600; white-space: nowrap; width: 1%; }
.conflict-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ── RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 1100px) {
  .app-version-badge { display: none; }
  /* The label is a bare text node the JS rewrites: only a zero font size can hide it. */
  .btn-compact { gap: 0; padding: 8px 11px; font-size: 0; }
  .btn-compact::before { font-size: 14px; content: attr(data-icon); }
  .app-header { gap: 10px; padding: 0 12px; }
  .org-logo { max-width: 96px; margin-left: 10px; }
  .nav-tab { padding: 0 9px; font-size: 13px; }
}
/* The phone (PLAN §2, §6): the header stacks, a modal takes the screen, a table becomes a list of cards.
   Nothing here may make the page scroll sideways. */
@media (max-width: 768px) {
  /* Two rows: the mark, the base and the account; then the tabs. A sticky header may not eat the screen. */
  .app-header { height: auto; grid-template-columns: auto minmax(0, 1fr) auto; padding: 8px 12px 0; gap: 4px 10px; }
  .app-logo { grid-area: 1 / 1; font-size: 0; }
  .app-logo-mark { margin-right: 0; }
  /* The organisation's logo stands for the mark: the base selector keeps the room. */
  .app-logo:has(.org-logo:not([hidden])) .app-logo-mark { display: none; }
  .org-logo { height: 30px; max-width: 72px; margin-left: 0; }
  .head-scope { grid-area: 1 / 2; min-width: 0; }
  .head-scope label { display: none; }
  .head-scope .settings-text-input { flex: 1; min-width: 0; }
  .header-right { grid-area: 1 / 3; gap: 4px; }
  .nav-tabs-wrap { grid-area: 2 / 1 / 3 / -1; height: 40px; }
  .nav-back { width: 40px; height: 36px; }
  /* Zoom is the pinch's business on a phone, and the sync status is its own button. */
  #nav-zoom-display, .header-divider, #btn-sync { display: none; }
  .sync-status { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; min-height: 40px; font-size: 13px; }
  .page { padding: 14px 12px; }
  .form-2col, .rule-grid { grid-template-columns: 1fr; }
  .modal-overlay { padding: 0; align-items: stretch; }
  .modal, .modal[style] { max-width: none !important; max-height: none; height: 100%; border: none; border-radius: 0; padding: 20px 16px; }
  .modal-footer .btn { justify-content: center; width: 100%; }
  .modal-footer { gap: 6px; flex-direction: column; }
  /* Stacked, the action comes first and the deletion last. */
  .modal-footer-split { flex-direction: column-reverse; }
  .modal-footer-main { flex-direction: column-reverse; width: 100%; margin: 0; gap: 6px; }
  .modal-footer > div { flex-direction: column; width: 100%; }
  .sc-row { grid-template-columns: 1fr 1fr; }
  .panel-actions { width: 100%; }
  .conflict-actions { flex-direction: column; }
  /* A table: the search first, the filters behind a button, a row per card — its name, then its `phone`
     fields. */
  .tbl-top { flex-wrap: nowrap; padding: 8px 12px; }
  .tbl-top .panel-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tbl-top .panel-actions { width: auto; flex-wrap: nowrap; flex-shrink: 0; gap: 4px; }
  .tbl-top .btn { gap: 0; min-width: 40px; justify-content: center; }
  .tbl-top .btn-label { display: none; }
  /* A card has no columns to choose. */
  .tbl-top [data-act="openColumns"], .tbl-toolbar [data-act="tblColumns"], .tbl-view-reset { display: none; }
  .tbl-toolbar { padding: 10px 12px; }
  .tbl-toolbar .btn-label, .tbl-view span { display: none; }
  .tbl-toolbar .btn { min-width: 40px; justify-content: center; }
  .tbl-search { flex: 1 1 100%; }
  .tbl-view { flex: 1 1 120px; }
  .tbl-view-select { width: 100%; max-width: none; min-width: 0; }
  .tbl-filter-toggle { display: inline-flex; }
  .tbl-filters.open { display: flex; flex-direction: column; gap: 6px; width: 100%; }
  .tbl-filter-field { display: grid; grid-template-columns: 112px minmax(0, 1fr); align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
  .tbl-scroll { overflow: visible; }
  .tbl { min-width: 0 !important; width: auto !important; }
  .tbl thead, .tbl td.col-desk, .tbl td:empty { display: none; }
  .tbl, .tbl tbody { display: block; }
  .tbl tr { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
  .tbl td { padding: 0; border: none; overflow: visible; white-space: normal; overflow-wrap: anywhere; font-size: 12.5px; }
  .tbl td.tbl-name { order: -1; flex: 1 1 100%; font-size: 14px; }
  .tbl td.tbl-pick { position: absolute; top: 0; right: 4px; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; }
  .tbl tr:has(.tbl-pick) td.tbl-name { padding-right: 40px; }
  .tbl-none td { padding: 4px 0; }
  .imp-mapping, .cols-free-row { grid-template-columns: 1fr; }
  .mv-period { flex-wrap: wrap; }
  .mv-period input { flex: 1 1 120px; width: auto; }
  .mv-seg { flex-wrap: wrap; width: 100%; }
  .mv-seg button { flex: 1 1 auto; min-height: 40px; }
}
/* A finger is not a pointer: 40 px targets, and 16 px in the fields — below it, iOS zooms the page on focus. */
@media (pointer: coarse) {
  .btn, .seg button, .pf-filter-select, .settings-text-input, .form-row input, .form-row select { min-height: 40px; }
  .btn-icon, .btn-gear { width: 40px; height: 40px; }
  .settings-text-input, .form-row input, .form-row select, .form-row textarea { font-size: 16px; }
  .check-row { min-height: 40px; margin-bottom: 4px; }
  .check-row input, .toggle-switch { flex-shrink: 0; }
  .check-row input[type="checkbox"], .sc-row input[type="checkbox"] { width: 20px; height: 20px; }
  .hdr-menu button, .cal-dd label { padding-top: 11px; padding-bottom: 11px; }
  .cal-dd label { min-height: 40px; box-sizing: border-box; }
  .cal-dd input[type="checkbox"] { width: 20px; height: 20px; flex-shrink: 0; }
  .th-sort { min-height: 40px; }
  .row-pick { width: 20px; height: 20px; }
  .imp-prev td { padding-top: 11px; padding-bottom: 11px; }
}

/* ── Maintenance (lot 5): the mode switch, the dues, the calendar, the card's block ── */
.mt-mode { margin-bottom: 12px; }
.form-3col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.mt-done-row { display: flex; gap: 6px; align-items: center; }
.mt-done-row input { flex: 1; min-width: 0; }
.mt-next { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 8px; font-size: 13px; }
.mt-next .settings-hint { margin: 0; }
.mt-left { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }
.fl-papers { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0 0 8px; font-size: 13px; }
.fl-period { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.profile-tasks { grid-column: 1 / -1; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--border); }
.cal-dow { background: var(--surface2); padding: 6px 8px; font-size: 11.5px; font-weight: 600; color: var(--text-muted); text-transform: capitalize; }
.cal-day { background: var(--surface); min-height: 88px; padding: 4px 6px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-other { background: color-mix(in srgb, var(--surface2) 60%, var(--surface)); }
.cal-other .cal-num { color: var(--text-muted); }
.cal-num { font-size: 11.5px; font-weight: 600; align-self: flex-end; }
.cal-today .cal-num { background: var(--accent); color: #fff; border-radius: 999px; min-width: 20px; height: 20px; line-height: 20px; text-align: center; }
.cal-entry { display: block; width: 100%; max-width: 100%; text-align: left; border: none; border-radius: 6px; padding: 3px 6px; font: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-more { font-size: 11px; color: var(--text-muted); }
.cal-nodate { padding: 10px 16px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; border-top: 1px solid var(--border); }
.cal-nodate .cal-entry { width: auto; }
@media (max-width: 768px) {
  .form-3col { grid-template-columns: 1fr; }
  .cal-grid { grid-template-columns: 1fr; }
  .cal-dow, .cal-day.cal-empty { display: none; }
  .cal-day { min-height: 0; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 8px 12px; }
  .cal-num { align-self: center; min-width: 32px; }
  .cal-entry { flex: 1 1 100%; min-height: 40px; display: flex; align-items: center; }
}

/* Inventories (lot 6): a campaign's head, its figures as filters, and the count — one equipment per screen,
   big targets, made for a phone in a warehouse. */
.ic-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.ic-head .settings-hint { margin: 0; }
.btn-back { background: var(--accent-light); color: color-mix(in srgb, var(--accent) 65%, var(--text)); border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent); font-weight: 600; }
.btn-back:hover { background: color-mix(in srgb, var(--accent) 24%, transparent); }
.ic-note { margin: -4px 0 12px; }
.kpi-card.kpi-on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.ic-lose { margin-left: 6px; min-height: 0; padding: 2px 8px; font-size: 11.5px; }
#cn-search { width: 100%; margin-bottom: 8px; }
.cn-picks { margin-bottom: 8px; }
.cn-item { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; margin: 4px 0 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface2); }
.cn-code { font-size: 14px; }
.cn-desc { font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.cn-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mv-seg.cn-seg { display: flex; width: 100%; }
.cn-seg button { flex: 1 1 0; min-height: 44px; font-size: 13px; }
.cn-verdict { display: flex; gap: 10px; margin-top: 14px; }
.cn-verdict .cn-big { flex: 1 1 0; min-height: 52px; font-size: 15px; font-weight: 600; }
.cn-done { padding: 24px 8px; text-align: center; font-weight: 600; }
.cn-nav { display: inline-flex; gap: 8px; }
/* Scanning: the header's button, the count's beside its search; the camera's picture with a frame to aim at,
   a photo of the label where there is no live camera, then a code typed (or a scanner's). */
.btn-scan:hover { transform: none; }
/* The reminders (PLAN §2): the header's bell, its count on its corner. */
.btn-reminders { position: relative; }
.btn-reminders:hover { transform: none; }
.btn-reminders .nav-badge { position: absolute; top: -7px; right: -7px; margin: 0; }
.cn-find { display: flex; gap: 8px; margin-bottom: 8px; }
.cn-find #cn-search { flex: 1; min-width: 0; margin-bottom: 0; }
.btn-scan-sm { flex-shrink: 0; width: 40px; padding: 0; justify-content: center; }
.scan-live { position: relative; overflow: hidden; margin-bottom: 10px; border-radius: 10px; background: #000; aspect-ratio: 4 / 3; }
.scan-live video { display: block; width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; inset: 15% 25%; border: 3px solid rgba(255, 255, 255, .85); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .3); pointer-events: none; }
.scan-photo { width: 100%; min-height: 52px; margin-bottom: 10px; justify-content: center; }
.scan-typed { display: flex; gap: 8px; margin-top: 10px; }
.scan-typed input { flex: 1; min-width: 0; }
@media (max-width: 768px) {
  .cn-modal .modal-footer-split { flex-direction: column; gap: 8px; }
  .cn-nav, .cn-modal .modal-footer-main { flex-direction: row; width: 100%; gap: 8px; }
  .cn-nav .btn, .cn-modal .modal-footer-main .btn { flex: 1 1 0; width: auto; }
}

/* Photos and documents (PLAN §3.6): a strip of thumbnails, the button that adds one, a viewer over the form. */
.att-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.att-thumb { position: relative; width: 80px; height: 80px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: var(--surface2); }
.att-open { display: block; width: 100%; height: 100%; padding: 0; border: none; background: none; cursor: zoom-in; }
.att-open img { display: block; width: 100%; height: 100%; object-fit: cover; }
.att-open img:not([src]) { visibility: hidden; }
.att-file .att-open { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px; cursor: pointer; color: var(--text); }
.att-file-icon { font-size: 26px; line-height: 1; }
.att-file-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--text-muted); }
.att-thumb.att-wait::before { content: '⏳'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--text-muted); pointer-events: none; }
.att-thumb.att-pending::after { content: '↑'; position: absolute; left: 4px; bottom: 4px; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; line-height: 18px; text-align: center; pointer-events: none; }
/* A 40 px target (PLAN §10), the circle drawn smaller in its corner. */
.att-remove { position: absolute; top: 0; right: 0; width: 40px; height: 40px; padding: 0 0 6px 6px; border: none; background: radial-gradient(circle at 23px 17px, rgba(0, 0, 0, .65) 12px, transparent 13px); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; }
/* A label, so that it opens the camera; not a form label for all that. */
.form-row label.att-add, .att-add { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; margin: 0; text-transform: none; letter-spacing: normal; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; }
.ph-modal { max-width: min(96vw, 1100px); padding: 12px; text-align: center; }
#ph-img { display: block; max-width: 100%; max-height: calc(100vh - 110px); margin: 0 auto; border-radius: 6px; object-fit: contain; }
/* Its buttons above what is shown: a PDF's reader takes the taps below. */
.ph-bar { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 8px; }
/* A PDF in the browser's own reader, in place of the image. */
#ph-doc { display: block; width: 100%; height: calc(100vh - 110px); border: none; border-radius: 6px; background: #fff; }
.ph-modal.ph-pdf { width: min(96vw, 1100px); }
.ph-modal.ph-pdf #ph-img, .ph-modal:not(.ph-pdf) #ph-doc, .ph-modal:not(.ph-pdf) #ph-save { display: none; }
@media (max-width: 768px) {
  #ph-img { max-height: calc(100vh - 90px); }
  #ph-doc { height: calc(100vh - 90px); }
}

/* The dashboard (lot 6b): the figures of the selection, then panels two by two — one column on a phone. */
.db-kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.db-kpis .kpi-card { justify-content: flex-start; }
.kpi-sub.db-alert, .db-sub.db-alert { color: color-mix(in srgb, var(--ink-warn) 75%, var(--text)); }
.db-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.db-grid .panel { margin-bottom: 0; }
.db-wide { grid-column: 1 / -1; }
.db-none { margin: 0; }
.db-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.db-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.db-list { list-style: none; }
.db-line { display: grid; grid-template-columns: minmax(0, 1fr) 48px 104px; gap: 2px 14px; align-items: baseline; width: 100%; padding: 8px 6px; border: 0; border-bottom: 1px solid var(--border); background: none; color: var(--text); font: inherit; text-align: left; }
.db-list > li:last-child, .db-list > li:last-child > .db-line, .db-list > li:last-child .db-item { border-bottom: 0; }
.db-link { cursor: pointer; min-height: 40px; }
.db-link:hover, .db-link:focus-visible { background: var(--surface2); }
.db-link .db-name::after { content: ' ›'; color: var(--text-muted); }
.db-crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-bottom: 8px; }
.db-crumbs .settings-hint { margin: 0; }
.db-split { display: flex; height: 16px; border-radius: 5px; overflow: hidden; background: var(--border); margin-bottom: 6px; }
.db-split > span { height: 100%; }
.db-split > span + span { box-shadow: inset 1px 0 0 var(--surface); }
.db-chart { margin-left: auto; }
.db-donut { display: block; width: 170px; height: 170px; margin: 4px auto 10px; }
.db-arc { fill: none; stroke-width: 18; }
.db-arc[data-act] { cursor: pointer; }
.db-arc[data-act]:hover { opacity: .8; }
.db-donut-total { text-anchor: middle; font-size: 10px; font-weight: 700; fill: var(--text); }
.db-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.db-line > .kpi-bar, .db-line > .db-sub { grid-column: 1 / -1; }
.db-line > .kpi-bar { margin: 4px 0 0; }
.db-head { padding-top: 0; font-size: 11px; font-weight: 600; color: var(--text-muted); }
.db-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-total { border-top: 2px solid var(--border); }
.db-total > span { font-weight: 700; }
.db-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.db-sub { font-size: 11.5px; color: var(--text-muted); }
.db-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: start; width: 100%; min-height: 40px; padding: 8px 6px; background: none; border: 0; border-bottom: 1px solid var(--border); color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.db-item:hover, .db-item:focus-visible { background: var(--surface2); }
.db-item > .kpi-bar, .db-item > .db-sub, .db-flags { grid-column: 1 / -1; }
.db-item > .kpi-bar { margin: 4px 0 0; }
.db-what { min-width: 0; }
.db-what .db-sub { display: block; }
.db-end { text-align: right; white-space: nowrap; }
.db-flags { display: flex; flex-wrap: wrap; gap: 4px; }
.db-flags > span { padding: 1px 8px; border-radius: 10px; font-size: 11px; }
@media (max-width: 768px) {
  .db-grid { grid-template-columns: 1fr; }
}

/* The field app (phone.js): on a phone, the field page alone — the header one row high, without the tab strip,
   the bell or the scan (the page has them), and the page's tabs fixed at the bottom with their icons. */
body.phone .nav-tabs-wrap, body.phone #btn-scan, body.phone #btn-reminders { display: none; }
body.phone .app-header { min-height: 56px; padding: 8px 12px; align-items: center; }
body.phone .page { padding-bottom: calc(var(--fd-tabbar-h) + 16px + env(safe-area-inset-bottom)); }
body.phone .toast, body.phone .undo-toast { bottom: calc(var(--fd-tabbar-h) + 12px + env(safe-area-inset-bottom)); }
:root { --fd-tabbar-h: 60px; }
.fd-tabbar { display: none; }
body.phone .fd-tabbar:not([hidden]) { position: fixed; left: 0; right: 0; bottom: 0; z-index: 150; display: flex; height: calc(var(--fd-tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--border); }
.fd-tab { position: relative; flex: 1; min-width: 0; min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 0 4px; background: none; border: 0; color: var(--text-muted); font: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer; }
.fd-tab[hidden] { display: none; }
.fd-tab.active { color: var(--accent); }
.fd-tab > span:not(.nav-badge) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fd-tab-icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.fd-tab .nav-badge { position: absolute; top: 4px; left: calc(50% + 6px); margin: 0; }
.fd-search { display: flex; gap: 8px; margin-bottom: 8px; }
.fd-search input { flex: 1; min-width: 0; min-height: 44px; font-size: 16px; }
.fd-scan { min-width: 48px; justify-content: center; }
.fd-hint { padding: 8px 2px; }
/* A line of the field page is a card to tap: raised, a chevron, pressed under the finger. */
#page-field .db-list { display: flex; flex-direction: column; gap: 8px; }
#page-field .db-item { position: relative; min-height: 60px; align-items: center; padding: 12px 34px 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 1px 3px color-mix(in srgb, var(--shadow) 30%, transparent); font-size: 14px; -webkit-tap-highlight-color: transparent; transition: background .1s, transform .1s; }
#page-field .db-item::after { content: '›'; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 24px; line-height: 1; color: var(--text-muted); }
#page-field .db-item:active { background: var(--surface2); transform: scale(.985); }
#page-field .fd-count { padding-right: 14px; }
#page-field .fd-count::after { content: none; }
.fd-go { padding: 5px 12px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 13px; font-weight: 600; white-space: nowrap; }
.fc-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.fc-acts { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 14px; }
.fc-act { min-height: 48px; gap: 8px; font-size: 14px; white-space: normal; text-align: left; }
.fc-facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; margin-top: 14px; font-size: 13px; }
.fc-facts dt { color: var(--text-muted); }
.fc-facts dd { margin: 0; overflow-wrap: anywhere; }
