/* Marcom — one style system. See DESIGN.md.
   Quiet white cards on a soft grey page; one blue for actions; green = profit, red = a real problem.
   Each item keeps its own colour (set per item in JS as --ic).
   Every size, weight, space, radius, height, layer and time below comes from the scale in :root; take a value from
   there instead of typing a new one into a rule. */

/* The serif for figures and titles (Source Serif 4, variable weight, self-hosted; SIL Open Font License in /fonts). */
@font-face {
  font-family: 'Ledger';
  font-style: normal;
  font-display: swap;
  font-weight: 200 900;
  src: url(/fonts/source-serif-4-latin-wght-normal.woff2) format('woff2');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC,
    U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Ledger';
  font-style: normal;
  font-display: swap;
  font-weight: 200 900;
  src: url(/fonts/source-serif-4-latin-ext-wght-normal.woff2) format('woff2');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light;
  /* ----- colour: light. Dark is written once, below ----- */
  --bg: #fbfbfd;
  --surface: #ffffff;
  --surface-2: #f6f6f9;
  --surface-3: #ffffff;
  --chip-bg: #efeff3;
  --line: #e2e2e8;
  --line-soft: #eeeef2;
  --line-strong: #cfcfd8;
  --text: #1d1d1f;
  --text-2: #3a3a3f;
  --muted: #5f5f66;
  --accent: #0066cc; /* fills and lines; white text on it is 5.6:1 */
  --accent-text: #0066cc; /* blue used as text: 4.9:1 on its own tint */
  --accent-ink: #ffffff;
  --accent-soft: #e8f1fd;
  --gp-pos: #16752f;
  --pos-soft: #e3f6e6;
  --danger: #d70015; /* fills and lines */
  --danger-text: #d70015; /* red used as text */
  --danger-soft: #fdeceb;
  --warn: #9a5b00;
  --warn-soft: #fdf1da;
  --warn-line: #f5a623;
  --fill-pos: #2fb457;
  --fill-neg: #ff3b30;
  --on-fill: #ffffff;
  /* sticky-note yellow: project notes, the shared budget row, the Shared pill */
  --note: #ffd60a;
  --note-ink: #7a5200;
  --note-edge: #d6a900;
  /* a bar that is only a size: spend by supplier */
  --fill-neutral: #8a8a93;
  /* ranks 1 to 3 in the Report */
  --rk1: #fde68a;
  --rk1-ink: #7a5200;
  --rk2: #e5e7eb;
  --rk2-ink: #4b5563;
  --rk3: #fed7aa;
  --rk3-ink: #9a3412;
  --glass: rgba(255, 255, 255, 0.14);
  --glass-strong: rgba(255, 255, 255, 0.24);
  --toast-btn: rgba(255, 255, 255, 0.2);
  --backdrop: rgba(20, 20, 28, 0.46);
  --bar-bg: rgba(244, 244, 247, 0.82);
  --shadow: 0 8px 28px rgba(20, 20, 35, 0.08);
  --shadow-sm: 0 1px 2px rgba(20, 20, 35, 0.05), 0 2px 8px rgba(20, 20, 35, 0.04);
  --shadow-xs: 0 1px 3px rgba(0, 0, 0, 0.12);
  --shadow-fab: 0 8px 22px color-mix(in srgb, var(--accent) 42%, transparent), 0 2px 6px rgba(0, 0, 0, 0.2);
  --shadow-pop: 0 18px 50px rgba(20, 20, 35, 0.2), 0 2px 8px rgba(20, 20, 35, 0.08);
  --font:
    -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    sans-serif;
  --font-fig: 'Ledger', Georgia, 'Times New Roman', serif; /* figures and titles */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);

  /* ----- the scale: sizes, weights, space, corners, heights, layers and time are taken from here ----- */
  --t-xs: 11px;
  --t-sm: 12px;
  --t-md: 13px;
  --t-base: 14px;
  --t-lg: 17px;
  --t-xl: 22px;
  --t-2xl: 28px;
  --t-fig-sm: clamp(20px, 2.2vw, 26px); /* tile figures in the Report */
  --t-fig-xl: clamp(40px, 6.5vw, 80px); /* the Report's one big figure */
  --lh-fig: 1.1;
  --lh-head: 1.25;
  --lh-body: 1.45;
  --w-regular: 400;
  --w-semi: 600;
  --w-bold: 700;
  --w-heavy: 800;
  --tr-tight: -0.03em;
  --tr-snug: -0.015em;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --r-xs: 4px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-pill: 999px;
  --ctl-sm: 32px;
  --ctl-md: 40px;
  --ctl-lg: 48px;
  --chip-h: 22px; /* every status chip */
  --ic-sm: 16px;
  --ic-md: 20px;
  --ic-lg: 24px;
  --z-sticky: 10;
  --z-raised: 20;
  --z-bar: 40;
  --z-modal: 300;
  --z-menu: 400;
  --z-dialog: 500;
  --z-tip: 550;
  --z-toast: 600;
  --dur-fast: 0.15s;
  --dur: 0.25s;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}
/* Dark is only the colours that change. It is for screens only, so a printout is always on white paper. */
@media screen {
  :root[data-theme='dark'] {
    color-scheme: dark;
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #242427;
    --surface-3: #2c2c2f;
    --chip-bg: #2c2c2f;
    --line: #38383b;
    --line-soft: #2c2c2f;
    --line-strong: #4a4a4e;
    --text: #f5f5f7;
    --text-2: #d8d8dc;
    --muted: #b4b4ba;
    --accent: #0b6bf5; /* a deeper blue under white text (4.7:1) */
    --accent-text: #5aa9ff; /* a lighter blue for text on dark */
    --accent-soft: rgba(10, 132, 255, 0.2);
    --gp-pos: #34d058;
    --pos-soft: rgba(48, 209, 88, 0.16);
    --danger: #d63a31;
    --danger-text: #ff6259;
    --danger-soft: rgba(255, 81, 72, 0.18);
    --warn: #ffc44d;
    --warn-soft: rgba(255, 196, 77, 0.14);
    --fill-pos: #30d158;
    --fill-neg: #ff453a;
    --note-ink: #ffd60a;
    --toast-btn: rgba(0, 0, 0, 0.12);
    --backdrop: rgba(0, 0, 0, 0.62);
    --bar-bg: rgba(0, 0, 0, 0.72);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-pop: 0 20px 60px rgba(0, 0, 0, 0.7), 0 2px 8px rgba(0, 0, 0, 0.5);
  }
}

* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html,
body {
  margin: 0;
}
body {
  font-family: var(--font);
  font-size: var(--t-base);
  line-height: var(--lh-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
body.modal-open {
  overflow: hidden;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
a {
  color: var(--accent-text);
}
h1,
h2,
h3,
h4 {
  margin: 0;
}
.hidden {
  display: none !important;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.gp-pos {
  color: var(--gp-pos);
}
.gp-neg {
  color: var(--danger-text);
}
.muted {
  color: var(--muted);
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
::selection {
  background: var(--accent-soft);
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* motion (used by the spinners, windows, dialogs, menus, toasts and loading placeholders) */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes fadeIn {
  from {
    opacity: 0.5;
    transform: translateY(-3px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes fadeOnly {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes sheetUp {
  from {
    transform: translateY(40px);
    opacity: 0.6;
  }
  to {
    transform: none;
    opacity: 1;
  }
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* icons */
.ic {
  width: var(--ic-md);
  height: var(--ic-md);
  flex: 0 0 auto;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -4px;
}
.ic.sm {
  width: var(--ic-sm);
  height: var(--ic-sm);
}
[data-ic] {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}

/* currency tag */

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: var(--ctl-md);
  padding: 0 var(--sp-4);
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: var(--w-semi);
  font-size: var(--t-base);
  white-space: nowrap;
  transition:
    background var(--dur-fast),
    border-color var(--dur-fast),
    box-shadow var(--dur-fast),
    filter var(--dur-fast),
    transform var(--dur-fast);
}
.btn:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
}
.btn:active {
  transform: scale(0.98);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn.primary:hover {
  filter: brightness(1.07);
  background: var(--accent);
}
.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--on-fill);
}
.btn.danger:hover {
  filter: brightness(1.06);
  background: var(--danger);
}
.btn.danger-ghost {
  color: var(--danger-text);
  background: transparent;
  border-color: transparent;
  padding: 0 var(--sp-2);
}
.btn.danger-ghost:hover {
  background: var(--danger-soft);
}
.btn.sm {
  height: var(--ctl-sm);
  padding: 0 var(--sp-3);
  font-size: var(--t-md);
}
.btn.lg {
  height: var(--ctl-lg);
  font-size: var(--t-base);
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}
.icon-btn {
  width: var(--ctl-md);
  height: var(--ctl-md);
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  display: inline-grid;
  place-items: center;
  padding: 0;
  transition: background var(--dur-fast);
}
.icon-btn:hover {
  background: var(--surface-2);
}
.icon-btn .ic {
  vertical-align: 0;
}

/* fields */
.input,
.cst-field input,
.cst-field select {
  width: 100%;
  height: var(--ctl-md);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 0 var(--sp-3);
  min-width: 0;
  transition:
    border-color var(--dur-fast),
    box-shadow var(--dur-fast);
}
.input:focus,
.cst-field input:focus,
.cst-field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder,
textarea::placeholder {
  color: var(--muted);
}
select {
  color: var(--text);
}
input[type='checkbox'],
input[type='radio'] {
  accent-color: var(--accent);
}
kbd {
  font-family: var(--font);
  font-size: var(--t-xs);
  font-weight: var(--w-semi);
  color: var(--muted);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: var(--r-xs);
  padding: 1px var(--sp-2);
  background: var(--surface);
}

/* full screens: boot, sign in, no access */
.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6);
  background: var(--bg);
}
.boot {
  text-align: center;
}
.boot-msg {
  margin-top: var(--sp-3);
  color: var(--muted);
  font-size: var(--t-md);
  max-width: 260px;
}
.spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
.login-card {
  width: min(400px, 100%);
  display: grid;
  gap: var(--sp-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-7) var(--sp-7) var(--sp-6);
  box-shadow: var(--shadow);
}
.login-card h1 {
  font-size: var(--t-2xl);
  margin: var(--sp-2) 0 0;
  text-align: center;
}
.login-card p {
  color: var(--muted);
  margin: 0 0 var(--sp-2);
  text-align: center;
  line-height: var(--lh-body);
}
.login-card p b {
  color: var(--text);
  overflow-wrap: anywhere;
}
.login-mark {
  width: 64px;
  height: 64px;
  border-radius: var(--r-md);
  justify-self: center;
  box-shadow: var(--shadow-sm);
}
.login-card .btn {
  width: 100%;
}
.login-card .err {
  min-height: 18px;
  color: var(--danger-text);
  font-size: var(--t-md);
  text-align: center;
}
.login-link {
  justify-self: center;
  background: none;
  border: 0;
  padding: var(--sp-1) var(--sp-2);
  font: inherit;
  font-size: var(--t-md);
  color: var(--accent-text);
  cursor: pointer;
  border-radius: var(--r-xs);
}
.login-link:hover {
  text-decoration: underline;
}
.login-link:disabled {
  color: var(--muted);
  cursor: default;
  text-decoration: none;
}
.login-card .ok {
  min-height: 0;
  color: var(--muted);
  font-size: var(--t-md);
  text-align: center;
  line-height: var(--lh-body);
}
.login-foot {
  margin-top: var(--sp-2);
  text-align: center;
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  color: var(--muted);
}

/* ---------- app shell ---------- */
.app {
  min-height: 100vh;
  min-height: 100dvh;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-bar);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: calc(var(--sp-2) + var(--sat)) max(var(--sp-5), calc((100vw - 1280px) / 2)) var(--sp-2);
  background: var(--bar-bg);
  backdrop-filter: saturate(1.6) blur(18px);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  border-bottom: 1px solid var(--line-soft);
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex: none;
}
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
}
.brand-name {
  font-size: var(--t-lg);
}
.tabs {
  display: inline-flex;
  border-radius: var(--r-md);
}
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  border: 0;
  color: var(--muted);
  font-weight: var(--w-semi);
  font-size: var(--t-base);
  transition:
    background var(--dur-fast),
    color var(--dur-fast);
  height: var(--ctl-md);
  padding: 0 var(--sp-1);
  border-radius: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  box-shadow: none;
}
.tab .ic {
  display: none;
}
.tab:hover {
  color: var(--text);
}
.tab.on {
  border-bottom-color: var(--text);
  color: var(--text);
}
.badge {
  display: inline-grid;
  place-items: center;
  min-width: var(--chip-h);
  height: var(--chip-h);
  padding: 0 var(--sp-2);
  border-radius: var(--r-pill);
  background: var(--accent);
  color: var(--on-fill);
  font-size: var(--t-sm);
  font-weight: var(--w-bold);
  font-style: normal;
  line-height: 1;
}
.top-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* "Offline" pill in the top bar */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--t-sm);
  font-weight: var(--w-bold);
  padding: 0 var(--sp-3);
  border-radius: var(--r-pill);
  white-space: nowrap;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);

  height: var(--chip-h);
}
.pill::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.pill.off {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: transparent;
}

.content {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--sp-5) var(--sp-5) 60px;
}
.section-panel {
  display: none;
}
.section-panel.open {
  display: block;
  animation: fadeIn var(--dur-fast) var(--ease);
}

/* search + filters */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin: 0 0 var(--sp-3);
}
.search {
  position: relative;
  display: block;
  flex: 1 1 300px;
  min-width: 0;
}
.search > [data-ic] {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search input {
  width: 100%;
  height: var(--ctl-md);
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-pill);
  padding: 0 44px 0 40px;
  font-size: var(--t-base);
  transition:
    border-color var(--dur-fast),
    box-shadow var(--dur-fast);
  -webkit-appearance: none;
  appearance: none;
}
.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}
.search-kbd {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}
.search input:focus ~ .search-kbd,
.search input:not(:placeholder-shown) ~ .search-kbd {
  display: none;
}
@media (hover: none) {
  .search-kbd {
    display: none;
  }
}
.filter-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}
.filter-group {
  display: flex;
  min-width: 0;
  flex: none;
}
.filter-group select {
  height: var(--ctl-md);
  width: auto;
  min-width: 112px;
  max-width: 210px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-pill);
  padding: 0 var(--sp-7) 0 var(--sp-3);
  font-size: var(--t-base);
  font-weight: var(--w-semi);
  text-overflow: ellipsis;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M1 1l4 4 4-4' stroke='%238a8a92' stroke-width='1.6' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
.filter-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.filter-bar.active .filter-group select:not([value='']) {
  border-color: var(--accent);
}
.filter-clear {
  border: 0;
  background: none;
  color: var(--accent-text);
  font-weight: var(--w-bold);
  font-size: var(--t-base);
  padding: 0 var(--sp-2);

  height: var(--ctl-sm);
}
.filter-clear:disabled {
  display: none;
}

/* list summary strip */
.list-summary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-5);
  margin: 0 2px var(--sp-3);
  font-size: var(--t-md);
  color: var(--muted);
}
.list-summary:empty {
  display: none;
}
.list-summary b {
  color: var(--text);
  font-weight: var(--w-bold);
}
.list-summary .gp-pos b {
  color: var(--gp-pos);
}
.list-summary .gp-neg b {
  color: var(--danger-text);
}
.list-summary .cur-note {
  margin-left: auto;
  color: var(--muted);
}
.list-summary .sum-note {
  color: var(--muted);
}
/* Export ▾ - sits at the end of the summary line */
.xl-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: var(--ctl-sm);
  margin: -6px 0 -6px var(--sp-1);
  padding: 0 var(--sp-2) 0 var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--t-base);
  font-weight: var(--w-semi);
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition:
    border-color var(--dur-fast),
    background var(--dur-fast),
    box-shadow var(--dur-fast);
}
.xl-btn > .ic {
  width: var(--ic-md);
  height: var(--ic-md);
  color: var(--accent-text);
  vertical-align: 0;
}
.xl-btn > .ic.sm {
  width: var(--ic-sm);
  height: var(--ic-sm);
  color: var(--muted);
  margin: 0 var(--sp-1) 0 -2px;
  stroke-width: 2.2;
}
.xl-btn b {
  min-width: 24px;
  height: 22px;
  padding: 0 var(--sp-2);
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: var(--t-sm);
  font-weight: var(--w-bold);
  display: inline-grid;
  place-items: center;
  font-variant-numeric: tabular-nums;
  transition:
    background var(--dur-fast),
    color var(--dur-fast);
}
.xl-btn:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: var(--shadow);
}
.xl-btn:hover b {
  background: var(--accent);
  color: var(--on-fill);
}
.xl-btn[aria-haspopup] b {
  margin-right: 1px;
}
.xl-btn.is-busy {
  padding-right: var(--sp-3);
  color: var(--muted);
}
/* any button that is busy (Export, Excel): a small spinner in front of "Preparing…" */
.busy-spin {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
  opacity: 0.75;
  flex: none;
}

