:root {
  color-scheme: light;
  --bg: #f5f4f1; --surface: #ffffff; --surface-2: #faf9f7; --ink: #1f2328; --muted: #6b6f76; --line: #e3e1dc;
  --brand: #7a4b2a; --brand-ink: #ffffff; --brand-soft: #f3ebe4;
  --ok: #1e7a4a; --ok-soft: #e4f3ea; --warn: #9a6200; --warn-soft: #fbf0db;
  --bad: #b3261e; --bad-soft: #fbe7e5; --info: #2457a6; --info-soft: #e5edf9;
  --hover: #faf8f5; --hover-strong: #f1eee9; --field-bg: #ffffff; --field-border: #958d82; --field-border-hover: #6f6458;
  --field-shadow: inset 0 1px 2px rgba(0,0,0,.06), 0 1px 3px rgba(60,40,20,.10); --field-ring: rgba(124,74,42,.18);
  --chip-bg: #eceae6; --chip-ink: #555555; --kanban-col: #efebe5; --grp: #f7f4f0; --thumb-bg: #efe9e2;
  --status-bg: #f1eee9; --status-done-bg: #e4dbd1; --status-done-ink: #6b5a4c; --card-hover-border: #cdbfb2;
  --facet-hover: #eadccf; --tile: #ffffff; --menu-bg: #ffffff; --chat-sys: #9a8f86; --diagram-bg: #ffffff;
  --topbar-bg: #3b2a20; --topbar-sub: #4a372b; --topbar-ink: #f4ede6; --topbar-muted: #e6dbd0;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04); --shadow-md: 0 3px 8px rgba(0,0,0,.08); --shadow-lg: 0 10px 30px rgba(0,0,0,.12);
  --tile-shadow: 0 1px 2px rgba(0,0,0,.06), 0 6px 16px rgba(60,40,20,.07); --tile-shadow-hover: 0 2px 4px rgba(0,0,0,.08), 0 12px 24px rgba(60,40,20,.12);
  /* Chart series: validated palette (light steps); dark steps validated against the dark surface. */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7;
  --series-other: #9a948d; --series-neg: #e34948; --grid: #e6e2dc; --zero: #8f8a84;
  --st-client-bg: #f3e6f1; --st-client-ink: #6d3a66; --st-finished-bg: #e3f3ec; --st-finished-ink: #1e6b47;
  --st-catalog-bg: #e5eff7; --st-catalog-ink: #24506b; --st-site-bg: #fbeedf; --st-site-ink: #8a4b12; --st-material-bg: #efe9e2; --st-material-ink: #5a4636;
  --radius: 10px;
}
/* Dark theme: its own steps (warm, low-glare), text contrast >= 4.5:1 on every surface.
   Applied when the user picks "dark", or follows the device when "automatic". */
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #161311; --surface: #211d1a; --surface-2: #2a2521; --ink: #ece5de; --muted: #a89d93; --line: #3a332e;
    --brand: #dca57b; --brand-ink: #1a120c; --brand-soft: #3b2a1e;
    --ok: #5cc995; --ok-soft: #173427; --warn: #e8b755; --warn-soft: #3a2c12;
    --bad: #f28b82; --bad-soft: #3e1d1a; --info: #8ab4f8; --info-soft: #1b2a45;
    --hover: #2a2521; --hover-strong: #332d28; --field-bg: #1b1815; --field-border: #6f655c; --field-border-hover: #94877b;
    --field-shadow: inset 0 1px 2px rgba(0,0,0,.45), 0 1px 3px rgba(0,0,0,.5); --field-ring: rgba(210,160,120,.28);
    --chip-bg: #332d28; --chip-ink: #cfc6bd; --kanban-col: #1b1815; --grp: #28231f; --thumb-bg: #2a2521;
    --status-bg: #2a2521; --status-done-bg: #3a3029; --status-done-ink: #d2c0b0; --card-hover-border: #5a4d43;
    --facet-hover: #4a3527; --tile: #262120; --menu-bg: #26211e; --chat-sys: #6e655d; --diagram-bg: #f4ede6;
    --topbar-bg: #0f0c0a; --topbar-sub: #1a1512; --topbar-ink: #f4ede6; --topbar-muted: #cbbfb3;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow-md: 0 3px 10px rgba(0,0,0,.5); --shadow-lg: 0 12px 32px rgba(0,0,0,.6);
    --tile-shadow: 0 1px 2px rgba(0,0,0,.45), 0 6px 16px rgba(0,0,0,.35); --tile-shadow-hover: 0 2px 4px rgba(0,0,0,.5), 0 12px 24px rgba(0,0,0,.45);
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --series-6: #008300; --series-7: #9085e9;
    --series-other: #8f877f; --series-neg: #e66767; --grid: #3a332e; --zero: #8a827a;
    --st-client-bg: #3a2336; --st-client-ink: #e2b3da; --st-finished-bg: #17342a; --st-finished-ink: #7fd6ad;
    --st-catalog-bg: #1b2d3d; --st-catalog-ink: #9cc4e4; --st-site-bg: #3b2a17; --st-site-ink: #efbf85; --st-material-bg: #2f2822; --st-material-ink: #d8c3ae;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #161311; --surface: #211d1a; --surface-2: #2a2521; --ink: #ece5de; --muted: #a89d93; --line: #3a332e;
  --brand: #dca57b; --brand-ink: #1a120c; --brand-soft: #3b2a1e;
  --ok: #5cc995; --ok-soft: #173427; --warn: #e8b755; --warn-soft: #3a2c12;
  --bad: #f28b82; --bad-soft: #3e1d1a; --info: #8ab4f8; --info-soft: #1b2a45;
  --hover: #2a2521; --hover-strong: #332d28; --field-bg: #1b1815; --field-border: #6f655c; --field-border-hover: #94877b;
    --field-shadow: inset 0 1px 2px rgba(0,0,0,.45), 0 1px 3px rgba(0,0,0,.5); --field-ring: rgba(210,160,120,.28);
  --chip-bg: #332d28; --chip-ink: #cfc6bd; --kanban-col: #1b1815; --grp: #28231f; --thumb-bg: #2a2521;
  --status-bg: #2a2521; --status-done-bg: #3a3029; --status-done-ink: #d2c0b0; --card-hover-border: #5a4d43;
  --facet-hover: #4a3527; --tile: #262120; --menu-bg: #26211e; --chat-sys: #6e655d; --diagram-bg: #f4ede6;
  --topbar-bg: #0f0c0a; --topbar-sub: #1a1512; --topbar-ink: #f4ede6; --topbar-muted: #cbbfb3;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow-md: 0 3px 10px rgba(0,0,0,.5); --shadow-lg: 0 12px 32px rgba(0,0,0,.6);
  --tile-shadow: 0 1px 2px rgba(0,0,0,.45), 0 6px 16px rgba(0,0,0,.35); --tile-shadow-hover: 0 2px 4px rgba(0,0,0,.5), 0 12px 24px rgba(0,0,0,.45);
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --series-6: #008300; --series-7: #9085e9;
  --series-other: #8f877f; --series-neg: #e66767; --grid: #3a332e; --zero: #8a827a;
  --st-client-bg: #3a2336; --st-client-ink: #e2b3da; --st-finished-bg: #17342a; --st-finished-ink: #7fd6ad;
  --st-catalog-bg: #1b2d3d; --st-catalog-ink: #9cc4e4; --st-site-bg: #3b2a17; --st-site-ink: #efbf85; --st-material-bg: #2f2822; --st-material-ink: #d8c3ae;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "IBM Plex Sans Arabic", -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, Arial, sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; font-weight: 500; line-height: 1.6; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { min-height: calc(100vh - 56px); }
