/* Crmula base styles. Themes switch through [data-theme]; Arabic flips through dir="rtl". */
:root {
  --brand: #0E7C7B;
  --bg: #F3F5F7;
  --surface: #FFFFFF;
  --surface-2: #F7F9FA;
  --text: #0F1B2D;
  --muted: #52627A;
  --border: #E1E6EC;
  --accent: #0E7C7B;
  --accent-text: #FFFFFF;
  --link: #0B6E6D;
  --side-bg: #0F1B2D;
  --side-text: #C9D3E0;
  --side-active: #1E2D44;
  --ok-bg: #D7EAEA; --ok-text: #084F4E;
  --off-bg: #EEF1F4; --off-text: #52627A;
  --danger-bg: #FDE8E8; --danger-text: #9B1C1C;
  --radius: 12px;
  --focus: 0 0 0 3px rgba(14, 124, 123, .35);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0B111A; --surface: #151E2B; --surface-2: #1A2433; --text: #E6ECF3; --muted: #9AA8BA; --border: #243246;
  --accent: #3CC7C4; --accent-text: #06201F; --link: #7FD4D2; --side-bg: #070C14; --side-text: #B6C2D2; --side-active: #1C2738;
  --ok-bg: #133B3B; --ok-text: #8FE0DE; --off-bg: #243246; --off-text: #B6C2D2; --danger-bg: #3A1616; --danger-text: #F5B4B4;
  color-scheme: dark;
}
[data-theme="contrast"] {
  --bg: #FFFFFF; --surface: #FFFFFF; --surface-2: #FFFFFF; --text: #000000; --muted: #222222; --border: #000000;
  --accent: #000000; --accent-text: #FFFFFF; --link: #0000CC; --side-bg: #000000; --side-text: #FFFFFF; --side-active: #333333;
  --ok-bg: #FFFFFF; --ok-text: #000000; --off-bg: #FFFFFF; --off-text: #000000;
  --focus: 0 0 0 3px #FFB000;
}
[data-theme="brand"] {
  --accent: var(--brand); --link: var(--brand); --side-bg: var(--brand); --side-text: rgba(255,255,255,.88); --side-active: rgba(0,0,0,.22);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", Tahoma, sans-serif;
}
a { color: var(--link); }
h1, h2 { line-height: 1.25; margin: 0 0 .75rem; }
h2 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }

/* Shell */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.sidebar {
  flex: 1 1 220px; max-width: 250px; background: var(--side-bg); color: var(--side-text);
  padding: 20px 12px; display: flex; flex-direction: column; gap: 2px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; color: #fff; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
[data-theme="brand"] .brand-mark { background: rgba(255,255,255,.2); color: #fff; }
.brand-logo { max-height: 36px; max-width: 120px; border-radius: 6px; background: #fff; padding: 2px; }
.brand-name { font-weight: 600; }
.nav-link { display: block; padding: 9px 12px; border-radius: 8px; color: var(--side-text); text-decoration: none; }
.nav-link:hover, .nav-link.is-active { background: var(--side-active); color: #fff; }
.nav-group { margin: 16px 12px 6px; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; opacity: .7; }
.sidebar-foot { margin-top: auto; padding: 16px 8px 0; font-size: .72rem; opacity: .75; }
.main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 18px 28px; border-bottom: 1px solid var(--border); background: var(--surface); }
.page-title { font-size: 1.35rem; margin: 0; }
.topbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.who { display: flex; flex-direction: column; line-height: 1.2; font-size: .9rem; }
.who small { color: var(--muted); }
.content { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 20px; max-width: 1200px; width: 100%; }
.inline { display: inline; }

/* Components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.muted-card { background: var(--surface-2); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; display: flex; flex-direction: column; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat strong { font-size: 1.6rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 0; }
.facts dt { color: var(--muted); font-size: .85rem; }
.facts dd { margin: 0; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px 20px; }
.span-2 { grid-column: 1 / -1; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.search input { min-width: 260px; }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: .9rem; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 11px; min-height: 42px;
}
input[type="color"] { padding: 4px; width: 80px; }
input:disabled, select:disabled { background: var(--surface-2); color: var(--muted); }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin: 0; }
legend { font-weight: 600; padding: 0 6px; }
.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; }
.check input { min-height: auto; width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.check span { display: flex; flex-direction: column; }
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px 20px; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 16px; border-radius: 8px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; border: 1px solid transparent; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn:hover { filter: brightness(.95); }

.flash { margin: 0; padding: 12px 16px; border-radius: 10px; background: var(--ok-bg); color: var(--ok-text); }
.flash-error { background: var(--danger-bg); color: var(--danger-text); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.pill-ok { background: var(--ok-bg); color: var(--ok-text); }
.pill-off { background: var(--off-bg); color: var(--off-text); }

.table-wrap { overflow-x: auto; }
.table-wrap.card { padding: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
.matrix td:not(:first-child), .matrix th:not(:first-child) { text-align: center; }
.matrix input { width: 18px; height: 18px; min-height: auto; accent-color: var(--accent); }
.plain { margin: 0; padding-inline-start: 18px; display: flex; flex-direction: column; gap: 6px; }

.theme-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.theme-option { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.theme-option input { min-height: auto; accent-color: var(--accent); }
.swatch { width: 28px; height: 20px; border-radius: 5px; border: 1px solid var(--border); flex: none; }
.swatch-light { background: linear-gradient(90deg, #0F1B2D 35%, #F3F5F7 35%); }
.swatch-dark { background: linear-gradient(90deg, #070C14 35%, #151E2B 35%); }
.swatch-contrast { background: linear-gradient(90deg, #000 35%, #fff 35%); }
.swatch-brand { background: linear-gradient(90deg, var(--brand) 35%, #F3F5F7 35%); }

.logo-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.logo-preview { max-height: 56px; max-width: 160px; border: 1px solid var(--border); border-radius: 8px; padding: 4px; background: #fff; }

/* Sign-in */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login-brand { display: flex; gap: 12px; align-items: center; }
.login-company { font-weight: 700; font-size: 1.1rem; }
.login-card h1 { font-size: 1.3rem; margin: 6px 0 0; }
.login-lang { display: flex; justify-content: center; }

@media (max-width: 720px) {
  .sidebar { max-width: none; flex-basis: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; }
  .brand { padding: 0 8px 0 0; flex-basis: 100%; margin-bottom: 8px; }
  .nav-group, .sidebar-foot { display: none; }
  .topbar, .content { padding-inline: 16px; }
  .search input { min-width: 0; width: 100%; }
}

/* Stage 2: tasks, notifications, reminders */
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: #F28C4A; color: #1B0E05; font-size: .75rem; font-weight: 700; text-align: center; margin-inline-start: 6px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tab { padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--text); border: 1px solid var(--border); background: var(--surface); }
.tab.is-active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.toolbar-right { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.stat-link { text-decoration: none; color: inherit; }
.stat-link:hover { border-color: var(--accent); }
.pill.st-new { background: #E6E9F2; color: #2B3A67; }
.pill.st-in_progress { background: var(--ok-bg); color: var(--ok-text); }
.pill.st-sent_back { background: #FFF4CC; color: #6B4E00; }
.pill.st-done { background: #DCF3E4; color: #14532D; }
.pill.st-denied { background: var(--danger-bg); color: var(--danger-text); }
.pill.st-cancelled { background: var(--off-bg); color: var(--off-text); }
[data-theme="dark"] .pill.st-new { background: #232B45; color: #B9C3F0; }
[data-theme="dark"] .pill.st-sent_back { background: #3A3214; color: #F5D98A; }
[data-theme="dark"] .pill.st-done { background: #143322; color: #9BE0B5; }
.pr-high { color: #B4430B; }
.pr-urgent { color: #C62828; }
[data-theme="dark"] .pr-high { color: #F6B38A; }
[data-theme="dark"] .pr-urgent { color: #F5B4B4; }
.btn-danger { background: #C62828; color: #fff; }
.flash-warn { background: #FFF4CC; color: #6B4E00; }
[data-theme="dark"] .flash-warn { background: #3A3214; color: #F5D98A; }
.task-layout { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.task-layout > .stack { flex: 999 1 520px; min-width: 0; }
.task-layout > aside { flex: 1 1 260px; display: flex; flex-direction: column; gap: 10px; }
.task-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.task-title { margin: 4px 0 0; font-size: 1.2rem; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0 0; }
.side-facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0 0 6px; font-size: .92rem; }
.side-facts dt { color: var(--muted); }
.side-facts dd { margin: 0; font-weight: 600; }
.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; align-items: end; }
.action-form { display: flex; flex-direction: column; gap: 8px; }
.action-form textarea { min-height: 60px; }
.timeline { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.timeline li { border-inline-start: 3px solid var(--border); padding-inline-start: 12px; }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-list li { padding: 14px 20px; border-bottom: 1px solid var(--border); }
.notif-list li:last-child { border-bottom: 0; }
.notif-list li.unread { border-inline-start: 4px solid var(--accent); }
.notif-list a { font-weight: 600; }
.reminder-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
textarea { resize: vertical; }

.pill { white-space: nowrap; }

/* Stage 3: leads, companies, stages */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters input[type="search"] { flex: 1 1 240px; min-width: 0; }
.num { text-align: end; }
tfoot td { background: var(--surface-2); font-size: .9rem; border-bottom: 0; }
.btn-small { min-height: 34px; padding: 0 10px; font-size: .85rem; }
.inline-h { display: inline; margin: 0; font-size: 1.05rem; }
details > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸"; color: var(--muted); }
details[open] > summary::before { content: "▾"; }
[dir="rtl"] details > summary::before { content: "◂"; }
[dir="rtl"] details[open] > summary::before { content: "▾"; }
/* Date ranges ("start → end") read from the start in both directions: the arrow turns in right-to-left pages. */
.dir-arrow { display: inline-block; }
[dir="rtl"] .dir-arrow { transform: scaleX(-1); }
.edit-form, .upload-form { margin-top: 16px; }
.upload-form { border-top: 1px solid var(--border); padding-top: 16px; }
.aside-h { font-size: .95rem; margin: 8px 0 0; }
.contact-card { display: flex; flex-direction: column; gap: 2px; }
.stat-warn { border-color: #E6B800; }
.flash-warn-card { background: #FFF8DB; border-color: #F0D77A; }
[data-theme="dark"] .flash-warn-card { background: #2E2810; border-color: #5C4E1A; }
.pill.ls-open { background: var(--ok-bg); color: var(--ok-text); }
.pill.ls-won { background: #DCF3E4; color: #14532D; }
.pill.ls-lost { background: var(--danger-bg); color: var(--danger-text); }
[data-theme="dark"] .pill.ls-won { background: #143322; color: #9BE0B5; }

.steps { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; }
.steps li { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-weight: 600; font-size: .9rem; }
.steps li.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.steps li.is-done { color: var(--ok-text); background: var(--ok-bg); border-color: transparent; }
.company-strip { display: flex; flex-direction: column; gap: 10px; }

.stage-strip { list-style: none; margin: 0; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(110px, 1fr); gap: 4px; overflow-x: auto; }
.stage-strip li { padding: 10px 12px; background: var(--off-bg); color: var(--off-text); font-size: .85rem; font-weight: 600; white-space: nowrap; }
.stage-strip li:first-child { border-start-start-radius: 8px; border-end-start-radius: 8px; }
.stage-strip li:last-child { border-start-end-radius: 8px; border-end-end-radius: 8px; }
.stage-strip li.is-done { background: var(--ok-bg); color: var(--ok-text); }
.stage-strip li.is-active { background: var(--accent); color: var(--accent-text); }

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 6px; align-items: start; }
.board-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.board-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 4px 4px 6px; border-bottom: 1px solid var(--border); }
.board-card { display: flex; flex-direction: column; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; color: var(--text); text-decoration: none; }
.board-card:hover { border-color: var(--accent); }
.board-title { font-weight: 600; }
.board-meta { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }

.stage-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; justify-content: space-between; }
.stage-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; flex: 999 1 520px; }
.stage-form label { flex: 1 1 140px; min-width: 0; }
.stage-form input { width: 100%; min-width: 0; }
.stage-form .btn { flex: none; }
.stage-num { width: 32px; height: 32px; border-radius: 16px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; flex: none; margin-bottom: 5px; }
.stage-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

bdi[dir="ltr"] { unicode-bidi: isolate; }

/* Page codes (removable in Settings) */
.page-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-code { display: inline-block; font: 600 .72rem/1.6 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; letter-spacing: .04em;
  padding: 1px 8px; border-radius: 6px; background: #FFF1C2; color: #5B4300; border: 1px solid #E8CF7A; white-space: nowrap; }
[data-theme="dark"] .page-code { background: #3A3214; color: #F5D98A; border-color: #6B5A1E; }
.page-code-float { position: fixed; top: 10px; inset-inline-end: 12px; z-index: 5; }
.codes-table td, .codes-table th { padding: 8px 16px; }
.checks-days { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }

/* Drag and drop */
.board-list { display: flex; flex-direction: column; gap: 8px; min-height: 64px; flex: 1; }
.board-col { transition: background-color .15s, border-color .15s; }
.board-col.is-drop-over { border-color: var(--accent); background: var(--ok-bg); }
.board-card[data-draggable="true"] { cursor: grab; -webkit-user-drag: none; -webkit-touch-callout: none; user-select: none; }
.board-card.is-dragging, .stage-row.is-dragging { opacity: .35; }
.drag-ghost { position: fixed; top: 0; left: 0; z-index: 50; pointer-events: none; box-shadow: 0 10px 28px rgba(15, 27, 45, .22); opacity: .95; cursor: grabbing; }
body.is-drag-active, body.is-drag-active * { cursor: grabbing !important; user-select: none; }
.drag-handle { cursor: grab; color: var(--muted); font-size: 1.1rem; line-height: 1; padding: 10px 6px; margin-bottom: 4px; touch-action: none; user-select: none; -webkit-touch-callout: none; letter-spacing: -2px; }
.sr-status { position: fixed; inset-inline-start: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; margin: 0;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s; }
[dir="rtl"] .sr-status { transform: translateX(50%); }
.sr-status.is-visible { opacity: 1; }
.drag-hint { margin: 0; }

/* Stage 4: projects */
.pill.ps-awaiting_assignment { background: #FFF4CC; color: #6B4E00; }
.pill.ps-planning { background: #E6E9F2; color: #2B3A67; }
.pill.ps-in_progress { background: var(--ok-bg); color: var(--ok-text); }
.pill.ps-completed { background: #DCF3E4; color: #14532D; }
.pill.ps-cancelled { background: var(--off-bg); color: var(--off-text); }
[data-theme="dark"] .pill.ps-awaiting_assignment { background: #3A3214; color: #F5D98A; }
[data-theme="dark"] .pill.ps-planning { background: #232B45; color: #B9C3F0; }
[data-theme="dark"] .pill.ps-completed { background: #143322; color: #9BE0B5; }
a.pill { text-decoration: none; }

.time-block { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--border); padding-top: 14px; }
.time-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.time-bar { position: relative; height: 14px; border-radius: 7px; background: var(--off-bg); overflow: visible; }
.time-fill { position: absolute; inset-block: 0; inset-inline-start: 0; width: 0; border-radius: 7px; background: var(--accent); }
.time-bar.is-overdue .time-fill { background: #C62828; }
.time-mark { position: absolute; top: -4px; width: 2px; height: 22px; background: #B4430B; inset-inline-start: 0; }
.mini-bar { display: block; height: 6px; border-radius: 3px; background: var(--off-bg); overflow: hidden; margin-top: 4px; }
.mini-bar > span { display: block; height: 6px; width: 0; background: var(--accent); }

.sheet-form { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 16px; }
.line-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.line-form label { flex: 1 1 110px; min-width: 0; }
.line-form label.grow { flex: 3 1 220px; }
.line-form label.wide { flex: 1 1 150px; }
.line-form input, .line-form select { width: 100%; min-width: 0; }
.sheet-tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 14px; }
.sheet-tools .action-form { flex-direction: row; flex-wrap: wrap; align-items: end; }
.sheet-tools .action-form label { flex: 1 1 180px; }
.send-box { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.inline-action { display: inline; }
.team-form { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 16px; }
.invite-box { margin-top: 16px; padding: 14px 16px; border-radius: 10px; background: #FFF8DB; border: 1px solid #F0D77A; display: flex; flex-direction: column; gap: 10px; }
.invite-box h3 { margin: 0; font-size: 1rem; }
[data-theme="dark"] .invite-box { background: #2E2810; border-color: #5C4E1A; }
.ext-list li { padding: 10px 0; border-bottom: 1px solid var(--border); list-style: none; }
.ext-list { padding: 0; }
.ext-list li:last-child { border-bottom: 0; }

/* ---------- Categories, chips and the Lists page (CO-1, CO-3, CP-9) ---------- */
.cat-teal { --c: #0E8A88; } .cat-blue { --c: #2563EB; } .cat-indigo { --c: #4F46E5; } .cat-purple { --c: #8B3FD9; }
.cat-pink { --c: #D63A82; } .cat-red { --c: #D33A3A; } .cat-orange { --c: #E06A12; } .cat-amber { --c: #C08A00; }
.cat-green { --c: #2E9147; } .cat-gray { --c: #6B7A8F; }
.cat-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c, #6B7A8F); flex: none; margin-inline-end: 6px; vertical-align: baseline; }
.cat-pill { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap;
  background: color-mix(in srgb, var(--c, #6B7A8F) 15%, var(--surface)); color: color-mix(in srgb, var(--c, #6B7A8F) 70%, var(--text)); }
[data-theme="contrast"] .cat-pill { background: #fff; color: #000; border: 1px solid #000; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.chip { display: inline-flex; align-items: center; gap: 2px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); text-decoration: none; font-size: .88rem; }
.chip:hover { border-color: var(--accent); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip.is-active .cat-dot { box-shadow: 0 0 0 2px var(--surface); }
.chip-n { color: var(--muted); font-size: .8rem; margin-inline-start: 4px; }
.chip.is-active .chip-n { color: inherit; opacity: .85; }
.chip-link { border-style: dashed; color: var(--link); }

.board-head strong { display: block; min-width: 0; }
.board-head strong .cat-dot { vertical-align: 0; }
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; }
.is-hidden-item { opacity: .6; }

.tabs-wrap { margin-bottom: 14px; }
.list-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.list-head h2 { margin-bottom: 4px; }
.list-rows { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin: 10px 0 16px; }
.list-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.list-row .drag-handle { margin: 0; padding: 6px 4px; }
.list-row.is-dragging { opacity: .35; }
.list-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: 999 1 420px; min-width: 0; }
.list-form input { flex: 1 1 150px; min-width: 0; }
.list-form .color-select { flex: 0 1 130px; min-width: 0; }
.list-form .btn { flex: none; }
.list-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: 1 0 auto; justify-content: flex-end; }
.list-tools form { margin: 0; }
.list-add { padding: 12px; border: 1px dashed var(--border); border-radius: 10px; background: var(--surface-2); }
.list-add-title { flex: 1 0 100%; }
.link-tiles { display: flex; flex-wrap: wrap; gap: 10px; }
.link-tile { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); text-decoration: none; }
.link-tile:hover { border-color: var(--accent); }
@media (max-width: 720px) {
  .list-tools { justify-content: flex-start; }
}

/* ---------- Button rows, pop-out details, history, certificates, contacts (CO-2, CT-*, LD-5) ---------- */
.button-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.button-row form { margin: 0; }
.sub-h { font-size: .95rem; margin: 18px 0 8px; }
details.pop { position: relative; }
details.pop > summary, details.history-block > summary { list-style: none; cursor: pointer; }
details.pop > summary::-webkit-details-marker, details.history-block > summary::-webkit-details-marker { display: none; }
details.pop[open] > summary { border-color: var(--accent); background: var(--ok-bg); color: var(--ok-text); }
.pop-body { margin-top: 10px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); min-width: min(420px, 85vw); }
.button-row details.pop[open] { flex: 1 1 100%; }
details.history-block > summary { display: inline-flex; }
details.history-block[open] > summary { margin-bottom: 12px; border-color: var(--accent); background: var(--ok-bg); color: var(--ok-text); }
.contact-box { display: flex; flex-wrap: wrap; gap: 12px 32px; align-items: flex-start; }
.contact-box .contact-card { min-width: 180px; font-size: 1rem; }
.cert-ok { color: #14532D; } .cert-warn { color: #8A5A00; } .cert-bad { color: var(--danger-text); font-weight: 600; }
[data-theme="dark"] .cert-ok { color: #8FE0B0; } [data-theme="dark"] .cert-warn { color: #F2C14E; }
.lock { font-size: .85em; }
.board-card[data-draggable="false"] { cursor: pointer; }
.toolbar .grow, .filters .grow { flex: 1 1 260px; }
.link-contact-form { margin-top: 14px; align-items: end; }
.link-contact-form label { display: flex; flex-direction: column; gap: 4px; }
details.pop > summary::before, details.history-block > summary::before { content: none; }
details.history-block > summary::after { content: "▾"; margin-inline-start: 6px; color: var(--muted); }
details.history-block[open] > summary::after { content: "▴"; }
[hidden] { display: none !important; }
.kept-file { display: block; padding: 8px 10px; margin: 4px 0 6px; border: 1px dashed var(--accent); border-radius: 8px; background: var(--ok-bg); color: var(--ok-text); font-size: .9rem; }
td details.pop .pop-body { min-width: 260px; max-width: 320px; }
td details.pop textarea { width: 100%; }

/* ---------- Stage 5: management dashboard (DB-2) ---------- */
:root { --s1: #00908C; --s2: #C26A1E; --warn-mark: #C62828; --grid: #E6EAEF; }
[data-theme="dark"] { --s1: #13A39F; --s2: #D17A30; --warn-mark: #F07171; --grid: #243246; }
[data-theme="contrast"] { --s1: #000000; --s2: #6B6B6B; --warn-mark: #B00000; --grid: #BBBBBB; }
[data-theme="brand"] { --s1: var(--brand); }
.db-toolbar { margin-bottom: -8px; }
.db-range { margin: 0; }
.db-section { font-size: 1.15rem; margin: 8px 0 -4px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; }
.kpi strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-sub { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.delta { font-weight: 600; }
.delta-up { color: #1D7A3E; } .delta-down { color: #B3261E; } .delta-flat { color: var(--muted); }
[data-theme="dark"] .delta-up { color: #7FD69B; } [data-theme="dark"] .delta-down { color: #F5A3A3; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.link-card { display: block; text-decoration: none; color: inherit; }
.link-card:hover { border-color: var(--accent); }
.link-card p { margin: 0; }

.chart-scroll { overflow-x: auto; }
.chart { display: block; width: 100%; min-width: 560px; height: auto; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--muted); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .col.s1, .bar-fill.s1, .key.s1 { fill: var(--s1); background: var(--s1); }
.chart .col.s2, .bar-fill.s2, .key.s2 { fill: var(--s2); background: var(--s2); }
.chart .col:hover, .bar-fill:hover { opacity: .8; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.chart-data { margin-top: 8px; font-size: .9rem; }
.chart-data summary { color: var(--link); }
.chart-data table { margin-top: 8px; }

.bar-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.bar-rows li { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label value" "bar bar"; gap: 4px 12px; align-items: baseline; }
.bar-label { grid-area: label; min-width: 0; overflow-wrap: anywhere; }
.bar-value { grid-area: value; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-track { grid-area: bar; display: block; width: 100%; height: 10px; }
.bar-bg { fill: var(--off-bg); }
.bar-fill.warn { fill: var(--warn-mark); }
.bar-rows li.is-warn .bar-value { color: var(--warn-mark); }
[dir="rtl"] .bar-track { transform: scaleX(-1); }
.bar-inline { height: 6px; margin-top: 6px; max-width: 220px; }

.team-table td { vertical-align: middle; }
.deal-list { list-style: none; margin: 0; padding: 0; }
.deal-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.deal-list li:first-child { padding-top: 0; }
.deal-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.deal-list a { font-weight: 600; overflow-wrap: anywhere; }
.deal-value { font-weight: 600; white-space: nowrap; }
.deal-meta { grid-column: 1 / -1; }
.late { color: var(--warn-mark); font-weight: 600; white-space: nowrap; }
.pill-warn { background: #FFF4CC; color: #6B4E00; }
[data-theme="dark"] .pill-warn { background: #3A3110; color: #F2D77A; }

/* ---------- Stage 5.1: sales targets (CP-10), sales and branch dashboards (DB-3, DB-4) ---------- */
.filter-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--ok-bg); color: var(--ok-text); font-size: .85rem; }

.tgt-wrap { max-width: 100%; }
.tgt-grid { border-collapse: separate; border-spacing: 0; min-width: 1180px; }
.tgt-grid th, .tgt-grid td { padding: 6px 6px; white-space: nowrap; }
.tgt-grid thead th { position: sticky; top: 0; z-index: 1; }
.tgt-grid thead th.is-now { color: var(--accent); }
.tgt-grid .tgt-name { position: sticky; inset-inline-start: 0; z-index: 2; background: var(--surface); text-align: start; min-width: 170px; max-width: 220px;
  white-space: normal; font-weight: 600; text-transform: none; letter-spacing: 0; font-size: .9rem; color: var(--text);
  box-shadow: inset -1px 0 0 var(--border); }
[dir="rtl"] .tgt-grid .tgt-name { box-shadow: inset 1px 0 0 var(--border); }
.tgt-grid thead .tgt-name { background: var(--surface-2); color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; z-index: 3; }
.tgt-grid .tgt-group th { background: var(--surface-2); color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; text-align: start; padding: 8px 12px; position: static; }
.tgt-grid .tgt-group th:first-child { position: static; }
.tgt-group-name { position: sticky; inset-inline-start: 12px; }
.tgt-input { width: 106px; min-height: 34px; padding: 4px 6px; text-align: end; font-variant-numeric: tabular-nums; direction: ltr; }
[dir="rtl"] .tgt-input { text-align: start; }
.tgt-ro { display: inline-block; min-width: 106px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tgt-sum { background: var(--surface-2); font-variant-numeric: tabular-nums; }
.tgt-year { font-weight: 700; }
.tgt-branch .tgt-name, .tgt-team .tgt-name { font-weight: 700; }
.tgt-team td { font-weight: 600; font-variant-numeric: tabular-nums; border-bottom-width: 2px; }
.tgt-grid td.is-over { color: var(--warn-mark); background: var(--danger-bg); }
.tgt-copy { align-items: center; }
.tgt-copy label { font-weight: 600; }

.tgt-table td { vertical-align: middle; }
.tgt-table .tgt-total td { background: var(--surface-2); }
.ach-col { min-width: 170px; }
.ach { display: grid; grid-template-columns: 3.2em minmax(80px, 1fr); align-items: center; gap: 8px; }
.ach .tgt-bar { grid-area: auto; width: 100%; }
.tgt-table td, .tgt-table th { white-space: nowrap; }
.tgt-table td:first-child { white-space: normal; min-width: 150px; }
.hygiene-table td:first-child a { white-space: nowrap; }
.ach .num { font-weight: 600; font-variant-numeric: tabular-nums; }
.tgt-bar { overflow: visible; }
.pace-mark { fill: var(--text); }
.pace-key { display: inline-block; width: 2px; height: 12px; background: var(--text); vertical-align: middle; }
.legend-note { margin: 10px 0 0; }
.kpis-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 14px; }
.kpis-4 .kpi strong { font-size: 1.2rem; }
.pill.pill-warn { text-decoration: none; }
@media (max-width: 720px) {
  /* The target table becomes one labelled card per row on a phone. */
  .tgt-table, .tgt-table tbody, .tgt-table tr, .tgt-table td { display: block; }
  .tgt-table thead { display: none; }
  .tgt-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
  .tgt-table td { padding: 0; border: 0; text-align: start; white-space: normal; min-width: 0; }
  .tgt-table td::before { content: attr(data-label); display: block; color: var(--muted); font-size: .72rem; }
  .tgt-table .tgt-who, .tgt-table .ach-col { grid-column: 1 / -1; }
  .tgt-table .tgt-who::before { content: none; }
  .tgt-table .tgt-total td { background: transparent; }
  .tgt-grid .tgt-name { min-width: 130px; max-width: 150px; }
  .db-toolbar .toolbar-right { width: 100%; }
}
@media print {
  .sidebar, .topbar-actions, .db-toolbar form, .chart-data summary { display: none; }
  .card, .stat { break-inside: avoid; }
}

/* ---------- Stage 5.2: technical (DB-5) and finance (DB-6) dashboards ---------- */
.pill-danger { background: var(--danger-bg); color: var(--danger-text); text-decoration: none; }
.card-head-sub { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.card-head-sub h3 { margin: 0; font-size: 1rem; }
.money-table tr.is-over td { background: var(--danger-bg); }
.money-table tr.is-over td:first-child { box-shadow: inset 3px 0 0 var(--warn-mark); }
[dir="rtl"] .money-table tr.is-over td:first-child { box-shadow: inset -3px 0 0 var(--warn-mark); }
.money-table tfoot td { font-weight: 700; font-variant-numeric: tabular-nums; }
.money-table td, .money-table th { white-space: nowrap; }
.money-table td:first-child { white-space: normal; min-width: 180px; }
.tgt-grid td.is-unchecked { background: var(--surface-2); outline: 1px dashed var(--muted); outline-offset: -3px; }
.card .stats + .deal-list { margin-top: 16px; }
@media (max-width: 720px) {
  /* Dashboard tables with several figures become one labelled card per row on a phone. */
  .stack-table, .stack-table tbody, .stack-table tfoot, .stack-table tr, .stack-table td { display: block; }
  .stack-table { min-width: 0; }
  .stack-table thead { display: none; }
  .stack-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; padding: 12px 8px; border-bottom: 1px solid var(--border); }
  .stack-table td { padding: 0; border: 0; text-align: start; white-space: normal; min-width: 0; }
  .stack-table td::before { content: attr(data-label); display: block; color: var(--muted); font-size: .72rem; }
  .stack-table td:first-child { grid-column: 1 / -1; min-width: 0; }
  .stack-table td:first-child::before { content: none; }
  .money-table tr.is-over td { background: transparent; }
  .money-table tr.is-over { background: var(--danger-bg); }
  .money-table tr.is-over td:first-child { box-shadow: none; }
  .money-table tr.is-over { box-shadow: inset 3px 0 0 var(--warn-mark); }
  [dir="rtl"] .money-table tr.is-over { box-shadow: inset -3px 0 0 var(--warn-mark); }
  .money-table tfoot tr { background: var(--surface-2); }
}

/* Stage 5.3: every DB-5 / DB-6 tile and card says whether it is as of today ("Now") or follows the period tabs. */
.when { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: .72rem; font-weight: 600; line-height: 1.5; white-space: nowrap; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); }
.when::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.when.when-period { background: var(--ok-bg); color: var(--ok-text); border-color: transparent; }
.when.when-period::before { border-radius: 1px; }
.when.when-both { background: var(--surface-2); color: var(--ok-text); }
[data-theme="contrast"] .when, [data-theme="contrast"] .when.when-period, [data-theme="contrast"] .when.when-both { background: #fff; color: #000; border-color: #000; }
/* The tag sits on its own line above the label, so narrow tiles keep their label readable. */
.stat .kpi-top { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; color: var(--muted); font-size: .85rem; }
.stat .kpi-top .kpi-label { color: var(--muted); font-size: .85rem; min-width: 0; order: 2; }
.stat .kpi-top .when { font-size: .68rem; order: 1; }
.card-when { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.late-compare { margin-top: 4px; }
.late-compare td:first-child { white-space: normal; }
.given-by-dept { display: block; margin-top: 2px; font-size: .78rem; color: var(--ok-text); background: var(--ok-bg); border-radius: 6px; padding: 1px 8px; width: fit-content; }
.db-notes p { margin: 0; }
.db-notes p + p { margin-top: 4px; }
tr.is-hidden-project td:first-child { font-style: italic; }
@media (max-width: 720px) {
  .late-compare tr { grid-template-columns: 1fr 1fr 1fr; }
}

/* Stage 6.1: forgot password, export, backups */
.login-forgot { margin: -4px 0 0; text-align: end; font-size: .92rem; }
.login-back { margin: 0; text-align: center; font-size: .92rem; }
.bk-intro p { margin: 0 0 8px; }
.bk-now { justify-content: flex-start; margin-top: 4px; }
.bk-name { font: .82rem/1.4 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; overflow-wrap: anywhere; direction: ltr; unicode-bidi: isolate; }
.bk-action { text-align: end; }
@media (max-width: 720px) {
  .bk-table thead { display: none; }
  .bk-table tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .bk-table td { border: 0; padding: 0; }
  .bk-table td.bk-action { grid-row: 1 / span 3; grid-column: 2; align-self: center; }
  .bk-table td::before { content: attr(data-label); display: block; color: var(--muted); font-size: .72rem; }
  .bk-table td.num { text-align: start; }
  .bk-table tfoot tr { display: block; }
}

/* Stage 6.2: suppliers, quotations and purchase orders */
.pill-row { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-static { cursor: default; }
.chips .chip { margin: 0; }
.supplier-form fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.supplier-form legend { font-weight: 600; padding: 0 6px; }
.pill.po-draft, .pill.qs-received { background: var(--off-bg); color: var(--off-text); }
.pill.po-waiting_approval { background: #FFF4CC; color: #6B4E00; }
.pill.po-approved, .pill.po-sent { background: #DCE8FB; color: #1E3A8A; }
.pill.po-partly_received { background: #FCE7D6; color: #7A3B0B; }
.pill.po-received, .pill.qs-chosen { background: var(--ok-bg); color: var(--ok-text); }
.pill.po-cancelled, .pill.qs-not_chosen { background: var(--danger-bg); color: var(--danger-text); }
[data-theme="dark"] .pill.po-waiting_approval { background: #3A3110; color: #F2D77A; }
[data-theme="dark"] .pill.po-approved, [data-theme="dark"] .pill.po-sent { background: #1B2B4A; color: #A9C4F5; }
[data-theme="dark"] .pill.po-partly_received { background: #3D2412; color: #F6C49A; }
[data-theme="contrast"] .pill[class*="po-"], [data-theme="contrast"] .pill[class*="qs-"] { background: #fff; color: #000; border: 1px solid #000; }

/* The quotation comparison: the item column stays in view while the suppliers scroll sideways. */
.cmp-wrap { border: 1px solid var(--border); border-radius: 10px; }
.cmp-table { min-width: 560px; }
.cmp-table th, .cmp-table td { padding: 10px 12px; }
.cmp-table .cmp-item { position: sticky; inset-inline-start: 0; background: var(--surface); z-index: 1; min-width: 160px; max-width: 260px; white-space: normal; }
.cmp-table thead .cmp-item { background: var(--surface-2); }
.cmp-table th.cmp-q { text-transform: none; letter-spacing: 0; font-size: .85rem; color: var(--text); min-width: 150px; vertical-align: bottom; }
.cmp-table td.num, .cmp-table th.num { white-space: nowrap; }
.cmp-table .is-chosen { background: color-mix(in srgb, var(--ok-bg) 55%, transparent); }
.cmp-table td.is-best { font-weight: 600; }
.cmp-table tfoot th, .cmp-table tfoot td { border-top: 1px solid var(--border); background: var(--surface-2); }
.cmp-table tfoot th { position: sticky; inset-inline-start: 0; z-index: 1; text-transform: none; letter-spacing: 0; font-size: .85rem; color: var(--text); }
.cmp-table tfoot td.is-chosen { background: color-mix(in srgb, var(--ok-bg) 70%, var(--surface-2)); }
.cmp-table .cmp-total td { font-size: 1rem; }
.cmp-table tfoot tr:last-child th, .cmp-table tfoot tr:last-child td { border-bottom: 0; }
.cmp-missing { font-style: italic; }
.best-tag { display: inline-block; margin-inline-start: 4px; padding: 0 6px; border-radius: 999px; background: var(--ok-bg); color: var(--ok-text); font-size: .7rem; font-weight: 700; vertical-align: middle; }
[data-theme="contrast"] .best-tag { border: 1px solid #000; }
.choose-list { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.choose-option { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; align-items: center; }
.check.choose-option > span { display: block; }
.choose-option.is-expired { opacity: .65; }
.chosen-card { border-inline-start: 4px solid var(--accent); }

/* Quotation lines (QT-2) */
.line-table td { padding: 6px 8px; }
.line-table td:first-child { min-width: 200px; width: 50%; }
.line-table td { vertical-align: middle; }
.line-table input { width: 100%; min-width: 0; }
.line-table td.num input { max-width: 140px; text-align: end; }
.quote-form fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.quote-form legend { font-weight: 600; padding: 0 6px; }
.quote-form .line-table tfoot td { font-variant-numeric: tabular-nums; }

/* Purchase order (PU-2) */
.po-lines tr.is-done td { color: var(--muted); }
.po-lines td { white-space: nowrap; }
.po-lines th { white-space: normal; }
.po-lines th, .po-lines td { padding-inline: 10px; }
.offer-row { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; margin: 0 0 10px; }
.offer-label { color: var(--muted); font-size: .85rem; min-width: 150px; }
.po-lines td:first-child { white-space: normal; min-width: 180px; }
.receive-table input { width: 110px; text-align: end; }
.receive-table td:first-child { min-width: 150px; }
.action-h { margin: 0; font-size: .95rem; }
.purchase-card .button-row { margin: 0; }

@media (max-width: 720px) {
  .line-table thead { display: none; }
  .line-table tr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .line-table td { border: 0; padding: 0; }
  .line-table td:first-child { grid-column: 1 / -1; min-width: 0; }
  .line-table td.num input { max-width: none; }
  .line-table tfoot tr { grid-template-columns: 2fr 1fr; }
  .line-table tfoot td { text-align: start; }
  .line-table tfoot td[colspan] { grid-column: auto; }
  .po-lines td:first-child { min-width: 0; }
  .po-lines tfoot tr { grid-template-columns: 1fr 1fr; }
  .po-lines tfoot td:empty { display: none; }
  .receive-table input { width: 90px; }
  .cmp-table .cmp-item { min-width: 120px; }
}

/* Stage 6.3: store and stock */
.item-code { font: 600 .82rem/1.4 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }
.pill.mv-receive, .pill.mv-return { background: var(--ok-bg); color: var(--ok-text); }
.pill.mv-issue { background: #DCE8FB; color: #1E3A8A; }
.pill.mv-adjust { background: #FFF4CC; color: #6B4E00; }
.pill.sc-open { background: #FFF4CC; color: #6B4E00; }
.pill.sc-applied { background: var(--ok-bg); color: var(--ok-text); }
.pill.sc-discarded { background: var(--off-bg); color: var(--off-text); }
[data-theme="dark"] .pill.mv-issue { background: #1B2B4A; color: #A9C4F5; }
[data-theme="dark"] .pill.mv-adjust, [data-theme="dark"] .pill.sc-open { background: #3A3110; color: #F2D77A; }
[data-theme="contrast"] .pill[class*="mv-"], [data-theme="contrast"] .pill[class*="sc-"] { background: #fff; color: #000; border: 1px solid #000; }
.mv-in { color: var(--ok-text); font-weight: 600; }
.mv-out { color: var(--danger-text); font-weight: 600; }
.stock-table tr.is-low td:first-child, .count-table tr.has-diff td:first-child { box-shadow: inset 3px 0 0 var(--warn-mark); }
[dir="rtl"] .stock-table tr.is-low td:first-child, [dir="rtl"] .count-table tr.has-diff td:first-child { box-shadow: inset -3px 0 0 var(--warn-mark); }
.stock-table tr.is-hidden-item td { color: var(--muted); }
.stock-table td.num, .materials-table td.num, .moves-table td.num, .count-table td.num { white-space: nowrap; }
.filter-check { align-self: center; white-space: nowrap; }
.item-stats { margin: 12px 0; }
.levels-table td.num { width: 30%; }
.moves-table td { vertical-align: top; }
.stock-tag { margin-top: 2px; }
.stock-tag a { text-decoration: none; }
.link-box { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.link-box select { max-width: 100%; }
.link-new { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.link-new[hidden] { display: none; }
.link-new input { width: 100%; min-width: 0; }
.receive-loc { max-width: 360px; margin-bottom: 8px; }
.materials-table select { max-width: 220px; }
.materials-table input { width: 90px; text-align: end; }
.materials-table tr.is-done td { color: var(--muted); }
.count-table input { width: 110px; text-align: end; }
.count-actions { flex-wrap: wrap; }
.adjust-dir { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }
.adjust-dir legend { font-size: .85rem; color: var(--muted); padding: 0; margin-bottom: 4px; }
.return-form { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.return-form h3 { margin: 0; font-size: 1rem; }
.moves-details { margin-top: 12px; }
.moves-details summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.moves-details li { padding: 6px 0; border-bottom: 1px solid var(--border); }
details.card > summary { cursor: pointer; }
details.card > summary h2 { display: inline; margin: 0; }
details.card[open] > summary { margin-bottom: 12px; }
.loc-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.loc-row input[name="name_en"], .loc-row input[name="name_ar"] { flex: 1 1 180px; min-width: 0; }
.loc-table td { padding: 8px 0; }
.loc-table thead { display: none; }
.loc-add { margin-top: 12px; }
@media (max-width: 720px) {
  .link-new { grid-template-columns: 1fr 1fr; }
  .materials-table select { max-width: none; width: 100%; }
  .materials-table input, .count-table input { width: 100%; }
  .stock-table tr.is-low, .count-table tr.has-diff { box-shadow: inset 3px 0 0 var(--warn-mark); }
  [dir="rtl"] .stock-table tr.is-low, [dir="rtl"] .count-table tr.has-diff { box-shadow: inset -3px 0 0 var(--warn-mark); }
  .stock-table tr.is-low td:first-child, .count-table tr.has-diff td:first-child { box-shadow: none; }
}

.spread { display: block; }
.spread-loc + .spread-loc::before { content: " · "; }
.receive-table .link-new input { width: 100%; text-align: start; }
.mat-lines { list-style: none; margin: 0; padding: 0; }
.mat-line { padding: 12px 0; border-bottom: 1px solid var(--border); }
.mat-line.is-done .mat-name { color: var(--muted); }
.mat-head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; justify-content: space-between; }
.mat-name { font-weight: 600; }
.mat-facts { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 6px 0 0; }
.mat-facts div { display: flex; gap: 6px; align-items: baseline; }
.mat-facts dt { color: var(--muted); font-size: .8rem; }
.mat-facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.mat-issue { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) minmax(0, 1fr); gap: 8px; margin-top: 10px; }
.mat-issue:not(:has(.mat-item)) { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); max-width: 520px; }
.mat-issue label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; min-width: 0; }
.mat-issue select, .mat-issue input { width: 100%; min-width: 0; }
.mat-issue input { text-align: end; }
@media (max-width: 720px) {
  .receive-table thead { display: none; }
  .receive-table, .receive-table tbody, .receive-table tr, .receive-table td { display: block; }
  .receive-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
  .receive-table td { padding: 0; border: 0; text-align: start; }
  .receive-table td:first-child { grid-column: 1 / -1; }
  .receive-table td::before { content: attr(data-label); display: block; color: var(--muted); font-size: .72rem; }
  .receive-table td:first-child::before { content: none; }
  .receive-table td input { width: 100%; }
  .link-new { grid-template-columns: 1fr 1fr; }
  .mat-issue, .mat-issue:not(:has(.mat-item)) { grid-template-columns: 1fr 1fr; max-width: none; }
  .mat-issue .mat-item { grid-column: 1 / -1; }
}
.moves-table td a, .mat-facts a { white-space: nowrap; }

/* Stage 6.4: customer quotations */
.pill.sq-draft { background: var(--off-bg); color: var(--off-text); }
.pill.sq-waiting_approval { background: #FFF4CC; color: #6B4E00; }
.pill.sq-approved, .pill.sq-sent { background: #DCE8FB; color: #1E3A8A; }
.pill.sq-accepted { background: var(--ok-bg); color: var(--ok-text); }
.pill.sq-rejected { background: var(--danger-bg); color: var(--danger-text); }
.pill.sq-superseded { background: var(--off-bg); color: var(--off-text); text-decoration: line-through; }
[data-theme="dark"] .pill.sq-waiting_approval { background: #3A3110; color: #F2D77A; }
[data-theme="dark"] .pill.sq-approved, [data-theme="dark"] .pill.sq-sent { background: #1B2B4A; color: #A9C4F5; }
[data-theme="contrast"] .pill[class*="sq-"] { background: #fff; color: #000; border: 1px solid #000; }
.sq-form fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.sq-form legend { font-weight: 600; padding: 0 6px; }
.sq-lines { display: flex; flex-direction: column; gap: 10px; }
.sq-line { display: grid; grid-template-columns: minmax(0, 3fr) repeat(3, minmax(88px, 1fr)) minmax(124px, max-content); gap: 8px 10px; align-items: end;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.sq-line label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; min-width: 0; }
.sq-line input, .sq-line textarea, .sq-line select { width: 100%; min-width: 0; }
.sq-line input[type="number"] { text-align: end; }
.sq-line-head { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }
.sq-line-n { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: .8rem; font-weight: 700; }
.sq-desc { grid-column: 1 / -1; order: 9; }
.sq-desc textarea { resize: vertical; min-height: 2.4em; }
.sq-line-total { display: flex; flex-direction: column; gap: 4px; text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; padding-bottom: 8px; }
.sq-cost { grid-column: 1 / -1; order: 10; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr); gap: 8px 10px; align-items: end;
  border-top: 1px dashed var(--border); padding-top: 8px; }
.sq-cost small { grid-column: 1 / -1; }
.sq-sums { display: grid; grid-template-columns: max-content max-content; gap: 4px 18px; justify-content: end; margin: 6px 0 0; font-variant-numeric: tabular-nums; }
.sq-sums > div { display: contents; }
.sq-sums dt { color: var(--muted); text-align: end; }
.sq-sums dd { margin: 0; text-align: end; white-space: nowrap; }
.sq-sums .sq-grand dt, .sq-sums .sq-grand dd { font-weight: 700; color: var(--text); font-size: 1.05rem; }
.sq-sums .sq-cost-sum dt, .sq-sums .sq-cost-sum dd { font-size: .9rem; }
.sq-sums .sq-cost-sum:first-of-type dt, .sq-sums .sq-cost-sum:first-of-type dd { border-top: 1px dashed var(--border); padding-top: 4px; }
[data-limit-live] { margin: 0; text-align: end; }
.sq-lead-table tr.is-accepted td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
[dir="rtl"] .sq-lead-table tr.is-accepted td:first-child { box-shadow: inset -3px 0 0 var(--accent); }
.sq-versions li { padding: 4px 0; }
.sq-versions li.is-current { font-weight: 600; }
.sq-lines-table td .pre { white-space: pre-wrap; }
@media (max-width: 720px) {
  .sq-line { grid-template-columns: 1fr 1fr; }
  .sq-item { grid-column: 1 / -1; }
  .sq-line-total { text-align: start; padding-bottom: 0; }
  .sq-cost { grid-template-columns: 1fr 1fr; }
  .sq-cost-src { grid-column: 1 / -1; }
  .sq-sums { justify-content: stretch; grid-template-columns: 1fr max-content; }
  .sq-sums dt { text-align: start; }
  [data-limit-live] { text-align: start; }
  .sq-lead-table tr.is-accepted { box-shadow: inset 3px 0 0 var(--accent); }
  .sq-lead-table tr.is-accepted td:first-child { box-shadow: none; }
}
.sq-lines-table th, .sq-cost-table th { white-space: normal; }
.sq-lines-table th, .sq-lines-table td, .sq-cost-table th, .sq-cost-table td { padding-inline: 8px; }
.sq-lines-table td:first-child, .sq-cost-table td:first-child { min-width: 150px; }
@media (max-width: 720px) {
  .sq-lines-table tfoot tr, .sq-cost-table tfoot tr { grid-template-columns: 1fr auto; align-items: baseline; padding: 8px; }
  .sq-lines-table tfoot td:first-child, .sq-cost-table tfoot td:first-child { grid-column: auto; }
  .sq-lines-table tfoot td.num, .sq-cost-table tfoot td.num { text-align: end; white-space: nowrap; }
  .sq-lines-table tfoot td.num::before { content: none; }
  .sq-cost-table tfoot tr { grid-template-columns: 1fr 1fr; }
  .sq-cost-table tfoot td:first-child { grid-column: 1 / -1; }
}

/* Stage 6.5: invoices, payments, receivables */
.pill.inv-draft { background: var(--off-bg); color: var(--off-text); }
.pill.inv-issued { background: #DCE8FB; color: #1E3A8A; }
.pill.inv-partly_paid { background: #FFF4CC; color: #6B4E00; }
.pill.inv-paid { background: #DCF3E4; color: #14532D; }
.pill.inv-cancelled { background: var(--off-bg); color: var(--off-text); text-decoration: line-through; }
.pill.rc-recorded { background: #DCF3E4; color: #14532D; }
.pill.rc-void { background: var(--off-bg); color: var(--off-text); }
[data-theme="dark"] .pill.inv-issued { background: #1B2B4A; color: #A9C4F5; }
[data-theme="dark"] .pill.inv-partly_paid { background: #3A3110; color: #F2D77A; }
[data-theme="dark"] .pill.inv-paid, [data-theme="dark"] .pill.rc-recorded { background: #143524; color: #9BE3B5; }
[data-theme="contrast"] .pill[class*="inv-"], [data-theme="contrast"] .pill[class*="rc-"] { background: #fff; color: #000; border: 1px solid #000; }
.inv-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 16px; margin: 4px 0 14px; }
.inv-figures > div { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface-2); min-width: 0; }
.inv-figures > div.is-warn { border-color: var(--warn-mark); }
.inv-figures dt { color: var(--muted); font-size: .8rem; }
.inv-figures dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.inv-figures dd small { display: block; font-weight: 400; }
.inv-progress { position: relative; height: 12px; border-radius: 999px; background: var(--grid); overflow: hidden; margin: 2px 0 6px; }
.inv-bar { position: absolute; inset-block: 0; inset-inline-start: 0; width: 0; border-radius: 999px; }
.inv-bar-invoiced { background: var(--s1); opacity: .35; }
.inv-bar-collected { background: var(--s1); }
.inv-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0 0 12px; }
.inv-legend .key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--s1); }
.inv-legend .key-invoiced { opacity: .35; }
.inv-new { margin-top: 14px; }
.inv-new > summary { display: inline-flex; }
.inv-new > summary::before { content: none; }
.inv-new[open] > summary { margin-bottom: 12px; }
.inv-new-form fieldset { display: flex; flex-direction: column; gap: 10px; }
.inv-table tr.is-void td { color: var(--muted); text-decoration: line-through; }
.inv-table tr.is-void td .pill { text-decoration: none; }
.inv-vat-note p { margin: 0; }
.inv-vat-note p + p { margin-top: 4px; }
.flash-note { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.inline-end { display: flex; justify-content: flex-end; margin-top: -8px; }
.inv-terms-form { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; align-items: end; }
.inv-terms-form label { display: flex; flex-direction: column; gap: 4px; }
.inv-terms-form input { max-width: 160px; }
.inv-terms-form small { flex: 1 1 100%; }
.rc-form fieldset { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.alloc-input { width: 140px; max-width: 100%; text-align: end; }
.st-table tr.st-opening td, .st-print tr.st-opening td { color: var(--muted); font-style: italic; }
.st-aging th, .st-aging td { text-align: center; }
.ar-table td:first-child { min-width: 180px; }
@media (max-width: 720px) {
  .inv-figures { grid-template-columns: 1fr 1fr; }
  .alloc-input { width: 100%; }
  .st-aging, .st-aging tbody, .st-aging tr { display: block; }
  .st-aging tr { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .st-aging th, .st-aging td { padding: 6px 4px; font-size: .78rem; }
  .inline-end { justify-content: flex-start; margin-top: 0; }
}
.list-head > .btn, .list-head > a.btn { white-space: nowrap; flex: none; }
.inv-kpis .stat { min-width: 0; }
.inv-kpis .stat strong { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
@media (max-width: 720px) { .inv-kpis .stat strong { font-size: 1.15rem; } }

/* Stage 6.6: leave, employee files and HR letters */
.pill-bad { background: var(--danger-bg); color: var(--danger-text); }
.pill.lv-pending_manager, .pill.lv-pending_hr { background: #FFF4CC; color: #6B4E00; }
.pill.lv-approved, .pill.hl-issued { background: #DCF3E4; color: #14532D; }
.pill.lv-rejected, .pill.hl-not_issued { background: var(--danger-bg); color: var(--danger-text); }
.pill.lv-cancelled { background: var(--off-bg); color: var(--off-text); }
.pill.hl-requested { background: #E6E9F2; color: #2B3A67; }
[data-theme="dark"] .pill.lv-pending_manager, [data-theme="dark"] .pill.lv-pending_hr { background: #3A3214; color: #F5D98A; }
[data-theme="dark"] .pill.lv-approved, [data-theme="dark"] .pill.hl-issued { background: #143322; color: #9BE0B5; }
[data-theme="dark"] .pill.hl-requested { background: #232B45; color: #B9C3F0; }
.lv-flag { margin-inline-start: 6px; font-weight: 600; white-space: normal; }
.hr-sub { font-size: .95rem; margin: 16px 0 8px; }
.hr-badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.hr-expiries li { line-height: 1.6; }
.hr-table td:first-child { min-width: 200px; }
.hr-table td:first-child .pill { margin-top: 4px; }
.lv-letters li { line-height: 1.8; }
.lv-month-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lv-month { margin: 0 6px; font-size: 1.1rem; min-width: 9em; text-align: center; }
.lv-cal-card { padding: 0; overflow: hidden; }
.lv-cal-wrap { max-width: 100%; position: relative; }
.lv-cal { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
.lv-cal th, .lv-cal td { padding: 0; border-bottom: 1px solid var(--border); border-inline-end: 1px solid var(--border); text-align: center; }
.lv-cal thead th { font-size: .72rem; text-transform: none; letter-spacing: 0; padding: 6px 0; min-width: 27px; font-weight: 600; color: var(--text); }
.lv-cal thead th span { display: block; color: var(--muted); font-weight: 500; font-size: .66rem; }
.lv-cal td { height: 34px; min-width: 27px; position: relative; }
.lv-cal .who { position: sticky; inset-inline-start: 0; z-index: 1; background: var(--surface); text-align: start; padding: 6px 12px; min-width: 140px; max-width: 180px; font-weight: 600; font-size: .85rem; text-transform: none; letter-spacing: 0; color: var(--text); }
.lv-cal thead .who { background: var(--surface-2); }
.lv-cal .who small { display: block; color: var(--muted); font-weight: 400; font-size: .72rem; }
.lv-cal .off { background: var(--surface-2); }
.lv-cal td.off { background-image: repeating-linear-gradient(135deg, transparent 0 4px, rgba(127, 127, 127, .10) 4px 6px); }
.lv-cal .today { box-shadow: inset 0 0 0 2px var(--accent); }
.lv-cal td.on { background: var(--accent); background-image: none; }
.lv-cal td.on.t-sick { background: #D17A30; }
.lv-cal td.on.t-unpaid { background: #7A8699; }
.lv-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0; padding: 10px 16px; color: var(--muted); border-top: 1px solid var(--border); }
.lv-key { display: inline-block; width: 16px; height: 12px; border-radius: 3px; border: 1px solid var(--border); vertical-align: middle; }
.lv-key.on { background: var(--accent); }
.lv-key.off { background: var(--surface-2); background-image: repeating-linear-gradient(135deg, transparent 0 3px, rgba(127, 127, 127, .25) 3px 5px); }
.lv-away li { line-height: 1.7; }
.lv-type-new { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); align-items: end; }
.lv-types input[type="number"] { max-width: 120px; }
.lv-bal-grid th small { display: block; font-weight: 400; text-transform: none; letter-spacing: 0; }
.lv-bal-grid th[scope="row"] { background: var(--surface); text-transform: none; letter-spacing: 0; font-size: .88rem; color: var(--text); white-space: nowrap; }
.lv-bal-grid th[scope="row"] small { color: var(--muted); font-size: .72rem; }
.lv-cell { display: flex; gap: 6px; margin-bottom: 4px; }
.lv-cell input { width: 74px; min-height: 36px; padding: 6px 8px; text-align: end; }
.lv-cell input.is-default { color: var(--muted); font-style: italic; }
.hr-letter-form { margin-top: 14px; padding-top: 6px; border-top: 1px solid var(--border); }
@media (max-width: 720px) {
  .lv-cal .who { min-width: 110px; max-width: 130px; padding: 6px 8px; }
  .lv-cal thead th, .lv-cal td { min-width: 26px; }
  .lv-month { min-width: 0; }
  .hr-badges { justify-content: flex-start; }
  .lv-types input[type="number"] { max-width: none; }
}
.lv-compact li { line-height: 1.9; }

/* Stage 6.7: maintenance contracts, tickets with their SLA clock, planned visits and site visit reports. */
.sla { display: inline-block; font-weight: 600; font-size: .85rem; white-space: nowrap; }
.sla-ok { color: var(--ok-text); }
.sla-warn { color: #8A5A00; }
.sla-bad { color: var(--warn-mark); }
.sla-paused { color: var(--muted); font-weight: 500; }
[data-theme="dark"] .sla-warn { color: #F5D98A; }
.bar-fill.amber { fill: #D99A1E; }
.sla-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.sla-block { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: grid; gap: 6px; min-width: 0; }
.sla-block.is-breached { border-color: var(--warn-mark); box-shadow: inset 3px 0 0 var(--warn-mark); }
[dir="rtl"] .sla-block.is-breached { box-shadow: inset -3px 0 0 var(--warn-mark); }
.sla-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sla-block .bar-track { width: 100%; height: 10px; display: block; }
.sla-table { width: auto; min-width: 0; }
.sla-table th, .sla-table td { padding: 6px 10px; }
.sla-table input { width: 7.5em; }
tr.is-breached td:first-child { box-shadow: inset 3px 0 0 var(--warn-mark); }
[dir="rtl"] tr.is-breached td:first-child { box-shadow: inset -3px 0 0 var(--warn-mark); }
.mc-sites li, .mc-company li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.mc-sites li:last-child, .mc-company li:last-child { border-bottom: 0; }
.mc-sites li form { margin-inline-start: auto; }
.mc-add { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.mc-import-pick { margin-top: 12px; align-items: end; }
.mc-import { margin-top: 10px; display: grid; gap: 10px; }
.checks-col { display: grid; gap: 6px; }
.sr-times { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sr-list li { padding: 8px 0; border-bottom: 1px solid var(--border); display: grid; gap: 4px; }
.sr-list li:last-child { border-bottom: 0; }
.sr-add > summary { list-style: none; display: inline-flex; margin-top: 8px; cursor: pointer; }
.sr-add > summary::-webkit-details-marker { display: none; }
.sr-add[open] > summary { margin-bottom: 10px; }
.tk-note { margin-top: 12px; }
@media (max-width: 720px) {
  .sla-grid { grid-template-columns: 1fr; }
  .sla-table input { width: 100%; min-width: 4.5em; }
  .sr-times { grid-template-columns: 1fr 1fr; }
  .stack-table tr.is-breached { box-shadow: inset 3px 0 0 var(--warn-mark); }
  [dir="rtl"] .stack-table tr.is-breached { box-shadow: inset -3px 0 0 var(--warn-mark); }
  .stack-table tr.is-breached td:first-child { box-shadow: none; }
}

/* Stage 6.8: the Crmula.com platform */
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--link); text-decoration: underline; cursor: pointer; text-align: start; }
.tf-pill { font-size: .68rem; padding: 0 6px; vertical-align: middle; }
.ia-banner { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; padding: 10px 28px; background: #FFF4CC; color: #5A4100; border-bottom: 1px solid #F0D98A; font-weight: 600; font-size: .9rem; }
[data-theme="dark"] .ia-banner { background: #3A3110; color: #F2D77A; border-color: #5a4a14; }
[data-theme="contrast"] .ia-banner { background: #FFB000; color: #000; }

/* Public site */
.web { max-width: 1180px; margin: 0 auto; padding: 0 24px 40px; }
.web-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 18px 0; }
.web-brand { display: inline-flex; gap: 10px; align-items: center; font-weight: 800; font-size: 1.2rem; color: var(--text); text-decoration: none; }
.web-nav { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.web-hero { padding: 36px 0 24px; max-width: 780px; }
.web-hero h1 { font-size: clamp(1.7rem, 4vw, 2.6rem); line-height: 1.15; margin-bottom: 14px; }
.web-lead { font-size: 1.08rem; color: var(--muted); margin: 0 0 16px; }
.web-points { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 0; margin: 0; list-style: none; font-weight: 600; }
.web-points li::before { content: "✓ "; color: var(--accent); }
.web-plans { padding-top: 22px; }
.web-plans h2 { font-size: 1.5rem; margin-bottom: 4px; }
.web-foot { text-align: center; padding-top: 28px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-top: 16px; align-items: start; }
.plan-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 22px 20px; display: flex; flex-direction: column; gap: 6px; }
.plan-card.is-highlighted { border: 2px solid var(--accent); box-shadow: 0 8px 28px rgba(14, 124, 123, .14); }
.plan-card h3 { margin: 0; font-size: 1.2rem; }
.plan-card .btn { margin: 8px 0 4px; justify-content: center; }
.plan-flag { position: absolute; inset-block-start: -11px; inset-inline-start: 18px; background: var(--accent); color: var(--accent-text); font-size: .72rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.plan-price { margin: 4px 0 0; }
.plan-price strong { font-size: 1.9rem; font-variant-numeric: tabular-nums; }
.plan-trial { color: var(--ok-text); font-weight: 600; margin: 0; }
.plan-features { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.plan-features li { display: flex; gap: 8px; align-items: baseline; }
.pf-mark { flex: none; width: 1.1em; text-align: center; font-weight: 800; color: var(--accent); }
.pf-off { color: var(--muted); }
.pf-off .pf-mark { color: var(--muted); }
.pf-addon .pf-mark { color: #B26B00; }
[data-theme="dark"] .pf-addon .pf-mark { color: #F2C14E; }
.pf-note { display: block; font-size: .78rem; color: var(--muted); }
.pf-soon { display: inline-block; font-size: .66rem; font-weight: 700; padding: 0 6px; border-radius: 999px; background: var(--off-bg); color: var(--off-text); vertical-align: middle; }
.signup-card { max-width: 520px; }

/* Plan cards editor (PL-3) */
.pv-legend { display: flex; flex-wrap: wrap; gap: 6px 22px; padding: 0; margin: 0 0 12px; list-style: none; color: var(--muted); }
.pv-legend strong { color: var(--text); font-variant-numeric: tabular-nums; }
.plan-editor { display: grid; grid-template-columns: repeat(auto-fit, minmax(235px, 1fr)); gap: 12px; align-items: start; }
.plan-edit label, .pv-row2 > label { min-width: 0; }
.plan-edit input:not([type="checkbox"]), .plan-edit select { min-width: 0; max-width: 100%; }
.pv-row2 input { width: 100%; }
.plan-edit.card { padding: 16px 14px; }
.plan-edit { display: flex; flex-direction: column; gap: 10px; margin: 0; min-width: 0; }
.plan-edit.is-highlighted { border-color: var(--accent); }
.pv-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pv-h { margin: 6px 0 0; font-size: .92rem; border-top: 1px solid var(--border); padding-top: 10px; }
.pv-line { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 8px; align-items: center; font-size: .86rem; }
.pv-line .pv-label { flex: 1 1 110px; }
.pv-label { min-width: 0; }
.pv-field { display: inline-flex; gap: 4px; align-items: center; }
.pv-field input { width: 62px; min-width: 0; text-align: end; font-variant-numeric: tabular-nums; padding-inline: 8px; }
.pv-field select { width: auto; padding-inline: 6px; }
.pv-field .btn-small { padding: 4px 7px; min-height: 0; line-height: 1; }
.pv-field.is-bad input { border-color: var(--danger-text); background: var(--danger-bg); }

/* Two-step sign-in */
.tf-steps { margin: 0; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 14px; }
.tf-qr { margin: 10px 0; }
.tf-qr svg { display: block; max-width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--border); }
.tf-secret { font: 1rem/1.5 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .06em; word-break: break-all; background: var(--surface-2); padding: 4px 8px; border-radius: 6px; }
.tf-confirm { margin-top: 8px; }
.code-input { font: 1.3rem/1.2 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .25em; text-align: center; max-width: 220px; }
.tf-codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; list-style: none; padding: 0; margin: 12px 0; }
.tf-codes code { display: block; font: .98rem ui-monospace, Menlo, Consolas, monospace; background: var(--surface-2); border: 1px dashed var(--border); border-radius: 8px; padding: 8px; text-align: center; }
.tf-codes-card { border-inline-start: 4px solid var(--accent); }

/* Company logo (CP-6) */
.logo-box { display: flex; flex-direction: column; gap: 12px; }
.logo-options { display: flex; flex-wrap: wrap; gap: 12px 18px; }
.logo-options label { min-width: 160px; }
.logo-previews { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.logo-previews figure { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.logo-icon-frame { width: 72px; height: 72px; border-radius: 14px; border: 1px solid var(--border); background: repeating-conic-gradient(#e9edf1 0 25%, #fff 0 50%) 0 0 / 14px 14px; display: grid; place-items: center; overflow: hidden; }
.logo-icon-frame img { width: 64px; height: 64px; }
.logo-doc-frame { width: min(320px, 100%); padding: 14px; border: 1px solid var(--border); border-radius: 8px; background: #fff; display: flex; flex-direction: column; gap: 8px; }
.logo-doc-frame img { max-height: 56px; max-width: 220px; object-fit: contain; align-self: flex-start; }
.logo-doc-line { display: block; height: 6px; border-radius: 3px; background: #e3e8ee; }
.logo-doc-line.short { width: 60%; }
@media (max-width: 720px) {
  .web { padding: 0 16px 32px; }
  .ia-banner { padding: 10px 16px; }
  .pv-row2 { grid-template-columns: 1fr 1fr; }
}

/* Stage 6.9: pages of a long list, and the note under a board column that draws only its first cards. */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin: 12px 0 4px; }
.pager-count { margin: 0; }
.pager-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; list-style: none; margin: 0; padding: 0; }
.pager-links a, .pager-current { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; min-height: 36px; padding: 0 10px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; }
.pager-links a:hover { border-color: var(--accent); }
.pager-current { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.pager-gap { color: var(--muted); padding: 0 2px; }
.board-more { margin: 0; padding: 4px 6px; }
@media print { .pager { display: none; } }
.er-table code { white-space: nowrap; }
.er-table summary { cursor: pointer; overflow-wrap: anywhere; }
.er-stack { margin: 8px 0 0; padding: 10px; max-height: 260px; overflow: auto; font-size: .8rem; white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }
.bk-checks { margin: 0 0 12px; padding-inline-start: 18px; }
tr.is-current td { background: var(--surface-2); }

/* ---------- Stage 6.10: requests for quotation, products, supplier portal ---------- */
.pill.rq-draft { background: var(--off-bg); color: var(--off-text); }
.pill.rq-sent { background: #DCE8FB; color: #1E3A8A; }
.pill.rq-award_pending { background: #FFF4CC; color: #6B4E00; }
.pill.rq-awarded { background: var(--ok-bg); color: var(--ok-text); }
.pill.rq-closed, .pill.rq-cancelled { background: var(--danger-bg); color: var(--danger-text); }
.pill.ri-sent { background: #DCE8FB; color: #1E3A8A; }
.pill.ri-viewed { background: #E6E9F2; color: #2B3A67; }
.pill.ri-responded { background: var(--ok-bg); color: var(--ok-text); }
.pill.ri-declined, .pill.ri-cancelled { background: var(--off-bg); color: var(--off-text); }
.pill.ri-late { background: var(--danger-bg); color: var(--danger-text); }
.pill.rn-requested { background: #FFF4CC; color: #6B4E00; }
.pill.rn-answered { background: var(--ok-bg); color: var(--ok-text); }
.pill.rn-expired { background: var(--off-bg); color: var(--off-text); }
[data-theme="dark"] .pill.rq-sent, [data-theme="dark"] .pill.ri-sent { background: #1B2B4A; color: #A9C4F5; }
[data-theme="dark"] .pill.rq-award_pending, [data-theme="dark"] .pill.rn-requested { background: #3A3110; color: #F2D77A; }
[data-theme="dark"] .pill.ri-viewed { background: #232B45; color: #B9C3F0; }
[data-theme="contrast"] .pill[class*="rq-"], [data-theme="contrast"] .pill[class*="ri-"], [data-theme="contrast"] .pill[class*="rn-"] { background: #fff; color: #000; border: 1px solid #000; }
.price-change { display: inline-block; font-size: .75rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.price-change.is-up { color: var(--danger-text); }
.price-change.is-down { color: #1E3A8A; }
[data-theme="dark"] .price-change.is-down { color: #A9C4F5; }
.price-alert-row td { background: color-mix(in srgb, var(--danger-bg) 45%, transparent); }
.rq-line-table td:first-child, .rq-line-table th:first-child { min-width: 0; width: 2.2em; color: var(--muted); }
.rq-line-table td:nth-child(2) { min-width: 140px; }
.rq-line-table td:nth-child(4) { min-width: 220px; width: 40%; }
.rq-line-table td:nth-child(6) input { width: 90px; }
.rq-line-table td:nth-child(7) input { width: 80px; }
.lookup-note { display: block; margin-top: 4px; }
.rq-n-inline { color: var(--muted); font-size: .85rem; }
.rq-cmp td .nego-check { margin-top: 6px; justify-content: flex-end; }
.rq-cmp select { min-width: 150px; }
.nego-forms, .award-form { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.nego-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; margin: 8px 0; }
.nego-form label { flex: 1 1 260px; }
.send-list { display: grid; gap: 10px; }
.send-row { display: grid; gap: 8px; padding: 14px 16px; }
.send-row.is-picked { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
[dir="rtl"] .send-row.is-picked { box-shadow: inset -4px 0 0 var(--accent); }
.send-row.is-done { opacity: .7; }
.send-contact { max-width: 460px; }
.scope-choice { border: 1px dashed var(--border); border-radius: 10px; padding: 8px 12px; display: grid; gap: 6px; }
.scope-choice legend { padding: 0 4px; font-weight: 600; }
.match-all { color: var(--ok-text); font-weight: 600; }
.match-some { color: #6B4E00; font-weight: 600; }
[data-theme="dark"] .match-some { color: #F2D77A; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; z-index: 2; }
.rfq-card { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.rfq-card h3 { margin: 0; }
.portal-box { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.portal-box h3 { margin: 0 0 4px; }
.portal-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 12px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.portal-row:last-child { border-bottom: 0; }
.checks-wide { max-height: 320px; overflow: auto; padding: 4px; border: 1px solid var(--border); border-radius: 10px; }
tr.is-target td, :target > td { background: color-mix(in srgb, var(--ok-bg) 60%, transparent); }

/* The supplier portal: a simple frame of its own, no staff menu. */
.sup-shell { min-height: 100vh; display: flex; flex-direction: column; }
.sup-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 16px; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.sup-brand { display: flex; align-items: center; gap: 10px; }
.sup-brand .brand-logo { width: 36px; height: 36px; object-fit: contain; border-radius: 8px; }
.sup-brand .brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; background: var(--accent); color: var(--accent-text); font-weight: 700; }
.sup-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.sup-actions .who { display: flex; flex-direction: column; line-height: 1.2; }
.sup-nav { display: flex; flex-wrap: wrap; gap: 4px 6px; padding: 8px 20px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.sup-link { padding: 6px 12px; border-radius: 999px; text-decoration: none; color: var(--text); font-weight: 500; }
.sup-link.is-active { background: var(--accent); color: var(--accent-text); }
.sup-main { flex: 1; width: 100%; max-width: 1040px; margin: 0 auto; padding: 20px 16px 32px; display: flex; flex-direction: column; gap: 16px; }
.sup-title { margin: 0; font-size: 1.35rem; }
.sup-foot { text-align: center; padding: 16px; }
.sup-narrow { max-width: 520px; }
.sup-rfq { padding: 10px 0; border-bottom: 1px solid var(--border); }
.sup-rfq:last-child { border-bottom: 0; }
.sup-lines { display: grid; gap: 12px; }
.sup-line { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: grid; gap: 10px; }
.sup-line.is-unavailable { opacity: .75; background: var(--surface-2); }
.sup-line-head { display: flex; gap: 10px; align-items: flex-start; }
.sup-line-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 14px; align-items: end; }
.sup-line-fields .span-2 { grid-column: span 2; }
.sup-total { margin: 12px 0 0; text-align: end; }
.sup-price-table input { width: 110px; }
.sup-price-table select { min-width: 120px; }
.nego-card { border-inline-start: 4px solid #D9A400; }
@media (max-width: 720px) {
  .sup-line-fields .span-2 { grid-column: auto; }
  .sup-top, .sup-nav { padding-inline: 16px; }
  .nego-form { flex-direction: column; align-items: stretch; }
}
/* Hidden labels inside a scrolling table stay inside it (they would otherwise widen the page on phones). */
.table-wrap, .cmp-wrap { position: relative; }
.rq-cmp .cmp-item { min-width: 220px; max-width: 300px; }
.send-list { grid-template-columns: minmax(0, 1fr); }
.send-row, .send-row > * { min-width: 0; }
.send-row select { max-width: 100%; }
body:has(.sup-shell) .page-code-float { top: auto; bottom: 12px; }