/* empty states, skeletons, "show more" */
.empty {
  padding: 56px var(--sp-5);
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
}
.empty-ic {
  width: 52px;
  height: 52px;
  border-radius: var(--r-md);
  margin: 0 auto var(--sp-3);
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-text);
}
.empty-ic .ic {
  width: var(--ic-lg);
  height: var(--ic-lg);
  vertical-align: 0;
}
.empty h3 {
  font-size: var(--t-lg);
  color: var(--text);
  margin: 0 0 var(--sp-1);
}
.empty p {
  margin: 0 auto var(--sp-4);
  max-width: 380px;
  line-height: var(--lh-body);
}
.skel {
  padding: var(--sp-5);
  display: grid;
  gap: var(--sp-2);
}
.skel-line {
  height: 14px;
  border-radius: var(--r-xs);
  background: linear-gradient(90deg, var(--chip-bg) 25%, var(--surface-2) 50%, var(--chip-bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
.skel-line.w40 {
  width: 40%;
}
.skel-line.w25 {
  width: 25%;
}
.more-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
  margin: var(--sp-2) 0 0;
  padding: var(--sp-3);
  border: 1px dashed var(--line-strong);
  background: transparent;
  border-radius: var(--r-md);
  color: var(--accent-text);
  font-weight: var(--w-bold);
  font-size: var(--t-base);

  min-height: var(--ctl-md);
}
.more-btn span {
  font-size: var(--t-sm);
  font-weight: var(--w-regular);
  color: var(--muted);
}
.more-btn:hover {
  background: var(--accent-soft);
}

/* phone bottom bar + add button */
.tabbar,
.fab {
  display: none;
}

/* ---------- pop-up menu ---------- */
.menu {
  position: fixed;
  z-index: var(--z-menu);
  min-width: 250px;
  max-width: calc(100vw - 16px);
  max-height: min(70vh, 460px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  padding: var(--sp-2);
  animation: pop var(--dur-fast) var(--ease);
}
.menu button {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: var(--sp-2) var(--sp-2);
  border-radius: var(--r-sm);
  font-size: var(--t-base);
  color: var(--text);

  min-height: var(--ctl-md);
}
.menu button:hover,
.menu button:focus-visible {
  background: var(--surface-2);
  outline: none;
}
.menu button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.menu button > span {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.menu button small {
  font-size: var(--t-sm);
  color: var(--muted);
  margin-top: 1px;
}
.menu button .ic {
  color: var(--muted);
}
.menu hr {
  border: 0;
  border-top: 1px solid var(--line-soft);
  margin: var(--sp-1) var(--sp-1);
}
.menu-h {
  padding: var(--sp-2) var(--sp-2) var(--sp-1);
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  color: var(--muted);
}
.menu kbd {
  margin-left: auto;
}

/* ---------- toasts ---------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(22px + var(--sab));
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: 94vw;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  background: var(--text);
  color: var(--bg);
  padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  font-size: var(--t-base);
  font-weight: var(--w-semi);
  box-shadow: var(--shadow-pop);
  max-width: min(560px, 94vw);
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity var(--dur),
    transform var(--dur);
}
.toast.show {
  opacity: 1;
  transform: none;
}
.toast.error {
  background: var(--danger);
  color: var(--on-fill);
}
.toast button {
  border: 0;
  background: var(--toast-btn);
  color: inherit;
  font-weight: var(--w-bold);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  flex: none;
}
.toast.error button {
  background: var(--glass-strong);
}

/* ---------- dialogs (replace the browser's confirm / prompt) ---------- */
.dlg-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-dialog);
  background: var(--backdrop);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
  animation: fadeOnly var(--dur-fast) var(--ease);
}
.dlg {
  width: min(430px, 100%);
  max-height: min(86vh, 100%);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  animation: pop var(--dur-fast) var(--ease);
}
.dlg.wide {
  width: min(660px, 100%);
}
.dlg-h {
  padding: var(--sp-5) var(--sp-6) var(--sp-1);
}
.dlg-h h3 {
  font-size: var(--t-lg);
}
.dlg-b {
  padding: var(--sp-2) var(--sp-6) var(--sp-2);
  overflow: auto;
  color: var(--text-2);
}
.dlg-b .msg {
  margin: var(--sp-2) 0 var(--sp-1);
  line-height: var(--lh-body);
  white-space: pre-line;
}
.dlg-b .field {
  margin-top: var(--sp-3);
}
.dlg-b .field label {
  display: block;
  font-size: var(--t-sm);
  font-weight: var(--w-bold);
  color: var(--muted);
  margin-bottom: var(--sp-1);
}
.dlg-f {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-6) var(--sp-5);
}
@media (max-width: 600px) {
  .dlg-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .dlg,
  .dlg.wide {
    width: 100%;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    max-height: 90dvh;
    border-bottom: 0;
    animation: sheetUp var(--dur) var(--ease);
  }
  .dlg-f {
    padding: var(--sp-3) var(--sp-4) calc(var(--sp-4) + var(--sab));
    flex-direction: column-reverse;
  }
  .dlg-f .btn {
    width: 100%;
    height: 46px;
  }
  .dlg-h {
    padding: var(--sp-5) var(--sp-5) var(--sp-1);
  }
  .dlg-b {
    padding: var(--sp-2) var(--sp-5);
  }
}

/* Trash, "Check my data", how-to, shortcuts */
.tr-list {
  display: grid;
  gap: var(--sp-3);
  min-height: 60px;
}
.tr-group h4,
.hc-h {
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  color: var(--muted);
  margin: var(--sp-2) 0 var(--sp-2);
}
.tr-group h4 small {
  font-weight: var(--w-semi);
  margin-left: var(--sp-1);
}
.tr-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
  border-top: 1px solid var(--line-soft);
}
.tr-name {
  flex: 1;
  min-width: 0;
}
.tr-name b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.tr-name small {
  color: var(--muted);
  font-size: var(--t-sm);
}
.tr-empty {
  text-align: center;
  color: var(--muted);
  padding: var(--sp-6) var(--sp-2);
}
.tr-empty .ic {
  width: var(--ic-lg);
  height: var(--ic-lg);
  color: var(--muted);
  margin-bottom: var(--sp-2);
}
.tr-empty p {
  margin: 0;
  line-height: var(--lh-body);
}
.tr-empty b {
  color: var(--text);
}
.hc-ok {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--pos-soft);
  color: var(--gp-pos);
}
.hc-ok .ic {
  width: var(--ic-lg);
  height: var(--ic-lg);
}
.hc-ok b {
  display: block;
  color: var(--text);
}
.hc-ok small {
  color: var(--text-2);
  font-size: var(--t-md);
}
.hc-sum {
  margin: var(--sp-1) 0 var(--sp-2);
  color: var(--muted);
}
.hc-sum b {
  color: var(--text);
}
.hc-row {
  display: flex;
  gap: var(--sp-2);
  align-items: flex-start;
  padding: var(--sp-2) 0;
  border-top: 1px solid var(--line-soft);
}
.hc-row > div {
  flex: 1;
  min-width: 0;
}
.hc-row b {
  display: block;
  color: var(--text);
  overflow-wrap: anywhere;
}
.hc-row small {
  display: block;
  color: var(--muted);
  font-size: var(--t-sm);
  line-height: var(--lh-body);
}
.hc-ic {
  flex: none;
  margin-top: 1px;
}
.hc-row.warn .hc-ic {
  color: var(--warn);
}
.hc-row.info .hc-ic {
  color: var(--accent-text);
}
.hc-more {
  color: var(--muted);
  font-size: var(--t-sm);
  padding: var(--sp-2) 0;
}
.keys {
  display: grid;
  gap: 2px;
}
.kb {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) 2px;
  border-top: 1px solid var(--line-soft);
  color: var(--text-2);
}
.kb:first-child {
  border-top: 0;
}
.kb kbd + kbd {
  margin-left: var(--sp-1);
}

/* chart tooltip */
.chart-tip {
  position: fixed;
  pointer-events: none;
  background: var(--text);
  color: var(--bg);
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-pop);
  z-index: var(--z-tip);
  transform: translate(-50%, calc(-100% - 12px));
  line-height: var(--lh-body);
  white-space: nowrap;
}
.chart-tip b {
  display: block;
  font-size: var(--t-base);
  margin-bottom: 2px;
  font-weight: var(--w-heavy);
}

/* ---------- project rows ---------- */
.project-wrap {
  position: relative;
  transition:
    box-shadow var(--dur-fast),
    border-color var(--dur-fast);
  content-visibility: auto;
  contain-intrinsic-size: auto 68px;
}
.project-wrap.expanded {
  box-shadow: none;
  content-visibility: visible;
}
.project-wrap.skel {
  content-visibility: visible;
}
.project-wrap.flash {
  animation: projFlash 1.8s ease-out;
}
@keyframes projFlash {
  0%,
  30% {
    box-shadow:
      0 0 0 3px var(--accent),
      var(--shadow);
  }
  100% {
    box-shadow:
      0 0 0 3px transparent,
      var(--shadow);
  }
}
/* a thin edge says "running now" (green) or "starts within a week" (blue); everything else stays quiet */
.project-wrap::before {
  content: '';
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 0 var(--r-xs) var(--r-xs) 0;
  background: transparent;
}
.project-wrap[data-st='now']::before {
  background: var(--gp-pos);
}
.project-wrap[data-st='soon']::before {
  background: var(--accent);
}
.proj-head {
  display: grid;
  grid-template-columns: 22px minmax(170px, 1.1fr) minmax(150px, 1fr) minmax(104px, 1fr) auto auto;
  align-items: center;
  gap: var(--sp-2) var(--sp-5);
  padding: var(--sp-3) var(--sp-4) var(--sp-3) var(--sp-3);
}
/* the only thing that opens a project: wider than it looks, so it is easy to hit */
.chevron {
  display: grid;
  place-items: center;
  width: var(--ctl-md);
  height: var(--ctl-md);
  margin: -9px;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition:
    transform var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease);
}
.chevron:hover {
  background: var(--chip-bg);
  color: var(--accent-text);
}
.chevron:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.chevron .ic {
  width: var(--ic-sm);
  height: var(--ic-sm);
  vertical-align: 0;
  stroke-width: 2.2;
}
.project-wrap.expanded .chevron {
  transform: rotate(90deg);
  color: var(--accent-text);
}
.proj-title-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 0;
}
.proj-name-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.proj-name {
  font-size: var(--t-lg);
  overflow-wrap: anywhere;
  line-height: var(--lh-head);
}
.proj-tag {
  background: var(--pos-soft);
  color: var(--gp-pos);
  font-weight: var(--w-bold);
  font-size: var(--t-sm);
  padding: 0 var(--sp-2);
  border-radius: var(--r-pill);
  white-space: nowrap;

  display: inline-flex;

  align-items: center;

  height: var(--chip-h);

  line-height: 1;
}
.proj-dates {
  color: var(--muted);
  font-size: var(--t-md);
}
.on-now {
  color: var(--gp-pos);
  font-weight: var(--w-bold);
}
/* what the project is made of: one strip in the item colours (like colour-coded tape on a flight case) */
.proj-mix {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.mix-bar {
  display: flex;
  gap: 2px;
  height: 7px;
  border-radius: var(--r-xs);
  overflow: hidden;
}
.mix-bar i {
  display: block;
  min-width: 5px;
  border-radius: var(--r-xs);
}
.mix-leg {
  display: flex;
  align-items: center;
  gap: 0 var(--sp-3);
  overflow: hidden;
  font-size: var(--t-sm);
  color: var(--muted);
  white-space: nowrap;
}
.mix-leg span {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  flex: none;
}
.mix-leg u {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  text-decoration: none;
}
.mix-leg .more {
  color: var(--muted);
}
.proj-mix.is-empty .mix-leg {
  color: var(--muted);
}
/* the numbers: budget and cost are plain, only GP carries colour */
.proj-head-stats {
  display: flex;
  gap: var(--sp-5);
  flex: none;
}
.stat {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat span {
  display: block;
  font-size: var(--t-sm);
  font-weight: var(--w-regular);
  color: var(--muted);
  line-height: var(--lh-head);
}
.stat b {
  display: block;
  font-size: var(--t-base);
  margin-top: 1px;
}
.stat-b,
.stat-c {
  width: 96px;
}
.stat-gp {
  width: 132px;
}
.stat-gp.gp-pos {
  color: var(--gp-pos);
}
.stat-gp.gp-neg {
  color: var(--danger-text);
}
.stat-gp.gp-low {
  color: var(--warn);
}
.stat-gp.gp-pos span,
.stat-gp.gp-neg span,
.stat-gp.gp-low span {
  color: inherit;
}
.stat-gp.gp-none {
  background: none;
}
.stat-gp.gp-none b {
  font-size: var(--t-md);
  font-weight: var(--w-semi);
  color: var(--muted);
}

/* month headings in a date-ordered list */
.grp-head {
  display: grid;
  align-items: end;
  flex-wrap: wrap;
  gap: 2px var(--sp-3);
  font-size: var(--t-md);
  color: var(--muted);

  grid-template-columns: minmax(0, 1fr) 96px 96px 132px;

  column-gap: var(--sp-5);

  row-gap: 2px;

  padding: 0 calc(var(--sp-4) + 1px) 0 var(--sp-3);
}
.grp-name {
  font-size: var(--t-base);
  color: var(--text);
}
.grp-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px var(--sp-3);
  min-width: 0;
}
.grp-fig {
  text-align: right;
  white-space: nowrap;
  font-size: var(--t-sm);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.grp-fig b {
  display: block;
  font-size: var(--t-base);
  font-weight: var(--w-semi);
  color: var(--text);
}
.grp-fig.gp-pos b {
  color: var(--gp-pos);
}
.grp-fig.gp-neg b {
  color: var(--danger-text);
}
@media (min-width: 1101px) {
  .by-month .stat-b span,
  .by-month .stat-c span {
    display: none;
  }
}
.list-summary .sum-gp b {
  font-size: var(--t-lg);
}
/* a short word beside a project's name when it needs a look */
.proj-flag {
  display: inline-flex;
  align-items: center;
  height: var(--chip-h);
  padding: 0 var(--sp-2);
  border-radius: var(--r-pill);
  font-size: var(--t-sm);
  font-weight: var(--w-bold);
  line-height: 1;
  white-space: nowrap;
}
.proj-flag.bad {
  background: var(--danger-soft);
  color: var(--danger-text);
}
.proj-flag.warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.stat-b b,
.stat-c b {
  color: var(--text-2);
  font-weight: var(--w-regular);
}
.stat-gp b {
  font-size: var(--t-lg);
}

.grp-now {
  padding: 0 var(--sp-2);
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: var(--t-sm);
  font-weight: var(--w-bold);
  align-self: center;

  display: inline-flex;

  align-items: center;

  height: var(--chip-h);

  line-height: 1;
} /* notes sit in the row, saved as you type; an empty one is just a small "+ Note" that opens when clicked */
.proj-notes {
  position: relative;
  min-width: 0;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
}
.proj-notes-none {
  display: block;
}
.proj-notes-input {
  display: block;
  width: 100%;
  height: var(--ctl-lg);
  min-height: var(--ctl-lg);
  resize: none;
  overflow: hidden;
  border: 1.5px solid transparent;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--note) 15%, var(--surface-2));
  color: var(--text);
  font-size: var(--t-base);
  line-height: var(--lh-body);
  padding: var(--sp-2) var(--sp-3);
  outline: 0;
  transition:
    background var(--dur-fast),
    border-color var(--dur-fast),
    box-shadow var(--dur-fast);
  cursor: text;
}
.proj-notes-input:hover {
  border-color: var(--line);
}
.proj-notes-input:focus {
  overflow: auto;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.proj-notes-input[readonly] {
  background: color-mix(in srgb, var(--note) 10%, var(--surface-2));
  cursor: default;
  border-color: transparent;
}
.proj-notes-input.is-empty:not(:focus) {
  width: auto;
  height: var(--ctl-sm);
  min-height: var(--ctl-sm);
  padding: var(--sp-1) var(--sp-2);
  text-align: left;
  line-height: 20px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  background: transparent;
  font-size: var(--t-sm);

  min-width: 76px;
}
.proj-notes-input.is-empty:not(:focus)::placeholder {
  color: var(--muted);
  font-weight: var(--w-semi);
  opacity: 1;
}
.proj-notes-input.is-empty:not(:focus):hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.proj-notes-input.is-empty:not(:focus):hover::placeholder {
  color: var(--accent-text);
}
.proj-notes-status {
  position: absolute;
  right: 10px;
  bottom: 4px;
  font-size: var(--t-xs);
  font-weight: var(--w-semi);
  color: var(--muted);
  pointer-events: none;
}

.proj-body {
  display: none;
  padding: 0 var(--sp-5) var(--sp-5);
}
.project-wrap.expanded .proj-body {
  display: block;
}
.proj-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-2) var(--sp-3);
  flex-wrap: wrap;
  margin: 2px 0 var(--sp-3);
}
.proj-attach-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  flex: 1 1 280px;
}
.proj-attach-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-pill);
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--t-sm);
  color: var(--text);
  text-decoration: none;
  max-width: 260px;

  min-height: var(--ctl-sm);
}
.proj-attach-chip:hover {
  background: var(--accent-soft);
}
.proj-attach-chip .ic {
  width: var(--ic-sm);
  height: var(--ic-sm);
  vertical-align: -2px;
  color: var(--muted);
}
.proj-toolbar {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-left: auto;
}
.pbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--r-pill);
  padding: 0 var(--sp-3);
  font-size: var(--t-md);
  font-weight: var(--w-semi);
  white-space: nowrap;
  transition:
    background var(--dur-fast),
    border-color var(--dur-fast),
    color var(--dur-fast);

  height: var(--ctl-sm);
}
.pbtn .ic {
  width: var(--ic-sm);
  height: var(--ic-sm);
  vertical-align: 0;
}
.pbtn:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
}
.pbtn:disabled {
  opacity: 0.55;
  cursor: default;
}
.pbtn-edit {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: transparent;
}
.pbtn-edit:hover {
  background: var(--accent);
  color: var(--on-fill);
  border-color: transparent;
}
.pbtn-del {
  color: var(--danger-text);
}
.pbtn-del:hover {
  background: var(--danger-soft);
  border-color: transparent;
}
.proj-audit {
  margin-top: var(--sp-2);
  font-size: var(--t-sm);
  color: var(--muted);
  text-align: right;
}
.item-pill-empty {
  color: var(--muted);
  font-size: var(--t-base);
  padding: var(--sp-3) var(--sp-1);

  line-height: var(--lh-body);
}
.item-pill-list {
  display: block;
}

