/* Patrika design system. Tokens come from docs/design/brand-foundations.md (D-025).
   Use these tokens and components only; don't invent one-off styles on a screen. */

/* ------------------------------------------------------------ tokens */
:root {
  --navy: #002147;
  --blue: #0059A8;
  --blue-50: #EEF5FB; --blue-100: #D6E7F6; --blue-200: #ADCDEB; --blue-600: #00498A;
  --fold-blue: #1A8CCF;
  --hero-bg: #002147; --hero-text: #FFFFFF; --hero-soft: #D6E7F6; --hero-muted: #B9C8DA;  /* always on navy, so the same in both themes */
  --ink: #0E1A2B;
  --paper: #F8F8F6;
  --white: #FFFFFF;          /* always white: text on blue buttons, Google badge */
  --surface: #FFFFFF;        /* cards, lists, inputs (dark in dark mode) */
  --hover: #F7F9FB;
  --inverse-bg: #0E1A2B;     /* toasts, bulk action bar */
  --inverse-fg: #FFFFFF;
  --primary-bg: #0059A8;
  --s100: #EEF1F4; --s200: #E2E6EB; --s300: #C3CAD3; --s400: #8A94A3; --s500: #5F6B7A; --s600: #4A5568; --s700: #2D3748;

  --st-wait: #FFC72C;   --st-wait-bg: #FFF4D1;   --st-wait-mark: #B8860B;
  --st-progress: #0077B6; --st-progress-bg: #DDF0FA;
  --st-done: #1E7A4C;   --st-done-bg: #DDF1E6;
  --st-done-ink: #1E7A4C; --st-wait-ink: #7A5A06;
  --st-attn: #C2185B;   --st-attn-bg: #FBE1EB; --st-attn-line: #E9B7CB;
  --st-closed: #5F6B7A; --st-closed-bg: #EEF1F4;

  --font-brand: "Poppins", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --text-title: 26px; --text-section: 19px; --text-item: 16px; --text-body: 15px; --text-label: 14px; --text-caption: 13px;

  --r-input: 8px; --r-card: 12px; --r-pill: 999px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-6: 24px; --sp-8: 32px; --sp-12: 48px;
  --target: 48px;
  --shadow-float: 0 8px 28px rgba(14, 26, 43, .14);
  /* Motion (D-114): three speeds, two curves. Arriving things ease out; leaving things ease in, and go faster. */
  --dur-quick: 150ms;  /* colour, press, arrows */
  --dur-base: 200ms;   /* fades, list swaps, anything leaving */
  --dur-slow: 280ms;   /* panel, selection bar and toasts arriving */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-exit: cubic-bezier(.4, 0, 1, 1);
}
html[data-text="small"] { --text-title: 22px; --text-section: 17px; --text-item: 14px; --text-body: 13px; --text-label: 13px; --text-caption: 12px; }
html[data-text="large"] { --text-title: 28px; --text-section: 21px; --text-item: 18px; --text-body: 17px; --text-label: 15px; --text-caption: 14px; }
html[data-text="xl"] { --text-title: 31px; --text-section: 23px; --text-item: 20px; --text-body: 19px; --text-label: 17px; --text-caption: 16px; }

/* ------------------------------------------------------------ base */
/* Native controls (checkboxes, radios, date pickers) follow Patrika's theme, not the device's (D-038). */
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root[data-theme="system"] { color-scheme: dark; } }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--font-body); font-size: var(--text-body); line-height: 1.5;
  font-variant-numeric: tabular-nums;
  overflow-wrap: break-word;  /* long words break only when they have to; flex and grid boxes below stay able to shrink (D-083) */
}
h1, h2, h3 { font-family: var(--font-brand); color: var(--navy); font-weight: 600; margin: 0; line-height: 1.25; }
h1 { font-size: var(--text-title); }
h2 { font-size: var(--text-section); }
h3 { font-size: var(--text-item); }
p { margin: 0 0 var(--sp-3); }
a { color: var(--blue); text-underline-offset: 3px; }
a:hover { color: var(--blue-600); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--s600); }
.caption { font-size: var(--text-caption); color: var(--s600); }
.label { font-size: var(--text-label); font-weight: 700; color: var(--ink); }
.nowrap { white-space: nowrap; }
.icon { width: 20px; height: 20px; flex: none; vertical-align: -4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.stack > * + * { margin-top: var(--sp-4); }
.row { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ------------------------------------------------------------ layout */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.rail { background: var(--surface); border-right: 1px solid var(--s200); padding: var(--sp-6) var(--sp-4); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: var(--sp-2); }
.rail .brand { display: flex; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-2) var(--sp-6); text-decoration: none; }
.nav-link {
  display: flex; align-items: center; gap: var(--sp-3); min-height: var(--target); padding: 0 var(--sp-3);
  border-radius: var(--r-input); text-decoration: none; color: var(--s700); font-weight: 700; font-size: var(--text-label);
}
.nav-link svg { width: 22px; height: 22px; flex: none; }
.nav-link:hover { background: var(--s100); color: var(--navy); }
.nav-link[aria-current="page"] { background: var(--blue-50); color: var(--blue); }
.rail .rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--sp-1); }
.main { padding: var(--sp-8) var(--sp-8) 120px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-6); }
.page-head .eyebrow { font-size: var(--text-caption); color: var(--s600); font-weight: 700; margin-bottom: var(--sp-1); }
.tabbar { display: none; }

@media (max-width: 860px) {
  .shell { display: block; }
  .rail { display: none; }
  .main { padding: var(--sp-6) var(--sp-4) 120px; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--surface);
    border-top: 1px solid var(--s200); padding: var(--sp-1) var(--sp-1) calc(var(--sp-2) + env(safe-area-inset-bottom));
  }
  .tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 56px; text-decoration: none; color: var(--s600); font-size: 13px; font-weight: 700; border-radius: var(--r-input);
  }
  .tabbar a svg { width: 24px; height: 24px; }
  .tabbar a[aria-current="page"] { color: var(--blue); }
}

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--target); padding: 0 var(--sp-6); border-radius: var(--r-input);
  font-family: var(--font-brand); font-weight: 600; font-size: var(--text-label); line-height: 1; text-decoration: none;
  border: 1.5px solid transparent; cursor: pointer; background: none; color: inherit;
  transition: transform var(--dur-quick) var(--ease), background-color var(--dur-quick), border-color var(--dur-quick), color var(--dur-quick);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 20px; height: 20px; }
.btn-primary { background: var(--primary-bg); color: var(--white); }
.btn-primary:hover { background: color-mix(in srgb, var(--primary-bg) 86%, black); color: var(--white); }
.btn-secondary { background: var(--surface); color: var(--navy); border-color: var(--s300); }
.btn-secondary:hover { border-color: var(--s400); color: var(--navy); background: var(--s100); }
.btn-quiet { color: var(--blue); padding: 0 var(--sp-3); }
.btn-quiet:hover { background: var(--blue-50); }
.btn-danger { background: var(--surface); color: var(--st-attn); border-color: var(--st-attn-line); }
.btn-danger:hover { background: var(--st-attn-bg); color: var(--st-attn); }
.btn-block { width: 100%; }
.btn-small { min-height: 40px; padding: 0 var(--sp-4); font-size: 15px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }

/* ------------------------------------------------------------ status pill: colour + shape + word */
.status {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 4px 8px; border-radius: var(--r-pill);
  font-weight: 700; font-size: var(--text-caption); color: var(--ink); white-space: nowrap; line-height: 1.4;
  transition: background-color var(--dur-base) var(--ease);
}
.status svg { width: 16px; height: 16px; flex: none; }
.status-wait { background: var(--st-wait-bg); }
.status-progress { background: var(--st-progress-bg); }
.status-done { background: var(--st-done-bg); }
.status-attn { background: var(--st-attn-bg); }
.status-closed { background: var(--st-closed-bg); color: var(--s600); }

.flag { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-caption); font-weight: 700; color: var(--s600); background: var(--s100); padding: 2px 10px; border-radius: var(--r-pill); }
.flag-attn { color: var(--st-attn); background: var(--st-attn-bg); }

/* ------------------------------------------------------------ grouped lists (iOS-style) */
.group { background: var(--surface); border: 1px solid var(--s200); border-radius: var(--r-card); overflow: hidden; }
.group + .group { margin-top: var(--sp-4); }
.group-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--s200); background: var(--surface); flex-wrap: wrap; }
.group-head a { text-decoration: none; }
.group-head .title { font-family: var(--font-brand); font-weight: 600; font-size: var(--text-item); color: var(--navy); }
.list-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); min-height: 64px; border-bottom: 1px solid var(--s200); background: var(--surface);
}
.list-row:last-child { border-bottom: none; }
.list-row.no-check { grid-template-columns: 1fr auto; }
.list-row .t { font-family: var(--font-brand); font-weight: 600; font-size: 16.5px; color: var(--navy); }
.list-row .m { font-size: var(--text-caption); color: var(--s600); }
.list-row .actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; justify-content: flex-end; }
.list-row a.t { text-decoration: none; }
.check { width: 24px; height: 24px; accent-color: var(--blue); cursor: pointer; }
.check-target { display: flex; align-items: center; justify-content: center; width: var(--target); height: var(--target); margin: -12px; }
@media (max-width: 640px) {
  .list-row { grid-template-columns: auto 1fr; }
  .list-row.no-check { grid-template-columns: 1fr; }
  .list-row .actions { grid-column: 1 / -1; justify-content: flex-start; }
}

/* ------------------------------------------------------------ the fold: our one signature (true cut corner, no outline) */
.fold-wrap { filter: drop-shadow(0 4px 12px rgba(14, 26, 43, .12)); }
.fold {
  --f: 36px; position: relative; background: var(--surface); border-radius: var(--r-card); padding: var(--sp-6);
  clip-path: polygon(0 0, calc(100% - var(--f)) 0, 100% var(--f), 100% 100%, 0 100%);
}
.fold::after {
  content: ""; position: absolute; top: 0; right: 0; width: var(--f); height: var(--f);
  background: linear-gradient(225deg, transparent 50%, var(--blue-200) 50%, var(--blue-100) 100%);
  border-bottom-left-radius: 5px;
}
.fold .eyebrow { font-size: var(--text-caption); font-weight: 700; color: var(--blue); }

/* ------------------------------------------------------------ cards, panels, stats */
.card { background: var(--surface); border: 1px solid var(--s200); border-radius: var(--r-card); padding: var(--sp-6); }
.card-tight { padding: var(--sp-4); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--sp-3); }
.stat { background: var(--surface); border: 1px solid var(--s200); border-radius: var(--r-card); padding: var(--sp-4); text-decoration: none; color: inherit; display: block; }
.stat:hover { border-color: var(--s300); }
.stat .n { font-family: var(--font-brand); font-weight: 600; font-size: 28px; color: var(--navy); line-height: 1.1; }
.stat .l { font-size: var(--text-caption); color: var(--s600); font-weight: 700; }
.stat.attn .n { color: var(--st-attn); }
.empty { text-align: center; padding: var(--sp-12) var(--sp-6); color: var(--s600); }
.empty h3 { margin-bottom: var(--sp-2); }

