/* Entirely Sales.
   Built on the estate's design tokens (web/tokens/, the same copies every staff app carries):
   Sand page, Moss header, white panels, Neon accent, Bagoss Standard headings, Outfit for everything else.
   The header, panel and capsule buttons match Entirely Procurement, so the staff apps read as one product. */

@import url('tokens/colors.css');
@import url('tokens/fonts.css');
@import url('tokens/spacing.css');
@import url('tokens/typography.css');

/* [hidden] must outrank any later display rule, or the fixed full-screen gate stays on top
   of a rendered app with nothing in the console to say why. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }

:root {
  --field-border: rgba(0, 0, 0, 0.2);
  --field-height: 44px;
  --danger: #b3261e;
  --ok-ink: #1f5c36;
  --wait-ink: #6b5a00;
}

body {
  margin: 0;
  background: var(--surface-page);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  letter-spacing: var(--tracking-body);
  -webkit-text-size-adjust: 100%;
}

/* Form controls take the page font; browsers otherwise use their own. */
button, input, select, textarea { font-family: inherit; letter-spacing: inherit; }

/* ------------------------------------------------------------------ header */
.bar {
  background: var(--surface-moss);
  color: var(--text-on-dark);
  position: sticky;
  top: 0;
  z-index: 2;
  padding-top: env(safe-area-inset-top);
}
.bar-in {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  min-height: 60px;
}
.brand { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.mark { width: var(--stroke-heavy); height: 34px; background: var(--accent); display: block; flex: none; }
.bar h1 {
  font-family: var(--font-display);
  font-weight: var(--weight-medium);
  font-size: var(--fs-h3);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-h3);
  margin: 0;
}
.bar p { margin: 0; font-size: var(--fs-caption); color: rgba(255, 255, 255, 0.72); }
.who { display: flex; align-items: center; gap: var(--space-3); font-size: var(--fs-caption); color: rgba(255, 255, 255, 0.85); flex-wrap: wrap; }
#whoami { word-break: break-all; }
.tier {
  border: var(--stroke-thin) solid var(--border-on-dark);
  border-radius: var(--radius-capsule);
  padding: 2px var(--space-3);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caption);
  color: var(--accent);
}

.banner {
  background: var(--color-cream);
  color: var(--text-primary);
  font-size: var(--fs-small);
  padding: var(--space-3) var(--space-4);
  text-align: center;
}

main {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) calc(var(--space-6) + env(safe-area-inset-bottom));
}

/* -------------------------------------------------------------------- tabs */
.tabs { display: flex; gap: var(--space-2); margin: 0 0 var(--space-4); overflow-x: auto; }
.tab {
  font-size: var(--fs-small);
  font-weight: var(--weight-medium);
  padding: var(--space-2) var(--space-4);
  min-height: 40px;
  border-radius: var(--radius-capsule);
  border: var(--stroke-thin) solid var(--border-subtle);
  background: var(--surface-card);
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { border-color: var(--field-border); }
.tab[aria-selected="true"] { background: var(--surface-moss); color: var(--text-on-dark); border-color: var(--surface-moss); }

/* ------------------------------------------------------------------ panels */
.panel {
  background: var(--surface-card);
  border: var(--stroke-thin) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.panel h2 {
  font-family: var(--font-display);
  font-weight: var(--weight-medium);
  font-size: var(--fs-h4);
  line-height: var(--lh-heading);
  letter-spacing: var(--tracking-tight);
  margin: 0 0 var(--space-4);
}
/* A section inside a panel: small, tracked capitals. */
.subhead {
  font-size: var(--fs-caption);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caption);
  color: var(--text-secondary);
  margin: 0 0 var(--space-3);
}
.divider { border: 0; border-top: var(--stroke-thin) solid var(--border-subtle); margin: var(--space-5) 0; }
p.lede { margin: -8px 0 var(--space-5); color: var(--text-secondary); font-size: var(--fs-small); max-width: 60ch; }
.row { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.between .subhead { margin: 0; }
.gap-top { margin-top: var(--space-5); }
.status { font-size: var(--fs-small); color: var(--text-secondary); margin: var(--space-2) 0; }
.status:empty { display: none; }

/* A panel title with its one action on the right. */
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin: 0 0 var(--space-4); }
.panel-head h2, .panel-head .subhead { margin: 0; }
.panel-head + .status, h3 + .status { margin-top: 0; }
.detail-block { margin-top: var(--space-5); padding-top: var(--space-5); border-top: var(--stroke-thin) solid var(--border-subtle); }
button.btn.back { margin: 0 0 var(--space-4); padding-left: var(--space-3); }
button.btn.back::before { content: '\2190'; margin-right: var(--space-2); }

/* ------------------------------------------------------------------ fields */
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4) var(--space-4); }
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  font-size: var(--fs-small);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
}
.field.wide { grid-column: 1 / -1; }
@media (max-width: 560px) { .fields { grid-template-columns: 1fr; } }