/* ---------- the sheet (same structure as the Excel export) ---------- */
.sheet-wrap {
  overflow-x: auto;
  border-radius: var(--r-sm);
  -webkit-overflow-scrolling: touch;
}
.sheet {
  min-width: 620px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
  font-size: var(--t-base);
  background: var(--surface);
}
.sheet-row {
  display: grid;
  grid-template-columns: 44px minmax(150px, 3fr) repeat(3, minmax(90px, 1fr));
}
.sheet.has-led {
  min-width: 740px;
}
.sheet.has-led .sheet-row {
  grid-template-columns: 44px minmax(130px, 2.2fr) 64px 64px 100px repeat(3, minmax(88px, 1fr));
}
.sheet-row > div {
  padding: var(--sp-2) var(--sp-2);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 0;
  overflow-wrap: anywhere;
  border-bottom: 1px solid var(--line-soft);
}
.sheet-row > div + div {
  border-left: 1px solid var(--line-soft);
}
.sheet-row > div.l {
  justify-content: flex-start;
  text-align: left;
}
.sheet-row > div.muted {
  color: var(--muted);
}
.sheet-group {
  display: block;
}
.sheet-group + .sheet-group {
  border-top: 1px solid var(--line);
}
.sheet-bandrow > div {
  background: var(--ic, var(--accent));
  color: var(--on-fill);
  font-weight: var(--w-bold);
  border-color: transparent;
  padding: var(--sp-2) var(--sp-3);
}
.sheet-bandrow > div.bname {
  grid-column: 1/-1;
  justify-content: flex-start;
  text-align: left;
  font-size: var(--t-lg);
  gap: var(--sp-2) var(--sp-3);
  flex-wrap: wrap;
}
.sheet-bandrow .sh-sup {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--glass-strong);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-pill);
  font-size: var(--t-md);
  font-weight: var(--w-bold);
}
.sheet-bandrow .sh-sup small {
  font-size: var(--t-sm);
  opacity: 0.85;
  font-weight: var(--w-semi);
}
.sheet-head > div {
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  padding-top: var(--sp-2);
  padding-bottom: var(--sp-2);
}
.sheet-row .gp {
  font-weight: var(--w-bold);
}
.sheet-group .sheet-row:not(.sheet-bandrow):not(.sheet-head):not(.sheet-sub):not(.sheet-shared) > div:first-child {
  box-shadow: inset 4px 0 0 var(--ic, var(--accent));
}
.sheet-row > div.sq {
  color: var(--ic, var(--accent));
  font-weight: var(--w-bold);
}
.sheet-shared > div {
  background: color-mix(in srgb, var(--note) 14%, var(--surface));
}
.sheet-group .sheet-shared > div:first-child {
  box-shadow: inset 4px 0 0 var(--note-edge);
}
.sheet-row > div.sh-lab {
  justify-content: flex-end;
}
.sh-pill,
.pe-pill {
  display: inline-flex;
  white-space: nowrap;
  font-weight: var(--w-bold);
  font-size: var(--t-sm);
  padding: 0 var(--sp-3);
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--note) 38%, var(--surface));
  color: var(--note-ink);

  align-items: center;

  height: var(--chip-h);

  line-height: 1;
}
.sheet-sub > div {
  background: color-mix(in srgb, var(--ic, var(--accent)) 11%, var(--surface));
  font-weight: var(--w-bold);
}
.sheet-sub > div.lab {
  justify-content: flex-end;
  color: var(--muted);
  font-size: var(--t-sm);
}
.sheet-gtotal > div {
  background: color-mix(in srgb, var(--ic, var(--accent)) 24%, var(--surface));
  font-weight: var(--w-heavy);
  border-top: 2px solid var(--ic, var(--accent));
}
.sheet-gtotal > div.lab {
  justify-content: flex-end;
  font-size: var(--t-md);
}
.sheet-gap {
  height: 12px;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.sheet-total > div {
  font-weight: var(--w-heavy);
  font-size: var(--t-base);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
}
.sheet-total > div.lab {
  justify-content: center;
  font-size: var(--t-md);
}
.sheet-empty {
  padding: var(--sp-3) var(--sp-1);
  color: var(--muted);
  display: block;

  font-size: var(--t-base);

  line-height: var(--lh-body);
}
.sheet-row > div.c-blank {
  padding: 0;
}
.item-pill-quotes {
  padding: var(--sp-2) var(--sp-2);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  border-top: 1px solid var(--line-soft);
}
.item-pill-quote-chip .ic {
  width: var(--ic-sm);
  height: var(--ic-sm);
  color: var(--muted);
}
.item-pill-quote-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-pill);
  padding: var(--sp-1) var(--sp-2);
  font-size: var(--t-sm);
  color: var(--text);
  text-decoration: none;

  min-height: var(--ctl-sm);
}
.item-pill-quote-chip:hover {
  background: var(--accent-soft);
}

/* ---------- documents attached to a project (editor) ---------- */
.attach-section {
  margin: 0 var(--sp-6);
  border-radius: var(--r-md);
  transition:
    background var(--dur-fast),
    outline-color var(--dur-fast);
  outline: 2px dashed transparent;
  outline-offset: -2px;
  background: var(--surface-2);
}
.attach-section.drag-over {
  background: var(--accent-soft);
  outline-color: var(--accent);
}
.attach-label {
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  color: var(--muted);
  margin-bottom: var(--sp-2);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.attach-label .attach-sub {
  font-weight: var(--w-regular);
  color: var(--muted);
  font-size: var(--t-sm);
}
.attach-add-btn {
  background: var(--surface);
  color: var(--accent-text);
  font-weight: var(--w-bold);
  font-size: var(--t-md);
  padding: 0 var(--sp-3);
  border-radius: var(--r-pill);
  border: 1px solid var(--line);

  height: var(--ctl-sm);
}
.attach-add-btn:hover {
  background: var(--accent-soft);
}
.attach-add-btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.attach-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-pill);
  padding: var(--sp-1) var(--sp-2) var(--sp-1) var(--sp-3);
  font-size: var(--t-sm);
  max-width: 260px;

  min-height: var(--ctl-sm);
}
.attach-chip a {
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attach-chip a:hover {
  text-decoration: underline;
}
.attach-chip .mini-btn {
  width: 20px;
  height: 20px;
  min-width: 20px;
  font-size: var(--t-md);
}
.attach-chip-pending {
  color: var(--muted);
}
.attach-chip-error {
  background: var(--danger-soft);
  color: var(--danger-text);
  border-color: transparent;
}
.attach-status-text {
  font-size: var(--t-xs);
  color: var(--muted);
}
.attach-spinner {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  border-top-color: transparent;
  animation: spin 0.7s linear infinite;
  flex: none;
}
.attach-retry {
  color: var(--accent-text);
  font-weight: var(--w-semi);
}
.mini-btn {
  display: inline-grid;
  place-items: center;
  border: 0;
  background: var(--chip-bg);
  color: var(--muted);
  width: var(--ctl-sm);
  height: var(--ctl-sm);
  min-width: var(--ctl-sm);
  border-radius: var(--r-sm);
  font-size: var(--t-lg);
  line-height: 1;
  flex: 0 0 auto;
  padding: 0;
  transition:
    background var(--dur-fast),
    color var(--dur-fast);
}
.mini-btn .ic {
  width: var(--ic-sm);
  height: var(--ic-sm);
  vertical-align: 0;
}
.mini-btn:hover {
  background: var(--danger-soft);
  color: var(--danger-text);
}

/* ---------- big windows (project editor, price, costing sheet) ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 4vh var(--sp-5) var(--sp-5);
  overflow: auto;
  background: var(--backdrop);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal-backdrop.open {
  display: flex;
  animation: fadeOnly var(--dur-fast) var(--ease);
}
.modal-card {
  width: min(1180px, 100%);
  max-height: 92vh;
  max-height: 92dvh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  position: relative;
  animation: pop var(--dur-fast) var(--ease);
}
.modal-card.narrow {
  width: min(480px, 100%);
}
.modal-title {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6);
  background: var(--surface);
  border-bottom: 1px solid var(--line-soft);
  font-size: var(--t-lg);
}
.modal-close {
  border: 0;
  background: var(--chip-bg);
  color: var(--text);
  border-radius: 50%;
  width: var(--ctl-sm);
  height: var(--ctl-sm);
  display: grid;
  place-items: center;
  padding: 0;
  flex: none;
}
.modal-close:hover {
  background: var(--line);
}
.modal-close .ic {
  width: var(--ic-md);
  height: var(--ic-md);
  vertical-align: 0;
}
.editor {
  background: var(--surface);
}
.editor-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-6) var(--sp-5);
}
.editor-warn {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  margin: var(--sp-3) var(--sp-6) 0;
  padding: var(--sp-3) var(--sp-3);
  border-radius: var(--r-md);
  background: var(--warn-soft);
  color: var(--text);
  font-size: var(--t-base);
  line-height: var(--lh-body);
}
.editor-warn .ic {
  color: var(--warn);
  margin-top: 1px;
}

/* project name / tag / dates */
.pe-form {
  display: grid;
  grid-template-columns: minmax(220px, 2.2fr) minmax(130px, 1fr) 170px 170px;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-6) var(--sp-3);
}
.pe-field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
}
.pe-field > span {
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  color: var(--muted);
  padding-left: 2px;
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
}
.pe-date-hint {
  font-style: normal;
  font-weight: var(--w-semi);
  color: var(--accent-text);
  font-size: var(--t-sm);
}
.pe-field input {
  width: 100%;
  height: var(--ctl-lg);
  font-size: var(--t-base);
  font-weight: var(--w-semi);
  color: var(--text);
  padding: 0 var(--sp-3);
  border-radius: var(--r-sm);
  outline: 0;
  border: 1px solid var(--line);
  background: var(--surface-2);
  transition:
    border-color var(--dur-fast),
    box-shadow var(--dur-fast),
    background var(--dur-fast);
  min-width: 0;
}
.pe-field input::placeholder {
  color: var(--muted);
  font-weight: var(--w-regular);
}
.pe-field input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.pe-quick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-6) var(--sp-4);
}
.pe-quick:empty {
  display: none;
}
.pe-quick .ql {
  font-size: var(--t-sm);
  color: var(--muted);
  margin-right: 2px;
}
.qchip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: var(--ctl-sm);
  padding: 0 var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  font-size: var(--t-md);
  font-weight: var(--w-semi);
  color: var(--text);
  cursor: pointer;
  transition:
    border-color var(--dur-fast),
    background var(--dur-fast);
}
.qchip u {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  text-decoration: none;
  background: var(--ic);
}
.qchip:hover {
  border-color: var(--ic);
  background: color-mix(in srgb, var(--ic) 9%, var(--surface));
}
.qchip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.pe-items {
  padding: var(--sp-4) var(--sp-6) var(--sp-5);
  display: flex;
  flex-direction: column;
  overflow-x: auto;
}

/* one card per item */
.item-card {
  --ic: var(--accent);
  min-width: 740px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--ic) 28%, var(--line));
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.item-card.is-led {
  min-width: 800px;
}
.item-band-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
  background: color-mix(in srgb, var(--ic) 13%, var(--surface));
}
.item-dot {
  flex: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--ic);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ic) 24%, transparent);
}
.item-band-row input.item {
  flex: 0 1 260px;
  min-width: 0;
  height: var(--ctl-md);
  font-size: var(--t-lg);
  font-weight: var(--w-bold);
  color: var(--text);
  padding: 0 var(--sp-3);
  border-radius: var(--r-sm);
  outline: 0;
  border: 1.5px solid color-mix(in srgb, var(--ic) 36%, var(--line));
  background: var(--surface);
  transition: all var(--dur-fast) var(--ease);
}
.item-band-row input.item::placeholder {
  color: var(--muted);
  font-weight: var(--w-regular);
}
.item-band-row input.item:focus {
  border-color: var(--ic);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ic) 22%, transparent);
}
.sup-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-1) 0 var(--sp-3);
  height: var(--ctl-md);
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1.5px solid color-mix(in srgb, var(--ic) 36%, var(--line));
  flex: 0 1 320px;
  min-width: 0;
  transition: all var(--dur-fast) var(--ease);
}
.sup-pill:focus-within {
  border-color: var(--ic);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ic) 22%, transparent);
}
.sup-pill small {
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  color: var(--ic);
  flex: none;
}
.sup-pill input {
  flex: 1;
  min-width: 0;
  height: 100%;
  font-size: var(--t-base);
  font-weight: var(--w-semi);
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
  padding: 0 var(--sp-2) 0 2px;
}
.sup-pill input::placeholder {
  color: var(--muted);
  font-weight: var(--w-regular);
}
.item-remove {
  margin-left: auto;
}
.item-remove:hover {
  background: var(--danger-soft);
  color: var(--danger-text);
}