.main { padding: 24px 28px 48px; max-width: 1280px; margin: 0 auto; min-width: 0; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.top h1 { font-size: 22px; margin: 0; }

.tb-sticky { position: sticky; top: 0; z-index: 10; }
.topbar { height: 56px; display: flex; align-items: center; gap: 6px; padding: 0 14px; background: var(--topbar-bg); color: var(--topbar-ink); box-shadow: 0 1px 0 rgba(0,0,0,.15); }
.topbar a { color: inherit; text-decoration: none; }
.tb-home { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; color: var(--topbar-ink); }
.tb-home:hover { background: rgba(255,255,255,.12); }
.tb-app { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 10px; font-weight: 700; font-size: 16px; }
a.tb-app:hover { background: rgba(255,255,255,.12); }
.tb-app .app-svg { background: var(--tile); border-radius: 7px; padding: 3px; }
.tb-spacer { flex: 1; }
.tb-user { display: flex; align-items: center; gap: 10px; font-size: 14px; }
/* Environment strip (staging copy): impossible to mistake for the real system. */
.env-banner { background: var(--warn-soft); color: var(--warn); text-align: center; font-weight: 700; font-size: 13px; padding: 6px 12px; border-bottom: 1px solid var(--warn); }
/* A trial company (change 0066): its own banner on every page, a “Trial” mark on prints, a badge in lists. */
.trial-banner { background: var(--info-soft); color: var(--info); text-align: center; font-weight: 700; font-size: 13px; padding: 6px 12px; border-bottom: 2px dashed var(--info); }
.b-trial { background: var(--info-soft); color: var(--info); }
.trial-mark { display: none; }
@media print { .trial-mark { display: block; position: fixed; top: 42%; left: 0; right: 0; text-align: center; font-size: 96px; font-weight: 800; color: var(--info); opacity: .14; transform: rotate(-30deg); pointer-events: none; z-index: 0; } }
/* The company the user is working in: always visible, so nothing is entered in the wrong company. */
.tb-company { display: flex; align-items: center; gap: 6px; margin-inline-end: 12px; font-size: 13px; }
.tb-company .tb-company-name { padding: 4px 10px; border-radius: 999px; background: var(--topbar-sub); color: var(--topbar-ink); font-weight: 600; white-space: nowrap; }
.tb-company select { width: auto; max-width: 260px; padding: 4px 8px; font-size: 13px; }
.tb-avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: #E8833A; color: #fff; font-weight: 700; }
.topbar .btn.tb-logout, .topbar .btn.lang-toggle, .topbar .theme-menu > summary { color: var(--topbar-ink); border-color: rgba(255,255,255,.45); background: transparent; }
.topbar .btn.tb-logout:hover, .topbar .btn.lang-toggle:hover, .topbar .theme-menu > summary:hover { background: rgba(255,255,255,.12); }
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.launcher { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 40px 14px; padding: 32px 8px 40px; max-width: 1000px; margin: 0 auto; }
.app-tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.app-tile:hover { text-decoration: none; }
.app-icon { width: 80px; height: 80px; display: grid; place-items: center; background: var(--tile); border-radius: 7px; box-shadow: var(--tile-shadow); transition: transform .15s ease, box-shadow .15s ease; }
.app-icon .app-svg { width: 54px; height: 54px; }
/* Shapes marked `m` multiply over the ones beneath, inside the drawing only (not over the tile). */
.app-art { isolation: isolate; }
.app-art .m { mix-blend-mode: multiply; }
a.app-tile:hover .app-icon { transform: translateY(-3px); box-shadow: var(--tile-shadow-hover); }
.app-label { font-weight: 600; font-size: 15px; text-align: center; }
.app-tile.soon { cursor: default; }
.app-tile.soon .app-icon { filter: grayscale(.85); opacity: .5; }
.app-tile.soon .app-label { color: var(--muted); }
.soon-tag { position: absolute; top: -8px; inset-inline-start: calc(50% + 24px); background: var(--warn-soft); color: var(--warn); font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.section-title { font-size: 17px; margin: 4px 0 14px; color: var(--muted); font-weight: 600; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.card h2 { font-size: 16px; margin: 0 0 14px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 26px; font-weight: 700; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; background: var(--surface-2); }
td.num, th.num { direction: ltr; font-variant-numeric: tabular-nums; }
[dir="rtl"] .num { text-align: left; }
[dir="ltr"] .num { text-align: right; }
[dir="rtl"] .ltr-in { text-align: right; }
[dir="ltr"] .ltr-in { text-align: left; }
.table-wrap { overflow-x: auto; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--field-border); border-radius: 8px; font: inherit; background: var(--field-bg); color: var(--ink); box-shadow: var(--field-shadow); transition: border-color .15s, box-shadow .15s; }
/* Every field shows a framed, lightly shadowed box so it is clear where to type. */
input:hover, select:hover, textarea:hover { border-color: var(--field-border-hover); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--field-shadow), 0 0 0 3px var(--field-ring); }
input[type=checkbox], input[type=radio] { width: auto; box-shadow: none; accent-color: var(--brand); }
input[type=file] { padding: 7px; }
/* File fields drawn in the page's language (js/file-input.js): the real input stays, hidden but focusable. */
.file-pick { position: relative; display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--field-border); border-radius: 8px; background: var(--field-bg); box-shadow: var(--field-shadow); min-height: 42px; }
.file-pick:hover { border-color: var(--field-border-hover); }
.file-pick:focus-within { border-color: var(--brand); box-shadow: var(--field-shadow), 0 0 0 3px var(--field-ring); }
.file-pick input[type=file] { position: absolute; inset-inline-start: 0; bottom: 0; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; box-shadow: none; }
.file-pick .btn { flex: none; }
.file-pick .file-name { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
textarea { min-height: 70px; }
.field { margin-bottom: 12px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; }

.btn { display: inline-block; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink); padding: 8px 16px; border-radius: 8px; font: inherit; cursor: pointer; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.bad { background: var(--bad); border-color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--chip-bg); color: var(--chip-ink); }
.b-DRAFT, .b-PREVIEW, .b-PLANNED, .b-SUPERSEDED { background: var(--chip-bg); color: var(--chip-ink); }
.b-SENT, .b-PENDING, .b-IN_PRODUCTION, .b-INSTALLATION, .b-CLIENT_REVIEW, .b-IN_PROGRESS, .b-SUBMITTED { background: var(--info-soft); color: var(--info); }
.b-APPROVED, .b-IMPORTED, .b-POSTED, .b-OPEN, .b-ACTIVE, .b-COMPLETED, .b-SUCCESS, .b-CLIENT_APPROVED, .b-RELEASED_FOR_PRODUCTION, .b-RUNNING { background: var(--ok-soft); color: var(--ok); }
.kind-chip { font-weight: 600; }
.kind-tender { background: var(--info-soft); color: var(--info); }
.kind-existing { background: var(--ok-soft); color: var(--ok); }
.kind-none { background: var(--warn-soft); color: var(--warn); }
.kind-gap { display: inline-block; font-size: 11px; color: var(--bad); }
.kind-box { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 10px; }
.b-REJECTED, .b-DISCARDED, .b-CLOSED, .b-CANCELLED, .b-EXPIRED, .b-FAILED, .b-REFUSED { background: var(--bad-soft); color: var(--bad); }
.b-ON_HOLD { background: var(--warn-soft); color: var(--warn); }

.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--brand-soft); color: var(--ink); }
.alert ul { margin: 0; padding-inline-start: 18px; }
.muted { color: var(--muted); }
.na { color: var(--warn); font-weight: 600; }
dl.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; }
.login h1 { font-size: 20px; margin: 0 0 4px; }

