/* DDS Finhub. Dirac Delta Systems brand (diracdelta.com.hk): Montserrat, near-black text, the logo green #3db75f
   for marks and highlights, and the darker brand green #058341 for links and buttons (readable on white). */
@font-face {
  font-family: "Montserrat";
  src: url("brand/montserrat-latin-wght.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
:root {
  color-scheme: light dark;
  --font: "Montserrat", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --brand: #3db75f;
  --bg: #f5f6f5;
  --panel: #ffffff;
  --panel-2: #f8faf8;
  --ink: #2b2b2b;
  --muted: #626965;
  --line: #e2e6e3;
  --accent: #058341;
  --accent-hover: #046a35;
  --accent-ink: #ffffff;
  --accent-soft: #e3f4e8;
  --shadow: 0 1px 2px rgba(20, 40, 28, 0.05), 0 6px 18px rgba(20, 40, 28, 0.05);
  --side: #ffffff;
  --side-ink: #3d4440;
  --side-strong: #2b2b2b;
  --side-active: #e8f6ec;
  --red: #a8321f;
  --red-soft: #f9e2dc;
  --amber: #8a5a00;
  --amber-soft: #fbeccb;
  --blue: #235a94;
  --blue-soft: #dfeaf6;
  --green: #1d6b3c;
  --green-soft: #dcf0e2;
  --grey-soft: #ebe9e2;
  --viz-received: #2a78d6;
  --viz-past_due: #d03b3b;
  --viz-invoiced: #1baf7a;
  --viz-planned: #eda100;
  --viz-unscheduled: #b9b7ae;
  --viz-cost: #7a5bd1;
  --viz-grid: #e1e0d9;
  --viz-base: #c3c2b7;
  --viz-axis: #6f6e68;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1311;
    --panel: #171c19;
    --panel-2: #1d231f;
    --ink: #e7ece9;
    --muted: #9ba59f;
    --line: #2b332e;
    --accent: #4cc472;
    --accent-hover: #6bd38c;
    --accent-ink: #06210f;
    --accent-soft: #183823;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.25);
    --side: #131815;
    --side-ink: #c9d3cd;
    --side-strong: #f1f5f2;
    --side-active: #1d3325;
    --red: #f0917d;
    --red-soft: #47241d;
    --amber: #e9bd62;
    --amber-soft: #3f3116;
    --blue: #8dbbee;
    --blue-soft: #1e3248;
    --green: #7fd29c;
    --green-soft: #1b3a27;
    --grey-soft: #2b3532;
    --viz-received: #3987e5;
    --viz-past_due: #d03b3b;
    --viz-invoiced: #199e70;
    --viz-planned: #c98500;
    --viz-unscheduled: #56605d;
    --viz-cost: #9a7ee8;
    --viz-grid: #2c3532;
    --viz-base: #414c49;
    --viz-axis: #93a09c;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 13.5px/1.5 var(--font);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--accent-hover); }
h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 10px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* Layout */
.layout { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 22px 12px; display: flex; flex-direction: column; gap: 3px; position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line); }
/* The DDS logo with the product name under it. The logo is black and green, so on dark it sits on a white chip. */
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 0 10px 20px; color: var(--side-strong); text-decoration: none; }
.brand-logo { display: block; width: 150px; height: auto; }
.brand-product { font-size: 11.5px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); }
@media (prefers-color-scheme: dark) { .brand-logo { background: #ffffff; padding: 6px 9px; border-radius: 10px; box-sizing: content-box; } }
.side a.nav { display: block; color: var(--side-ink); padding: 8px 12px; border-radius: 999px; font-weight: 500; }
.side a.nav:hover { background: var(--side-active); color: var(--side-strong); text-decoration: none; }
.side a.nav.active { background: var(--side-active); color: var(--accent); font-weight: 700; box-shadow: inset 3px 0 0 var(--brand); }
.side .spacer { flex: 1; }
.side .who { padding: 12px 10px 4px; font-size: 12px; border-top: 1px solid var(--line); }
.side .who strong { display: block; color: var(--side-strong); font-size: 13px; }
.side .linkbtn { background: none; border: 0; padding: 4px 0 0; color: var(--side-ink); cursor: pointer; font: inherit; font-size: 12px; text-decoration: underline; margin-right: 12px; }
.side .linkbtn:hover { color: var(--accent); }
.main { padding: 26px 30px 60px; max-width: 1400px; width: 100%; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head .sub { color: var(--muted); margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Panels and tiles */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 18px; box-shadow: var(--shadow); }
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush h2 { padding: 14px 16px 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: block; color: inherit; box-shadow: var(--shadow); }
a.tile:hover { border-color: var(--brand); text-decoration: none; }
.tile .label { color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.tile .value { font-size: 27px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .value.money { font-size: 21px; line-height: 1.5; }
.tile .label.sub { margin-top: 2px; text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 12px; }
.tile.alert .value { color: var(--red); }
.tile.warn .value { color: var(--amber); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel-2); }
th.num { text-align: right; }
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: var(--panel-2); }
.empty { padding: 26px; text-align: center; color: var(--muted); }

/* Badges */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-paid { background: var(--green-soft); color: var(--green); }
.b-payment_overdue, .b-invoice_overdue { background: var(--red-soft); color: var(--red); }
.b-invoiced { background: var(--blue-soft); color: var(--blue); }
.b-invoice_soon { background: var(--amber-soft); color: var(--amber); }
.b-scheduled, .b-unscheduled, .b-role, .b-inactive { background: var(--grey-soft); color: var(--muted); }
.b-Current { background: var(--accent-soft); color: var(--accent); }
.b-Completed { background: var(--green-soft); color: var(--green); }
.b-On-hold, .b-Pipeline { background: var(--amber-soft); color: var(--amber); }
.review { display: block; margin-top: 4px; font-size: 12px; color: var(--amber); }
.review::before { content: "\2691\00a0"; }
.chips { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.chips.flags { display: flex; margin-top: 5px; }

/* Progress */
.bar { height: 6px; background: var(--grey-soft); border-radius: 3px; overflow: hidden; width: 90px; margin-top: 5px; }
.bar > div { height: 100%; background: var(--accent); }

/* Controls */
button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 999px; padding: 7px 16px;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { color: var(--red); }
button.sm { padding: 3px 9px; font-size: 12px; }
button:disabled { opacity: 0.55; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; width: 100%;
}
input[type="checkbox"] { width: auto; }
textarea { min-height: 64px; resize: vertical; }
.filters { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.filters > * { width: auto; min-width: 170px; }
.filters input[type="search"] { flex: 1; min-width: 200px; }

/* Forms and dialogs */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field .hint { font-weight: 400; display: block; margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-error { background: var(--red-soft); color: var(--red); padding: 8px 10px; border-radius: 6px; margin-bottom: 12px; }
dialog { border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: 0 18px 48px rgba(0, 0, 0, 0.18); width: min(560px, calc(100vw - 32px)); background: var(--panel); color: var(--ink); max-height: calc(100vh - 32px); }
dialog::backdrop { background: rgba(10, 18, 16, 0.5); }
dialog h2 { font-size: 17px; margin-bottom: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.dialog-actions .left { margin-right: auto; }
.secret { font-family: Consolas, Menlo, monospace; font-size: 16px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 10px; word-break: break-all; user-select: all; margin: 10px 0; }

/* Sign-in */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(900px 420px at 85% -10%, var(--accent-soft), transparent 70%) no-repeat, var(--bg); }
.auth .card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 30px 30px 28px; width: min(400px, 100%); box-shadow: var(--shadow); border-top: 4px solid var(--brand); }
.auth-logo { display: block; width: 170px; height: auto; margin: 0 0 18px; }
@media (prefers-color-scheme: dark) { .auth-logo { background: #ffffff; padding: 8px 11px; border-radius: 12px; box-sizing: content-box; } }
.auth h1 { margin-bottom: 4px; }
.auth p { margin: 0 0 18px; color: var(--muted); }
.auth button { width: 100%; margin-top: 4px; }

.ms-signin { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--ink); font-weight: 600; }
.ms-signin:hover { border-color: var(--accent); text-decoration: none; }
.local-form { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.btn-link { display: inline-block; font-weight: 600; border-radius: 999px; padding: 7px 16px; border: 1px solid var(--line); }
.btn-link.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-link:hover { text-decoration: none; }

.client-services { margin-top: 12px; }
.client-sub { padding: 0 16px; }
.client-doc-filter { padding: 0 16px; }
.summary .label { margin-bottom: 2px; }

/* Project summary */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.summary .label { color: var(--muted); font-size: 12px; }
.summary .amount { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.note-block { white-space: pre-wrap; margin-top: 10px; }
.cell-notes { max-width: 260px; white-space: pre-wrap; }
.details { max-width: 480px; word-break: break-word; font-size: 12px; color: var(--muted); }
.form-section { font-size: 13px; font-weight: 650; margin: 16px 0 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.recipient-list { max-height: 170px; overflow-y: auto; margin-bottom: 12px; }
.recipient-list .check { margin-bottom: 6px; }
.preview-wrap { max-height: 50vh; overflow: auto; margin: 10px 0; }
.rule-actions { min-width: 160px; }
.rule-actions button { margin: 2px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px 8px; flex-wrap: wrap; }
.panel.flush .panel-head h2 { padding: 0; margin: 0; }
.panel-head select { width: auto; }
.tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--line); overflow: auto hidden; }
.tab { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.tab.active { color: var(--accent); border-bottom-color: var(--brand); font-weight: 700; }
.filter-count { align-self: center; min-width: 0 !important; }
.board { display: grid; grid-template-columns: repeat(4, minmax(210px, 1fr)); gap: 12px; margin-bottom: 18px; overflow-x: auto; align-items: start; }
.board-col { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.board-col h2 { font-size: 14px; margin: 0; }
.board-total { margin-bottom: 10px; }
.deal { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; display: grid; gap: 3px; justify-items: start; }
.deal-name { background: none; border: 0; padding: 0; color: var(--ink); cursor: pointer; font: inherit; font-weight: 650; text-align: left; text-decoration: underline; }
.deal-value { font-weight: 650; font-variant-numeric: tabular-nums; }
.deal-stage { margin-top: 6px; width: 100%; }
.timeline { list-style: none; margin: 0; padding: 0 16px 8px; max-height: 620px; overflow-y: auto; }
.timeline li { display: flex; gap: 14px; padding: 9px 0; border-top: 1px solid var(--line); align-items: flex-start; }
.timeline-date { flex: 0 0 90px; color: var(--muted); font-size: 12px; padding-top: 2px; }
.timeline-body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.timeline .note-block { margin-top: 3px; }
.done-row td { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.toast { position: fixed; right: 18px; bottom: 18px; background: var(--ink); color: var(--panel); padding: 10px 14px; border-radius: 8px; z-index: 50; }

/* Projection and charts */
.viz-head { margin: 26px 0 10px; }
.viz-head h2 { font-size: 17px; margin: 0; }
.viz-filters { align-items: flex-end; margin-bottom: 14px; }
.viz-filter { display: block; min-width: 0; }
.viz-filter > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.viz-filter select { min-width: 220px; }
.segmented { display: inline-flex; gap: 0; }
.segmented button { border-radius: 0; margin-left: -1px; font-weight: 500; }
.segmented button:first-child { border-radius: 999px 0 0 999px; margin-left: 0; }
.segmented button:last-child { border-radius: 0 999px 999px 0; }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); position: relative; }
.viz-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 430px), 1fr)); gap: 14px; margin-bottom: 14px; }
.viz-card { margin: 0; min-width: 0; }
.viz-card.span-all { grid-column: 1 / -1; }
.viz-card h2 { margin-bottom: 2px; }
.viz-sub { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.viz-plot { width: 100%; min-height: 286px; }
.viz-plot svg { display: block; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.viz-legend > span { display: inline-flex; align-items: center; }
.viz-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; flex: none; }
.viz-swatch.line { width: 16px; height: 0; border-radius: 0; border-width: 2px 0 0; border-style: solid none none; background: none !important; }
.viz-swatch.line.dashed { border-style: dashed none none; }
.k-received { background: var(--viz-received); border-color: var(--viz-received); }
.k-past_due { background: var(--viz-past_due); border-color: var(--viz-past_due); }
.k-invoiced { background: var(--viz-invoiced); border-color: var(--viz-invoiced); }
.k-planned { background: var(--viz-planned); border-color: var(--viz-planned); }
.k-unscheduled { background: var(--viz-unscheduled); border-color: var(--viz-unscheduled); }
.k-projected { background: var(--viz-invoiced); border-color: var(--viz-invoiced); }
.f-received { fill: var(--viz-received); }
.f-past_due { fill: var(--viz-past_due); }
.f-invoiced { fill: var(--viz-invoiced); }
.f-planned { fill: var(--viz-planned); }
.viz-gridline { stroke: var(--viz-grid); stroke-width: 1; }
line.viz-base { stroke: var(--viz-base); stroke-width: 1; }
.viz-axis { fill: var(--viz-axis); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz-axis.end { text-anchor: end; }
.viz-axis.mid { text-anchor: middle; }
.viz-axis.now { fill: var(--ink); font-weight: 650; }
.viz-end { fill: var(--ink); font-size: 12px; font-weight: 650; text-anchor: end; }
.viz-val { fill: var(--ink); font-size: 12px; font-weight: 650; text-anchor: middle; font-variant-numeric: tabular-nums; paint-order: stroke; stroke: var(--panel); stroke-width: 3px; stroke-linejoin: round; pointer-events: none; }
.k-cost { background: var(--viz-cost); border-color: var(--viz-cost); }
.k-net { background: var(--ink); border-color: var(--ink); }
.f-cost { fill: var(--viz-cost); }
.f-estimate { fill: var(--viz-cost); opacity: 0.42; }
.k-estimate { background: var(--viz-cost); border-color: var(--viz-cost); opacity: 0.42; }
.l-net { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.d-net { fill: var(--ink); stroke: var(--panel); stroke-width: 2; pointer-events: none; }
.setup-steps { margin: 8px 0 14px; padding-left: 20px; }
.setup-steps li { margin-bottom: 8px; }
.copy-row { display: flex; gap: 8px; margin-top: 6px; max-width: 620px; }
.copy-row input, .copy-row select { flex: 1 1 auto; min-width: 0; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 18px; margin: 8px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.check-list { list-style: none; margin: 8px 0; padding: 0; }
.check-list li { margin-bottom: 6px; }
.xero-checks { margin-top: 12px; }
.viz-mini { display: flex; flex-wrap: wrap; gap: 10px 36px; margin: 4px 0 12px; }
.viz-mini-value { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.viz-mini-label { color: var(--muted); font-size: 12px; }
.viz-forecast { fill: var(--panel-2); }
.viz-wash { fill: var(--ink); opacity: 0; }
.viz-col:hover .viz-wash, .viz-col:focus-within .viz-wash { opacity: 0.06; }
.viz-hit { fill: transparent; outline: none; cursor: default; }
.viz-today { stroke: var(--viz-base); stroke-width: 1; }
.viz-cross { stroke: var(--muted); stroke-width: 1; }
.viz-reference { stroke: var(--viz-axis); stroke-width: 1; }
.l-received, .l-projected { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.l-received { stroke: var(--viz-received); }
.l-projected { stroke: var(--viz-invoiced); stroke-dasharray: 2 5; }
.d-projected { fill: var(--viz-invoiced); stroke: var(--panel); stroke-width: 2; }
.viz-tip { position: fixed; z-index: 60; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; pointer-events: none; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18); max-width: 280px; }
.viz-tip-title { font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.viz-tip-row { display: flex; align-items: center; gap: 6px; }
.viz-tip-row strong { font-variant-numeric: tabular-nums; }
.viz-tip-key { width: 12px; height: 2px; flex: none; }
.viz-seg { display: flex; gap: 2px; height: 28px; margin: 8px 0 12px; }
.viz-seg-part { flex: 1 1 0; min-width: 2px; border-radius: 4px; color: #ffffff; font-size: 12px; font-weight: 600; line-height: 28px; padding-left: 7px; white-space: nowrap; overflow: hidden; }
.viz-seg-part.k-planned { color: #0b0b0b; }
.viz-seg-part.k-unscheduled { color: var(--ink); }
.viz-table { width: 100%; }
.viz-table td { padding: 5px 0; border-bottom: 1px solid var(--line); }
.viz-table td.num { padding-left: 14px; }
.viz-table tr:last-child td { border-bottom: 0; }
.viz-bars { display: grid; gap: 2px; margin-top: 4px; }
.viz-bar-row { display: grid; grid-template-columns: minmax(0, 38%) minmax(30px, 1fr) auto; gap: 10px; align-items: center; color: inherit; padding: 4px 4px; border-radius: 4px; }
a.viz-bar-row:hover { background: var(--panel-2); text-decoration: none; }
.viz-bar-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.viz-bar-track { display: block; }
.viz-bar-fill { height: 14px; background: var(--viz-received); border-radius: 0 4px 4px 0; }
.viz-bar-value { font-variant-numeric: tabular-nums; font-size: 12px; text-align: right; min-width: 88px; }
.viz-details summary { cursor: pointer; font-weight: 600; }
.viz-details table { margin-top: 10px; }
.viz-notes { margin: 0 0 8px; padding-left: 18px; color: var(--muted); font-size: 12px; }
.viz-notes li { margin-bottom: 3px; }

/* Finance overview */
.fin-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.fin-head .viz-sub { margin-bottom: 0; margin-top: 2px; }
.detail-head { margin-top: 34px; padding-top: 18px; border-top: 1px solid var(--line); }
.entity-chip { display: inline-block; min-width: 26px; padding: 0 6px; border-radius: 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-align: center; line-height: 18px; }
.entity-chip.e-SA { background: var(--accent-soft); color: var(--accent); }
.entity-chip.e-HK { background: var(--blue-soft); color: var(--blue); }
.bank-tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 8px; }
.bank-tile { display: flex; flex-direction: column; gap: 2px; min-width: 0; position: relative; }
.bank-tile .bank-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.bank-label { font-size: 12px; font-weight: 600; color: var(--muted); line-height: 1.3; }
.bank-tile .value.money { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.bank-tile.is-missing .value { color: var(--muted); font-weight: 500; }
.bank-accounts { list-style: none; margin: 2px 0 0; padding: 0; font-size: 12px; color: var(--muted); }
.bank-accounts li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.bank-accounts li > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bank-accounts li > .num { white-space: nowrap; }
.tile-action { align-self: flex-start; margin-top: 8px; padding: 3px 9px; font-size: 12px; }
.budget-grid { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 14px; align-items: start; margin-bottom: 8px; }
.budget-panel { margin: 0; min-width: 0; padding: 12px 0 6px; }
.budget-panel .viz-notes { padding: 0 16px 0 32px; margin-top: 10px; }
.budget-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; padding: 0 16px 10px; }
.budget-toolbar .segmented button { padding: 5px 11px; font-size: 12px; }
.check.inline { margin: 0; font-size: 12px; color: var(--muted); }
.budget-wrap { border-top: 1px solid var(--line); max-height: 640px; overflow: auto; }
.budget-table { font-size: 12.5px; }
.budget-table th, .budget-table td { padding: 5px 9px; }
.budget-table thead th { position: sticky; top: 0; z-index: 2; }
.budget-table thead tr.kind-row th { top: 31px; padding-top: 0; }
.budget-table .sticky { position: sticky; left: 0; z-index: 1; background: var(--panel); min-width: 210px; max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: 1px 0 0 var(--line); }
.budget-table thead .sticky { z-index: 3; background: var(--panel-2); }
.budget-table td.proj, .budget-table th.proj { background: color-mix(in srgb, var(--panel-2) 70%, var(--blue-soft)); }
.budget-table td.total, .budget-table th.total { font-weight: 650; box-shadow: inset 1px 0 0 var(--line); }
.budget-table td { border-bottom-color: color-mix(in srgb, var(--line) 60%, transparent); }
.budget-table .zero { color: var(--muted); opacity: 0.6; }
.budget-table .neg { color: var(--red); }
.budget-table td.edit { cursor: pointer; }
.budget-table td.edit:hover, .budget-table td.edit:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; background: var(--accent-soft); }
.kind-pill { display: inline-block; font-size: 10px; font-weight: 600; letter-spacing: 0.02em; padding: 0 6px; border-radius: 999px; }
.kind-pill.actual { background: var(--green-soft); color: var(--green); }
.kind-pill.projected { background: var(--blue-soft); color: var(--blue); }
.row-section td { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding-top: 14px; background: var(--panel); }
.row-section td.sticky { overflow: visible; }
.row-line td.sticky { padding-left: 18px; }
.row-total td { font-weight: 650; border-top: 1px solid var(--line); }
.row-key td { font-weight: 700; background: var(--accent-soft); color: var(--ink); }
.row-key td.sticky { background: var(--accent-soft); }
.row-key td.proj { background: color-mix(in srgb, var(--accent-soft) 75%, var(--blue-soft)); }
.row-pct td { font-size: 11.5px; color: var(--muted); }
.kpi-stack { display: grid; gap: 12px; }
.kpi-period { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi-card { margin: 0; padding: 14px 16px; }
.kpi-card h3 { font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 0 4px; }
.kpi-card .kpi-subhead { margin-top: 14px; }
.kpi-value { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.25; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.kpi-spark { width: 100%; min-height: 70px; }
.kpi-spark svg { display: block; }
.kpi-bar { fill: var(--accent); }
.kpi-bar.neg { fill: var(--red); }
.kpi-bar.proj { fill-opacity: 0.35; }
.fin-bars .viz-bar-row { grid-template-columns: minmax(0, 34%) minmax(24px, 1fr) auto; }
.fin-bars .viz-bar-fill { background: var(--accent); }
.fin-bars .viz-bar-fill.neg { background: var(--red); }
.fin-bars .viz-bar-value { min-width: 96px; }
.fin-grid { display: grid; grid-template-columns: minmax(330px, 4fr) minmax(0, 8fr); gap: 14px; align-items: start; margin-bottom: 18px; }
.fin-panel table { font-size: 12.5px; }
.fin-panel th, .fin-panel td { padding: 7px 10px; }
.fin-panel td.name { max-width: 210px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fin-stack { display: grid; gap: 14px; min-width: 0; }
.fin-panel { margin: 0; min-width: 0; }
.fin-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.panel.flush .fin-panel-head { padding: 14px 16px 0; }
.fin-panel-head h2 { margin: 0; }
.fin-panel .viz-sub { margin: 4px 0 10px; }
.fin-panel .viz-sub.pad { padding: 0 16px; }
.fin-panel .segmented button { padding: 3px 9px; font-size: 12px; }
.fin-scroll { max-height: 420px; overflow: auto; border-top: 1px solid var(--line); }
.fin-scroll thead th { position: sticky; top: 0; z-index: 1; }
.clip { max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
td.neg { color: var(--red); font-weight: 600; }
.pay-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 760px; overflow-y: auto; }
.pay { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.pay:hover { border-color: var(--border-hover, var(--accent)); }
.pay.late { border-color: color-mix(in srgb, var(--red) 45%, var(--line)); background: color-mix(in srgb, var(--red-soft) 45%, var(--panel)); }
.pay.soon { border-color: color-mix(in srgb, var(--amber) 35%, var(--line)); }
.pay-check { width: 22px; height: 22px; padding: 0; border-radius: 50%; border: 2px solid var(--muted); background: var(--panel); position: relative; flex: none; }
.pay-check:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.pay-check:hover:not(:disabled)::after { content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px; border: solid var(--accent); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.pay-body { min-width: 0; }
.pay-title { display: block; background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--ink); text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
button.pay-title:hover { color: var(--accent); text-decoration: underline; }
.pay-meta { display: flex; align-items: center; gap: 8px; margin-top: 3px; font-size: 12px; min-width: 0; }
.pay-meta > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pay-date { text-align: right; font-size: 12px; color: var(--muted); line-height: 1.3; }
.pay-date strong { display: block; font-size: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }
.pay.late .pay-date, .pay.late .pay-date strong { color: var(--red); }
.pay.soon .pay-date span { color: var(--amber); font-weight: 600; }
.pay-list .empty { border: 1px dashed var(--line); border-radius: 8px; }
.segmented button.sm { font-weight: 500; }
.fin-toast { display: flex; align-items: center; gap: 14px; }
.fin-toast .linkbtn { background: none; border: 0; color: inherit; text-decoration: underline; padding: 0; font-weight: 700; cursor: pointer; }
.rate-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; max-height: 52vh; overflow-y: auto; }
@media (max-width: 1380px) { .bank-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1180px) {
  .budget-grid { grid-template-columns: minmax(0, 1fr); }
  .kpi-stack { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .kpi-period { grid-column: 1 / -1; }
  .fin-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 620px) {
  .bank-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .budget-table .sticky { min-width: 150px; max-width: 170px; }
  .rate-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 10px 8px 0; width: 100%; flex-direction: row; align-items: center; gap: 10px; }
  .brand-logo { width: 116px; }
  .side .spacer { display: none; }
  .side .who { border-top: 0; width: 100%; padding: 6px 10px 0; }
  .main { padding: 18px 16px 40px; }
  .grid2 { grid-template-columns: 1fr; }
  .filters > * { width: 100%; }
}

/* Milestone evidence from DDS Hub */
.badge.evidence { margin-left: 4px; }
.evidence-files { margin-top: 4px; display: grid; gap: 2px; }

/* Role checkboxes on the Users page */
fieldset.roles { border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px 10px; margin: 10px 0; }
fieldset.roles legend { font-weight: 600; padding: 0 4px; }
fieldset.roles .check { align-items: flex-start; margin: 8px 0 0; }

/* Kimai timesheets */
.kimai-months { margin: 14px 0 6px; }
.kimai-months .viz-bar-fill { background: var(--brand); }
.kimai-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 6px 24px; margin: 10px 0; }
.kimai-list h3 { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin: 8px 0 4px; }
.panel-head.flush-head { padding: 0 0 10px; }
.check.inline { align-self: center; }
.kimai-billing { margin: 12px 0; }
.kimai-billing h3 { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin: 8px 0 4px; }

/* Fields managed in DDS Hub are shown read-only. */
input:disabled, select:disabled, textarea:disabled { opacity: 0.6; cursor: not-allowed; }
/* The project request dialog's milestone rows. */
.ms-table td { padding: 4px 6px; vertical-align: middle; }
.ms-table .ms-title { width: 100%; min-width: 7rem; }
.ms-table .ms-amount { width: 6.5rem; }
.ms-table .ms-date { width: 8.5rem; }
/* The billing setup checklist on a project. */
.gap-list { margin: 8px 0 0; padding-left: 18px; }
.gap-list li { margin: 2px 0; }
/* Sales access lists. */
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 16px; margin: 8px 0; }
.check-list.tall { display: block; max-height: 340px; overflow-y: auto; border: 1px solid var(--line, #2a2f2c); border-radius: 8px; padding: 6px 10px; margin-top: 8px; }
.check-list.tall .check { display: flex; gap: 6px; padding: 2px 0; }
/* The Integrity page: gaps fixed in place. */
.fix-heading { margin: 18px 0 8px; font-size: 17px; }
.fix-card { margin-bottom: 12px; }
.fix-card .panel-head { padding: 12px 16px 4px; }
.fix-card h3 { margin: 0; font-size: 15px; }
.fix-row { display: flex; gap: 10px; align-items: center; padding: 6px 16px; flex-wrap: wrap; }
.fix-pad { padding: 0 16px 12px; }
.fix-table td { vertical-align: middle; }
.fix-table .fix-amount { width: 8rem; }
.fix-table select, .fix-table input[type=date] { width: auto; }
.fix-row select { width: auto; min-width: 14rem; }
/* Picking a Xero invoice or contact. */
.inv-list { max-height: 320px; overflow-y: auto; margin: 8px 0; border: 1px solid var(--line, #2a2f2c); border-radius: 8px; }
.inv-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line, #2a2f2c); cursor: pointer; }
.inv-row:last-child { border-bottom: 0; }
.fix-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; } .fix-actions select { width: auto; max-width: 16rem; }