.pe-grid {
  display: grid;
  gap: var(--sp-2);
  align-items: center;
}
.item-card.is-led .pe-grid {
  grid-template-columns:
    34px minmax(140px, 1.5fr) 84px 84px 100px minmax(88px, 0.9fr) minmax(88px, 0.9fr) minmax(80px, 0.7fr)
    32px;
}
.item-card:not(.is-led) .led-only {
  display: none;
}
.pe-cols {
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  color: var(--muted);
  text-align: center;
}
.pe-cols .l {
  text-align: left;
  padding-left: var(--sp-3);
}
.row-no {
  flex: none;
  min-width: 24px;
  height: 24px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--muted);
  font-size: var(--t-sm);
  font-weight: var(--w-bold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.item-card .row-no {
  justify-self: center;
  background: color-mix(in srgb, var(--ic) 15%, var(--surface));
  color: var(--ic);
}
.item-card .fld {
  width: 100%;
  min-width: 0;
  color: var(--text);
  padding: 0 var(--sp-3);
  border-radius: var(--r-sm);
  outline: 0;
  border: 1px solid transparent;
  background: var(--surface-2);
  transition: all var(--dur-fast) var(--ease);
}
.item-card .fld.left {
  text-align: left;
}
.item-card .fld.num {
  text-align: center;
  -moz-appearance: textfield;
}
.item-card .fld.num::-webkit-outer-spin-button,
.item-card .fld.num::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.item-card .fld::placeholder {
  color: var(--muted);
  opacity: 0.85;
}
.item-card .fld:hover {
  border-color: var(--line);
}
.item-card .fld:focus {
  background: var(--surface);
  border-color: var(--ic);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ic) 22%, transparent);
}
.item-card input.gp {
  width: 100%;
  border: 0;
  background: transparent;
  font-size: var(--t-base);
  font-weight: var(--w-bold);
  outline: 0;
  pointer-events: none;
  padding: 0 var(--sp-1);
  text-align: center;
  color: var(--muted);
}
.item-card .pos {
  color: var(--gp-pos) !important;
}
.item-card .neg {
  color: var(--danger) !important;
}
.item-card .row-remove {
  width: var(--ctl-sm);
  height: var(--ctl-sm);
  min-width: var(--ctl-sm);
  border-radius: 50%;
  font-size: var(--t-lg);
  background: transparent;
}
.item-card .row-remove:hover {
  opacity: 1;
  background: var(--danger-soft);
  color: var(--danger-text);
}
.sz-out {
  justify-self: stretch;
  text-align: center;
  font-weight: var(--w-bold);
  font-size: var(--t-base);
  color: var(--ic);
  background: color-mix(in srgb, var(--ic) 10%, var(--surface));
  border-radius: var(--r-sm);
}
.item-row.sz-missing .sz-w,
.item-row.sz-missing .sz-h {
  border-color: var(--warn-line);
  background: color-mix(in srgb, var(--warn-line) 14%, var(--surface));
}

.item-foot {
  background: color-mix(in srgb, var(--note) 8%, var(--surface));
}
.item-foot .pe-addrow {
  grid-column: 1/3;
  justify-self: start;
}
.item-foot .pe-pill {
  justify-self: end;
}
.pe-addrow {
  border: 0;
  border-radius: var(--r-pill);
  padding: 0 var(--sp-4);
  font-size: var(--t-md);
  font-weight: var(--w-bold);
  background: color-mix(in srgb, var(--ic) 14%, var(--surface));
  color: var(--ic);
  transition: all var(--dur-fast) var(--ease);
  white-space: nowrap;

  height: var(--ctl-sm);
}
.pe-addrow:hover {
  background: var(--ic);
  color: var(--on-fill);
}
.item-foot .fld {
  background: transparent;
  border: 1px dashed color-mix(in srgb, var(--note-edge) 55%, var(--line));
}
.item-foot .fld:focus {
  border-style: solid;
}
.sub-total-row {
  background: color-mix(in srgb, var(--ic) 10%, var(--surface));
  font-weight: var(--w-bold);
  text-align: center;
}
.sub-total-row .lab {
  grid-column: 1/3;
  text-align: right;
  padding-right: var(--sp-2);
  color: var(--muted);
  font-size: var(--t-sm);
}
.item-card.is-led .sub-total-row .lab {
  grid-column: 1/5;
}
.sub-total-row .st-a {
  color: var(--ic);
}
.sub-total-row .st-g.pos,
.group-total .st-g.pos {
  color: var(--gp-pos);
}
.sub-total-row .st-g.neg,
.group-total .st-g.neg {
  color: var(--danger-text);
}
.group-total {
  margin: -2px 0 0;
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--ic) 20%, var(--surface));
  border: 1.5px solid var(--ic);
  font-weight: var(--w-heavy);
  text-align: center;
  padding-top: var(--sp-3);
  padding-bottom: var(--sp-3);
  min-width: 740px;
}
.group-total.is-led {
  min-width: 800px;
  grid-template-columns:
    34px minmax(140px, 1.5fr) 84px 84px 100px minmax(88px, 0.9fr) minmax(88px, 0.9fr) minmax(80px, 0.7fr)
    32px;
}
.group-total .lab {
  grid-column: 1/3;
  text-align: right;
  font-size: var(--t-sm);
}
.group-total.is-led .lab {
  grid-column: 1/5;
}
.group-total .st-a {
  color: var(--ic);
}
.group-total.pe-grid {
  display: grid;
}

/* footer: add item · totals · cancel · save */
.pe-footer {
  position: sticky;
  bottom: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-6) calc(var(--sp-3) + var(--sab));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.pe-add-item,
.pe-cancel,
.pe-save {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  border: 0;
  border-radius: var(--r-pill);
  height: var(--ctl-md);
  padding: 0 var(--sp-5);
  font-size: var(--t-base);
  font-weight: var(--w-bold);
  transition: all var(--dur-fast) var(--ease);
}
.pe-add-item {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.pe-add-item:hover {
  background: var(--accent);
  color: var(--on-fill);
}
.pe-cancel {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}
.pe-cancel:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
}
.pe-save {
  background: var(--accent);
  color: var(--on-fill);
  padding: 0 var(--sp-7);
}
.pe-save:hover {
  filter: brightness(1.07);
}
.pe-save:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.pe-total {
  margin-left: auto;
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.pe-chip {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-pill);
  background: var(--surface-2);

  min-height: var(--ctl-md);
}
.pe-chip span {
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  color: var(--muted);
}
.pe-chip b {
  font-size: var(--t-base);
}
.pe-chip.pe-gp {
  background: var(--pos-soft);
}
.pe-chip.pe-gp b {
  color: var(--gp-pos);
}
.pe-chip.pe-gp.neg {
  background: var(--danger-soft);
}
.pe-chip.pe-gp.neg b {
  color: var(--danger-text);
}
.pe-chip.pe-area {
  background: var(--accent-soft);
}
.pe-chip.pe-area b {
  color: var(--accent-text);
}
.pe-chip[hidden] {
  display: none;
}

/* ---------- Report ---------- */
.rp-years {
  display: inline-flex;
  gap: 2px;
  padding: var(--sp-1);
  border-radius: var(--r-md);
  background: var(--chip-bg);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.rp-years::-webkit-scrollbar {
  display: none;
}
.rp-years button {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: var(--w-semi);
  font-size: var(--t-base);
  padding: 0 var(--sp-4);
  border-radius: var(--r-sm);

  height: var(--ctl-sm);
}
.rp-years button.on {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}
.kpi-tile span {
  display: block;
  color: var(--muted);
  font-size: var(--t-md);
  font-weight: var(--w-semi);
}
.kpi-tile b {
  font-size: var(--t-2xl);
  display: block;
  margin-top: var(--sp-1);
  color: var(--text);
}
.dash-panel h3 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
  margin: 0 0 var(--sp-4);
}
.dash-panel h3 small {
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  opacity: 0.85;
}
.dash-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-2);
  border-radius: var(--r-sm);
  cursor: default;
}
.dash-row[tabindex]:hover,
.dash-row[tabindex]:focus-visible {
  background: var(--surface-2);
}
.dash-row[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.dash-row.is-link {
  cursor: pointer;
}
.dash-row + .dash-row {
  border-top: 1px solid var(--line-soft);
}
.dash-rank {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: var(--muted);
  font-weight: var(--w-bold);
  font-size: var(--t-sm);
}
.dash-rank.rk1 {
  background: var(--rk1);
  color: var(--rk1-ink);
}
.dash-rank.rk2 {
  background: var(--rk2);
  color: var(--rk2-ink);
}
.dash-rank.rk3 {
  background: var(--rk3);
  color: var(--rk3-ink);
}
.dash-name-col {
  flex: 0 0 220px;
  min-width: 0;
}
.dash-name-col.narrow {
  flex: 0 0 170px;
}
.dash-name {
  font-weight: var(--w-bold);
  font-size: var(--t-base);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-sub {
  color: var(--muted);
  font-size: var(--t-sm);
}
.dash-dot {
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.dash-bar-track {
  flex: 1;
  height: 12px;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  overflow: hidden;
  position: relative;
}
.dash-bar-fill {
  height: 100%;
  border-radius: var(--r-pill);
}
.dash-bar-fill.gp-pos-bg {
  background: var(--fill-pos);
}
.dash-bar-fill.gp-neg-bg {
  background: var(--fill-neg);
}
.dash-bar-fill.rp-sup {
  background: var(--fill-neutral);
}
.dash-value {
  flex: 0 0 104px;
  text-align: right;
  color: var(--text);
} /* ---------- the top of the Report: the result, what is worth a look, and where the budget goes ---------- */
.rp-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: var(--sp-5) var(--sp-7);
  align-items: end;
  padding-top: var(--sp-5);
  border-top: 3px solid var(--text);
}
.rp-lead {
  min-width: 0;
}
.rp-eyebrow {
  font-size: var(--t-md);
  font-weight: var(--w-semi);
  color: var(--muted);
}
/* the total, underlined twice as in a ledger */
.rp-big {
  display: inline-block;
  max-width: 100%;
  margin: var(--sp-2) 0 var(--sp-3);
  padding-bottom: var(--sp-1);
  border-bottom: 4px double var(--text);
  font-size: var(--t-fig-xl);
  font-weight: var(--w-semi);
  letter-spacing: var(--tr-tight);
  line-height: var(--lh-fig);
  white-space: nowrap;
}
.rp-big .rp-cur {
  margin-right: 0.3em;
  font-size: 0.38em;
  font-weight: var(--w-semi);
  letter-spacing: 0;
  color: var(--muted);
  vertical-align: 0.9em;
}
.rp-top.neg .rp-big {
  color: var(--danger-text);
  border-bottom-color: var(--danger);
}
.rp-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-4);
  font-size: var(--t-base);
  color: var(--text-2);
}
.rp-pill {
  display: inline-flex;
  align-items: center;
  height: var(--chip-h);
  padding: 0 var(--sp-3);
  border-radius: var(--r-pill);
  background: var(--pos-soft);
  color: var(--gp-pos);
  font-size: var(--t-sm);
  font-weight: var(--w-bold);
  line-height: 1;
}
.rp-top.neg .rp-pill {
  background: var(--danger-soft);
  color: var(--danger-text);
}
/* three things worth knowing, each one tap from the project or the item */
.rp-picks {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.rp-chip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: var(--sp-3);
  align-items: baseline;
  width: 100%;
  padding: var(--sp-3) var(--sp-2);
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-fast);
}
.rp-chip:last-child {
  border-bottom: 1px solid var(--line);
}
.rp-chip small {
  grid-column: 1/-1;
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  color: var(--muted);
}
.rp-chip-n {
  font-family: var(--font-fig);
  font-size: var(--t-lg);
  font-weight: var(--w-semi);
  line-height: var(--lh-head);
  overflow-wrap: anywhere;
}
.rp-chip b {
  font-size: var(--t-lg);
  color: var(--gp-pos);
}
.rp-chip.warn b {
  color: var(--danger-text);
}
.rp-chip:hover,
.rp-chip:focus-visible {
  background: var(--surface-2);
}
/* the tape: one segment per item, as wide as its budget; solid is the cost, light is the profit */
.rp-tape-wrap {
  grid-column: 1/-1;
  padding-top: var(--sp-3);
}
.rp-tape-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-1) var(--sp-5);
  font-size: var(--t-md);
  font-weight: var(--w-semi);
  color: var(--text-2);
}
.rp-tape-key {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1) var(--sp-2);
  font-size: var(--t-sm);
  font-weight: var(--w-regular);
  color: var(--muted);
}
.rp-tape-key b {
  margin-right: var(--sp-3);
  font-weight: var(--w-semi);
  color: var(--text);
}
.rp-tape-key i {
  width: 12px;
  height: 12px;
  border-radius: var(--r-xs);
}
.k-cost {
  background: var(--text-2);
}
.k-prof {
  background: color-mix(in srgb, var(--text-2) 22%, var(--surface));
}
.rp-tape {
  display: flex;
  gap: 3px;
  height: 48px;
  margin-top: var(--sp-3);
}
.rp-seg {
  --ic: var(--accent);
  display: flex;
  min-width: 10px;
  padding: 0;
  border: 0;
  border-radius: var(--r-xs);
  overflow: hidden;
  background: color-mix(in srgb, var(--ic) 24%, var(--surface));
  cursor: pointer;
  transition:
    opacity var(--dur-fast),
    transform var(--dur-fast);
}
.rp-seg .c {
  display: block;
  height: 100%;
  background: var(--ic);
}
.rp-seg.is-over {
  box-shadow: inset 0 0 0 3px var(--danger);
}
.rp-seg:hover,
.rp-seg.is-hot {
  transform: translateY(-4px);
}
.rp-tape-wrap.has-hot .rp-seg:not(.is-hot) {
  opacity: 0.3;
}
.rp-tape-leg {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-5);
  margin-top: var(--sp-3);
}
.rp-leg {
  --ic: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--ctl-sm);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: var(--t-md);
  cursor: pointer;
}
.rp-leg i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ic);
}
.rp-leg b {
  font-weight: var(--w-semi);
}
.rp-leg:hover,
.rp-leg.is-hot {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.rp-faint {
  color: var(--muted);
}
.rp-pending {
  margin-top: var(--sp-2);
  font-size: var(--t-sm);
  color: var(--muted);
}
.rp-top .nocost-link {
  font-weight: var(--w-semi);
}
.rp-switch {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 var(--sp-2);
}
.dash-value.gp-low {
  color: var(--warn);
}
.dash-bar-fill.gp-low-bg {
  background: var(--warn-line);
}
.dash-row.is-hot {
  background: var(--surface-2);
}
/* the opening moment: the tape draws in from the left (the figures count up in report.js) */
@keyframes tapeDraw {
  from {
    clip-path: inset(0 100% 0 0);
  }
  to {
    clip-path: inset(0 0 0 0);
  }
}
.rp-reveal .rp-tape {
  animation: tapeDraw 0.9s var(--ease) both;
}
@media (max-width: 1100px) {
  .rp-top {
    grid-template-columns: 1fr;
  }
  .rp-picks {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0 var(--sp-4);
  }
  .rp-chip {
    flex: 1 1 220px;
    width: auto;
  }
}
@media (max-width: 760px) {
  .rp-picks {
    flex-direction: column;
  }
  .rp-chip {
    flex: none;
    width: 100%;
  }
  .rp-tape {
    height: 40px;
  }
}

.rp-tiles {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--sp-3);
}
/* the Report: the trend, then two columns that each fill their height (on a narrower screen one column, in this order) */
.rp-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-4);
  align-items: start;
}
.rp-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.rp-tiles .kpi-tile {
  padding: var(--sp-4) 0 var(--sp-5);
}
.rp-tiles .kpi-tile b {
  font-size: var(--t-fig-sm);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rp-tiles .kpi-tile em {
  display: block;
  font-style: normal;
  color: var(--muted);
  font-size: var(--t-sm);
  margin-top: var(--sp-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#reportList .dash-panel + .dash-panel {
  margin-top: 0;
}
.rp-empty {
  color: var(--muted);
  font-size: var(--t-base);
  line-height: var(--lh-body);
  padding: var(--sp-3) var(--sp-1);
}
.rp-led-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}
.rp-led-stats > div {
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-3);
}
.rp-led-stats span {
  display: block;
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  color: var(--muted);
}
.rp-led-stats b {
  display: block;
  font-size: var(--t-xl);
  margin-top: var(--sp-1);
}
.rp-led-stats u {
  text-decoration: none;
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  color: var(--muted);
  margin-left: var(--sp-1);
}
.rp-led-table {
  display: flex;
  flex-direction: column;
}
.rp-lt-head,
.rp-lt-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-2);
  align-items: center;
  font-size: var(--t-base);
}
.rp-lt-head {
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  color: var(--muted);
  padding-bottom: var(--sp-1);
}
.rp-lt-head span:not(:first-child),
.rp-lt-row span:not(:first-child) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.rp-lt-row {
  border-top: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
}
.rp-lt-row:hover,
.rp-lt-row:focus-visible {
  background: var(--surface-2);
  outline: none;
}
.rp-lt-row .n {
  font-weight: var(--w-bold);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rp-lt-row em {
  font-style: normal;
  font-size: var(--t-xs);
  font-weight: var(--w-bold);
  margin-left: var(--sp-2);
  padding: 2px var(--sp-2);
  border-radius: var(--r-pill);
  background: var(--pos-soft);
  color: var(--gp-pos);
}
.rp-months {
  overflow-x: auto;
  padding: var(--sp-6) 0 var(--sp-1);
}
.rp-m-plot {
  position: relative;
  margin-bottom: var(--sp-6);
  display: flex;
  gap: var(--sp-2);
  min-width: max-content;
  padding: 0 var(--sp-2);
}
.rp-m-zero {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--line);
}
.rp-m-col {
  position: relative;
  flex: 1 0 54px;
  height: 100%;
  border-radius: var(--r-sm);
  outline: none;
}
.rp-m-col:hover,
.rp-m-col:focus-visible {
  background: var(--surface-2);
}
.rp-m-bar {
  position: absolute;
  left: 50%;
  width: 28px;
  margin-left: -14px;
  border-radius: var(--r-xs) var(--r-xs) var(--r-xs) var(--r-xs);
  display: block;
}
.rp-m-bar.gp-pos-bg {
  background: var(--fill-pos);
}
.rp-m-bar.gp-neg-bg {
  background: var(--fill-neg);
  border-radius: var(--r-xs) var(--r-xs) var(--r-xs) var(--r-xs);
}
.rp-m-val {
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  font-size: var(--t-xs);
  font-weight: var(--w-bold);
}
.rp-m-labs {
  display: flex;
  gap: var(--sp-2);
  min-width: max-content;
  padding: var(--sp-2) var(--sp-2) 0;
}
.rp-m-labs span {
  flex: 1 0 54px;
  text-align: center;
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  color: var(--muted);
}
@media (max-width: 1100px) {
  .rp-tiles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 900px) {
  .rp-cols {
    display: flex;
    flex-direction: column;
  }
  .rp-col {
    display: contents;
  }
  .rp-p-rank {
    order: 1;
  }
  .rp-p-item {
    order: 2;
  }
  .rp-p-tag {
    order: 3;
  }
  .rp-p-sup {
    order: 4;
  }
  .rp-p-led {
    order: 5;
  }
}

