/* Pro Electric Group workspace.
   Structure comes from hairlines on a quiet canvas, not filled blobs. Brand green marks actions and
   where you are; everything else stays neutral so project data reads first. */
@font-face {
  font-family: Geist;
  src: url('/assets/geist.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
:root {
  color-scheme: light;
  --ink: #15201b;
  --text: #2f3a34;
  --muted: #66716b;
  --faint: #8d9690;
  --line: #e2e6e3;
  --line-strong: #cdd4cf;
  --canvas: #f5f6f4;
  --white: #fff;
  --background: #fff;
  --soft: #f0f2f0;
  --row: #f8f9f8;
  --green: #153c2e;
  --green-hover: #1e5040;
  --tint: #e6efe9;
  --ring: rgb(21 60 46 / 18%);
  --ok: #2c6e47;   --ok-bg: #e5f0e8;
  --info: #2f5b86; --info-bg: #e6edf5;
  --warn: #855600; --warn-bg: #f9efd8;
  --bad: #a1382a;  --bad-bg: #f9e7e3;
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 8px;
  --sidebar: 232px;
  --control: 34px;
  font: 16px/1.5 Geist, system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (min-width: 851px) { :root { font-size: 14px; } }

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { color: inherit; font: inherit; }
button { cursor: pointer; border: 0; }
button:disabled { cursor: wait; opacity: .55; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
a { color: var(--green); text-underline-offset: 3px; }
img { max-width: 100%; }
h1, h2, h3, p { margin: 0; }
small { color: var(--muted); }
svg { flex: 0 0 auto; vertical-align: middle; }
kbd { font: inherit; }
[hidden] { display: none !important; }
::selection { background: var(--tint); color: var(--ink); }
.sr-only { border: 0; clip-path: inset(50%); height: 1px; width: 1px; overflow: hidden; position: absolute; white-space: nowrap; }
.skip-link { position: fixed; top: 8px; left: 12px; z-index: 20; transform: translateY(-160%); background: var(--green); color: white; padding: 8px 14px; border-radius: var(--radius); text-decoration: none; }
.skip-link:focus { transform: none; }

/* ---- Navigation shell ---------------------------------------------------------------- */
.sidebar { position: fixed; z-index: 10; inset: 0 auto 0 0; width: var(--sidebar); display: flex; flex-direction: column; gap: 12px; padding: 14px 12px 12px; background: var(--white); border-right: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0 6px; }
.sidebar-brand { display: block; line-height: 0; }
.sidebar-brand img { width: 92px; height: auto; }
.sidebar-close { display: none !important; }
.sidebar-search { display: flex; align-items: center; gap: 8px; width: 100%; height: var(--control); padding: 0 8px 0 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--row); color: var(--muted); font-size: .9286rem; text-decoration: none; text-align: left; }
.sidebar-search:hover { border-color: var(--line-strong); color: var(--text); }
.sidebar-search span { flex: 1; }
.sidebar-search kbd { padding: 0 5px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--white); font-size: .8rem; line-height: 1.5; color: var(--faint); }
.sidebar-nav { display: grid; gap: 16px; }
.nav-group { display: grid; gap: 1px; }
.nav-label { padding: 0 10px 4px; color: var(--faint); font-size: .8571rem; font-weight: 500; }
.nav-link { display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 0 10px; border-radius: var(--radius); color: var(--text); font-size: .9643rem; font-weight: 500; text-decoration: none; }
.nav-link svg { color: var(--faint); }
.nav-link:hover { background: var(--soft); color: var(--ink); }
.nav-link[aria-current="page"] { background: var(--tint); color: var(--green); font-weight: 600; }
.nav-link[aria-current="page"] svg { color: var(--green); }
.nav-link span:first-of-type { flex: 1; }
.nav-dot { flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.sidebar-account { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 12px 4px 0; border-top: 1px solid var(--line); }
.avatar { display: grid; place-items: center; flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; background: var(--tint); color: var(--green); font-size: .8214rem; font-weight: 650; }
.account-name { flex: 1; min-width: 0; line-height: 1.3; }
.account-name strong, .account-name small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.account-name strong { font-size: .9286rem; font-weight: 600; }
.account-name small { font-size: .8214rem; }
.account-action { display: grid; place-items: center; flex: 0 0 auto; width: 30px; height: 30px; border-radius: var(--radius); background: transparent; color: var(--muted); }
.account-action:hover { background: var(--soft); color: var(--ink); }
.mobile-bar, .tab-bar, .nav-scrim { display: none; }
body.has-shell { padding-left: var(--sidebar); }

/* ---- Page frame ------------------------------------------------------------------------ */
.main { width: 100%; max-width: 1240px; margin: 0 auto; padding: 28px 36px 56px; }
.main:focus { outline: none; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
h1 { font-size: 1.5714rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.25; }
.page-heading p { margin-top: 3px; color: var(--muted); font-size: .9643rem; }
.heading-controls { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; align-items: center; flex-shrink: 0; }
.heading-kicker { display: none; }

/* ---- Controls -------------------------------------------------------------------------- */
.button { display: inline-flex; gap: 6px; align-items: center; justify-content: center; min-height: var(--control); padding: 0 12px; border: 1px solid transparent; border-radius: var(--radius); background: transparent; font-size: .9643rem; font-weight: 550; line-height: 1.2; white-space: nowrap; text-decoration: none; }
.button svg { margin-left: -2px; }
.primary { background: var(--green); color: #fff; }
.primary:hover { background: var(--green-hover); }
.secondary, .subtle { background: var(--white); border-color: var(--line-strong); color: var(--ink); }
.secondary:hover, .subtle:hover { background: var(--soft); }
.wide { width: 100%; }
.icon-button { display: grid; place-items: center; min-width: var(--control); min-height: var(--control); border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); color: var(--text); text-decoration: none; }
.icon-button:hover { background: var(--soft); }

.badge { display: inline-flex; align-items: center; gap: 6px; width: fit-content; padding: 1px 7px; border-radius: var(--radius-sm); background: var(--soft); color: var(--text); font-size: .8571rem; font-weight: 550; line-height: 1.6; white-space: nowrap; }
.badge i, .unread-dot { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 auto; background: currentColor; }
.badge.in-progress, .badge.completed, .badge.paid, .badge.synced, .badge.linked-to-pylon, .badge.accepted-in-pylon, .badge.owner { background: var(--ok-bg); color: var(--ok); }
.badge.scheduled, .badge.sent, .badge.configured { background: var(--info-bg); color: var(--info); }
.badge.quoted, .badge.setup-required, .badge.pylon-draft { background: var(--warn-bg); color: var(--warn); }
.badge.overdue, .badge.cancelled, .badge.void, .badge.disabled { background: var(--bad-bg); color: var(--bad); }

/* ---- Surfaces -------------------------------------------------------------------------- */
.card { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--white); overflow: hidden; }
.card-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 52px; padding: 12px 16px; }
.card-heading h2 { font-size: 1.0714rem; font-weight: 600; letter-spacing: -.01em; line-height: 1.3; }
.card-heading p { margin-top: 1px; color: var(--muted); font-size: .8929rem; }
.card-heading .button { min-height: 30px; padding-inline: 10px; font-size: .9286rem; }
.card-note { padding: 16px; color: var(--muted); font-size: .9286rem; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); margin: 0 0 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--white); overflow: hidden; }
.metrics-grid.count-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.metrics-grid.count-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.metric { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; padding: 16px 18px; border-right: 1px solid var(--line); background: transparent; text-align: left; }
.metric:last-child { border-right: 0; }
.metric:hover { background: var(--row); }
.metric-top { display: flex; align-items: center; gap: 7px; color: var(--muted); }
.metric .metric-icon { display: inline-grid; background: none; color: var(--faint); }
.metric-title { color: var(--muted); font-size: .9286rem; font-weight: 500; }
.metric > strong { margin-top: 8px; font-size: 1.8571rem; font-weight: 600; letter-spacing: -.025em; line-height: 1.1; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metric-foot { margin-top: 4px; color: var(--muted); font-size: .8929rem; }

.insights-grid { display: grid; gap: 16px; grid-template-columns: minmax(0,1.7fr) minmax(0,1fr); margin-bottom: 16px; }
.insights-grid.single, .schedule-grid.single { grid-template-columns: minmax(0,1fr); }
.period-select, .filter-select { display: flex; align-items: center; position: relative; color: var(--text); }
.period-select select, .filter-select select { appearance: none; min-height: 30px; padding: 0 28px 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--white); font-size: .9286rem; }
.period-select svg, .filter-select svg:last-child { position: absolute; right: 8px; pointer-events: none; color: var(--muted); }
.revenue-total { display: flex; align-items: baseline; gap: 8px; padding: 0 16px; }
.revenue-total strong { font-size: 1.8571rem; font-weight: 600; letter-spacing: -.025em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.revenue-total span { color: var(--muted); font-size: .8929rem; }
.chart-wrap { min-width: 0; padding: 12px 16px 14px; }
.chart-wrap canvas { display: block; width: 100%; height: 176px; }

.upcoming-card > .card-heading, .recent-card > .card-heading, .schedule-grid .card-heading, .event-feed .card-heading { border-bottom: 1px solid var(--line); }
.upcoming-icon { display: none; }
.upcoming-list { padding: 0 16px; }
.upcoming-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; }
.upcoming-row:last-child { border-bottom: 0; }
.upcoming-row:hover .upcoming-text strong { text-decoration: underline; text-underline-offset: 3px; }
.upcoming-card > .wide { display: flex; width: calc(100% - 32px); margin: 4px 16px 16px; }
.date-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); color: var(--ink); line-height: 1.05; }
.date-tile strong { font-size: 1rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.date-tile small { margin-top: 1px; font-size: .7857rem; font-weight: 500; color: var(--muted); }
.upcoming-text, .record-main { flex: 1; min-width: 0; }
.upcoming-text strong, .record-main strong, .project-name strong { display: block; font-size: .9643rem; font-weight: 550; line-height: 1.3; overflow-wrap: anywhere; }
.upcoming-text small, .record-main small, .project-name small { display: block; margin-top: 1px; font-size: .8929rem; overflow-wrap: anywhere; }
.upcoming-row > svg, .record-row > svg:last-child, .project-table-row > svg:last-child, .operation-row svg { color: var(--faint); }
.small-empty { padding: 16px 0; color: var(--muted); font-size: .9286rem; }

/* ---- Tables and lists ------------------------------------------------------------------ */
.project-table-head, .project-table-row { display: grid; grid-template-columns: minmax(0,2.1fr) minmax(0,1.3fr) minmax(110px,1fr) minmax(80px,.7fr) 16px; gap: 16px; align-items: center; }
.project-table-head, .directory-head { padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--row); color: var(--muted); font-size: .8929rem; font-weight: 500; }
.project-table-head span:nth-child(4) { text-align: right; }
.project-table-row { width: 100%; min-height: 54px; padding: 8px 16px; border-top: 1px solid var(--line); background: var(--white); font-size: .9643rem; text-align: left; }
.project-table-head + [role="listitem"] .project-table-row { border-top: 0; }
.project-table-row:hover, .record-row:hover, .operation-row:hover { background: var(--row); }
.project-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.project-name > span:last-child { min-width: 0; }
.project-icon { display: grid; place-items: center; flex: 0 0 auto; width: 30px; height: 30px; border-radius: var(--radius); background: var(--tint); color: var(--green); }
.green, .lime, .sand, .blue { background: var(--tint); color: var(--green); }
.project-customer { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-amount { text-align: right; font-weight: 550; font-variant-numeric: tabular-nums; white-space: nowrap; }

.list-card .filter-bar { display: flex; gap: 8px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.list-search { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; max-width: 420px; min-height: var(--control); padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--white); color: var(--muted); }
.list-search:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px var(--ring); }
.list-search input { width: 100%; min-width: 0; min-height: calc(var(--control) - 2px); border: 0; outline: 0; background: transparent; color: var(--ink); }
.list-search input:focus-visible { outline: 0; }
.filter-select { flex: 0 0 auto; }
.filter-select select { min-height: var(--control); padding-left: 32px; }
.filter-select svg:first-child { position: absolute; left: 10px; pointer-events: none; color: var(--muted); }
.search-results { margin-top: 8px; }
.search-results .record-row { padding: 8px 4px; }
.record-list .record-row + .record-row, .task-row + .task-row { border-top: 1px solid var(--line); }
.record-row, .task-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 16px; background: var(--white); text-align: left; }
.contact-avatar { display: grid; place-items: center; flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%; background: var(--tint); color: var(--green); font-size: .8571rem; font-weight: 650; }
.record-extra { color: var(--muted); font-size: .8929rem; }
.amount-cell { min-width: 96px; text-align: right; font-size: .9643rem; font-weight: 550; font-variant-numeric: tabular-nums; white-space: nowrap; }
.directory-head { display: grid; grid-template-columns: minmax(0,1fr) 25% 112px; }
.directory .record-row { min-height: 60px; }
.directory-suburb { width: 25%; color: var(--text); font-size: .9286rem; }
.directory-row .record-extra { min-width: 72px; }
.mail-row .unread-dot { background: var(--green); }
.empty { padding: 40px 18px; text-align: center; }
.empty > span { display: grid; place-items: center; width: 40px; height: 40px; margin: 0 auto 12px; border-radius: var(--radius-lg); background: var(--tint); color: var(--green); }
.empty h3 { font-size: 1.0714rem; font-weight: 600; }
.empty p { max-width: 46ch; margin: 4px auto 0; color: var(--muted); font-size: .9643rem; }