.field .label { color: var(--text-primary); }
.field .opt { margin-left: var(--space-1); font-weight: var(--weight-regular); color: var(--text-muted); }
.hint { font-size: var(--fs-caption); font-weight: var(--weight-regular); color: var(--text-secondary); line-height: 1.4; }
.hint.error { color: var(--danger); }

input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  /* 16px or more, or iOS Safari zooms the page on focus. */
  font-size: max(16px, var(--fs-body));
  font-weight: var(--weight-regular);
  line-height: var(--lh-tight);
  color: var(--text-primary);
  background-color: var(--surface-card);
  border: var(--stroke-thin) solid var(--field-border);
  border-radius: var(--radius-md);
  padding: 0 var(--space-3);
  width: 100%;
  height: var(--field-height);
  margin: 0;
  transition: border-color var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard);
}
textarea { height: auto; min-height: 120px; padding: var(--space-3); line-height: var(--lh-body); resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 1; }
input:hover, select:hover { border-color: rgba(0, 0, 0, 0.35); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus-ring); box-shadow: 0 0 0 3px rgba(0, 62, 38, 0.15); }
input:user-invalid { border-color: var(--danger); }
/* One chevron for every select, so they match the inputs in height and look. */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: var(--space-7);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%232e2e2e' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  cursor: pointer;
}
input[type="date"] { min-width: 0; }
input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.6; }
input[type="search"] { -webkit-appearance: none; }

.actions-row { grid-column: 1 / -1; display: flex; gap: var(--space-4); align-items: center; flex-wrap: wrap; margin-top: var(--space-2); }
.actions-row .status { margin: 0; }

/* A group of fields inside a form, such as the contact person. */
.group { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); margin: var(--space-2) 0 0; padding: var(--space-5) 0 0;
  border: 0; border-top: var(--stroke-thin) solid var(--border-subtle); min-width: 0; }
.group .group-title { grid-column: 1 / -1; margin: 0; }
.group .group-hint { grid-column: 1 / -1; margin: calc(-1 * var(--space-3)) 0 0; }
@media (max-width: 560px) { .group { grid-template-columns: 1fr; } }

/* Customer picker on the opportunity form. */
.chosen {
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-3);
  min-height: var(--field-height); padding: var(--space-1) var(--space-1) var(--space-1) var(--space-3);
  border: var(--stroke-thin) solid var(--focus-ring); border-radius: var(--radius-md); background: var(--color-sage);
  font-size: var(--fs-body); font-weight: var(--weight-medium); color: var(--text-primary);
}
.pick-list { list-style: none; margin: 0; padding: 0; max-height: 264px; overflow-y: auto;
  border: var(--stroke-thin) solid var(--border-subtle); border-radius: var(--radius-md); }
.pick-list:empty { display: none; }
.pick-list li + li { border-top: var(--stroke-thin) solid var(--border-subtle); }
button.pick { display: flex; justify-content: space-between; gap: var(--space-3); width: 100%; text-align: left; background: none; border: 0;
  padding: var(--space-3); font-size: var(--fs-body); font-weight: var(--weight-regular); color: var(--text-primary); cursor: pointer; }