@media (max-width: 760px) {
  .dash-row {
    flex-wrap: wrap;
    row-gap: var(--sp-2);
  }
  .dash-name-col,
  .dash-name-col.narrow {
    flex: 1 1 calc(100% - 40px);
  }
  .dash-row > .dash-bar-track {
    flex: 1 1 0;
    margin-left: 38px;
  }
  .dash-row:has(.dash-dot) > .dash-bar-track {
    margin-left: var(--sp-6);
  }
  .dash-row:not(:has(.dash-rank)):not(:has(.dash-dot)) > .dash-bar-track {
    margin-left: 0;
  }
  .dash-row:not(:has(.dash-rank)):not(:has(.dash-dot)) > .dash-name-col {
    flex-basis: 100%;
  }
  .dash-value {
    flex: 0 0 auto;
    min-width: 84px;
  }
  .rp-lt-row .n {
    white-space: normal;
  }
}
@media (max-width: 760px) {
  .rp-tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.rp-more {
  display: block;
  width: 100%;
  margin: var(--sp-2) 0;
  padding: var(--sp-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  background: transparent;
  color: var(--accent-text);
  font-weight: var(--w-bold);
  font-size: var(--t-base);

  min-height: var(--ctl-md);
}
.rp-more:hover {
  background: var(--accent-soft);
}
.rp-m-bar.is-ghost {
  opacity: 0.38;
}

/* "N not costed yet": a real link that shows those projects */
.nocost-link {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  border-radius: var(--r-xs);
}
.nocost-link::after {
  content: '›';
  margin-left: 0.3em;
  text-decoration: none;
  display: inline-block;
}
.nocost-link:hover {
  text-decoration-style: solid;
}
.nocost-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.dash-panel .nocost-link,
.list-summary .nocost-link {
  color: var(--accent-text);
  font-weight: var(--w-semi);
}

/* ---------- Costing (owner only): sheet list, Rate Card tab ---------- */
.cst-subtabs {
  display: inline-flex;
  gap: 2px;
  padding: var(--sp-1);
  border-radius: var(--r-md);
  background: var(--chip-bg);
  margin: 0 0 var(--sp-3);
}
.cst-subtab {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: var(--r-sm);
  padding: 0 var(--sp-4);
  font: inherit;
  font-weight: var(--w-semi);
  font-size: var(--t-base);
  cursor: pointer;

  height: var(--ctl-sm);

  display: inline-flex;

  align-items: center;

  justify-content: center;
}
.cst-subtab.open {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}
.cst-subtab i {
  font-style: normal;
  font-size: var(--t-sm);
  background: var(--chip-bg);
  color: var(--muted);
  border-radius: var(--r-pill);
  padding: 0 var(--sp-2);
  margin-left: var(--sp-1);

  display: inline-flex;

  align-items: center;

  height: var(--chip-h);

  font-weight: var(--w-bold);

  line-height: 1;
}
.cst-subtab.open i {
  background: var(--accent);
  color: var(--on-fill);
}
.cst-subpanel {
  display: none;
}
.cst-subpanel.open {
  display: block;
}
.cst-toolbar {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  margin: 0 0 var(--sp-3);
  flex-wrap: wrap;
}
.cst-toolbar .search {
  flex: 1 1 240px;
}
.cst-onboard {
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  text-align: center;
  padding: var(--sp-7) var(--sp-6);
}
.cst-onboard-ic {
  width: 52px;
  height: 52px;
  border-radius: var(--r-md);
  margin: 0 auto var(--sp-3);
  display: grid;
  place-items: center;
  font-size: var(--t-lg);
  color: var(--accent-text);
  background: var(--accent-soft);
}
.cst-onboard h3 {
  margin: 0 0 var(--sp-2);
  font-size: var(--t-lg);
  color: var(--text);
}
.cst-onboard p {
  margin: 0 auto var(--sp-5);
  max-width: 460px;
  color: var(--muted);
  font-size: var(--t-base);
  line-height: var(--lh-body);
}
.cst-onboard .btn {
  margin-top: 2px;
}
.cst-sheet-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3) var(--sp-5);
  padding: var(--sp-5) var(--sp-6);
  cursor: pointer;
  transition: box-shadow var(--dur-fast);
}
.cst-sheet-card:hover {
  box-shadow: var(--shadow);
}
.cst-sheet-info {
  flex: 1 1 320px;
  min-width: 0;
}
.cst-sheet-name {
  font-size: var(--t-lg);
  margin-bottom: var(--sp-2);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cst-sheet-total {
  flex: 0 0 auto;
  text-align: right;
}
.cst-sheet-total span {
  display: block;
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  color: var(--muted);
}
.cst-sheet-total b {
  font-size: var(--t-xl);
  color: var(--text);
}
.cst-sheet-actions {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  flex: 0 0 auto;
}
.sh-chips {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.sh-chip {
  font-size: var(--t-sm);
  font-weight: var(--w-bold);
  color: var(--muted);
  background: var(--chip-bg);
  border-radius: var(--r-pill);
  padding: 0 var(--sp-2);
  white-space: nowrap;

  display: inline-flex;

  align-items: center;

  height: var(--chip-h);

  line-height: 1;
}
.sh-bar {
  display: flex;
  gap: 2px;
  height: 7px;
  border-radius: var(--r-pill);
  overflow: hidden;
  margin-top: var(--sp-3);
  background: var(--chip-bg);
}
.sh-bar i {
  display: block;
  min-width: 4px;
}
.sh-legend {
  display: flex;
  gap: var(--sp-1) var(--sp-3);
  flex-wrap: wrap;
  margin-top: var(--sp-2);
  font-size: var(--t-sm);
  color: var(--muted);
}
.sh-legend u {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: var(--sp-1);
  vertical-align: baseline;
}
.sh-legend b {
  color: var(--text);
  margin-left: 2px;
}

/* ---------- Costing sheet window: frame, halls, footer ---------- */
.cst-modal {
  width: min(1320px, 100%);
  max-height: 94vh;
  max-height: 94dvh;
}
.cst-modal .modal-title {
  padding: var(--sp-3) var(--sp-5);
  font-size: var(--t-lg);
}
.cst-meta-row {
  display: grid;
  grid-template-columns: 2fr 1.4fr 0.8fr 1.1fr;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-soft);
}
.cst-field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 0;
}
.cst-field label {
  font-size: var(--t-xs);
  font-weight: var(--w-semi);
  color: var(--muted);
}
.cst-field input,
.cst-field select {
  width: 100%;
  height: var(--ctl-sm);
  padding: var(--sp-1) var(--sp-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--t-md);
}
.cst-suffix {
  position: relative;
}
.cst-suffix input {
  padding-right: 42px !important;
}
.cst-suffix span {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--t-sm);
  font-weight: var(--w-bold);
  color: var(--muted);
  pointer-events: none;
}
.cst-hint {
  font-size: var(--t-sm);
  color: var(--muted);
  line-height: var(--lh-body);
}
.cst-hint-bar {
  padding: var(--sp-2) var(--sp-5);
  border-bottom: 1px solid var(--line-soft);
  background: var(--accent-soft);
  color: var(--text);
}
.cst-hall-block {
  margin: var(--sp-2) var(--sp-5) 0;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.cst-hall-block:last-child {
  margin-bottom: var(--sp-3);
}
.cst-hall-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-2);
  background: var(--accent-soft);
  cursor: pointer;
  user-select: none;
  border-radius: calc(var(--r-md) - 1px) calc(var(--r-md) - 1px) 0 0;
}
.cst-hall-block.collapsed > .cst-hall-head {
  border-radius: calc(var(--r-md) - 1px);
}
.cst-hall-block:not(.collapsed) .cst-hall-head {
  border-bottom: 1px solid var(--line-soft);
}
.cst-hall-chev {
  font-size: var(--t-xs);
  color: var(--accent-text);
  width: 12px;
  transition: transform var(--dur-fast) var(--ease);
}
.cst-hall-block.collapsed .cst-hall-chev {
  transform: rotate(-90deg);
}
.cst-hall-block.collapsed .cst-hall-body {
  display: none;
}
.cst-hall-name {
  font-weight: var(--w-heavy);
  font-size: var(--t-base);
  color: var(--text);
}
.cst-hall-subtotal {
  margin-left: auto;
  font-size: var(--t-sm);
  color: var(--muted);
  font-weight: var(--w-bold);
  white-space: nowrap;
}
.cst-hall-subtotal b {
  color: var(--text);
  font-size: var(--t-base);
  margin-left: var(--sp-1);
}
.cst-footer {
  position: sticky;
  bottom: 0;
  z-index: var(--z-sticky);
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-5) calc(var(--sp-2) + var(--sab));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.cst-footer .btn {
  height: var(--ctl-md);
}
.cst-add-hall {
  border: 1.5px dashed var(--line);
  background: transparent;
  color: var(--accent-text);
  border-radius: var(--r-pill);
  padding: 0 var(--sp-3);
  font-weight: var(--w-bold);
  font-size: var(--t-md);
  cursor: pointer;
  white-space: nowrap;

  height: var(--ctl-sm);
}
.cst-add-hall:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.cst-grand {
  margin-right: auto;
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.cst-grand span {
  font-size: var(--t-sm);
  color: var(--muted);
  font-weight: var(--w-semi);
}
.cst-grand b {
  font-size: var(--t-sm);
  color: var(--muted);
  font-weight: var(--w-semi);
}
.cst-grand b em {
  font-style: normal;
  font-size: var(--t-xl);
  color: var(--text);
  margin-left: var(--sp-2);
}
@media (max-width: 760px) {
  .cst-sheet-total {
    text-align: left;
  }
  .cst-toolbar {
    gap: var(--sp-2);
  }
  .cst-toolbar .search {
    flex: 1 1 100%;
  }
  .cst-toolbar .btn {
    flex: 1;
  }
  .cst-meta-row {
    grid-template-columns: 1fr 1fr;
    padding: var(--sp-3);
  }
  .cst-meta-row .cst-field:first-child {
    grid-column: 1/-1;
  }
  .cst-hall-block {
    margin: var(--sp-2) var(--sp-2) 0;
  }
}

/* ---------- tablets and narrow windows ---------- */
@media (max-width: 1100px) {
  .proj-head {
    grid-template-columns: 22px minmax(0, 1fr) auto auto;
    grid-template-areas: 'chev title stats gp' '. mix notes notes';
    gap: var(--sp-2) var(--sp-4);
  }
  .chevron {
    grid-area: chev;
  }
  .proj-title-wrap {
    grid-area: title;
  }
  .proj-head-stats {
    grid-area: stats;
  }
  .stat-gp {
    grid-area: gp;
    min-width: 104px;
    width: auto;
  }
  .proj-mix {
    grid-area: mix;
  }
  .proj-notes {
    grid-area: notes;
  }
  .stat-b,
  .stat-c {
    min-width: 72px;
    width: auto;
  }
  .pe-form {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  }
  .grp-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px var(--sp-4);
    padding: 0 var(--sp-1);
  }
  .grp-fig {
    text-align: left;
  }
  .grp-fig b {
    display: inline;
  }
  .pe-form .pe-field:nth-child(n + 3) {
    grid-column: auto;
  }
}
@media (max-width: 900px) {
  .filter-group select {
    min-width: 104px;
    max-width: 170px;

    height: var(--ctl-md);
  }
}