@media (max-width: 860px) {
  .main { padding: 16px; }
  .tb-name { display: none; }
  /* The company stays visible but never widens the bar past the screen. */
  .tb-company { margin-inline-end: 6px; min-width: 0; flex-shrink: 1; }
  .tb-company select, .tb-company .tb-company-name { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .launcher { grid-template-columns: repeat(3, 1fr); gap: 22px 10px; padding: 16px 0 24px; }
  .app-icon { width: 64px; height: 64px; border-radius: 6px; }
  .app-icon .app-svg { width: 44px; height: 44px; }
  .app-label { font-size: 13px; }
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpis .card { padding: 12px; margin-bottom: 0; }
  .kpi .value { font-size: 20px; }
  .soon-tag { inset-inline-start: calc(50% + 16px); }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  dl.kv { grid-template-columns: 1fr; }
}
@media print { .tb-sticky, .topbar, .tb-menu-m, .actions, .no-print { display: none !important; } }
.pagination { display: flex; gap: 8px; list-style: none; padding: 0; margin: 14px 0 0; }
.pagination li a, .pagination li span { display: inline-block; padding: 5px 12px; border: 1px solid var(--line); border-radius: 8px; }
.pagination li.disabled span { color: var(--muted); }
.perm-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.perm-group { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px 12px; margin: 0; }
.perm-group legend { padding: 0 6px; }
.perm-all { display: flex; gap: 6px; align-items: center; font-weight: 700; color: var(--ink); font-size: 14px; }
.perm-item { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 14px; padding: 3px 0; margin: 0; }
.perm-item input, .perm-all input { width: auto; }

/* ---------- Top bar app menu ---------- */
.tb-menu { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tb-menu a { padding: 7px 12px; border-radius: 8px; font-size: 14px; white-space: nowrap; color: var(--topbar-muted); }
.tb-menu a:hover { background: rgba(255,255,255,.12); color: #fff; }
.tb-menu a.on { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
/* Second line of the top bar (option A, 2026-10-25): every section of the app, on every screen size. */
.tb-menu-m { display: flex; flex-wrap: wrap; gap: 2px 4px; background: var(--topbar-sub); padding: 5px 14px; }
.tb-menu-m a { color: var(--topbar-muted); white-space: nowrap; padding: 6px 12px; border-radius: 8px; font-size: 14px; text-decoration: none; }
.tb-menu-m a:hover { background: rgba(255,255,255,.12); color: #fff; }
.tb-menu-m a.on { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
/* The screen's control panel (breadcrumbs, search, filters, buttons) stays under the bar on computers;
   heights come from js/sticky.js. Anchors land below both. */
html { scroll-padding-top: calc(var(--tb-h, 100px) + var(--cp-h, 0px) + 12px); }
@media (min-width: 861px) {
  .main > .cp { position: sticky; top: var(--tb-h, 100px); z-index: 8; box-shadow: 0 6px 12px -10px rgba(0,0,0,.35); }
  .main > .cp::before { content: ""; position: absolute; inset-inline: -1px; bottom: 100%; height: 24px; background: var(--bg); }
}

/* ---------- Control panel ---------- */
.cp { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.cp-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cp-row:first-child { justify-content: space-between; }
.crumbs { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crumbs a { font-weight: 600; color: var(--brand); }
.crumb-sep { color: var(--muted); font-weight: 400; }
.cp-pager { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.pg-btn { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 6px; font-size: 16px; color: var(--ink); }
.pg-btn:hover { background: var(--hover-strong); text-decoration: none; }
.pg-btn.off { opacity: .35; pointer-events: none; }
.cp-left { min-width: 110px; }
.cp-search { flex: 1; min-width: 240px; max-width: 620px; display: flex; position: relative; border: 1px solid var(--field-border); border-radius: 8px; background: var(--field-bg); box-shadow: var(--field-shadow); }
.cp-search:focus-within { border-color: var(--brand); box-shadow: var(--field-shadow), 0 0 0 3px var(--field-ring); }
.cp-search:focus-within { border-color: var(--brand); }
.facets { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 4px 8px; }
.facets input, .facets input:focus { border: 0; outline: 0; background: transparent; box-shadow: none; padding: 5px 2px; flex: 1; min-width: 120px; width: auto; }
.facet { display: inline-flex; gap: 6px; align-items: center; background: var(--brand-soft); color: var(--brand); border-radius: 6px; padding: 2px 8px; font-size: 13px; }
.facet b { font-weight: 400; opacity: .7; }
.facet:hover { text-decoration: none; background: var(--facet-hover); }
.facet-group { background: var(--info-soft); color: var(--info); }
.facet-q { background: var(--chip-bg); color: var(--chip-ink); }
.cp-drop summary { list-style: none; cursor: pointer; padding: 6px 12px; border-inline-start: 1px solid var(--line); height: 100%; display: grid; place-items: center; color: var(--muted); }
.cp-drop summary::-webkit-details-marker { display: none; }
.cp-drop[open] summary { color: var(--brand); }
.cp-menu { position: absolute; top: calc(100% + 6px); inset-inline-end: 0; z-index: 20; background: var(--menu-bg); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); display: flex; min-width: 360px; }
.cp-col { padding: 10px; flex: 1; display: grid; align-content: start; gap: 2px; }
.cp-col + .cp-col { border-inline-start: 1px solid var(--line); }
.cp-col-title { font-weight: 700; font-size: 13px; color: var(--muted); padding: 2px 8px 6px; }
.cp-col a { padding: 6px 8px; border-radius: 6px; color: var(--ink); font-size: 14px; }
.cp-col a:hover { background: var(--hover-strong); text-decoration: none; }
.cp-col a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.cp-col a.on::before { content: "✓ "; }
.cp-col hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.cp-views { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.cp-views:empty { display: none; }
.vw { display: grid; place-items: center; width: 38px; height: 34px; color: var(--muted); }
.vw + .vw { border-inline-start: 1px solid var(--line); }
.vw.on { background: var(--brand-soft); color: var(--brand); }

/* ---------- Grouped list ---------- */
tr.grp td { background: var(--grp); font-weight: 700; }
tr.grp .grp-count { color: var(--muted); font-weight: 400; margin-inline-start: 6px; }
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: var(--hover); }
tr.sub-row td { padding-top: 4px; font-size: 13px; }
.empty-state { text-align: center; padding: 40px 12px; color: var(--muted); }
.empty-state strong { display: block; color: var(--ink); font-size: 17px; margin-bottom: 6px; }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.kb-col { background: var(--kanban-col); border-radius: 10px; padding: 10px; min-height: 120px; }
.kb-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 700; padding: 2px 4px 10px; }
.kb-head .kb-sum { font-weight: 400; color: var(--muted); font-size: 12px; }
.kb-card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; color: var(--ink); box-shadow: var(--shadow-sm); }
.kb-card:hover { text-decoration: none; border-color: var(--card-hover-border); box-shadow: var(--shadow-md); }
.kb-title { font-weight: 700; margin-bottom: 4px; }
.kb-meta { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.kb-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 12px 0; }
.kb-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.kb-cards .kb-card { display: flex; gap: 12px; align-items: center; margin: 0; }
.kb-avatar { flex: none; width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: 18px; color: #fff; }
/* Attendance cards (Today board): a header row, the status, then the times across the full width. */
.att-cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.kb-cards .att-card { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.att-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.att-head .kb-avatar { width: 40px; height: 40px; font-size: 16px; }
.att-avatar-muted { background: var(--muted); }
.att-name { flex: 1; min-width: 0; }
.att-name .kb-title { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; }
.att-line .badge { white-space: nowrap; }
.att-times { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; margin: 0; padding-top: 8px; border-top: 1px solid var(--line); }
.att-times dt { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-times dd { margin: 2px 0 0; font-size: 15px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.att-times .warn dd { color: var(--bad); }
.att-foot { font-size: 12px; color: var(--muted); }
.att-action { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.att-daily td.num, .att-daily .badge { white-space: nowrap; }
.att-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.att-seg, .att-links { display: flex; flex-wrap: wrap; gap: 6px; }
.att-panel > summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }
.att-panel > summary::-webkit-details-marker { display: none; }
.att-panel > summary::before { content: '▸'; color: var(--muted); }
.att-panel[open] > summary::before { content: '▾'; }
[dir="rtl"] .att-panel > summary::before { content: '◂'; }
[dir="rtl"] .att-panel[open] > summary::before { content: '▾'; }
.att-panel > summary h2 { display: inline; margin: 0; }
.att-panel[open] > summary { margin-bottom: 10px; }
td.nowrap { white-space: nowrap; }
.att-mail { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.att-mail h3 { margin: 0 0 6px; font-size: 15px; }

/* ---------- Record (form) view ---------- */
.rec-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; padding: 10px 14px; }
.rec-bar + .card { border-radius: 0 0 var(--radius) var(--radius); }
.statusbar { display: flex; }
.statusbar span { position: relative; padding: 6px 14px 6px 22px; background: var(--status-bg); color: var(--muted); font-size: 13px; font-weight: 600; clip-path: polygon(0 50%, 12px 0, 100% 0, 100% 100%, 12px 100%); margin-inline-start: -8px; }
.statusbar span:first-child { margin-inline-start: 0; clip-path: polygon(0 50%, 12px 0, 100% 0, 100% 100%, 12px 100%); border-radius: 0 6px 6px 0; }
.statusbar span.done { background: var(--status-done-bg); color: var(--status-done-ink); }
.statusbar span.cur { background: var(--brand); color: var(--brand-ink); }
.statusbar span.cur.bad { background: var(--bad); color: var(--brand-ink); }
.rec-title { font-size: 26px; font-weight: 700; margin: 0 0 14px; }
.rec-sub { color: var(--muted); font-size: 14px; margin: -10px 0 14px; }

/* ---------- Activity log (chatter) ---------- */
.chatter { margin-top: 6px; }
.chatter h2 { font-size: 15px; }
.chat-item { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.chat-item:first-of-type { border-top: 0; }
.chat-av { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #E8833A; color: #fff; font-weight: 700; font-size: 14px; }
.chat-av.sys { background: var(--chat-sys); }
.chat-head { font-size: 13px; }
.chat-head strong { margin-inline-end: 6px; }
.chat-head time { color: var(--muted); }
.chat-body { font-size: 14px; margin-top: 2px; }
.chat-body ul { margin: 2px 0 0; padding-inline-start: 18px; }
.chat-body del { color: var(--muted); }

@media (max-width: 860px) {
  .tb-menu { display: none; }
  .tb-menu-m { display: flex; gap: 4px; overflow-x: auto; background: var(--topbar-sub); padding: 6px 10px; scrollbar-width: none; }
  .tb-menu-m a { color: var(--topbar-muted); white-space: nowrap; padding: 5px 10px; border-radius: 7px; font-size: 13px; }
  .tb-menu-m a.on { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
  .cp-left { min-width: 0; }
  .cp-search { order: 3; flex-basis: 100%; min-width: 0; max-width: none; }
  .cp-row { gap: 8px; }
  .facets input, .facets input:focus { min-width: 60px; }
  .cp-drop { flex: none; }
  .cp-menu { min-width: 280px; inset-inline-end: -8px; }
  .kanban { grid-auto-columns: 82%; }
  .statusbar span { padding: 5px 10px 5px 18px; font-size: 12px; }
  .table-wrap td, .table-wrap th { white-space: nowrap; }
}

/* ---------- Reports ---------- */
.report-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.report-card { display: grid; gap: 6px; color: var(--ink); margin: 0; }
.report-card:hover { text-decoration: none; border-color: var(--card-hover-border); box-shadow: var(--shadow-md); }
.report-card strong { font-size: 16px; }
.report-bar { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; padding: 12px 14px; }
.report-bar label { display: grid; gap: 4px; margin: 0; }
.report-bar select { min-width: 190px; }
table.pivot tbody tr:hover td { background: var(--hover); }
table.pivot tfoot th { background: var(--hover-strong); color: var(--ink); font-weight: 700; }
td.strong { font-weight: 700; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--ink); margin: 6px 0 14px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 220px) 1fr; gap: 12px; align-items: center; }
.bar-label { font-size: 13px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: start; }
.bar-track { position: relative; height: 24px; margin-inline-end: 110px; border-inline-start: 1px solid var(--grid); }
.bar, .bar-stack { position: absolute; top: 2px; height: 20px; }
.bar { background: var(--series-1); border-radius: 4px 0 0 4px; }
[dir="rtl"] .bar { border-radius: 4px 0 0 4px; }
.bar.neg { background: var(--series-neg); border-radius: 0 4px 4px 0; }
.bar-stack { display: flex; gap: 2px; background: transparent; }
.bar-stack .seg { display: block; height: 100%; min-width: 2px; }
.bar-stack .seg:last-child { border-radius: 4px 0 0 4px; }
.bar:hover, .bar-stack .seg:hover { filter: brightness(1.08); }
.bar-zero { position: absolute; top: -2px; bottom: -2px; width: 1px; background: var(--zero); }
.bar-value { position: absolute; top: 2px; line-height: 20px; font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 860px) {
  .bar-row { grid-template-columns: 1fr; gap: 4px; }
  .bar-track { margin-inline-end: 90px; }
  .report-bar select { min-width: 0; width: 100%; }
  .report-bar label { flex: 1 1 140px; }
}
.report-range { margin: -4px 2px 10px; font-size: 14px; color: var(--ink); }
.report-bar input[type=date], .report-bar input[data-date] { min-width: 160px; }

[dir="ltr"] .statusbar span { padding: 6px 22px 6px 14px; clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 12px 50%); }
[dir="ltr"] .statusbar span:first-child { clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%); border-radius: 6px 0 0 6px; }
/* bars: square at the baseline, rounded at the data end (inline-end), in both directions */
.bar, .bar-stack .seg:last-child { border-radius: 0; border-start-end-radius: 4px; border-end-end-radius: 4px; }
.bar.neg { border-radius: 0; border-start-start-radius: 4px; border-end-start-radius: 4px; }

/* Studio (image library) */
.studio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.studio-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; color: var(--ink); box-shadow: var(--shadow-sm); }
.studio-card:hover { text-decoration: none; border-color: var(--card-hover-border); box-shadow: var(--shadow-md); }
.studio-thumb { display: block; aspect-ratio: 4 / 3; background: var(--thumb-bg); }
.studio-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.studio-cap { display: block; padding: 8px 10px; min-width: 0; }
.studio-cap .kb-title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.studio-group { margin: 6px 0 10px; font-size: 15px; }
.studio-mini { width: 48px; height: 36px; object-fit: cover; border-radius: 4px; display: block; background: var(--thumb-bg); }
.studio-show { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.studio-image { padding: 8px; }
.studio-image img { width: 100%; height: auto; max-height: 75vh; object-fit: contain; display: block; border-radius: 4px; }
.studio-previews { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.studio-previews img { width: 96px; height: 72px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); }
.badge.st-CLIENT_REFERENCE { background: var(--st-client-bg); color: var(--st-client-ink); }
.badge.st-FINISHED_WORK { background: var(--st-finished-bg); color: var(--st-finished-ink); }
.badge.st-CATALOG { background: var(--st-catalog-bg); color: var(--st-catalog-ink); }
.badge.st-SITE { background: var(--st-site-bg); color: var(--st-site-ink); }
.badge.st-MATERIAL { background: var(--st-material-bg); color: var(--st-material-ink); }
/* Quotation line image */
.line-img { display: flex; align-items: center; gap: 6px; }
.line-img img { width: 44px; height: 33px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); }
.q-line-img { width: 72px; height: 54px; object-fit: cover; border-radius: 4px; display: block; }
dialog.picker { width: min(920px, 94vw); max-height: 86vh; border: 1px solid var(--line); border-radius: 10px; padding: 0; background: var(--surface); color: var(--ink); }
dialog.picker::backdrop { background: rgba(30, 20, 12, .45); }
.picker-head { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.picker-head input { flex: 1; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 12px; overflow: auto; max-height: calc(86vh - 70px); }
.picker-grid button { all: unset; cursor: pointer; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.picker-grid button:hover, .picker-grid button:focus-visible { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.picker-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--thumb-bg); }
.picker-grid span { display: block; padding: 6px 8px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 760px) { .studio-show { grid-template-columns: 1fr; } .studio-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
@media print { .line-img button { display: none; } }

/* Record stat tiles (manufacturing / HR) */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.stat { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--bg); }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 20px; font-weight: 700; direction: ltr; text-align: start; }
[dir="rtl"] .stat .v { text-align: right; }
.inline-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; min-width: 0; }
.inline-form input[type=number] { width: 110px; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.section-title h2 { margin: 0; }
.warn-text { color: var(--bad); }
.inline-details { display: inline-block; } .inline-details > summary { list-style: none; } .inline-details > summary::-webkit-details-marker { display: none; }
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; }

/* Printing always uses the light theme (paper is white). */
@media print {
  :root, :root[data-theme="dark"] {
    color-scheme: light;
    --bg: #ffffff; --surface: #ffffff; --surface-2: #f5f5f5; --ink: #000000; --muted: #444444; --line: #cccccc;
    --brand: #7a4b2a; --brand-ink: #ffffff; --brand-soft: #f3ebe4; --chip-bg: #eeeeee; --chip-ink: #333333;
    --status-bg: #eeeeee; --status-done-bg: #e4dbd1; --status-done-ink: #6b5a4c; --grp: #f5f5f5; --hover: #ffffff;
    --ok: #1e7a4a; --ok-soft: #e4f3ea; --warn: #9a6200; --warn-soft: #fbf0db; --bad: #b3261e; --bad-soft: #fbe7e5; --info: #2457a6; --info-soft: #e5edf9;
  }
}

/* Theme switch (top bar and sign-in page) */
.theme-menu { position: relative; }
.theme-menu > summary { list-style: none; cursor: pointer; }
.theme-menu > summary::-webkit-details-marker { display: none; }
.theme-menu .theme-list { position: absolute; top: calc(100% + 6px); inset-inline-end: 0; z-index: 30; background: var(--menu-bg); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 210px; display: grid; gap: 2px; }
.theme-list button { white-space: nowrap; }
.theme-list button { all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border-radius: 7px; font-size: 14px; color: var(--ink); }
.theme-list button:hover, .theme-list button:focus-visible { background: var(--hover-strong); }
.theme-list button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.theme-list svg { flex: none; }

/* Treasury dashboard (Odoo accounting-style cards) */
.acct-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.acct-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow-sm); }
.acct-card:hover { border-color: var(--card-hover-border); box-shadow: var(--shadow-md); }
.acct-head { display: flex; flex-direction: column; gap: 2px; color: var(--ink); }
.acct-head:hover { text-decoration: none; }
.acct-name { font-weight: 700; font-size: 17px; }
.acct-kind { align-self: flex-start; font-size: 12px; border-radius: 999px; padding: 1px 10px; }
.acct-kind.k-CASH { background: var(--ok-soft); color: var(--ok); }
.acct-kind.k-BANK { background: var(--info-soft); color: var(--info); }
.acct-kind.k-CUSTODY { background: var(--warn-soft); color: var(--warn); }
.acct-figure { display: flex; flex-direction: column; background: var(--surface-2); border-radius: 8px; padding: 8px 12px; }
.acct-figure .label { color: var(--muted); font-size: 13px; }
.acct-figure .value { font-size: 24px; font-weight: 700; }
.acct-figure.bad .value, .acct-figure.bad .label { color: var(--bad); }
.acct-flags { display: flex; flex-wrap: wrap; gap: 6px; min-height: 0; }
.acct-flags:empty { display: none; }
.acct-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.stmt-in { color: var(--ok); }
.stmt-out { color: var(--bad); }
tr.draft-line td { color: var(--muted); font-style: italic; }

/* Odoo-style smart buttons on a record form, and centred list cells. */
.smart-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0; margin: -4px 0 16px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; width: fit-content; margin-inline-start: auto; }
.smart-btn { display: flex; flex-direction: column; align-items: center; padding: 8px 18px; color: var(--ink); text-decoration: none; border-inline-start: 1px solid var(--line); min-width: 130px; }
.smart-btn:first-child { border-inline-start: 0; }
.smart-btn:hover { background: var(--hover); }
.smart-btn strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.smart-btn span { font-size: 12px; color: var(--muted); }
td.center, th.center { text-align: center; }
.input-lg { font-size: 20px; font-weight: 600; }

/* Financial reports (Odoo style): options bar, report sheet, lines by kind. */
.fin-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px; }
.fin-drop { position: relative; }
.fin-drop > summary { list-style: none; cursor: pointer; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 14px; }
.fin-drop > summary::-webkit-details-marker { display: none; }
.fin-drop[open] > summary { border-color: var(--brand); }
.fin-menu { position: absolute; z-index: 30; top: calc(100% + 4px); inset-inline-start: 0; min-width: 240px; background: var(--menu-bg); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-md); padding: 6px; display: grid; gap: 2px; }
.fin-menu a { padding: 7px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; }
.fin-menu a:hover { background: var(--hover); }
.fin-menu a.on { font-weight: 600; background: var(--brand-soft); }
.fin-menu a.on::before { content: "✓ "; }
.fin-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.fin-custom { display: grid; gap: 6px; padding: 4px 6px; }
.fin-custom label { display: grid; gap: 2px; font-size: 13px; color: var(--muted); }
.fin-sheet { padding: 22px 26px; }
.fin-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.fin-head h1 { margin: 0 0 4px; font-size: 22px; }
.fin-checks { display: flex; gap: 6px; flex-wrap: wrap; }
.fin-report { width: 100%; border-collapse: collapse; font-size: 14px; }
.fin-report th { text-align: start; font-weight: 600; color: var(--muted); font-size: 13px; padding: 8px 10px; border-bottom: 2px solid var(--line); background: transparent; }
.fin-report th.grp-head { text-align: center; color: var(--ink); border-bottom: 1px solid var(--line); }
.fin-report td { padding: 7px 10px; border-bottom: 1px solid var(--line); }
.fin-report td.num { text-align: end; direction: ltr; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fin-report td.num.neg { color: var(--bad); }
.fin-report .code { color: var(--muted); margin-inline-end: 8px; font-variant-numeric: tabular-nums; }
.fin-report .fold { display: inline-block; width: 16px; color: var(--muted); text-decoration: none; }
.fin-report tr.fr-heading td { font-weight: 700; font-size: 15px; padding-top: 16px; border-bottom: none; color: var(--ink); }
.fin-report tr.fr-section td { font-weight: 600; background: var(--surface-2); }
.fin-report tr.fr-account:hover td, .fin-report tr.fr-detail:hover td { background: var(--hover); }
.fin-report tr.fr-total td { font-weight: 700; border-top: 1px solid var(--ink); }
.fin-report tr.fr-grand td { font-weight: 700; font-size: 15px; border-top: 1.5px solid var(--ink); border-bottom: 3px double var(--ink); }
.fin-report tr.fr-detail td, .fin-report tr.fr-initial td { font-size: 13px; color: var(--muted); }
.fin-report tr.fr-initial td { font-style: italic; }
.fin-report .fr-note { font-size: 12px; margin-inline-start: 6px; }
.fin-foot { margin-bottom: 0; }
@media print { .fin-bar { display: none; } }
.quick-dates { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 2px 10px; }
.quick-dates a { padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; color: var(--ink); text-decoration: none; background: var(--surface); }
.quick-dates a:hover { background: var(--hover); }
.quick-dates a.on { border-color: var(--brand); background: var(--brand-soft); font-weight: 600; }
.report-group { font-size: 16px; margin: 6px 2px 10px; color: var(--muted); font-weight: 600; }
.report-group ~ .report-group { margin-top: 22px; }
.app-version { text-align: center; margin: 24px 0 8px; }
.btn.bad-text { color: var(--bad); }

/* Home: getting started + waiting for action (Odoo-style: only what needs doing, each a link) */
.home-board { max-width: 1000px; margin: 0 auto; }
.setup-card { margin-bottom: 22px; }
.setup-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.setup-head h2 { margin: 0; }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 10px 0 14px; }
.progress > span { display: block; height: 100%; background: var(--brand); }
.setup-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px 18px; }
.setup-steps li { display: grid; grid-template-columns: 26px 1fr; column-gap: 8px; align-items: start; }
.setup-steps .hint { grid-column: 2; margin: 0; }
.step-mark { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.setup-steps li.done .step-mark { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.setup-steps li.done a { color: var(--muted); text-decoration: line-through; }
.action-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.action-card { display: grid; gap: 4px; text-decoration: none; color: var(--ink); border-inline-start: 4px solid var(--info); margin: 0; }
.action-card:hover { border-color: var(--card-hover-border); box-shadow: var(--shadow-md); }
.action-card.tone-warn { border-inline-start-color: var(--warn); }
.action-card.tone-bad { border-inline-start-color: var(--bad); }
.action-count { font-size: 26px; font-weight: 700; }
.action-label { color: var(--ink); }
.action-amount { color: var(--muted); font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Accounting dashboard: a card per journal (Odoo) */
.journal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-bottom: 22px; }
.journal-card { display: grid; gap: 8px; align-content: start; margin: 0; }
.jc-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.jc-balance { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.jc-amount { font-size: 22px; font-weight: 700; }
.jc-todo { font-size: 13px; color: var(--warn); }
.jc-todo.bad, .jc-todo.bad a { color: var(--bad); }
.jc-links { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; border-top: 1px solid var(--line); padding-top: 8px; }
.theme-menu > summary { display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 860px) { .theme-label { display: none; } }

/* Reports and quotations: headline figures, share bars, totals box */
.kpi-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; border-top: 3px solid var(--brand); box-shadow: var(--shadow-sm); }
.kpi-tile.tone-ok { border-top-color: var(--ok); } .kpi-tile.tone-ok .kpi-value { color: var(--ok); }
.kpi-tile.tone-bad { border-top-color: var(--bad); } .kpi-tile.tone-bad .kpi-value { color: var(--bad); }
.kpi-tile.tone-warn { border-top-color: var(--warn); } .kpi-tile.tone-warn .kpi-value { color: var(--warn); }
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-sub { color: var(--muted); font-size: 12.5px; }
.share-col { white-space: nowrap; color: var(--muted); }
.share-bar { display: inline-block; width: 90px; height: 7px; background: var(--surface-2); border-radius: 99px; overflow: hidden; vertical-align: middle; margin-inline-end: 8px; }
.share-bar > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
table.pivot th { position: sticky; top: 0; }
table.pivot td.num, table.pivot th.num { font-variant-numeric: tabular-nums; }
table.pivot tbody tr:nth-child(even) td { background: var(--surface-2); }
.report-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--tile); box-shadow: var(--tile-shadow); margin-bottom: 4px; }
.report-card { border-top: 3px solid transparent; transition: border-color .15s, box-shadow .15s; }
.report-card:hover { border-top-color: var(--brand); }
.fin-report tr.fr-section td:first-child { box-shadow: inset -3px 0 0 var(--brand); }
[dir=ltr] .fin-report tr.fr-section td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
.fin-report tr.fr-grand td { background: var(--brand-soft); }
.q-totals { width: min(380px, 100%); margin-inline-start: auto; margin-top: 12px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.q-totals > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.q-totals > div:last-child { border-bottom: none; }
.q-totals .num { font-variant-numeric: tabular-nums; direction: ltr; }
.q-totals .sub { font-weight: 600; background: var(--surface-2); }
.q-totals .grand { font-weight: 700; font-size: 16px; background: var(--brand-soft); color: var(--brand); }
.q-totals .grand small { font-size: 12px; font-weight: 600; }
.report-card { align-content: start; }

/* Reports page: sections with a jump bar; cards size to the screen */
.report-jump { position: sticky; top: calc(var(--tb-h, 0px) + var(--cp-h, 0px)); z-index: 5; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 8px 2px; margin: -6px 0 8px; background: var(--bg); }
.report-jump a { white-space: nowrap; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; color: var(--ink); background: var(--surface); text-decoration: none; }
.report-jump a:hover { background: var(--hover); }
.report-jump a span { color: var(--muted); margin-inline-start: 4px; }
.report-section { scroll-margin-top: 56px; margin-bottom: 18px; }
.report-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 12px; }
@media (min-width: 1500px) { .report-list { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); } .main { max-width: 1680px; } }
@media (max-width: 600px) { .report-card .muted { font-size: 13px; } .kpi-value { font-size: 20px; } .share-bar { width: 50px; } }
@media (max-width: 600px) { .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } .kpi-strip .kpi-tile:first-child { grid-column: 1 / -1; } .kpi-tile { padding: 10px 12px; } }