.finance-totals { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); margin-bottom: 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--white); overflow: hidden; }
.finance-totals > .card { padding: 16px 18px; border: 0; border-right: 1px solid var(--line); border-radius: 0; }
.finance-totals > .card:last-child { border-right: 0; }
.finance-totals span { color: var(--muted); font-size: .9286rem; }
.finance-totals strong { display: block; margin-top: 6px; font-size: 1.5714rem; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* Tabs: an underline on the current view, so they read as views rather than buttons. */
.segments { display: flex; gap: 20px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.segments button { position: relative; min-height: 36px; padding: 0 1px; background: transparent; color: var(--muted); font-size: .9643rem; font-weight: 550; }
.segments button:hover { color: var(--ink); }
.segments button[aria-pressed="true"], .segments button[aria-selected="true"] { color: var(--ink); }
.segments button[aria-pressed="true"]::after, .segments button[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 1px; background: var(--green); }

.schedule-grid, .integrations-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: start; gap: 16px; }
.task-row { gap: 4px; padding-block: 4px; padding-left: 8px; }
.task-toggle { display: grid; place-items: center; flex: 0 0 auto; width: 40px; height: 40px; padding: 0; background: none; }
.task-toggle span { display: grid; place-items: center; width: 18px; height: 18px; border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--white); }
.task-toggle:hover span { border-color: var(--green); }
.task-toggle.done span { border-color: var(--green); background: var(--green); color: white; }
.task-description { display: flex; flex: 1; justify-content: space-between; align-items: center; gap: 10px; min-height: 48px; padding: 0; background: transparent; text-align: left; }
.task-description.done strong { text-decoration: line-through; color: var(--muted); }