/* ---------- phones ---------- */
@media (max-width: 760px) {
  input:not([type='checkbox']):not([type='radio']):not([type='range']):not(.gp),
  select,
  textarea {
    font-size: 16px !important;
  }
  .topbar {
    padding: calc(var(--sp-2) + var(--sat)) var(--sp-3) var(--sp-2);
    gap: var(--sp-2);
  }
  .brand-mark {
    width: 28px;
    height: 28px;
  }
  .tabs,
  #addProjectBtn {
    display: none;
  }
  .content {
    padding: var(--sp-3) var(--sp-3) calc(96px + var(--sab));
  }
  .filter-bar {
    gap: var(--sp-2);
    margin-bottom: var(--sp-3);
  }
  .search {
    flex: 1 1 100%;
  }
  /* tag / item / margin / sort sit in one swipeable row of pills instead of stacking */
  .filter-row {
    flex: 1 1 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 0 calc(var(--sp-3) * -1);
    padding: 0 var(--sp-3) 2px;
  }
  .filter-row::-webkit-scrollbar {
    display: none;
  }
  .filter-group select {
    height: var(--ctl-md);
    min-width: 0;
    max-width: none;
    padding: 0 var(--sp-7) 0 var(--sp-3);
    background-position: right 12px center;
  }
  .filter-clear {
    flex: none;
    padding: 2px var(--sp-2);
  }
  .nocost-link {
    padding: var(--sp-2) 0;
  }

  .tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-bar);
    padding: var(--sp-2) var(--sp-2) calc(var(--sp-2) + var(--sab));
    background: var(--bar-bg);
    backdrop-filter: saturate(1.6) blur(18px);
    -webkit-backdrop-filter: saturate(1.6) blur(18px);
    border-top: 1px solid var(--line-soft);
  }
  .tabbar button {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: 0;
    background: none;
    color: var(--muted);
    font-size: var(--t-xs);
    font-weight: var(--w-semi);
    padding: var(--sp-1) 0;
    min-height: 48px;
  }
  .tabbar button .ic {
    width: var(--ic-lg);
    height: var(--ic-lg);
    vertical-align: 0;
  }
  .tabbar button.on {
    color: var(--accent-text);
  }
  .tabbar .badge {
    position: absolute;
    top: 2px;
    left: calc(50% + 6px);
    min-width: 17px;
    height: 17px;
    font-size: var(--t-xs);
  }
  .fab {
    display: grid;
    place-items: center;
    position: fixed;
    right: 16px;
    bottom: calc(72px + var(--sab));
    z-index: var(--z-raised);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 0;
    padding: 0;
    background: var(--accent);
    color: var(--on-fill);
    box-shadow: var(--shadow-fab);
  }
  .fab .ic {
    width: var(--ic-lg);
    height: var(--ic-lg);
    stroke-width: 2.2;
    vertical-align: 0;
  }
  .fab:active {
    transform: scale(0.95);
  }
  body.modal-open .tabbar,
  body.modal-open .fab {
    display: none;
  }
  .toasts {
    bottom: calc(76px + var(--sab));
  }

  /* a phone row: name and GP on top, the colour strip, one line of budget / cost; a note only if there is one */
  .proj-head {
    grid-template-columns: 18px minmax(0, 1fr) auto;
    grid-template-areas: 'chev title gp' '. mix mix' '. stats stats' '. notes notes';
    padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-2);
    gap: var(--sp-2) var(--sp-2);
  }
  .chevron {
    grid-area: chev;
    align-self: start;
    margin-top: var(--sp-1);
  }
  .proj-title-wrap {
    grid-area: title;
  }
  .stat-gp {
    grid-area: gp;
    min-width: 0;
    align-self: start;

    width: auto;
  }
  .proj-mix {
    grid-area: mix;
  }
  .proj-head-stats {
    grid-area: stats;
  }
  .proj-notes {
    grid-area: notes;
  }
  .proj-name {
    font-size: var(--t-lg);
  }
  .proj-head-stats .stat {
    display: flex;
    align-items: baseline;
    gap: var(--sp-2);
    text-align: left;
    min-width: 0;
  }
  .proj-head-stats .stat span {
    display: inline;
    font-size: var(--t-sm);
  }
  .proj-head-stats .stat b {
    display: inline;
    font-size: var(--t-base);
    margin: 0;
  }
  .stat-gp.gp-none span {
    display: none;
  }
  .stat-gp b {
    font-size: var(--t-lg);
  }
  .project-wrap:not(.expanded) .proj-notes:has(.proj-notes-input.is-empty) {
    display: none;
  }
  .proj-notes-none {
    display: none;
  }
  .proj-body {
    padding: 0 var(--sp-3) var(--sp-3);
  }
  .proj-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .proj-bar .proj-attach-row {
    flex: 0 0 auto;
  }
  .proj-toolbar {
    width: 100%;
    margin-left: 0;
  }
  .pbtn {
    flex: 1;
    padding: 0 var(--sp-2);
    font-size: var(--t-sm);
  }
  .proj-audit {
    text-align: left;
  }

  /* the sheet: each row stacks so the numbers are always on screen */
  .sheet-wrap {
    overflow-x: visible;
  }
  .sheet,
  .sheet.has-led {
    min-width: 0;
    border: 0;
    background: transparent;
    border-radius: 0;
  }
  .sheet-group {
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    overflow: hidden;
    margin-bottom: var(--sp-2);
    background: var(--surface);
  }
  .sheet-group + .sheet-group {
    border-top: 1px solid var(--line);
  }
  .sheet-head {
    display: none !important;
  }
  .sheet-row,
  .sheet.has-led .sheet-row {
    grid-template-columns: 28px repeat(3, minmax(0, 1fr));
  }
  .sheet-row > div,
  .sheet-row > div + div {
    border: 0;
    padding: var(--sp-1) var(--sp-2);
  }
  .sheet-row:not(.sheet-bandrow) {
    border-bottom: 1px solid var(--line-soft);
  }
  .sheet-row > div.c-no {
    grid-column: 1;
    grid-row: 1 / span 3;
    align-items: flex-start;
    padding-top: var(--sp-2);
  }
  .sheet-row > div.c-desc {
    grid-column: 2/5 !important;
    justify-content: flex-start;
    text-align: left;
    font-weight: var(--w-semi);
    padding-top: var(--sp-2);
  }
  .sheet-row > div.c-w,
  .sheet-row > div.c-b {
    grid-column: 2;
  }
  .sheet-row > div.c-h,
  .sheet-row > div.c-c {
    grid-column: 3;
  }
  .sheet-row > div.c-sq,
  .sheet-row > div.c-g {
    grid-column: 4;
  }
  .sheet-row > div[data-l] {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    gap: 1px;
    padding-bottom: var(--sp-2);
  }
  .sheet-row > div[data-l]::before {
    content: attr(data-l);
    font-size: var(--t-xs);
    font-weight: var(--w-semi);
    color: var(--muted);
  }
  .sheet-row > div.c-lab {
    grid-column: 1/-1 !important;
    justify-content: flex-start !important;
    padding: var(--sp-2) var(--sp-2) 2px;
  }
  .sheet-row > div.c-blank {
    display: none;
  }
  .sheet-sub > div.c-sq,
  .sheet-gtotal > div.c-sq {
    grid-column: 2/-1;
  }
  .sheet-shared > div.c-g {
    display: none;
  }
  .sheet-bandrow > div.bname {
    flex-wrap: wrap;
    gap: var(--sp-2);
  }
  .sheet-group .sheet-row:not(.sheet-bandrow):not(.sheet-head):not(.sheet-sub):not(.sheet-shared) > div:first-child {
    box-shadow: none;
  }
  .sheet-gap {
    display: none;
  }
  .sheet-total {
    border: 1px solid var(--line) !important;
    border-radius: var(--r-sm);
    overflow: hidden;
    margin-top: 2px;
  }
  .sheet-gtotal > div {
    border-top: 0;
  }

  /* editor: a full-screen sheet */
  .modal-backdrop {
    padding: 0;
    align-items: stretch;
  }
  .modal-card,
  .cst-modal {
    width: 100%;
    max-height: none;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    border: 0;
    animation: sheetUp var(--dur) var(--ease);
  }
  .modal-card.narrow {
    height: auto;
    max-height: 92dvh;
    margin-top: auto;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
  }
  .modal-title {
    padding: calc(var(--sp-3) + var(--sat)) var(--sp-4) var(--sp-3);
    font-size: var(--t-lg);
  }
  .modal-card.narrow .modal-title {
    padding-top: var(--sp-4);
  }
  .editor-footer {
    padding: var(--sp-3) var(--sp-4) calc(var(--sp-4) + var(--sab));
  }
  .editor-warn {
    margin: var(--sp-3) var(--sp-3) 0;
  }
  .pe-form {
    grid-template-columns: 1fr 1fr;
    padding: var(--sp-3) var(--sp-3) var(--sp-2);
    gap: var(--sp-3);
  }
  .pe-form .pe-field:nth-child(-n + 2) {
    grid-column: 1/-1;
  }
  .attach-section {
    margin: 0 var(--sp-3);
  }
  .attach-label .attach-sub {
    display: none;
  }
  .pe-items {
    padding: var(--sp-3) var(--sp-3);
    overflow-x: visible;
  }
  .item-card,
  .item-card.is-led,
  .group-total,
  .group-total.is-led {
    min-width: 0;
  }
  .item-band-row {
    padding: var(--sp-2) var(--sp-3);
    gap: var(--sp-2);
  }
  .item-band-row input.item,
  .sup-pill {
    flex: 1 1 100%;
  }
  .item-remove {
    position: absolute;
    right: 10px;
    top: 10px;
    margin: 0;
  }
  .item-card {
    position: relative;
  }
  .item-dot {
    display: none;
  }
  .item-band-row input.item {
    margin-right: var(--sp-7);
    flex: 1 1 calc(100% - 34px);

    height: var(--ctl-md);
  }
  .item-card .pe-cols {
    display: none;
  }
  .item-card .item-row.pe-grid,
  .item-card.is-led .item-row.pe-grid {
    padding: var(--sp-2) var(--sp-3);
    border-top: 1px solid var(--line-soft);
  }
  .item-row .row-no {
    grid-area: no;
  }
  .item-row .desc {
    grid-area: desc;
  }
  .item-row .sz-w {
    grid-area: w;
  }
  .item-row .sz-h {
    grid-area: h;
  }
  .item-row .sz-out {
    grid-area: sq;
  }
  .item-row .budget {
    grid-area: bud;
  }
  .item-row .cost {
    grid-area: cost;
  }
  .item-row input.gp {
    grid-area: gp;
  }
  .item-row .row-remove {
    grid-area: rm;
  }
  .item-card .item-foot.pe-grid,
  .item-card.is-led .item-foot.pe-grid {
    grid-template-columns: 1fr 1fr;
  }
  .item-card .item-foot .pe-addrow,
  .item-card.is-led .item-foot .pe-addrow {
    grid-column: 1/2;
  }
  .item-card .item-foot .pe-pill,
  .item-card.is-led .item-foot .pe-pill {
    font-size: var(--t-sm);
    padding: var(--sp-2) var(--sp-2);
  }
  .item-card .sub-total-row.pe-grid,
  .group-total,
  .group-total.is-led {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .item-card.is-led .sub-total-row.pe-grid,
  .group-total.is-led {
    grid-template-columns: repeat(4, 1fr);
  }
  .item-card .sub-total-row .lab,
  .item-card.is-led .sub-total-row .lab,
  .group-total .lab,
  .group-total.is-led .lab {
    grid-column: 1/-1;
    text-align: left;
  }
  .st-a::before,
  .st-b::before,
  .st-c::before,
  .st-g::before {
    display: block;
    font-size: var(--t-sm);
    font-weight: var(--w-semi);
    color: var(--muted);
  }
  .st-a::before {
    content: 'Area';
  }
  .st-b::before {
    content: 'Budget';
  }
  .st-c::before {
    content: 'Cost';
  }
  .st-g::before {
    content: 'GP';
  }
  .pe-footer {
    padding: var(--sp-2) var(--sp-3) calc(var(--sp-2) + var(--sab));
    gap: var(--sp-2);
  }
  .pe-total {
    order: -1;
    width: 100%;
    margin-left: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .pe-total::-webkit-scrollbar {
    display: none;
  }
  .pe-chip {
    flex: none;
  }
  .pe-add-item,
  .pe-cancel,
  .pe-save {
    height: var(--ctl-lg);
    padding: 0 var(--sp-4);
    font-size: var(--t-base);
  }
  .pe-add-item {
    flex: 1;
    justify-content: center;
  }
  .pe-save {
    flex: 1;
    justify-content: center;
  }
  .cst-footer {
    flex-wrap: wrap;
  }
  .cst-footer .btn {
    flex: 1;

    height: var(--ctl-md);
  }
  .cst-grand {
    flex: 1 1 100%;
    order: -1;
    margin-right: 0;
  }
  .cst-add-hall {
    flex: 1 1 100%;
    order: -2;
  }
}
@media (max-width: 380px) {
  .proj-head-stats {
    gap: var(--sp-3);
  }
  .topbar .pill {
    font-size: var(--t-xs);
    padding: var(--sp-1) var(--sp-2);
  }
}

/* ---------- touch screens ---------- */
/* A few rarely used controls grow to 44px. Everything else small keeps its size and its row height, and its tappable area
   grows to 44px with an invisible margin (6px each side), so lists do not get longer. A pointer on a desktop is not affected. */
@media (pointer: coarse) {
  /* the normal control height is 44px on a touch screen (40 with a pointer) */
  :root {
    --ctl-md: 44px;
  }
  .xl-btn,
  .login-link,
  .filter-clear,
  .tab,
  .rp-years button,
  .cst-subtab {
    min-height: var(--ctl-md);
  }
  .btn.sm,
  .pbtn,
  .attach-add-btn,
  .pe-addrow,
  .pe-shared-btn,
  .cst-add-hall,
  .qchip,
  .cs-chip,
  .cs-rc,
  .cs-day,
  .proj-attach-chip,
  .attach-chip,
  .item-pill-quote-chip,
  .rcx-seg button,
  .mini-btn:not(.item-remove),
  .item-card .row-remove,
  .rcx-rm,
  .cs-x,
  .modal-close {
    position: relative;
  }
  .btn.sm::after,
  .pbtn::after,
  .attach-add-btn::after,
  .pe-addrow::after,
  .pe-shared-btn::after,
  .cst-add-hall::after,
  .qchip::after,
  .cs-chip::after,
  .cs-rc::after,
  .cs-day::after,
  .proj-attach-chip::after,
  .attach-chip::after,
  .item-pill-quote-chip::after,
  .rcx-seg button::after,
  .mini-btn::after,
  .item-card .row-remove::after,
  .rcx-rm::after,
  .cs-x::after,
  .modal-close::after {
    content: '';
    position: absolute;
    inset: -6px;
  }
}

/* ---------- print ---------- */
@media print {
  :root {
    --bg: var(--surface);
  }
  .topbar,
  .tabbar,
  .fab,
  .filter-bar,
  .toasts,
  .proj-toolbar,
  .more-btn,
  .proj-notes-status {
    display: none !important;
  }
  body {
    background: var(--surface);
  }
  .content {
    padding: 0;
    max-width: none;
  }
  .project-wrap {
    break-inside: avoid;
    border-color: var(--line-strong);
    content-visibility: visible;
  }
  .proj-body {
    display: block;
  }
}

/* ---------- Costing sheet editor: category → lines ---------- */
.cs-hall > .cst-hall-body {
  padding: var(--sp-3);
  display: grid;
  gap: var(--sp-2);
}
.cs-cat {
  --cc: var(--accent);
  border: 1px solid var(--line);
  border-left: 4px solid var(--cc);
  border-radius: var(--r-sm);
  background: var(--surface);
  overflow: hidden;
}
.cs-cat-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-2);
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-3);
  background: color-mix(in srgb, var(--cc) 9%, var(--surface));
  border-bottom: 1px solid var(--line-soft);
}
.cs-cat-n {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--cc);
  color: var(--on-fill);
  font-weight: var(--w-heavy);
  font-size: var(--t-sm);
  display: grid;
  place-items: center;
  flex: none;
}
.cs-cat-name {
  font-weight: var(--w-heavy);
  font-size: var(--t-base);
  color: var(--text);
}
.cs-rate {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-left: var(--sp-2);
  font-size: var(--t-sm);
  font-weight: var(--w-bold);
  color: var(--muted);
}
.cs-rate .cs-in {
  width: 96px;
  text-align: right;
  font-weight: var(--w-heavy);
  background: var(--surface);
  border-color: var(--line);
}
.cs-rate em {
  font-style: normal;
  font-weight: var(--w-semi);
  white-space: nowrap;
}
.cs-led-rc {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}
.cs-cat-sum {
  margin-left: auto;
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  color: var(--muted);
  white-space: nowrap;
}
.cs-cat-sum b {
  color: var(--text);
  font-size: var(--t-base);
  margin-left: 2px;
}
.cs-move {
  display: inline-flex;
  gap: 0;
}
.cs-move .cs-x {
  width: 26px;
  font: inherit;
  font-size: var(--t-base);
  font-weight: var(--w-heavy);
}
/* one line: dot · description · qty · rate or size · total · remove */
.cs-cols,
.cs-line {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) 72px 196px 160px 30px;
  gap: var(--sp-2);
  align-items: start;
  padding: 0 var(--sp-2);
}
.cs-cols {
  padding-top: var(--sp-2);
  padding-bottom: var(--sp-1);
  font-size: var(--t-sm);
  font-weight: var(--w-bold);
  color: var(--muted);
}
.cs-cols span:nth-child(3) {
  text-align: center;
}
.cs-cols span:nth-last-child(2) {
  text-align: right;
}
.cs-line {
  padding-top: var(--sp-1);
  padding-bottom: var(--sp-1);
}
.cs-dot::before {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cc);
  margin: var(--sp-3) 0 0 var(--sp-1);
}
.cs-in {
  width: 100%;
  height: var(--ctl-sm);
  padding: var(--sp-2) var(--sp-2);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: var(--t-md);
}
.cs-in::placeholder {
  color: var(--muted);
  opacity: 0.7;
}
.cs-in:hover {
  border-color: var(--line);
}
.cs-in:focus {
  outline: 0;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea.cs-in {
  height: auto;
  min-height: var(--ctl-sm);
  line-height: 20px;
  resize: none;
  overflow: hidden;
  display: block;
}
.cs-qty {
  text-align: center;
}
.cs-ratecell {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  min-width: 0;
}
.cs-ratecell .cs-in {
  text-align: right;
  min-width: 0;
}
.cs-day {
  flex: none;
  height: var(--ctl-sm);
  padding: 0 var(--sp-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: var(--t-xs);
  font-weight: var(--w-bold);
  cursor: pointer;
}
.cs-day:hover {
  opacity: 1;
  border-color: var(--accent);
  color: var(--accent-text);
}
.cs-day.on {
  opacity: 1;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-fill);
}
.cs-day[disabled] {
  cursor: default;
}
.cs-size {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}
.cs-size .cs-in {
  width: 58px;
  text-align: center;
  padding: var(--sp-2) var(--sp-1);
}
.cs-size em {
  font-style: normal;
  color: var(--muted);
  font-weight: var(--w-bold);
}
.cs-size small {
  font-size: var(--t-xs);
  color: var(--muted);
  white-space: nowrap;
  min-width: 48px;
  margin-left: 2px;
}
.cs-total {
  text-align: right;
  min-width: 0;
}
.cs-total .cs-price {
  text-align: right;
  font-weight: var(--w-bold);
}
.cs-total b {
  display: block;
  padding-top: var(--sp-2);
  font-size: var(--t-base);
  line-height: 18px;
}
.cs-total small {
  display: block;
  font-size: var(--t-xs);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cs-x {
  width: var(--ctl-sm);
  height: var(--ctl-sm);
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.cs-x .ic,
.cs-x svg {
  width: var(--ic-sm);
  height: var(--ic-sm);
}
.cs-x:hover,
.cs-x:focus-visible {
  opacity: 1;
  color: var(--danger-text);
  background: var(--surface-2);
}
.cs-x[disabled] {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}
.cs-line:hover .cs-x {
  opacity: 0.8;
}
/* under each category: + Add line, and its Rate Card prices */
.cs-cat-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-2) var(--sp-2) var(--sp-7);
}
.cs-add-line {
  margin: 0;
  padding: var(--sp-2) var(--sp-2);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--accent-text);
  font: inherit;
  font-size: var(--t-sm);
  font-weight: var(--w-bold);
  cursor: pointer;
}
.cs-add-line:hover {
  background: var(--accent-soft);
}
.cs-rc {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: var(--ctl-sm);
  padding: 0 var(--sp-2);
  border: 1px dashed color-mix(in srgb, var(--cc) 55%, var(--line));
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--cc) 6%, var(--surface));
  color: var(--text);
  font: inherit;
  font-size: var(--t-sm);
  font-weight: var(--w-bold);
  cursor: pointer;
}
.cs-rc small {
  font-weight: var(--w-semi);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.cs-rc:hover {
  border-style: solid;
  border-color: var(--cc);
}
.cs-rc.used {
  border-style: solid;
  border-color: var(--gp-pos);
  background: var(--pos-soft);
  color: var(--gp-pos);
}
.cs-rc.sm {
  height: var(--ctl-sm);
  padding: 0 var(--sp-2);
  font-size: var(--t-sm);
}
.cs-led-rc .cs-rc.used {
  color: var(--text);
}
/* "Add a category" and its buttons (also used on the Rate Card) */
.cs-addcat {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border: 1.5px dashed var(--line);
  border-radius: var(--r-sm);
}
.cs-hall .cst-hall-body > .cs-addcat:first-child {
  padding: var(--sp-5) var(--sp-3);
  flex-direction: column;
  align-items: flex-start;
}
.cs-addcat-lab {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  flex-wrap: wrap;
  font-size: var(--t-sm);
  font-weight: var(--w-bold);
  color: var(--muted);
}
.cs-addcat-lab small {
  font-weight: var(--w-regular);
  font-size: var(--t-sm);
  color: var(--muted);
}
.cs-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.cs-chip {
  --cc: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: var(--ctl-sm);
  padding: 0 var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--t-sm);
  font-weight: var(--w-bold);
  cursor: pointer;
}
.cs-chip u {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cc);
}
.cs-chip:hover {
  border-color: var(--cc);
  background: color-mix(in srgb, var(--cc) 10%, var(--surface));
}
.cs-other {
  display: inline-flex;
  gap: var(--sp-1);
}
.cs-other-in,
.rc2-catname {
  width: 130px;
  height: var(--ctl-sm);
  padding: 0 var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--t-sm);
}
.cs-other-in:focus,
.rc2-catname:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.cs-other-add {
  color: var(--accent-text);
}
.cs-keys {
  display: inline-block;
  margin-left: var(--sp-2);
  padding: 1px var(--sp-2);
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: var(--surface);
  font-size: var(--t-xs);
  font-weight: var(--w-semi);
  color: var(--muted);
}