/* ------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-size: var(--text-label); font-weight: 700; }
.field .hint { font-size: var(--text-caption); color: var(--s600); }
.field .error, .form-error { font-size: var(--text-caption); color: var(--st-attn); font-weight: 700; }
.input, select.input, textarea.input {
  width: 100%; min-height: var(--target); padding: 10px 14px; border: 1.5px solid var(--s300); border-radius: var(--r-input);
  background: var(--surface); color: var(--ink); font: inherit; font-size: var(--text-body);
}
textarea.input { min-height: 96px; resize: vertical; }
.input:hover { border-color: var(--s400); }
.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-100); }
.input[aria-invalid="true"] { border-color: var(--st-attn); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-3); }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.choice { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: var(--target); font-weight: 700; font-size: var(--text-label); cursor: pointer; }
.choice input { width: 22px; height: 22px; accent-color: var(--blue); }
input[type=checkbox], input[type=radio] { cursor: pointer; }
input[type=checkbox]:disabled, input[type=radio]:disabled { cursor: not-allowed; }
.segmented { display: inline-flex; background: var(--s100); border-radius: var(--r-input); padding: 4px; gap: 4px; flex-wrap: wrap; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 var(--sp-4); border-radius: 6px; font-weight: 700; font-size: var(--text-label); color: var(--s600); cursor: pointer; }
.segmented input:checked + span { background: var(--surface); color: var(--navy); box-shadow: 0 1px 3px rgba(14, 26, 43, .12); }
.segmented input:focus-visible + span { outline: 3px solid var(--blue); }
fieldset { border: none; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }

.item-editor { background: var(--surface); border: 1px solid var(--s200); border-radius: var(--r-card); padding: var(--sp-6); }
.item-editor + .item-editor { margin-top: var(--sp-4); }
.subpanel { background: var(--paper); border: 1px solid var(--s200); border-radius: var(--r-input); padding: var(--sp-4); }
.subpanel + .subpanel { margin-top: var(--sp-3); }

.dropzone {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4); border: 2px dashed var(--s300); border-radius: var(--r-input);
  background: var(--surface); cursor: pointer; color: var(--s600); font-weight: 700; font-size: var(--text-label);
}
.dropzone.over { border-color: var(--blue); background: var(--blue-50); color: var(--blue); }
.dropzone svg { width: 28px; height: 28px; flex: none; }

/* ------------------------------------------------------------ tables */
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th { text-align: left; font-size: var(--text-caption); color: var(--s600); font-weight: 700; padding: var(--sp-3) var(--sp-4); border-bottom: 1.5px solid var(--s300); }
.table td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--s200); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ action bar, sheet, toast */
.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; background: var(--inverse-bg); color: var(--inverse-fg);
  padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; justify-content: center;
  transform: translateY(110%); transition: transform var(--dur-base) var(--ease-exit);
}
.action-bar.open { transform: none; transition: transform var(--dur-slow) var(--ease); }
.action-bar .input { min-height: 44px; width: auto; }
.action-bar .btn-secondary { border-color: transparent; }
@media (min-width: 861px) { .action-bar { left: 232px; } }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(14, 26, 43, .35); z-index: 60; opacity: 0; transition: opacity var(--dur-base) var(--ease-exit); }
.sheet-backdrop.open { opacity: 1; transition: opacity var(--dur-slow) var(--ease); }
.sheet {
  position: fixed; z-index: 61; left: 50%; bottom: 0; width: min(560px, 100%); max-height: 88vh; overflow: auto;
  background: var(--surface); border-radius: 16px 16px 0 0; box-shadow: var(--shadow-float);
  padding: var(--sp-6) var(--sp-6) calc(var(--sp-6) + env(safe-area-inset-bottom));
  transform: translate(-50%, 100%); transition: transform var(--dur-base) var(--ease-exit);
}
.sheet.open { transform: translate(-50%, 0); transition: transform var(--dur-slow) var(--ease); }
.sheet .grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--s300); margin: -8px auto var(--sp-4); }
@media (min-width: 861px) {
  .sheet { bottom: auto; top: 6vh; border-radius: 16px; transform: translate(-50%, 12px); opacity: 0; transition: transform var(--dur-base) var(--ease-exit), opacity var(--dur-base) var(--ease-exit); }
  .sheet.open { transform: translate(-50%, 0); opacity: 1; transition: transform var(--dur-slow) var(--ease), opacity var(--dur-slow) var(--ease); }
  .sheet .grabber { display: none; }
}

.toasts { position: fixed; z-index: 80; left: 50%; bottom: 96px; transform: translateX(-50%); display: flex; flex-direction: column; gap: var(--sp-2); width: min(520px, calc(100% - 32px)); }
.toast {
  display: flex; align-items: center; gap: var(--sp-3); background: var(--inverse-bg); color: var(--inverse-fg); border-radius: var(--r-card);
  padding: var(--sp-3) var(--sp-4); box-shadow: var(--shadow-float); font-weight: 700; font-size: var(--text-label);
  animation: toast-in var(--dur-slow) var(--ease);
  transition: opacity var(--dur-base) var(--ease-exit), transform var(--dur-base) var(--ease-exit);
}
.toast.leaving { opacity: 0; transform: translateY(8px); }
.toast.error { background: var(--st-attn); }
.toast .btn { color: var(--inverse-fg); min-height: 40px; }
.toast .btn:hover { background: rgba(128,128,128,.18); color: var(--inverse-fg); }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } }

.skeleton { background: linear-gradient(90deg, var(--s100), var(--s200), var(--s100)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; height: 16px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.htmx-indicator { opacity: 0; transition: opacity var(--dur-base); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ------------------------------------------------------------ sign-in: a brand moment (D-025 allows the gradient here) */
.auth {
  position: relative; min-height: 100vh; overflow: hidden; display: grid; place-items: center; padding: var(--sp-6) var(--sp-4);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(44, 170, 228, .35), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(60, 248, 255, .14), transparent 60%),
    var(--hero-bg);  /* brand moment: navy in both themes */
}
.auth-inner { position: relative; width: min(420px, 100%); display: flex; flex-direction: column; align-items: center; gap: var(--sp-6); }
.auth-card-wrap { width: 100%; filter: drop-shadow(0 24px 48px rgba(0, 0, 0, .35)); }
.auth-card { --f: 44px; text-align: center; padding: 56px var(--sp-8) var(--sp-8); display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); }
.auth-mark { height: 52px; width: auto; margin-bottom: var(--sp-3); }
.auth-wordmark { font-size: 44px; font-weight: 600; letter-spacing: -0.02em; line-height: 1; }
.auth-tagline { color: var(--s600); margin: var(--sp-2) 0 var(--sp-6); max-width: 30ch; }
.auth-card form { width: 100%; }
.auth-google { gap: var(--sp-3); }
.auth-google .g-badge { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; background: var(--white); }
.auth-google .g-badge svg { width: 18px; height: 18px; }
.auth-notice { width: 100%; background: var(--st-wait-bg); border-radius: var(--r-input); padding: var(--sp-3) var(--sp-4); font-size: var(--text-caption); color: var(--ink); text-align: left; }
.auth-notice code { font-size: 13px; }
.auth-notice + .auth-notice { margin-top: var(--sp-2); }
.auth-notice-error { background: var(--st-attn-bg); color: var(--ink); font-weight: 700; margin-bottom: var(--sp-4); }
.auth-wordmark-small { font-family: var(--font-brand); font-weight: 600; color: var(--white); }
/* Error pages share the sign-in shell (D-033). */
.error-card { gap: var(--sp-3); }
.error-code { font-size: var(--text-caption); font-weight: 700; color: var(--blue); background: var(--blue-50); padding: 2px 12px; border-radius: var(--r-pill); }
.error-title { font-size: 28px; line-height: 1.2; }
.error-message { color: var(--s600); max-width: 34ch; }
.error-message p { margin: 0 0 var(--sp-2); }
.error-actions { width: 100%; display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-3); }
/* Fallback for allauth's own markup inside the branded card. */
.allauth-card { text-align: left; align-items: stretch; }
.allauth-card h1 { font-size: 26px; text-align: center; }
.allauth-card input:not([type=hidden]):not([type=checkbox]) { width: 100%; min-height: var(--target); padding: 10px 14px; border: 1.5px solid var(--s300); border-radius: var(--r-input); font: inherit; }
.allauth-card button[type=submit] { width: 100%; min-height: var(--target); border: 0; border-radius: var(--r-input); background: var(--blue); color: var(--white); font-family: var(--font-brand); font-weight: 600; font-size: 16px; cursor: pointer; margin-top: var(--sp-3); }
.auth-dev { width: 100%; margin-top: var(--sp-4); text-align: left; }
.auth-dev summary { font-size: var(--text-caption); color: var(--s500); cursor: pointer; text-align: center; list-style-position: inside; }
.auth-dev form { margin-top: var(--sp-4); }
.auth-by { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--hero-muted); font-size: var(--text-caption); font-weight: 700; }
.auth-by img { height: 16px; width: auto; }
@media (max-width: 480px) {
  .auth-card { padding: var(--sp-8) var(--sp-6) var(--sp-6); }
  .auth-wordmark { font-size: 38px; }
}

/* ------------------------------------------------------------ motion (D-114)
   Page changes fade between pages while the sidebar, top bar and tab bar stay still.
   Lists swapped in place and rows added in forms fade in (app.js). */