.integration-card { display: flex; flex-direction: column; align-items: flex-start; padding: 20px; }
.integration-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; margin-bottom: 14px; }
.provider-logo { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-lg); background: var(--tint); color: var(--green); }
.pylon .provider-logo { background: #fbeee2; color: #a2531f; }
.integration-card h2 { font-size: 1.1429rem; font-weight: 600; letter-spacing: -.01em; }
.integration-card p { margin: 4px 0 14px; color: var(--muted); }
.integration-card .integration-status { margin-top: -6px; color: var(--text); font-size: .9286rem; }
.integration-card label { display: grid; gap: 4px; width: 100%; margin-top: 12px; font-size: .9286rem; font-weight: 550; }
.integration-card label select { min-height: var(--control); padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: white; }
.integration-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.token-note { color: var(--muted); font-size: .9286rem; }
.pylon-groups { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(280px,100%),1fr)); gap: 16px; align-items: start; }
.pylon-groups .card-heading { border-bottom: 1px solid var(--line); }
.operation-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 8px 16px; background: var(--white); color: var(--text); text-align: left; }
.operation-row + .operation-row, .result-item, .event-feed .record-row { border-top: 1px solid var(--line); }
.event-feed { margin-top: 16px; }
.role-guide { margin-top: 16px; }
.role-guide dl { display: grid; grid-template-columns: max-content minmax(0,1fr); gap: 8px 28px; margin: 0; padding: 4px 16px 18px; font-size: .9643rem; }
.role-guide dt { font-weight: 600; }
.role-guide dd { margin: 0; color: var(--muted); }
.activity-row { min-height: 56px; }
.activity-row .activity-detail { overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8214rem; }
summary { cursor: pointer; padding: 10px 0; font-weight: 600; }
#pylon-results pre { padding: 10px; border-radius: var(--radius); background: var(--row); font-size: .8571rem; white-space: pre-wrap; overflow-wrap: anywhere; }
#pylon-results:empty { display: none; }
.record-facts { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.45fr); gap: 6px 14px; font-size: .9643rem; }
.record-facts dt { color: var(--muted); text-transform: capitalize; }
.record-facts dd { margin: 0; overflow-wrap: anywhere; }
.record-facts .record-facts { display: block; padding-left: 8px; border-left: 2px solid var(--line); }
.record-facts .record-facts dd { margin-bottom: 6px; }
.record-facts summary { padding: 0; }
.related-pylon { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }

/* ---- Sign-in and loading --------------------------------------------------------------- */
.loading { display: grid; place-content: center; justify-items: center; gap: 12px; height: 100dvh; padding: 20px; text-align: center; }
.loading p, .login p { color: var(--muted); }
.login { display: grid; place-items: center; min-height: 100dvh; padding: 16px; }
.login > section { width: min(100%, 384px); padding: 28px; }
.login .brand { display: block; margin-bottom: 24px; }
.company-logo { width: 104px; height: auto; }
.login h1 { margin-bottom: 4px; }
.login form { margin-top: 20px; }
.login label { display: grid; gap: 5px; font-size: .9286rem; font-weight: 550; }
.login label + label, .login .field-hint + label { margin-top: 14px; }
.login .field-hint { margin-top: 5px; font-size: .8571rem; }
.login .button { margin-top: 16px; min-height: 40px; }

/* ---- Forms and sheets ------------------------------------------------------------------ */
.form-fields { display: grid; gap: 14px; align-content: start; }
.form-fields label { display: grid; gap: 5px; min-width: 0; font-size: .9286rem; font-weight: 550; color: var(--text); }
.form-fields input, .form-fields textarea, .form-fields select, .login input { display: block; width: 100%; min-width: 0; min-height: 36px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--white); color: var(--ink); font-size: 1rem; font-weight: 400; }
.form-fields input:focus, .form-fields textarea:focus, .form-fields select:focus, .login input:focus { outline: 0; border-color: var(--green); box-shadow: 0 0 0 3px var(--ring); }
.form-fields textarea { resize: vertical; }
.field-select { display: block; position: relative; }
.field-select select { appearance: none; padding-right: 32px; }
.field-select svg { position: absolute; right: 10px; top: 50%; translate: 0 -50%; pointer-events: none; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.form-fields .checkbox-field { display: flex; flex-direction: row; align-items: center; gap: 8px; min-height: 36px; font-weight: 500; }
.form-fields .checkbox-field input { width: 18px; height: 18px; min-height: auto; accent-color: var(--green); }
.form-error, .login .form-error { color: var(--bad); font-weight: 550; font-size: .9286rem; }
.form-error:empty { display: none; }
.field-hint { color: var(--muted); font-size: .8929rem; font-weight: 400; }
.plain-fieldset { display: grid; gap: 14px; min-width: 0; margin: 0; padding: 0; border: 0; }
.plain-fieldset:disabled :is(input,select,textarea) { color: var(--text); -webkit-text-fill-color: var(--text); background: var(--row); opacity: 1; cursor: default; }

dialog { width: min(calc(100% - 24px), 560px); max-height: min(90dvh, 820px); margin: auto; padding: 0; border: 0; border-radius: 12px; background: var(--white); color: var(--ink); box-shadow: 0 24px 64px rgb(16 24 20 / 22%), 0 2px 6px rgb(16 24 20 / 8%); overflow: auto; overscroll-behavior: contain; }
dialog::backdrop { background: rgb(16 24 20 / 32%); }
body:has(dialog[open]) { overflow: hidden; }
.sheet-grabber { display: none; }
.sheet-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 56px; padding: 10px 12px 10px 20px; border-bottom: 1px solid var(--line); background: var(--white); }
.sheet-header h2 { font-size: 1.1429rem; font-weight: 600; letter-spacing: -.01em; overflow-wrap: anywhere; }
.close-sheet { border-color: transparent; color: var(--muted); }
.sheet-body { padding: 18px 20px; }
.sheet-footer { position: sticky; bottom: 0; z-index: 1; display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--white); }
.sheet-related { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.sheet-related strong { width: 100%; font-size: .9286rem; }
.sheet-related .button { white-space: normal; }
.sheet-note { color: var(--muted); font-size: .9286rem; overflow-wrap: anywhere; }
.sheet-section { border-top: 1px solid var(--line); }
.sheet-section h3 { font-size: 1rem; font-weight: 600; }
.form-fields details > .form-fields { margin-top: 6px; }
.setup-copy ol { margin: 10px 0; padding-left: 22px; }
.setup-copy li { padding: 6px 0; overflow-wrap: anywhere; }
.message-meta { display: flex; align-items: center; gap: 10px; }
.message-meta small { display: block; overflow-wrap: anywhere; }
.message-body { margin: 16px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
#toast { display: none; position: fixed; z-index: 30; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: min(440px, calc(100% - 32px)); padding: 10px 14px; border-radius: var(--radius-lg); background: var(--ink); color: white; font-size: .9643rem; text-align: center; box-shadow: 0 8px 24px rgb(16 24 20 / 24%); }
#toast.visible { display: block; }
body.has-shell #toast { left: calc(50% + var(--sidebar) / 2); }

/* Record details open as a panel on the right, so the list stays in view. */
@media (min-width: 851px) {
  #sheet { inset: 0 0 0 auto; width: min(560px, 100%); height: 100dvh; max-height: none; margin: 0; border-left: 1px solid var(--line); border-radius: 0; box-shadow: -16px 0 48px rgb(16 24 20 / 14%); }
  #sheet[open] { animation: sheet-in .2s cubic-bezier(.2,.8,.2,1); }
  #sheet > form { min-height: calc(100% - 56px); display: flex; flex-direction: column; }
  #sheet > form > .sheet-body:first-child { flex: 1; }
}
@keyframes sheet-in { from { transform: translateX(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #sheet[open] { animation: none; } }

/* ---- Project page ---------------------------------------------------------------------- */
.crumbs ol { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 6px; padding: 0; list-style: none; font-size: .9286rem; color: var(--muted); }
.crumbs li + li::before { content: "/"; margin-right: 6px; color: var(--line-strong); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.heading-value { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.badge.accepted, .badge.handed-over { background: var(--ok-bg); color: var(--ok); }
.badge.issued, .badge.sent-to-customer { background: var(--info-bg); color: var(--info); }
.badge.not-started, .badge.draft { background: var(--soft); color: var(--muted); }
.stepper { display: flex; margin: 0 0 16px; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--white); overflow-x: auto; }
.step { flex: 1 1 0; min-width: 112px; }
.step + .step { border-left: 1px solid var(--line); }
.step > button, .step > span { display: flex; align-items: center; gap: 8px; width: 100%; height: 100%; padding: 11px 14px; background: transparent; text-align: left; color: var(--muted); font-size: .9286rem; }
.step > button:hover { background: var(--row); color: var(--ink); }
.step-dot { display: grid; place-items: center; flex: 0 0 auto; width: 22px; height: 22px; border: 1px solid var(--line-strong); border-radius: 50%; font-size: .7857rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.step-label { white-space: nowrap; }
.step.done .step-dot { border-color: var(--ok-bg); background: var(--ok-bg); color: var(--ok); }
.step.done > * { color: var(--text); }
.step.current { background: var(--tint); box-shadow: inset 0 -2px 0 var(--green); }
.step.current > span { color: var(--ink); font-weight: 600; }
.step.current .step-dot { border-color: var(--green); background: var(--green); color: #fff; }
.stage-banner { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--white); color: var(--muted); }
.next-step { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; padding: 14px 16px 14px 18px; border: 1px solid var(--line); border-left: 3px solid var(--green); border-radius: var(--radius-lg); background: var(--white); }
.next-step strong { font-size: 1.0714rem; font-weight: 600; }
.next-step p { margin-top: 2px; color: var(--muted); }
.next-step > .button, .next-step > a { flex: 0 0 auto; }
.next-step.wait { border-left-color: var(--info); }
.next-step.alert { border-left-color: var(--bad); }
.next-step.done { border-left-color: var(--ok); }
.project-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); align-items: start; gap: 16px; }
.project-main, .project-side { display: grid; gap: 16px; min-width: 0; }
.card-pad { padding: 0 16px 16px; }
.card-actions { display: flex; gap: 6px; }
.design-row { color: inherit; text-decoration: none; }
.design-row:hover, .project-grid .record-row:hover { background: var(--row); }
.job-summary { display: grid; gap: 10px; }
.job-status { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .9286rem; }
.progress-line { display: grid; grid-template-columns: 120px minmax(0, 1fr) 48px; align-items: center; gap: 10px; font-size: .9286rem; color: var(--text); }
.progress-line b { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar { width: 100%; height: 6px; border: 0; border-radius: 3px; background: var(--soft); overflow: hidden; -webkit-appearance: none; appearance: none; }
.bar::-webkit-progress-bar { border-radius: 3px; background: var(--soft); }
.bar::-webkit-progress-value { border-radius: 3px; background: var(--green); }
.bar::-moz-progress-bar { border-radius: 3px; background: var(--green); }
.photo-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; }
.photo-strip img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); background: var(--soft); }
.job-handover { display: flex; align-items: center; gap: 6px; color: var(--ok); font-size: .9286rem; }
.money-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-block: 1px solid var(--line); }
.money-strip > div { padding: 10px 16px; }
.money-strip > div + div { border-left: 1px solid var(--line); }
.money-strip span { display: block; color: var(--muted); font-size: .8571rem; }
.money-strip strong { font-size: 1.0714rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.facts { display: grid; gap: 6px; justify-items: start; }
.facts a { overflow-wrap: anywhere; }
.person { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.other-projects { display: grid; justify-items: start; gap: 2px; margin-top: 8px; }
.link-button { padding: 0; background: none; color: var(--green); text-align: left; text-decoration: underline; text-underline-offset: 3px; }
.fact-list { display: grid; gap: 8px; margin: 0; }
.fact-list > div { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; }
.fact-list dt { color: var(--muted); font-size: .9286rem; }
.fact-list dd { margin: 0; overflow-wrap: anywhere; }
.project-notes { border-top: 1px solid var(--line); padding-top: 12px; }
.project-notes p { margin-top: 2px; white-space: pre-wrap; }
.task-row small.late { color: var(--bad); }
.timeline { margin: 0; padding: 0 16px 12px; list-style: none; }
.timeline li { position: relative; display: flex; gap: 12px; padding: 8px 0; }
.timeline li:not(:last-child)::before { content: ""; position: absolute; left: 12px; top: 34px; bottom: -6px; width: 1px; background: var(--line); }
.timeline li > span:last-child { display: grid; min-width: 0; }
.timeline strong { font-weight: 550; }
.timeline-icon { display: grid; place-items: center; flex: 0 0 auto; width: 25px; height: 25px; border-radius: 50%; background: var(--soft); color: var(--muted); }
.timeline .accepted .timeline-icon, .timeline .handover .timeline-icon, .timeline .paid .timeline-icon { background: var(--ok-bg); color: var(--ok); }
.timeline .proposal .timeline-icon { background: var(--info-bg); color: var(--info); }

/* ---- Tablet and phone ------------------------------------------------------------------ */
@media (max-width: 1100px) {
  .project-grid { grid-template-columns: minmax(0, 1fr); }
  .project-side { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}
@media (max-width: 850px) {
  .next-step { flex-direction: column; align-items: stretch; }
  .money-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .money-strip > div:nth-child(3) { border-left: 0; }
  .money-strip > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .step { min-width: 0; flex: 0 0 auto; }
  .step:not(.current) .step-label { display: none; }
  :root { --control: 44px; }
  body.has-shell { padding: 0 0 calc(64px + env(safe-area-inset-bottom)); }
  .sidebar { z-index: 40; width: min(300px, 86vw); padding-top: max(14px, env(safe-area-inset-top)); transform: translateX(-100%); visibility: hidden; transition: transform .24s cubic-bezier(.2,.8,.2,1), visibility 0s .24s; }
  body.nav-open .sidebar { transform: none; visibility: visible; box-shadow: 12px 0 40px rgb(16 24 20 / 18%); transition: transform .24s cubic-bezier(.2,.8,.2,1); }
  .sidebar-close { display: grid !important; border-color: transparent; }
  .nav-link { min-height: 44px; }
  .account-action { width: 44px; height: 44px; }
  .nav-scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgb(16 24 20 / 32%); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  .mobile-bar { position: sticky; top: 0; z-index: 8; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: env(safe-area-inset-top) 16px 0; border-bottom: 1px solid var(--line); background: rgb(255 255 255 / 96%); backdrop-filter: blur(12px); }
  .mobile-brand { line-height: 0; }
  .mobile-brand img { width: 80px; height: auto; }
  .mobile-bar .icon-button { border-color: transparent; }
  .tab-bar { position: fixed; z-index: 9; left: 0; right: 0; bottom: 0; display: flex; padding: 4px max(6px, env(safe-area-inset-left)) max(4px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgb(255 255 255 / 97%); backdrop-filter: blur(12px); }
  .tab { display: flex; flex: 1 1 0; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 54px; background: transparent; color: var(--muted); font-size: .75rem; font-weight: 550; text-decoration: none; }
  .tab[aria-current="page"], .tab.is-current { color: var(--green); }
  .tab[aria-current="page"] svg, .tab.is-current svg { stroke-width: 2.1; }
  .main { padding: 20px 16px 32px; }
  .button { min-height: 44px; }
  .card-heading .button, .period-select select { min-height: 40px; }
  #toast, body.has-shell #toast { left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); }
  .insights-grid, .schedule-grid, .integrations-grid { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 570px) {
  .page-heading { flex-wrap: wrap; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
  h1 { font-size: 1.5rem; }
  .heading-controls { justify-content: flex-start; }
  .metrics-grid, .metrics-grid.count-3 { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .metric { padding: 14px; }
  .metric:nth-child(2n) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .metrics-grid.count-3 .metric:last-child { grid-column: 1 / -1; border-bottom: 0; }
  .metrics-grid.count-2 .metric:nth-child(-n+2) { border-bottom: 0; }
  .metric > strong { font-size: 1.5rem; }
  .metric-title, .metric-foot { font-size: .8125rem; }
  .insights-grid { gap: 12px; margin-bottom: 12px; }
  .upcoming-card { order: -1; }
  .card-heading { padding-inline: 14px; }
  .chart-wrap, .revenue-total { padding-inline: 14px; }
  .upcoming-list { padding-inline: 14px; }
  .upcoming-card > .wide { width: calc(100% - 28px); margin-inline: 14px; }
  .project-table-head, .directory-head, .directory-suburb, .project-customer { display: none; }
  .project-table-row { grid-template-columns: minmax(0,1fr) auto 14px; gap: 4px 8px; padding: 10px 14px; }
  .project-name { grid-row: span 2; }
  .project-table-row > span:nth-child(3) { grid-row: 2; grid-column: 2; justify-self: end; }
  .project-table-row > .project-amount { grid-row: 1; grid-column: 2; justify-self: end; }
  .project-table-row > svg { grid-column: 3; grid-row: 1 / 3; }
  .list-card .filter-bar { flex-wrap: wrap; padding: 10px; }
  .list-search { flex-basis: 140px; max-width: none; }
  .filter-select select { max-width: 160px; }
  .record-row { gap: 10px; padding-inline: 12px; }
  .directory-row .record-extra { min-width: 0; font-size: .8125rem; }
  .finance-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto 14px; gap: 4px 8px; }
  .finance-row .project-icon, .finance-row .record-main, .finance-row > svg { grid-row: span 2; }
  .finance-row > svg { grid-column: 4; grid-row: 1 / 3; }
  .finance-row .amount-cell { grid-column: 3; grid-row: 1; min-width: 0; }
  .finance-row .badge { grid-column: 3; grid-row: 2; justify-self: end; }
  .finance-totals > .card { padding: 12px 10px; }
  .finance-totals span { display: block; font-size: .75rem; }
  .finance-totals strong { font-size: clamp(.9rem, 4vw, 1.2rem); }
  .segments { overflow-x: auto; }
  .segments button { min-height: 44px; flex: 0 0 auto; }
  .integration-card { padding: 16px; }
  .role-guide dl { grid-template-columns: minmax(0,1fr); gap: 2px; padding-inline: 14px; }
  .role-guide dd { margin-bottom: 10px; }
  dialog { position: fixed; inset: auto 0 0; width: 100%; max-width: none; max-height: calc(100dvh - max(16px, env(safe-area-inset-top))); margin: 0; border-radius: 14px 14px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .sheet-grabber { display: block; width: 36px; height: 4px; margin: 8px auto 0; border-radius: 2px; background: var(--line-strong); }
  .sheet-header, .sheet-body, .sheet-footer, .sheet-related { padding-inline: 16px; }
  .sheet-footer > .button { flex: 1; }
}
@media (max-width: 360px) {
  .main { padding-inline: 12px; }
  .project-name { gap: 6px; }
  .project-name strong, .record-main strong { font-size: .875rem; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar, .nav-scrim { transition: none; }
}