/* ---------- Rate Card tab: one card per category ---------- */
.rcx-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-5);
  margin: 0 0 var(--sp-3);
}
.rcx-stats {
  font-size: var(--t-md);
  color: var(--muted);
}
.rcx-stats b {
  color: var(--text);
}
.rcx-all {
  margin-left: var(--sp-2);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-text);
  font: inherit;
  font-weight: var(--w-semi);
  cursor: pointer;
}
.rcx-all:hover {
  text-decoration: underline;
}
.rcx-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  font-size: var(--t-sm);
  color: var(--muted);
}
.rcx-legend i {
  display: inline-block;
  margin-right: var(--sp-2);
  padding: 1px var(--sp-2);
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-style: normal;
  font-weight: var(--w-bold);
  font-size: var(--t-xs);
}
.rcx-legend i.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-fill);
}
.rcx-card {
  --cc: var(--accent);
  margin: 0 0 var(--sp-3);
  overflow: hidden;
}
.rcx-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-3) 0 0;
  border-bottom: 1px solid var(--line-soft);
  border-left: 4px solid var(--cc);
}
.rcx-fold {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-2) var(--sp-3) var(--sp-3);
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.rcx-fold b {
  font-size: var(--t-base);
  letter-spacing: var(--tr-snug);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rcx-fold small {
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  color: var(--muted);
  white-space: nowrap;
}
.rcx-chev {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  color: var(--muted);
  transition: transform var(--dur-fast) var(--ease);
}
.rcx-chev svg {
  width: var(--ic-sm);
  height: var(--ic-sm);
}
.rcx-card.folded .rcx-chev {
  transform: rotate(-90deg);
}
.rcx-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--cc);
}
.rcx-basis {
  flex: none;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  white-space: nowrap;
}
.rcx-rm {
  flex: none;
  width: var(--ctl-sm);
  height: var(--ctl-sm);
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.rcx-rm svg {
  width: var(--ic-sm);
  height: var(--ic-sm);
}
.rcx-rm:hover {
  background: var(--danger-soft);
  color: var(--danger-text);
}
.rcx-card.folded .rcx-body {
  display: none;
}
.rcx-card.folded {
  margin-bottom: var(--sp-2);
}
.rcx-card.folded .rcx-head {
  border-bottom: 0;
}
.rcx-cols,
.rcx-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px 168px 100px;
  gap: var(--sp-2);
  align-items: center;
  padding: var(--sp-1) var(--sp-3) var(--sp-1) var(--sp-4);
}
.rcx-cols {
  padding-top: var(--sp-2);
  padding-bottom: var(--sp-1);
  font-size: var(--t-sm);
  font-weight: var(--w-bold);
  color: var(--muted);
}
.rcx-cols span:nth-child(2) {
  text-align: left;
}
.rcx-row {
  border-top: 1px solid var(--line-soft);
}
.rcx-cols + .rcx-row {
  border-top: 0;
}
.rcx-acts {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 2px;
}
.rcx-acts .cs-x[disabled] {
  opacity: 0.25;
  cursor: default;
}
.rcx-rate {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.rcx-per {
  flex: none;
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  color: var(--muted);
}
.rcx-rate > .num {
  flex: 1 1 90px;
  min-width: 0;
}
.rcx-rate .rcx-unit {
  flex: none;
  width: 92px;
  min-width: 0;
}
.rcx-rate em {
  flex: none;
  min-width: 50px;
  font-style: normal;
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  color: var(--muted);
  white-space: nowrap;
}
.rcx-seg {
  display: inline-flex;
  padding: 2px;
  border-radius: var(--r-sm);
  background: var(--chip-bg);
  justify-self: start;
}
.rcx-seg button {
  height: calc(var(--ctl-sm) - 4px);
  padding: 0 var(--sp-3);
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: var(--t-sm);
  font-weight: var(--w-bold);
  cursor: pointer;
}
.rcx-seg button:hover:not(.on) {
  color: var(--text);
}
.rcx-seg button.on {
  background: var(--surface);
  color: var(--accent-text);
  box-shadow: var(--shadow-xs);
}
.rcx-fixed {
  justify-self: start;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-sm);
  background: var(--chip-bg);
  color: var(--muted);
  font-size: var(--t-sm);
  font-weight: var(--w-bold);
  white-space: nowrap;
}
.rcx-add {
  background: var(--surface-2);
}
.rcx-add .rc2-in {
  background: var(--surface);
  border-color: var(--line);
}
.rcx-add .btn {
  height: var(--ctl-sm);
  padding: 0 var(--sp-3);
  border-radius: var(--r-sm);
  justify-self: end;
}
.rcx-newcat {
  margin: 0 0 var(--sp-3);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-md);
}
.rcx-newcat b {
  font-size: var(--t-md);
  color: var(--muted);
}
.rc2-in {
  width: 100%;
  height: var(--ctl-sm);
  padding: var(--sp-2) var(--sp-2);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--t-md);
}
.rc2-in:hover {
  border-color: var(--line);
  background: var(--surface-2);
}
.rc2-in:focus {
  outline: 0;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.rc2-in.num {
  text-align: right;
  font-weight: var(--w-bold);
  font-variant-numeric: tabular-nums;
}
.rc2-empty {
  padding: var(--sp-5);
  text-align: center;
  color: var(--muted);
  font-size: var(--t-md);
}

@media (max-width: 760px) {
  .cs-hall > .cst-hall-body {
    padding: var(--sp-2) var(--sp-2);
  }
  .cs-cols {
    display: none;
  }
  .cs-line,
  .cs-line.led {
    grid-template-columns: 14px 48px minmax(0, 1.35fr) minmax(0, 1fr) 30px;
    column-gap: var(--sp-2);
    grid-template-areas: 'dot desc desc desc x' '. qty rate total .';
    row-gap: var(--sp-2);
    padding-top: var(--sp-2);
    padding-bottom: var(--sp-2);
    border-bottom: 1px solid var(--line-soft);
  }
  .cs-line.led {
    grid-template-areas: 'dot desc desc desc x' '. qty size size .' '. total total total .';
  }
  .cs-dot {
    grid-area: dot;
  }
  .cs-desc {
    grid-area: desc;
  }
  .cs-qty {
    grid-area: qty;
  }
  .cs-ratecell {
    grid-area: rate;
  }
  .cs-size {
    grid-area: size;
  }
  .cs-total {
    grid-area: total;
  }
  .cs-x {
    grid-area: x;

    width: var(--ctl-sm);

    height: var(--ctl-sm);
  }
  .cs-ratecell .cs-in {
    padding: var(--sp-2) var(--sp-2);
  }
  .cs-rate {
    margin-left: 0;
    flex: 1 1 100%;
    order: 5;
  }
  .cs-cat-sum {
    margin-left: auto;
  }
  .cs-keys {
    display: none;
  }
  .rcx-cols {
    display: none;
  }
  .rcx-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: 'item del' 'rate rate' 'seg seg';
    row-gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-3);
  }
  .rcx-row > [data-f='item'],
  .rcx-row > [data-n='item'] {
    grid-area: item;
  }
  .rcx-row > .rcx-rate {
    grid-area: rate;
  }
  .rcx-row > .rcx-seg,
  .rcx-row > .rcx-fixed {
    grid-area: seg;
    justify-self: start;
  }
  .rcx-row > .rcx-acts,
  .rcx-row > .btn {
    grid-area: del;
  }
  .rcx-basis {
    display: none;
  }
  .rcx-head .rcx-fold small {
    margin-left: auto;
  }
  .cst-subtabs {
    display: flex;

    border-radius: var(--r-md);
  }
  .cst-subtab {
    flex: 1;
    padding: 0 var(--sp-2);
  }
}

/* ======================================================================================================
   2.18 refinements
   ====================================================================================================== */

/* Project editor: each number box sits in a labelled cell. Invisible on a computer (the column header names the box),
   a captioned cell on a phone. */
.item-row .cell {
  display: contents;
}
.item-row .cell > .cap {
  display: none;
}

/* A SubTotal / group-total row is tinted as a whole, so no white gap shows where its cells are laid out in a grid. */
.sheet-sub {
  background: color-mix(in srgb, var(--ic, var(--accent)) 11%, var(--surface));
}
.sheet-gtotal {
  background: color-mix(in srgb, var(--ic, var(--accent)) 24%, var(--surface));
}

@media (max-width: 760px) {
  /* ---- editor rows: description on top, then W / H / SQM, then Budget / Cost / GP, each box captioned and equally wide */
  .item-card .item-row.pe-grid,
  .item-card.is-led .item-row.pe-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    column-gap: var(--sp-2);
    row-gap: var(--sp-2);
    align-items: end;
  }
  .item-row .row-no,
  .item-row .row-remove {
    align-self: center;
    justify-self: center;
  }
  .item-row .cell {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    min-width: 0;
  }
  .item-row .cell > .cap {
    display: block;
    padding-left: 2px;
    font-size: var(--t-sm);
    font-weight: var(--w-semi);
    color: var(--muted);
  }
  .item-row .c-w {
    grid-area: w;
  }
  .item-row .c-h {
    grid-area: h;
  }
  .item-row .c-sq {
    grid-area: sq;
  }
  .item-row .c-b {
    grid-area: bud;
  }
  .item-row .c-c {
    grid-area: cost;
  }
  .item-row .c-g {
    grid-area: gp;
  }
  .item-row .cell .fld.num {
    width: 100%;
    padding-left: var(--sp-2);
    padding-right: var(--sp-2);
    text-align: right;
    font-variant-numeric: tabular-nums;
  }
  .item-row .cell .sz-out,
  .item-row .cell input.gp {
    width: 100%;
    height: 44px;
    display: grid;
    place-items: center;
    text-align: center;
  }
  /* the item bar's name and supplier fields keep their width, the delete button its corner */
  .item-card .item-foot.pe-grid {
    row-gap: var(--sp-2);
  }

  /* ---- the list summary: a small header line (count, Export) and three figures that are all visible, not a strip to swipe */
  .list-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--sp-2) var(--sp-2);
    align-items: end;
    overflow: visible;
    white-space: normal;
    margin: 0 0 var(--sp-2);
    padding: 0;

    font-size: var(--t-sm);
  }
  .list-summary > span {
    min-width: 0;
  }
  .list-summary > span:first-child {
    grid-column: 1 / 3;
    grid-row: 1;
    align-self: center;
    font-size: var(--t-md);
  }
  .list-summary .xl-btn {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    position: static;
    margin: 0;
    box-shadow: var(--shadow-sm);
  }
  /* Budget / Cost / GP: label small on top, figure below, like the project cards */
  .list-summary > span:not(:first-child):not(.sum-note):not(.cur-note) {
    grid-row: 2;
    display: block;
    font-size: var(--t-sm);
    font-weight: var(--w-semi);
  }
  .list-summary > span:not(:first-child):not(.sum-note):not(.cur-note) b {
    display: block;
    margin-top: 1px;
    font-size: var(--t-base);
    letter-spacing: var(--tr-snug);
  }
  .list-summary .sum-note,
  .list-summary .cur-note {
    grid-column: 1 / -1;
    margin: 0;
    font-size: var(--t-sm);
  }
  .list-summary .sum-note {
    grid-column: 1 / 3;
    grid-row: 3;
  }
  .list-summary .cur-note {
    grid-column: 3;
    grid-row: 3;
    text-align: right;
    white-space: nowrap;
  } /* ---- notices while a window is open: at the top, clear of the window's own buttons */
  body.modal-open .toasts {
    top: calc(10px + var(--sat));
    bottom: auto;
  }

  /* ---- editor totals: Budget / Cost / GP (and LED area) share the width, label above figure, nothing cut off */
  .pe-total {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
    gap: var(--sp-2);
  }
  .pe-chip.pe-area {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: baseline;
    gap: var(--sp-2);
  }
  .pe-chip {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: var(--sp-2) var(--sp-2);
    border-radius: var(--r-sm);
    min-width: 0;
  }
  .pe-chip span {
    font-size: var(--t-xs);
    white-space: nowrap;
  }
  .pe-chip b {
    font-size: var(--t-base);
    white-space: nowrap;
  }
}