button.pick:hover, button.pick:focus-visible { background: var(--color-sage); }
button.pick .meta { color: var(--text-secondary); font-size: var(--fs-small); }
.pick-empty { padding: var(--space-3); font-size: var(--fs-small); font-weight: var(--weight-regular); color: var(--text-secondary); }
.note {
  grid-column: 1 / -1;
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-sand);
  font-size: var(--fs-small);
  font-weight: var(--weight-regular);
  color: var(--text-secondary);
}
.problems { grid-column: 1 / -1; color: var(--danger); font-size: var(--fs-small); margin: 0; padding-left: var(--space-5); }
.problems:empty { display: none; }

/* ----------------------------------------------------------------- buttons */
/* Capsule CTAs, per the brand's pill UI. */
button.btn {
  font-size: var(--fs-body);
  font-weight: var(--weight-medium);
  line-height: 1;
  padding: 0 var(--space-5);
  height: var(--field-height);
  border-radius: var(--radius-capsule);
  border: var(--stroke-thin) solid var(--field-border);
  background: var(--surface-card);
  color: var(--text-primary);
  cursor: pointer;
}
button.btn:hover:not(:disabled) { border-color: var(--text-primary); }
button.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--text-on-accent); }
button.btn.primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
button.btn:disabled { opacity: 0.45; cursor: default; }
button.btn.small { font-size: var(--fs-small); padding: 0 var(--space-4); height: 32px; }
.who button.btn { background: transparent; border-color: var(--border-on-dark); color: var(--text-on-dark); }
.who button.btn:hover { border-color: var(--text-on-dark); }
button:focus-visible, .list button.item:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* -------------------------------------------------------------------- lists */
.list { list-style: none; margin: var(--space-2) 0 0; padding: 0; }
.list li { border-top: var(--stroke-thin) solid var(--border-subtle); }
.list li:last-child { border-bottom: var(--stroke-thin) solid var(--border-subtle); }
.list .item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-2);
  font-size: var(--fs-body);
  font-weight: var(--weight-medium);
  line-height: var(--lh-tight);
  text-align: left;
  color: var(--text-primary);
  background: none;
  border: 0;
}
.list button.item { cursor: pointer; border-radius: var(--radius-sm); }
.list button.item:hover { background: var(--color-sand); }
.item .meta { display: inline-block; margin-top: 4px; color: var(--text-secondary); font-size: var(--fs-small); font-weight: var(--weight-regular); }
.item .amount { font-variant-numeric: tabular-nums; white-space: nowrap; }

.badge {
  flex: none;
  border-radius: var(--radius-capsule);
  padding: 2px var(--space-2);
  font-size: var(--fs-caption);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  background: var(--color-heather);
  color: var(--text-secondary);
}
.badge.ok { background: var(--color-sage); color: var(--ok-ink); }
.badge.wait { background: var(--color-cream); color: var(--wait-ink); }

/* ------------------------------------------------------------------ detail */
#backToCustomers { margin-bottom: var(--space-4); }
.facts { display: grid; grid-template-columns: 11em 1fr; gap: var(--space-3) var(--space-4); margin: 0 0 var(--space-5); }
.facts dt { font-size: var(--fs-small); color: var(--text-secondary); }
.facts dd { margin: 0; word-break: break-word; }
@media (max-width: 560px) {
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: var(--space-3); }
}

/* -------------------------------------------------------------------- gate */
.gate {
  position: fixed;
  inset: 0;
  background: var(--surface-page);
  display: grid;
  place-items: center;
  padding: var(--space-5);
  z-index: 5;
}
.gate-card {
  background: var(--surface-card);
  border: var(--stroke-thin) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-5);
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-sm);
}
.gate-card h2 { font-family: var(--font-display); font-weight: var(--weight-medium); font-size: var(--fs-h4); margin: 0 0 var(--space-3); }
.gate-card p { white-space: pre-line; color: var(--text-secondary); margin: 0 0 var(--space-4); }