/* Report sections: each bundle has its own accent (validated series colours, light and dark) */
.sec-finance { --sec: var(--series-1); } .sec-sales { --sec: var(--series-2); } .sec-production { --sec: var(--series-3); }
.sec-inventory { --sec: var(--series-4); } .sec-purchasing { --sec: var(--series-5); } .sec-hr { --sec: var(--series-6); }
.report-band { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 12px; padding: 10px 16px; border-radius: 10px;
  font-size: 16px; font-weight: 700; color: var(--ink); background: color-mix(in srgb, var(--sec) 16%, var(--surface)); border-inline-start: 5px solid var(--sec); }
.band-count { font-size: 12.5px; font-weight: 700; min-width: 26px; text-align: center; padding: 2px 8px; border-radius: 999px; background: var(--sec); color: var(--surface); }
.report-section .report-card:hover { border-top-color: var(--sec); }
.report-section .report-icon { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--sec) 45%, transparent), var(--tile-shadow); }
.report-jump a[class^="sec-"] { border-inline-start: 4px solid var(--sec); }
.back-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -4px 0 12px; }
/* Reports: a very light line between data rows (totals keep their own rules) */
.fin-report tbody td, table.pivot tbody td { border-bottom: 1px solid color-mix(in srgb, var(--ink) 35%, transparent); }
.fin-report tr.fr-heading td { border-bottom: none; }
.fin-report tr.fr-total td { border-top: 1px solid var(--ink); }
.fin-report tr.fr-grand td { border-top: 1.5px solid var(--ink); border-bottom: 3px double var(--ink); }