@view-transition { navigation: auto; }
.rail { view-transition-name: rail; }
.topbar { view-transition-name: topbar; }
.tabbar { view-transition-name: tabbar; }
::view-transition-group(rail), ::view-transition-group(topbar), ::view-transition-group(tabbar),
::view-transition-new(rail), ::view-transition-new(topbar), ::view-transition-new(tabbar) { animation: none; }
::view-transition-old(rail), ::view-transition-old(topbar), ::view-transition-old(tabbar) { display: none; }
::view-transition-old(root) { animation: fade-out var(--dur-quick) var(--ease-exit) both; }
::view-transition-new(root) { animation: fade-in var(--dur-base) var(--ease) both; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.chip, .nav-link, .tabbar a, .icon-btn { transition: background-color var(--dur-quick), border-color var(--dur-quick), color var(--dur-quick); }
.input { transition: border-color var(--dur-quick), box-shadow var(--dur-quick); }
details[open] > summary ~ * { animation: fade-in var(--dur-base) var(--ease); }
.is-leaving { opacity: 0; transition: opacity var(--dur-base) var(--ease-exit); }
#page.is-loading { opacity: .6; transition: opacity var(--dur-base) var(--ease); }
/* Switching tabs slides (app.js names the part that changes "slide" and sets --slide-dir: 1 = to a later tab,
   -1 = back, 0 = just fade). Headings, page buttons, tabs, search and save bar that are the same on both sides
   are named stay-* and keep their place; a page button whose words change cross-fades there. */
::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation-duration: var(--dur-base); animation-timing-function: var(--ease); }
::view-transition-group(slide) { animation-duration: var(--dur-slow); }
::view-transition-image-pair(slide) { overflow: clip; }
/* the old list clears first and the new one follows just behind, so the two never blur together */
::view-transition-old(slide) { animation: slide-out var(--dur-quick) var(--ease-exit) both; }
::view-transition-new(slide) { animation: slide-in var(--dur-slow) var(--ease) calc(var(--dur-quick) / 3) both; }
@keyframes slide-out { to { opacity: 0; transform: translateX(calc(var(--slide-dir, 0) * -48px)); } }
@keyframes slide-in { from { opacity: 0; transform: translateX(calc(var(--slide-dir, 0) * 48px)); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  @view-transition { navigation: none; }
}
@media print {
  .rail, .tabbar, .action-bar, .btn, .toasts { display: none !important; }
  .shell { display: block; } .main { padding: 0; }
  body { background: white; }
}

/* ------------------------------------------------------------ compact job table (Today) — D-031
   One row per item, everything visible at once. Dense with a mouse; touch screens get 44px+ targets. */
.page-head.compact { margin-bottom: var(--sp-4); }
.btn-xs { min-height: 34px; padding: 0 12px; font-size: var(--text-label); border-radius: 7px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: var(--sp-3); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--s200); color: var(--s700); font-weight: 700; font-size: var(--text-label); text-decoration: none;
}
.chip b { font-family: var(--font-brand); font-weight: 600; color: var(--s500); }
.chip:hover { border-color: var(--s300); color: var(--navy); }
.chip[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chip[aria-current="true"] b { color: var(--s300); }
.chip-attn b { color: var(--st-attn); }

.jobs { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--s200); border-radius: var(--r-card); overflow: hidden; font-size: var(--text-body); }
.jobs th { text-align: left; font-size: var(--text-caption); font-weight: 700; color: var(--s500); padding: 8px 10px; border-bottom: 1px solid var(--s200); background: var(--paper); white-space: nowrap; }
.jobs td { padding: 5px 10px; border-bottom: 1px solid var(--s100); vertical-align: middle; height: 46px; }
.jobs tbody tr:last-child td { border-bottom: none; }
.jobs tbody tr:hover td { background: var(--hover); }
.jobs tr.late td:first-child { box-shadow: inset 3px 0 0 var(--st-attn); }
.jobs .c-check { width: 40px; padding-right: 0; }
.jobs .c-due { width: 74px; white-space: nowrap; }
.jobs .c-client { width: 22%; max-width: 0; }
.jobs .c-client a { display: block; font-weight: 700; color: var(--navy); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jobs .c-item { max-width: 0; }
.jobs .item-title { display: block; color: var(--ink); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jobs a.item-title:hover, .jobs .c-client a:hover { text-decoration: underline; }  /* only real links (D-111) */
.jobs .item-meta { display: block; font-size: var(--text-caption); color: var(--s500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jobs .item-meta:empty { display: none; }
.jobs .item-meta .attn { color: var(--st-attn); font-weight: 700; }
.jobs .c-status { width: 1%; white-space: nowrap; }
.jobs .c-act { width: 1%; white-space: nowrap; text-align: right; }
.jobs .c-act form { display: inline; }
.jobs .status { font-size: var(--text-caption); padding: 2px 10px 2px 6px; gap: 5px; }
.jobs .status svg { width: 14px; height: 14px; }
.jobs .check { width: 20px; height: 20px; }
.due { font-weight: 700; font-variant-numeric: tabular-nums; }
.due-late { color: var(--st-attn); }

/* Touch screens: keep targets at least 44px (D-025 rule 1). */
@media (pointer: coarse) {
  .btn-xs, .chip { min-height: 44px; }
  .jobs td { height: 56px; }
  .jobs .check { width: 24px; height: 24px; }
}

/* Phones: each row becomes two compact lines; still one list, no cards. */
@media (max-width: 760px) {
  .jobs thead { display: none; }
  .jobs, .jobs tbody { display: block; }
  .jobs tr { display: grid; grid-template-columns: 32px 1fr auto; grid-template-areas: "check client due" "check item status"; column-gap: 8px; row-gap: 2px; padding: 10px 12px; border-bottom: 1px solid var(--s100); }
  .jobs tbody tr:last-child { border-bottom: none; }
  .jobs td { display: block; height: auto; padding: 0; border: none; max-width: none; width: auto; }
  .jobs .c-check { grid-area: check; padding-top: 2px; }
  .jobs .c-client, .jobs .c-item, .jobs .c-due, .jobs .c-status, .jobs .c-act { max-width: none; width: auto; }
  .jobs .c-client { grid-area: client; min-width: 0; }
  .jobs .c-due { grid-area: due; text-align: right; }
  .jobs .c-item { grid-area: item; min-width: 0; }
  .jobs .c-status { grid-area: status; align-self: start; }
  .jobs .c-act { grid-area: act; text-align: left; display: flex; gap: 6px; padding-top: 6px; }
  .jobs .item-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .jobs tr.late { box-shadow: inset 3px 0 0 var(--st-attn); }
  .jobs tr.late td:first-child { box-shadow: none; }
}

/* Tighter rows everywhere else too. */
.list-row { min-height: 52px; padding: 10px var(--sp-4); }
.list-row .t { font-size: var(--text-item); }
.group-head { padding: 10px var(--sp-4); }

/* ------------------------------------------------------------ D-032: one size for every status and step button */
.status-label { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }
.status .chev { width: 12px; height: 12px; flex: none; color: var(--s500); margin-left: 2px; }
.pill-btn { display: inline-flex; padding: 0; border: 0; background: none; cursor: pointer; border-radius: var(--r-pill); font: inherit; }
.pill-btn:hover .status { box-shadow: inset 0 0 0 1.5px rgba(14, 26, 43, .18); }
.pill-btn:active .status { transform: scale(.97); }
.pill-btn .status, .jobs .status { width: 11.6em; }
.jobs .status { width: 11.6em; }
.btn-step { width: 12em; }
.jobs .btn-step { width: 11em; }
.due-input { min-height: 34px; padding: 2px 6px; font-size: 13px; width: 132px; border-color: var(--st-attn); }
@media (pointer: coarse) { .due-input { min-height: 44px; } }
@media (max-width: 760px) {
  .jobs .c-due { min-width: 0; }
  .jobs .btn-step { width: auto; min-width: 150px; }
}

/* ------------------------------------------------------------ sidebar wordmark: Patrika, by Patraloka */
.rail .brand { flex-direction: column; align-items: flex-start; gap: 2px; padding: 0 var(--sp-3) var(--sp-6); }
.rail .wordmark { font-family: var(--font-brand); font-weight: 600; font-size: 24px; color: var(--navy); letter-spacing: -0.01em; line-height: 1.1; }
.rail .byline { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--s500); font-weight: 700; }
.rail .byline img { height: 15px; width: auto; }
.error-ref { font-size: 13px; color: var(--s500); font-family: ui-monospace, Menlo, monospace; margin-top: var(--sp-2); }

/* ------------------------------------------------------------ Orders table (D-035) */
.search-bar { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1.5px solid var(--s300); border-radius: var(--r-input); padding: 0 12px; margin-bottom: var(--sp-3); }
.search-bar:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-100); }
.search-bar .icon { color: var(--s500); }
.search-bar .input { border: 0; box-shadow: none; padding-left: 0; min-height: 44px; }
.search-bar .input:focus { box-shadow: none; }
.orders .c-num { width: 92px; white-space: nowrap; }
.orders .c-num a { color: var(--s600); font-weight: 700; text-decoration: none; font-variant-numeric: tabular-nums; }
.orders .c-client { width: 24%; }
.orders tbody tr:hover td { background: var(--hover); }
@media (max-width: 760px) {
  .orders tr { grid-template-columns: 1fr auto; grid-template-areas: "client due" "item status" "num billing"; }
  .orders .c-num { grid-area: num; width: auto; }
  .orders td.c-status:last-child { grid-area: billing; justify-self: end; }
  .orders .c-status { justify-self: end; }
}
.set-date { display: inline-block; font-size: 13px; font-weight: 700; color: var(--st-attn); background: var(--st-attn-bg); border-radius: var(--r-pill); padding: 2px 10px; text-decoration: none; white-space: nowrap; }

/* ------------------------------------------------------------ D-036: read the whole job from Today */
.jobs .c-client { width: 18%; }
.jobs .item-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.35; }
.jobs td { height: auto; padding-top: 8px; padding-bottom: 8px; }
.jobs .c-client a { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
@media (pointer: coarse) { .jobs td { padding-top: 10px; padding-bottom: 10px; } }

/* Toasts: close button and pause-on-hover (D-036) */
.toast .toast-close { margin-left: 2px; min-width: 40px; padding: 0 10px; font-size: 18px; line-height: 1; opacity: .8; }
.toast .toast-close:hover { opacity: 1; }
.toast .toast-bar { position: absolute; left: 0; bottom: 0; height: 3px; background: currentColor; opacity: .45; border-radius: 0 0 0 12px; }
.toast { position: relative; overflow: hidden; }


/* ------------------------------------------------------------ dark mode (D-037): same components, dark tokens */
:root[data-theme="dark"] {
  --navy: #E6EEF9; --blue: #6AAEF2; --blue-50: #132539; --blue-100: #1A3350; --blue-200: #2A4C74; --blue-600: #9CCBFA;
  --ink: #E7ECF3; --paper: #0B1220; --surface: #131C2B; --hover: #182335;
  --s100: #1A2433; --s200: #263143; --s300: #3A4860; --s400: #8291A6; --s500: #95A3B7; --s600: #B2BDCC; --s700: #CDD5E0;
  --inverse-bg: #E7ECF3; --inverse-fg: #0E1A2B; --primary-bg: #2A72BD;
  --st-wait-bg: #3A2F0E; --st-progress-bg: #0D2E44; --st-done-bg: #10331F; --st-done-ink: #7BD8A4; --st-wait-ink: #F2C14E; --st-attn: #F27BA6; --st-attn-bg: #3E1628; --st-attn-line: #6B2A45; --st-closed-bg: #1F2837;
  --shadow-float: 0 8px 28px rgba(0, 0, 0, .5);
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
  --navy: #E6EEF9; --blue: #6AAEF2; --blue-50: #132539; --blue-100: #1A3350; --blue-200: #2A4C74; --blue-600: #9CCBFA;
  --ink: #E7ECF3; --paper: #0B1220; --surface: #131C2B; --hover: #182335;
  --s100: #1A2433; --s200: #263143; --s300: #3A4860; --s400: #8291A6; --s500: #95A3B7; --s600: #B2BDCC; --s700: #CDD5E0;
  --inverse-bg: #E7ECF3; --inverse-fg: #0E1A2B; --primary-bg: #2A72BD;
  --st-wait-bg: #3A2F0E; --st-progress-bg: #0D2E44; --st-done-bg: #10331F; --st-done-ink: #7BD8A4; --st-wait-ink: #F2C14E; --st-attn: #F27BA6; --st-attn-bg: #3E1628; --st-attn-line: #6B2A45; --st-closed-bg: #1F2837;
  --shadow-float: 0 8px 28px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] .status svg circle[fill="#1E7A4C"], :root[data-theme="dark"] .status svg path[fill="#0077B6"] { filter: brightness(1.35); }

/* Display sheet options */
.option-list { display: flex; flex-direction: column; gap: 8px; }
.option { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1.5px solid var(--s300); border-radius: var(--r-input); cursor: pointer; }
.option:has(input:checked) { border-color: var(--blue); background: var(--blue-50); }
.option input { width: 20px; height: 20px; accent-color: var(--blue); }
.option-body { display: flex; flex-direction: column; }
.option-title { font-weight: 700; }
.option-title.size-small { font-size: 13px; } .option-title.size-standard { font-size: 15px; } .option-title.size-large { font-size: 17px; } .option-title.size-xl { font-size: 19px; }
.option-hint { font-size: var(--text-caption); color: var(--s500); }

/* ------------------------------------------------------------ status panel (D-037) */
.sheet-head h2 { margin-top: 2px; }
.next-step { justify-content: space-between; min-height: 52px; font-size: var(--text-item); }
.next-step .next-hint { font-family: var(--font-body); font-weight: 700; font-size: var(--text-caption); opacity: .85; }
.status-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.status-option {
  position: relative; display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 12px;
  border-radius: var(--r-input); border: 2px solid transparent; cursor: pointer; font-weight: 700; font-size: var(--text-label); color: var(--ink);
}
.status-option svg { width: 16px; height: 16px; flex: none; }
.status-option input { position: absolute; opacity: 0; pointer-events: none; }
.status-option.s-wait { background: var(--st-wait-bg); }
.status-option.s-progress { background: var(--st-progress-bg); }
.status-option.s-done { background: var(--st-done-bg); }
.status-option.s-attn { background: var(--st-attn-bg); }
.status-option.s-closed { background: var(--st-closed-bg); }
.status-option:hover { border-color: var(--s300); }
.status-option:has(input:checked) { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface) inset; }
.status-option:has(input:focus-visible) { outline: 3px solid var(--blue); outline-offset: 2px; }
.status-option.is-current { opacity: .4; cursor: not-allowed; filter: grayscale(.6); }
.status-option.is-current:hover { border-color: transparent; }
.so-label { flex: 1; }
.so-tag { font-size: 11px; font-weight: 700; text-transform: none; background: var(--surface); color: var(--s600); border-radius: var(--r-pill); padding: 1px 8px; }
@media (max-width: 420px) { .status-options { grid-template-columns: 1fr; } }
.mobile-only { display: none; }
@media (max-width: 860px) { .mobile-only { display: inline-flex; } }
.status-sheet { gap: 14px; }
.status-sheet > * + * { margin-top: 0; }
.happened { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.happened .label { margin-right: 4px; }
.input-xs { width: auto; min-height: 34px; padding: 4px 8px; font-size: var(--text-label); }
.add-note summary { font-size: var(--text-label); font-weight: 700; color: var(--blue); cursor: pointer; }
.add-note .input { margin-top: 8px; }
@media (pointer: coarse) { .input-xs { min-height: 44px; } }

/* Standard size is dense like a spreadsheet: tighter rows (D-038). */
html[data-text="small"] .jobs td { padding-top: 5px; padding-bottom: 5px; }
html[data-text="small"] .jobs .check { width: 16px; height: 16px; }
html[data-text="small"] .btn-xs, html[data-text="small"] .chip { min-height: 30px; }
html[data-text="small"] .nav-link { min-height: 40px; }
@media (pointer: coarse) { html[data-text="small"] .btn-xs, html[data-text="small"] .chip { min-height: 40px; } }
.settings-section { display: flex; flex-direction: column; gap: 14px; padding-top: 4px; }
.settings-section + .settings-section { border-top: 1px solid var(--s200); padding-top: 16px; }
.chip-select { appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer; font-family: inherit;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.chip-select.is-current { background-color: var(--ink); border-color: var(--ink); color: var(--surface); }

/* ------------------------------------------------------------ sidebar account bar (D-038) */
.me-bar { display: flex; align-items: center; gap: 4px; margin-top: 8px; padding: 10px 4px 0; border-top: 1px solid var(--s200); }
.avatar { width: 36px; height: 36px; border-radius: 50%; overflow: hidden; flex: none; display: grid; place-items: center;
  background: var(--blue-100); color: var(--navy); font-family: var(--font-brand); font-weight: 600; font-size: 14px; text-decoration: none;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--s300); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar:hover { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--blue); }
.me-name { flex: 1; min-width: 0; margin-left: 8px; font-weight: 700; font-size: var(--text-label); color: var(--s700); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 8px; background: none; color: var(--s600); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--s100); color: var(--navy); }
.icon-btn .icon { width: 19px; height: 19px; }
@media (pointer: coarse) { .icon-btn, .avatar { width: 44px; height: 44px; } }
/* show the icon for the mode you'd switch TO */
.theme-sun { display: none; }
:root[data-theme="dark"] .theme-moon { display: none; }
:root[data-theme="dark"] .theme-sun { display: block; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] .theme-moon { display: none; }
  :root[data-theme="system"] .theme-sun { display: block; }
}
.account-card { display: flex; align-items: center; gap: 20px; }
.avatar-lg { width: 72px; height: 72px; font-size: 26px; }

/* ------------------------------------------------------------ narrow screens: top bar instead of the sidebar (D-041) */
.topbar { display: none; }
@media (max-width: 860px) {
  .topbar { display: flex; align-items: center; justify-content: space-between; margin: calc(-1 * var(--sp-6)) calc(-1 * var(--sp-4)) var(--sp-4);
    padding: 10px var(--sp-4); background: var(--surface); border-bottom: 1px solid var(--s200); position: sticky; top: 0; z-index: 30; }
  .topbar-brand { display: flex; align-items: baseline; gap: 6px; text-decoration: none; }
  .topbar-brand .wordmark { font-family: var(--font-brand); font-weight: 600; font-size: 20px; color: var(--navy); }
  .topbar-brand .byline { font-size: 12px; font-weight: 700; color: var(--s500); }
  .hide-sm { display: none !important; }
}

/* Status panel spacing (D-041): room between sections, modest buttons */
.status-sheet { gap: 20px; }
.status-sheet .next-step { min-height: 42px; font-size: var(--text-label); padding: 0 16px; }
.status-sheet .status-options { gap: 10px; }
.status-sheet .status-option { min-height: 40px; }
.status-sheet .happened { border-top: 1px solid var(--s200); padding-top: 18px; }
.status-sheet .sheet-actions { padding-top: 4px; }
.status-sheet fieldset legend { margin-bottom: 10px; }