/* ---------------------------------------------------------------- activities */
.chips { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.chip-choice { position: relative; }
.chip-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-choice span {
  display: inline-flex; align-items: center; height: 40px; padding: 0 var(--space-4);
  border: var(--stroke-thin) solid var(--field-border); border-radius: var(--radius-capsule);
  font-size: var(--fs-small); font-weight: var(--weight-medium); color: var(--text-primary); background: var(--surface-card); cursor: pointer;
}
.chip-choice input:checked + span { background: var(--surface-moss); border-color: var(--surface-moss); color: var(--text-on-dark); }
.chip-choice input:focus-visible + span { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.activity .kind {
  display: inline-block; margin-right: var(--space-1); padding: 1px var(--space-2); border-radius: var(--radius-capsule);
  font-size: var(--fs-caption); font-weight: var(--weight-semibold); background: var(--color-heather); color: var(--text-secondary); vertical-align: 1px;
}
.activity .kind-call { background: var(--color-sage); color: var(--ok-ink); }
.activity .kind-meeting { background: var(--color-cream); color: var(--wait-ink); }
.activity .notes { display: block; margin-top: var(--space-1); font-size: var(--fs-small); font-weight: var(--weight-regular); color: var(--text-secondary); white-space: pre-line; }

/* ---------------------------------------------------------------- browsing */
.segmented { display: inline-flex; padding: 3px; margin: 0 0 var(--space-4); border-radius: var(--radius-capsule); background: var(--color-heather); }
.segmented button {
  height: 34px; padding: 0 var(--space-4); border: 0; border-radius: var(--radius-capsule); background: transparent;
  font-size: var(--fs-small); font-weight: var(--weight-medium); color: var(--text-secondary); cursor: pointer;
}
.segmented button[aria-checked="true"] { background: var(--surface-card); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.search-field { margin-bottom: var(--space-3); }
/* Letters wrap on wide screens; on a phone they are one row that scrolls sideways (see the phone rules). */
.letters { display: flex; flex-wrap: wrap; gap: 2px; margin: 0 0 var(--space-2); padding-bottom: 4px; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.letters button {
  flex: none; min-width: 30px; height: 32px; padding: 0 var(--space-2); border: 0; border-radius: var(--radius-sm); background: none;
  font-size: var(--fs-small); font-weight: var(--weight-medium); color: var(--text-secondary); cursor: pointer;
}
.letters button:hover { background: var(--color-sand); color: var(--text-primary); }
.letters button[aria-pressed="true"] { background: var(--surface-moss); color: var(--text-on-dark); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-4); }
.page-info { font-size: var(--fs-small); color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ phones */
@media (max-width: 560px) {
  .bar-in { padding: var(--space-2) var(--space-4); min-height: 52px; gap: var(--space-2); }
  .bar p { display: none; }
  .mark { height: 26px; }
  .who { gap: var(--space-2); }
  #whoami { display: none; }
  .tier { padding: 1px var(--space-2); font-size: 10px; }
  .who button.btn.small { height: 30px; padding: 0 var(--space-3); }
  main { padding: var(--space-3) var(--space-3) calc(var(--space-6) + env(safe-area-inset-bottom)); }
  .tabs { margin-bottom: var(--space-3); }
  .panel { padding: var(--space-4); border-radius: var(--radius-md); }
  .panel h2 { font-size: var(--fs-h3); }
  .panel-head { margin-bottom: var(--space-3); }
  p.lede { margin-bottom: var(--space-4); }
  /* The fade on the right says the row scrolls. */
  .letters { flex-wrap: nowrap; overflow-x: auto; -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); mask-image: linear-gradient(to right, #000 85%, transparent); padding-right: var(--space-6); }
  .segmented { display: flex; }
  .segmented button { flex: 1; }
  .list .item { padding: var(--space-3) var(--space-1); }
  .actions-row button.btn.primary { width: 100%; }
  .chosen { flex-wrap: wrap; }
  .pager .btn { flex: none; }
}

/* ----------------------------------------------------------------- desktop */
/* Wide screens use the width: lists in two columns, the customer page beside its activities, forms spread out.
   The phone layout above is the base; these only add columns. */
@media (min-width: 1024px) {
  main { padding-top: var(--space-5); }
  .panel { padding: var(--space-6); }
  /* Newspaper columns: an alphabetical list reads down the first column, then the second. */
  #customerList, #oppList { columns: 2; column-gap: var(--space-7); }
  #customerList li, #oppList li { break-inside: avoid; border-top: 0; border-bottom: var(--stroke-thin) solid var(--border-subtle); }
  .search-field { max-width: 560px; }
  .detail-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--space-7); align-items: start; }
  .detail-side { margin-top: 0; padding-top: 0; border-top: 0; padding-left: var(--space-7); border-left: var(--stroke-thin) solid var(--border-subtle); }
  .facts { margin-bottom: 0; }
  .fields { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-5); }
  .group { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  p.lede { max-width: 72ch; }
}

/* ------------------------------------------------------------------ quotes */
.quote-grid { display: grid; gap: var(--space-5); }
.quote-groups { display: grid; gap: var(--space-2); margin-top: var(--space-5); }
.pick-group { border: var(--stroke-thin) solid var(--border-subtle); border-radius: var(--radius-md); padding: 0 var(--space-4); background: var(--surface-card); }
.pick-group > summary {
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); list-style: none; cursor: pointer;
  min-height: 48px; font-weight: var(--weight-semibold);
}
.pick-group > summary::-webkit-details-marker { display: none; }
.pick-group > summary::after { content: '+'; font-weight: var(--weight-regular); color: var(--text-secondary); }
.pick-group[open] > summary::after { content: '–'; }
.pick-group[open] { padding-bottom: var(--space-3); }
.pick-group .count { margin-left: auto; font-size: var(--fs-small); font-weight: var(--weight-medium); color: var(--ok-ink); }
.pick-group > .hint { margin: 0 0 var(--space-2); }
.pick-row { display: grid; grid-template-columns: 22px 1fr auto; gap: var(--space-3); align-items: center; padding: var(--space-2) 0; border-top: var(--stroke-thin) solid var(--border-subtle); cursor: pointer; }
.pick-row input[type="radio"], .pick-row input[type="checkbox"] { width: 18px; height: 18px; margin: 0; accent-color: var(--surface-moss); }
.pick-name { font-size: var(--fs-body); }
.pick-name .meta { display: block; font-size: var(--fs-caption); color: var(--text-secondary); margin-top: 2px; }
.tag-warn { color: var(--wait-ink); font-weight: var(--weight-semibold); }
input.qty { width: 84px !important; height: 36px !important; text-align: right; }
input.qty.rate { width: 108px !important; }
.quote-summary { align-self: start; padding: var(--space-4); border-radius: var(--radius-md); background: var(--color-sand); }
.quote-bar { display: none; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: var(--space-2) var(--space-4); margin: 0 0 var(--space-3); }
.totals dt { font-size: var(--fs-small); color: var(--text-secondary); }
.totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: var(--weight-medium); }
.totals dt:first-of-type, .totals dd:first-of-type { font-size: var(--fs-h3); font-weight: var(--weight-semibold); color: var(--text-primary); }
.warnings { margin: 0 0 var(--space-3); padding-left: var(--space-5); font-size: var(--fs-small); color: var(--wait-ink); }
.warnings:empty { display: none; }
.quote-lines { margin-bottom: var(--space-3); font-size: var(--fs-small); }
.quote-lines summary { cursor: pointer; color: var(--text-secondary); }
.quote-lines table { width: 100%; border-collapse: collapse; margin-top: var(--space-2); }
.quote-lines td { padding: var(--space-1) 0; border-top: var(--stroke-thin) solid rgba(0,0,0,0.08); vertical-align: top; }
.quote-lines td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.quote-summary .actions-row button.btn.primary { width: 100%; }
@media (min-width: 1024px) {
  .quote-grid { grid-template-columns: minmax(0, 1fr) 340px; gap: var(--space-6); align-items: start; }
  .quote-summary { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow-y: auto; }
}
/* On a phone the price rides along at the bottom, so it is in view while choosing. */
@media (max-width: 1023px) {
  /* Phones and tablets: the price panel follows the form; a slim bar keeps the total in view. */
  .quote-bar { position: sticky; bottom: calc(var(--space-2) + env(safe-area-inset-bottom)); z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
    padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); background: var(--color-sand); box-shadow: var(--shadow-md); font-size: var(--fs-small); font-weight: var(--weight-semibold); }
}