/* Match / mismatch marks in reconciliations. */
.ok-text { color: var(--ok); font-weight: 600; }
.bad-text { color: var(--bad); font-weight: 600; }
.warn-mark { color: var(--warn); font-weight: 600; }

/* Import from Excel (templates) */
.imp-drop { position: relative; }
.imp-drop > summary { list-style: none; cursor: pointer; }
.imp-drop > summary::-webkit-details-marker { display: none; }
.imp-menu { position: absolute; top: calc(100% + 6px); inset-inline-end: 0; z-index: 20; background: var(--menu-bg); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); min-width: 300px; padding: 6px; display: grid; gap: 2px; }
.imp-item { padding: 8px 10px; border-radius: 6px; display: grid; gap: 2px; font-size: 14px; }
.imp-item:hover { background: var(--hover-strong); }
.imp-item span { font-size: 13px; }
.imp-sections { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.imp-sections .card h2 { font-size: 15px; margin: 0 0 8px; }
.imp-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.imp-list li { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.imp-list li:last-child { border-bottom: 0; }
.imp-list .acts { white-space: nowrap; font-size: 13px; }
.imp-steps { margin: 0; padding-inline-start: 20px; display: grid; gap: 4px; }
.imp-upload { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
tr.imp-bad td { background: var(--bad-soft); }
.imp-msg { font-size: 13px; }
@media (max-width: 640px) { .imp-menu { inset-inline-end: auto; inset-inline-start: 0; min-width: 260px; } }

/* ---- CRM -------------------------------------------------------------- */
.statusbar-click { flex-wrap: wrap; row-gap: 4px; }
.statusbar-click form { display: contents; }
.statusbar-click button { position: relative; border: 0; font: inherit; cursor: pointer; padding: 6px 14px 6px 22px; background: var(--status-bg); color: var(--muted); font-size: 13px; font-weight: 600; clip-path: polygon(0 50%, 12px 0, 100% 0, 100% 100%, 12px 100%); margin-inline-start: -8px; }
.statusbar-click form:first-child button { margin-inline-start: 0; border-radius: 0 6px 6px 0; }
.statusbar-click button.done { background: var(--status-done-bg); color: var(--status-done-ink); }
.statusbar-click button.cur { background: var(--brand); color: var(--brand-ink); cursor: default; }
.statusbar-click button:not(.cur):not(:disabled):hover { filter: brightness(.95); }
.statusbar-click button:disabled:not(.cur) { opacity: .5; cursor: default; }
[dir="ltr"] .statusbar-click button { padding: 6px 22px 6px 14px; clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 12px 50%); }
[dir="ltr"] .statusbar-click form:first-child button { border-radius: 6px 0 0 6px; }
.b-WON { background: var(--ok-soft); color: var(--ok); }
.b-LOST { background: var(--bad-soft); color: var(--bad); }
.inline-pop { position: relative; display: inline-block; }
.inline-pop > summary { list-style: none; }
.inline-pop > summary::-webkit-details-marker { display: none; }
.inline-pop .pop-body { position: absolute; z-index: 20; inset-inline-start: 0; top: calc(100% + 6px); width: min(320px, 86vw); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; box-shadow: var(--shadow-md); }
.ribbon { float: inline-end; font-weight: 700; font-size: 13px; padding: 3px 12px; border-radius: 6px; }
.ribbon.ok { background: var(--ok-soft); color: var(--ok); }
.ribbon.bad { background: var(--bad-soft); color: var(--bad); }
.act-due { font-size: 12px; white-space: nowrap; }
.act-due.late { color: var(--bad); font-weight: 700; }
.act-due.today { color: var(--warn); font-weight: 700; }
.act-due.none { color: var(--warn); }
tr.done-row td { color: var(--muted); }
.crm-card[draggable="true"] { cursor: grab; }
.crm-card.dragging { opacity: .5; }
.kb-col.drop-on { outline: 2px dashed var(--brand); outline-offset: -4px; }
.kb-add { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-inline-start: 6px; border-radius: 6px; color: var(--muted); font-weight: 700; }
.kb-add:hover { background: var(--surface); color: var(--brand); text-decoration: none; }
.kb-actbar { display: flex; gap: 2px; height: 6px; margin: -4px 4px 10px; border-radius: 3px; overflow: hidden; }
.kb-actbar .seg.late { background: var(--bad); }
.kb-actbar .seg.today { background: var(--warn); }
.kb-actbar .seg.planned { background: var(--ok); }
.kb-actbar .seg.none { background: var(--line); }
.kb-won { border: 2px dashed var(--ok); background: var(--ok-soft); }
.kb-won .kb-head { color: var(--ok); }
/* Team tasks (0040): an overdue card carries a red edge; the assignee's buttons sit under it. */
.task-card.late { border-inline-start: 3px solid var(--bad); }
.task-card .kb-title a { color: var(--ink); }
.task-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.task-acts form.inline { margin: 0; }
.stars { color: #e2a400; letter-spacing: 1px; font-weight: 400; }
.stars-input { display: flex; gap: 6px; flex-wrap: wrap; }
.stars-input label { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; color: #e2a400; }
.stars-input label.on, .stars-input label:has(input:checked) { border-color: var(--brand); background: var(--surface); }
.stars-input input { margin: 0; }
.tag-row { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.tag-chip { --tag: #8a8f98; display: inline-block; font-size: 11px; line-height: 1.6; padding: 0 8px; border-radius: 999px; color: var(--tag); border: 1px solid var(--tag); background: color-mix(in srgb, var(--tag) 12%, transparent); }
.tag-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-pick { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.tag-pick input { margin: 0; }
.tag-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
@media (max-width: 860px) {
  .statusbar-click button { padding: 5px 10px 5px 18px; font-size: 12px; }
}

/* Notch and home-indicator areas when installed or in landscape. */
.topbar { padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top)); padding-inline-start: max(14px, env(safe-area-inset-left)); padding-inline-end: max(14px, env(safe-area-inset-right)); }
@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; }
  .app-version { margin-bottom: env(safe-area-inset-bottom); }
}

/* ---- Phones and the installed app (PWA) ------------------------------- */
.tb-account { display: none; position: relative; }
.tb-account > summary { list-style: none; cursor: pointer; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; }
.tb-account > summary::-webkit-details-marker { display: none; }
.acct-sheet { position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 40; width: min(320px, calc(100vw - 20px)); background: var(--menu-bg); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 8px 14px; }
.acct-who { display: grid; gap: 2px; padding: 8px 0 10px; border-bottom: 1px solid var(--line); }
.acct-who span { color: var(--muted); font-size: 13px; text-align: start; }
.acct-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--line); margin: 0; }
.acct-row:last-child { border-bottom: 0; }
.acct-label { color: var(--muted); font-size: 13px; min-width: 64px; }
.acct-row .tb-company { margin: 0; flex: 1; min-width: 0; }
.acct-row .tb-company select { max-width: 100%; width: 100%; }
.acct-row .tb-company .tb-company-name { background: var(--chip-bg); color: var(--ink); }
.acct-theme button { all: unset; cursor: pointer; padding: 5px 10px; border-radius: 8px; font-size: 13px; border: 1px solid var(--line); }
.acct-theme button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand); border-color: transparent; font-weight: 600; }
.acct-sheet .btn.lang-toggle { color: var(--brand); border-color: var(--brand); }
.acct-row[hidden], .acct-ios[hidden] { display: none; }