/* Phones: Today/Orders rows as three short lines — client & due · item · status & billing (D-041).
   Placed last so it wins over the desktop column widths defined above. */
@media (max-width: 760px) {
  .jobs tr { grid-template-columns: 28px minmax(0, 1fr) auto; grid-template-areas: "check client due" "check item item" "check status billing"; row-gap: 4px; }
  .jobs .c-client, .jobs .c-item { width: auto; max-width: none; }
  .jobs .c-client a { -webkit-line-clamp: 1; }
  .jobs td.c-status { grid-area: status; justify-self: start; }
  .jobs td.c-billing { grid-area: billing; justify-self: end; }
  .orders tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "client due" "item item" "status billing"; }
  .orders td.c-num { display: none; }
  .orders td.c-status:last-child { grid-area: billing; }
}

/* ------------------------------------------------------------ New order form (D-042) */
.item-heading { font-size: var(--text-item); }
.item-editor { padding: var(--sp-4) var(--sp-6) var(--sp-6); }
.item-editor > * + * { margin-top: 14px; }
.input-sm { min-height: 36px; padding: 6px 10px; font-size: var(--text-body); border-radius: 7px; }
.line-table { border: 1px solid var(--s200); border-radius: var(--r-input); overflow: hidden; }
.line-head, .line-row { display: grid; gap: 8px; align-items: center; padding: 6px 10px; }
.line-head { background: var(--paper); border-bottom: 1px solid var(--s200); font-size: var(--text-caption); font-weight: 700; color: var(--s500); padding-top: 8px; padding-bottom: 8px; }
.line-row + .line-row { border-top: 1px solid var(--s100); }
.part-line { grid-template-columns: 1.2fr 1.25fr 2.2fr 1.1fr 1fr 36px; }
.part-line.with-pages { grid-template-columns: 1.2fr 1.25fr 2fr 1fr 1fr 0.7fr 36px; }
.step-line { grid-template-columns: 1.6fr 0.9fr 1.6fr 36px; }
.line-row .na { color: var(--s500); padding-left: 10px; }
.line-row .fixed-step { font-weight: 700; padding-left: 4px; }
.line-row .icon-btn { width: 32px; height: 32px; font-size: 14px; }
.add-line { margin: 4px 6px 6px; }
.has-form-bar { padding-bottom: 110px; }
.form-bar { position: fixed; left: 232px; right: 0; bottom: 0; z-index: 40; display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 10px var(--sp-8) calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--s200); box-shadow: 0 -6px 20px rgba(14, 26, 43, .06); }
.form-bar-count { margin-right: auto; font-weight: 700; color: var(--s600); font-size: var(--text-label); }
@media (max-width: 860px) {
  .form-bar { left: 0; bottom: 64px; padding: 10px var(--sp-4); }
  .has-form-bar { padding-bottom: 170px; }
  .line-head { display: none; }
  .part-line { grid-template-columns: 1fr 1fr; }
  .step-line { grid-template-columns: 1fr 1fr; }
  .line-row .icon-btn { justify-self: end; }
  .line-row .na { display: none; }
}

/* Sidebar header band: the Patrika block reads as separate from the navigation (D-043) */
.rail { padding-top: 0; }
.rail .brand { margin: 0 calc(-1 * var(--sp-4)) var(--sp-3); padding: 22px 28px 18px; background: var(--blue-50); border-bottom: 1px solid var(--blue-100); }

