@font-face {
  font-family: Studio;
  src: local('Skia-Regular'), local('Skia');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* One scale owns the spacing of pages, cards, details and forms. */
:root {
  color-scheme: light;
  --brown: #645547;
  --brown-hover: #514235;
  --sand: #bba891;
  --ink: #292824;
  --muted: #746e65;
  --line: #e1dcd3;
  --line-strong: #d5cabb;
  --paper: #faf9f6;
  --base: #f3f1ec;
  --field: #fffefa;
  --red: #9c4236;
  --green: #3d6b54;
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s8: 32px;
  --s10: 40px;
  --control-radius: 6px;
  --panel-radius: 8px;
  --page-gutter: 40px;
  --panel-padding: 24px;
  --sidebar-width: 236px;
  --topbar-height: 68px;
  --duration-fast: 120ms;
  --duration-state: 200ms;
  --duration-panel: 280ms;
  --ease-out: cubic-bezier(.2, 0, 0, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);
  --ease-state: cubic-bezier(.4, 0, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scrollbar-gutter: stable; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--base);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 {
  font-family: Studio, 'Trebuchet MS', sans-serif;
  font-variation-settings: 'wght' 1, 'wdth' 1;
  font-weight: 400;
  letter-spacing: -.025em;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
h1 { font-size: 34px; line-height: 1.2; }
h2 { font-size: 22px; line-height: 1.3; }
h3 { font-size: 19px; line-height: 1.35; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { opacity: .55; cursor: wait; }
button, a, input, select, textarea { touch-action: manipulation; -webkit-tap-highlight-color: #bba89140; }
img { display: block; max-width: 100%; }
svg { display: block; flex-shrink: 0; }
[hidden] { display: none !important; }
:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--brown);
  outline-offset: 3px;
}
:where(button, a, input, select, textarea):focus:not(:focus-visible) { outline: none; }
/* Programmatic route focus belongs to a landmark, never to a giant blue box. */
main:focus, dialog:focus { outline: none; }
::selection { background: #d9c9b3; color: var(--ink); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.eyebrow { font-size: 10px; line-height: 1.5; letter-spacing: .14em; color: var(--brown); font-weight: 600; }

/* Shared controls. Text actions also have a deliberate hit area. */
.primary, .secondary, .danger, .text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 40px;
  max-width: 100%;
  padding: var(--s2) var(--s4);
  border: 1px solid transparent;
  border-radius: var(--control-radius);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  transition: background-color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}
.primary { background: var(--brown); border-color: var(--brown); color: #fffaf4; }
.primary:hover { background: var(--brown-hover); border-color: var(--brown-hover); }
.secondary { background: var(--field); border-color: var(--line-strong); color: var(--brown); }
.secondary:hover { background: #eee7dc; border-color: var(--sand); }
.danger { background: #fbefeb; color: var(--red); border-color: #e4c6bd; }
.danger:hover { background: #f6e3dc; border-color: #c89d90; }
.text-button { background: transparent; color: var(--brown); border-color: var(--line); min-height: 32px; padding: 6px 10px; }
.text-button:hover { background: #eee7dc; border-color: var(--line-strong); }
.icon-button { display: grid; place-items: center; width: 36px; height: 36px; flex-shrink: 0; border: 1px solid transparent; border-radius: var(--control-radius); background: transparent; font-size: 22px; color: var(--brown); transition: background-color var(--duration-fast) var(--ease-out); }
.icon-button:hover { background: #e5dccd; }
.row-link { display: inline; padding: 0; border: 0; border-radius: 2px; background: none; color: #493f33; text-align: left; font-size: inherit; font-weight: 500; line-height: inherit; overflow-wrap: anywhere; }
.row-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.inline-link { color: var(--brown); text-decoration: underline; text-decoration-color: #b6a38a; text-underline-offset: 4px; overflow-wrap: anywhere; }
.inline-link:hover { text-decoration-color: var(--brown); }

/* Shell and navigation. */
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: var(--sidebar-width); padding: var(--s6) var(--s4) var(--s5); display: flex; flex-direction: column; gap: var(--s6); background: #eee9df; border-right: 1px solid #dcd3c5; overflow-y: auto; overscroll-behavior: contain; }
.brand { display: flex; align-items: center; justify-content: center; padding: 0 var(--s3); }
.brand img { width: 144px; height: 99px; object-fit: contain; }
.sidebar-label { padding: 0 var(--s3); font-size: 9px; letter-spacing: .14em; color: #82725f; margin-bottom: calc(-1 * var(--s3)); }
.sidebar nav { display: flex; flex-direction: column; gap: var(--s1); }
.sidebar nav a { display: flex; align-items: center; gap: var(--s3); min-height: 44px; padding: var(--s3); color: #655b4d; border-radius: var(--control-radius); font-size: 13px; transition: background-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out); }
.sidebar nav a > span { width: 18px; flex-shrink: 0; }
.sidebar nav svg { width: 18px; height: 18px; }
.sidebar nav a:hover { background: #e5dccd; }
.sidebar nav a[aria-current=page] { background: var(--brown); color: #fffaf1; }
.sidebar-bottom { margin-top: auto; padding: 0 var(--s2); font-size: 12px; }
.sidebar-bottom > a { display: block; padding: var(--s4) 0; color: #756650; border-bottom: 1px solid var(--line-strong); }
.sidebar-bottom > a:hover { color: var(--ink); }
.sidebar-bottom > div { display: flex; align-items: center; gap: var(--s3); padding-top: var(--s4); }
.sidebar-bottom strong { display: block; max-width: 105px; overflow: hidden; text-overflow: ellipsis; font-size: 12px; font-weight: 500; }
.sidebar-bottom small { display: block; margin-top: var(--s1); font-size: 10px; color: #82725f; }
.sidebar-bottom .icon-button { margin-left: auto; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0; border: 1px solid var(--sand); background: #e8dfd1; border-radius: 50%; }
.workspace-main { margin-left: var(--sidebar-width); min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: var(--s4); height: var(--topbar-height); padding: 0 var(--page-gutter); background: var(--paper); border-bottom: 1px solid var(--line); }
.crumb { min-width: 0; font-size: 11px; color: #817461; letter-spacing: .03em; }
.crumb > span:first-child { margin: 0 var(--s3); color: #b8ac99; }
.crumb > span:last-child { color: #574d3e; }
.private-label { flex-shrink: 0; font-size: 10px; color: #7c7365; }
.private-label::first-letter { color: #a58c68; }
.mobile-toggle, .mobile-scrim { display: none; }
main { max-width: 1500px; min-height: calc(100dvh - var(--topbar-height) - 68px); margin: 0 auto; padding: var(--s8) var(--page-gutter) var(--s10); }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: var(--s6); margin-bottom: var(--s8); }
.page-heading > div:first-child { min-width: 0; display: grid; gap: var(--s3); }
.page-heading .muted { max-width: 720px; font-size: 13px; line-height: 1.7; }
#page-actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; flex-shrink: 0; }
#content { display: grid; gap: var(--s6); }
.app-footer { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s5); min-height: 68px; padding: var(--s4) var(--page-gutter); border-top: 1px solid var(--line); font-size: 10px; color: #817461; }
.app-footer > span:first-child { color: var(--brown); font-weight: 600; }
.app-footer > button { margin-left: auto; font-size: 10px; }

/* Dashboard, surfaces and regular lists. */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); }
.stat { display: grid; align-content: start; gap: var(--s2); padding: var(--panel-padding); background: var(--paper); border: 1px solid var(--line); border-radius: var(--panel-radius); }
.stat-label { font-size: 11px; color: var(--muted); }
.stat-value { font-size: 30px; line-height: 1.25; letter-spacing: -.03em; font-weight: 400; font-variation-settings: normal; font-variant-numeric: tabular-nums; color: #4f4334; }
.stat small { font-size: 10px; color: #817461; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--s6); align-items: start; }
.dashboard-grid > div { display: grid; gap: var(--s6); min-width: 0; }
.panel { min-width: 0; overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: var(--panel-radius); }
.panel-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--s3); padding: var(--s5) var(--panel-padding); border-bottom: 1px solid var(--line); }
.panel-header h2 { font-size: 19px; }
.panel-header .text-button { flex-shrink: 0; font-size: 11px; }
.panel-body { display: grid; gap: var(--s4); padding: var(--panel-padding); }
.panel-body > p { line-height: 1.7; }
.plan-preview { display: grid; gap: var(--s3); padding-bottom: var(--s4); border-bottom: 1px solid var(--line); }
.plan-preview:last-child { padding-bottom: 0; border-bottom: 0; }
.plan-preview > .text-button { justify-self: start; }
.notice { display: flex; align-items: flex-start; gap: var(--s4); padding: var(--s4) var(--s5); background: #eee5d6; border: 1px solid #ddceb8; border-radius: var(--panel-radius); color: #776044; font-size: 12px; line-height: 1.7; }
.notice strong { display: block; margin-bottom: var(--s1); color: #5b4932; font-size: 13px; }
.notice > span { font-size: 20px; line-height: 1.3; }
.compact-row { display: flex; align-items: center; gap: var(--s4); padding: var(--s4) var(--panel-padding); border-bottom: 1px solid var(--line); font-size: 12px; }
.compact-row:last-child { border-bottom: 0; }
.compact-row > div:first-child { flex: 1; min-width: 0; }
.compact-row strong { display: block; font-weight: 500; }
.compact-row small { display: block; margin-top: var(--s1); font-size: 10px; color: var(--muted); }
.compact-row .amount { white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge { display: inline-flex; align-items: center; width: fit-content; max-width: 100%; padding: var(--s1) var(--s2); border-radius: 4px; background: #ebe6dc; color: #756145; font-size: 10px; line-height: 1.4; white-space: nowrap; }
.badge.warn { background: #f2e8d1; color: #85601f; }
.badge.good { background: #e4eee7; color: #3e674e; }
.badge.bad { background: #f8e4df; color: var(--red); }
.badge.gray { background: #ecebe7; color: #706a60; }
.empty { padding: var(--s8) var(--panel-padding); color: #827461; font-size: 13px; line-height: 1.7; text-align: center; }
.empty strong { display: block; margin-bottom: var(--s2); color: var(--brown); font-size: 15px; }
.date-card { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; min-width: 44px; padding: 6px; background: #f5eee3; border: 1px solid var(--line-strong); border-radius: var(--control-radius); }
.date-card strong { font-size: 18px; line-height: 1.25; }
.date-card small { margin: 0; font-size: 9px; text-transform: uppercase; }
.inline-row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }

/* Data pages share a toolbar, table frame and explicit count. */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s4); margin-bottom: var(--s6); }
.search { flex: 1; min-width: 220px; max-width: 400px; }
.tabs { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); }
.tabs button { min-height: 36px; padding: var(--s2) var(--s3); border: 1px solid transparent; border-radius: var(--control-radius); background: transparent; font-size: 11px; color: #776954; transition: background-color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out); }
.tabs button[aria-pressed=true] { background: #e4dacb; border-color: #d6c5ae; color: #59462f; }
.tabs button:hover { background: #ece4d8; }
.data-section { display: grid; gap: var(--s3); min-width: 0; }
.table-wrap { overflow-x: auto; overscroll-behavior-x: contain; scroll-behavior: smooth; background: var(--paper); border: 1px solid var(--line); border-radius: var(--panel-radius); }
table { border-collapse: collapse; width: 100%; text-align: left; font-size: 12px; }
th { padding: var(--s3) var(--s5); background: #f4f0e9; border-bottom: 1px solid var(--line); font-size: 10px; font-weight: 500; letter-spacing: .02em; color: #82725f; white-space: nowrap; }
td { padding: var(--s4) var(--s5); border-bottom: 1px solid #e8e2d8; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color var(--duration-fast) var(--ease-out); }
tbody tr:hover { background: #f5f0e6; }
td small { display: block; margin-top: var(--s1); font-size: 10px; color: #827461; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.table-count { font-size: 11px; color: var(--muted); }
/* Projects use the same table surface, typography and spacing as customers. */
.sort-button { display: inline-flex; align-items: center; gap: var(--s2); margin: 0; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; letter-spacing: inherit; text-align: left; }
th:has(.sort-button) { position: relative; }
.sort-button::after { content: ''; position: absolute; inset: 0; }
.sort-button:focus-visible { outline-offset: 4px; }
.sort-direction { color: #a59680; font-size: 11px; line-height: 1; }
th[aria-sort=ascending] .sort-direction, th[aria-sort=descending] .sort-direction { color: var(--brown); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: var(--s6); }
.settings-grid .panel-body > p { font-size: 13px; color: #7c7161; }
.settings-grid .panel-body > p.small { font-size: 11px; }
.settings-grid .panel-body > button { justify-self: start; }
.activity { padding-bottom: var(--s3); border-bottom: 1px solid var(--line); font-size: 11px; color: #7b6b54; }
.activity:last-child { padding-bottom: 0; border: 0; }
.activity small { display: block; margin-top: var(--s1); font-size: 10px; color: #82725f; }

/* Incoming bills and statements reuse the shared table/detail components. */
.section-navigation { display: flex; flex-wrap: wrap; gap: var(--s2); margin: 0 0 var(--s6); padding-bottom: var(--s3); border-bottom: 1px solid var(--line); }
.section-navigation a { min-height: 36px; display: inline-flex; align-items: center; padding: var(--s2) var(--s3); border-radius: var(--control-radius); font-size: 12px; color: var(--muted); transition: color var(--duration-fast) var(--ease-out), background-color var(--duration-fast) var(--ease-out); }
.section-navigation a:hover { background: #ece4d8; }
.section-navigation a[aria-current=page] { background: #e4dacb; color: #59462f; }
.checkbox-label { display: flex; align-items: center; gap: var(--s3); min-height: 40px; cursor: pointer; }
.checkbox-label input { width: 18px; height: 18px; margin: 0; accent-color: var(--brown); flex-shrink: 0; }
.expense-payment-entry { display: grid; gap: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--line); }
.expense-payment-row { display: grid; gap: var(--s3); padding-bottom: var(--s4); border-bottom: 1px solid var(--line); }
.expense-payment-row:last-child { padding-bottom: 0; border-bottom: 0; }
.expense-payment-row .payment-row { border: 0; padding: 0; }

/* Fields: no browser-specific borders, file buttons or accidental margins. */
form { display: grid; gap: var(--s5); }
label { display: grid; gap: var(--s2); min-width: 0; margin: 0; font-size: 12px; color: #6e5e49; }
input:not([type=checkbox]), select, textarea { display: block; width: 100%; min-width: 0; min-height: 44px; margin: 0; padding: 10px var(--s3); border: 1px solid var(--line-strong); border-radius: var(--control-radius); background: var(--field); color: var(--ink); font-size: 14px; line-height: 1.5; transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out); }
input:not([type=checkbox]), textarea { -webkit-appearance: none; appearance: none; }
input::placeholder, textarea::placeholder { color: #9b9183; opacity: 1; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--brown); outline-offset: 2px; border-color: var(--brown); }
input[readonly] { background: #f0ece4; color: #6f6251; }
input[type=search]::-webkit-search-decoration { -webkit-appearance: none; }
input[type=search]::-webkit-search-cancel-button { cursor: pointer; }
input[type=date] { font-variant-numeric: tabular-nums; }
input[type=file] { padding: var(--s2); font-size: 12px; line-height: 1.8; }
input[type=file]::file-selector-button { margin-right: var(--s3); padding: 6px var(--s3); border: 1px solid var(--line-strong); border-radius: 4px; background: #eee7dc; color: var(--brown); font: inherit; cursor: pointer; }
select { -webkit-appearance: none; appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%23645547' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
textarea { min-height: 104px; resize: vertical; }
label > small, .field-note { color: #827461; font-size: 10px; line-height: 1.7; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s5) var(--s4); }
.form-grid > label { align-content: start; }
.form-grid .wide { grid-column: 1/-1; }
.form-error { color: var(--red); font-size: 12px; line-height: 1.6; }
.form-error:empty { display: none; }
.form-buttons, .drawer-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--s3); padding-top: var(--s6); border-top: 1px solid var(--line); }
.form-buttons { margin-top: var(--s1); }
.panel-actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s3); }

/* Drawers: every section has the same vertical rhythm and clear action zones. */
body.dialog-open { overflow: hidden; }
dialog { position: fixed; inset: 0 0 0 auto; width: 620px; max-width: 95vw; height: 100dvh; max-height: 100dvh; margin: 0; padding: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; border: 0; border-left: 1px solid var(--line-strong); border-radius: 0; background: #faf8f3; color: var(--ink); box-shadow: -16px 0 60px #382a1922; scroll-behavior: smooth; }
dialog::backdrop { background: #30292055; backdrop-filter: blur(2px); animation: backdrop-in var(--duration-state) var(--ease-out); }
dialog.is-closing::backdrop { animation: backdrop-out var(--duration-state) var(--ease-in) both; }
.drawer-header { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: var(--s5) var(--panel-padding); border-bottom: 1px solid var(--line); background: #faf8f3; }
.drawer-header h2 { font-size: 24px; }
.drawer-header .icon-button { font-size: 26px; }
#drawer-body { display: flex; flex-direction: column; gap: var(--s6); padding: var(--panel-padding); }
#drawer-body > * { flex-shrink: 0; }
#drawer-body > p { font-size: 13px; line-height: 1.7; }
.detail-heading { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); }
.detail-heading .muted { font-size: 11px; }
.detail-section { display: grid; gap: var(--s4); padding-top: var(--s6); border-top: 1px solid var(--line); }
.detail-section h3 { font-size: 18px; }
.detail-list { display: grid; grid-template-columns: 144px minmax(0, 1fr); gap: var(--s3) var(--s5); margin: 0; font-size: 12px; line-height: 1.7; }
.detail-list dt { margin: 0; color: #81715c; }
.detail-list dd { min-width: 0; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.related-list { overflow: hidden; border: 1px solid var(--line); border-radius: var(--control-radius); }
.related-list .compact-row { padding: var(--s4); }
.related-list .row-link { font-size: 12px; }
.notes { white-space: pre-wrap; font-size: 12px; line-height: 1.8; color: #7b6b55; }
.source { font-size: 10px; line-height: 1.7; color: #89775d; overflow-wrap: anywhere; }
.invoice-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--control-radius); background: #f1eadf; overflow: hidden; }
.invoice-summary > div { min-width: 0; display: grid; gap: var(--s2); padding: var(--s4); border-right: 1px solid var(--line); }
.invoice-summary > div:last-child { border: 0; }
.invoice-summary small { font-size: 10px; color: #81715c; }
.invoice-summary strong { font-size: 17px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.payment-row { display: flex; align-items: center; gap: var(--s4); padding: var(--s4) 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.payment-row:last-child { padding-bottom: 0; border: 0; }
.payment-row > div { flex: 1; min-width: 0; }
.payment-row small { display: block; margin-top: var(--s1); color: var(--muted); font-size: 10px; }
.upload { font-size: 12px; }
.file-picker { position: relative; display: flex; align-items: center; gap: var(--s3); min-height: 48px; padding: var(--s2); background: var(--field); border: 1px solid var(--line-strong); border-radius: var(--control-radius); }
.file-picker input[type=file] { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-picker:focus-within { outline: 2px solid var(--brown); outline-offset: 2px; border-color: var(--brown); }
.file-picker-button { flex-shrink: 0; padding: 6px var(--s3); border: 1px solid var(--line-strong); border-radius: 4px; background: #eee7dc; color: var(--brown); font-size: 12px; }
.file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.form-inline-actions { display: flex; flex-wrap: wrap; gap: var(--s3); }
.task-done .row-link { text-decoration: line-through; color: var(--muted); }

/* Price basis and billing totals share the existing detail/form spacing. */
.plan-calculation { display: grid; gap: var(--s4); padding: var(--s5); border: 1px solid var(--line); border-radius: var(--panel-radius); background: #f5f0e8; }
.plan-calculation-header { display: grid; gap: var(--s2); }
.plan-calculation-header h3 { font-size: 19px; }
.plan-calculation-header p { color: var(--brown); font-size: 12px; line-height: 1.7; }
.plan-calculation .invoice-summary { background: var(--paper); }
.plan-period-total { display: grid; gap: var(--s2); padding-top: var(--s4); border-top: 1px solid var(--line-strong); }
.plan-period-total > span, .plan-period-total p { font-size: 11px; line-height: 1.7; color: var(--muted); }
.plan-period-total > strong { font-size: 17px; font-weight: 500; font-variant-numeric: tabular-nums; }

/* Authentication and the separately encrypted vault. */
.auth-screen { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 96px; min-height: 100dvh; max-width: 1100px; margin: auto; padding: 56px; }
.auth-brand img { width: 260px; margin: auto; }
.auth-brand > span { display: block; margin-top: var(--s10); color: var(--brown); text-align: center; font-size: 11px; letter-spacing: .25em; }
.auth-card { display: grid; gap: var(--s5); padding: var(--s8); background: var(--paper); border: 1px solid var(--line); border-radius: 12px; }
.auth-card form { margin-top: var(--s1); }
.auth-card button { width: 100%; }
.auth-card > p:last-child { line-height: 1.7; }
.vault-locked { display: grid; gap: var(--s5); width: 100%; max-width: 570px; margin: var(--s4) auto; padding: var(--s8); background: var(--paper); border: 1px solid var(--line); border-radius: var(--panel-radius); }
.vault-lock-icon { font-size: 36px; line-height: 1; color: var(--brown); }
.vault-locked h2 { font-size: 27px; }
.vault-locked p { font-size: 13px; line-height: 1.8; color: #81715c; }
.vault-locked .primary { width: 100%; }
.secret-line { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); }
.secret-line input { flex: 1; min-width: 160px; }
.secret-line .secondary { min-width: 72px; min-height: 44px; }
.secret-warning { font-size: 11px; line-height: 1.7; color: #876e48; }
.toast { position: fixed; bottom: var(--s6); left: calc(50% + var(--sidebar-width) / 2); z-index: 100; width: max-content; max-width: calc(100vw - 40px); transform: translateX(-50%); padding: var(--s3) var(--s5); border-radius: var(--control-radius); background: #302b24; color: #fff8ec; box-shadow: 0 8px 25px #31200c33; font-size: 12px; line-height: 1.6; animation: toast-in var(--duration-state) var(--ease-out); }
.toast.error { background: var(--red); }
.skeleton { padding: 60px; color: #81715c; text-align: center; }
.scroll-reveal { opacity: 0; transform: translateY(10px); transition: opacity var(--duration-panel) var(--ease-out), transform var(--duration-panel) var(--ease-out); }
.scroll-reveal.is-revealed { opacity: 1; transform: none; }
@keyframes backdrop-in { from { background-color: #30292000; backdrop-filter: blur(0); } to { background-color: #30292055; backdrop-filter: blur(2px); } }
@keyframes backdrop-out { to { background-color: #30292000; backdrop-filter: blur(0); } }
@keyframes toast-in { from { opacity: 0; translate: 0 6px; } to { opacity: 1; translate: 0 0; } }

@media (max-width: 1250px) {
  :root { --page-gutter: 24px; }
  .dashboard-grid { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
  .stat-value { font-size: 27px; }
  .stat { padding: var(--s5); }
}
@media (max-width: 1000px) {
  :root { --sidebar-width: 210px; }
  .dashboard-grid, .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .dashboard-grid > .dashboard-right { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .private-label { display: none; }
  .page-heading { align-items: flex-start; flex-wrap: wrap; }
  th, td { padding-left: var(--s4); padding-right: var(--s4); }
}
@media (max-width: 760px) {
  :root { --page-gutter: 20px; --panel-padding: 20px; --topbar-height: 60px; }
  .sidebar { width: 245px; transform: translateX(-100%); transition: transform var(--duration-panel) var(--ease-out); box-shadow: 16px 0 40px #35251422; }
  .sidebar.open { transform: translateX(0); }
  body.menu-open { overflow: hidden; }
  .mobile-scrim:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 20; background: #382f2340; backdrop-filter: blur(1px); }
  .workspace-main { margin: 0; }
  .mobile-toggle { display: grid; }
  .topbar { justify-content: flex-start; gap: var(--s3); }
  .crumb { font-size: 10px; }
  main { padding-top: var(--s6); }
  h1 { font-size: 31px; }
  .page-heading { margin-bottom: var(--s6); gap: var(--s5); }
  .page-heading .eyebrow { font-size: 9px; }
  .page-heading .muted { font-size: 12px; }
  #page-actions { flex-shrink: 1; }
  .page-heading .primary { min-height: 40px; font-size: 11px; }
  .stats { grid-template-columns: minmax(0, 1fr); gap: 0; border: 1px solid var(--line); border-radius: var(--panel-radius); overflow: hidden; }
  .stat { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s1) var(--s3); border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: var(--s4) var(--panel-padding); }
  .stat:last-child { border: 0; }
  .stat-value { grid-column: 2; grid-row: 1/3; font-size: 24px; }
  .stat small { grid-column: 1; grid-row: 2; font-size: 9px; }
  .stat-label { font-size: 11px; }
  .dashboard-grid > .dashboard-right { grid-template-columns: minmax(0, 1fr); }
  .panel-header { padding-top: var(--s4); padding-bottom: var(--s4); }
  .panel-header h2 { font-size: 19px; }
  .notice { gap: var(--s3); padding: var(--s4); font-size: 11px; }
  .notice strong { font-size: 12px; }
  .compact-row { flex-wrap: wrap; gap: var(--s2) var(--s3); }
  .compact-row > div:first-child { min-width: 120px; }
  .compact-row .badge { font-size: 9px; }
  .search { flex-basis: 100%; min-width: 0; max-width: none; width: 100%; }
  .toolbar { gap: var(--s3); }
  .tabs { gap: var(--s1); }
  .tabs button { padding: var(--s2) 10px; font-size: 10px; }
  table { min-width: 650px; font-size: 11px; }
  .table-count { font-size: 10px; }
  .app-footer { gap: var(--s3); }
  .app-footer > span:nth-child(2) { display: none; }
  dialog { width: 100%; max-width: 100%; border: 0; }
  .drawer-header { padding-top: var(--s4); padding-bottom: var(--s4); }
  .drawer-header h2 { font-size: 23px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  input:not([type=checkbox]):not([type=file]), select, textarea { font-size: 16px; }
  .detail-list { grid-template-columns: 104px minmax(0, 1fr); gap: var(--s3) var(--s4); }
  .invoice-summary > div { padding: var(--s3) var(--s2); }
  .invoice-summary strong { font-size: 14px; }
  .invoice-summary small { font-size: 9px; }
  .auth-screen { display: flex; flex-direction: column; gap: var(--s8); max-width: 450px; padding: var(--s8) var(--s5); }
  .auth-brand img { width: 140px; }
  .auth-brand > span { margin-top: var(--s4); font-size: 9px; }
  .auth-card { width: 100%; padding: var(--s6); }
  .vault-locked { gap: var(--s5); margin: 0; padding: var(--s6); }
  .vault-locked h2 { font-size: 25px; }
  .vault-locked p { font-size: 12px; }
  .secret-line input { flex-basis: 100%; }
  .toast { left: 50%; bottom: var(--s4); max-width: calc(100vw - 32px); }
}
@media (max-width: 480px) {
  .plan-calculation .invoice-summary { grid-template-columns: minmax(0, 1fr); }
  .plan-calculation .invoice-summary > div { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); border-right: 0; border-bottom: 1px solid var(--line); padding: var(--s3); }
  .plan-calculation .invoice-summary > div:last-child { border-bottom: 0; }
}
@media (prefers-reduced-motion: reduce) {
  :root { --duration-fast: 0ms; --duration-state: 0ms; --duration-panel: 0ms; }
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
  .scroll-reveal { opacity: 1; transform: none; }
}

/* Stripe uses the existing Office panels, drawers and amount hierarchy. */
.stripe-id{overflow-wrap:anywhere}.stripe-entry+.stripe-entry{border-top:1px solid var(--line,#dcd5cc);margin-top:24px;padding-top:24px}.stripe-link{overflow-wrap:anywhere}.check-label{display:flex;align-items:flex-start;gap:12px}.check-label input[type=checkbox]{width:20px;min-width:20px;height:20px;margin-top:3px}.stripe-entry .panel-actions{flex-wrap:wrap}

/* Company context stays visible in the existing Office header. */
.company-switcher{display:flex;align-items:center;gap:8px;margin-left:auto;font-size:12px;color:var(--muted)}
.company-switcher select{min-height:40px;width:160px;font-size:14px;margin:0}
.company-switcher+.private-label{margin-left:12px}
@media(max-width:760px){.company-switcher{gap:5px}.company-switcher>span{display:none}.company-switcher select{width:124px;font-size:13px}.company-switcher+.private-label{display:none}.topbar .crumb{font-size:11px}}

.company-switcher,.company-switcher select{flex-shrink:0}
@media(max-width:480px){.company-switcher select{min-width:124px}.topbar .crumb{flex:1;white-space:nowrap}.topbar .crumb>span{display:none}}

/* Customer credentials extend the existing Office lists and private drawer. */
.vault-section-heading,.vault-context-bar{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:var(--s3)}
.vault-locked .vault-lock-icon svg{display:block;width:32px;height:32px}
#drawer-body .vault-locked{margin:0;max-width:none;padding:var(--s5)}
.vault-toolbar{display:grid;grid-template-columns:minmax(0,2fr) minmax(160px,1fr);gap:var(--s4);margin-bottom:var(--s4)}
#drawer-body .vault-toolbar{grid-template-columns:minmax(0,1fr)}
.vault-list{overflow:hidden;background:var(--paper);border:1px solid var(--line);border-radius:var(--control-radius)}
.vault-row{display:flex;align-items:center;gap:var(--s4);padding:var(--s4);border-bottom:1px solid var(--line)}
.vault-row:last-child{border:0}
.vault-row>div{flex:1;min-width:0}
.vault-row .row-link{font-size:13px;overflow-wrap:anywhere;text-align:left}
.vault-row small,.vault-login{display:block;margin-top:var(--s1);font-size:11px;color:var(--muted);overflow-wrap:anywhere}
.vault-row .text-button{flex-shrink:0}
#vault-count{margin-bottom:var(--s3)}
.vault-username{display:grid;justify-items:start;gap:var(--s3);min-width:0}
.vault-username p,.customer-vault-section p{overflow-wrap:anywhere}
#vault-entry-form [name=password],#secret-value,#secret-notes{font-family:ui-monospace,SFMono-Regular,Menlo,monospace}
#secret-notes{width:100%;white-space:pre-wrap;overflow-wrap:anywhere;resize:vertical}
#notes-mask{flex-basis:100%}
@media(max-width:760px){.vault-toolbar{grid-template-columns:minmax(0,1fr)}.vault-context-bar{align-items:stretch}.vault-row{gap:var(--s3)}.vault-row .row-link{font-size:14px}.vault-row .text-button{font-size:11px;padding-inline:4px}}
@media print{.customer-vault-section,.vault-list,#vault-entry-form,#secret-value,#secret-notes,.vault-login{display:none!important}body:has(#vault-unlock) #drawer-body,body:has(#secret-value) #drawer-body,body:has(#secret-notes) #drawer-body,body:has(#vault-entry-form) #drawer-body{visibility:hidden}body:has([data-view=credentials][aria-current=page]) #content{visibility:hidden}}