@media (max-width: 860px) {
  .topbar { padding-inline-start: max(8px, env(safe-area-inset-left)); padding-inline-end: max(8px, env(safe-area-inset-right)); gap: 2px; }
  .tb-user > :not(.tb-account), .topbar > .tb-company { display: none; }
  .tb-account { display: block; }
  .tb-app { padding: 6px; font-size: 15px; min-width: 0; }
  .tb-app span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* Comfortable touch targets. */
  .btn { min-height: 38px; }
  .btn.sm { min-height: 32px; }
  input, select, textarea { font-size: 16px; }   /* no zoom-in on focus (iOS) */
}

/* ---- Drafts on this device (forms not yet confirmed by the server) ---- */
.draft-note { margin-bottom: 12px; }
.draft-note .actions { gap: 6px; }
.acct-drafts { display: grid; gap: 4px; }
.acct-drafts[hidden] { display: none; }
.acct-draft-list { display: grid; gap: 2px; }
.acct-draft-list a { padding: 5px 8px; border-radius: 7px; font-size: 13px; background: var(--warn-soft); color: var(--ink); }
.acct-draft-list a .muted { font-size: 12px; }
.tb-account > summary { position: relative; }
.draft-dot { position: absolute; top: 2px; inset-inline-end: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--warn); color: #fff; font-size: 11px; line-height: 16px; text-align: center; font-weight: 700; }
.draft-dot[hidden] { display: none; }