/* Password box with a Show / Hide toggle */
.pw-wrap {
  position: relative;
}
.pw-wrap .input {
  width: 100%;
  padding-right: 66px;
}
.pw-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  padding: var(--sp-2) var(--sp-2);
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--accent-text);
  font: inherit;
  font-size: var(--t-md);
  font-weight: var(--w-semi);
  cursor: pointer;
}
.pw-toggle:hover {
  background: var(--accent-soft);
}

/* ---------- 2.20: Video lines have their own W × H ---------- */
.cs-descwrap {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
}
.cs-descwrap .cs-size {
  padding-left: 2px;
}
@media (max-width: 760px) {
  .cs-descwrap {
    grid-area: desc;
  }
}

/* ---------- 2.28: Report ---------- */
.rp-vs {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  white-space: nowrap;
}
.rp-delta {
  display: inline-block;
  font-style: normal;
  font-weight: var(--w-bold);
  font-size: var(--t-sm);
  white-space: nowrap;
}
.rp-delta.up {
  color: var(--gp-pos);
}
.rp-delta.down {
  color: var(--danger-text);
}
.rp-look {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin: var(--sp-3) 0 0;
}
.rp-look > span {
  font-size: var(--t-sm);
  font-weight: var(--w-bold);
  color: var(--muted);
  margin-right: 2px;
}
.rp-look button {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 0 var(--sp-3);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, var(--line));
  border-radius: var(--r-pill);
  background: var(--warn-soft);
  color: var(--warn);
  font: inherit;
  font-size: var(--t-md);
  font-weight: var(--w-semi);
  cursor: pointer;

  height: var(--ctl-sm);
}
.rp-look button b {
  font-weight: var(--w-heavy);
}
.rp-look button small {
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  opacity: 0.85;
}
.rp-look button.bad {
  border-color: color-mix(in srgb, var(--danger) 30%, var(--line));
  background: var(--danger-soft);
  color: var(--danger-text);
}
.rp-look button:hover {
  filter: brightness(0.97);
}
.rp-note {
  padding: var(--sp-2) 2px 2px;
  font-size: var(--t-sm);
  color: var(--muted);
}

/* ---------- 2.28: Costing ---------- */
.cst-sum {
  margin: 0 2px var(--sp-2);
  font-size: var(--t-md);
  color: var(--muted);
}
.cst-sum b {
  color: var(--text);
}
.rc2-in.rcx-name {
  display: block;
  height: auto;
  min-height: var(--ctl-sm);
  line-height: 20px;
  resize: none;
  overflow: hidden;
}

/* The Report has its own year buttons. */
body[data-section='reports'] .filter-group:has(#filterYear) {
  display: none;
}
@media (max-width: 760px) {
  /* a filter you came in with, and the way out of it, are never scrolled off the edge */
  .filter-bar.active .filter-clear {
    order: -1;
  }
  .rp-tiles .kpi-tile em {
    white-space: normal;
  }
  /* Video has no unit box, so its fixed "per m² · day" fits beside the rate */
  .rcx-row:has(.rcx-fixed) {
    grid-template-areas: 'item del' 'rate seg';
  }
  .rcx-row:has(.rcx-fixed) > .rcx-fixed {
    justify-self: end;
  }
  /* on a phone the sheet's lines come first: the how-to line pushed them below the fold */
  .cst-hint-bar {
    display: none;
  }
}

/* ---------- 2.29: Video rows have sizes ---------- */
.sheet-sub .c-sq,
.sheet-gtotal .c-sq {
  white-space: nowrap;
}

/* ---------- 2.30: the supplier box ---------- */
.item-sup {
  -webkit-appearance: none;
  appearance: none;
}
.item-sup::-webkit-search-decoration,
.item-sup::-webkit-search-cancel-button {
  -webkit-appearance: none;
  display: none;
}
.sup-pop {
  z-index: var(--z-menu);
  min-width: 220px;
  max-width: min(360px, calc(100vw - 16px));
}
.sup-pop button.on {
  background: var(--accent-soft);
  color: var(--accent-text);
}
@media (max-width: 760px) {
  /* a finger-sized arrow: the only thing that opens a project */
  .chevron {
    width: var(--ctl-lg);
    height: var(--ctl-lg);
    margin: -13px -15px 0;
  }
}

/* ---------- 2.31: Rate Card items in the project editor ---------- */
.pe-rcs {
  --cc: var(--ic, var(--accent));
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3) var(--sp-1) 44px;
}
.pe-rcs[hidden] {
  display: none;
}
.pe-rcs-lab {
  font-size: var(--t-sm);
  font-weight: var(--w-bold);
  color: var(--muted);
  margin-right: 2px;
}
@media (max-width: 760px) {
  .pe-rcs {
    padding: var(--sp-2) var(--sp-2) var(--sp-1);
  }
}

/* ---------- 2.32: Qty on project rows, and compact item cards ---------- */
/* a Qty column after the description */
.pe-grid {
  grid-template-columns:
    34px minmax(150px, 1fr) 64px minmax(88px, 0.55fr) minmax(88px, 0.55fr) minmax(80px, 0.45fr)
    32px;
  padding: var(--sp-1) var(--sp-3);
}
.item-card.is-led .pe-grid,
.group-total.is-led {
  grid-template-columns:
    34px minmax(140px, 1.5fr) 64px 80px 80px 96px minmax(88px, 0.9fr) minmax(88px, 0.9fr) minmax(80px, 0.7fr)
    32px;
}
.group-total {
  grid-template-columns:
    34px minmax(150px, 1fr) 64px minmax(88px, 0.55fr) minmax(88px, 0.55fr) minmax(80px, 0.45fr)
    32px;
}
.item-foot .pe-pill {
  grid-column: 2/4;
}
.item-card.is-led .item-foot .pe-pill {
  grid-column: 3/7;
}
.sub-total-row .lab,
.group-total .lab {
  grid-column: 1/4;
}
.item-card.is-led .sub-total-row .lab,
.group-total.is-led .lab {
  grid-column: 1/6;
}
/* tighter: smaller bars and boxes, less space between them */
.item-band-row {
  padding: var(--sp-2) var(--sp-3);
}
.item-card .fld {
  height: var(--ctl-sm);
  font-size: var(--t-base);
}
.sz-out {
  padding: var(--sp-2) 0;
}
.pe-cols {
  padding-top: var(--sp-2);
  padding-bottom: 0;
}
.sub-total-row {
  padding-top: var(--sp-2);
  padding-bottom: var(--sp-2);
  font-size: var(--t-base);
}
.pe-items {
  gap: var(--sp-3);
}
/* one line under the rows: + Add row, the Rate Card items, and the shared budget & cost on request */
.pe-acts {
  --cc: var(--ic, var(--accent));
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-2);
  padding: var(--sp-2) var(--sp-3) var(--sp-2);
}
.pe-acts .pe-addrow {
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--t-sm);
}
.pe-acts .pe-rcs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
  padding: 0;
}
.pe-acts .pe-rcs[hidden] {
  display: none;
}
.pe-shared-btn {
  margin-left: auto;
  padding: 0 var(--sp-3);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  cursor: pointer;

  height: var(--ctl-sm);
}
.pe-shared-btn:hover {
  background: var(--chip-bg);
  color: var(--text);
}
.item-card .item-foot[hidden] {
  display: none;
}
.item-foot {
  padding-top: var(--sp-1);
  padding-bottom: var(--sp-2);
}
/* Documents: one line until something is attached */
.attach-section {
  padding: var(--sp-2) var(--sp-3);
}
.attach-list:empty {
  display: none;
}
.attach-label:has(+ .attach-list:empty) {
  margin-bottom: 0;
}
/* the project view: "× 2" after a row's description */
.sh-qty {
  margin-left: var(--sp-1);
  color: var(--muted);
  font-weight: var(--w-semi);
  white-space: nowrap;
}
@media (max-width: 760px) {
  .item-card .item-row.pe-grid,
  .item-card.is-led .item-row.pe-grid {
    grid-template-areas: 'no desc desc desc qty rm' 'bud bud cost cost gp gp';
  }
  .item-card.is-led .item-row.pe-grid {
    grid-template-areas: 'no desc desc desc qty rm' 'w w h h sq sq' 'bud bud cost cost gp gp';
  }
  .item-row .c-q {
    grid-area: qty;
  }
  .item-card .fld {
    height: var(--ctl-md);
  }
  .item-card .item-foot .pe-pill,
  .item-card.is-led .item-foot .pe-pill {
    grid-column: 1/-1;
    justify-self: start;
  }
  .pe-acts {
    padding: var(--sp-2) var(--sp-2) var(--sp-2);
  }
}
.pe-add-item {
  white-space: nowrap;
}

/* keyboard focus: the month columns and the screen table's rows show a ring, not just a tooltip or a tint */
.rp-m-col:focus-visible,
.rp-lt-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
/* a tap acts at once: no double-tap zoom wait on anything you press */
button,
a,
select,
input,
textarea,
label,
[role='button'] {
  touch-action: manipulation;
}

/* ===== both looks: small finishing touches ===== */
/* An item's own colour used as text is deepened a little, so amber or teal on its own pale tint still reads (4.5:1 or better). */
:is(
  .sheet-row > div.sq,
  .sup-pill small,
  .item-card .row-no,
  .sz-out,
  .pe-addrow:not(:hover),
  .sub-total-row .st-a,
  .group-total .st-a
) {
  color: color-mix(in srgb, var(--ic) 66%, black);
}
/* In the dark theme an item's own colour is lightened where it is used as text, so a purple or teal label stays readable. */
@media screen {
  :root[data-theme='dark']
    :is(
      .sheet-row > div.sq,
      .sup-pill small,
      .item-card .row-no,
      .sz-out,
      .pe-addrow:not(:hover),
      .sub-total-row .st-a,
      .group-total .st-a
    ) {
    color: color-mix(in srgb, var(--ic) 60%, white);
  }
}
/* Titles and short lines break evenly instead of leaving one word alone on the last line. */
h1,
h2,
h3,
.empty p,
.dlg-b .msg {
  text-wrap: balance;
}

/* ===== The look: a ruled page =====
   Figures and titles in a serif with sturdy numerals, sections divided by a thin rule instead of boxed in white cards, and
   one filled block per page (the Report's hero) as the single emphasis. Buttons, tags, filters, menus, dialogs and the
   project windows stay in the sans. These rules come after the component rules above and override them. */
/* serif for titles */
:is(
  .login-card h1,
  .brand-name,
  .modal-title,
  .dlg-h h3,
  .empty h3,
  .cst-onboard h3,
  .grp-name,
  .proj-name,
  .cst-sheet-name,
  .sheet-bandrow > div.bname,
  .dash-panel h3
) {
  font-family: var(--font-fig);
  font-weight: var(--w-semi);
  letter-spacing: var(--tr-snug);
}
.brand-name {
  font-weight: var(--w-bold);
}
/* serif for every figure: tabular lining numerals so money columns line up */
:is(
  .num,
  .list-summary b,
  .stat b,
  .grp-fig b,
  .sheet-row > div.n,
  .item-card .fld.num,
  .item-card input.gp,
  .sz-out,
  .sub-total-row,
  .group-total,
  .pe-chip b,
  .dash-value,
  .rp-big,
  .rp-leg b,
  .rp-tape-key b,
  .rp-chip b,
  .kpi-tile b,
  .rp-led-stats b,
  .rp-lt-head span:not(:first-child),
  .rp-lt-row span:not(:first-child),
  .rp-m-val,
  .cst-sheet-total b,
  .sh-legend b,
  .cst-hall-subtotal b,
  .cst-grand b em,
  .cs-cat-sum b,
  .cs-total .cs-price,
  .cs-total b,
  .cs-in,
  .rc2-in
) {
  font-family: var(--font-fig);
  font-variant-numeric: lining-nums tabular-nums;
}
:is(.kpi-tile b, .rp-led-stats b, .cst-sheet-total b, .cst-grand b em, .stat b, .dash-value) {
  font-weight: var(--w-semi);
  letter-spacing: var(--tr-snug);
}
/* sections: a rule on top, no box */
:is(.kpi-tile, .dash-panel, .rcx-card) {
  background: transparent;
  border: 0;
  border-top: 1px solid var(--text-2);
  border-radius: 0;
  box-shadow: none;
  padding: var(--sp-4) 0 var(--sp-5);
}
.rcx-card {
  padding: 0;
}
.rcx-head {
  background: transparent;
}
.rp-tiles {
  column-gap: var(--sp-6);
}
.dash-panel h3 {
  font-size: var(--t-lg);
  color: var(--text);
}
.dash-panel h3 small {
  font-family: var(--font);
  letter-spacing: 0;
}
/* the Projects and Upcoming lists: month headings carry the rule, projects are ruled rows */
.grp-head {
  border-top: 1px solid var(--text-2);
  padding-top: var(--sp-3);
  padding-right: var(--sp-4);
  margin: var(--sp-6) 0 var(--sp-1);
}
.grp-fig:last-child {
  padding-right: 0;
}
.grp-head:first-child {
  margin-top: var(--sp-1);
}
.project-wrap {
  background: transparent;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  margin-bottom: 0;
}
.grp-head + .project-wrap {
  border-top: 0;
}
.project-wrap.expanded {
  border-color: var(--line);

  box-shadow: none;
}
.proj-head {
  border-radius: 0;
}
/* the GP of a project is coloured figures, not a tinted block */
:is(.stat-gp, .stat-gp.gp-pos, .stat-gp.gp-neg, .stat-gp.gp-low) {
  background: none;
  border-radius: 0;
  padding: 0;
}
/* the sheets in Costing: ruled rows */
.cst-sheet-card {
  background: transparent;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  margin-bottom: 0;
}
.cst-sheet-card:hover {
  background: var(--surface-2);
} /* lists set in the serif (names, dates, amounts); buttons, tags, filters and fields stay in the sans */
:is(.proj-head, .sheet, .dash-row, .rp-lt-head, .rp-lt-row, .cst-sheet-card, .list-summary) {
  font-family: var(--font-fig);
  font-size-adjust: 0.5;
}
:is(.proj-head, .sheet, .dash-row, .rp-lt-head, .rp-lt-row, .cst-sheet-card, .list-summary)
  :is(button, .btn, .xl-btn, .proj-tag, .grp-now, .sh-chip, .pill, .badge, input, select, textarea) {
  font-family: var(--font);
  font-size-adjust: none;
}
/* on a phone the Budget / Cost / GP tiles above the list become three ruled figures */
@media (max-width: 760px) {
  .list-summary > span:not(:first-child):not(.sum-note):not(.cur-note) {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    border-top: 1px solid var(--text-2);
    padding: var(--sp-2) 0 0;
  }
}
#reportList > * + * {
  margin-top: var(--sp-6);
}
.rp-cols {
  column-gap: var(--sp-7);
}
.rp-col {
  gap: var(--sp-6);
}
/* the sections of the page are text tabs on a rule, like the chapters of a ledger (a switch between a few choices stays a tray) */
.tabs {
  background: transparent;
  padding: 0;
  gap: var(--sp-5);
}