/* ------------------------------------------------------------ order page (D-043) */
.order-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.order-title h1 { margin-right: 4px; }
.summary-card { padding: var(--sp-4) var(--sp-6); margin-bottom: var(--sp-4); }
.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 2fr) auto; gap: 16px; align-items: start; }
.summary-edit { align-self: center; }
@media (max-width: 960px) { .summary-grid { grid-template-columns: 1fr 1fr; } .summary-wide { grid-column: 1 / -1; } }
.item-list { background: var(--surface); border: 1px solid var(--s200); border-radius: var(--r-card); overflow: hidden; margin-bottom: var(--sp-4); }
.item-head, .item-line { display: grid; grid-template-columns: 36px minmax(0, 1fr) 90px auto; gap: 10px; align-items: center; padding: 8px 14px; }
.item-head { background: var(--paper); border-bottom: 1px solid var(--s200); font-size: var(--text-caption); font-weight: 700; color: var(--s500); }
.item-block + .item-block { border-top: 1px solid var(--s100); }
.item-block.late .item-line { box-shadow: inset 3px 0 0 var(--st-attn); }
.item-line { cursor: pointer; }
.item-line:hover { background: var(--hover); }
.item-main { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.chev-row { width: 12px; height: 12px; margin-top: 4px; flex: none; color: var(--s500); transition: transform var(--dur-quick) var(--ease); }
.item-block.open .chev-row { transform: rotate(90deg); }
.item-name { display: block; font-weight: 700; color: var(--navy); }
.item-sub { display: block; font-size: var(--text-caption); color: var(--s500); }
.item-sub .attn { color: var(--st-attn); font-weight: 700; }
.item-detail { display: none; padding: 4px 14px 16px 64px; }
.item-block.open .item-detail { display: flex; flex-direction: column; gap: 14px; }
.item-block.open .item-line { background: var(--hover); }
.detail-label { font-size: var(--text-caption); font-weight: 700; color: var(--s500); margin-bottom: 4px; }
.mini-table { border-collapse: collapse; font-size: var(--text-body); }
.mini-table th { text-align: left; font-size: var(--text-caption); color: var(--s500); font-weight: 700; padding: 2px 16px 4px 0; }
.mini-table td { padding: 3px 16px 3px 0; }
.vendor-line { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 4px 0; }
.vendor-line + .vendor-line { border-top: 1px dashed var(--s200); }
.vl-step { font-weight: 700; min-width: 140px; }
.detail-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dropzone-sm { padding: 6px 12px; font-size: var(--text-caption); }
.dropzone-sm .icon { width: 18px; height: 18px; }
.history { margin: 0; padding-left: 18px; font-size: var(--text-caption); color: var(--s600); }
.add-item-card summary { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.billing-sheet .no-charge-reason { display: none; }
.billing-sheet:has(input[value="no_charge"]:checked) .no-charge-reason { display: flex; }
@media (max-width: 760px) {
  .item-head { display: flex; padding: 4px 14px; }
  .item-head > span:not(:first-child) { display: none; }
  .item-line { grid-template-columns: 28px minmax(0, 1fr) auto; grid-template-areas: "c main due" "c status status"; }
  .item-line > span:nth-child(1) { grid-area: c; }
  .item-line > .item-main { grid-area: main; }
  .item-line > .due { grid-area: due; }
  .item-line > span:last-child { grid-area: status; }
  .item-detail { padding-left: 14px; }
}

/* D-044: order page columns line up — fixed Due and Status widths shared by header and rows */
.item-head, .item-line { grid-template-columns: 36px minmax(0, 1fr) 96px 12.5em; }
.item-head > span:nth-child(3), .item-line > .due { text-align: left; }
.item-head > span:last-child, .item-line > span:last-child { justify-self: start; }

/* D-044: status popup — real breathing room, no stray divider */
.status-sheet { gap: 26px; }
.status-sheet .sheet-head h2 { margin-top: 4px; }
.status-sheet .sheet-head .row { margin-top: 10px !important; }
.status-sheet fieldset legend { margin-bottom: 12px; }
.status-sheet .status-options { gap: 12px 14px; }
.status-sheet .status-option { min-height: 42px; padding: 0 14px; }
.status-sheet .happened { border-top: 0; padding-top: 0; gap: 10px; }
.status-sheet .add-note summary { padding: 2px 0; }
.status-sheet .sheet-actions { padding-top: 0; gap: 10px; }
.sheet { padding: 28px 28px calc(28px + env(safe-area-inset-bottom)); }
.billing-sheet { gap: 22px; }
.billing-sheet .status-options { gap: 12px 14px; }
.delete-sheet { gap: 16px; }
.delete-warning { padding: var(--sp-3) var(--sp-4); border-radius: var(--r-input); background: var(--st-attn-bg); color: var(--ink); }
.summary-card form .summary-grid, form.summary-card .summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ------------------------------------------------------------ dropdown arrows with room from the edge (D-044) */
select.input, select.chip-select {
  -webkit-appearance: none; appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%235F6B7A' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 12px;
}
select.input-sm { padding-right: 32px; background-position: right 10px center; }
select.chip-select.is-current { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%23C3CAD3' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.pdf-clear { margin-left: auto; width: 28px; height: 28px; }
/* The panels are columns, so their gap actually applies (D-044). */
.status-sheet, .billing-sheet, .delete-sheet { display: flex; flex-direction: column; }
.status-sheet.stack > * + *, .billing-sheet.stack > * + *, .delete-sheet.stack > * + * { margin-top: 0; }
.status-sheet { gap: 24px; }
.billing-sheet { gap: 22px; }
.delete-sheet { gap: 14px; }
.status-sheet .happened { padding-top: 2px; }

.billing-options { grid-template-columns: 1fr !important; }

/* ------------------------------------------------------------ Patrika's own date picker and dropdowns (D-045) */
.cs-native { position: absolute !important; width: 1px !important; height: 1px !important; opacity: 0 !important; pointer-events: none !important; overflow: hidden; }
.cs-trigger, .dp-field { display: inline-flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; cursor: pointer; font: inherit; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-trigger.input, .cs-trigger.input-sm { width: 100%; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%235F6B7A' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 12px; }
.cs-trigger.is-placeholder { color: var(--s500); }
.cs-trigger.chip { width: auto; }
.action-bar .cs-trigger { width: auto; min-width: 150px; }
.dp-field { width: 100%; }
.dp-field.input-xs, .happened .dp-field { width: auto; min-width: 150px; }
.dp-field .dp-placeholder { color: var(--s500); }
.dp-field .dp-icon { width: 17px; height: 17px; color: var(--s500); flex: none; }
.dp-field.due-input { width: 140px; }
.pop { position: fixed; z-index: 90; background: var(--surface); border: 1px solid var(--s200); border-radius: 12px; box-shadow: var(--shadow-float); animation: pop-in var(--dur-quick) var(--ease); }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } }
.cs-pop { padding: 6px; max-width: min(420px, calc(100vw - 16px)); }
.cs-search { margin: 2px 2px 6px; width: calc(100% - 4px); }
.cs-list { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; }
.cs-group { font-size: var(--text-caption); font-weight: 800; color: var(--navy); padding: 10px 10px 4px; margin-top: 4px; border-top: 1px solid var(--s200); }
.cs-group-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: var(--target); padding: 0 10px; border-width: 1px 0 0; border-style: solid; border-color: var(--s200); background: none; font-family: inherit; cursor: pointer; flex-shrink: 0; }
.cs-group-toggle::after { content: "›"; font-size: 20px; line-height: 1; color: var(--s500); transition: transform var(--dur-quick) var(--ease); }
.cs-group-toggle[aria-expanded="true"]::after { transform: rotate(90deg); }
.cs-group-toggle:hover, .cs-group-toggle:focus-visible { background: var(--blue-50); outline: none; }
.cs-option.in-group { padding-left: 22px; }
.cs-option { text-align: left; border: 0; background: none; font: inherit; color: var(--ink); padding: 8px 10px; border-radius: 7px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.cs-option:hover, .cs-option:focus-visible, .cs-option.is-active { background: var(--blue-50); outline: none; }
.cs-option.is-selected { font-weight: 700; color: var(--blue); }
.cs-option.is-selected::after { content: "✓"; margin-left: auto; }
.cs-option[disabled] { color: var(--s400); cursor: default; background: none; }
.cs-empty { padding: 10px; color: var(--s500); font-size: var(--text-label); }
.dp-pop { padding: 12px; width: 312px; }
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dp-head strong { font-family: var(--font-brand); font-weight: 600; color: var(--navy); display: inline-flex; align-items: center; gap: 4px; }
.dp-navs { display: inline-flex; }
.dp-year { font: inherit; color: inherit; border: 1px solid var(--s200); border-radius: 6px; background: var(--surface); padding: 2px 4px; cursor: pointer; }
.dp-nav { width: 30px; height: 34px; border: 0; background: none; border-radius: 8px; font-size: 20px; line-height: 1; color: var(--s600); cursor: pointer; }
.dp-nav:hover { background: var(--s100); color: var(--navy); }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-dow { text-align: center; font-size: 12px; font-weight: 700; color: var(--s500); padding: 4px 0; }
.dp-day { height: 36px; border: 0; background: none; border-radius: 8px; font: inherit; font-variant-numeric: tabular-nums; color: var(--ink); cursor: pointer; }
.dp-day:hover, .dp-day:focus-visible { background: var(--blue-50); outline: none; }
.dp-day.is-today { box-shadow: inset 0 0 0 1.5px var(--blue); font-weight: 700; }
.dp-day.is-selected { background: var(--primary-bg); color: var(--white); font-weight: 700; }
.dp-day[disabled] { color: var(--s300); cursor: default; background: none; }
.dp-foot { display: flex; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--s100); }

[hidden] { display: none !important; }
.cs-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* Pending jobs and Orders: order date first, due date beside the status (D-056) */
.jobs .c-date { width: 74px; white-space: nowrap; color: var(--s600); font-variant-numeric: tabular-nums; }
@media (max-width: 760px) {
  .jobs .c-date { display: none; }
  .jobs:not(.orders) tr { grid-template-areas: "check client due" "check item item" "check status status"; }
}

/* Item editor: one line, then a spec line with its details folded away (D-046) */
.item-entry { display: grid; grid-template-columns: 1.2fr 1.6fr 96px 1.4fr 96px; gap: 12px; align-items: start; }
.item-entry .dropzone { padding: 10px 12px; font-size: var(--text-caption); min-height: 48px; }
.item-entry .dropzone .icon { width: 18px; height: 18px; }
.item-preview { display: grid; gap: 6px; }
.item-preview:empty { display: none; }
.spec-summary { font-size: var(--text-caption); font-weight: 700; color: var(--s600); }
.suggestion { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: var(--text-caption); color: var(--s600); }
.spec-more > summary { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-caption); font-weight: 700; color: var(--blue); min-height: 32px; }
.spec-more > summary::-webkit-details-marker { display: none; }
.spec-more[open] > summary { margin-bottom: 10px; }
.spec-more > .stack { gap: 14px; }
.part-extra { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.part-extra[hidden] { display: none; }
.part-extra .input { max-width: 260px; }
@media (max-width: 760px) {
  .item-entry { grid-template-columns: 1fr 1fr; }
  .item-entry > :nth-child(-n+2), .item-entry > .item-pdf { grid-column: 1 / -1; }
}

/* Collapsible sidebar (D-057). Phones use the bottom tabs, so this is desktop only. */
.brand-mark { display: none; width: auto; height: 30px; object-fit: contain; }  /* the mark is taller than wide; keep its shape */
.rail-toggle { width: 100%; border: 0; background: none; cursor: pointer; font-family: inherit; color: var(--s600); }
@media (min-width: 861px) {
  html[data-rail="collapsed"] .shell { grid-template-columns: 76px minmax(0, 1fr); }
  html[data-rail="collapsed"] .form-bar { left: 76px; }
  html[data-rail="collapsed"] .rail { padding-left: 12px; padding-right: 12px; }
  html[data-rail="collapsed"] .rail .brand { margin-left: -12px; margin-right: -12px; padding: 22px 0 18px; align-items: center; }
  html[data-rail="collapsed"] .rail .wordmark, html[data-rail="collapsed"] .rail .byline, html[data-rail="collapsed"] .nav-label, html[data-rail="collapsed"] .me-name { display: none; }
  html[data-rail="collapsed"] .brand-mark { display: block; }
  html[data-rail="collapsed"] .nav-link { justify-content: center; padding-left: 0; padding-right: 0; gap: 0; }
  html[data-rail="collapsed"] .rail-toggle svg { transform: rotate(180deg); }
  html[data-rail="collapsed"] .me-bar { flex-direction: column; padding-left: 0; padding-right: 0; }
}
.item-due { flex-direction: row; align-items: center; gap: 8px; margin-left: auto; }
.item-due label { white-space: nowrap; }
@media (max-width: 600px) { .item-due { flex-wrap: wrap; margin-left: 0; } .item-due label { white-space: normal; } }
.part-cell { min-width: 0; }
.part-cell .input { width: 100%; box-sizing: border-box; }
.part-cell[data-swapped] > .cs-trigger { display: none; }
.swap-box { position: relative; }
.swap-box[hidden] { display: none; }
.swap-box .input { padding-right: 34px; }
.swap-box .icon-btn { position: absolute; top: 2px; right: 2px; }
.cell-pair { display: grid; grid-template-columns: 1fr 112px; gap: 8px; }
.line-row[data-unprinted] .part-sides + .cs-trigger, .line-row[data-one-side] .part-sides + .cs-trigger { visibility: hidden; }
.line-row[data-no-cover] > .part-cell, .line-row[data-no-cover] .part-sides + .cs-trigger { visibility: hidden; }
.input-locked { background: var(--s100); color: var(--s500); border-color: var(--s200); cursor: not-allowed; opacity: 1; -webkit-text-fill-color: var(--s500); user-select: none; }
.part-cell [hidden] { display: none; }

/* ------------------------------------------------------------ home (D-073) */
.home-hero-wrap { margin-bottom: var(--sp-6); }
.home-hero { background: var(--hero-bg); color: var(--hero-text); padding: var(--sp-8) var(--sp-6); }
.home-hero .eyebrow { color: var(--hero-soft); }
.home-hero h1 { color: var(--hero-text); margin: var(--sp-1) 0; }
.home-hero p { margin: 0; color: var(--hero-soft); }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
.tile-main { grid-column: 1 / -1; min-height: 0; }
.tiles-small { grid-template-columns: repeat(4, 1fr); gap: var(--sp-3); }
.tiles-small .tile { flex-direction: row; align-items: center; gap: var(--sp-3); min-height: 72px; padding: var(--sp-3) var(--sp-4); }
.tiles-small .tile-icon, .tiles-small .avatar { margin-bottom: 0; flex: none; }
.tiles-small .tile-name { font-size: var(--text-item); }
.home-section-title { margin: var(--sp-8) 0 var(--sp-3); font-family: var(--font-brand); font-size: var(--text-item); font-weight: 600; color: var(--s600); }
@media (max-width: 860px) { .tiles-small { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .tiles, .tiles-small { grid-template-columns: 1fr; } }
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-1); min-height: 164px; padding: var(--sp-6) var(--sp-4) var(--sp-4); background: var(--surface); border: 1px solid var(--s200); border-radius: var(--r-card); color: inherit; text-decoration: none; }
a.tile:hover, a.tile:focus-visible { border-color: var(--blue); background: var(--hover); }
.tile-icon { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: var(--sp-2); border-radius: 10px; background: var(--blue-50); color: var(--blue); }
.tile .avatar { margin-bottom: var(--sp-2); }
.tile-name { font-family: var(--font-brand); font-weight: 600; font-size: var(--text-section); color: var(--navy); }
.tile-about { font-size: var(--text-caption); color: var(--s600); }
.tile-soon .tile-icon { background: var(--s100); color: var(--s500); }
.tile-soon .tile-name { color: var(--s600); }
.tile-soon .flag { margin-top: auto; }
button.tile { font: inherit; text-align: left; cursor: pointer; }
button.tile:hover, button.tile:focus-visible { border-color: var(--blue); background: var(--hover); }
.shell.no-rail { display: block; }
.shell.no-rail .topbar-brand { display: flex; align-items: baseline; gap: 6px; text-decoration: none; }
.shell.no-rail .topbar-brand { gap: 10px; }
.shell.no-rail .topbar-brand .wordmark { font-family: var(--font-brand); font-weight: 700; font-size: 32px; line-height: 1.1; color: var(--navy); }
.shell.no-rail .topbar-brand .byline { font-size: 16px; font-weight: 700; color: var(--s500); }
.shell.no-rail .topbar-brand .byline img { height: 20px; }
.topbar-brand .byline { display: inline-flex; align-items: center; gap: 4px; }
.topbar-brand .byline img { height: 14px; width: auto; }
@media (max-width: 480px) { .shell.no-rail .topbar-brand .wordmark { font-size: 26px; } .shell.no-rail .topbar-brand .byline { font-size: 14px; } }
.table-scroll { overflow-x: auto; }
.shell.no-rail .topbar { display: flex; align-items: center; justify-content: space-between; margin: calc(-1 * var(--sp-8)) calc(-1 * var(--sp-8)) var(--sp-6);
    padding: 10px var(--sp-4); background: var(--surface); border-bottom: 1px solid var(--s200); position: sticky; top: 0; z-index: 30; }
@media (max-width: 860px) { .shell.no-rail .topbar { margin: calc(-1 * var(--sp-6)) calc(-1 * var(--sp-4)) var(--sp-4); } }

.topbar-actions { display: flex; align-items: center; gap: 4px; }
.topbar-actions .avatar { margin-left: 6px; }
.tile-text { display: flex; flex-direction: column; min-width: 0; }
@media (max-width: 640px) {
  .tile { display: grid; grid-template-columns: 44px minmax(0, 1fr); column-gap: var(--sp-3); row-gap: 0; align-items: center; padding: var(--sp-3) var(--sp-4); min-height: 0; }
  .tile-icon, .tile .avatar { grid-row: 1 / span 3; margin-bottom: 0; }
  .tile-name { font-size: var(--text-item); }
  .tile-soon .flag { margin-top: 2px; justify-self: start; }
  .tiles-small .tile { display: flex; min-height: 60px; }
  .home-section-title { margin-top: var(--sp-6); }
}

/* ------------------------------------------------------------ phones and tablets: placed last so it wins (D-079) */
@media (max-width: 860px) {
  .part-line, .part-line.with-pages { grid-template-columns: 1fr 1fr 36px; grid-template-areas: "name name remove" "material material material" "size print print" "sides count count"; padding: 12px 10px; }
  .part-line > .c-name { grid-area: name; } .part-line > .c-material { grid-area: material; } .part-line > .c-size { grid-area: size; }
  .part-line > .c-print { grid-area: print; } .part-line > .c-sides { grid-area: sides; } .part-line > .c-count { grid-area: count; } .part-line > .c-remove { grid-area: remove; }
  .part-line .c-count .na { display: none; }
  .step-line { grid-template-columns: 1fr 1fr 36px; grid-template-areas: "step step remove" "mode vendor vendor"; padding: 12px 10px; }
  .step-line > .c-step { grid-area: step; } .step-line > .c-mode { grid-area: mode; } .step-line > .c-vendor { grid-area: vendor; }
  .step-line > .c-remove { grid-area: remove; }
  .line-row .fixed-step { padding-left: 0; }
}
@media (max-width: 760px) {
  .item-head { display: flex; padding: 4px 14px; }
  .item-head > span:not(:first-child) { display: none; }
  .item-line { grid-template-columns: 28px minmax(0, 1fr) auto; grid-template-areas: "c main due" "c status status"; row-gap: 6px; }
  .item-line > .due { text-align: right; }
  .order-title h1 { font-size: var(--text-title); }
  .item-editor { padding: var(--sp-4); }
  .home-hero { padding: var(--sp-6) var(--sp-4); }
  .tile { min-height: 0; }
}

/* ------------------------------------------------------------ bill status panel (D-080) */
.billing-sheet { gap: var(--sp-6); }
.billing-sheet .sheet-head h2 { margin-top: var(--sp-1); }
.billing-sheet fieldset legend { margin-bottom: var(--sp-3); }
.billing-sheet .billing-options { gap: var(--sp-3); }
.billing-sheet .status-option { min-height: 68px; padding: var(--sp-3) var(--sp-4); gap: var(--sp-3); }
.billing-sheet .status-option svg { width: 20px; height: 20px; }
.so-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.so-text .so-label { font-size: var(--text-item); }
.so-hint { font-size: var(--text-caption); font-weight: 400; color: var(--s600); }
.billing-sheet .no-charge-reason { gap: var(--sp-2); }
.billing-sheet .no-charge-reason .input { width: 100%; }
.billing-sheet .sheet-actions { gap: var(--sp-3); }
.billing-sheet .next-step { min-height: 42px; font-size: var(--text-label); padding: 0 16px; justify-content: space-between; }

/* ------------------------------------------------------------ account menu on phones: a line of icons (D-081) */
.me-menu { display: none; position: relative; }
.me-menu > .avatar { padding: 0; border: 0; background: none; cursor: pointer; }
.me-menu-rail { position: absolute; left: 50%; top: calc(100% + 8px); z-index: 50; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 52px; padding: 4px; background: var(--surface); border: 1px solid var(--s200); border-radius: 26px; box-shadow: var(--shadow-float); overflow: hidden; transform: translate(-50%, -10px); max-height: 0; opacity: 0; visibility: hidden; transition: max-height var(--dur-base) var(--ease), opacity var(--dur-quick), transform var(--dur-base) var(--ease), visibility var(--dur-base); }
.me-menu.open .me-menu-rail { max-height: 170px; opacity: 1; transform: translate(-50%, 0); visibility: visible; }
.me-menu-rail .icon-btn { width: 44px; height: 44px; color: var(--navy); }
@media (max-width: 860px) {
  .topbar-actions { display: none; }
  .me-menu { display: block; }
}

/* ------------------------------------------------------------ phones: compact rows, a lighter status panel (D-081) */
.select-all-sm { display: none; }
.tab-soon { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; color: var(--s500); font-size: 13px; font-weight: 700; }
.tab-soon svg { width: 24px; height: 24px; }
@media (max-width: 760px) {
  .select-all-sm { display: inline-flex; min-height: 36px; margin-bottom: var(--sp-1); font-size: var(--text-caption); }
  .jobs:not(.orders) tbody tr { grid-template-columns: 28px minmax(0, 1fr) auto; grid-template-areas: "check client due" "check item item" "check status date"; row-gap: 4px; padding: 10px 12px; }
  .jobs.orders tbody tr { row-gap: 4px; padding: 10px 12px; }
  .jobs tbody td { padding: 0; }
  .jobs tbody td.c-check { padding-top: 2px; }
  .jobs tbody td.c-date { display: block; grid-area: date; align-self: center; font-size: var(--text-caption); color: var(--s500); }
  .jobs.orders tbody tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "client due" "item item" "status billing"; }
  .jobs.orders tbody td.c-date { display: none; }
  .jobs .item-title { -webkit-line-clamp: 1; }
}
@media (max-width: 860px) {
  .sheet { padding: 18px var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom)); max-height: 80vh; }
  .sheet .grabber { margin-top: -6px; margin-bottom: var(--sp-3); }
  .status-sheet { gap: 14px; }
  .status-sheet .status-options { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .status-sheet .status-option { min-height: 38px; padding: 0 10px; }
  .status-sheet .next-step { min-height: 44px; }
  .billing-sheet { gap: 16px; }
  .billing-sheet .status-option { min-height: 56px; }
}
@media (max-width: 860px) {
  .happened { display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: center; }
  .happened .label { grid-column: 1 / -1; margin: 0; }
  .happened .dp-field { min-width: 0; width: 100%; }
  .happened .btn { padding: 0 10px; }
}