/* --------------------------------------------------------------- approvals */
.tab-count:not(:empty) { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 6px; padding: 0 6px; border-radius: var(--radius-capsule); background: var(--accent); color: var(--text-on-accent); font-size: var(--fs-caption); font-weight: var(--weight-semibold); }
.approval-box { border-top: var(--stroke-thin) solid rgba(0,0,0,0.1); padding-top: var(--space-3); margin-top: var(--space-2); display: grid; gap: var(--space-3); }
.approval-box .subhead { margin: 0; }
.approval-box .status { margin: 0; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.step { display: grid; grid-template-columns: 76px 1fr; gap: var(--space-2); font-size: var(--fs-small); }
.step-state { justify-self: start; align-self: start; padding: 1px var(--space-2); border-radius: var(--radius-capsule); font-size: var(--fs-caption); font-weight: var(--weight-semibold); background: var(--color-heather); color: var(--text-secondary); }
.step-pending .step-state { background: var(--color-cream); color: var(--wait-ink); }
.step-approved .step-state { background: var(--color-sage); color: var(--ok-ink); }
.step-rejected .step-state { background: #fbe9e7; color: var(--danger); }
.meta.block { display: block; }
.step .meta { color: var(--text-secondary); }
.step .meta.block { margin-top: 2px; font-size: var(--fs-caption); }
.history { list-style: none; margin: 0; padding: 0; font-size: var(--fs-caption); color: var(--text-secondary); display: grid; gap: var(--space-1); }
.history:empty { display: none; }
.sent-back { padding: var(--space-3); border-radius: var(--radius-md); background: #fbe9e7; color: var(--danger); font-size: var(--fs-small); }
.actions-row.stacked { flex-direction: column; align-items: stretch; gap: var(--space-2); }
.actions-row.stacked .btn { width: 100%; }
.lines-table { width: 100%; border-collapse: collapse; font-size: var(--fs-small); }
.lines-table td { padding: var(--space-2) 0; border-top: var(--stroke-thin) solid var(--border-subtle); vertical-align: top; }
.lines-table td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.services-block { margin-top: var(--space-3); }
.services-table th { text-align: left; font-weight: 600; color: var(--text-muted, inherit); padding-bottom: var(--space-1); }
.services-table th.num { text-align: right; }
.services-table th { padding-right: var(--space-2); white-space: nowrap; }
.services-table td { padding-right: var(--space-2); vertical-align: middle; }
.services-table td:first-child input { width: 100%; min-width: 10rem; }
.services-table select { width: auto; }
.services-table tr.project-row td { padding-top: var(--space-3); }
.services-table tr.part-row td:first-child { padding-left: var(--space-3); }
.services-add { display: flex; flex-wrap: wrap; gap: var(--space-2); }
/* On a phone the rows keep their columns and the table scrolls sideways, so Remove stays reachable. */
@media (max-width: 560px) { .services-table { display: block; overflow-x: auto; } .services-table td:first-child input { min-width: 8rem; } }
.decide { display: grid; gap: var(--space-3); margin-top: var(--space-4); }

/* ------------------------------------------------------------ customer copy */
.document-frame { width: 100%; height: min(80vh, 1100px); border: var(--stroke-thin) solid var(--border-subtle); border-radius: var(--radius-md); background: #fff; }
.entity-form { display: grid; gap: var(--space-3); max-width: 520px; margin-bottom: var(--space-4); }
@media (max-width: 560px) { .document-frame { height: 70vh; } }

.lines-table tr.total td { font-weight: var(--weight-semibold); border-top: 2px solid var(--border-subtle); }

/* --------------------------------------------------------- combined solution */
.product-block { display: grid; gap: var(--space-2); padding: var(--space-4); border: var(--stroke-thin) solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--color-sand); }
.product-block + .product-block { margin-top: var(--space-3); }
.product-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); }
.product-head h3 { margin: 0; font-family: var(--font-display); font-weight: var(--weight-medium); font-size: var(--fs-h3); display: flex; align-items: center; gap: var(--space-2); }
.product-settings { margin-bottom: var(--space-2); }
.add-product { margin-top: var(--space-4); max-width: 420px; }

.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.filter-row .segmented { margin: 0; }
.field.inline { display: flex; align-items: center; gap: var(--space-2); margin: 0; }
.field.inline select { width: auto; }
#opportunitiesPanel > .segmented { margin-bottom: var(--space-3); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.line-adjust { margin-top: var(--space-3); }
.line-adjust table input { width: 84px; text-align: right; }
.line-adjust > .fields, #exceptions > .field { margin-top: var(--space-3); }
.check-line { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-small); margin-top: var(--space-1); }
.check-line input { width: auto; }
.field-text { margin: 0; }
button.link { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; }
.line-adjust th { font-weight: var(--weight-semibold); font-size: var(--fs-caption); color: var(--text-secondary); text-align: left; }
.line-adjust th.num { text-align: right; }
.deal-terms { margin-top: var(--space-5); padding-top: var(--space-4); border-top: var(--stroke-thin) solid var(--border-subtle); }
.deal-terms textarea { width: 100%; }
.pre { white-space: pre-line; }
.doc-controls { margin: 0 0 var(--space-3); gap: var(--space-3); }
.doc-controls .segmented { margin: 0; }
.doc-controls select { width: auto; }