/* ---- Permission matrix ------------------------------------------------- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg a { padding: 6px 14px; color: var(--ink); font-size: 14px; }
.seg a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.matrix-card { padding: 0 0 14px; }
.matrix-card .actions { padding: 0 14px; }
.matrix-wrap { max-height: 72vh; overflow: auto; }
table.matrix { border-collapse: separate; border-spacing: 0; }
table.matrix th { position: sticky; top: 0; z-index: 2; background: var(--surface); font-size: 12px; white-space: normal; min-width: 76px; max-width: 96px; text-align: center; vertical-align: bottom; line-height: 1.3; }
table.matrix .mx-first { position: sticky; inset-inline-start: 0; z-index: 1; background: var(--surface); min-width: 260px; text-align: start; }
table.matrix th.mx-first { z-index: 3; }
table.matrix tr.grp td { background: var(--grp); font-weight: 700; }
table.matrix tr.grp td.mx-first { background: var(--grp); }
table.matrix td.mx-cell { text-align: center; }
table.matrix td.mx-cell input { width: 18px; height: 18px; cursor: pointer; }
table.matrix tbody tr:hover td, table.matrix tr:hover td { background: var(--hover); }
table.matrix code { font-size: 11px; }
@media (max-width: 860px) { table.matrix .mx-first { min-width: 170px; } table.matrix code { display: none; } }

/* Pricing: checks before submission (red blocks, amber warns). */
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.checks li { padding: 8px 12px; border-radius: 8px; }
.checks li.bad { background: var(--bad-soft); color: var(--bad); }
.checks li.warn { background: var(--warn-soft); color: var(--warn); }
.cmp-cell { display: flex; align-items: flex-start; gap: 6px; padding: 4px 0; }
.cmp-cell.best { font-weight: 700; color: var(--ok); }
.cmp-cell input { margin-top: 3px; }
.b-REQUESTED { background: var(--info-soft); color: var(--info); }
.b-RECEIVED { background: var(--ok-soft); color: var(--ok); }
.b-DECLINED { background: var(--chip-bg); color: var(--chip-ink); }
.b-APPROVED_AS_NOTED { background: var(--warn-soft); color: var(--warn); }
.to-line { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.to-line-head { margin-bottom: 8px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* User guide (2026-10-25): written files in resources/guide + live roles and permissions. */
.tb-help { font-weight: 700; min-width: 30px; text-align: center; }
.topbar .btn.tb-help { color: var(--topbar-ink); border-color: rgba(255,255,255,.45); background: transparent; }
.topbar .btn.tb-help:hover { background: rgba(255,255,255,.12); }
.guide { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 24px; align-items: start; }
.guide-toc { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px; max-height: calc(100vh - 24px); overflow: auto; }
.guide-toc-title { font-weight: 700; font-size: 13px; color: var(--muted); padding: 4px 8px 6px; }
.guide-toc a { padding: 6px 8px; border-radius: 6px; color: var(--ink); font-size: 14px; }
.guide-toc a:hover { background: var(--brand-soft); color: var(--brand); }
.guide-body { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px 28px 28px; min-width: 0; line-height: 1.75; }
.guide-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; border-bottom: 3px solid #f4bd52; padding-bottom: 12px; margin-bottom: 8px; }
.guide-head h1 { margin: 0 0 4px; font-size: 24px; }
.guide-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.guide-sec { padding-top: 10px; scroll-margin-top: 12px; }
.guide-sec > h2 { font-size: 19px; margin: 22px 0 10px; padding-inline-start: 10px; border-inline-start: 4px solid var(--brand); color: var(--ink); }
.guide-sec h3 { font-size: 16px; margin: 18px 0 8px; color: var(--brand); }
.guide-sec h4 { font-size: 15px; margin: 14px 0 6px; }
.guide-anchor { display: block; position: relative; top: -12px; visibility: hidden; }
.guide-body table { width: 100%; border-collapse: collapse; margin: 8px 0 16px; font-size: 13.5px; line-height: 1.55; }
.guide-body th { background: var(--topbar-bg); color: var(--topbar-ink); text-align: start; font-weight: 600; padding: 8px 10px; vertical-align: bottom; }
.guide-body td { padding: 7px 10px; border-top: 1px solid var(--line); vertical-align: top; }
.guide-body tbody tr:nth-child(even) td { background: var(--surface-2); }
.guide-body td.c, .guide-body th.c { text-align: center; }
.guide-body code { direction: ltr; unicode-bidi: isolate; font-size: 12px; background: var(--brand-soft); color: var(--brand); padding: 1px 5px; border-radius: 4px; white-space: nowrap; }
.guide-body .ok { color: var(--brand); font-size: 15px; }
.guide-body .note { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.guide-body .caption { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }
.guide-body .diagram { background: var(--diagram-bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin: 10px 0; }
.guide-role { border: 1px solid var(--line); border-radius: 10px; padding: 4px 16px 10px; margin: 0 0 12px; }
.guide-role h3 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-block; background: var(--brand-soft); color: var(--brand); border-radius: 999px; padding: 1px 10px; margin: 2px 3px; font-size: 12.5px; font-weight: 600; }
.guide .gloss { column-count: 2; column-gap: 24px; }
.guide .gloss h2 { font-size: 15px; margin: 0 0 6px; }
.guide .gloss table { break-inside: auto; }
.guide-matrix-wrap { overflow-x: auto; }
.guide-matrix { font-size: 12.5px; }
.guide-matrix th.rot { height: 150px; padding: 4px 2px; text-align: center; }
.guide-matrix th.rot span { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; display: inline-block; }
.guide-matrix td.c { color: var(--brand); border-inline-start: 1px solid var(--line); }
.guide-matrix tr.grp td, .guide-body tr.grp td { background: var(--brand-soft) !important; font-weight: 700; }
@media (max-width: 900px) {
  .guide { grid-template-columns: 1fr; }
  .guide-toc { position: static; max-height: none; flex-direction: row; flex-wrap: wrap; }
  .guide-body { padding: 14px; }
  .guide .gloss { column-count: 1; }
}
@media print {
  .guide { display: block; }
  .guide-toc, .guide-tools, .tb-menu-m, .cp, .control-panel { display: none !important; }
  .guide-body { border: 0; padding: 0; }
  .guide-sec { break-inside: auto; }
  .guide-sec > h2 { break-after: avoid; }
  .guide-body tr { break-inside: avoid; }
  .guide-body th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Date and time in the top bar (2026-10-25): time on top, Gregorian and Hijri dates under it; phones show the time only. */
.tb-clock { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: baseline; column-gap: 6px; max-width: 260px; margin-inline-end: 10px; color: var(--topbar-ink); line-height: 1.25; text-align: end; }
.tb-clock .clk-time { flex-basis: 100%; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tb-clock .clk-date, .tb-clock .clk-hijri { font-size: 11px; color: var(--topbar-muted); white-space: nowrap; }
.tb-clock .clk-date:not(:empty)::after { content: " ·"; }
.acct-clock { flex-direction: column; align-items: flex-start; gap: 2px; font-size: 13px; }
@media (max-width: 860px) {
  .tb-clock { margin-inline-end: 6px; }
  .tb-clock .clk-date, .tb-clock .clk-hijri { display: none; }
}
@media (max-width: 1200px) { .tb-clock .clk-hijri { display: none; } .tb-clock .clk-date::after { content: none; } }
@media print { .tb-clock { display: none; } }

/* ---- The page never moves sideways (owner report 2026-10-25) -----------
   Wide content scrolls inside its own box (.table-wrap, the app menu); the page itself is
   clipped to the screen width, and a sideways drag or swipe does not slide it. */
html, body { overflow-x: clip; overscroll-behavior-x: none; }
.tb-menu, .tb-menu-m, .table-wrap, .kanban, .report-jump, .guide-matrix-wrap { overscroll-behavior-x: contain; }
/* The clock keeps one width while the seconds tick, so nothing beside it shifts. */
.tb-clock { flex: none; }
.tb-clock .clk-time { min-width: 6.6em; font-feature-settings: "tnum" 1; }
.fin-report tr.muted-row td { color: var(--muted); font-size: 13px; }

/* Home: what is waiting for you, on top (screen review 2026-10-25) */
.wait-bar { max-width: 1000px; margin: 18px auto 0; display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; padding: 12px 16px; }
.wait-bar strong { font-size: 16px; }
.wait-bar .wb-total { font-variant-numeric: tabular-nums; }
.wait-bar .wb-chips { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; min-width: 0; }
.wait-bar .wb-chip { font-size: 12px; padding: 2px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--ink); font-weight: 600; text-decoration: none; }
.wait-bar .wb-chip.tone-warn { background: var(--warn-soft); color: var(--warn); }
.wait-bar .wb-chip.tone-bad { background: var(--bad-soft); color: var(--bad); }
.setup-foot { margin: 12px 0 0; }
/* Settings hub */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.settings-card { display: grid; grid-template-columns: 48px 1fr; gap: 4px 12px; align-items: start; color: var(--ink); text-decoration: none; margin: 0; }
.settings-card:hover { text-decoration: none; border-color: var(--card-hover-border); box-shadow: var(--shadow-md); }
.settings-card .app-icon { width: 48px; height: 48px; grid-row: span 2; }
.settings-card .app-icon .app-svg { width: 34px; height: 34px; }
.settings-card strong { font-size: 15px; }
.settings-card .muted { font-size: 13px; }
@media (max-width: 860px) { .wait-bar { margin-top: 10px; } }
/* A headline figure that opens its records (screen review 2026-10-25). */
a.kpi-tile.kpi-link { color: var(--ink); text-decoration: none; }
a.kpi-tile.kpi-link:hover { border-inline-color: var(--card-hover-border); border-bottom-color: var(--card-hover-border); box-shadow: var(--shadow-md); text-decoration: none; }
a.kpi-tile.kpi-link:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
/* Deadline chip (bid due date, quotation validity): days left, orange when near, red once passed. */
.due-chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 10px; border-radius: 999px; white-space: nowrap; background: var(--chip-bg); color: var(--muted); }
.due-chip.warn { background: var(--warn-soft); color: var(--warn); }
.due-chip.late { background: var(--bad-soft); color: var(--bad); }
.crm-card .due-chip { margin-top: 6px; }
.nat-address { border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px 4px; margin: 4px 0 12px; }
.nat-address legend { padding: 0 6px; font-weight: 700; }
.nat-address[hidden] { display: none; }
/* New quotation: the route choice (approved pricing sheet or quick manual quote). */
.route-choice { margin-bottom: 14px; }
.route-card { margin: 0; display: grid; gap: 8px; align-content: start; }
.route-card h2 { margin: 0; font-size: 17px; }
.route-card p { margin: 0; }
.route-card.chosen { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
/* ---- Form sections and the invoice summary (screen review 2026-10-25) ---- */
.form-sec { font-size: 15px; margin: 18px 0 10px; color: var(--brand); font-weight: 700; }
form > .form-sec:first-of-type { margin-top: 0; }
fieldset.form-terms { border: 1px dashed var(--line); border-radius: 10px; padding: 4px 14px 10px; margin: 14px 0; min-width: 0; }
.inv-summary { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 4px 14px 10px; margin: 14px 0; }
.sum-table { width: auto; min-width: min(360px, 100%); }
.sum-table td { padding: 4px 10px; border-bottom: 1px solid var(--line); }
.sum-table tr.strong td { font-weight: 700; }
.sum-table tr[hidden] { display: none; }
.proj-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0 10px; }
.proj-chips .chip { margin: 0; }
.chip.chip-bad { background: var(--bad-soft); color: var(--bad); }
.new-for-project { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; }
.new-for-project select { width: auto; min-width: 0; max-width: 100%; flex: 1 1 260px; }
/* Screen review 2026-10-25 (batch F): negative net flow on the CFO dashboard. */
.net-row td.neg, .net-row td.neg strong { color: var(--bad); }
.net-row th, .net-row td { border-top: 2px solid var(--line); }
.dep-preview { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: baseline; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 8px; margin: 4px 0 12px; font-size: 14px; }
.leave-balance { padding: 8px 0; font-size: 14px; color: var(--muted); }
/* ---- Screen review 2026-10-25 (purchasing and treasury) ---------------
   The hidden attribute always hides, whatever the element's display (a hidden .grid section of a form
   showed its fields before: the cash box form asked for a custodian). */
[hidden] { display: none !important; }
.cp-left { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* Session about to end (SessionPolicy): a bar at the bottom with "keep working". */
.session-warn { position: fixed; inset-inline: 16px; bottom: 16px; z-index: 1000; display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap;
    background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn); border-radius: 10px; padding: 10px 14px; font-weight: 700; box-shadow: 0 6px 20px rgba(0, 0, 0, .18); }
.session-warn[hidden] { display: none; }
@media print { .session-warn { display: none; } }


/* Punch log (2026-10-27): period chips, the role each punch has in its day, late / early in colour, day blocks. */
.punch-period { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; }
.period-chips { display: flex; flex-wrap: wrap; gap: 6px; }
input[type=date][dir=ltr] { text-align: start; }
/* Date fields in the page's language (public/js/date-input.js, 2026-10-31): a text field and a small calendar. */
html[dir=rtl] input[data-date] { text-align: right; }
html[dir=ltr] input[data-date] { text-align: left; }
input[data-date]::placeholder { color: var(--muted); opacity: .8; }
.date-pop { position: absolute; z-index: 1000; width: 272px; padding: 10px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.18); font-size: 14px; }
.date-pop button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; border-radius: 8px; }
.dp-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.dp-title { flex: 1; padding: 6px; font-weight: 700; }
.dp-title:hover, .dp-nav:hover, .dp-cell:hover, .dp-link:hover { background: var(--brand-soft); }
.dp-nav { width: 34px; height: 34px; font-size: 20px; line-height: 1; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.dp-months { grid-template-columns: repeat(3, 1fr); gap: 6px; }
.dp-dow { padding: 4px 0; color: var(--muted); font-size: 12px; }
.dp-cell { padding: 7px 0; font-variant-numeric: tabular-nums; }
.dp-cell.today { outline: 1px solid var(--brand); }
.dp-cell.on { background: var(--brand); color: var(--brand-ink); }
.dp-foot { display: flex; justify-content: space-between; margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; }
.dp-link { padding: 6px 10px; color: var(--brand); font-weight: 600; }
.unlinked-note { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.unlinked-item { background: var(--surface); color: var(--ink); border-radius: 999px; padding: 1px 10px; font-size: 13px; }
table.punch-log tr.day-start td { border-top: 2px solid var(--line); }
table.punch-log tr.is-dup td { opacity: .6; }
table.punch-log .t-late { color: var(--bad); font-weight: 700; }
table.punch-log .t-early { color: var(--warn); font-weight: 700; }
.role { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--chip-bg); color: var(--chip-ink); }
.role-in { background: var(--ok-soft); color: var(--ok); }
.role-out { background: var(--info-soft); color: var(--info); }
.role-dup { text-decoration: line-through; }
.role-single { background: var(--warn-soft); color: var(--warn); }
tr:target td { background: var(--brand-soft); }

/* The project file (owner request 2026-10-27): tabs, time bars, spend against the estimate, monthly bars */
.proj-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; padding: 4px 2px 10px; margin: 0 0 6px; }
.proj-tabs a { white-space: nowrap; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; font-size: 13.5px; color: var(--ink); background: var(--surface); text-decoration: none; }
.proj-tabs a:hover { background: var(--hover); text-decoration: none; }
.proj-tabs a.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.proj-dates { margin-top: 2px; }
.tbars { display: grid; gap: 10px; }
.tbar-row { display: grid; grid-template-columns: minmax(110px, 200px) 1fr 70px; gap: 12px; align-items: center; font-size: 13.5px; }
.tbar-track, .use-track { position: relative; display: block; height: 10px; border-radius: 999px; background: var(--grid); overflow: hidden; }
.tbar-fill, .use-fill { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: 999px; background: var(--brand); }
.tbar-row:nth-child(2) .tbar-fill { background: var(--series-1); }
.tbar-row:nth-child(3) .tbar-fill { background: var(--series-2); }
.use-fill.over, .tbar-fill.over { background: var(--bad); }
.tbar-val { text-align: end; font-variant-numeric: tabular-nums; color: var(--muted); }
.use-cell { min-width: 110px; }
.use-cell .use-pct { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
td.over { color: var(--bad); font-weight: 600; }
.pay { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--chip-bg); color: var(--chip-ink); white-space: nowrap; }
.pay-PAID { background: var(--ok-soft); color: var(--ok); }
.pay-PARTIAL, .pay-UNPAID { background: var(--warn-soft); color: var(--warn); }
.proj-alerts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.proj-alerts li { padding: 10px 14px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); }
.proj-alerts li.bad { background: var(--bad-soft); color: var(--bad); }
.proj-alerts li a { color: inherit; text-decoration: underline; }
.mchart { display: flex; align-items: flex-end; gap: 14px; height: 170px; padding: 8px 4px 0; border-bottom: 1px solid var(--grid); overflow-x: auto; overscroll-behavior-x: contain; }
.mchart .mcol { display: grid; grid-template-rows: 1fr auto; justify-items: center; height: 100%; min-width: 44px; }
.mchart .mbars { display: flex; align-items: flex-end; gap: 3px; height: 100%; }
.mchart .mbar { display: block; width: 16px; min-height: 1px; border-start-start-radius: 3px; border-start-end-radius: 3px; background: var(--series-1); }
.mchart .mbar.inv { background: var(--series-3); }
.mchart .mlabel { font-size: 11.5px; color: var(--muted); padding: 4px 0; white-space: nowrap; direction: ltr; }
.kv-list { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; margin: 0; }
.kv-list dt { color: var(--muted); }
.kv-list dd { margin: 0; text-align: end; font-variant-numeric: tabular-nums; }
table.nowrap-num td.num { white-space: nowrap; }
.kv-list dd small { display: block; color: var(--muted); font-size: 12px; }
@media (max-width: 600px) { .tbar-row { grid-template-columns: 1fr 56px; } .tbar-row .tbar-label { grid-column: 1 / -1; } }
/* Company documents (0058): both calendars, states, suggested-field chips, the review page beside its preview. */
.doc-hijri { display: block; font-size: 11px; color: var(--muted); }
.doc-state { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--line); color: var(--ink); white-space: nowrap; }
.doc-state.s-VALID, .doc-state.s-NO_EXPIRY { background: var(--ok-soft); color: var(--ok); }
.doc-state.s-EXPIRING, .doc-state.s-DRAFT { background: var(--warn-soft); color: var(--warn); }
.doc-state.s-EXPIRED { background: var(--bad-soft); color: var(--bad); }
.doc-state.s-ARCHIVED { color: var(--muted); }
.doc-chip { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--line); color: var(--muted); white-space: nowrap; }
.doc-chip.ok { background: var(--ok-soft); color: var(--ok); }
.doc-chip.bad { background: var(--bad-soft); color: var(--bad); white-space: normal; }
.doc-chip.sug { background: var(--warn-soft); color: var(--warn); margin-inline-start: 6px; }
.doc-filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.doc-filters input[type=search] { flex: 1 1 260px; }
/* The documents list (owner note 2026-10-31): each document and each column visibly apart; dates and numbers on one line. */
.doc-table th, .doc-table td { border: 1px solid var(--line); vertical-align: middle; }
.doc-table tr > :first-child { border-inline-start: 0; }
.doc-table tr > :last-child { border-inline-end: 0; }
.doc-table tr:nth-child(even) td { background: var(--surface-2); }
.doc-table th { white-space: nowrap; }
.doc-table td.nowrap .hint { white-space: nowrap; }
.doc-filters select { flex: 0 1 190px; width: auto; }
.doc-review { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.doc-preview { padding: 0; overflow: hidden; position: sticky; top: 12px; }
.doc-preview-bar { display: flex; justify-content: space-between; gap: 8px; padding: 8px 14px; background: var(--line); font-size: 13px; }
.doc-frame { display: block; width: 100%; height: 76vh; border: 0; background: var(--surface); }
.doc-open { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 16px; margin: 0; }
.doc-review-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.doc-image { display: block; max-width: 100%; margin: 0 auto; }
.doc-ai { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); }
.doc-dates { display: flex; gap: 8px; }
.doc-dates input { min-width: 0; }
.doc-checks { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.doc-checks label { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; }
.doc-type-form { margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); }
.doc-access { margin: 0; padding-inline-start: 18px; font-size: 13px; }
@media (max-width: 900px) { .doc-review { grid-template-columns: 1fr; } .doc-preview { position: static; } .doc-frame { height: 60vh; } }
@media (max-width: 600px) { .doc-filters select { flex: 1 1 45%; } .doc-dates { flex-direction: column; } }
/* Cost centres (0061) */
.cc-form { margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); min-width: min(640px, 80vw); }
.cc-depts { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.cc-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.cc-kpi { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--brand); border-radius: var(--radius); padding: 12px 14px; }
.cc-kpi.bad { border-top-color: var(--bad); }
.cc-kpi strong { display: block; font-size: 22px; margin-top: 4px; }
.cc-kpi.bad strong { color: var(--bad); }
.cc-table td.num a { color: inherit; }
.cc-table tr.sec td { font-weight: 600; background: var(--surface-2); }
@media (max-width: 600px) { .cc-form { min-width: 0; } .cc-kpi strong { font-size: 18px; } }
/* A code the system generates and never changes (0071). */
.field input.code-locked { background: var(--surface-2); color: var(--muted); border-style: dashed; box-shadow: none; cursor: default; }