/* ------------------------------------------------------------ lists: selected and hovered rows, Pickup shelf (D-082) */
.jobs tbody tr:has(input:checked) td { background: var(--blue-50); }
.item-line:has(input:checked) { background: var(--blue-50); }
.pickup-actions { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.pickup-actions form { margin: 0; }
.jobs th.c-status:empty { width: 1%; }
@media (max-width: 760px) {
  .jobs tbody tr:hover, .jobs tbody tr:active { background: var(--hover); }
  .jobs tbody tr:has(input:checked) { background: var(--blue-50); }
  .jobs tbody td.c-check { align-self: center; padding-top: 0; }
  .page-head.one-line { flex-wrap: nowrap; align-items: center; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin-left: calc(-1 * var(--sp-4)); margin-right: calc(-1 * var(--sp-4)); padding: 0 var(--sp-4); scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chips > * { flex: none; white-space: nowrap; }
}
@media (max-width: 760px) {
  #pickup-list tbody td.c-date { display: none; }
  #pickup-list tbody tr { grid-template-areas: "check client due" "check item item" "check status status"; }
  .action-bar { top: auto; bottom: 0; height: auto; flex-wrap: wrap; justify-content: flex-start; gap: var(--sp-2); padding: 10px var(--sp-4) calc(10px + env(safe-area-inset-bottom)); max-height: none; }
  .action-bar .input, .action-bar .cs-trigger, .action-bar .dp-field { flex: 1 1 40%; min-width: 0; width: auto; }
  .action-bar [data-bulk-count] { flex: 1 1 100%; }
}

/* ------------------------------------------------------------ nothing pushes past its box (D-083) */
.row > *, .page-head > *, .list-row > *, .order-title > *, .summary-grid > *, .detail-block, .vendor-line > *, .item-detail, .card, .group, .sheet-head, .field { min-width: 0; }
.input, textarea.input { min-width: 0; max-width: 100%; }
.page-head > .row, .page-head > .btn { flex-shrink: 0; max-width: 100%; }
.page-head > .row { flex-wrap: wrap; }

/* ------------------------------------------------------------ order page on phones (D-085) */
@media (max-width: 760px) {
  .summary-card { padding: var(--sp-3) var(--sp-4); }
  .summary-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px var(--sp-3); }
  .summary-wide.summary-empty { display: none; }
  .summary-edit { grid-column: 2; justify-self: end; align-self: end; }
  .summary-bill .status { font-size: var(--text-caption); padding-left: 8px; padding-right: 8px; }
  .mini-table, .mini-table tbody { display: block; width: 100%; }
  .mini-table thead { display: none; }
  .mini-table tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--s100); }
  .mini-table tr:last-child { border-bottom: 0; }
  .mini-table td { display: inline; padding: 0; border: 0; font-size: var(--text-caption); color: var(--s600); }
  .mini-table td:first-child { display: block; font-size: var(--text-body); font-weight: 700; color: var(--navy); }
  .mini-table td.is-empty { display: none; }
  .mini-table td:not(:first-child):not(.is-empty) ~ td:not(.is-empty)::before { content: " · "; }
}

/* ------------------------------------------------------------ order page on desktop: details fill the row (D-085) */
@media (min-width: 761px) {
  .item-detail { padding: var(--sp-3) var(--sp-4) var(--sp-4); }
  .mini-table { width: 100%; table-layout: fixed; }
  .mini-table th, .mini-table td { padding-left: 12px; padding-right: 12px; }
  .mini-table thead th { background: var(--paper); border-bottom: 1px solid var(--s200); padding-top: 8px; padding-bottom: 8px; }
  .mini-table tbody td { border-bottom: 1px solid var(--s100); padding-top: 8px; padding-bottom: 8px; }
  .mini-table th:nth-child(1) { width: 20%; } .mini-table th:nth-child(2) { width: 14%; } .mini-table th:nth-child(3) { width: 30%; }
  .mini-table th:nth-child(4), .mini-table th:nth-child(5), .mini-table th:nth-child(6) { width: 12%; }
  .vendor-line { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) minmax(0, 1fr); gap: var(--sp-3); align-items: center; padding: 6px 0; }
  .vendor-line .vl-step { min-width: 0; }
}

/* ------------------------------------------------------------ New order: the product line scales with the screen (D-087) */
@media (min-width: 861px) {
  .item-entry { grid-template-columns: minmax(0, 2fr) minmax(0, 2.2fr) minmax(90px, 0.7fr) minmax(0, 2fr) minmax(90px, 0.7fr); gap: var(--sp-4); }
  .item-entry .dropzone { min-height: var(--target); height: var(--target); padding: 0 12px; }
  .item-entry .dropzone span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
@media (min-width: 861px) and (max-width: 1180px) {
  .item-entry { grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) minmax(90px, 1fr); }
  .item-entry > .item-pdf { grid-column: span 2; }
}

/* ------------------------------------------------------------ collapsed sidebar: the picture opens its icons sideways (D-090) */
.me-bar-actions { display: flex; align-items: center; gap: 4px; }
.me-bar-account { display: none; }
@media (min-width: 861px) {
  html[data-rail="collapsed"] .me-bar { position: relative; }
  html[data-rail="collapsed"] .me-bar-actions { position: absolute; left: calc(100% + 24px); bottom: 2px; z-index: 50; flex-direction: row; padding: 4px; background: var(--surface); border: 1px solid var(--s200); border-radius: 26px; box-shadow: var(--shadow-float); overflow: hidden; max-width: 0; opacity: 0; visibility: hidden; transform: translateX(-8px); transition: max-width var(--dur-base) var(--ease), opacity var(--dur-quick), transform var(--dur-base) var(--ease), visibility var(--dur-base); }
  html[data-rail="collapsed"] .me-bar.open .me-bar-actions { max-width: 170px; opacity: 1; visibility: visible; transform: none; }
  html[data-rail="collapsed"] .me-bar-account { display: grid; }
  html[data-rail="collapsed"] .me-bar-actions .icon-btn { width: 44px; height: 44px; color: var(--navy); flex: none; }
  html[data-rail="collapsed"] .rail { overflow: visible; z-index: 30; }
  /* collapsed sidebar: hovering an icon shows its name beside it */
  html[data-rail="collapsed"] .nav-link { position: relative; }
  html[data-rail="collapsed"] .nav-link:is(:hover, :focus-visible) .nav-label {
    display: block; position: absolute; left: calc(100% + 14px); top: 50%; transform: translateY(-50%); z-index: 50;
    padding: 6px 12px; border-radius: 8px; background: var(--inverse-bg); color: var(--inverse-fg); white-space: nowrap;
    font-size: var(--text-label); font-weight: 700; box-shadow: var(--shadow-float); pointer-events: none;
    animation: fade-in var(--dur-quick) var(--ease); }
}