/* ------------------------------------------------------------ ticket portal */
.inline-form { margin: 0 0 var(--space-4); padding: var(--space-4); border: var(--stroke-thin) solid var(--border-subtle); border-radius: var(--radius-md); }
.inline-form .chip-choice { margin: var(--space-2) 0; }
.item.contact { align-items: flex-start; flex-wrap: wrap; }
.contact .badge { display: inline-block; margin-top: var(--space-1); }
.contact .badge.invoice { margin: 0 0 0 var(--space-2); background: var(--color-cream); color: var(--wait-ink); vertical-align: 1px; }
.contact-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: flex-end; }
.portal-status { margin: 0 0 var(--space-2); padding: 0 var(--space-2); }
.portal-status:empty { display: none; }
.remove-box { flex-basis: 100%; font-weight: var(--weight-regular); margin-top: var(--space-2); padding: var(--space-3); border: var(--stroke-thin) solid var(--border-subtle); border-radius: var(--radius-md); }
.remove-box p { margin: 0 0 var(--space-2); }
.remove-box select { width: auto; max-width: 100%; }
.former-contacts summary { cursor: pointer; color: var(--text-secondary); margin-top: var(--space-2); }
.stack { display: flex; flex-direction: column; gap: 6px; }
/* --------------------------------------------------------------- journey and My work */
.record-grid { display: grid; gap: var(--space-4); }
@media (min-width: 1024px) {
  .record-grid { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
  .record-grid > .journey { grid-column: 2; grid-row: 1; position: sticky; top: 84px; }
  .record-grid > .record-main { grid-column: 1; grid-row: 1; }
}
.journey { border-radius: var(--radius-md); background: var(--color-sand); padding: var(--space-3) var(--space-4); font-size: var(--fs-small); }
.journey.compact { margin-bottom: var(--space-4); }
.journey summary { cursor: pointer; list-style: none; }
.journey summary::-webkit-details-marker { display: none; }
.journey-head { display: grid; gap: 2px; }
.journey-head .label { font-size: var(--fs-caption); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); }
.journey-steps { list-style: none; margin: var(--space-3) 0 0; padding: 0; display: grid; gap: var(--space-2); }
.journey-step { display: grid; grid-template-columns: 14px 1fr; gap: var(--space-2); align-items: start; color: var(--text-secondary); }
.journey-dot { width: 10px; height: 10px; margin-top: 4px; border-radius: 50%; border: 2px solid var(--color-cement); }
.journey-done .journey-dot { background: var(--color-moss); border-color: var(--color-moss); }
.journey-current .journey-dot { background: var(--color-neon); border-color: var(--color-moss); }
.journey-waiting .journey-dot { background: var(--color-cream); border-color: var(--color-orange); }
.journey-current, .journey-waiting { color: var(--text-primary); }
.journey-state { font-weight: var(--weight-regular); }
