/* Booknip design system: CSS variables drive light, dark, system and corporate (tenant-branded) themes. */
:root {
  --bk-primary: #4f46e5;
  --bk-secondary: #0ea5e9;
  --bk-sidebar: #111827;
  --bk-font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Arabic", Arial, sans-serif;
  --bk-scale: 1;
  --bk-radius: .85rem;
  --bk-bg: #f4f6fb;
  --bk-surface: #ffffff;
  --bk-surface-2: #f8fafc;
  --bk-border: #e5e7eb;
  --bk-text: #0f172a;
  --bk-muted: #5b6577;
  --bk-sidebar-text: #cbd5e1;
  --bk-sidebar-active: rgba(255, 255, 255, .10);
  --bk-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
  --bk-rag-green: #16a34a; --bk-rag-amber: #d97706; --bk-rag-red: #dc2626; --bk-rag-blue: #2563eb; --bk-rag-grey: #94a3b8;
  --bs-primary: var(--bk-primary);
  --bs-link-color: var(--bk-primary);
  --bs-link-hover-color: color-mix(in srgb, var(--bk-primary) 80%, #000);
}
[data-theme="dark"] {
  --bk-bg: #0b1020;
  --bk-surface: #121a2e;
  --bk-surface-2: #0f172a;
  --bk-border: #24304a;
  --bk-text: #e2e8f0;
  --bk-muted: #94a3b8;
  --bk-sidebar: #0a0f1d;
  --bk-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  --bs-link-color: color-mix(in srgb, var(--bk-primary) 70%, #fff);
}
[data-theme="corporate"] {
  --bk-bg: color-mix(in srgb, var(--bk-primary) 5%, #f6f7fb);
  --bk-surface-2: color-mix(in srgb, var(--bk-primary) 3%, #fff);
  --bk-border: color-mix(in srgb, var(--bk-primary) 14%, #e5e7eb);
}

html { font-size: calc(16px * var(--bk-scale)); }
body { font-family: var(--bk-font); background: var(--bk-bg); color: var(--bk-text); -webkit-font-smoothing: antialiased; }
a { color: var(--bs-link-color); }
.text-muted, .form-text { color: var(--bk-muted) !important; }

/* Buttons and controls follow the brand colour */
.btn-primary { --bs-btn-bg: var(--bk-primary); --bs-btn-border-color: var(--bk-primary); --bs-btn-hover-bg: color-mix(in srgb, var(--bk-primary) 85%, #000); --bs-btn-hover-border-color: color-mix(in srgb, var(--bk-primary) 85%, #000); --bs-btn-active-bg: color-mix(in srgb, var(--bk-primary) 75%, #000); --bs-btn-disabled-bg: var(--bk-primary); --bs-btn-disabled-border-color: var(--bk-primary); }
.btn-outline-primary { --bs-btn-color: var(--bk-primary); --bs-btn-border-color: var(--bk-primary); --bs-btn-hover-bg: var(--bk-primary); --bs-btn-hover-border-color: var(--bk-primary); --bs-btn-active-bg: var(--bk-primary); }
.btn { border-radius: .6rem; font-weight: 500; }
.form-control, .form-select { border-radius: .6rem; background-color: var(--bk-surface); border-color: var(--bk-border); color: var(--bk-text); }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: var(--bk-primary); box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--bk-primary) 22%, transparent); }
.form-check-input:checked { background-color: var(--bk-primary); border-color: var(--bk-primary); }
.text-primary { color: var(--bk-primary) !important; }
.bg-primary-subtle { background: color-mix(in srgb, var(--bk-primary) 12%, transparent) !important; }
.badge.text-bg-primary { background: var(--bk-primary) !important; }

/* App shell */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 268px; flex: 0 0 268px; background: var(--bk-sidebar); color: var(--bk-sidebar-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; transition: width .2s, flex-basis .2s; z-index: 1030; }
.sidebar .brand { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1.2rem; color: #fff; text-decoration: none; font-weight: 700; letter-spacing: .2px; }
.sidebar .brand img { height: 32px; max-width: 150px; object-fit: contain; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--bk-primary), var(--bk-secondary)); display: grid; place-items: center; color: #fff; font-weight: 800; flex: none; box-shadow: 0 6px 16px color-mix(in srgb, var(--bk-primary) 45%, transparent); }
.brand-text small { display: block; font-weight: 500; font-size: .72rem; color: var(--bk-sidebar-text); opacity: .8; }
.sidebar-tools { padding: 0 .9rem .5rem; display: flex; flex-direction: column; gap: .45rem; }
.menu-filter { display: flex; align-items: center; gap: .45rem; padding: .3rem .4rem .3rem .7rem; border-radius: .6rem; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .08); color: var(--bk-sidebar-text); }
.menu-filter:focus-within { border-color: color-mix(in srgb, var(--bk-secondary) 70%, transparent); background: rgba(255, 255, 255, .09); }
.menu-filter input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: #fff; font-size: .86rem; }
.menu-filter input::placeholder { color: rgba(203, 213, 225, .6); }
.menu-palette { background: transparent; border: 0; padding: 0; color: inherit; }
.menu-palette kbd { background: rgba(255, 255, 255, .1); color: inherit; font-size: .66rem; }
.menu-actions { display: flex; gap: .35rem; }
.menu-actions button span { font-size: .72rem; margin-inline-start: .25rem; }
.sidebar .nav-link .label { flex: 0 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-actions button { background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .08); color: var(--bk-sidebar-text); border-radius: .45rem; padding: .15rem .5rem; font-size: .8rem; }
.menu-actions button:hover { color: #fff; background: rgba(255, 255, 255, .1); }
.menu-empty { color: rgba(203, 213, 225, .6); }
.ai-badge { display: inline-flex; align-items: center; font-size: .6rem; font-weight: 700; letter-spacing: .03em; padding: .08rem .38rem; border-radius: 999px; color: #fff; background: linear-gradient(135deg, #7c3aed, #2563eb); box-shadow: 0 0 0 1px rgba(255, 255, 255, .12) inset; white-space: nowrap; line-height: 1.3; }
.sidebar .nav-link .ai-badge { margin-inline-start: auto; }
.ai-dot { width: .45rem; height: .45rem; border-radius: 50%; background: linear-gradient(135deg, #a78bfa, #60a5fa); margin-inline-start: auto; box-shadow: 0 0 0 3px rgba(124, 58, 237, .25); }
.ai-dot + .chev { margin-inline-start: .5rem !important; }
.fav-toggle { opacity: 0; color: rgba(203, 213, 225, .7); padding: 0 .15rem; cursor: pointer; transition: opacity .15s; }
.sidebar .nav-link .fav-toggle i { font-size: .8rem; width: auto; }
.sidebar .nav-link:not(:has(.ai-badge)) .fav-toggle { margin-inline-start: auto; }
.sidebar .nav-link:hover .fav-toggle, .fav-toggle:focus, .fav-toggle.on { opacity: 1; }
.fav-toggle.on { color: #fbbf24; }
.fav-section .fav-toggle { opacity: 0; }
.fav-section .nav-link:hover .fav-toggle { opacity: 1; }
.menu-match mark { background: color-mix(in srgb, var(--bk-secondary) 45%, transparent); color: #fff; padding: 0; border-radius: 2px; }
.sidebar nav { overflow-y: auto; padding: .3rem .6rem 1rem; flex: 1; scrollbar-width: thin; }
.nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: rgba(203, 213, 225, .55); padding: .9rem .7rem .35rem; }
.sidebar .nav-link { display: flex; align-items: center; gap: .7rem; color: var(--bk-sidebar-text); padding: .5rem .7rem; border-radius: .55rem; font-size: .9rem; position: relative; }
.sidebar .nav-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; opacity: .9; }
.sidebar .nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar .nav-link.active { background: var(--bk-sidebar-active); color: #fff; }
.sidebar .nav-link.active::before { content: ""; position: absolute; inset-inline-start: -.6rem; top: .45rem; bottom: .45rem; width: 3px; border-radius: 3px; background: var(--bk-secondary); }
.sidebar .nav-link .chev { margin-inline-start: auto; transition: transform .2s; font-size: .75rem; }
.sidebar .nav-link[aria-expanded="true"] .chev { transform: rotate(90deg); }
.sidebar .subnav .nav-link { padding-inline-start: 2.6rem; font-size: .86rem; }
.sidebar-footer { padding: .8rem 1rem; border-top: 1px solid rgba(255, 255, 255, .07); font-size: .75rem; color: rgba(203, 213, 225, .6); }
/* Burger collapse: icons only; hovering the rail floats the full menu over the page. */
@media (min-width: 992px) {
  .sidebar-collapsed .sidebar { width: 76px; flex-basis: 76px; }
  .sidebar-collapsed .sidebar:not(:hover):not(:focus-within) :is(.brand-text, .label, .chev, .nav-section, .sidebar-tools, .sidebar-footer, .subnav, .ai-badge, .fav-toggle, .fav-section, .menu-empty) { display: none !important; }
  .sidebar-collapsed .sidebar:not(:hover):not(:focus-within) .nav-link { justify-content: center; }
  .sidebar-collapsed .sidebar:not(:hover):not(:focus-within) .ai-dot { position: absolute; top: .4rem; inset-inline-end: .55rem; margin: 0; }
  .sidebar-collapsed .sidebar:not(:hover):not(:focus-within) .nav-link:has(.ai-badge)::after { content: ""; position: absolute; top: .4rem; inset-inline-end: .55rem; width: .4rem; height: .4rem; border-radius: 50%; background: linear-gradient(135deg, #a78bfa, #60a5fa); }
  .sidebar-collapsed .sidebar:hover, .sidebar-collapsed .sidebar:focus-within { width: 280px; margin-inline-end: -204px; box-shadow: 12px 0 32px rgba(0, 0, 0, .3); }
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .6rem; padding: .65rem 1.4rem; background: color-mix(in srgb, var(--bk-surface) 85%, transparent); backdrop-filter: saturate(160%) blur(10px); border-bottom: 1px solid var(--bk-border); }
.topbar .btn-icon { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: .6rem; border: 1px solid var(--bk-border); background: var(--bk-surface); color: var(--bk-text); }
.topbar .btn-icon:hover { border-color: var(--bk-primary); color: var(--bk-primary); }
.topbar .chip { display: inline-flex; align-items: center; gap: .45rem; padding: .35rem .7rem; border-radius: 999px; border: 1px solid var(--bk-border); background: var(--bk-surface); color: var(--bk-text); font-size: .85rem; }
.btn-ai { background: linear-gradient(135deg, var(--bk-primary), var(--bk-secondary)); color: #fff !important; border: 0; box-shadow: 0 6px 18px color-mix(in srgb, var(--bk-primary) 35%, transparent); }
.btn-ai:hover { filter: brightness(1.08); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-size: .85rem; color: #fff; background: linear-gradient(135deg, var(--bk-secondary), var(--bk-primary)); }
.support-banner { background: repeating-linear-gradient(45deg, #f59e0b, #f59e0b 12px, #fbbf24 12px, #fbbf24 24px); color: #1f2937; font-weight: 600; padding: .45rem 1.4rem; display: flex; align-items: center; gap: .75rem; }
.content { padding: 1.5rem 1.6rem 3rem; width: 100%; max-width: none; }

/* Page header with action bar (User Guide, Std.Ref:, AI) */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; }
.page-head h1 { font-size: 1.55rem; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.page-head .crumb { font-size: .8rem; color: var(--bk-muted); margin-bottom: .2rem; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.btn-stdref { font-weight: 600; border: 1px dashed var(--bk-primary); color: var(--bk-primary); background: color-mix(in srgb, var(--bk-primary) 6%, transparent); }
.btn-stdref:hover { background: var(--bk-primary); color: #fff; }

/* Cards, tables, stats */
.card { background: var(--bk-surface); border: 1px solid var(--bk-border); border-radius: var(--bk-radius); box-shadow: var(--bk-shadow); color: var(--bk-text); }
.card-header { background: transparent; border-bottom: 1px solid var(--bk-border); padding: 1rem 1.2rem; font-weight: 600; }
.card-body { padding: 1.2rem; }
.table { --bs-table-bg: transparent; --bs-table-color: var(--bk-text); margin: 0; }
.table > :not(caption) > * > * { border-color: var(--bk-border); padding: .75rem 1rem; vertical-align: middle; }
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--bk-muted); font-weight: 600; background: var(--bk-surface-2); }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: color-mix(in srgb, var(--bk-primary) 5%, transparent); }
.stat { display: flex; gap: 1rem; align-items: center; }
.stat .icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 1.35rem; color: var(--bk-primary); background: color-mix(in srgb, var(--bk-primary) 12%, transparent); flex: none; }
.stat .value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat .label { color: var(--bk-muted); font-size: .82rem; }
.hero { position: relative; overflow: hidden; border-radius: calc(var(--bk-radius) + .2rem); padding: 1.6rem 1.8rem; color: #fff; background: radial-gradient(1200px 300px at 100% 0%, color-mix(in srgb, var(--bk-secondary) 70%, transparent), transparent 60%), linear-gradient(135deg, var(--bk-primary), color-mix(in srgb, var(--bk-primary) 55%, #0b1020)); box-shadow: var(--bk-shadow); }
.hero h2 { font-weight: 700; margin: 0 0 .3rem; }
.hero .ai-summary { background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .2); border-radius: .8rem; padding: .9rem 1rem; margin-top: 1rem; font-size: .92rem; }
.quick-link { display: flex; align-items: center; gap: .8rem; padding: .85rem 1rem; border-radius: .75rem; border: 1px solid var(--bk-border); background: var(--bk-surface); color: var(--bk-text); text-decoration: none; transition: transform .15s, border-color .15s, box-shadow .15s; }
.quick-link:hover { transform: translateY(-2px); border-color: var(--bk-primary); box-shadow: var(--bk-shadow); color: var(--bk-text); }
.quick-link i { font-size: 1.2rem; color: var(--bk-primary); }

/* RAG traffic lights */
.rag { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; font-weight: 600; }
.rag::before { content: ""; width: .65rem; height: .65rem; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 20%, transparent); }
.rag-Green { color: var(--bk-rag-green); } .rag-Amber { color: var(--bk-rag-amber); } .rag-Red { color: var(--bk-rag-red); } .rag-Blue { color: var(--bk-rag-blue); } .rag-Grey { color: var(--bk-rag-grey); }

/* AI */
.ai-label { display: inline-flex; align-items: center; gap: .3rem; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: .15rem .5rem; border-radius: 999px; background: color-mix(in srgb, var(--bk-primary) 14%, transparent); color: var(--bk-primary); }
.ai-thread { display: flex; flex-direction: column; gap: .8rem; }
.ai-msg { padding: .75rem .9rem; border-radius: .8rem; font-size: .92rem; white-space: pre-wrap; line-height: 1.5; }
.ai-msg.user { align-self: flex-end; background: var(--bk-primary); color: #fff; max-width: 85%; border-end-end-radius: .2rem; }
.ai-msg.bot { background: var(--bk-surface-2); border: 1px solid var(--bk-border); border-end-start-radius: .2rem; }
.ai-suggest { display: flex; flex-wrap: wrap; gap: .4rem; }
.ai-suggest button { font-size: .8rem; border-radius: 999px; }
.typing span { display: inline-block; width: 6px; height: 6px; margin: 0 2px; border-radius: 50%; background: var(--bk-muted); animation: blink 1.2s infinite both; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

/* Offcanvas, modal, dropdown in dark/corporate themes */
.offcanvas, .modal-content, .dropdown-menu { background: var(--bk-surface); color: var(--bk-text); border-color: var(--bk-border); }
.dropdown-item { color: var(--bk-text); border-radius: .4rem; }
.dropdown-menu { padding: .4rem; border-radius: .7rem; box-shadow: var(--bk-shadow); }
.dropdown-item.active, .dropdown-item:active { background: var(--bk-primary); }
.guide h6 { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--bk-muted); margin-top: 1.1rem; }
.guide ol, .guide ul { padding-inline-start: 1.2rem; }
.guide .dos li::marker { content: "✓  "; color: var(--bk-rag-green); }
.guide .donts li::marker { content: "✕  "; color: var(--bk-rag-red); }

/* Command palette */
.palette .modal-dialog { max-width: 640px; margin-top: 12vh; }
.palette input { font-size: 1.05rem; padding: .9rem 1rem; border: 0; border-bottom: 1px solid var(--bk-border); border-radius: 0; }
.palette .list-group-item { background: transparent; color: var(--bk-text); border: 0; border-radius: .5rem; display: flex; gap: .7rem; align-items: center; cursor: pointer; }
.palette .list-group-item.active { background: color-mix(in srgb, var(--bk-primary) 14%, transparent); color: var(--bk-text); }

/* Auth pages */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art { position: relative; padding: 3rem; color: #fff; display: flex; flex-direction: column; justify-content: space-between; background: radial-gradient(900px 400px at 0% 100%, rgba(14, 165, 233, .55), transparent 60%), linear-gradient(140deg, #312e81, #1e1b4b 55%, #0b1020); overflow: hidden; }
.auth-art h1 { font-size: 2.3rem; font-weight: 800; line-height: 1.15; max-width: 30rem; }
.auth-art .feature { display: flex; gap: .8rem; align-items: flex-start; margin-bottom: 1rem; color: #e0e7ff; }
.auth-art .feature i { font-size: 1.2rem; color: #7dd3fc; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem; background: var(--bk-bg); }
.auth-card { width: 100%; max-width: 420px; }
.demo-accounts button { font-size: .78rem; }

.theme-swatch { width: 100%; border: 2px solid var(--bk-border); border-radius: .8rem; padding: .7rem; background: var(--bk-surface); text-align: start; color: var(--bk-text); }
.theme-swatch.selected, .btn-check:checked + .theme-swatch { border-color: var(--bk-primary); box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--bk-primary) 20%, transparent); }
.theme-swatch .preview { height: 56px; border-radius: .5rem; margin-bottom: .5rem; display: flex; overflow: hidden; border: 1px solid var(--bk-border); }
.theme-swatch .preview span:first-child { width: 28%; }
.palette-swatch .preview i { display: block; width: 22px; height: 12px; border-radius: 4px; }
.palette-dots { display: grid; grid-template-columns: repeat(5, 28px); gap: .45rem; }
.palette-dot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--bk-surface); box-shadow: 0 0 0 1px var(--bk-border); background: linear-gradient(135deg, var(--dot-a) 55%, var(--dot-b) 55%); color: #fff; font-size: .75rem; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.palette-dot.active { box-shadow: 0 0 0 2px var(--bk-primary); }
.palette-dot:focus-visible { outline: 2px solid var(--bk-primary); outline-offset: 2px; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--bk-muted); }
.empty i { font-size: 2.4rem; color: var(--bk-primary); opacity: .6; }
.json-diff { font-family: Consolas, "Cascadia Mono", monospace; font-size: .78rem; white-space: pre-wrap; word-break: break-word; background: var(--bk-surface-2); border: 1px solid var(--bk-border); border-radius: .5rem; padding: .5rem .7rem; max-height: 220px; overflow: auto; }
.otp { font-family: Consolas, monospace; font-size: 1.15rem; letter-spacing: .08em; }

@media (max-width: 991.98px) {
  .sidebar { position: fixed; inset-inline-start: 0; transform: translateX(-100%); transition: transform .25s; }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
  .content { padding: 1rem; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Export toolbar (Copy / CSV / Excel / PDF) ---------- */
.export-toolbar { display: flex; align-items: center; gap: .5rem; padding: .5rem 1rem; border-bottom: 1px solid var(--bk-border); background: var(--bk-surface-2); }
.export-toolbar .btn { font-size: .8rem; }
.print-export { display: none; }
@media print {
  body.printing-export > *:not(.print-export) { display: none !important; }
  body.printing-export .print-export { display: block; font-family: system-ui, sans-serif; color: #000; }
  .print-export h1 { font-size: 16pt; margin: 0 0 4pt; }
  .print-export .meta { font-size: 8pt; color: #555; margin-bottom: 8pt; }
  .print-export table { width: 100%; border-collapse: collapse; font-size: 8pt; }
  .print-export th, .print-export td { border: 1px solid #bbb; padding: 3pt 4pt; text-align: start; vertical-align: top; }
  .print-export th { background: #eee; }
  .print-export thead { display: table-header-group; }
  .print-export { page: export-landscape; }
}
@page { size: A4 portrait; margin: 12mm; }
@page export-landscape { size: A4 landscape; margin: 12mm; }
/* Any printout (Ctrl+P or the Print button) shows only the page's content, never the app's menus. */
@media print {
  .sidebar, .topbar, .no-print, .export-toolbar, .page-head .btn, .page-tools { display: none !important; }
  .content { padding: 0 !important; margin: 0 !important; }
}

/* Collapsible filter panel for dashboards and reports */
.filter-toggle { position: relative; }
.filter-toggle .filter-count { position: absolute; top: -.35rem; inset-inline-end: -.35rem; font-size: .62rem; min-width: 1.1rem; height: 1.1rem; border-radius: 999px; background: var(--bk-primary); color: #fff; display: grid; place-items: center; padding: 0 .25rem; }
.filter-panel { border: 1px solid var(--bk-border); border-radius: .8rem; background: var(--bk-surface, var(--bs-body-bg)); padding: 1rem; margin-bottom: 1rem; }
.filter-panel .form-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--bs-secondary-color); margin-bottom: .2rem; }
.filter-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .75rem; }
.filter-chips .chip { font-size: .78rem; }

/* Per-user access editor */
.access-toolbar { top: .5rem; z-index: 20; }
.access-item { display: flex; align-items: center; gap: .55rem; padding: .35rem .5rem; border-radius: .45rem; cursor: pointer; font-size: .88rem; margin: 0; }
.access-item:hover { background: color-mix(in srgb, var(--bk-primary) 6%, transparent); }
.access-item .form-check-input { margin: 0; flex: none; }
.access-item.disabled { opacity: .5; cursor: not-allowed; }
.access-item.changed { background: color-mix(in srgb, #f59e0b 14%, transparent); box-shadow: inset 3px 0 0 #f59e0b; }
[dir="rtl"] .access-item.changed { box-shadow: inset -3px 0 0 #f59e0b; }

/* Practice screens: KPI tiles, funnel, kanban, charts */
.kpi { display: flex; flex-direction: column; gap: .15rem; container-type: inline-size; min-width: 0; }
/* Size containment gives the tile no width of its own, so beside an icon it must take the free space or it collapses to a sliver. */
.kpi { flex: 1 1 0%; width: 100%; }
.kpi .kpi-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--bk-muted); }
.kpi .kpi-value { font-size: 1.55rem; font-weight: 700; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Figures never break mid-number: on narrow tiles (phones, small columns) the value shrinks to fit the tile. */
@container (max-width: 240px) { .kpi .kpi-value { font-size: clamp(.95rem, 10.5cqi, 1.55rem); } }
.kpi .kpi-sub { font-size: .8rem; color: var(--bk-muted); }
.kpi-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem; background: color-mix(in srgb, var(--bk-primary) 12%, transparent); color: var(--bk-primary); flex: none; }
.funnel-row { display: grid; grid-template-columns: 130px 1fr 110px; gap: .75rem; align-items: center; margin-bottom: .55rem; font-size: .88rem; }
.funnel-bar { height: 26px; border-radius: 7px; background: var(--bk-surface-2); overflow: hidden; position: relative; }
.funnel-bar > span { display: block; height: 100%; border-radius: 7px; min-width: 2px; }
.funnel-bar > em { position: absolute; inset-inline-start: .5rem; top: 50%; transform: translateY(-50%); font-style: normal; font-size: .75rem; font-weight: 600; }
.bars { display: flex; align-items: flex-end; gap: .45rem; height: 160px; padding-top: .5rem; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .3rem; height: 100%; justify-content: flex-end; }
.bars .bar span { width: 100%; max-width: 34px; background: linear-gradient(180deg, var(--bk-primary), color-mix(in srgb, var(--bk-primary) 55%, transparent)); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.bars .bar small { font-size: .68rem; color: var(--bk-muted); white-space: nowrap; }
.stage-lead { --stage: #64748b; } .stage-qual { --stage: #0ea5e9; } .stage-est { --stage: #8b5cf6; } .stage-prop { --stage: #f59e0b; }
.stage-neg { --stage: #ec4899; } .stage-won { --stage: #16a34a; } .stage-lost { --stage: #dc2626; }
.stage-pill { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; color: var(--stage); background: color-mix(in srgb, var(--stage) 13%, transparent); white-space: nowrap; }
.funnel-bar > span.stage-fill { background: var(--stage); opacity: .85; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: .9rem; overflow-x: auto; padding-bottom: .75rem; }
.board-col { background: var(--bk-surface-2); border: 1px solid var(--bk-border); border-radius: .9rem; display: flex; flex-direction: column; min-height: 320px; }
.board-col header { padding: .7rem .85rem; border-bottom: 1px solid var(--bk-border); display: flex; align-items: center; gap: .5rem; border-top: 3px solid var(--stage); border-radius: .9rem .9rem 0 0; }
.board-col header .count { margin-inline-start: auto; font-size: .75rem; color: var(--bk-muted); }
.board-col .cards { padding: .6rem; display: flex; flex-direction: column; gap: .55rem; flex: 1; }
.board-col.drop-target { outline: 2px dashed var(--stage); outline-offset: -4px; }
.opp-card { background: var(--bk-surface); border: 1px solid var(--bk-border); border-radius: .7rem; padding: .7rem .75rem; display: block; color: inherit; text-decoration: none; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); cursor: grab; }
.opp-card:hover { border-color: color-mix(in srgb, var(--bk-primary) 40%, var(--bk-border)); color: inherit; }
.opp-card .t { font-weight: 600; font-size: .86rem; line-height: 1.3; }
.opp-card .c { font-size: .78rem; color: var(--bk-muted); }
.opp-card .f { display: flex; align-items: center; justify-content: space-between; margin-top: .45rem; font-size: .78rem; }
.mini-avatar { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font-size: .62rem; font-weight: 700; background: color-mix(in srgb, var(--bk-primary) 15%, transparent); color: var(--bk-primary); }
.overdue { color: var(--bk-rag-red); font-weight: 600; }
.stepper { display: flex; flex-wrap: wrap; gap: .35rem; }
.stepper .step { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .6rem; border-radius: 999px; font-size: .76rem; border: 1px solid var(--bk-border); color: var(--bk-muted); background: var(--bk-surface); }
.stepper .step.done { background: color-mix(in srgb, var(--bk-rag-green) 12%, transparent); border-color: transparent; color: var(--bk-rag-green); }
.stepper .step.current { background: var(--bk-primary); border-color: var(--bk-primary); color: #fff; font-weight: 600; }
.progress-thin { height: 6px; border-radius: 999px; background: var(--bk-surface-2); overflow: hidden; }
.progress-thin > span { display: block; height: 100%; background: var(--bk-primary); border-radius: 999px; }
.progress-thin.over > span { background: var(--bk-rag-red); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding-inline-start: 1.6rem; padding-bottom: 1rem; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: .45rem; top: .35rem; bottom: -.2rem; width: 2px; background: var(--bk-border); }
.timeline li:last-child::before { display: none; }
.timeline li > i { position: absolute; inset-inline-start: 0; top: .1rem; width: 1rem; height: 1rem; border-radius: 50%; background: var(--bk-surface); border: 2px solid var(--bk-primary); }
.dl-grid { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; font-size: .9rem; margin: 0; }
.dl-grid dt { color: var(--bk-muted); font-weight: 500; }
.dl-grid dd { margin: 0; }
.ai-box { border: 1px solid color-mix(in srgb, #7c3aed 30%, var(--bk-border)); background: linear-gradient(135deg, color-mix(in srgb, #7c3aed 6%, var(--bk-surface)), color-mix(in srgb, #2563eb 5%, var(--bk-surface))); border-radius: .9rem; padding: 1rem; }
.ai-box .ai-out { white-space: pre-wrap; font-size: .9rem; }
.doc-preview { white-space: pre-wrap; font-family: var(--bk-font); font-size: .92rem; line-height: 1.6; background: var(--bk-surface-2); border: 1px solid var(--bk-border); border-radius: .7rem; padding: 1rem 1.2rem; max-height: 560px; overflow: auto; }
.tpl-card { border: 1px solid var(--bk-border); border-radius: .75rem; padding: .75rem .85rem; background: var(--bk-surface); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.tpl-card:hover, .tpl-card.active { border-color: var(--bk-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bk-primary) 15%, transparent); }
.tpl-card .tpl-name { font-weight: 600; font-size: .9rem; }
.tpl-card .tpl-meta { font-size: .75rem; color: var(--bk-muted); }
.grid-editor input, .grid-editor select { border: 1px solid transparent; background: transparent; width: 100%; padding: .25rem .35rem; border-radius: .35rem; color: inherit; }
.grid-editor input:focus, .grid-editor select:focus { border-color: var(--bk-primary); background: var(--bk-surface); outline: 0; }
.grid-editor td { padding: .2rem .35rem !important; vertical-align: middle; }
.calc-panel .row-line { display: flex; justify-content: space-between; padding: .3rem 0; font-size: .9rem; border-bottom: 1px dashed var(--bk-border); }
.calc-panel .row-line:last-child { border-bottom: 0; }
.calc-panel .row-line.total { font-weight: 700; font-size: 1rem; }

/* Template browser (offcanvas) and library */
.tpl-browser.offcanvas-end { width: min(560px, 100vw); }
.tpl-list { display: flex; flex-direction: column; gap: .5rem; max-height: 42vh; overflow: auto; padding: .15rem; }
.tpl-card.match { border-inline-start: 3px solid var(--bk-primary); }
.tpl-browser .doc-preview { white-space: normal; max-height: 40vh; }
.tpl-kinds { display: flex; flex-wrap: wrap; gap: .5rem; }
.tpl-kind { display: inline-flex; align-items: center; gap: .45rem; padding: .45rem .75rem; border: 1px solid var(--bk-border); border-radius: 999px; background: var(--bk-surface); color: inherit; text-decoration: none; font-size: .85rem; }
.tpl-kind b { font-weight: 600; color: var(--bk-muted); }
.tpl-kind:hover { border-color: var(--bk-primary); color: inherit; }
.tpl-kind.active { background: var(--bk-primary); border-color: var(--bk-primary); color: #fff; }
.tpl-kind.active b { color: #fff; }
.section-edit { border-inline-start: 3px solid var(--bk-border); padding-inline-start: .75rem; }
.doc-render { background: var(--bk-surface); border: 1px solid var(--bk-border); border-radius: .7rem; padding: 2rem 2.4rem; line-height: 1.65; }
.doc-render h2 { font-size: 1.4rem; margin-bottom: 1rem; }
.doc-render h3 { font-size: 1.05rem; font-weight: 700; margin: 1.4rem 0 .5rem; color: var(--bk-primary); }
.doc-render p { margin-bottom: .6rem; }
.doc-render ul { padding-inline-start: 1.2rem; margin-bottom: .8rem; }
.doc-render table { font-size: .9rem; }
.doc-editor { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; line-height: 1.55; min-height: 520px; }
.rag-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; gap: 2px; }
.rag-bar > span { background: currentColor; }

/* ---------- Audit engine ---------- */
.audit-strip { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1.25rem; font-size: .85rem; padding: .55rem .9rem; border: 1px solid var(--bk-border); border-radius: .7rem; background: var(--bk-surface-2); }
.audit-tabs { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; }
.audit-tabs .nav-link { white-space: nowrap; }
.gate-list li { display: flex; align-items: center; gap: .45rem; padding: .15rem 0; }
.gate-list li.ok i { color: var(--bk-rag-green); }
.gate-list li.todo i { color: var(--bk-muted); }
.mat-box { border: 1px solid var(--bk-border); border-radius: .6rem; padding: .5rem; background: var(--bk-surface-2); }
.lead-key { display: inline-grid; place-items: center; min-width: 1.6rem; height: 1.6rem; border-radius: .4rem; font-weight: 700; font-size: .8rem; background: color-mix(in srgb, var(--bk-primary) 14%, transparent); color: var(--bk-primary); }
.heat td { font-weight: 700; height: 2.2rem; vertical-align: middle; }
.heat .heat-Low { background: color-mix(in srgb, var(--bk-rag-green) 22%, transparent); }
.heat .heat-Moderate { background: color-mix(in srgb, var(--bk-rag-amber) 26%, transparent); }
.heat .heat-High { background: color-mix(in srgb, var(--bk-rag-red) 26%, transparent); }
.jnl-grid input { width: 100%; border: 1px solid transparent; background: transparent; padding: .2rem .35rem; border-radius: .3rem; color: inherit; }
.jnl-grid input:hover, .jnl-grid input:focus { border-color: var(--bk-border); background: var(--bk-surface); outline: none; }
.jnl-grid tr.unbalanced td:first-child { box-shadow: inset 3px 0 0 var(--bk-rag-red); }
.signoff-row { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; font-size: .85rem; }
.review-note.cleared { opacity: .6; }
.note-response { background: var(--bk-surface-2); border-radius: .4rem; padding: .3rem .5rem; }
.fs-title { text-align: center; margin-bottom: 1rem; }
.fs-table { max-width: 900px; margin-inline: auto; }
.fs-table td, .fs-table th { border-color: transparent; }
.fs-table .fs-head td { font-weight: 700; padding-top: .8rem; }
.fs-table .fs-total td { font-weight: 700; border-top: 1px solid var(--bk-text); }
.fs-table .fs-head.fs-total td { border-bottom: 3px double var(--bk-text); }
.fs-table .lvl-1 { padding-inline-start: 1.5rem; }
@media print {
  body.printing-fs .sidebar, body.printing-fs .topbar, body.printing-fs .page-head, body.printing-fs .audit-strip, body.printing-fs .audit-tabs, body.printing-fs .no-print, body.printing-fs .export-toolbar { display: none !important; }
  body.printing-fs .content { padding: 0 !important; margin: 0 !important; }
  body.printing-fs .fs-doc .tab-pane { display: block !important; opacity: 1 !important; break-after: page; }
  body.printing-fs .card { border: 0 !important; box-shadow: none !important; }
}

/* Sampling and journal entry testing */
.sample-calc { background: var(--bs-tertiary-bg); border-radius: .5rem; padding: .6rem .75rem; }
.sample-input { min-width: 7rem; }
.population-table { max-height: 32rem; overflow-y: auto; }
.jet-narr { max-width: 22rem; }
.jet-band { width: 3.5rem; }
.jet-band-n { width: 2.5rem; }
.ai-suggestion { border-left: 3px solid var(--bs-primary); padding-left: .6rem; }
.jet-flags { display: flex; flex-wrap: wrap; gap: .2rem; margin-top: .25rem; }
.jet-flags .badge { font-weight: 500; }

/* ---------- Client requests and portal ---------- */
.pbc-grid textarea { min-height: 2rem; resize: vertical; }
.pbc-reply { background: var(--bs-tertiary-bg); border-radius: .375rem; padding: .25rem .5rem; }
.pbc-review > td { background: var(--bs-tertiary-bg); }
.table-info-subtle > td { background: var(--bs-info-bg-subtle); }
.pre-line { white-space: pre-line; }
.portal-link { word-break: break-all; font-size: .8rem; }
.portal { background: var(--bs-tertiary-bg); }
.portal-top { background: var(--bs-body-bg); border-top: 4px solid var(--portal-brand); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.portal-top .brand-mark { background: var(--portal-brand); }
.portal-logo { height: 2rem; width: auto; }
.portal .btn-primary { --bs-btn-bg: var(--portal-brand); --bs-btn-border-color: var(--portal-brand); --bs-btn-hover-bg: var(--portal-brand); --bs-btn-hover-border-color: var(--portal-brand); }
.portal .progress-bar { background: var(--portal-brand); }
.portal-progress { min-width: 12rem; }
.portal-note { background: var(--bs-warning-bg-subtle); border-radius: .375rem; padding: .5rem .75rem; font-size: .875rem; }
.portal-mini { height: .4rem; min-width: 5rem; }
.portal-sign { font-family: "Segoe Script", "Brush Script MT", cursive; font-size: 1.25rem; }

/* ---------- Auditor's report ---------- */
.audit-report { position: relative; max-width: 52rem; margin: 0 auto; font-family: Georgia, "Times New Roman", serif; line-height: 1.55; }
.audit-report h1 { font-size: 1.15rem; text-align: center; letter-spacing: .04em; margin-bottom: 1rem; }
.audit-report h2 { font-size: 1.05rem; text-decoration: underline; margin-top: 1.25rem; }
.audit-report h3 { font-size: .98rem; font-weight: 700; margin-top: 1.1rem; }
.audit-report p { text-align: justify; }
.report-watermark { position: absolute; inset: 30% 0 auto 0; text-align: center; font-size: 6rem; font-weight: 800; color: rgba(220, 53, 69, .08); transform: rotate(-20deg); pointer-events: none; }
@media print { body.printing-fs .audit-report { max-width: none; font-size: 10.5pt; } }

/* Timesheets */
.timesheet-grid .ts-cell { min-width: 4.25rem; }
.timesheet-grid .ts-weekend { background: var(--bs-tertiary-bg); }
.timesheet-grid th.ts-today { color: var(--bs-primary); }
.timesheet-grid td:first-child, .timesheet-grid th:first-child { min-width: 16rem; }
.ts-actions { min-width: 15rem; }

/* Questionnaires */
.tpl-pick { cursor: pointer; }
.tpl-pick:has(input:checked) { border-color: var(--bk-primary); box-shadow: 0 0 0 .15rem rgba(79, 70, 229, .15); }
.form-answer-col { min-width: 14rem; }

/* Billing */
.inv-num-col { width: 9rem; }
.invoice-doc { position: relative; max-width: 56rem; margin: 0 auto; }
.letter-spaced { letter-spacing: .08em; }
@media print { body.printing-fs .invoice-doc { max-width: none; font-size: 10.5pt; } }

/* Documents */
.doc-folders .list-group-item { font-size: .875rem; }
.doc-folders .list-group-item.active .badge { color: var(--bs-body-color); }

/* Notifications (§42): bell count, dropdown and unread rows */
.notif-count { position: absolute; top: -5px; inset-inline-end: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #dc3545; color: #fff; font-size: .68rem; font-weight: 600; line-height: 18px; text-align: center; }
.notif-menu { width: 340px; max-width: calc(100vw - 24px); }
.notif-item { display: flex; gap: .6rem; align-items: flex-start; white-space: normal; padding: .55rem 1rem; font-size: .85rem; }
.notif-item > .bi { margin-top: .15rem; color: var(--bk-muted, #6c757d); }
tr.notif-unread > td:first-child { box-shadow: inset 3px 0 0 var(--bs-primary); }

/* My Workspace (§35): work lists and calendar dates */
.ws-list .list-group-item { padding: .6rem 1rem; }
.ws-list .list-group-item:hover { background: var(--bk-hover, rgba(0,0,0,.03)); }
.ws-date { flex: 0 0 42px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: .5rem; background: var(--bs-primary-bg-subtle); color: var(--bs-primary); line-height: 1.05; padding: .25rem 0; }
.ws-date span { font-weight: 700; font-size: 1rem; }
.ws-date small { font-size: .65rem; text-transform: uppercase; }
.min-w-0 { min-width: 0; }

/* Report designer */
.report-table .report-group th { background: var(--bk-surface-2); font-weight: 600; }
.report-table .report-subtotal td { font-weight: 600; border-top: 1px solid var(--bk-border); }
.report-table .report-total td { font-weight: 700; background: var(--bk-surface-2); }
.report-logo { max-height: 48px; max-width: 160px; object-fit: contain; }
.report-bar { display: grid; grid-template-columns: minmax(90px, 220px) 1fr minmax(80px, auto); gap: .75rem; align-items: center; margin-bottom: .4rem; font-size: .875rem; }
.report-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report-bar-track { height: 14px; background: var(--bk-surface-2); border-radius: 4px; overflow: hidden; }
.report-bar-track > span { display: block; height: 100%; background: var(--bk-primary); border-radius: 4px; }
.report-bar-track > span.neg { background: var(--bk-rag-red); }
.report-bar-value { text-align: end; font-variant-numeric: tabular-nums; }
.report-columns { max-height: 420px; overflow-y: auto; }
@media print { .report-sheet { border: 0; } }
.sop-panel { border: 1px solid color-mix(in srgb, var(--bk-primary) 35%, transparent); border-radius: .75rem; padding: 1rem; background: color-mix(in srgb, var(--bk-primary) 5%, transparent); }
.update-diff { max-height: 460px; overflow-y: auto; font-size: .825rem; }
.diff-line { padding: .1rem .4rem; border-radius: 4px; white-space: pre-wrap; }
.diff-line .diff-mark { display: inline-block; width: 1rem; color: var(--bk-text-muted, #6c757d); }
.diff-add { background: color-mix(in srgb, var(--bk-rag-green) 14%, transparent); }
.diff-del { background: color-mix(in srgb, var(--bk-rag-red) 14%, transparent); text-decoration: line-through; }

/* Resource scheduler (§34) */
.sched td { min-width: 6.5rem; }
.sched .sched-items { max-width: 8rem; margin: 0 auto; font-size: .7rem; opacity: .8; }
.sched-free { background: rgba(25, 135, 84, .08); }
.sched-part { background: rgba(13, 110, 253, .16); }
.sched-full { background: rgba(13, 110, 253, .34); }
.sched-over { background: rgba(220, 53, 69, .38); font-weight: 600; }
.sched-off { background: repeating-linear-gradient(45deg, transparent, transparent 4px, rgba(128, 128, 128, .12) 4px, rgba(128, 128, 128, .12) 8px); }
.sched-key { display: inline-block; width: .9rem; height: .9rem; border-radius: .2rem; vertical-align: -2px; border: 1px solid var(--bs-border-color); }

/* ---------- Drill-down panel: details open over about 88% of the screen, with the path and a way back ---------- */
.drill-panel { --bs-offcanvas-width: min(88vw, 1680px); }
@media (max-width: 768px) { .drill-panel { --bs-offcanvas-width: 100vw; } }
.drill-frame { display: block; width: 100%; height: 100%; border: 0; background: var(--bk-bg, #fff); }
.drill-loading { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: color-mix(in srgb, var(--bk-surface, #fff) 70%, transparent); z-index: 2; }
.drill-loading.show { display: flex; }
.drill-crumbs { flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; scrollbar-width: thin; }
.drill-crumbs .breadcrumb-item a { text-decoration: none; }
.drill-crumbs .breadcrumb-item.active { font-weight: 600; color: var(--bk-text, inherit); }
.in-drill .sidebar, .in-drill .topbar { display: none !important; }
.in-drill .content { max-width: none; padding: 1rem 1.25rem 2rem; }
tr.drillable { cursor: pointer; }
tr.drillable:hover > td { background-color: color-mix(in srgb, var(--bk-primary) 6%, transparent); }
[data-drill], a.card .kpi { cursor: pointer; }
.drill-pane { height: 100%; overflow: auto; padding: 1rem 1.25rem 2rem; }
[data-drill-rows] { cursor: pointer; }
[data-drill-rows]:hover, a.card:hover { box-shadow: 0 0 0 2px color-mix(in srgb, var(--bk-primary) 35%, transparent); }
/* CFO cash forecast: weeks below the client's cash buffer */
.bars .bar.bar-warn span { background: linear-gradient(180deg, var(--bs-warning), color-mix(in srgb, var(--bs-warning) 55%, transparent)); }

/* Inputs inside grid tables keep a usable width on phones; the table scrolls sideways inside .table-responsive instead
   of squeezing an amount to a few pixels (valuation cash flows, VAT boxes, CFO lines). */
@media (max-width: 991.98px) {
    .table-responsive .table td > .form-control:not([type=checkbox]):not([type=radio]),
    .table-responsive .table td > .form-select { min-width: 7.5rem; }
    .table-responsive .table td > .form-control[type=number] { min-width: 8.5rem; }
    .table-responsive .table td > input[type=hidden] ~ .form-control { min-width: 10rem; }
}

/* Consolidation screens (engine pages) inside the Booknip page. */
.cons-load .form-select { min-width: 13rem; }
.cons-frame { display: block; width: 100%; min-height: 480px; border: 1px solid var(--bk-border); border-radius: .75rem; background: var(--bk-surface, #fff); }

/* ---------- QR code on issued documents and the public verification page ---------- */
.doc-qr { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: flex-end; margin-top: 1rem; break-inside: avoid; }
.doc-qr-item { margin: 0; width: 6.5rem; text-align: center; }
.doc-qr-code svg { display: block; width: 100%; height: auto; }
.doc-qr-item figcaption { font-size: .68rem; line-height: 1.25; color: var(--bk-muted, #6b7280); margin-top: .25rem; }
.verify-card { max-width: 36rem; }
.verify-card th { width: 40%; }
@media print { .doc-qr-item figcaption { color: #000; } }

/* Document designer: each firm's look for invoices, vouchers and payslips (colours, font, logo, page). */
.doc-styled { color: var(--doc-text, inherit); font-family: var(--doc-font, inherit); font-size: calc(1rem * var(--doc-scale, 1)); }
.doc-styled .table { --bs-table-color: var(--doc-text, inherit); font-size: inherit; }
.doc-styled .doc-title { color: var(--doc-accent, inherit); }
.doc-styled .doc-title-ar { font-size: .62em; letter-spacing: 0; }
.doc-styled thead th { color: var(--doc-accent, inherit); border-bottom: 2px solid var(--doc-accent, currentColor); }
.doc-styled .doc-rule { border-top: 3px solid var(--doc-accent, currentColor); margin: 0 0 1.25rem; opacity: 1; }
.doc-styled.doc-landscape { max-width: none; }
.doc-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.doc-brand { display: flex; align-items: center; gap: .9rem; flex: 1 1 auto; min-width: 0; }
.doc-head > .text-end { flex: 0 0 auto; }
@media (min-width: 576px) { .doc-head { flex-wrap: nowrap; } .doc-logo-centre .doc-head { flex-wrap: wrap; } }
.doc-logo { max-height: 4.5rem; max-width: 14rem; object-fit: contain; }
.doc-logo-right .doc-brand { order: 2; flex-direction: row-reverse; text-align: end; }
.doc-logo-centre .doc-head { flex-direction: column; align-items: center; text-align: center; }
.doc-logo-centre .doc-brand { flex-direction: column; }
.doc-logo-centre .doc-head .text-end { text-align: center !important; }
.doc-note { white-space: pre-line; font-size: .85em; }
.doc-foot { border-top: 1px solid var(--bk-border); margin-top: 1.25rem; padding-top: .75rem; }
.doc-sign { display: flex; justify-content: flex-end; margin-top: 2.5rem; }
.doc-sign span { border-top: 1px solid currentColor; min-width: 14rem; text-align: center; padding-top: .3rem; font-size: .85em; }
.designer-preview { position: sticky; top: 5rem; }
.designer-preview .doc-scale-box { overflow: auto; max-height: calc(100vh - 8rem); }
@page doc-a4-landscape { size: A4 landscape; margin: 12mm; }
@page doc-letter-portrait { size: letter portrait; margin: 12mm; }
@page doc-letter-landscape { size: letter landscape; margin: 12mm; }
@page doc-a5-portrait { size: A5 portrait; margin: 10mm; }
@page doc-a5-landscape { size: A5 landscape; margin: 10mm; }
.designer-preview .doc-portrait { aspect-ratio: 210 / 297; }
.designer-preview .doc-landscape { aspect-ratio: 297 / 210; }
/* A printed document is the whole printout: its own paper and orientation, full width, white, with the QR on the same page. */
@media print {
  body:has(.doc-styled), body:has(.doc-styled) .main, body:has(.doc-styled) .content { background: #fff !important; }
  body:has(.doc-styled) .page-head, body:has(.doc-styled) .alert { display: none !important; }
  body:has(.doc-paper-a4.doc-landscape) { page: doc-a4-landscape; }
  body:has(.doc-paper-letter.doc-portrait) { page: doc-letter-portrait; }
  body:has(.doc-paper-letter.doc-landscape) { page: doc-letter-landscape; }
  body:has(.doc-paper-a5.doc-portrait) { page: doc-a5-portrait; }
  body:has(.doc-paper-a5.doc-landscape) { page: doc-a5-landscape; }
  .doc-styled { max-width: none !important; width: 100%; padding: 0 !important; }
  .card:has(> .doc-styled) { border: 0 !important; box-shadow: none !important; width: 100%; background: #fff; }
  [class*="col-"]:has(.doc-styled) { flex: 0 0 100% !important; max-width: 100% !important; }
  .doc-styled .doc-qr { margin-top: .5rem; }
  .doc-styled .doc-qr-item { width: 5rem; }
  .doc-styled .doc-foot, .doc-styled .doc-qr, .doc-styled .doc-sign { break-inside: avoid; break-before: avoid; }
  .doc-styled.doc-landscape .doc-sign { margin-top: 1.5rem; }
}

/* Saved filter sets in every filter panel */
.saved-filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; border-top: 1px dashed var(--bk-border); margin-top: .75rem; padding-top: .75rem; }
.saved-filters .saved-filters-save { flex: 1 1 22rem; max-width: 36rem; }
@media (max-width: 575.98px) { .saved-filters .saved-filters-save { flex-wrap: wrap; } .saved-filters .saved-filters-save > .form-control { flex: 1 0 100%; border-radius: var(--bs-border-radius-sm) !important; margin-bottom: .25rem; } }
.saved-filters .dropdown-menu { min-width: 18rem; max-height: 22rem; overflow: auto; }
.saved-filters .sf-item { display: flex; align-items: center; gap: .5rem; }
.saved-filters .sf-item a { flex: 1; }
.saved-filters.saved-filters-inline { border-top: 0; margin-top: 0; padding-top: 0; margin-bottom: .75rem; }

/* Premium DMS metadata tree */
.dms-tree summary { cursor: pointer; padding: .15rem 0; list-style-position: inside; }
.dms-tree summary a { color: inherit; text-decoration: none; }
.dms-tree summary a:hover, .dms-tree li a:hover { text-decoration: underline; }
.dms-tree li a { color: inherit; text-decoration: none; }
.dms-preview { max-height: 9rem; overflow: auto; font-size: .8rem; white-space: pre-wrap; }

/* Full user guide */
.manual-shot { box-shadow: 0 .25rem 1rem rgba(0,0,0,.08); }
.manual-do { border-color: color-mix(in srgb, var(--bk-rag-green) 40%, transparent) !important; }
.manual-dont { border-color: color-mix(in srgb, var(--bk-rag-red) 40%, transparent) !important; }
@media print {
  body.printing-fs .manual-page { break-inside: avoid-page; page-break-inside: avoid; }
  body.printing-fs .manual-section { break-before: page; }
  body.printing-fs .manual-toc a { color: #000; text-decoration: none; }
  body.printing-fs .manual-cover { break-after: page; }
}
@media print { body.printing-fs, body.printing-fs .content, body.printing-fs main { background: #fff !important; } }

/* Body editor grid: wide enough to read each cell; the table scrolls sideways on small screens. */
[data-body-editor] table[data-rows] td input.form-control:not([type=number]) { min-width: 11rem; }
[data-body-editor] table[data-rows] td:first-child input.form-control { min-width: 4.5rem; }
[data-body-editor] table[data-rows] td select.form-select { min-width: 8rem; }
.para-body { min-width: 14rem; }
.para-text { white-space: pre-wrap; }
/* Statements in audited-FS style: single rule above subtotals, double rule under grand totals. */
.fs-table td, .fs-table th { white-space: nowrap; }
.fs-table td:first-child { white-space: normal; min-width: 14rem; }
.fs-table tr.fs-total td:not(:first-child) { border-top: 1px solid var(--bk-text, #212529); }
.fs-table tr.fs-grand td:not(:first-child) { border-top: 1px solid var(--bk-text, #212529); border-bottom: 3px double var(--bk-text, #212529); }
@media print { .cons-fs-tabs { display: none; } .tab-content > .tab-pane { display: block !important; opacity: 1 !important; page-break-after: always; } }
.checklist-note { min-width: 10rem; max-width: 18rem; }
.notes-list { max-height: 70vh; overflow: auto; }

/* Consolidated FS pack: the issued document (preview, print and shared link) */
.fs-pack { position: relative; max-width: 960px; margin-inline: auto; background: var(--bs-body-bg); color: var(--bk-text); }
.fs-pack .pack-page { padding: 2rem 2.25rem; border-bottom: 1px solid var(--bs-border-color); }
.fs-pack .pack-cover { min-height: 60vh; display: flex; flex-direction: column; justify-content: center; gap: .35rem; }
.fs-pack .pack-cover-firm { margin-top: 2rem; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--bs-secondary-color); }
.fs-pack .pack-cover-title { font-size: 2.2rem; font-weight: 700; color: #1f3864; margin: 0; }
.fs-pack .pack-cover-sub { font-size: 1.35rem; font-weight: 600; }
.fs-pack .pack-cover-period, .fs-pack .pack-cover-units { color: var(--bs-secondary-color); }
.fs-pack .pack-cover-status { margin-top: 1.5rem; font-size: .9rem; }
.fs-pack .pack-cover .doc-qr { margin-top: 1rem; }
.fs-pack .pack-h { font-size: 1.15rem; font-weight: 700; color: #1f3864; margin-bottom: .2rem; }
.fs-pack .pack-meta { font-size: .85rem; color: var(--bs-secondary-color); margin-bottom: 1rem; }
.fs-pack .pack-table { max-width: none; font-size: .9rem; }
.fs-pack .pack-table thead th { border-bottom: 1px solid var(--bk-text); font-weight: 600; }
.fs-pack .pack-section td { font-weight: 700; padding-top: .7rem; }
.fs-pack .pack-note { width: 4rem; text-align: center; color: var(--bs-secondary-color); }
.fs-pack .pack-contents li { margin-bottom: .3rem; }
.fs-pack .pack-contents-notes { columns: 2; font-size: .9rem; color: var(--bs-secondary-color); margin-top: .3rem; }
.fs-pack .pack-note-block { margin-bottom: 1.5rem; break-inside: avoid-page; }
.fs-pack .pack-note-title { font-size: 1rem; font-weight: 700; margin-bottom: .1rem; }
.fs-pack .pack-note-ref { font-size: .8rem; color: var(--bs-secondary-color); margin-bottom: .4rem; }
.fs-pack .pack-approval { margin-top: 2rem; font-size: .85rem; font-style: italic; }
.fs-pack .pack-watermark { position: absolute; inset: 0; display: flex; align-items: flex-start; justify-content: center; padding-top: 20rem; font-size: 8rem; font-weight: 800; color: rgba(220, 53, 69, .08); transform: rotate(-20deg); pointer-events: none; z-index: 1; overflow: hidden; }
@media (max-width: 575.98px) { .fs-pack .pack-page { padding: 1.25rem 1rem; } .fs-pack .pack-cover-title { font-size: 1.6rem; } .fs-pack .pack-contents-notes { columns: 1; } }
@media print {
  body.printing-fs .fs-pack { max-width: none; font-size: 10.5pt; }
  body.printing-fs .fs-pack .pack-page { border: 0; padding: 0 0 1rem; break-after: page; }
  body.printing-fs .fs-pack .pack-cover { min-height: 90vh; }
  body.printing-fs .fs-pack .pack-watermark { position: fixed; padding-top: 40vh; }
  body.printing-fs .shared-bar { display: none !important; }
}
.publish-readiness .list-group-item { display: flex; gap: .6rem; align-items: flex-start; }
.pack-frame { position: relative; overflow: hidden; }
.pack-overlay-mark { position: absolute; inset: 0; display: flex; align-items: flex-start; justify-content: center; padding-top: 22rem; font-size: 5rem; font-weight: 800; color: rgba(31, 56, 100, .08); transform: rotate(-20deg); pointer-events: none; z-index: 2; text-align: center; }
.pack-recipient-mark { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-around; align-items: center; pointer-events: none; z-index: 2; color: rgba(31, 56, 100, .07); font-size: 1.4rem; font-weight: 700; transform: rotate(-20deg); white-space: nowrap; }
.shared-print-block { display: none; }
@media print {
  body.printing-fs .pack-overlay-mark { position: fixed; padding-top: 40vh; }
  body.printing-fs .pack-recipient-mark { position: fixed; }
  .shared-view-only { display: none !important; }
  .shared-print-block { display: block; padding: 3rem; text-align: center; font-size: 14pt; }
}
/* Carry-forward wizard steps */
.cf-steps { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; padding: 0; counter-reset: cf; }
.cf-steps li { counter-increment: cf; flex: 1 1 9rem; padding: .5rem .75rem; border-radius: .5rem; background: var(--bs-tertiary-bg); font-size: .85rem; color: var(--bs-secondary-color); }
.cf-steps li::before { content: counter(cf) ". "; font-weight: 700; }
.cf-steps li.active { background: var(--bs-primary-bg-subtle); color: var(--bs-primary-text-emphasis); font-weight: 600; }
.cf-steps li.done { background: var(--bs-success-bg-subtle); color: var(--bs-success-text-emphasis); }
/* Consolidation document repository tree */
.doc-tree .doc-node { display: flex; align-items: center; gap: .25rem; padding: .25rem .4rem; border-radius: .35rem; color: inherit; text-decoration: none; }
.doc-tree .doc-node:hover, .doc-tree .doc-node.active { background: var(--bs-primary-bg-subtle); }
.doc-checksum { max-width: 8rem; }

/* Transfer pricing: the arm's length range picture */
.tp-range { position: relative; height: 1.25rem; border-radius: 999px; background: var(--bk-surface-2, rgba(127,127,127,.12)); }
.tp-range .tp-iqr { position: absolute; top: 0; bottom: 0; border-radius: 999px; background: color-mix(in srgb, var(--bk-rag-green) 35%, transparent); }
.tp-range .tp-mark { position: absolute; top: -.2rem; bottom: -.2rem; width: 3px; margin-left: -1.5px; border-radius: 2px; }
.tp-median { background: var(--bk-rag-green); }
.tp-tested { background: var(--bs-primary); }
.tp-key { display: inline-block; width: .6rem; height: .6rem; border-radius: 2px; margin-right: .25rem; vertical-align: middle; }
.text-prewrap { white-space: pre-wrap; }

/* Module dashboard bars that run across: label, track and figure. */
.hbars { display: flex; flex-direction: column; gap: .55rem; }
.hbar { display: grid; grid-template-columns: minmax(6rem, 38%) 1fr auto; align-items: center; gap: .6rem; font-size: .85rem; }
.hbar-link { cursor: pointer; }
.hbar-link:hover .hbar-label { color: var(--bk-primary); text-decoration: underline; }
.hbar-track { height: .6rem; background: color-mix(in srgb, var(--bk-muted) 18%, transparent); border-radius: 999px; overflow: hidden; }
.hbar-track > span { display: block; height: 100%; background: linear-gradient(90deg, var(--bk-primary), color-mix(in srgb, var(--bk-primary) 60%, transparent)); border-radius: 999px; min-width: 2px; }
.hbar-warn .hbar-track > span { background: linear-gradient(90deg, var(--bs-warning), color-mix(in srgb, var(--bs-warning) 60%, transparent)); }
.hbar-value { font-variant-numeric: tabular-nums; color: var(--bk-muted); white-space: nowrap; }
.bars .bar small { overflow: hidden; text-overflow: ellipsis; }

/* Independence graph: people on the left, clients on the right, ties coloured by the worst interest behind them. */
.ig-graph { min-width: 720px; font-size: 12px; direction: ltr; unicode-bidi: isolate; }
.ig-graph a { text-decoration: none; }
.ig-graph .ig-head { font-weight: 600; fill: var(--bs-secondary-color); text-transform: uppercase; font-size: 11px; }
.ig-graph .ig-label { fill: var(--bs-body-color); }
.ig-graph a:hover .ig-label { text-decoration: underline; fill: var(--bs-primary); }
.ig-link { fill: none; stroke-width: 1.5; opacity: .75; }
.ig-link:hover { stroke-width: 4; opacity: 1; }
.ig-node { stroke: var(--bs-body-bg); stroke-width: 2; }
.ig-team { --ig: var(--bs-secondary-color); }
.ig-cleared { --ig: var(--bs-success); }
.ig-safeguarded { --ig: var(--bs-info); }
.ig-declared { --ig: var(--bs-warning); }
.ig-prohibited { --ig: #b02a37; }
.ig-conflict { --ig: var(--bs-danger); }
.ig-link.ig-team { stroke: var(--ig); opacity: .35; stroke-width: 1; }
.ig-link:not(.ig-team) { stroke: var(--ig); stroke-width: 2.5; }
.ig-link.ig-conflict, .ig-link.ig-prohibited { stroke-dasharray: 6 3; stroke-width: 3; }
.ig-node { fill: var(--ig); }
.ig-key { display: inline-flex; align-items: center; gap: .35rem; }
.ig-key::before { content: ""; width: 1.25rem; height: 3px; border-radius: 2px; background: var(--ig); }

/* Column charts: bars share the card's width and long month labels shorten rather than push the page sideways (RTL too). */
.bars { overflow: hidden; }
.bars .bar { min-width: 0; }
.bars .bar small { max-width: 100%; }

/* ---------- Traffic lights (blueprint §10) ---------- */
.rag { padding: .18rem .6rem .18rem .45rem; border-radius: 999px; background: color-mix(in srgb, currentColor 11%, transparent); border: 1px solid color-mix(in srgb, currentColor 35%, transparent); line-height: 1.25; white-space: nowrap; }
.rag::before { box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 25%, transparent), 0 0 8px currentColor; }
.rag.rag-Grey::before { box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 25%, transparent); }
.tl { display: inline-flex; flex-direction: column; gap: .22rem; padding: .3rem; border-radius: .7rem; background: #1f2937; box-shadow: inset 0 0 0 2px #111827; vertical-align: middle; }
.tl.tl-row { flex-direction: row; }
.tl > i { width: .8rem; height: .8rem; border-radius: 50%; background: #374151; display: block; }
.tl.tl-lg > i { width: 1.35rem; height: 1.35rem; }
.tl.tl-sm > i { width: .55rem; height: .55rem; }
.tl.on-Red > .l-r { background: var(--bk-rag-red); box-shadow: 0 0 10px var(--bk-rag-red); }
.tl.on-Amber > .l-a { background: var(--bk-rag-amber); box-shadow: 0 0 10px var(--bk-rag-amber); }
.tl.on-Green > .l-g { background: var(--bk-rag-green); box-shadow: 0 0 10px var(--bk-rag-green); }
.tl.on-Blue > .l-g { background: var(--bk-rag-blue); box-shadow: 0 0 8px var(--bk-rag-blue); }
.tl-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: .75rem; }
.tl-area { display: flex; align-items: center; gap: .75rem; padding: .7rem .85rem; border: 1px solid var(--bk-border); border-radius: .8rem; background: var(--bk-surface); color: var(--bk-text); text-decoration: none; border-inline-start: 4px solid var(--rag, var(--bk-border)); transition: transform .15s, box-shadow .15s; }
.tl-area:hover { transform: translateY(-2px); box-shadow: var(--bk-shadow); color: var(--bk-text); }
.tl-area .tl-name { font-weight: 600; font-size: .9rem; }
.tl-area .tl-sub { font-size: .78rem; color: var(--bk-muted, #6b7280); }
.tl-area.rag-area-Red { --rag: var(--bk-rag-red); } .tl-area.rag-area-Amber { --rag: var(--bk-rag-amber); } .tl-area.rag-area-Green { --rag: var(--bk-rag-green); } .tl-area.rag-area-Blue { --rag: var(--bk-rag-blue); }
.tl-count { display: flex; align-items: center; gap: .5rem; padding: .35rem 0; color: var(--bk-text); text-decoration: none; }
.tl-count b { font-size: 1.35rem; min-width: 2.2rem; }
/* KPI tiles light up by the colour of their figure: red needs action, amber needs watching, green is on target. */
.card:has(> .card-body.kpi .kpi-value.text-danger), .card:has(> .kpi .kpi-value.text-danger) { border-top: 4px solid var(--bk-rag-red); }
.card:has(> .card-body.kpi .kpi-value.text-warning), .card:has(> .kpi .kpi-value.text-warning) { border-top: 4px solid var(--bk-rag-amber); }
.card:has(> .card-body.kpi .kpi-value.text-success), .card:has(> .kpi .kpi-value.text-success) { border-top: 4px solid var(--bk-rag-green); }
.card-body.kpi:has(.kpi-value.text-danger) .kpi-label::before, .card-body.kpi:has(.kpi-value.text-warning) .kpi-label::before, .card-body.kpi:has(.kpi-value.text-success) .kpi-label::before { content: ""; display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; margin-inline-end: .35rem; vertical-align: middle; }
.card-body.kpi:has(.kpi-value.text-danger) .kpi-label::before { background: var(--bk-rag-red); box-shadow: 0 0 6px var(--bk-rag-red); }
.card-body.kpi:has(.kpi-value.text-warning) .kpi-label::before { background: var(--bk-rag-amber); box-shadow: 0 0 6px var(--bk-rag-amber); }
.card-body.kpi:has(.kpi-value.text-success) .kpi-label::before { background: var(--bk-rag-green); box-shadow: 0 0 6px var(--bk-rag-green); }

/* Country switcher: fifteen entries scroll on short screens. */
.country-menu { max-height: min(70vh, 32rem); overflow-y: auto; }

/* Phones: the top bar must fit 360-390px screens, otherwise every page is zoomed out with a sideways scroll. */
@media (max-width: 575.98px) {
  .topbar { padding: .5rem .75rem; gap: .4rem; }
  .topbar > .ms-auto { gap: .3rem !important; min-width: 0; }
  .topbar .btn-icon { width: 34px; height: 34px; }
  .topbar .avatar { width: 32px; height: 32px; }
  .topbar .chip { padding: .3rem .5rem; gap: .3rem; max-width: 7.5rem; }
  .topbar .chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .topbar .btn-ai { padding-left: .5rem !important; padding-right: .5rem !important; }
}

/* Light theme: amber, grey and stage colours used as text must stay readable on white (WCAG AA, 4.5:1). Fills keep the brighter colour. */
[data-bs-theme="light"] .text-warning { color: #a15c07 !important; }
[data-bs-theme="light"] .rag-Grey { color: #526071; }
[data-bs-theme="light"] .rag-Amber { color: #92400e; }
[data-bs-theme="light"] .stage-pill { color: color-mix(in srgb, var(--stage) 52%, #000); }
/* QA-19: green, red and blue labels and outline buttons on tinted backgrounds (light theme, 4.5:1). */
[data-bs-theme="light"] .rag-Green { color: #166534; }
[data-bs-theme="light"] .rag-Red { color: #991b1b; }
[data-bs-theme="light"] .rag-Blue { color: #1e40af; }
[data-bs-theme="light"] .btn-outline-secondary { --bs-btn-color: #4a5260; --bs-btn-border-color: #8a93a0; }
[data-bs-theme="light"] .btn-outline-success { --bs-btn-color: #0f5132; --bs-btn-border-color: #146c43; }
[data-bs-theme="light"] .btn-outline-danger { --bs-btn-color: #9a1c27; --bs-btn-border-color: #b02a37; }

/* Process flow: one arrow per stage, traffic-light colours, and a green progress bar with the share complete. */
.process-flow { --flow-green: #15803d; --flow-amber: #b45309; --flow-red: #b91c1c; --flow-todo-bg: color-mix(in srgb, var(--bk-border) 70%, var(--bk-surface)); min-width: 0; }
.process-flow-title { font-size: .78rem; font-weight: 600; color: var(--bk-muted); margin-bottom: .35rem; text-transform: uppercase; letter-spacing: .03em; }
.flow-arrows { display: flex; flex-wrap: wrap; row-gap: .4rem; list-style: none; margin: 0; padding: 0; }
.flow-arrow { position: relative; margin-inline-end: -4px; }
.flow-arrow > a, .flow-arrow > .flow-arrow-body { display: inline-flex; align-items: center; gap: .35rem; min-height: 2.1rem; padding: .35rem 1.25rem .35rem 1.35rem; font-size: .78rem; font-weight: 600; line-height: 1.15; text-decoration: none; color: inherit;
  clip-path: polygon(0 0, calc(100% - .8rem) 0, 100% 50%, calc(100% - .8rem) 100%, 0 100%, .8rem 50%); }
.flow-arrow:first-child > a, .flow-arrow:first-child > .flow-arrow-body { padding-inline-start: .9rem; clip-path: polygon(0 0, calc(100% - .8rem) 0, 100% 50%, calc(100% - .8rem) 100%, 0 100%); }
[dir="rtl"] .flow-arrow > a, [dir="rtl"] .flow-arrow > .flow-arrow-body { clip-path: polygon(.8rem 0, 100% 0, calc(100% - .8rem) 50%, 100% 100%, .8rem 100%, 0 50%); }
[dir="rtl"] .flow-arrow:first-child > a, [dir="rtl"] .flow-arrow:first-child > .flow-arrow-body { clip-path: polygon(.8rem 0, 100% 0, 100% 100%, .8rem 100%, 0 50%); }
.flow-done > * { background: var(--flow-green); color: #fff !important; }
.flow-ontrack > * { background: var(--flow-green); color: #fff !important; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
.flow-atrisk > * { background: var(--flow-amber); color: #fff !important; }
.flow-blocked > * { background: var(--flow-red); color: #fff !important; }
.flow-todo > * { background: var(--flow-todo-bg); color: var(--bk-muted) !important; }
.flow-skipped > * { background: transparent; color: var(--bk-muted) !important; text-decoration: line-through; outline: 1px dashed var(--bk-border); }
.flow-arrow > a:hover, .flow-arrow > a:focus-visible { filter: brightness(1.08); }
.flow-progress-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; margin-top: .55rem; }
.flow-progress { flex: 1 1 10rem; height: .55rem; border-radius: 999px; background: color-mix(in srgb, var(--flow-green) 14%, var(--bk-surface)); overflow: hidden; min-width: 6rem; }
.flow-progress > span { display: block; height: 100%; background: linear-gradient(90deg, #16a34a, var(--flow-green)); border-radius: inherit; transition: width .4s ease; }
.flow-progress-label { font-size: .8rem; font-weight: 700; color: var(--flow-green); }
.flow-light { display: inline-flex; align-items: center; gap: .3rem; font-size: .76rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; }
.flow-light.flow-done, .flow-light.flow-ontrack { color: var(--flow-green); background: color-mix(in srgb, var(--flow-green) 12%, transparent); }
.flow-light.flow-atrisk { color: var(--flow-amber); background: color-mix(in srgb, var(--flow-amber) 12%, transparent); }
.flow-light.flow-blocked { color: var(--flow-red); background: color-mix(in srgb, var(--flow-red) 12%, transparent); }
.flow-note { font-size: .78rem; color: var(--bk-muted); }
[data-bs-theme="dark"] .process-flow { --flow-green: #15803d; --flow-amber: #b45309; --flow-red: #b91c1c; }
[data-bs-theme="dark"] .flow-progress-label, [data-bs-theme="dark"] .flow-light.flow-done, [data-bs-theme="dark"] .flow-light.flow-ontrack { color: #4ade80; }
[data-bs-theme="dark"] .flow-light.flow-atrisk { color: #fbbf24; }
[data-bs-theme="dark"] .flow-light.flow-blocked { color: #f87171; }
@media (max-width: 575.98px) { .flow-arrow > a, .flow-arrow > .flow-arrow-body { font-size: .72rem; padding-inline: 1rem .95rem; min-height: 1.9rem; } }
@media print { .flow-arrow > * { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }
.flow-count { display: inline-block; min-width: 1.4rem; padding: 0 .35rem; border-radius: 999px; background: rgba(255,255,255,.25); text-align: center; font-variant-numeric: tabular-nums; }
.flow-todo .flow-count { background: color-mix(in srgb, var(--bk-muted) 18%, transparent); }
.flow-mini { display: inline-flex; gap: 2px; margin-top: .2rem; }
.flow-mini > i { width: .95rem; height: .55rem; clip-path: polygon(0 0, 70% 0, 100% 50%, 70% 100%, 0 100%, 30% 50%); background: var(--flow-todo-bg, color-mix(in srgb, var(--bk-border) 70%, var(--bk-surface))); }
[dir="rtl"] .flow-mini > i { clip-path: polygon(30% 0, 100% 0, 70% 50%, 100% 100%, 30% 100%, 0 50%); }
.flow-mini > i.flow-done, .flow-mini > i.flow-ontrack { background: #15803d; }
.flow-mini > i.flow-atrisk { background: #b45309; }
.flow-mini > i.flow-blocked { background: #b91c1c; }
.flow-mini > i.flow-todo { background: color-mix(in srgb, var(--bk-border) 85%, var(--bk-surface)); }

/* Visually hidden labels inside icon buttons stay within a table's scroll box on phones. */
.table-responsive { position: relative; }

/* Invoice and receipt documents stay within their card on phones; the line table scrolls inside them. */
@media screen { .card > .doc-styled, .card > .invoice-doc { width: 100%; min-width: 0; } .invoice-doc img, .invoice-doc svg, .invoice-doc figure { max-width: 100%; height: auto; } }

/* Evidence linking: differences between the book and the document stand out; the preview keeps to its card. */
.evidence-diff { color: var(--bk-rag-red); font-weight: 600; }
.evidence-marks span { display: inline-flex; align-items: center; gap: .15rem; margin-inline-end: .35rem; font-size: .8rem; }
.evidence-legend span { margin-inline-start: .6rem; white-space: nowrap; }
.evidence-chips .badge[data-drill-rows] { cursor: pointer; }
.evidence-num { width: 7rem; }
.evidence-actions { min-width: 12rem; }
.evidence-frame { width: 100%; height: 60vh; min-height: 320px; }
.evidence-text { white-space: pre-wrap; max-height: 320px; overflow: auto; font-size: .78rem; }
tr.evidence-prefilled > td { box-shadow: inset 0 0 0 9999px color-mix(in srgb, var(--bk-rag-green) 12%, transparent); }

/* Population analytics: Benford chart (actual bars, expected marker), drillable like every chart. */
.benford { display: flex; align-items: stretch; gap: .45rem; height: 180px; padding-top: .5rem; }
.benford .bf { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: .3rem; cursor: pointer; }
.benford .bf-plot { position: relative; flex: 1; width: 100%; max-width: 34px; }
.benford .bf-bar { position: absolute; left: 0; right: 0; bottom: 0; min-height: 2px; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, var(--bk-primary), color-mix(in srgb, var(--bk-primary) 55%, transparent)); }
.benford .bf.bf-over .bf-bar { background: linear-gradient(180deg, var(--bs-warning), color-mix(in srgb, var(--bs-warning) 55%, transparent)); }
.benford .bf-exp { position: absolute; left: -2px; right: -2px; border-top: 2px dashed var(--bs-danger); }
.benford .bf small { font-size: .68rem; color: var(--bk-muted); white-space: nowrap; }
.benford .bf:hover .bf-bar, .benford .bf:focus .bf-bar { filter: brightness(1.1); outline: 2px solid color-mix(in srgb, var(--bk-primary) 40%, transparent); }
.benford.benford-two { gap: 1px; }
.benford.benford-two .bf-bar { border-radius: 2px 2px 0 0; }
.benford.benford-two .bf-exp { left: 0; right: 0; border-top-width: 1px; }
.bf-key { display: inline-block; width: 14px; height: 0; vertical-align: middle; }
.bf-key-exp { border-top: 2px dashed var(--bs-danger); }
.bf-key-over { height: 10px; border-radius: 2px; background: var(--bs-warning); }