/* ------------------------------------------------------------ setup screens (D-091) */
.section-title { font-size: var(--text-section); margin: 0; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 var(--sp-4); }
.contact-line { grid-template-columns: 1.2fr 1fr 1fr 1.4fr 36px; }
.alias-line { grid-template-columns: minmax(0, 1fr) 36px; }
@media (max-width: 760px) {
  .contact-line { grid-template-columns: 1fr 1fr 36px; }
  .contact-line > .icon-btn { grid-column: 3; grid-row: 1 / span 2; align-self: center; }
  .archive-card { flex-wrap: wrap; }
  .archive-card .grow { flex: 1 1 200px; }
  .choice-grid { grid-template-columns: 1fr 1fr; }
  .jobs.parties tbody tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "client status" "item item" "contact contact"; }
  .jobs.parties tbody td.c-status { grid-area: status; justify-self: end; font-size: var(--text-caption); color: var(--s600); }
  .jobs.parties tbody td.c-contact { grid-area: contact; }
  .jobs.parties tbody td.c-contact .item-title { font-size: var(--text-caption); color: var(--s600); }
  .jobs.parties tbody td.is-empty { display: none; }
}
/* clients & vendors list: four even columns, each with a second line, so the row is used end to end (D-099) */
@media (min-width: 761px) {
  .jobs.parties .c-client { width: 30%; }
  .jobs.parties .c-item { width: 30%; }
  .jobs.parties .c-contact { width: 26%; max-width: 0; }
  .jobs.parties .c-status { width: 14%; white-space: nowrap; }
  .jobs.parties td { height: 56px; }
  .jobs.parties :is(.c-item, .c-contact, .c-status) { text-align: center; }
}
.jobs.parties .is-empty .item-title { color: var(--s400); }
.invite-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.5fr) minmax(0, 1fr) auto; gap: var(--sp-4); align-items: end; }
.person-name { display: block; font-weight: 700; color: var(--navy); }
.jobs.team tr.is-off td { color: var(--s500); }
.jobs.team tr.is-off .person-name { color: var(--s500); }
@media (min-width: 761px) {
  .jobs.team .c-due { width: 200px; text-align: center; }
  .jobs.team .c-status { width: 300px; text-align: center; }
  .jobs.team td.c-due .input { margin: 0 auto; }
}
/* Access says whether they can sign in, with the button beside it (D-105) */
.jobs.team td.c-status { white-space: nowrap; }
.jobs.team .access-state { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-caption); color: var(--s600); margin-right: var(--sp-2); vertical-align: middle; }
.jobs.team .access-state svg { width: 14px; height: 14px; }
.jobs.team .access-state.is-allowed { color: var(--st-done); font-weight: 700; }
.jobs.team .access-state.is-revoked { color: var(--st-attn); font-weight: 700; }
.jobs.team .remove-btn { gap: 4px; }
.jobs.team .remove-btn svg { width: 14px; height: 14px; }
#team-list > .section-title { margin-top: var(--sp-8); }
@media (max-width: 760px) {
  .invite-grid { grid-template-columns: 1fr; }
  .jobs.team tbody tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "client client" "item item" "due status"; align-items: center; row-gap: 4px; }
  .jobs.team tbody td.c-due { text-align: left; padding-top: 6px; }
  .jobs.team tbody td.c-status { grid-area: status; justify-self: end; padding-top: 6px; }
}
/* what each role can do (D-102) */
.role-table-card { margin: var(--sp-6) 0; }
.role-table-card summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; font-weight: 700; color: var(--navy); min-height: 28px; }
.role-table-card summary::-webkit-details-marker { display: none; }
.role-table-card[open] summary { margin-bottom: var(--sp-3); }
.role-table { width: 100%; border-collapse: collapse; font-size: var(--text-label); }
.role-table th, .role-table td { padding: 8px 10px; border-bottom: 1px solid var(--s100); text-align: center; }
.role-table thead th { font-size: var(--text-caption); color: var(--s500); }
.role-table th[scope="row"] { text-align: left; font-weight: 400; color: var(--ink); white-space: nowrap; }
.role-table tbody tr:last-child > * { border-bottom: none; }
.role-table .yes { color: var(--st-done); font-weight: 700; }
.role-table .no { color: var(--s300); }
.setup-tabs { margin-bottom: var(--sp-2); }
.setup-tabs .chip[aria-current="true"] { background: var(--navy); color: var(--surface); }
.setup-part-line { grid-template-columns: 1.3fr 1fr 2fr 1fr 1fr 0.8fr 1.3fr 36px; }
.setup-remove input { position: absolute; opacity: 0; pointer-events: none; }
.setup-remove { position: relative; cursor: pointer; }
.line-row.is-removed { opacity: .45; }
.line-row.is-removed .setup-remove { color: var(--st-attn); }
.subject-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto; }
.list-row form { margin: 0; }
@media (min-width: 761px) {
  .jobs.setup-table .c-client { width: 32%; }
  .jobs.setup-table .c-status { width: 240px; }
  .jobs.setup-table.labels-table .c-client { width: 36%; }
}
/* each part on two lines, so no dropdown is cut short (D-110) */
@media (min-width: 861px) {
  .setup-part-line { grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.9fr) minmax(0, 0.8fr) minmax(0, 2.4fr) 36px; row-gap: 6px; }
  .setup-part-line > :is(.part-cell, span):nth-of-type(1) { grid-column: 1; grid-row: 1; }
  .setup-part-line > :is(.part-cell, span):nth-of-type(2) { grid-column: 2; grid-row: 1; }
  .setup-part-line > :is(.part-cell, span):nth-of-type(6) { grid-column: 3; grid-row: 1; }
  .setup-part-line > :is(.part-cell, span):nth-of-type(3) { grid-column: 4; grid-row: 1; }
  .setup-part-line > .setup-remove, .setup-part-line > span:nth-of-type(8) { grid-column: 5; grid-row: 1; }
  .setup-part-line > :is(.part-cell, span):nth-of-type(4) { grid-column: 1; grid-row: 2; }
  .setup-part-line > :is(.part-cell, span):nth-of-type(5) { grid-column: 2 / 4; grid-row: 2; }
  .setup-part-line > :is(.part-cell, span):nth-of-type(7) { grid-column: 4; grid-row: 2; }
}
/* each part its own box, so two parts don't run together; cover layout only on bound labels (D-111) */
#setup-parts .line-row { border: 1px solid var(--s200); border-radius: var(--r-input); padding: 10px; background: var(--surface); }
#setup-parts .line-row + .line-row { margin-top: 10px; border-top: 1px solid var(--s200); }
.line-table:has(#setup-parts) { border: none; overflow: visible; }
.label-form:not([data-family="partner"]):not([data-family="large_format"]) .made-by-vendor { display: none; }
@media (hover: none) { .jobs .c-rowact { display: none; } }
/* archive and remove: icons on the hovered row, or the bar once rows are ticked (D-112) */
.jobs .c-rowact { width: 1%; white-space: nowrap; text-align: right; }
.row-actions { display: inline-flex; gap: 2px; visibility: hidden; }
.row-actions form { margin: 0; }
.jobs tbody tr:hover .row-actions, .jobs tbody tr:focus-within .row-actions { visibility: visible; }
.pick-table:has(input[data-bulk]:checked) .row-actions { visibility: hidden; }
.icon-btn.icon-danger:hover, .btn.icon-danger:hover { color: var(--st-attn); }
.btn-icon { min-width: 44px; padding: 0 10px; }
.btn-icon .icon { width: 19px; height: 19px; margin: 0; }
.jobs.subject-table { border: 0; border-radius: 0; border-top: 1px solid var(--s100); table-layout: fixed; }
.jobs.subject-table td.c-check { width: 44px; }
.jobs.subject-table td.c-client { width: auto; max-width: none; }
.jobs.subject-table td.c-rowact { width: 96px; }
/* Catalogue: tabs and search on one line; tabs swap the list in place (D-113), with the shared fade (D-114) */
.catalogue-bar { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.catalogue-bar .setup-tabs { margin: 0; flex: none; }
.catalogue-bar .search-bar { flex: 1 1 auto; max-width: 360px; margin: 0 0 0 auto; }
.catalogue-bar .search-bar .input { min-height: 38px; }
.jobs tbody tr[hidden], .service-group[hidden] { display: none; }
.pick-table tr.is-archived .c-client a, .pick-table tr.is-archived .item-title, .pick-table tr.is-archived .c-status,
.pick-table tr.is-archived .subject-name { color: var(--s500); }
.search-empty { margin-top: var(--sp-3); }
@media (max-width: 760px) {
  .catalogue-bar { flex-direction: column; align-items: stretch; gap: var(--sp-2); }
  .catalogue-bar .search-bar { max-width: none; margin: 0; }
}
.remove-list { margin: 0; padding-left: 18px; }
.remove-list:empty { display: none; }
.label-form:not([data-family="bound"]) .setup-part-line > :is(.part-cell, span):nth-of-type(7) { display: none; }
.subject-actions { gap: 6px; flex-wrap: nowrap; }
.measure-input { display: grid; grid-template-columns: minmax(0, 1fr) 92px; gap: 8px; }
.subject-rows { padding: 0 var(--sp-4) var(--sp-2); }
.subject-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); min-height: 48px; border-top: 1px solid var(--s100); }
.subject-row .muted { color: var(--s500); }
.subject-row form { margin: 0; }
@media (max-width: 860px) {
  .setup-part-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px; }
  .setup-part-line > .part-cell:nth-of-type(1) { grid-column: 1 / 3; grid-row: 1; }
  .setup-part-line > .setup-remove { grid-column: 3; grid-row: 1; }
  .setup-part-line > .part-cell:nth-of-type(2) { grid-column: 1; grid-row: 2; }
  .setup-part-line > .part-cell:nth-of-type(6) { grid-column: 2 / 4; grid-row: 2; }
  .setup-part-line > .part-cell:nth-of-type(3) { grid-column: 1 / -1; grid-row: 3; }
  .setup-part-line > .part-cell:nth-of-type(4) { grid-column: 1; grid-row: 4; }
  .setup-part-line > .part-cell:nth-of-type(5) { grid-column: 2 / 4; grid-row: 4; }
  .setup-part-line > .part-cell:nth-of-type(7) { grid-column: 1 / -1; grid-row: 5; }
}
@media (max-width: 760px) {
  .jobs.setup-table tbody tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "client client" "item status"; }
  .jobs.setup-table.pick-table tbody tr { grid-template-columns: 28px minmax(0, 1fr) auto; grid-template-areas: "check client client" "check item status"; }
  .jobs.setup-table.pick-table td.c-rowact { display: none; }
  .jobs.setup-table.subject-table tbody tr { grid-template-areas: "check client client"; }
  .jobs.setup-table tbody td.c-status:empty { display: none; }
  .jobs.setup-table tbody td.c-status { grid-area: status; justify-self: end; align-self: center; }
  .jobs.setup-table tbody td.c-item { grid-area: item; }
  .jobs.setup-table tbody td.c-due { font-size: var(--text-caption); color: var(--s600); }
  .jobs.setup-table tbody td.c-status { font-size: var(--text-caption); color: var(--s600); }
  .subject-grid { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------ costs and rates (D-094) */
.cost-line { grid-template-columns: minmax(0, 2fr) repeat(3, minmax(80px, 1fr)); }
.rule-line { grid-template-columns: minmax(0, 2fr) repeat(3, minmax(80px, 1fr)); }
/* the price book (D-131): what it is, its quantity tiers, floor and trade */
.price-line { grid-template-columns: minmax(0, 1.6fr) minmax(0, 2.4fr) minmax(90px, 0.8fr) minmax(90px, 0.8fr); align-items: center; }
.price-tiers { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-2); }
.price-tiers .btn { min-height: 36px; }
@media (min-width: 761px) { .price-line .price-tag { display: none; } }
@media (max-width: 760px) {
  .price-line { grid-template-columns: 1fr 1fr; }
  .price-line > :first-child, .price-line .price-tiers { grid-column: 1 / -1; }
}
.finish-cost-line { grid-template-columns: minmax(0, 2fr) minmax(0, 1.3fr) minmax(90px, 1fr) minmax(90px, 1fr); }
.margin-line { grid-template-columns: minmax(0, 2fr) minmax(90px, 1fr); }
.cost-name { font-weight: 700; color: var(--navy); min-width: 0; }
.rate-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-3); align-items: end; }
@media (max-width: 860px) { .rate-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.line-row[hidden] { display: none; }
.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.vendor-rates .label { display: flex; gap: var(--sp-3); align-items: baseline; }
/* invoice prices: known ones, then the worked-out ones in grey (D-117) */
.invoice-job { display: flex; flex-direction: column; gap: var(--sp-2); padding-bottom: var(--sp-3); }
.invoice-job > :not(table) { margin-left: var(--sp-4); margin-right: var(--sp-4); }
.invoice-table tr.is-worked-out .subject-name { color: var(--s600); font-weight: 400; }
.predict-row { display: flex; align-items: center; gap: var(--sp-2); }
.predict-row .input { width: 140px; }
.predict-out:empty { display: none; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
/* Costs: each section folds; empty boxes are marked after a save (D-115) */
.cost-groups .cost-body { display: flex; flex-direction: column; gap: var(--sp-3); padding: 0 var(--sp-4) var(--sp-4); }
.paper-per { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--text-label); font-weight: 700; }
.paper-per .input { width: auto; }
@media (max-width: 760px) {
  .cost-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .finish-cost-line { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr); }
  .cost-line > .cost-name, .finish-cost-line > .cost-name { grid-column: 1 / -1; }
  .finish-cost-line.line-head > span:not(:first-child) { display: none; }
  .rate-grid { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------ quotes (D-096) */
.price-box { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: var(--sp-4); padding: var(--sp-3) var(--sp-4); background: var(--paper); border: 1px solid var(--s200); border-radius: var(--r-input); }
.price-panel { display: flex; flex-wrap: wrap; gap: var(--sp-3) var(--sp-6); align-items: flex-start; }
.price-figure { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.price-figure strong { font-family: var(--font-brand); font-size: var(--text-section); color: var(--navy); }
.price-own { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: var(--sp-3); }
.price-missing { flex-basis: 100%; font-size: var(--text-caption); color: var(--s600); }
.price-missing ul { margin: 4px 0 0; padding-left: 18px; }
.quote-total { display: flex; align-items: baseline; justify-content: flex-end; gap: var(--sp-4); flex-wrap: wrap; }
.quote-total strong { font-family: var(--font-brand); font-size: var(--text-title); color: var(--navy); }
@media (max-width: 860px) { .price-box, .price-own { grid-template-columns: 1fr; } }
/* service groups: closed rows with an arrow and what's ticked inside (D-099) */
.service-groups { border: 1px solid var(--s200); border-radius: var(--r-input); overflow: hidden; }
.service-group + .service-group { border-top: 1px solid var(--s200); }
.service-group summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: var(--sp-3); min-height: 48px; padding: 0 var(--sp-4); font-weight: 700; color: var(--navy); }
.service-group summary::-webkit-details-marker { display: none; }
.service-group summary:hover { background: var(--hover); }
.service-group .sg-name { flex: none; }
.service-group .sg-picked { flex: 1; min-width: 0; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.service-group .sg-count { flex: none; font-size: var(--text-caption); color: var(--navy); background: var(--s100); border-radius: 999px; padding: 2px 10px; }
.service-group .sg-count:empty { display: none; }
.sg-arrow { flex: none; width: 8px; height: 8px; margin: 0 4px 4px auto; border-right: 2px solid var(--s500); border-bottom: 2px solid var(--s500); transform: rotate(45deg); transition: transform var(--dur-quick) var(--ease); }
details[open] > summary .sg-arrow { transform: rotate(-135deg); margin-bottom: -4px; }
.service-group[open] .sg-picked { visibility: hidden; }
.service-group .choice-grid { padding: 0 var(--sp-4) var(--sp-3); }
.contacts-set > legend { margin-bottom: var(--sp-2); padding: 0; }
.quick-client .contact-line { grid-template-columns: 1fr 1fr 36px; }
.quick-client .contact-line > .icon-btn { grid-column: 3; grid-row: 1 / span 2; align-self: center; }
/* archive: set apart from Save, in a light warning tint (D-100) */
.archive-card { display: flex; align-items: center; gap: var(--sp-4); margin-top: var(--sp-8); background: var(--st-attn-bg); border-color: var(--st-attn-line); }
.archive-card .archive-icon { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--surface); color: var(--st-attn); }
.archive-card .archive-icon svg { width: 22px; height: 22px; }
.archive-card .caption { margin: 2px 0 0; color: var(--s600); }
.party-fields .segmented { display: grid; grid-template-columns: 1fr 1fr; }
/* State and City (and GSTIN for a business) share one row; Address gets the full width below (D-101) */
.place-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp-4); }
.party-fields .segmented span { justify-content: center; width: 100%; }
.client-pick { display: flex; gap: var(--sp-2); align-items: flex-start; }
.client-pick > :first-child { flex: 1; min-width: 0; }
.supply-pick { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--sp-2); }

/* Directory menu heading (D-101); hidden when the menu is collapsed to icons */
.rail .rail-heading { font-size: var(--text-caption); font-weight: 700; color: var(--s500); text-transform: uppercase; letter-spacing: .06em; padding: var(--sp-2) var(--sp-3) 0; }
html[data-rail="collapsed"] .rail .rail-heading { display: none; }

/* Team on phones (D-102): the roles table fits the screen; row labels wrap */
@media (max-width: 760px) {
  .role-table { font-size: var(--text-caption); table-layout: fixed; }
  .role-table th, .role-table td { padding: 8px 2px; }
  .role-table thead th { font-size: 11px; padding: 8px 0; white-space: nowrap; overflow: hidden; }
  .role-table th[scope="row"] { white-space: normal; padding-right: 6px; }
  .role-table thead th:first-child { width: 36%; }
}
.owner-tag { display: inline-block; font-size: var(--text-caption); font-weight: 700; color: var(--navy); background: var(--s100); border-radius: var(--r-pill); padding: 3px 10px; }

/* Team member page (D-104) */
.id-card .section-title { display: flex; align-items: center; gap: 8px; }
.id-card .section-title svg { width: 18px; height: 18px; }
.file-pick { align-self: flex-start; cursor: pointer; }
.id-cover { display: flex; flex-direction: column; gap: var(--sp-3); }
.id-cover canvas { width: 100%; max-width: 720px; height: auto; border: 1px solid var(--s200); border-radius: var(--r-input); touch-action: none; cursor: crosshair; background: var(--paper); }
.static-value { min-height: 44px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--ink); }
/* signature for their agreement (D-106): drawn in ink colour on white, in both themes */
.signature-pad { width: 100%; max-width: 520px; aspect-ratio: 900 / 260; height: auto; background: var(--white); border: 1px dashed var(--s300); border-radius: var(--r-input); touch-action: none; cursor: crosshair; }
.signature-img { max-width: 320px; background: var(--white); border: 1px solid var(--s200); border-radius: var(--r-input); }


/* ------------------------------------------------------------ D-132: quotes */
.show-sm { display: none !important; }
@media (max-width: 860px) { .show-sm { display: inline-flex !important; } }
.quote-actions { gap: 8px; flex-wrap: wrap; }
.quote-table .cell-label { display: none; }
.quote-table .c-due strong { display: block; }
.quote-spec .item-meta, .quote-list .item-meta { white-space: normal; }
.below-floor { color: var(--st-attn) !important; font-weight: 700; display: inline-flex !important; align-items: center; gap: 4px; }
.below-floor svg { width: 14px; height: 14px; flex: none; }
.price-warning { flex-basis: 100%; margin: 0; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-input); background: var(--st-attn-bg); color: var(--st-attn); font-size: var(--text-caption); font-weight: 700; }
.notice-card { display: flex; gap: var(--sp-3); align-items: flex-start; border-color: var(--st-attn-line); background: var(--st-attn-bg); }
.notice-card svg { width: 20px; height: 20px; flex: none; color: var(--st-attn); margin-top: 2px; }
.notice-card p { margin: 0; }
@media (max-width: 760px) {
  .jobs.setup-table.quote-table tbody tr { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "client client" "item item" "due status"; row-gap: 8px; }
  .jobs.setup-table.quote-table tbody td.c-due { grid-area: due; text-align: left; }
  .jobs.setup-table.quote-table tbody td.c-status { grid-area: status; justify-self: start; align-self: start; }
  .quote-table .cell-label { display: block; font-size: var(--text-caption); color: var(--s500); }
  .jobs.setup-table.quote-list tbody tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "client due" "item item" "status status"; row-gap: 4px; }
  .jobs.setup-table.quote-list tbody td.c-due { grid-area: due; text-align: right; }
  .jobs.setup-table.quote-list tbody td.c-status { grid-area: status; justify-self: start; }
  .quote-list .status { width: auto; }
}
.line-total { font-size: var(--text-caption); font-weight: 700; color: var(--navy); min-height: 1.4em; }
.price-box-check { grid-template-columns: 1fr; }
.check-total { font-weight: 700; color: var(--navy); }
.line-margin { font-size: var(--text-caption); color: var(--st-done, var(--s600)); font-weight: 700; }
.line-margin:empty, .line-total:empty { display: none; }
.line-margin.low { color: var(--st-attn); }
.plan-head { margin-top: 6px; font-weight: 700; }
/* D-138: the rate card in Price check */
.card-pick { margin-right: 6px; }
.pill-own { display: inline-block; margin-left: 6px; padding: 0 8px; border-radius: var(--r-pill); background: var(--blue-50); color: var(--blue); font-size: var(--text-caption); font-weight: 700; }
.card-actions { gap: 8px; flex-wrap: wrap; align-items: center; position: sticky; bottom: 0; background: var(--surface); padding: var(--sp-2) 0; }
.sign-preview { padding: var(--sp-3); border: 1px dashed var(--s300, var(--s200)); border-radius: var(--r-input); background: var(--white); width: fit-content; max-width: 100%; }
.sign-preview img { display: block; max-height: 120px; max-width: 100%; }
.card-table { width: 100%; border-collapse: collapse; }
.card-table th { font-size: var(--text-caption); color: var(--s600); text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--s200); white-space: nowrap; }
.card-table td { padding: 8px; border-bottom: 1px solid var(--s100); vertical-align: top; font-weight: 700; }
.card-table td .caption { display: block; font-weight: 400; }
.card-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.card-table tbody tr:last-child td { border-bottom: 0; }
.rate-card .cost-body { overflow-x: auto; }
.link-btn { padding: 0; border: 0; background: none; font: inherit; font-weight: 700; color: var(--blue); cursor: pointer; text-align: left; }
.link-btn:hover { text-decoration: underline; }
/* D-140: invoicing */
.money-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-4); }
.money-card { display: flex; flex-direction: column; gap: 2px; padding: var(--sp-3) var(--sp-4); }
.money-card strong { font-family: var(--font-brand); font-size: var(--text-section); color: var(--navy); }
.chips-sub { margin-top: calc(-1 * var(--sp-1)); }
.kv-list { display: grid; gap: var(--sp-2); margin: 0; }
.kv-list > div { display: grid; grid-template-columns: 140px 1fr; gap: var(--sp-3); }
.kv-list dt { color: var(--s600); }
.kv-list dd { margin: 0; }
.inv-lines { gap: var(--sp-3); }
.inv-line { display: grid; grid-template-columns: minmax(0, 3fr) 86px 76px 70px 96px 96px minmax(90px, 1fr) 32px; gap: var(--sp-2); align-items: start; padding-bottom: var(--sp-3); border-bottom: 1px solid var(--s100); }
.inv-line .field { gap: 2px; }
.inv-title { display: grid; gap: 4px; }
.inv-amount { text-align: right; padding-top: 18px; }
.inv-remove { margin-top: 20px; }
.inv-line .field > label.caption { font-weight: 700; }
.inv-title .sr-only + .input { margin-top: 18px; }
.inv-totals { display: grid; gap: 4px; justify-self: end; min-width: 260px; margin-left: auto; }
.inv-totals > div { display: flex; justify-content: space-between; gap: var(--sp-4); }
.inv-grand { font-size: var(--text-section); border-top: 1px solid var(--s200); padding-top: 4px; }
@media (max-width: 860px) {
  .inv-line { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .inv-title { grid-column: 1 / -1; }
  .inv-title .sr-only + .input { margin-top: 0; }
  .inv-line [data-inv-gst] { min-width: 90px; }
  .inv-line .field:has([data-inv-gst]) { grid-column: span 2; }
  .inv-amount { grid-column: 1 / 4; text-align: left; padding-top: 0; }
  .inv-remove { margin-top: 0; justify-self: end; }
  .inv-totals { min-width: 0; width: 100%; }
}
.dues-card { display: flex; flex-wrap: wrap; gap: var(--sp-3) var(--sp-6); align-items: center; }
.dues-card > div:not(.dues-actions) { display: flex; flex-direction: column; }
.dues-card strong { font-family: var(--font-brand); font-size: var(--text-section); color: var(--navy); }
.dues-actions { margin-left: auto; display: flex; gap: 8px; }
.money-table .item-title { white-space: normal; }
.card-inset { padding: var(--sp-3) var(--sp-4); border: 1px solid var(--s200); border-radius: var(--r-input); }

/* Invoice list (D-145): payment type, and edit / view / cancel / delete on each row, as on GoGSTBill */
.inv-list .c-act { width: 1%; white-space: nowrap; text-align: right; }
.inv-actions { display: inline-flex; gap: 2px; }
.pay-badge { display: inline-block; padding: 4px 10px; border: 1px solid transparent; border-radius: 7px; font: 700 var(--text-label)/1.3 var(--font-body, inherit); text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
button.pay-badge { cursor: pointer; }
button.pay-badge:hover { border-color: currentColor; }
.pay-unpaid { background: var(--st-attn-bg); border-color: var(--st-attn-line); color: var(--st-attn); }
.pay-part { background: var(--st-wait-bg); border-color: var(--st-wait-mark); color: var(--st-wait-ink); }
.pay-paid { background: var(--st-done-bg); color: var(--st-done-ink); }
.pay-closed { background: var(--st-closed-bg); color: var(--st-closed); }
.inv-list tr.is-cancelled .item-title, .inv-list tr.is-cancelled .c-due strong { text-decoration: line-through; color: var(--s500); }
@media (max-width: 760px) {
  .jobs.setup-table.inv-list tbody tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "item due" "client client" "foot foot"; row-gap: 6px; }
  .jobs.setup-table.inv-list tbody td.c-item { grid-area: item; }
  .jobs.setup-table.inv-list tbody td.c-client { grid-area: client; }
  .jobs.setup-table.inv-list tbody td.c-due { grid-area: due; text-align: right; }
  .jobs.setup-table.inv-list tbody td.c-status { grid-area: foot; justify-self: start; align-self: center; }
  .jobs.setup-table.inv-list tbody td.c-status { max-width: calc(100% - 4 * 46px); }
  .inv-list .pay-badge { white-space: normal; }
  .jobs.setup-table.inv-list tbody td.c-act { grid-area: foot; justify-self: end; align-self: center; padding-top: 0; width: auto; }
}
.pay-list li { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
/* Outstanding, grouped by client or vendor (D-148) */
.outstanding-total { margin: 0 0 var(--sp-2); color: var(--s600); }
.outstanding-total strong { color: var(--navy); }
.inv-list .group-row td { background: var(--s100); font-weight: 700; height: auto; padding-top: 8px; padding-bottom: 8px; }
.inv-list .group-row td a { color: var(--navy); }
.group-meta { margin-left: var(--sp-3); font-weight: 400; color: var(--s600); }
.group-meta strong { color: var(--navy); }
.jobs tbody.party-group tr.group-row:hover td { background: var(--s100); }
@media (max-width: 760px) {
  .jobs tbody.party-group { display: block; }
  .jobs.setup-table.inv-list tbody tr.group-row { display: block; padding: 8px 12px; background: var(--s100); }
  .jobs.setup-table.inv-list tbody tr.group-row td { display: block; padding: 0; }
  .group-meta { display: block; margin-left: 0; }
  .jobs.setup-table.inv-list tbody.party-group td.c-client { display: none; }
}
/* One Add button with a short menu (D-150) */
.add-menu { position: relative; }
.add-menu > summary { list-style: none; cursor: pointer; }
.add-menu > summary::-webkit-details-marker { display: none; }
.add-menu-list { position: absolute; z-index: 40; top: calc(100% + 6px); right: 0; min-width: 310px; padding: 6px; background: var(--surface); border: 1px solid var(--s200); border-radius: 12px; box-shadow: var(--shadow-float); display: flex; flex-direction: column; }
.add-menu-list a { display: flex; flex-direction: column; gap: 1px; padding: 10px 12px; border-radius: 8px; color: var(--navy); text-decoration: none; }
.add-menu-list a span { font-size: var(--text-caption); color: var(--s600); }
.add-menu-list a:hover, .add-menu-list a:focus-visible { background: var(--hover); }
.add-menu[open] .add-menu-list { animation: menu-in var(--dur-quick) var(--ease); }
@media (max-width: 760px) {
  .page-head:has(.add-menu) { position: relative; }
  .add-menu { position: static; }
  .add-menu-list { left: 0; right: 0; min-width: 0; }
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .add-menu[open] .add-menu-list { animation: none; } }
.choice-list { display: flex; flex-wrap: wrap; gap: 4px var(--sp-4); }
.money-in { color: var(--st-done-ink); }
.money-out { color: var(--st-attn); }
.money-card .item-meta { display: block; }
/* Planned (D-154): starting numbers, six month cards, the list */
.notice-info { border-color: var(--blue-200); background: var(--blue-50); }
.plan-basis-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: var(--sp-3); align-items: start; }
.plan-basis-form .btn { margin-top: 26px; }
.plan-months { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); margin: var(--sp-4) 0 var(--sp-6); }
.plan-month { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-4); }
.plan-month h3 { margin: 0; font-family: var(--font-brand); font-size: var(--text-body); color: var(--navy); }
.plan-month dl { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.plan-month dl > div { display: flex; justify-content: space-between; gap: var(--sp-2); font-variant-numeric: tabular-nums; }
.plan-month dt { color: var(--s600); min-width: 0; }
.plan-month dd { margin: 0; white-space: nowrap; }
.plan-month .plan-item dt, .plan-month .plan-item dd { color: var(--st-attn); }
.plan-month .plan-end { border-top: 1px solid var(--s200); padding-top: 6px; margin-top: 2px; font-weight: 700; }
.plan-month .plan-end dd { color: var(--st-done-ink); }
.plan-month.is-short { border-color: var(--st-attn-line); background: var(--st-attn-bg); }
.plan-month.is-short .plan-end dd { color: var(--st-attn); }
.plan-warn { margin: 0; font-weight: 700; color: var(--st-attn); font-size: var(--text-caption); }
.plan-month .caption { margin: 0; }
@media (max-width: 1000px) { .plan-months { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .plan-months { grid-template-columns: 1fr; }
  .plan-basis-form { grid-template-columns: 1fr; }
  .plan-basis-form .btn { margin-top: 0; justify-self: start; }
}
.field-wide { grid-column: 1 / -1; }
