:root {
  /* Professional slate/blue palette: quieter surfaces, crisp borders, and
     restrained status colors that still scan quickly on the shop floor. */
  --bg: #f6f8fb;
  --bg-soft: #eef2f7;
  --card: #ffffff;
  --card-hover: #f8fafc;
  --border: #d7dee8;
  --text: #111827;
  --text-dim: #607086;
  --accent: #1f5fbf;
  --accent-soft: #e8eef8;
  --price: #047857;
  --warn: #a85f12;
  --danger: #b42318;
  --radius: 8px;
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 18px rgba(15, 23, 42, 0.045);
  --font-sans: "Lexend", sans-serif;
  --font-display: var(--font-sans);
  --font-mono: "SF Mono", SFMono-Regular, ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
  --header-h: 112px; /* fallback; app.js sets the real measured height */
  --workspace-max: 1100px;
  --workspace-pad: clamp(16px, 4vw, 48px);
  --sidebar-w: 224px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
img { max-width: 100%; height: auto; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 1.15em; height: 1.15em; display: inline-block; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.15em; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

:focus-visible {
  outline: 2px solid #7aa2e3;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: max(env(safe-area-inset-top), 14px) var(--workspace-pad) 12px;
}

.header-row {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  gap: 12px;
  width: min(100%, var(--workspace-max));
  margin: 0 auto;
}
.brand { grid-column: 2; justify-content: center; }

.nav-menu-toggle {
  grid-column: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--card);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='m1 1 4 4 4-4' fill='none' stroke='%23607086' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 18px center;
  color: var(--text);
  cursor: pointer;
  flex: none;
}
.nav-menu-toggle .icon { width: 20px; height: 20px; }
.nav-menu-toggle:active { transform: scale(0.96); }

.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 190;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.nav-backdrop[hidden] { display: none; }
body.nav-open .nav-backdrop { opacity: 1; }

.brand {
  font-family: var(--font-display);
  font-size: 1.22rem;
  margin: 0;
  font-weight: 500;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-logo {
  display: block;
  width: clamp(122px, 28vw, 160px);
  height: auto;
}
.brand-icon { width: 1.28em; height: 1.28em; color: var(--accent); stroke-width: 1.9; }
/* Signature element: a small powered-on LED pulse beside the brand mark */
.brand::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--price);
  box-shadow: 0 0 0 0 rgba(15, 122, 76, 0.5);
  animation: led-pulse 2.4s ease-out infinite;
}
.brand:has(.brand-logo)::after { display: none; }
@keyframes led-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(15, 122, 76, 0.45); }
  70%  { box-shadow: 0 0 0 6px rgba(15, 122, 76, 0); }
  100% { box-shadow: 0 0 0 0 rgba(15, 122, 76, 0); }
}

.info-banner {
  margin: 16px 0 0;
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.4;
}

.status-line {
  margin: 8px 0 0;
  font-size: 0.75rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex: none;
}
.status-dot.live { background: var(--price); box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.12); }
.status-dot.stale { background: var(--warn); }
.status-dot.error { background: var(--danger); }

/* ---------- Container ---------- */
.container {
  width: min(100%, var(--workspace-max));
  margin: 0 auto;
  padding: 20px var(--workspace-pad) 48px;
}

/* ---------- Search ---------- */
/* Sticks just below the header so it stays reachable while a long list
   scrolls underneath. The opaque background + top padding masks list
   content scrolling up behind it. */
.search-wrap {
  position: relative;
  top: auto;
  z-index: 1;
  background: var(--bg);
  padding: 16px 0 14px;
  margin: 0;
}
#view-prices .search-wrap {
  position: sticky;
  top: var(--header-h);
  z-index: 20;
}
@media (max-width: 899px) {
  #view-prices .search-wrap { z-index: 5; }
}
#view-prices.focused-search-result .search-wrap {
  box-shadow: 0 8px 18px rgba(35, 45, 72, 0.08);
}
.search-input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.05rem;
  padding: 14px 44px 14px 16px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow);
}
.search-input::placeholder { color: var(--text-dim); }
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 95, 191, 0.12);
}
.clear-search {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.clear-search[hidden] { display: none; }
.clear-search:hover { background: var(--card-hover); }
.clear-search .icon { width: 16px; height: 16px; }

.common-price-searches {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -4px 0 14px;
}
.common-price-searches[hidden] { display: none; }
.common-searches-label {
  flex: none;
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 600;
}
.common-searches-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.common-search-chip {
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 1px 2px rgba(35, 45, 72, 0.04);
}
.common-search-apply,
.common-search-delete {
  display: inline-flex;
  align-items: center;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.common-search-apply {
  gap: 6px;
  min-height: 32px;
  padding: 0 8px 0 12px;
  font-size: 0.86rem;
  font-weight: 600;
}
.common-search-delete {
  justify-content: center;
  width: 30px;
  height: 32px;
  color: var(--text-dim);
  border-left: 1px solid var(--border);
}
.common-search-delete .icon { width: 13px; height: 13px; }
.common-search-apply:hover,
.common-search-delete:hover { background: var(--bg-soft); }
.common-search-count {
  min-width: 18px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 0.72rem;
}

/* ---------- Filter chips ---------- */
.filter-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  max-height: 58px;
  padding: 2px 2px 8px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  opacity: 1;
  transition: max-height 0.18s ease, opacity 0.16s ease, padding 0.18s ease, margin 0.18s ease;
}
.filter-chips::-webkit-scrollbar { display: none; }
.brand-filter-chips.collapsed {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-bottom: 0;
  overflow: hidden;
  pointer-events: none;
}
.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.chip:active { transform: scale(0.96); }
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.status-chip {
  gap: 7px;
  background: var(--status-bg);
  border-color: var(--status-border);
  color: var(--status-ink);
}
.status-chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--status-dot);
}
.status-chip.active {
  background: var(--status-ink);
  border-color: var(--status-ink);
  color: #fff;
}
.status-chip.active::before { background: #fff; }

/* ---------- Results ---------- */
.result-count {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin: 0 0 10px 2px;
}
.results { display: flex; flex-direction: column; gap: 10px; }
#results { gap: 6px; }
.view-more-btn {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--accent);
  font: 500 0.9rem var(--font-display);
  cursor: pointer;
  box-shadow: var(--shadow);
}
.view-more-btn:hover { background: var(--accent-soft); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: background 0.15s;
  box-shadow: var(--shadow);
}
#results .card {
  border-radius: var(--radius-md);
  box-shadow: none;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
}
#results .card-head {
  min-height: 52px;
  padding: 10px 12px;
}
.card-head:hover { background: var(--card-hover); }
.card-model {
  font-size: 1.02rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 9px;
}
#results .card-model {
  min-width: 0;
  flex: 1;
  white-space: nowrap;
}
#results .card-model > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-tag {
  font-size: 0.62rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
}
.card-right { display: flex; align-items: center; gap: 10px; flex: none; }
.from-price { display: flex; align-items: center; text-align: right; }
.from-label { font-size: 0.62rem; color: var(--text-dim); display: block; line-height: 1; }
.from-value { font-family: var(--font-mono); font-size: 0.92rem; font-weight: 500; color: var(--price); white-space: nowrap; }
.from-prefix { font-family: inherit; font-size: 0.72rem; font-weight: 500; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em; }
.from-value.na { color: var(--warn); font-family: inherit; font-size: 0.82rem; font-weight: 500; }
.chevron {
  color: var(--text-dim);
  font-size: 0.85rem;
  transition: transform 0.2s;
}
.card.open .chevron { transform: rotate(180deg); }

@media (max-width: 460px) {
  #results .brand-tag { display: none; }
  #results .card-head { gap: 8px; }
  #results .card-model { font-size: 0.96rem; }
  .from-prefix { display: none; }
}

.card-body {
  display: none;
  padding: 0 16px 14px;
  border-top: 1px solid var(--border);
}
.card.open .card-body { display: block; }
.price-grid {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0;
  margin-top: 10px;
}
.price-row {
  display: contents;
  cursor: pointer;
}
.price-row > span {
  padding: 9px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
  transition: background 0.12s ease;
}
.price-row:last-child > span { border-bottom: none; }
/* .price-row uses display: contents (no box of its own), so hover/focus
   styling has to target the child spans, which are the actual grid items. */
.price-row:hover > span,
.price-row:focus-visible > span {
  background: var(--accent-soft);
}
.price-name { color: var(--text-dim); display: inline-flex; align-items: center; }
.price-val { text-align: right; font-weight: 500; color: var(--price); font-family: var(--font-mono); }
.price-stock-tick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 18px;
  height: 18px;
  margin-left: 7px;
  border-radius: var(--radius-sm);
  background: #dff5ec;
  color: var(--price);
  font-size: 0.74rem;
  font-weight: 500;
  line-height: 1;
}
.price-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 18px;
  height: 18px;
  margin-right: 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1;
  pointer-events: none;
  transition: transform 0.12s ease;
}
.price-row:hover .price-add-btn,
.price-row:focus-visible .price-add-btn {
  transform: scale(1.15);
}
.price-edit-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  flex: none;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.price-edit-btn .icon { width: 14px; height: 14px; }
.price-row:hover .price-edit-btn,
.price-row:focus-within .price-edit-btn {
  opacity: 1;
}
.price-add-repair-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  margin-top: 10px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: 600 0.82rem var(--font-display);
  cursor: pointer;
}
.price-add-repair-btn:hover,
.price-add-repair-btn:focus-visible { text-decoration: underline; outline: none; }
.price-val-editing {
  grid-column: 2 / span 2;
  display: flex;
  align-items: center;
  gap: 6px;
  text-align: left;
}
.price-name-editing { padding-right: 8px !important; }
.price-inline-name-input { width: 100%; min-width: 0; padding: 6px 8px; font: inherit; }
.price-val-editing .price-inline-input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  font-size: 0.85rem;
}
.price-val-editing .icon-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  flex: none;
}
.price-val-editing .icon-btn .icon { width: 14px; height: 14px; }
.price-inline-input.field-error-input { border-color: var(--danger); }
.no-prices {
  margin-top: 10px;
  font-size: 0.9rem;
  color: var(--warn);
}

/* ---------- Parts Checker ---------- */
.parts-checker-shell {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin-top: 16px;
}
.parts-checker-left {
  display: grid;
  gap: 12px;
  align-self: start;
  position: sticky;
  top: calc(var(--header-h) + 14px);
}
.parts-checker-form-card,
.parts-checker-results-card,
.parts-price-tool {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.parts-checker-form-card {
  padding: 18px;
}
.parts-checker-results-card {
  min-height: 575px;
  padding: 18px;
}
.parts-checker-heading h2,
.parts-checker-result-head h2 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.15;
}
.parts-checker-form {
  display: grid;
  gap: 13px;
  margin-top: 16px;
}
.parts-submit-note {
  margin: -2px 0 0;
  color: var(--text-dim);
  font-size: 0.78rem;
  line-height: 1.45;
}
.parts-checker-grid {
  gap: 12px;
}
.parts-helper-text {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.76rem;
  line-height: 1.35;
}
.parts-touch-auto-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 13px;
  border: 1px solid rgba(31, 95, 191, 0.28);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--text-dim);
  font-size: 0.82rem;
}
.parts-touch-auto-note[hidden] {
  display: none;
}
.parts-touch-auto-note strong {
  color: var(--accent);
  font-size: 0.88rem;
}
.parts-checker-form .primary-btn,
.parts-checker-result-head .ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.parts-checker-results {
  display: grid;
  gap: 18px;
}
.parts-checker-result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.parts-checker-result-head .ghost-btn {
  flex: none;
}
.parts-confidence {
  display: grid;
  gap: 8px;
}
.parts-confidence-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-dim);
  font-size: 0.82rem;
}
.parts-confidence-row strong {
  color: var(--price);
  font-family: var(--font-mono);
}
.parts-meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-soft);
}
.parts-meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--warn), var(--price));
}
.parts-section-title {
  margin: 0 0 10px;
  font-size: 0.98rem;
}
.parts-result-pair {
  display: grid;
  grid-template-columns: minmax(220px, 0.95fr) minmax(260px, 1.15fr);
  gap: 12px;
  align-items: start;
}
.parts-laptop-match {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card-hover);
}
.parts-laptop-photo {
  margin: 0 0 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  aspect-ratio: 4 / 3;
}
.parts-laptop-photo[hidden] {
  display: none;
}
.parts-laptop-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.parts-laptop-name {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 13px;
}
.parts-laptop-name .icon {
  color: var(--accent);
}
.parts-laptop-name strong {
  font-size: 1rem;
  line-height: 1.25;
}
.parts-laptop-match dl {
  display: grid;
  gap: 8px;
  margin: 0;
}
.parts-laptop-match dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.parts-laptop-match dl div:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.parts-laptop-match dt {
  color: var(--text-dim);
  font-size: 0.78rem;
}
.parts-laptop-match dd {
  margin: 0;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: right;
  overflow-wrap: anywhere;
}
.parts-laptop-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.parts-laptop-actions .primary-btn,
.parts-laptop-actions .ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 11px;
  font-size: 0.78rem;
  text-decoration: none;
}
.parts-price-tool {
  padding: 14px;
}
.parts-price-tool[hidden] {
  display: none;
}
.parts-price-tool .parts-section-title {
  margin-bottom: 12px;
}
.parts-cost-input {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.parts-cost-input span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text-dim);
  font-weight: 600;
}
.parts-cost-input input {
  min-width: 0;
}
.parts-price-breakdown {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
}
.parts-price-breakdown div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-dim);
  font-size: 0.82rem;
}
.parts-price-breakdown dt,
.parts-price-breakdown dd {
  margin: 0;
}
.parts-price-breakdown dd {
  color: var(--text);
  font-family: var(--font-mono);
  font-weight: 600;
}
.parts-price-total {
  align-items: baseline;
  margin-top: 2px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.parts-price-total dt {
  color: var(--text);
  font-weight: 700;
}
.parts-price-total dd {
  color: var(--price);
  font-size: 1.2rem;
}
.parts-price-tool .parts-helper-text {
  margin-top: 10px;
}
.parts-checklist {
  display: grid;
  gap: 9px;
  padding: 0;
  margin: 0;
  list-style: none;
}
.parts-checklist li {
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--price);
  border-radius: var(--radius-sm);
  background: var(--card-hover);
}
.parts-checklist strong,
.parts-link-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.9rem;
}
.parts-link-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.parts-link-card-head > strong {
  min-width: 0;
  margin-bottom: 0;
}
.parts-link-price {
  display: grid;
  justify-items: end;
  flex: 0 0 auto;
  max-width: 132px;
  padding: 6px 8px;
  border: 1px solid rgba(22, 101, 52, 0.22);
  border-radius: var(--radius-sm);
  background: rgba(22, 163, 74, 0.08);
  color: var(--price);
  text-align: right;
}
.parts-link-price span {
  color: var(--text-dim);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.1;
  text-transform: uppercase;
}
.parts-link-price strong {
  margin: 1px 0 0;
  color: var(--price);
  font-size: 0.95rem;
}
.parts-link-price small {
  margin-top: 2px;
  color: var(--text-dim);
  font-size: 0.66rem;
  font-weight: 500;
  line-height: 1.2;
}
.parts-checklist span,
.parts-link-card > span {
  display: block;
  color: var(--text-dim);
  font-size: 0.82rem;
  line-height: 1.4;
}
.parts-link-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.parts-result-pair .parts-link-grid {
  grid-template-columns: 1fr;
}
.parts-link-card {
  min-height: 108px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: inherit;
  text-decoration: none;
  background: var(--card);
  transition: border-color 0.15s, background 0.15s;
}
.parts-link-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.parts-queries {
  display: grid;
  gap: 8px;
}
.parts-query {
  display: block;
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: 0.82rem var(--font-mono);
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.parts-query:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

@media (max-width: 880px) {
  .parts-checker-shell {
    grid-template-columns: 1fr;
  }
  .parts-checker-left {
    position: static;
  }
  .parts-result-pair {
    grid-template-columns: 1fr;
  }
  .parts-checker-form-card {
    position: static;
  }
  .parts-checker-results-card {
    min-height: auto;
  }
}

@media (max-width: 560px) {
  .parts-link-grid {
    grid-template-columns: 1fr;
  }
  .parts-laptop-actions {
    display: grid;
  }
  .parts-checker-result-head {
    display: grid;
  }
  .parts-checker-result-head .ghost-btn {
    width: 100%;
  }
}

/* ---------- Inventory ---------- */
.inventory-add-row { display: flex; justify-content: flex-end; margin-top: 10px; }
.inventory-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 14px;
}
.inventory-summary-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  box-shadow: var(--shadow);
}
.inventory-summary-tile span {
  display: block;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.inventory-summary-tile strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 1.28rem;
}
.inventory-summary-tile.is-warn { background: #fffbeb; border-color: #f3d9a7; }
.inventory-summary-tile.is-warn strong { color: var(--warn); }
.inventory-summary-tile.is-danger { background: #fff5f5; border-color: #f4c7c3; }
.inventory-summary-tile.is-danger strong { color: var(--danger); }
.inventory-table-shell {
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.inventory-table-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 0 16px;
  background: linear-gradient(180deg, #fff, #f8fafc);
  border-bottom: 1px solid var(--border);
}
.inventory-filter-wrap {
  flex: none;
  min-width: 158px;
}
.inventory-filter {
  width: 100%;
  min-height: 52px;
  padding: 8px 42px 8px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--accent);
  font: 500 1.02rem var(--font-display);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(35, 45, 72, 0.05);
  transition: border-color 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease;
}
.inventory-filter:hover,
.inventory-filter:focus {
  border-color: rgba(31, 95, 191, 0.28);
  box-shadow: 0 8px 20px rgba(31, 95, 191, 0.08);
}
.inventory-stock-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  max-width: min(42vw, 520px);
  overflow-x: auto;
  padding: 2px;
  scrollbar-width: none;
}
.inventory-stock-filters::-webkit-scrollbar { display: none; }
.inventory-stock-filter {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-dim);
  font: 500 0.82rem var(--font-display);
  cursor: pointer;
  white-space: nowrap;
}
.inventory-stock-filter:hover,
.inventory-stock-filter.active {
  border-color: currentColor;
  color: var(--stock-filter-color, var(--accent));
}
.inventory-stock-filter-all { --stock-filter-color: var(--accent); }
.inventory-stock-filter-ok { --stock-filter-color: var(--price); }
.inventory-stock-filter-low,
.inventory-stock-filter-out { --stock-filter-color: var(--danger); }
.inventory-stock-filter-ordered { --stock-filter-color: var(--warn); }
.inventory-stock-filter-backordered { --stock-filter-color: var(--danger); }
.inventory-stock-filter-arrived { --stock-filter-color: var(--price); }
.inventory-stock-filter-cancelled { --stock-filter-color: var(--text-dim); }
.inventory-stock-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.inventory-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--bg-soft);
  color: var(--text-dim);
}
.inventory-search:focus-within {
  border-color: rgba(31, 95, 191, 0.24);
  background: var(--card);
  box-shadow: 0 0 0 3px rgba(31, 95, 191, 0.08);
}
.inventory-search .icon { width: 20px; height: 20px; flex: none; }
.inventory-search input {
  width: 100%;
  min-height: 40px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: 500 0.98rem var(--font-display);
}
.inventory-search input::placeholder { color: var(--text-dim); }
.inventory-clear-search,
.inventory-view-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}
.inventory-clear-search:hover,
.inventory-view-btn:hover { background: var(--bg-soft); color: var(--text); }
.inventory-clear-search[hidden] { display: none; }
.inventory-view-btn {
  border: 1px solid var(--border);
  background: var(--card);
}
.inventory-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.inventory-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  table-layout: auto;
}
.inventory-table th,
.inventory-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 0.92rem;
  vertical-align: middle;
}
.inventory-table th {
  background: var(--bg-soft);
  color: var(--text-dim);
  font-weight: 500;
  text-align: left;
  letter-spacing: 0.02em;
}
.inventory-table th.num,
.inventory-table td.num {
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 500;
}
.inventory-table th.num { font-family: var(--font-display); }
.inventory-row { border-left: 4px solid transparent; }
.inventory-row:hover { background: #f8fafc; }
.inventory-row.inventory-ok { border-left-color: rgba(4, 120, 87, 0.32); }
.inventory-row.inventory-low { border-left-color: var(--danger); }
.inventory-row.inventory-low td[data-label="On hand"],
.inventory-row.inventory-low .inventory-stock-status { color: var(--danger); }
.inventory-row.inventory-out { opacity: 0.72; }
.inventory-row.inventory-out { border-left-color: var(--danger); }
.inventory-row.inventory-out td[data-label="On hand"],
.inventory-row.inventory-out .inventory-stock-status { color: var(--danger); }
.inventory-product {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.inventory-thumb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 46px;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, #fff, var(--bg-soft));
  color: var(--accent);
}
.inventory-thumb .icon { width: 24px; height: 24px; stroke-width: 1.7; }
.inventory-product-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.inventory-product-text strong {
  color: var(--text);
  font-weight: 500;
  line-height: 1.25;
  overflow-wrap: anywhere;
  white-space: normal;
}
.inventory-product-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  color: var(--text-dim);
  font-size: 0.8rem;
}
.inventory-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 1px 8px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}
.inventory-category,
.inventory-stock-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text);
  font-weight: 500;
}
.inventory-stock-status {
  background: #fff;
  color: var(--price);
  box-shadow: none;
}
.inventory-stock-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.inventory-stock-low {
  background: #fff;
  color: var(--danger);
  box-shadow: none;
}
.inventory-stock-out {
  background: #fff;
  color: var(--danger);
  box-shadow: none;
}
.inventory-unavailable {
  display: block;
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 0.74rem;
  font-weight: 500;
}
.inventory-note { color: var(--warn); }
.inventory-muted { color: var(--text-dim) !important; font-weight: 500; }
.inventory-adjust-col { min-width: 190px; }
.inventory-table th.inventory-adjust-col {
  padding-right: 34px;
  text-align: right;
}
.inventory-adjust {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  width: 100%;
}
.inventory-adjust-btn,
.inventory-update-btn {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font: 500 0.9rem var(--font-display);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.inventory-adjust-btn {
  width: 34px;
  padding: 0;
  color: var(--accent);
  font-size: 1rem;
}
.inventory-update-btn {
  min-width: 72px;
  padding: 0 12px;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.inventory-adjust-btn:hover,
.inventory-update-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(31, 95, 191, 0.4);
}
.inventory-update-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
.inventory-delta {
  min-width: 34px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-weight: 500;
  text-align: center;
}
.inventory-delta.is-positive { color: var(--price); }
.inventory-delta.is-negative { color: var(--warn); }
.inventory-row-error {
  margin: 5px 0 0;
  color: var(--danger);
  font-size: 0.74rem;
  font-weight: 500;
  text-align: right;
}
@media (max-width: 820px) {
  .inventory-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inventory-table-toolbar { flex-wrap: wrap; }
  .inventory-stock-filters {
    order: 3;
    width: 100%;
    max-width: 100%;
  }
}
@media (max-width: 720px) {
  .inventory-table-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
  }
  .inventory-filter-wrap,
  .inventory-filter { width: 100%; }
  .inventory-stock-filters { order: initial; }
  .inventory-view-btn { display: none; }
  .inventory-table-scroll { overflow: visible; }
  .inventory-table,
  .inventory-table tbody,
  .inventory-table tr,
  .inventory-table td { display: block; width: 100%; min-width: 0; }
  .inventory-table thead { display: none; }
  .inventory-table tr.inventory-row {
    width: auto;
  }
  .inventory-row {
    margin: 10px;
    border: 1px solid var(--border);
    border-left-width: 5px;
    border-radius: var(--radius-md);
    background: var(--card);
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.045);
  }
  .inventory-table td {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 9px 12px;
    border-bottom: 0;
  }
  .inventory-table td::before {
    content: attr(data-label);
    color: var(--text-dim);
    font-size: 0.74rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    text-transform: uppercase;
  }
  .inventory-table td:first-child {
    display: block;
    padding-top: 12px;
  }
  .inventory-table td:first-child::before { display: none; }
  .inventory-table td.num { text-align: right; }
  .inventory-table td[data-label="Update"],
  .inventory-table td[data-label="Linked to"],
  .inventory-table td[data-label="Actions"] {
    display: block;
  }
  .inventory-table td[data-label="Update"]::before,
  .inventory-table td[data-label="Linked to"]::before,
  .inventory-table td[data-label="Actions"]::before {
    display: block;
    margin-bottom: 8px;
  }
  .inventory-adjust {
    justify-content: stretch;
  }
  .inventory-adjust-btn {
    width: 44px;
    min-height: 44px;
  }
  .inventory-update-btn {
    flex: 1;
    min-height: 44px;
  }
  .inventory-row-error { text-align: left; }
  .inventory-product { align-items: flex-start; }
}

/* The parts-orders table has two extra columns (Destination, Ordered) over
   Inventory's, so it needs more room before it fits as a real table — switch
   it to stacked cards at a wider breakpoint than Inventory's 720px so it
   never has to horizontally scroll at any realistic viewport width (the
   sidebar nav alone eats 224px+ starting at 900px). Scoped to
   .parts-order-table specifically so Inventory's table is untouched. */
@media (max-width: 1100px) {
  .inventory-table-scroll:has(.parts-order-table) { overflow: visible; }
  .parts-order-table,
  .parts-order-table tbody,
  .parts-order-table tr,
  .parts-order-table td { display: block; width: 100%; min-width: 0; }
  .parts-order-table thead { display: none; }
  .parts-order-table tr.inventory-row {
    width: auto;
  }
  .parts-order-table .inventory-row {
    margin: 10px;
    border: 1px solid var(--border);
    border-left-width: 5px;
    border-radius: var(--radius-md);
    background: var(--card);
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.045);
  }
  .parts-order-table td {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 9px 12px;
    border-bottom: 0;
  }
  .parts-order-table td::before {
    content: attr(data-label);
    color: var(--text-dim);
    font-size: 0.74rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    text-transform: uppercase;
  }
  .parts-order-table td:first-child {
    display: block;
    padding-top: 12px;
  }
  .parts-order-table td:first-child::before { display: none; }
  .parts-order-table td.num { text-align: right; }
  .parts-order-table td[data-label="Destination"],
  .parts-order-table td[data-label="Actions"] {
    display: block;
  }
  .parts-order-table td[data-label="Destination"]::before,
  .parts-order-table td[data-label="Actions"]::before {
    display: block;
    margin-bottom: 8px;
  }
  .parts-order-shipment-header td {
    display: block !important;
  }
  .parts-order-shipment-item td:first-child { padding-left: 12px; }
  /* Two flex items with min-width:0 never wrap onto their own lines — the
     browser just crushes the label down to a sliver instead. Stack them so
     the label gets a full line to itself before the actions row. */
  .parts-order-shipment-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .parts-order-shipment-actions { justify-content: flex-start; }
  .parts-order-table .inventory-adjust {
    justify-content: stretch;
  }
  .parts-order-table .inventory-adjust-btn {
    width: 44px;
    min-height: 44px;
  }
  .parts-order-table .inventory-update-btn {
    flex: 1;
    min-height: 44px;
  }
  .parts-order-table .inventory-row-error { text-align: left; }
  .parts-order-table .inventory-product { align-items: flex-start; }
}

/* ---------- States ---------- */
.empty-state, .error-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-dim);
}
.empty-icon { width: 48px; height: 48px; display: inline-flex; align-items: center; justify-content: center; margin: 0 0 12px; border-radius: var(--radius-md); color: var(--accent); background: var(--accent-soft); }
.empty-icon .icon { width: 25px; height: 25px; stroke-width: 1.65; }
.empty-icon.error { color: var(--danger); background: #fce7e5; }
.empty-title { font-size: 1.05rem; font-weight: 500; color: var(--text); margin: 0 0 4px; }
.empty-sub { font-size: 0.88rem; margin: 0; }
.price-empty-add {
  width: auto;
  margin-top: 16px;
}
.price-empty-add[hidden] { display: none; }

.skeleton {
  height: 56px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--bg-soft) 25%, #f9fafd 50%, var(--bg-soft) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Footer ---------- */
.app-footer {
  text-align: center;
  padding: 18px 16px max(env(safe-area-inset-bottom), 18px);
  color: var(--text-dim);
  font-size: 0.72rem;
  border-top: 1px solid var(--border);
}

.install-app-btn { color: var(--accent); }
.install-app-btn .icon { color: var(--accent); }

.install-ios-tip[hidden] { display: none; }
.install-ios-tip {
  position: fixed;
  left: 50%;
  /* Sits above where .app-toasts (status/error banners) render, at the
     same bottom-center anchor, so a transient toast never overlaps this
     persistent tip. */
  bottom: calc(max(env(safe-area-inset-bottom), 16px) + 76px);
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 10px 12px 16px;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  animation: view-in 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}
.install-ios-tip p { margin: 0; font-size: 0.86rem; line-height: 1.4; }
.install-ios-tip strong { font-weight: 700; }
.install-ios-tip .icon-btn {
  flex: none;
  width: 32px;
  height: 32px;
  border-color: rgba(255, 255, 255, 0.3);
  background: transparent;
  color: #fff;
}
.install-ios-tip .icon-btn:hover { background: rgba(255, 255, 255, 0.12); }

@media (min-width: 600px) {
  .brand { font-size: 1.35rem; }
}

/* ---------- View nav ---------- */
/* Mobile default: a slide-out drawer triggered by .nav-menu-toggle, opened via
   body.nav-open. Replaced by an always-visible sidebar at the 900px+ breakpoint. */
.view-nav {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  position: fixed;
  top: 0;
  left: 0;
  height: 100dvh;
  width: min(78vw, 280px);
  margin: 0;
  background: var(--card);
  padding: max(env(safe-area-inset-top), 16px) 12px 16px;
  border-radius: 0;
  box-shadow: 8px 0 28px rgba(15, 23, 42, 0.18);
  z-index: 200;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}
body.nav-open .view-nav { transform: translateX(0); }
.nav-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px 14px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.nav-drawer-logo { width: 128px; height: auto; }
.nav-drawer-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text-dim);
  cursor: pointer;
}
.nav-drawer-close .icon { width: 16px; height: 16px; }
.nav-drawer-close:hover { color: var(--text); background: var(--bg-soft); }
.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  flex: none;
  width: 100%;
  min-height: 44px;
  white-space: nowrap;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
/* The install button starts hidden and is only revealed by JS (when
   beforeinstallprompt fires) — without this, the base display:inline-flex
   above wins the cascade over the browser's default [hidden]{display:none},
   since author styles beat user-agent styles regardless of specificity. */
.nav-btn[hidden] { display: none; }
.nav-btn:active { transform: scale(0.98); }
.nav-btn.active {
  background: var(--card);
  border-color: var(--border);
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(18, 24, 38, 0.08);
}
@media (min-width: 900px) {
  :root {
    --workspace-max: 1280px;
    --workspace-pad: clamp(18px, 2.4vw, 34px);
  }
  body {
    padding-left: var(--sidebar-w);
  }
  .app-header {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-w);
    height: 100dvh;
    padding: max(env(safe-area-inset-top), 18px) 12px 16px;
    overflow-y: auto;
    background: #f1f5f9;
    border-right: 1px solid var(--border);
    border-bottom: 0;
    box-shadow: 8px 0 24px rgba(18, 24, 38, 0.04);
  }
  .header-row {
    display: flex;
    justify-content: flex-start;
    width: 100%;
    margin: 0;
    padding: 2px 8px 14px;
  }
  .nav-menu-toggle { display: none; }
  .nav-backdrop { display: none; }
  .nav-drawer-header { display: none; }
  .brand-logo {
    width: 158px;
  }
  .view-nav {
    position: static;
    height: auto;
    transform: none;
    transition: none;
    box-shadow: none;
    z-index: auto;
    overflow-y: visible;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    width: 100%;
    margin: 4px 0 0;
    padding: 0;
    background: transparent;
    border-radius: 0;
  }
  .nav-btn {
    justify-content: flex-start;
    flex: none;
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: #475569;
    font-size: 0.95rem;
    font-weight: 500;
  }
  .nav-btn:hover {
    background: rgba(255, 255, 255, 0.64);
    color: var(--text);
  }
  .nav-btn.active {
    background: var(--card);
    border-color: rgba(255, 255, 255, 0.9);
    color: var(--text);
    box-shadow: 0 1px 2px rgba(18, 24, 38, 0.05);
  }
  .nav-btn.active .icon {
    color: var(--accent);
  }
  .nav-btn .icon {
    width: 20px;
    height: 20px;
    color: #4c5563;
  }
  .settings-nav-btn {
    margin-top: 2px;
    padding-top: 12px;
    border-top-color: var(--border);
  }
  .container {
    padding-top: 24px;
  }
  .app-footer {
    margin-left: 0;
  }
}
.view[hidden] { display: none; }
/* Animation is on the element itself (not a toggled class), so it replays
   automatically each time `hidden` is removed and the view re-enters layout.
   Also reused for sub-tab/step panels (.appt-panel, .form-step) so switching
   between any "page" in the app — top nav or in-flow steps — feels dynamic
   rather than an abrupt cut. */
.view:not([hidden]),
.appt-panel:not([hidden]),
.form-step:not([hidden]),
.completed-repairs-section {
  animation: view-in 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes view-in {
  from { opacity: 0; transform: translateY(10px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.nav-btn { position: relative; }
.nav-btn.active { transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease; }

/* ---------- Business dashboard ---------- */
.dashboard-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0 18px;
}
.dashboard-kpi-card,
.today-focus-card,
.dashboard-target-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.dashboard-target-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px 18px;
  margin: 16px 0 0;
  padding: 15px 16px;
}
.targets-page-card {
  margin-top: 18px;
  padding: 20px;
}
.targets-history-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-top: 18px;
  padding: 20px;
}
.targets-history-list { margin-top: 14px; }
.target-history-row small { color: var(--text-dim); font-size: 0.8rem; flex: none; }
.targets-progress {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.targets-progress-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: grid;
  gap: 8px;
  align-content: start;
}
.targets-progress-value {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 7px;
}
.targets-progress-value strong {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.targets-progress-value span {
  color: var(--text-dim);
  font-size: 0.85rem;
}
.targets-progress-sub {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.82rem;
}
.target-clear-done {
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.74rem;
  cursor: pointer;
}
.target-clear-done:hover { border-color: var(--danger); color: var(--danger); }
.target-card-age {
  display: block;
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 0.72rem;
}
@media (max-width: 680px) {
  .targets-progress { grid-template-columns: 1fr; }
}
.targets-title {
  margin: 3px 0 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.dashboard-target-help {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 0.84rem;
}
.dashboard-target-form {
  display: inline-grid;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) auto;
  align-items: end;
  gap: 8px;
}
.target-input-group {
  display: grid;
  gap: 6px;
  color: var(--text-dim);
  font-size: 0.76rem;
  font-weight: 500;
}
.target-money-input {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
}
.dashboard-currency {
  color: var(--text-dim);
  font-size: 0.95rem;
  font-weight: 500;
}
.dashboard-target-form input {
  min-height: 40px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text);
  padding: 8px 10px;
  font: 500 0.95rem var(--font-display);
  outline: none;
}
.dashboard-target-form input:focus {
  border-color: rgba(31, 95, 191, 0.32);
  background: var(--card);
  box-shadow: 0 0 0 3px rgba(31, 95, 191, 0.08);
}
.dashboard-target-form .ghost-btn {
  min-height: 40px;
  white-space: nowrap;
  align-self: end;
}
.dashboard-target-message {
  grid-column: 2 / -1;
  margin: -6px 0 0;
  color: var(--price);
  font-size: 0.76rem;
  font-weight: 500;
}
.targets-action-card {
  margin-top: 14px;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.target-plan-form {
  display: grid;
  gap: 10px;
  padding-top: 14px;
}
.target-plan-form .ghost-btn {
  justify-self: start;
  min-width: 150px;
}
.target-card-create {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px auto;
  gap: 8px;
}
.target-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.target-board-column {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #f8fafc;
  overflow: hidden;
}
.target-board-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
/* Label absorbs the free space so the count (and Done's Clear button)
   group on the right regardless of how many controls a column has. */
.target-board-heading span:first-child { margin-right: auto; }
.target-board-heading b {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-weight: 500;
}
.target-board-cards {
  display: grid;
  gap: 10px;
  padding: 10px;
}
.target-inline-composer {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.target-inline-title,
.target-inline-notes {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: 500 0.9rem var(--font-display);
}
.target-inline-title::placeholder,
.target-inline-notes::placeholder {
  color: var(--text-dim);
}
.target-inline-notes {
  min-height: 38px;
  resize: vertical;
  color: var(--text-dim);
  font-size: 0.82rem;
  line-height: 1.35;
}
.target-inline-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.target-inline-actions .dashboard-target-message {
  margin: 0;
  min-width: 0;
}
.target-inline-add {
  width: auto;
  min-height: 34px;
  padding: 6px 10px;
  flex: none;
}
.target-inline-add .icon {
  width: 15px;
  height: 15px;
}
.target-action-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.target-action-card strong {
  display: block;
  font-weight: 500;
}
.target-action-card p {
  margin: 6px 0 0;
  color: var(--text-dim);
  font-size: 0.82rem;
  line-height: 1.35;
}
.target-card-actions,
.ops-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.target-card-actions button,
.ops-row-actions button {
  min-height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text-dim);
  padding: 5px 9px;
  font: 500 0.75rem var(--font-display);
  cursor: pointer;
}
.target-card-actions button:hover,
.ops-row-actions button:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.danger-text { color: var(--danger) !important; }
.ops-card {
  margin-top: 18px;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.ops-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.ops-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #f8fafc;
}
.ops-row.is-complete { opacity: 0.68; }
.ops-row strong {
  display: block;
  font-weight: 500;
}
.ops-row p,
.ops-row small {
  display: block;
  margin: 4px 0 0;
  color: var(--text-dim);
}
/* ---------- Reminders (Apple Reminders-style list) ----------
   Flat rows on one card with hairline separators, a round tap-to-complete
   circle on the left, and red reserved for the things that are late. */
:root {
  --rem-red: #dc2626;
  --rem-red-soft: #fef2f2;
}

/* Red clock in the sidebar — these sit after .nav-btn .icon / .nav-btn.active
   .icon in the cascade, so the equal-specificity rules below win on order. */
.nav-btn .icon-reminders,
.nav-btn.active .icon-reminders { color: var(--rem-red); }

.reminders-page { max-width: min(760px, 100%); margin: 0 auto; }
.rem-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}
.rem-page-title-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rem-page-icon { width: 26px; height: 26px; flex: none; color: var(--rem-red); }
.rem-page-title { margin: 0; font-size: 1.55rem; font-weight: 700; letter-spacing: -0.01em; }
.rem-page-count { font-size: 1.3rem; font-weight: 600; color: var(--text-dim); }
.rem-page-sub { margin: 0 0 16px; font-size: 0.88rem; color: var(--text-dim); }

/* Segmented control (Open / Done / All) */
.rem-segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  margin-bottom: 18px;
  background: #e9ecf1;
  border-radius: 10px;
}
.rem-seg-btn {
  min-width: 84px;
  padding: 7px 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.rem-seg-btn:hover { color: var(--text); }
.rem-seg-btn.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.16);
}

/* Grouped sections */
.rem-group + .rem-group { margin-top: 24px; }
.rem-group-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 8px 2px;
  font-size: 1rem;
  font-weight: 700;
}
.rem-group-count { font-size: 0.88rem; font-weight: 600; color: var(--text-dim); }
.rem-group.is-overdue-group .rem-group-title { color: var(--rem-red); }
.rem-group.is-overdue-group .rem-group-count { color: var(--rem-red); opacity: 0.75; }

.rem-group-items {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

/* Rows */
.rem-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 10px 12px 14px; }
.rem-item + .rem-item { border-top: 1px solid var(--border); }
.rem-item:hover { background: #fafbfd; }

.rem-check {
  flex: none;
  margin-top: 1px;
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  padding: 0;
  border: 1.6px solid #c3cad6;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.rem-check:hover { border-color: var(--rem-red); }
.rem-check-mark { width: 13px; height: 13px; color: #fff; opacity: 0; stroke-width: 3.2; }
.rem-item.is-overdue .rem-check { border-color: var(--rem-red); }
.rem-item.is-done .rem-check { background: var(--rem-red); border-color: var(--rem-red); }
.rem-item.is-done .rem-check-mark { opacity: 1; }

.rem-body-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.rem-body {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.rem-title { font-size: 0.95rem; color: var(--text); overflow-wrap: anywhere; }
.rem-notes { font-size: 0.72rem; color: var(--text-dim); overflow-wrap: anywhere; }
.rem-due { font-size: 0.82rem; color: var(--text-dim); }
.rem-item.is-overdue .rem-due { color: var(--rem-red); font-weight: 600; }
/* Completed items stay readable but recede — Apple dims rather than strikes. */
.rem-item.is-done .rem-title { color: var(--text-dim); }

.rem-note-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 100%;
  margin-top: 1px;
}
.rem-note-preview {
  min-width: 0;
  color: var(--text-dim);
  font-size: 0.72rem;
  line-height: 1.35;
}
.rem-note-row:not(.is-open) .rem-note-preview {
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rem-note-row.is-open .rem-note-preview {
  flex-basis: 100%;
  overflow-wrap: anywhere;
}
.rem-note-toggle {
  flex: none;
  padding: 2px 7px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2, #f1f3f6);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.5;
  cursor: pointer;
}
.rem-note-toggle:hover { background: #e8eefb; }

.rem-delete {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #9aa4b2;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.rem-delete .icon { width: 16px; height: 16px; }
.rem-item:hover .rem-delete,
.rem-delete:focus-visible { opacity: 1; }
.rem-delete:hover { color: var(--rem-red); background: var(--rem-red-soft); }
/* Touch devices never hover, so the control has to stay put. */
@media (hover: none) { .rem-delete { opacity: 1; } }

.rem-empty { padding: 44px 20px; }
.rem-empty-icon { color: var(--rem-red); background: var(--rem-red-soft); }

/* Quick due-date presets in the add/edit sheet */
.reminder-due-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.reminder-due-presets .chip { padding: 6px 12px; font-size: 0.8rem; }

/* Custom due date/time popup (replaces the native datetime-local picker so
   we can put an in-popup Save button on it). */
.due-picker { position: relative; }
.due-picker-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  text-align: left;
}
.due-picker-trigger .icon { width: 17px; height: 17px; color: var(--text-dim); flex-shrink: 0; }
.due-popup {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  width: 380px;
  max-width: calc(100vw - 32px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow), 0 12px 28px rgba(15, 23, 42, 0.14);
  padding: 12px;
}
.due-popup[hidden] { display: none; }
.due-popup.due-popup-flip-up { top: auto; bottom: calc(100% + 6px); }
.due-popup-body { display: flex; gap: 12px; margin-bottom: 10px; }
.due-popup-calendar { flex: 1; min-width: 0; }
.due-popup-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.due-popup-month { font-weight: 600; font-size: 0.85rem; }
.due-popup-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  cursor: pointer;
  color: var(--text);
}
.due-popup-nav:hover { background: var(--bg-soft); }
.due-popup-nav .icon { width: 14px; height: 14px; }
.due-popup-nav#dueCalPrev .icon { transform: rotate(90deg); }
.due-popup-nav#dueCalNext .icon { transform: rotate(-90deg); }
.due-popup-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.due-popup-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.due-popup-day {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: 50%;
  font-size: 0.82rem;
  color: var(--text);
  cursor: pointer;
}
.due-popup-day:hover { background: var(--bg-soft); }
.due-popup-day.is-outside { color: var(--text-dim); opacity: 0.55; }
.due-popup-day.is-today { font-weight: 600; }
.due-popup-day.is-selected { background: var(--accent); color: #fff; }
.due-popup-time {
  flex: none;
  width: 76px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}
.due-popup-time-label { font-size: 0.68rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em; }
.due-popup-time .select-input { width: 100%; padding: 6px 6px; font-size: 0.8rem; }
.due-popup-footer { display: flex; justify-content: space-between; gap: 8px; }
.due-popup-footer .ghost-btn, .due-popup-footer .primary-btn { padding: 7px 14px; font-size: 0.85rem; flex: 1; }

.rem-toolbar { display: flex; gap: 10px; margin-bottom: 12px; }
.rem-searchbar { flex: 1; min-height: 44px; }
.rem-searchbar input { min-height: 40px; }
select.rem-assignee-filter { flex: none; width: auto; min-width: 140px; }

.field-warning {
  color: var(--warn);
  font-size: 0.83rem;
  margin: 6px 0 0;
}

.rem-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; max-width: 100%; }
.rem-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}
.rem-tag .icon { flex: none; }
.rem-tag-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rem-tag-priority.pr-urgent { background: var(--rem-red-soft); color: var(--rem-red); }
.rem-tag-priority.pr-customer_update { background: #eff6ff; color: #2563eb; }
.rem-tag-priority.pr-parts { background: #fff7ed; color: #c2410c; }
.rem-tag-priority.pr-repair { background: #ecfdf5; color: #059669; }
.rem-tag-priority.pr-pickup { background: #f5f3ff; color: #7c3aed; }
.rem-tag-assignee { background: var(--surface-2, #f1f3f6); color: var(--text-dim); }
.rem-tag-ticket {
  background: var(--surface-2, #f1f3f6);
  color: var(--text-dim);
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.66rem;
  line-height: 1.35;
  padding: 3px 8px;
  overflow: hidden;
  text-align: left;
}
.rem-tag-ticket:hover { background: var(--rem-red-soft); color: var(--rem-red); }

@media (max-width: 420px) {
  .rem-page-head { gap: 10px; }
  .rem-add-btn { width: 100%; justify-content: center; }
  .rem-toolbar { flex-direction: column; }
  select.rem-assignee-filter { width: 100%; }
  .rem-segmented { display: flex; width: 100%; }
  .rem-seg-btn { flex: 1; min-width: 0; padding-inline: 8px; }
}

.leads-workspace { margin-top: 14px; }
.leads-topbar {
  position: sticky;
  top: var(--header-h);
  z-index: 18;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(150px, 0.32fr) minmax(170px, 0.36fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  background: var(--bg);
}
.leads-searchbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 50px;
  padding: 0 10px 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--text-dim);
}
.leads-searchbar .icon { width: 20px; height: 20px; flex: none; }
.leads-searchbar input {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: 500 1rem var(--font-display);
}
.leads-heading-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 12px;
}
.leads-heading-row h2 {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
}
.leads-form {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow);
}
.leads-form-actions {
  grid-column: 1 / -1;
  justify-content: flex-start;
  margin-top: 0;
}
.leads-list {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
  gap: 10px;
}
.lead-card {
  --lead-tone: var(--accent);
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) minmax(190px, auto);
  grid-template-areas: "avatar main side";
  align-items: start;
  gap: 16px;
  padding: 16px 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--lead-tone);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.lead-card:hover { background: var(--card-hover); }
.lead-card:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.lead-status-new { --lead-tone: var(--accent); }
.lead-status-contacted { --lead-tone: #416aa3; }
.lead-status-quoted,
.lead-status-follow-up { --lead-tone: var(--warn); }
.lead-status-won { --lead-tone: var(--price); }
.lead-status-lost { --lead-tone: var(--danger); }
.lead-avatar {
  grid-area: avatar;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 1px solid color-mix(in srgb, var(--lead-tone) 28%, var(--border));
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--lead-tone) 11%, var(--card));
  color: var(--lead-tone);
}
.lead-avatar .icon {
  width: 27px;
  height: 27px;
  stroke-width: 1.8;
}
.lead-card-main {
  grid-area: main;
  min-width: 0;
}
.lead-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.lead-card-title {
  min-width: 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
}
.lead-status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--lead-tone) 12%, var(--card));
  color: var(--lead-tone);
  font-size: 0.72rem;
  font-weight: 600;
}
.lead-status-won .lead-status-pill { background: #dff5ec; color: var(--price); }
.lead-status-lost .lead-status-pill { background: #fff5f5; color: var(--danger); }
.lead-status-follow-up .lead-status-pill,
.lead-status-quoted .lead-status-pill { background: #fffbeb; color: var(--warn); }
.lead-card-sub {
  margin-top: 3px;
  color: var(--text-dim);
  font-size: 0.88rem;
  line-height: 1.35;
}
.lead-phone-wrap {
  margin-top: 10px;
  max-width: 360px;
}
.lead-detail-grid {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}
.lead-detail {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 0.8rem;
}
.lead-detail .icon {
  width: 15px;
  height: 15px;
  flex: none;
  stroke-width: 1.9;
}
.lead-detail.is-due {
  border-color: #f2c6c0;
  background: #fff5f5;
  color: var(--danger);
  font-weight: 600;
}
.lead-followup-label {
  position: relative;
  cursor: pointer;
}
.lead-followup-label:hover {
  border-color: var(--accent);
}
.lead-followup-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: transparent;
  opacity: 0;
  cursor: pointer;
}
.lead-side-row {
  display: flex;
  gap: 8px;
}
.lead-side-row .lead-notes-btn { width: auto; flex: 1; }
.lead-notes-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text-dim);
  padding: 7px 12px;
  font: 600 0.78rem var(--font-display);
  cursor: pointer;
  white-space: nowrap;
}
.lead-notes-btn .icon { width: 15px; height: 15px; flex: none; stroke-width: 1.9; }
.lead-notes-btn:hover, .lead-notes-btn:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--card-hover);
}
.lead-notes-btn.has-notes {
  border-color: #86cfa3;
  background: var(--card);
  color: #14783e;
}
.lead-notes-btn.has-notes:hover,
.lead-notes-btn.has-notes:focus-visible {
  border-color: #42a96c;
  background: var(--card);
  color: #0f6a35;
}
.lead-notes-btn.has-notes .lead-notes-count {
  background: #e4f8ec;
  color: #14783e;
}
.lead-notes-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
}
.lead-notes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 14px;
}
.lead-note-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--bg-soft);
}
.lead-note-row p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.lead-note-row small { display: block; margin-top: 6px; color: var(--text-dim); font-size: 0.76rem; }
.lead-notes-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lead-card-side {
  grid-area: side;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: min(100%, 248px);
  justify-self: end;
}
.lead-card-status {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  font-size: 0.84rem;
  font-weight: 600;
}
.lead-card-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.lead-card-actions button {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text-dim);
  padding: 7px 12px;
  font: 600 0.78rem var(--font-display);
  cursor: pointer;
}
.lead-card-side .lead-notes-btn {
  min-height: 38px;
}
.lead-card-actions button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--card-hover);
}
.lead-card-actions .danger-text:hover {
  border-color: var(--danger);
  color: var(--danger) !important;
}
.ops-empty {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.86rem;
}
.expense-total {
  text-align: right;
}
.expense-total span {
  display: block;
  color: var(--text-dim);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.expense-total strong {
  display: block;
  margin-top: 2px;
  color: var(--danger);
  font-size: 1.25rem;
  font-weight: 500;
}
.expenses-workspace { margin-top: 14px; }
.expenses-topbar { grid-template-columns: minmax(240px, 1fr) auto; }
.expense-category-chips { margin-top: 4px; }
.expenses-heading-row { align-items: center; }
.expense-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.expense-breakdown-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 0.82rem;
}
.expense-breakdown-item span { color: var(--text-dim); }
.expense-breakdown-item strong { color: var(--text); }
.dashboard-kpi-card {
  min-height: 152px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
}
.dashboard-kpi-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: transparent;
}
.dashboard-kpi-card.is-warn::before { background: var(--warn); }
.dashboard-kpi-card.is-urgent::before { background: #d97706; }
.dashboard-kpi-card.is-clickable {
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}
.dashboard-kpi-card.is-clickable:hover {
  transform: translateY(-1px);
  border-color: #b8c5d8;
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.06), 0 12px 22px rgba(15, 23, 42, 0.07);
}
.dashboard-card-top {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.dashboard-card-icon {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-sm);
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid #d4def1;
}
.dashboard-card-label,
.dashboard-eyebrow {
  color: var(--text-dim);
  font-family: var(--font-display);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.dashboard-card-value {
  display: block;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 3vw, 2.15rem);
  line-height: 1;
  letter-spacing: -0.03em;
}
.dashboard-card-sub {
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 500;
}
.dashboard-progress {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid #dde5f0;
}
.dashboard-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #3b82f6);
}
.today-focus-card {
  padding: 18px;
}
.today-focus-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.today-focus-header h2 {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.dashboard-eyebrow { margin: 0; }
.today-focus-date {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 500;
  white-space: nowrap;
}
.today-focus-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  padding-top: 14px;
}
.today-focus-item {
  min-height: 112px;
  padding: 14px;
  text-align: left;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  font: inherit;
}
.today-focus-item.is-clickable {
  cursor: pointer;
  background: #fff;
}
.today-focus-item.is-clickable:hover {
  border-color: #b8c5d8;
  background: var(--card-hover);
}
.today-focus-item:disabled {
  opacity: 1;
  cursor: default;
}
.today-focus-item strong {
  display: block;
  font-weight: 500;
}
.today-focus-item small {
  display: block;
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 0.78rem;
  line-height: 1.25;
}
.today-focus-item b {
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}
.today-focus-empty {
  margin: 14px 0 0;
  color: var(--text-dim);
  font-weight: 500;
}

@media (max-width: 1100px) {
  .dashboard-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .today-focus-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .dashboard-kpi-grid,
  .today-focus-list { grid-template-columns: 1fr; }
  .dashboard-target-card,
  .dashboard-target-form {
    grid-template-columns: 1fr;
  }
  .target-card-create,
  .target-board,
  .leads-topbar { grid-template-columns: 1fr; position: static; }
  .leads-heading-row { align-items: start; flex-direction: column; }
  .lead-card {
    grid-template-columns: 48px minmax(0, 1fr);
    grid-template-areas:
      "avatar main"
      "side side";
    gap: 12px;
    padding: 14px;
  }
  .lead-avatar {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-sm);
  }
  .lead-card-side {
    width: 100%;
    justify-self: stretch;
  }
  .lead-card-actions { justify-content: stretch; }
  .lead-card-actions button { flex: 1; }
  .lead-phone-wrap { max-width: none; }
  .dashboard-target-message { grid-column: 1; }
  .dashboard-kpi-card { min-height: 134px; }
  .today-focus-header { flex-direction: column; }
}

/* ---------- Buttons / inputs (shared) ---------- */
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}
.primary-btn:active { transform: scale(0.98); }
.primary-btn:hover { filter: brightness(1.1); }
.primary-btn:disabled { opacity: 0.55; cursor: default; }
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.ghost-btn:hover { background: var(--card-hover); }
.ghost-btn:active { transform: scale(0.97); }
.icon-btn { width: 42px; height: 42px; padding: 0; }
.icon-btn .icon { width: 19px; height: 19px; }
.danger-btn {
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.32);
}
.danger-btn:hover { background: rgba(180, 35, 24, 0.08); }
.primary-btn.danger-btn {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.primary-btn.danger-btn:hover { filter: brightness(1.08); }
.text-input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  padding: 11px 13px;
  outline: none;
  box-sizing: border-box;
  font-family: inherit;
}
.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 95, 191, 0.12);
}
.field-label {
  display: block;
  font-size: 0.74rem;
  color: var(--text-dim);
  font-weight: 500;
  margin: 0 0 5px 2px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.field-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 10px 0 0;
}
.field-hint {
  text-transform: none;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-dim);
  font-size: 0.78rem;
}

/* ---------- Issue tags: multi-select toggle chips ---------- */
.issue-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.issue-toggle {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.issue-toggle:hover { background: var(--card-hover); }
.issue-toggle.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.issue-other-input { margin-top: 14px; }

/* Button on the form that opens the issue-picker modal */
.issue-select-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 1rem;
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
}
.issue-select-btn:hover { background: var(--card-hover); }
.issue-select-btn.has-selection #issueSelectLabel,
.issue-select-btn.has-selection #apptIssueSelectLabel,
.issue-select-btn.has-selection { color: var(--text); }
.issue-select-chevron { color: var(--text-dim); width: 18px; height: 18px; }

/* Read-only issue chips shown on a ticket card, or as a selection summary */
.issue-tags-readonly { margin-top: 6px; }
.issue-chip {
  display: inline-block;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: 500;
  margin: 0 6px 6px 0;
}
.issue-chip.muted { color: var(--text-dim); font-weight: 500; background: none; border-style: dashed; }
.issue-notes-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--accent, #2b52b8);
  border-color: var(--border);
}
.issue-notes-btn .icon { width: 12px; height: 12px; flex: none; }
.issue-notes-btn:hover,
.issue-notes-btn:focus-visible { background: var(--bg-soft); outline: none; }

/* ---------- Setup card ---------- */
.setup-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-top: 6px;
  box-shadow: var(--shadow);
}
.setup-title { margin: 0 0 6px; font-family: var(--font-display); font-size: 1.1rem; }
.setup-sub { margin: 0 0 16px; font-size: 0.85rem; color: var(--text-dim); }
.setup-card .field-label { margin-top: 12px; }
/* Scoped to the id, not ".setup-card .primary-btn" — the whole Settings
   UI (incl. the price grid's "Save changes" button) lives nested inside
   this same .setup-card section, so a descendant selector here stretched
   "Save changes" to full width too and threw off its size next to
   "Discard" in the price grid's save bar. */
#cfgSave.primary-btn { width: 100%; margin-top: 16px; }
.settings-maintenance { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.settings-help { margin: 5px 0 12px; color: var(--text-dim); font-size: 0.82rem; line-height: 1.45; }
.settings-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.settings-actions .ghost-btn { justify-content: center; min-height: 42px; }
.settings-actions .danger-btn { grid-column: 1 / -1; }
.settings-back { width: 100%; justify-content: center; margin-top: 12px; }
.technician-create-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}
.technician-create-row .primary-btn {
  width: auto;
  min-height: 44px;
  margin-top: 0;
  padding-inline: 14px;
}
.technician-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.technician-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-soft);
}
.technician-row span {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
}
.technician-row .icon {
  width: 17px;
  height: 17px;
  color: var(--accent);
}
.technician-delete {
  width: 36px;
  min-height: 36px;
  padding: 0;
  color: var(--danger);
  flex: none;
}
.technician-delete .icon { width: 16px; height: 16px; }
.technician-default {
  flex: none;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
@media (max-width: 420px) {
  .technician-create-row { grid-template-columns: 1fr; }
  .technician-create-row .primary-btn { width: 100%; }
}
.customer-settings .result-count { margin: 10px 0 0; }
.customer-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.customer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-soft);
}
.customer-row-main { min-width: 0; }
.customer-name { font-size: 0.9rem; font-weight: 500; color: var(--text); }
.customer-meta {
  margin-top: 3px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 0.78rem;
  color: var(--text-dim);
}
.customer-phone {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
  text-decoration: none;
}
.customer-phone:hover { text-decoration: underline; }
.customer-phone .icon { width: 13px; height: 13px; }
.customer-phone.no-phone { color: var(--text-dim); }
.customer-email { word-break: break-all; }
.customer-stats {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 0.76rem;
  color: var(--text-dim);
}
.customer-count { font-weight: 500; color: var(--text); }

/* ---- Settings → Frequent searches ---------------------------------------- */
.common-search-settings .result-count { margin: 10px 0 0; }
.common-search-settings-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 8px;
  margin-top: 10px;
}
.common-search-settings-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.common-search-settings-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
}
.common-search-settings-query {
  display: grid;
  min-width: 0;
  gap: 2px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.common-search-settings-query:hover .common-search-settings-text { color: var(--accent); }
.common-search-settings-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.94rem;
  font-weight: 600;
}
.common-search-settings-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
  font-size: 0.74rem;
}
.common-search-settings-count {
  min-width: 40px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
}
.common-search-settings-delete {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text-dim);
  cursor: pointer;
}
.common-search-settings-delete:hover {
  background: var(--bg-soft);
  color: var(--text);
}
.common-search-settings-delete .icon { width: 14px; height: 14px; }
.common-search-settings-empty {
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--text-dim);
  font-size: 0.86rem;
}

/* ---- Settings → Repair prices (bulk editor) ------------------------------ */
.price-settings .result-count { margin: 10px 0 0; }
.price-admin-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto auto;
  gap: 8px;
  margin-top: 10px;
}
.price-admin-toolbar .select-wrap { min-width: 140px; }
.price-admin-add-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  margin-top: 8px;
}
.price-admin-bulk {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--bg-soft);
}
.price-admin-selected {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}
.price-admin-bulk .select-wrap { min-width: 150px; }
.price-admin-bulk-value { max-width: 110px; }

/* The grid is intentionally the only thing on the page allowed to scroll
   sideways — a shop with a dozen repair types would otherwise push the whole
   settings page off screen on a phone. */
.price-admin-grid-wrap {
  margin-top: 10px;
  max-height: min(64vh, 720px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.price-admin-grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
}
.price-admin-grid th,
.price-admin-grid td {
  padding: 7px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.price-admin-grid thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--bg-soft);
  box-shadow: 0 1px 0 var(--border);
  font-weight: 600;
  font-size: 0.76rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.price-admin-grid tbody tr:last-child td { border-bottom: 0; }
.price-admin-grid tbody tr:hover { background: var(--bg-soft); }
.price-admin-check-col { width: 34px; }
.price-admin-actions-col { width: 44px; }
.price-admin-model-col { min-width: 170px; white-space: normal; }
.price-admin-brand-col { min-width: 130px; white-space: normal; }
.price-admin-model-name { display: block; font-weight: 500; color: var(--text); }
.price-admin-brand {
  display: block;
  margin-top: 1px;
  font-size: 0.72rem;
  color: var(--text-dim);
}
.price-admin-draft-row { background: color-mix(in srgb, var(--accent) 5%, var(--bg)); }
.price-admin-text-cell {
  width: 100%;
  min-width: 130px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.price-admin-text-cell:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent);
}
.price-admin-cell {
  width: 92px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  text-align: right;
}
.price-admin-cell:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent);
}
/* Unsaved cells stay visibly marked while scrolling a long list. */
.price-admin-cell.dirty {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
}
.price-admin-empty {
  padding: 18px 12px;
  color: var(--text-dim);
  font-size: 0.85rem;
}
.price-admin-savebar {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--bg);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
}
.price-admin-dirty { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.price-admin-savebar-actions { display: flex; gap: 8px; }
/* These three are toggled with the `hidden` attribute, and an explicit
   `display` above would otherwise beat the browser's `[hidden]` rule and leave
   an empty bar on screen. Same trap as .cancel-device-btn[hidden]. */
.price-admin-bulk[hidden],
.price-admin-savebar[hidden] { display: none; }
@media (max-width: 560px) {
  .common-search-settings-toolbar { grid-template-columns: 1fr; }
  .common-search-settings-toolbar .ghost-btn { width: 100%; justify-content: center; }
  .common-search-settings-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .common-search-settings-delete {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
  .common-search-settings-count {
    justify-self: start;
    min-width: 34px;
  }
  .price-admin-toolbar { grid-template-columns: 1fr; }
  .price-admin-toolbar .ghost-btn { width: 100%; justify-content: center; }
  .price-admin-grid-wrap { max-height: 58vh; }
  .price-admin-bulk > *,
  .price-admin-bulk .select-wrap { flex: 1 1 100%; }
  .price-admin-bulk-value { max-width: none; }
  .price-admin-savebar-actions { flex: 1 1 100%; }
  .price-admin-savebar-actions .ghost-btn,
  .price-admin-savebar-actions .primary-btn { flex: 1; justify-content: center; }
}

.technician-combobox {
  position: relative;
  z-index: 1200;
}
.technician-combobox .text-input {
  padding-right: 44px;
}
.technician-dropdown-btn {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.technician-dropdown-btn:hover,
.technician-combobox.open .technician-dropdown-btn {
  background: var(--accent-soft);
  color: var(--accent);
}
.technician-dropdown-btn .icon {
  width: 16px;
  height: 16px;
  transition: transform 0.15s ease;
}
.technician-combobox.open .technician-dropdown-btn .icon {
  transform: rotate(180deg);
}
.technician-dropdown {
  position: absolute;
  z-index: 2000;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: min(380px, 48vh);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  box-shadow: var(--shadow);
}
.technician-option {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  padding: 9px 10px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.technician-option:hover,
.technician-option:focus-visible,
.technician-option.active {
  background: var(--accent-soft);
  color: var(--accent);
  outline: none;
}
.technician-option.add-option {
  color: var(--price);
}
.technician-option.add-option .icon {
  width: 16px;
  height: 16px;
}

.device-combobox {
  position: relative;
  z-index: 20;
}
.device-combobox.open {
  z-index: 40;
}
.device-combobox .text-input {
  padding-right: 44px;
}
.device-dropdown-btn {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.device-dropdown-btn:hover,
.device-combobox.open .device-dropdown-btn {
  background: var(--accent-soft);
  color: var(--accent);
}
.device-dropdown-btn[hidden] { display: none; }
.device-dropdown-btn .icon {
  width: 16px;
  height: 16px;
  transition: transform 0.15s ease;
}
.device-combobox.open .device-dropdown-btn .icon {
  transform: rotate(180deg);
}
.device-dropdown {
  position: absolute;
  z-index: 1;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: min(380px, 48vh);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  box-shadow: var(--shadow);
}
.device-option {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  padding: 9px 10px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.device-option:hover,
.device-option:focus-visible,
.device-option.active {
  background: var(--accent-soft);
  color: var(--accent);
  outline: none;
}
.device-dropdown-empty { padding: 9px 10px; color: var(--text-dim); font-size: 0.86rem; }

/* ---------- Toolbar ---------- */
.repairs-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

/* Fixed bottom-right so it's reachable without scrolling back to the top of
   a long ticket list; sits inside #view-intake so the existing
   `.view[hidden] { display: none }` rule hides it for free on other tabs.
   z-index 50 stays below .modal-backdrop's 100, so opening the device-log
   modal correctly dims/covers it instead of floating above it. */
.intake-action-row {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 12px;
}
.intake-fab {
  position: static;
  min-width: 134px;
  height: 42px;
  padding: 0 15px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: #111827;
  border: 1px solid #111827;
  color: #fff;
  font: 500 0.9rem var(--font-display);
  letter-spacing: -0.01em;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.22), 0 8px 18px rgba(15, 23, 42, 0.12);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.intake-fab .icon { width: 17px; height: 17px; stroke-width: 2; }
.intake-fab:hover {
  background: #0f172a;
  border-color: #0f172a;
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.24), 0 10px 22px rgba(15, 23, 42, 0.14);
}
.intake-fab:active { transform: scale(0.98); }
.intake-fab:focus-visible { outline: 2px solid #94a3b8; outline-offset: 3px; }
.intake-filter-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  min-height: 62px;
  margin: 0 0 16px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow);
}
.intake-status-filter-wrap {
  width: 184px;
}
.intake-status-select {
  width: 100%;
  min-height: 42px;
  padding: 8px 34px 8px 12px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--bg-soft);
  color: var(--text);
  font: 500 0.9rem var(--font-display);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.intake-status-filter-wrap::after {
  content: "";
  position: absolute;
  right: 13px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-dim);
  border-bottom: 2px solid var(--text-dim);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}
.intake-search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 42px;
  padding: 0 10px;
  border-left: 1px solid var(--border);
  color: var(--text-dim);
}
.intake-search-field .icon {
  width: 20px;
  height: 20px;
}
.intake-search-field input {
  width: 100%;
  min-height: 40px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: 500 0.98rem var(--font-display);
}
.intake-search-field input::placeholder {
  color: var(--text-dim);
}

@media (max-width: 620px) {
  .intake-action-row { justify-content: stretch; }
  .intake-fab { width: 100%; }
  .intake-filter-bar {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .intake-status-filter-wrap { width: 100%; }
  .intake-search-field {
    border-left: 0;
    border-top: 1px solid var(--border);
    padding-top: 8px;
  }
}

/* ---------- Intake form ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-field-full { grid-column: 1 / -1; }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}
@media (max-width: 460px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* ---------- Form polish: section labels, custom selects ---------- */
.form-section-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 18px 0 10px;
}
.form-section-label:first-child { margin-top: 2px; }
.form-step[hidden],
.form-actions > [hidden] { display: none !important; }
.form-progress { display: flex; align-items: flex-start; gap: 7px; margin: 0 0 22px; }
/* Quick-log from a price row already knows the device/issue, so the wizard
   skips from Customer details to Payment — collapse the middle step visually. */
#intakeFormModal.quick-log [data-progress-step="2"],
#intakeFormModal.quick-log .form-progress-line:first-of-type {
  display: none;
}
#repairCostField[hidden] { display: none; }
.quoted-price-summary {
  margin: -4px 0 16px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 500;
}
.form-progress-step { position: relative; display: flex; align-items: center; justify-content: center; flex: none; width: 28px; height: 28px; border: 1px solid var(--border); border-radius: 50%; color: var(--text-dim); font-size: 0.74rem; font-weight: 500; line-height: 1; background: none; padding: 0; font-family: inherit; cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease; }
.form-progress-step > span { position: absolute; top: calc(100% + 10px); left: 50%; transform: translateX(-50%); color: var(--text-dim); font-size: 0.67rem; font-weight: 500; line-height: 1; white-space: nowrap; }
.form-progress-step.active { border-color: var(--accent); background: var(--accent); color: #fff; }
.form-progress-step.complete { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.form-progress-step.active > span,
.form-progress-step.complete > span { color: var(--accent); }
.form-progress-step:hover:not(:disabled):not(.active) { border-color: var(--accent); color: var(--accent); }
.form-progress-step:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.form-progress-step:disabled { cursor: not-allowed; opacity: 0.5; }

/* ---------- Multi-device check-in (add another device for the same client) ---------- */
.added-device-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.added-device-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}
.added-device-main { flex: 1; min-width: 0; }
.added-device-name { font-weight: 500; font-size: 0.9rem; }
.added-device-issues {
  margin-top: 2px;
  color: var(--text-dim);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.added-device-remove { flex: none; }
.add-device-btn { width: 100%; justify-content: center; }
.cancel-device-btn { margin-top: 10px; }
/* .ghost-btn's display would otherwise win over the browser's [hidden]. */
.cancel-device-btn[hidden] { display: none; }

.payment-device-card {
  padding: 14px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  background: var(--bg-soft);
}
.payment-device-card:last-child { margin-bottom: 0; }
.payment-device-label { margin: 0 0 10px; font-weight: 500; font-size: 0.88rem; }
.payment-device-label span { display: block; margin-top: 2px; color: var(--text-dim); font-size: 0.76rem; font-weight: 400; }
.form-progress-line { height: 1px; flex: 1; min-width: 18px; margin-top: 14px; background: var(--border); }
.form-progress-line.complete { background: var(--accent); }
.form-step-heading { margin: 0 0 18px; }
.form-step-heading .form-section-label { margin: 0 0 5px; }
.form-step-heading h4 { margin: 0; font-family: var(--font-display); font-size: 1.18rem; }
.form-step-heading p:last-child { margin: 5px 0 0; color: var(--text-dim); font-size: 0.88rem; line-height: 1.45; }
.invoice-request {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
}
.invoice-request input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.invoice-request strong, .invoice-request small { display: block; }
.invoice-request strong { font-size: 0.9rem; }
.invoice-request small { margin-top: 2px; color: var(--text-dim); font-size: 0.78rem; line-height: 1.35; }
.form-success { text-align: center; padding: 24px 8px 12px; }
.success-check {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: rgba(15, 122, 76, 0.12);
  color: var(--price);
  font-size: 2rem;
  font-weight: 500;
}
.form-success .form-step-heading { margin-bottom: 0; }

.select-wrap { position: relative; }
.select-input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  cursor: pointer;
}
.select-wrap::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-dim);
  border-bottom: 2px solid var(--text-dim);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}

/* ---------- Ticket cards ---------- */
.ticket {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--status-dot, var(--border));
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.ticket-head {
  display: grid;
  grid-template-columns: 64px minmax(180px, 0.85fr) minmax(180px, 1.45fr) minmax(128px, auto) 44px;
  grid-template-areas: "thumb identity repair status activity" "thumb phone repair status activity";
  align-items: center;
  gap: 16px;
  min-height: 104px;
  padding: 16px 18px;
  cursor: pointer;
}
.ticket-head:hover { background: var(--card-hover); }
.ticket-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ticket-device-thumb {
  grid-area: thumb;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, var(--bg-soft), var(--card));
  color: var(--accent);
}
.ticket-device-fallback { width: 30px; height: 30px; stroke-width: 1.6; }
.ticket-device-thumb img { display: none; width: 100%; height: 100%; object-fit: contain; padding: 9px; }
.ticket-device-thumb.has-image img { display: block; }
.ticket-device-thumb.has-image .ticket-device-fallback { display: none; }
.ticket-identity { grid-area: identity; min-width: 0; }
.ticket-phone-row { grid-area: phone; }
.ticket-num {
  display: block;
  margin-bottom: 3px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}
.ticket-customer {
  font-size: 1rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ticket-sub {
  margin-top: 1px;
  font-size: 0.86rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ticket-repair {
  grid-area: repair;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  min-width: 0;
}
.ticket-repair-label {
  color: var(--text-dim);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.ticket-repair .issue-tags {
  justify-content: flex-start;
  margin-top: 0;
  max-width: 100%;
}
.ticket-status {
  grid-area: status;
  justify-self: end;
  min-width: 128px;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
}
.ticket-activity {
  grid-area: activity;
  justify-self: end;
}
.ticket-head.no-click { cursor: default; }
.ticket-head.no-click:hover { background: none; }
.ticket-tech-label { font-size: 0.72rem; color: var(--text-dim); }
.ticket-row-actions { display: flex; gap: 6px; }
.ticket-status button[data-complete],
.ticket-status button[data-delete] {
  min-height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text-dim);
  padding: 5px 10px;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
}
.ticket-status button[data-complete]:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.ticket-status button[data-delete] { color: #c0392b; border-color: #f3c9c2; }
.ticket-status button[data-delete]:hover { background: #fdf0ee; }
.ticket-activity .activity-log-btn { width: 44px; height: 44px; }
@media (max-width: 760px) {
  .ticket-head {
    position: relative;
    grid-template-columns: 64px minmax(0, 1fr) auto;
    grid-template-areas:
      "thumb identity identity"
      "phone phone phone"
      "repair repair status";
    align-items: start;
    gap: 12px;
    padding: 14px;
  }
  .ticket-status { min-width: 0; align-self: center; }
  .ticket-repair { padding-top: 2px; }
  .ticket-identity .ticket-phone { display: none; }
  .ticket-head .ticket-phone-row { display: block; grid-area: phone; }
  /* The identity row spans the full card width so the client name gets the
     whole line. That only works with the activity button lifted out of the
     grid: as a third column it shares its track with .ticket-status, whose
     nowrap status badge sizes the column to ~250px and squeezes the name
     down to a few characters. Absolutely positioned, it keeps its top-right
     spot and identity just reserves room for it. */
  .ticket-activity {
    position: absolute;
    top: 14px;
    right: 14px;
  }
  .ticket-identity { padding-right: 56px; }
  .ticket-customer {
    white-space: normal;
    overflow-wrap: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}
@media (max-width: 390px) {
  .ticket-head {
    grid-template-columns: 56px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 12px;
  }
  .ticket-device-thumb { width: 56px; height: 56px; border-radius: var(--radius-md); }
  .ticket-device-thumb img { padding: 8px; }
  .ticket-activity { top: 12px; right: 12px; }
  .ticket-customer { font-size: 0.95rem; }
}
/* Full-width duplicate of the phone link, shown only on the narrow mobile
   ticket-head layout where the identity column is too cramped for it. */
.ticket-phone-row { display: none; }
.ticket-head:not(.ticket-head-compact) .ticket-phone-row { display: block; }
/* Tap-to-call number shown right on the card */
.ticket-phone {
  display: flex;
  width: 100%;
  box-sizing: border-box;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin-top: 6px;
  padding: 8px 12px 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 500;
  font-family: var(--font-mono);
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
}
.ticket-phone:hover { background: #dde6fb; }
.ticket-phone:active { transform: scale(0.97); }
.ticket-phone-icon { width: 17px; height: 17px; stroke-width: 1.9; }
.ticket-phone.no-phone {
  background: var(--bg-soft);
  color: var(--text-dim);
  font-weight: 500;
  font-family: inherit;
}
.status-badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  background: var(--status-bg, var(--accent-soft));
  color: var(--status-ink, var(--accent));
}
.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--status-dot, currentColor);
}
.status-badge-btn {
  border: none;
  font-family: inherit;
  cursor: pointer;
}
.status-badge-btn:hover, .status-badge-btn:focus-visible { filter: brightness(0.94); }
.status-badge-btn:focus-visible { outline: 2px solid var(--status-ink, var(--accent)); outline-offset: 1px; }
.ticket-body {
  display: none;
  padding: 4px 15px 15px;
  border-top: 1px solid var(--border);
}
.ticket.open .ticket-body { display: block; }
.repairs-list-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.repairs-list-summary .result-count { margin-right: auto; }
.repairs-toggle-all {
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 6px 0;
  font: 600 0.78rem var(--font-display);
  cursor: pointer;
}
.repairs-toggle-all:hover,
.repairs-toggle-all:focus-visible { text-decoration: underline; }
.repairs-status-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  margin: 16px 0 8px;
  padding: 10px 14px;
  border: 1px solid var(--status-border, var(--border));
  border-left: 4px solid var(--status-ink, var(--accent));
  border-radius: 10px;
  background: var(--status-bg, var(--bg-soft));
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  cursor: grab;
}
.repairs-status-section:active { cursor: grabbing; }
.repairs-status-section { transition: transform 0.14s ease, margin 0.14s ease, box-shadow 0.14s ease, background 0.14s ease; }
.repairs-status-section.is-dragging { opacity: 0.45; transform: scale(0.985); }
.repairs-status-section.is-drag-before { box-shadow: 0 -4px 0 var(--accent); }
.repairs-status-section.is-drag-after { box-shadow: 0 4px 0 var(--accent); }
.repairs-status-section:hover { filter: brightness(0.98); box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08); }
.repairs-status-section:focus-visible { outline: 2px solid var(--status-ink, var(--accent)); outline-offset: 2px; }
.repairs-status-section:first-child { margin-top: 0; }
.repairs-status-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 600 0.92rem var(--font-display);
  color: var(--status-ink, var(--text));
}
.repairs-status-drag-handle { font-size: 1.15rem; line-height: 1; color: currentColor; opacity: 0.65; letter-spacing: -0.2em; }
.repairs-status-section-meta { display: inline-flex; align-items: center; gap: 10px; }
.repairs-status-drag-hint { font-size: 0.68rem; font-weight: 500; opacity: 0.65; }
.repairs-status-section-state { font-size: 0.72rem; font-weight: 600; color: var(--status-ink, var(--accent)); }
.repairs-status-chevron {
  width: 16px;
  height: 16px;
  flex: none;
  transition: transform 0.15s ease;
}
.repairs-status-chevron.is-collapsed { transform: rotate(-90deg); }
.repairs-status-section-count {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--status-ink, var(--accent)) 12%, white);
  color: var(--status-ink, var(--text-dim));
  font-size: 0.76rem;
  font-weight: 700;
}
@media (max-width: 560px) {
  .repairs-status-drag-hint { display: none; }
  .repairs-status-section-state { display: none; }
  .repairs-status-section { min-height: 44px; }
}
.ticket-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.ticket-row .k { color: var(--text-dim); }
.ticket-row .v { text-align: right; font-weight: 500; }
.ticket-row .v.mono { font-family: var(--font-mono); }
.ticket-actions { margin-top: 14px; }
.status-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}
.status-set {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.status-set:hover { background: var(--card-hover); color: var(--text); }
.status-set.current { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.ticket-tech-btn {
  min-height: 30px;
  max-width: 190px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text-dim);
  padding: 5px 10px;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ticket-tech-btn:hover,
.ticket-tech-btn:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  outline: none;
}
.ticket-due-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 190px;
  min-height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text-dim);
  padding: 5px 10px;
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ticket-due-pill .icon { width: 13px; height: 13px; flex: none; }
.ticket-due-pill.is-alert {
  border-color: #f2c6c0;
  background: #fff5f5;
  color: var(--danger);
}
.ticket-edit-btn { margin-top: 12px; }
.ticket-client-btn { margin-top: 12px; margin-left: 8px; }
.ticket-delete-btn { margin-top: 12px; margin-left: 8px; color: var(--danger); }

/* ---- "Waiting for Parts" sub-status + overdue reminder ------------------- */
.ticket-parts-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 190px;
  min-height: 28px;
  border: 1px solid #f3d9a7;
  border-radius: var(--radius-sm);
  background: #fffbeb;
  color: #a85f12;
  padding: 5px 10px;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ticket-parts-btn .icon { width: 13px; height: 13px; flex: none; }
.ticket-parts-btn:hover,
.ticket-parts-btn:focus-visible { border-color: #a85f12; background: #fdf3da; outline: none; }
.ticket-parts-btn.is-ordered { border-color: #bfe8d8; background: #ecfdf5; color: #047857; }
.ticket-parts-btn.is-ordered:hover,
.ticket-parts-btn.is-ordered:focus-visible { border-color: #047857; background: #ddf7ec; }

.ticket-parts-alert,
.ticket-repair-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-top: 1px solid #f2c6c0;
  background: #fff5f5;
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 500;
}
.ticket-parts-alert .icon,
.ticket-repair-alert .icon { width: 16px; height: 16px; flex: none; }
.ticket-parts-alert span,
.ticket-repair-alert span { flex: 1; min-width: 0; }
.ticket-parts-alert-btn {
  flex: none;
  border: 1px solid #f2c6c0;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--danger);
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.ticket-parts-alert-btn:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
/* Draw the card's left border in red (overriding its status color) while a
   parts reminder is showing, so it stands out at a glance in the list. */
.ticket.has-parts-alert,
.ticket.has-repair-alert { --status-dot: var(--danger); }

/* ---------- Grouped check-in card (one client, several devices) ----------
   Devices dropped off together are saved as separate tickets but share one
   card: the client sits in the header, each device keeps its own row. */
.ticket-group-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 12px;
  padding: 14px 18px;
}
.ticket-group-identity { flex: 1; min-width: 0; }
.ticket-group-head .ticket-phone { width: fit-content; max-width: 100%; margin-top: 6px; min-height: 36px; }
.ticket-group-count {
  flex: none;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 0.74rem;
  font-weight: 500;
}
.ticket-group-devices { display: flex; flex-direction: column; }
.ticket-group-item {
  border-top: 1px solid var(--border);
  border-left: 4px solid var(--status-dot, var(--border));
}
.ticket-group-item.has-parts-alert,
.ticket-group-item.has-repair-alert { --status-dot: var(--danger); }
.ticket-head-compact { min-height: 88px; grid-template-areas: "thumb identity repair status activity"; }
@media (max-width: 559px) {
  .ticket-group-head { padding: 14px; }
  /* Compact rows have no phone line — drop that row from the mobile grid. */
  .ticket-head-compact {
    grid-template-areas:
      "thumb identity identity"
      "repair repair status";
  }
}
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.repair-loading {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 30px 0;
}

.ticket-tel {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.ticket-tel:hover { text-decoration: underline; }

/* Status colour map — one palette powers card borders, pills, and filters. */
.st-received {
  --status-bg: #e8eef8;
  --status-border: #c7d5ee;
  --status-ink: #1f5fbf;
  --status-dot: #1f5fbf;
}
.st-diagnosing {
  --status-bg: #f1eafe;
  --status-border: #dfcffb;
  --status-ink: #7c3aed;
  --status-dot: #7c3aed;
}
.st-parts {
  --status-bg: #fffbeb;
  --status-border: #f3d9a7;
  --status-ink: #a85f12;
  --status-dot: #c8791a;
}
/* Part to be Ordered reads as blocking (red); Part Ordered as in-flight
   (blue) — so a glance at the board separates "someone must act" from
   "we're waiting on the courier". */
.st-parts-needed {
  --status-bg: #fff5f4;
  --status-border: #f6c9c4;
  --status-ink: #c0341f;
  --status-dot: #d0402a;
}
.st-parts-ordered {
  --status-bg: #eef4ff;
  --status-border: #cbd9f5;
  --status-ink: #2b52b8;
  --status-dot: #3560c9;
}
.st-progress {
  --status-bg: #ecfdf5;
  --status-border: #bfe8d8;
  --status-ink: #047857;
  --status-dot: #0d946b;
}
.st-repaired {
  --status-bg: #ecfdf5;
  --status-border: #bfe8d8;
  --status-ink: #047857;
  --status-dot: #047857;
}
.st-checked-out {
  --status-bg: #ecfeff;
  --status-border: #a5e9f2;
  --status-ink: #0e7490;
  --status-dot: #0891b2;
}
.st-pickedup {
  --status-bg: #eef2f7;
  --status-border: #d7dee8;
  --status-ink: #607086;
  --status-dot: #94a3b8;
}
.st-no-fix {
  --status-bg: #f4f4f5;
  --status-border: #d4d4d8;
  --status-ink: #3f3f46;
  --status-dot: #52525b;
}
.st-cancelled {
  --status-bg: #fff5f5;
  --status-border: #f4c7c3;
  --status-ink: #b42318;
  --status-dot: #b42318;
}

/* ---------- Mono utility (ticket IDs, PIN dots) ---------- */
.mono { font-family: var(--font-mono); }

/* ---------- Activity log (history timeline) ---------- */
.activity-log-backdrop { z-index: 110; }
/* Width is shared with .ticket-modal-panel — see that rule. The timeline
   opens on top of the device modal, so anything narrower reads as a smaller
   box floating inside it rather than a peer sheet. */
.activity-log-section + .activity-log-section { margin-top: 18px; }
.activity-log-note { margin-top: 8px; }
.activity-log-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text-dim);
  cursor: pointer;
  flex: none;
}
.activity-log-btn .icon { width: 17px; height: 17px; }
.activity-log-btn:hover,
.activity-log-btn:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  outline: none;
}
.activity-log-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 500;
  line-height: 16px;
  text-align: center;
}
.ticket-detail-hero-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
.ticket-detail-hero-main { min-width: 0; flex: 1; }
.history-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.history-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.history-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 5px;
}
.history-msg { font-size: 0.88rem; font-weight: 500; }
.history-when { font-size: 0.72rem; color: var(--text-dim); margin-top: 1px; }

/* Subtle interaction polish */
.text-input, .primary-btn, .ghost-btn, .chip, .nav-btn {
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

/* ---------- Issue picker modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(18, 24, 38, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal-backdrop[hidden] { display: none; }
/* Applies to every modal that reuses this backdrop/panel pattern. Defined on
   the element itself, so it replays each time `hidden` is removed. */
.modal-backdrop:not([hidden]) { animation: modal-fade 0.18s ease; }
.modal-backdrop:not([hidden]) .modal-panel { animation: modal-pop 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes modal-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (min-width: 560px) {
  .modal-backdrop { align-items: center; padding: 20px; }
}
.modal-panel {
  position: relative;
  z-index: 1;
  background: var(--card);
  width: 100%;
  max-width: 480px;
  max-height: min(82vh, 640px);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -8px 30px rgba(18, 24, 38, 0.18);
}
@media (max-width: 559px) {
  .modal-panel {
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }
}
@media (min-width: 560px) {
  .modal-panel { border-radius: var(--radius); box-shadow: var(--shadow); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.modal-header h3 { margin: 0; font-family: var(--font-display); font-size: 1.05rem; }
.modal-eyebrow { margin: 0 0 2px; color: var(--text-dim); font-size: 0.7rem; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; }
.modal-close {
  background: var(--bg-soft);
  border: none;
  color: var(--text-dim);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.modal-close .icon { width: 17px; height: 17px; }
.modal-close:hover { background: var(--border); }
.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
}
/* Let the due-date popup escape the modal's scroll clipping while it's open. */
.modal-body.due-popup-open { overflow: visible; }
.modal-footer {
  padding: 14px 18px max(env(safe-area-inset-bottom), 14px);
  border-top: 1px solid var(--border);
  flex: none;
}
.modal-footer .primary-btn { width: 100%; }
.modal-footer .form-actions { margin-top: 0; }
.modal-footer .form-actions .ghost-btn,
.modal-footer .form-actions .primary-btn { flex: 1; width: auto; }
.add-price-device-body {
  display: grid;
  gap: 8px;
}
.add-price-device-body .settings-help { margin-bottom: 0; }
.add-price-device-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(110px, 0.8fr);
  gap: 10px;
}
@media (max-width: 480px) {
  .add-price-device-grid { grid-template-columns: 1fr; }
  .price-empty-add { width: 100%; justify-content: center; }
}
#technicianModal .modal-panel {
  max-width: min(760px, calc(100vw - 32px));
  max-height: min(92vh, 760px);
}
#technicianModal .modal-body {
  min-height: 360px;
  overflow: visible;
}
.technician-modal-footer {
  display: flex;
  gap: 8px;
}
.technician-modal-footer .ghost-btn,
.technician-modal-footer .primary-btn {
  flex: 1;
  width: auto;
}

/* ---------- Ticket detail sheet ---------- */
/* Grouped deliberately: the timeline modal opens over the device modal, and
   the two are only visually coherent if they're exactly the same width. */
.ticket-modal-panel,
.activity-log-panel { max-width: 560px; }
.ticket-detail-hero { display: flex; align-items: center; gap: 12px; padding: 2px 0 16px; border-bottom: 1px solid var(--border); }
.ticket-device-icon { width: 42px; height: 42px; display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: var(--radius-md); background: var(--accent-soft); color: var(--accent); }
.ticket-device-icon .icon { width: 22px; height: 22px; }
.ticket-detail-title { margin: 0; font-size: 1.05rem; font-family: var(--font-display); }
.ticket-detail-issue { margin: 2px 0 0; color: var(--danger); font-size: 0.84rem; font-weight: 500; overflow-wrap: anywhere; }
.ticket-detail-id { margin: 2px 0 0; font-size: 0.72rem; color: var(--text-dim); }
.ticket-detail-section { margin-top: 18px; }
.ticket-detail-section .field-label { margin-bottom: 8px; }
.ticket-detail-grid { border-top: 1px solid var(--border); }
.ticket-detail-row { display: grid; grid-template-columns: 26px minmax(88px, 0.6fr) minmax(0, 1.4fr) auto; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.ticket-detail-row .icon { width: 17px; height: 17px; color: var(--text-dim); }
.ticket-detail-label { color: var(--text-dim); }
.ticket-detail-value { min-width: 0; text-align: right; font-weight: 500; overflow-wrap: anywhere; }
.ticket-detail-value.money-positive { color: var(--price); }
.ticket-detail-value.money-due { color: var(--danger); }
.ticket-detail-value.repair-due-alert-text { color: var(--danger); }
.ticket-detail-value .ticket-tel { font-size: inherit; }
.ticket-detail-edit-btn { width: 28px; height: 28px; padding: 0; flex: none; }
.ticket-detail-edit-btn .icon { width: 14px; height: 14px; }
.ticket-detail-value.ticket-detail-editing { grid-column: 3 / span 2; display: flex; align-items: center; gap: 6px; text-align: left; }
.ticket-detail-value.ticket-detail-editing .ticket-inline-input { flex: 1; min-width: 0; padding: 6px 8px; font-size: 0.85rem; }
.ticket-detail-value.ticket-detail-editing .icon-btn { width: 28px; height: 28px; padding: 0; flex: none; }
.ticket-detail-value.ticket-detail-editing .icon-btn .icon { width: 14px; height: 14px; }
.ticket-inline-input.field-error-input { border-color: var(--danger); }
.ticket-media-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.ticket-media-gallery .ops-empty { grid-column: 1 / -1; }
.ticket-media-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--card-hover);
  border: 1px solid var(--border);
}
.ticket-media-link {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.ticket-media-item img,
.ticket-media-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ticket-media-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  pointer-events: none;
}
.ticket-media-play .icon { width: 22px; height: 22px; }
.ticket-media-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.ticket-media-delete .icon { width: 12px; height: 12px; }
.ticket-media-add-btn { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.ticket-media-add-btn.is-uploading { opacity: 0.6; pointer-events: none; }
.form-media-pending { margin-bottom: 8px; }
.media-viewer-backdrop {
  z-index: 5200;
  align-items: stretch;
  padding: 0;
  background: rgba(5, 10, 20, 0.9);
}
.media-viewer-panel {
  width: 100%;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  color: #fff;
  background: #050a14;
}
.media-viewer-topbar,
.media-viewer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(env(safe-area-inset-top), 14px) 16px 12px;
}
.media-viewer-footer {
  padding: 12px 16px max(env(safe-area-inset-bottom), 14px);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.media-viewer-topbar h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.02rem;
}
.media-viewer-topbar .modal-eyebrow { color: rgba(255, 255, 255, 0.62); }
.media-viewer-close,
.media-viewer-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
}
.media-viewer-close {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
}
.media-viewer-close .icon,
.media-viewer-nav .icon {
  width: 20px;
  height: 20px;
}
.media-viewer-stage-wrap {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
}
.media-viewer-stage {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 56px;
}
.media-viewer-media {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
video.media-viewer-media {
  width: min(100%, 1080px);
  height: auto;
  max-height: 100%;
  background: #000;
}
.media-viewer-nav {
  position: absolute;
  top: 50%;
  z-index: 1;
  width: 42px;
  height: 48px;
  border-radius: var(--radius-sm);
  transform: translateY(-50%);
}
.media-viewer-prev { left: 10px; }
.media-viewer-next { right: 10px; }
.media-viewer-nav:disabled {
  opacity: 0;
  pointer-events: none;
}
.media-viewer-counter {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.84rem;
}
.media-viewer-footer .ghost-btn {
  width: auto;
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.media-viewer-footer .ghost-btn[hidden] { display: none; }
@media (min-width: 760px) {
  .media-viewer-backdrop { padding: 18px; }
  .media-viewer-panel {
    min-height: 0;
    height: min(920px, calc(100dvh - 36px));
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  }
}
@media (max-width: 520px) {
  .media-viewer-stage { padding: 8px 0; }
  .media-viewer-nav {
    top: auto;
    bottom: 12px;
    transform: none;
  }
}
.field-optional { color: var(--text-dim); font-weight: 400; text-transform: none; }
.ticket-detail-notes { margin: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 12px; color: var(--text-dim); font-size: 0.88rem; white-space: pre-wrap; }
.ticket-modal-footer {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: stretch;
  gap: 8px;
}
.ticket-modal-footer .primary-btn,
.ticket-modal-footer .ghost-btn {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 42px;
  padding-inline: 8px;
  white-space: normal;
  text-align: center;
  line-height: 1.2;
  font-size: clamp(0.72rem, 2.5vw, 0.92rem);
}
.ticket-modal-footer .icon {
  width: 16px;
  height: 16px;
}
.ticket-modal-footer .danger-btn {
  margin-left: 0;
}
.ticket-modal-footer .danger-btn .icon {
  width: 18px;
  height: 18px;
}
@media (max-width: 420px) {
  .ticket-modal-footer {
    gap: 6px;
    padding-inline: 10px;
  }
  .ticket-modal-footer .primary-btn,
  .ticket-modal-footer .ghost-btn {
    min-height: 40px;
    padding-inline: 5px;
    gap: 4px;
  }
}

/* ============ Appointments — Cal.com-style booking ============ */
.booking-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.booking-calendar-panel { padding: 24px; border-bottom: 1px solid var(--border); }
.booking-calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.booking-calendar-header strong { font-family: var(--font-display); font-size: 1.15rem; }
.booking-calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 10px;
}
.booking-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.booking-day {
  aspect-ratio: 1;
  max-width: 76px;
  max-height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 1.12rem;
  cursor: pointer;
}
.booking-day.is-empty { visibility: hidden; cursor: default; }
.booking-day:not(:disabled):hover { background: var(--card-hover); }
.booking-day.is-today { box-shadow: inset 0 0 0 1px var(--accent); }
.booking-day.is-selected { background: var(--accent); color: #fff; }
.booking-day:disabled { color: var(--text-dim); opacity: 0.4; cursor: not-allowed; }

.booking-slots-panel { padding: 24px; }
.booking-slots-label { margin: 0 0 14px; font-weight: 600; font-size: 1rem; }
.booking-slots-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; }
.booking-slot-btn {
  padding: 12px 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.92rem;
  cursor: pointer;
  text-align: center;
}
.booking-slot-btn:hover { background: var(--accent-soft); }
.booking-slot-btn.is-selected { background: var(--accent); color: #fff; }
.booking-slot-btn.has-bookings { display: flex; align-items: center; justify-content: center; gap: 8px; }
.booking-slot-count {
  font-family: var(--font-sans, inherit);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}
.booking-slot-btn.is-selected .booking-slot-count { background: rgba(255, 255, 255, 0.25); color: #fff; }
.booking-slots-empty { color: var(--text-dim); font-size: 0.86rem; }
.booking-existing-list { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.booking-existing-heading {
  margin: 0 0 8px;
  color: var(--text-dim);
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.booking-existing-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.86rem;
}
.booking-existing-row:last-child { border-bottom: none; }
.booking-existing-time { flex: none; font-family: var(--font-mono); color: var(--text-dim); font-size: 0.82rem; }
.booking-existing-details { color: var(--text); }

@media (min-width: 720px) {
  .booking-card { grid-template-columns: 1fr 240px; }
  .booking-calendar-panel { border-bottom: none; border-right: 1px solid var(--border); }
}

.booking-details-card {
  margin-top: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.booking-selected-summary { margin: 0 0 14px; font-weight: 600; color: var(--accent); }

.booking-list-card {
  margin-top: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.booking-list-title { margin: 0 0 14px; font-family: var(--font-display); font-size: 1.1rem; }
.booking-list { display: flex; flex-direction: column; gap: 10px; }
.booking-empty { color: var(--text-dim); font-size: 0.9rem; }
.booking-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.booking-row:hover { background: var(--card-hover); }
.booking-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.booking-row.is-completed { opacity: 0.6; }
.booking-row-main p { margin: 2px 0; color: var(--text-dim); font-size: 0.86rem; }
.booking-row-main small { color: var(--text-dim); font-size: 0.8rem; }
.booking-row-datetime { display: inline-flex; align-items: center; gap: 4px; }
.appt-reschedule-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-dim);
  cursor: pointer;
}
.appt-reschedule-btn .icon { width: 13px; height: 13px; stroke-width: 2; }
.appt-reschedule-btn:hover, .appt-reschedule-btn:focus-visible {
  color: var(--accent);
  background: var(--accent-soft);
}
.ticket-detail-row .appt-reschedule-btn { margin-left: auto; }
.reschedule-slots { max-height: 280px; }
.booking-row-actions { display: flex; gap: 8px; flex: none; }
.booking-row-actions button {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.8rem;
  cursor: pointer;
}
.booking-row-actions .danger-text { color: var(--danger); border-color: var(--danger); }

.appt-sidebar-subnav { display: none; }
.appt-subnav { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.appt-subnav-btn {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
.appt-subnav-btn:hover { background: var(--card-hover); }
.appt-subnav-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.completed-repairs-topbar {
  position: sticky;
  top: var(--header-h);
  /* Stays under .app-header's z-index 10 — the nav drawer is nested inside the
     header's stacking context, so anything above 10 here covers the drawer. */
  z-index: 5;
  max-width: min(1060px, 100%);
  margin: 0 auto;
  padding: 12px 0;
  background: var(--bg);
}
.completed-repairs-section { margin-bottom: 24px; }
.completed-repairs-section .booking-list-title { margin-bottom: 12px; }
.completed-repairs-list,
.completed-repairs-list #completedTicketsList,
.completed-repairs-list #completedAppointmentsList {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
[data-completed-ticket] .booking-row-main { cursor: pointer; }

.source-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  vertical-align: middle;
}
.source-tag-checkin { background: var(--accent-soft); color: var(--accent); }
.source-tag-appointment { background: #fdf2e9; color: #b9650a; }

.booking-wizard-card {
  max-width: min(1200px, 100%);
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.booking-wizard-card .booking-card { border: none; box-shadow: none; border-radius: 0; }
.appt-wizard-footer { border-top: 1px solid var(--border); margin-top: 18px; padding-top: 16px; background: none; }
.booking-list-card { max-width: min(1060px, 100%); margin-left: auto; margin-right: auto; }

.appt-device-row { display: flex; align-items: center; gap: 12px; }
.appt-device-row .text-input { flex: 1; }
.appt-device-row .device-combobox { flex: 1; }
.appt-device-thumb { flex: none; width: 56px; height: 56px; }

.technician-picker { display: flex; flex-wrap: wrap; gap: 10px; }
.technician-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 76px;
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
}
.technician-chip-avatar {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: var(--card);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
}
.technician-chip-avatar .icon { width: 20px; height: 20px; }
.technician-chip-name { font-size: 0.74rem; text-align: center; line-height: 1.25; color: var(--text-dim); }
.technician-chip.is-selected .technician-chip-avatar { background: var(--accent); color: #fff; }
.technician-chip.is-selected .technician-chip-name { color: var(--text); font-weight: 600; }

@media (max-width: 899.98px) {
  .nav-btn[data-target="intake"].active + .appt-sidebar-subnav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: -1px 0 6px 34px;
    padding: 0 0 2px;
  }
  .view-nav .appt-sidebar-subnav .appt-subnav-btn {
    position: relative;
    min-height: 34px;
    padding: 7px 10px 7px 22px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: #475569;
    box-shadow: none;
    font-size: 0.86rem;
    font-weight: 500;
    text-align: left;
  }
  .view-nav .appt-sidebar-subnav .appt-subnav-btn::before {
    content: "";
    position: absolute;
    left: 8px;
    top: 50%;
    width: 5px;
    height: 5px;
    border: 1px solid currentColor;
    border-radius: 50%;
    transform: translateY(-50%);
  }
  .view-nav .appt-sidebar-subnav .appt-subnav-btn:hover {
    background: var(--bg-soft);
    color: var(--text);
  }
  .view-nav .appt-sidebar-subnav .appt-subnav-btn.active {
    background: var(--accent);
    color: #fff;
  }
  .view-nav .appt-sidebar-subnav .appt-subnav-btn.active::before {
    background: currentColor;
  }
}

@media (min-width: 900px) {
  .nav-btn:not(.active) + .appt-sidebar-subnav,
  .settings-nav-btn:not(.active) + .appt-sidebar-subnav {
    display: none;
  }
  #view-targets > .targets-content-subnav {
    display: none;
  }
  /* Settings and Repairs show their sub-tabs in the sidebar (above) at this
     width, same as Appointments/Targets — the pill row inside the content
     area is the mobile-only fallback, so it's redundant here. */
  .settings-subnav,
  .repairs-subnav {
    display: none;
  }
  .appt-sidebar-subnav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: -1px 0 6px 34px;
    padding: 0 0 2px;
  }
  .appt-sidebar-subnav .appt-subnav-btn {
    position: relative;
    justify-content: flex-start;
    min-height: 34px;
    padding: 7px 10px 7px 22px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    box-shadow: none;
    color: #475569;
    font-size: 0.84rem;
    font-weight: 500;
    text-align: left;
  }
  .appt-sidebar-subnav .appt-subnav-btn::before {
    content: "";
    position: absolute;
    left: 8px;
    top: 50%;
    width: 5px;
    height: 5px;
    border: 1px solid currentColor;
    border-radius: 50%;
    transform: translateY(-50%);
  }
  .appt-sidebar-subnav .appt-subnav-btn:hover {
    background: rgba(255, 255, 255, 0.64);
    color: var(--text);
  }
  .appt-sidebar-subnav .appt-subnav-btn.active {
    background: var(--accent);
    color: #fff;
  }
  .appt-sidebar-subnav .appt-subnav-btn.active::before {
    background: currentColor;
  }

  #view-appointments:not([hidden]) {
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 1.2vh, 12px);
    height: 100dvh;
    max-width: none;
    padding-top: clamp(12px, 1.8vh, 20px);
    padding-bottom: clamp(12px, 1.8vh, 20px);
    overflow-y: auto;
  }
  #view-appointments > .info-banner {
    flex: none;
    margin: 0;
  }
  #view-appointments > .appt-content-subnav {
    display: none;
  }
  #view-appointments > .appt-panel[data-appt-panel-section="create"]:not([hidden]) {
    display: flex;
    flex: 1;
    min-height: 0;
  }
  #view-appointments .booking-wizard-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: none;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: clamp(14px, 1.8vh, 20px);
    overflow: hidden;
  }
  #view-appointments .form-progress {
    flex: none;
    margin-bottom: clamp(16px, 2vh, 22px);
  }
  #view-appointments .booking-wizard-card .form-step:not([hidden]) {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
  }
  #view-appointments .form-step-heading {
    flex: none;
    margin-bottom: clamp(10px, 1.5vh, 16px);
  }
  #view-appointments .booking-card {
    flex: 1;
    min-height: 0;
    grid-template-columns: minmax(360px, 1.75fr) minmax(190px, 0.8fr);
  }
  #view-appointments .booking-calendar-panel,
  #view-appointments .booking-slots-panel {
    min-height: 0;
    padding: clamp(14px, 1.8vh, 20px);
  }
  #view-appointments .booking-calendar-panel,
  #view-appointments .booking-slots-panel {
    display: flex;
    flex-direction: column;
  }
  #view-appointments .booking-calendar-header {
    flex: none;
    margin-bottom: clamp(8px, 1.3vh, 14px);
  }
  #view-appointments .booking-calendar-weekdays {
    flex: none;
    margin-bottom: 8px;
  }
  #view-appointments .booking-calendar-grid {
    flex: none;
    gap: 4px;
    align-content: start;
  }
  #view-appointments .booking-day {
    width: min(42px, 5.2vh);
    height: min(42px, 5.2vh);
    max-width: none;
    max-height: none;
    aspect-ratio: auto;
    font-size: clamp(0.88rem, 1.9vh, 1rem);
  }
  #view-appointments .booking-slots-label {
    flex: none;
    margin-bottom: 10px;
  }
  #view-appointments .booking-slots-list {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
  }
  #view-appointments .booking-slot-btn {
    min-height: 38px;
    padding: 8px 12px;
    font-size: 0.86rem;
  }
  #view-appointments .appt-wizard-footer {
    flex: none;
    margin-top: clamp(10px, 1.4vh, 14px);
    padding-top: clamp(10px, 1.4vh, 14px);
  }
  #view-appointments .appt-wizard-footer .form-actions {
    margin-top: 0;
  }
}

@media (min-width: 900px) and (max-width: 1080px) {
  #view-appointments .booking-card {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  #view-appointments .booking-calendar-panel {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
}

/* ---- Toasts (in-app replacement for browser alert() popups) ------------- */
.app-toasts {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* Above .modal-backdrop (5000) so save errors/confirmations are visible
     while a modal like the ticket detail sheet is open — that's exactly
     where inline edits happen. */
  z-index: 6000;
  width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}
.app-toast {
  background: var(--text);
  color: #fff;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
  padding: 12px 16px;
  font-size: 0.88rem;
  line-height: 1.4;
  opacity: 1;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.app-toast.is-error { background: #b42318; }
.app-toast.is-leaving { opacity: 0; transform: translateY(6px); }

/* ---- WhatsApp client notifications --------------------------------------- */
.whatsapp-btn { color: #128c4b; border-color: #9ad9b8; }
.whatsapp-btn:hover { background: #ecfdf3; }
.status-notify-copy {
  width: 100%;
  margin: 0 0 4px;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.45;
}
#statusModalOptions .primary-btn,
#statusModalOptions .ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* ============ Diagnostics — visual before/after device testing ============ */
.dg-shell { margin-top: 14px; max-width: min(1180px, 100%); }

/* ---- Client / ticket tagging ---- */
.dg-client-card {
  margin-top: 12px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.dg-field { min-width: 0; }
.dg-field .field-label { display: block; margin-bottom: 6px; }
.dg-field-search { position: relative; }
.dg-combo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-soft);
  color: var(--text-dim);
}
.dg-combo:focus-within { border-color: var(--accent); background: var(--card); }
.dg-combo .icon { width: 18px; height: 18px; flex: none; }
.dg-combo-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: 500 0.95rem var(--font-sans);
  min-height: 44px;
}
.dg-combo-list {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  margin-top: 6px;
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
}
.dg-combo-list[hidden] { display: none; }
.dg-combo-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.dg-combo-item:hover, .dg-combo-item:focus-visible { background: var(--accent-soft); outline: none; }
.dg-combo-name { font-size: 0.9rem; font-weight: 500; color: var(--text); }
.dg-combo-meta { grid-column: 1; font-size: 0.78rem; color: var(--text-dim); }
.dg-combo-id {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
}
.dg-combo-empty { margin: 0; padding: 10px; font-size: 0.84rem; color: var(--text-dim); line-height: 1.45; }

.dg-tagged { margin-top: 12px; }
.dg-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 8px 7px 12px;
  border: 1px solid #bcd3f2;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.82rem;
}
.dg-tag-chip .icon { width: 15px; height: 15px; }
.dg-tag-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(31, 95, 191, 0.14);
  color: inherit;
  cursor: pointer;
}
.dg-tag-clear:hover { background: rgba(31, 95, 191, 0.28); }
.dg-tag-clear .icon { width: 13px; height: 13px; }

.dg-client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

/* ---- Before / after stage switch ---- */
.dg-stage-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
.dg-stage-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.dg-stage-btn:hover { border-color: var(--text-dim); }
.dg-stage-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.dg-stage-name { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.dg-stage-btn.active .dg-stage-name { color: var(--accent); }
.dg-stage-meta { font-size: 0.76rem; color: var(--text-dim); }

.dg-overview {
  display: grid;
  grid-template-columns: auto auto minmax(220px, 1fr);
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.dg-overview-item,
.dg-overview-active {
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
}
.dg-overview-item {
  display: grid;
  grid-template-columns: auto auto;
  gap: 1px 10px;
  align-items: baseline;
  min-width: 120px;
}
.dg-overview-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dg-overview-item strong {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--text);
}
.dg-overview-item span:last-child {
  grid-column: 1 / -1;
  color: var(--text-dim);
  font-size: 0.74rem;
}
.dg-overview-label {
  color: var(--text-dim);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.dg-overview-active {
  display: grid;
  gap: 8px;
}
.dg-overview-bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-soft);
}
.dg-overview-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.2s ease;
}

/* ---- Map + side rail ---- */
.dg-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: 14px;
  margin-top: 14px;
  align-items: start;
}
.dg-map-card, .dg-section-panel, .dg-compare-card, .dg-saved-list {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.dg-map-card { padding: 18px 18px 10px; }
.dg-type-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
}
.dg-type-switch { display: inline-flex; gap: 6px; }
.dg-type-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--text-dim);
  font: 500 0.8rem var(--font-sans);
  cursor: pointer;
}
.dg-type-btn .icon { width: 15px; height: 15px; }
.dg-type-btn:hover { border-color: var(--text-dim); color: var(--text); }
.dg-type-btn.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.dg-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.dg-legend-item { display: inline-flex; align-items: center; gap: 5px; font-size: 0.74rem; color: var(--text-dim); }
.dg-swatch {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex: none;
  background: #d9e0ea;
  border: 1px solid #c2ccd9;
}
.dg-swatch.state-pass { background: var(--price); border-color: var(--price); }
.dg-swatch.state-fail { background: var(--danger); border-color: var(--danger); }
.dg-swatch.state-na { background: var(--warn); border-color: var(--warn); }

.dg-map { display: flex; justify-content: center; }
.dg-svg { width: 100%; max-width: 340px; height: auto; }
.dg-frame { fill: var(--bg-soft); stroke: #c8d2e0; stroke-width: 2.5; }
.dg-frame-screen { fill: var(--card); stroke: #dde4ee; stroke-width: 1.5; }

.dg-hotspot { cursor: pointer; }
.dg-hotspot:focus-visible { outline: none; }
.dg-hotspot:focus-visible .dg-dot { stroke: var(--accent); stroke-width: 3; }
.dg-dot {
  fill: #eef2f7;
  stroke: #c2ccd9;
  stroke-width: 2;
  transition: fill 0.14s ease, stroke 0.14s ease;
}
.dg-hotspot:hover .dg-dot { stroke: var(--text-dim); }
.dg-dot-icon { fill: none; stroke: #5b6b80; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.dg-dot-badge { fill: #fff; stroke: currentColor; stroke-width: 1.6; pointer-events: none; }
.dg-dot-tick { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.dg-hotspot.state-pass { color: var(--price); }
.dg-hotspot.state-pass .dg-dot { fill: #e3f6ec; stroke: var(--price); }
.dg-hotspot.state-pass .dg-dot-icon { stroke: #04684b; }
.dg-hotspot.state-fail { color: var(--danger); }
.dg-hotspot.state-fail .dg-dot { fill: #fdeceb; stroke: var(--danger); }
.dg-hotspot.state-fail .dg-dot-icon { stroke: #93261c; }
.dg-hotspot.state-na { color: var(--warn); }
.dg-hotspot.state-na .dg-dot { fill: #fdf5e6; stroke: var(--warn); }
.dg-hotspot.state-na .dg-dot-icon { stroke: #8a4f0f; }
.dg-hint { margin: 6px 0 4px; text-align: center; font-size: 0.76rem; color: var(--text-dim); }

.dg-side { display: grid; gap: 12px; align-content: start; }

/* ---- Section stepper ---- */
.dg-stepper {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-bottom: 4px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.dg-step {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: none;
  padding: 9px 14px 9px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dg-step:hover { border-color: var(--text-dim); }
.dg-step-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 0.76rem;
  font-weight: 600;
}
.dg-step-mark .icon { width: 14px; height: 14px; }
.dg-step-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.dg-step-label { font-size: 0.84rem; font-weight: 500; white-space: nowrap; }
.dg-step-meta { font-size: 0.7rem; color: var(--text-dim); white-space: nowrap; }
.dg-step.is-complete .dg-step-mark { background: var(--price); color: #fff; }
.dg-step.has-fail .dg-step-mark { background: var(--danger); color: #fff; }
.dg-step.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.dg-step.active .dg-step-label { color: var(--accent); }

/* ---- Current section panel ---- */
.dg-section-panel { padding: 16px; }
.dg-section-head { display: flex; align-items: center; gap: 10px; }
.dg-section-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--accent);
}
.dg-section-icon .icon { width: 19px; height: 19px; }
.dg-section-titles { flex: 1; min-width: 0; }
.dg-section-eyebrow {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.dg-section-title { margin: 1px 0 0; font-family: var(--font-display); font-size: 1.06rem; }
.dg-section-count {
  flex: none;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
}
.dg-section-count.is-complete { color: var(--price); }
.dg-section-hint { margin: 10px 0 12px; font-size: 0.82rem; color: var(--text-dim); line-height: 1.45; }
.dg-section-quick {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 10px;
}
.dg-quick-btn {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text-dim);
  font: 600 0.78rem var(--font-sans);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.dg-quick-btn:hover { border-color: var(--text-dim); color: var(--text); }
.dg-quick-btn.is-pass:hover {
  border-color: var(--price);
  background: #e3f6ec;
  color: #04684b;
}
.dg-quick-btn.is-na:hover {
  border-color: var(--warn);
  background: #fdf5e6;
  color: #8a4f0f;
}

.dg-test-cards { display: grid; gap: 8px; }
.dg-test-card {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 6px 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-soft);
}
.dg-test-card.state-pass { border-color: #b7e0cd; background: #f0f9f4; }
.dg-test-card.state-fail { border-color: #f2c6c0; background: #fff5f5; }
.dg-test-card.state-na { border-color: #ecd4ac; background: #fdf7ec; }
.dg-test-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text-dim);
}
.dg-test-icon .icon { width: 17px; height: 17px; }
.dg-test-name { font-size: 0.92rem; font-weight: 500; }
.dg-test-btns { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.dg-test-btn {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text-dim);
  font: 600 0.82rem var(--font-sans);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s, transform 0.1s;
}
.dg-test-btn:active { transform: scale(0.97); }
.dg-test-btn.is-pass:hover { border-color: var(--price); color: var(--price); }
.dg-test-btn.is-fail:hover { border-color: var(--danger); color: var(--danger); }
.dg-test-btn.is-na:hover { border-color: var(--warn); color: var(--warn); }
.dg-test-btn.is-pass.active { background: var(--price); border-color: var(--price); color: #fff; }
.dg-test-btn.is-fail.active { background: var(--danger); border-color: var(--danger); color: #fff; }
.dg-test-btn.is-na.active { background: var(--warn); border-color: var(--warn); color: #fff; }

/* ---- Section navigation ---- */
.dg-section-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}
.dg-section-nav .ghost-btn, .dg-section-nav .primary-btn { width: auto; flex: none; }
.dg-section-nav .primary-btn.attention { animation: dg-nudge 1.4s ease-in-out 2; }
@keyframes dg-nudge {
  0%, 100% { box-shadow: 0 0 0 0 rgba(31, 95, 191, 0.35); }
  50% { box-shadow: 0 0 0 6px rgba(31, 95, 191, 0); }
}
.dg-progress-inline { flex: 1; min-width: 0; }
.dg-progress-bar { height: 8px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; }
.dg-progress-fill { height: 100%; background: var(--accent); transition: width 0.2s ease; }
.dg-progress-sub { margin: 6px 0 0; font-size: 0.76rem; color: var(--text-dim); text-align: center; }
.dg-ink-pass { color: var(--price); font-weight: 600; }
.dg-ink-fail { color: var(--danger); font-weight: 600; }

.dg-compare-card { margin-top: 14px; padding: 16px; }
.dg-compare-title {
  margin: 0 0 12px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.dg-compare-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.dg-compare-block {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius-md);
  background: var(--bg-soft);
}
.dg-compare-block.is-fixed { border-left-color: var(--price); }
.dg-compare-block.is-still { border-left-color: var(--warn); }
.dg-compare-block.is-new { border-left-color: #c2ccd9; }
.dg-compare-block.is-new.is-alert { border-left-color: var(--danger); background: #fff5f5; }
.dg-compare-count { display: block; font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.dg-compare-block.is-fixed .dg-compare-count { color: var(--price); }
.dg-compare-block.is-still .dg-compare-count { color: var(--warn); }
.dg-compare-block.is-new.is-alert .dg-compare-count { color: var(--danger); }
.dg-compare-label { display: block; margin-bottom: 8px; font-size: 0.78rem; font-weight: 600; color: var(--text-dim); }
.dg-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.dg-chip {
  display: inline-block;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  font-size: 0.72rem;
  color: var(--text);
}
.dg-chip-none { color: var(--text-dim); border-style: dashed; }
.dg-compare-warning {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #fff5f5;
  color: var(--danger);
  font-size: 0.83rem;
  font-weight: 500;
}
.dg-compare-warning .icon { width: 16px; height: 16px; flex: none; }
.dg-compare-empty {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 0.86rem;
}
.dg-compare-empty .icon { width: 20px; height: 20px; flex: none; color: var(--accent); }
.dg-compare-empty p { margin: 0; }

/* ---- Notes / actions / saved ---- */
.dg-notes { margin-top: 14px; }
.dg-notes textarea { resize: vertical; min-height: 56px; }
.dg-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.dg-actions .primary-btn, .dg-actions .ghost-btn { width: auto; }

.dg-saved { margin-top: 26px; }
.dg-saved-title { margin: 0; font-family: var(--font-display); font-size: 1.05rem; }
.dg-saved-list { margin-top: 10px; padding: 6px; }
.dg-saved-list .ops-empty { padding: 14px; }
.dg-saved-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  border-radius: var(--radius-sm);
}
.dg-saved-row + .dg-saved-row { border-top: 1px solid var(--border); }
.dg-saved-main { flex: 1; min-width: 160px; }
.dg-saved-name { display: flex; align-items: center; gap: 7px; font-size: 0.9rem; font-weight: 500; }
.dg-saved-ticket { font-family: var(--font-mono); font-size: 0.72rem; color: var(--accent); }
.dg-saved-sub { margin-top: 2px; font-size: 0.78rem; color: var(--text-dim); }
.dg-saved-stats { display: flex; flex-wrap: wrap; gap: 6px; }
.dg-saved-stat {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg-soft);
  color: var(--text-dim);
}
.dg-saved-stat.is-fixed { background: #e3f6ec; color: #04684b; }
.dg-saved-stat.is-still { background: #fdf5e6; color: #8a4f0f; }
.dg-saved-stat.is-new { background: #fdeceb; color: var(--danger); }
.dg-saved-actions { display: flex; gap: 6px; flex: none; }
.dg-saved-actions .ghost-btn { padding: 7px 12px; font-size: 0.8rem; }

@media (max-width: 860px) {
  .dg-main { grid-template-columns: 1fr; }
  .dg-side { order: -1; }
  .dg-svg { max-width: 260px; }
  .dg-overview { grid-template-columns: 1fr 1fr; }
  .dg-overview-active { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .dg-stage-bar { grid-template-columns: 1fr; }
  .dg-overview { grid-template-columns: 1fr; }
  .dg-overview-active { grid-column: auto; }
  .dg-type-row { flex-direction: column; align-items: flex-start; }
  .dg-type-switch { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .dg-type-btn { justify-content: center; }
  .dg-section-quick { grid-template-columns: 1fr; }
  .dg-section-nav { flex-wrap: wrap; }
  .dg-section-nav .ghost-btn, .dg-section-nav .primary-btn { flex: 1; justify-content: center; }
  .dg-progress-inline { order: -1; width: 100%; flex-basis: 100%; }
  .dg-actions .primary-btn, .dg-actions .ghost-btn { flex: 1; justify-content: center; }
  .dg-saved-row { align-items: flex-start; }
  .dg-saved-actions { width: 100%; }
  .dg-saved-actions .ghost-btn { flex: 1; justify-content: center; }
}

/* ---- On-screen reminder alerts ------------------------------------------ */
/* Cards that interrupt whatever tab is open once a reminder falls due. Sits
   below .modal-backdrop (5000) on purpose: an alert must never cover a form
   someone is mid-way through filling in. */
.reminder-alerts {
  position: fixed;
  /* Bottom-right, not top-right: every screen in this app puts its primary
     action ("Add expense", "Add reminder", …) in the top-right corner, and an
     alert that covers the button you were reaching for is worse than useless. */
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  right: 16px;
  z-index: 4500;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100vh - var(--header-h) - 32px);
  overflow-y: auto;
}
.reminder-alert {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.16);
  padding: 12px 14px;
  animation: reminder-alert-in 0.22s ease-out;
}
.reminder-alert.is-cash { border-left-color: var(--price); }
@keyframes reminder-alert-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.reminder-alert-head { display: flex; align-items: flex-start; gap: 10px; }
.reminder-alert-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  background: #fdf3e6;
  color: var(--warn);
}
.reminder-alert.is-cash .reminder-alert-icon { background: #e7f6ef; color: var(--price); }
.reminder-alert-heading { min-width: 0; flex: 1; }
.reminder-alert-eyebrow {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.reminder-alert-title { margin: 2px 0 0; font-size: 0.95rem; line-height: 1.3; }
.reminder-alert-due { margin: 3px 0 0; font-size: 0.78rem; color: var(--warn); font-weight: 600; }
.reminder-alert.is-cash .reminder-alert-due { color: var(--price); }
.reminder-alert-close {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px;
  border-radius: var(--radius-sm);
}
.reminder-alert-close:hover { background: var(--bg-soft); color: var(--text); }
.reminder-alert-minimize {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px;
  border-radius: var(--radius-sm);
}
.reminder-alert-minimize:hover { background: var(--bg-soft); color: var(--text); }
.reminder-alerts.is-minimized {
  width: auto;
  align-items: flex-end;
}
.reminder-alert-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.16);
  padding: 10px 16px;
  font: 500 0.86rem var(--font-display);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  animation: reminder-alert-in 0.22s ease-out;
}
.reminder-alert-pill:hover { background: var(--bg-soft); }
.reminder-alert-pill .icon { width: 17px; height: 17px; flex: none; color: var(--warn); }
.reminder-alert-pill-chevron { transform: rotate(180deg); }
.reminder-alert-notes {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.reminder-alert-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.reminder-alert-actions .primary-btn,
.reminder-alert-actions .ghost-btn { padding: 6px 12px; font-size: 0.8rem; }
.reminder-alert-snooze {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-dim);
}
.reminder-alert-snooze .chip { padding: 3px 9px; font-size: 0.72rem; }
.reminder-alert-custom-snooze { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.reminder-alert-custom-snooze input[type="datetime-local"] {
  flex: 1 1 100%;
  padding: 7px 9px;
  font-size: 0.82rem;
}
.reminder-alert-custom-snooze .ghost-btn { flex: 1; padding: 6px 10px; font-size: 0.8rem; }
.reminder-alert-more {
  border: 1px dashed var(--border);
  background: var(--card);
  color: var(--text-dim);
  border-radius: var(--radius-md);
  padding: 8px;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}
.reminder-alert-more:hover { background: var(--card-hover); color: var(--text); }

@media (max-width: 640px) {
  .reminder-alerts {
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    right: 12px;
    left: 12px;
    width: auto;
    max-height: 70vh;
  }
}

/* Due-count badge on the Reminders nav item. */
.nav-badge {
  margin-left: auto;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

/* ---- Cash-reclaim expenses ---------------------------------------------- */
.reclaim-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-soft);
  cursor: pointer;
}
.reclaim-toggle input { margin-top: 3px; flex: none; width: 16px; height: 16px; accent-color: var(--accent); }
.reclaim-toggle span { display: block; }
.reclaim-toggle strong { display: block; font-size: 0.86rem; }
.reclaim-toggle small { display: block; color: var(--text-dim); font-size: 0.76rem; }
.reclaim-fields {
  border-left: 2px solid var(--price);
  padding-left: 12px;
}

.reclaim-strip {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin: 12px 0 4px;
}
.reclaim-strip-head { display: flex; align-items: center; gap: 12px; }
.reclaim-strip-icon { width: 22px; height: 22px; color: var(--price); }
.reclaim-strip-head strong { font-size: 1.35rem; color: var(--price); }
.reclaim-strip-count { margin-left: auto; font-size: 0.78rem; color: var(--text-dim); }
.reclaim-strip-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.reclaim-strip-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-soft);
}
.reclaim-strip-row.is-overdue { border-color: #e7b7b2; background: #fdf1f0; }
.reclaim-strip-main { min-width: 0; }
.reclaim-strip-main strong { font-size: 0.95rem; }
.reclaim-strip-main span { font-size: 0.85rem; color: var(--text); margin-left: 6px; }
.reclaim-strip-main small { display: block; font-size: 0.74rem; color: var(--text-dim); }
.reclaim-collect-btn {
  margin-left: auto;
  flex: none;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--price);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.reclaim-collect-btn:hover { background: #e7f6ef; border-color: #9ad9b8; }
.reclaim-collection-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; flex-shrink: 0; }
.reclaim-collection-actions .reclaim-collect-btn { margin-left: 0; }
.reclaim-collect-btn:disabled { opacity: 0.6; cursor: wait; }

.reclaim-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fdf3e6;
  color: var(--warn);
  font-size: 0.72rem;
  font-weight: 600;
}
.reclaim-badge .icon { width: 12px; height: 12px; }
.reclaim-badge.is-settled { background: #e7f6ef; color: var(--price); }
.expense-row.is-owed { border-left: 3px solid var(--warn); }
.rem-tag-cash { background: #e7f6ef; color: var(--price); }

/* ---- Parts orders (top-level tab) ---------------------------------------- */
.parts-order-topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
/* table-layout:auto otherwise starves this column down to its longest
   unbroken word (e.g. "Aftermarket") once the other columns' fixed-width
   chips/buttons stake their claim, wrapping the part name letter by letter
   instead of by word. */
.parts-order-table td:first-child,
.parts-order-table th:first-child {
  min-width: 260px;
}
.parts-order-status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg-soft);
  color: var(--text-dim);
  white-space: nowrap;
}
.parts-order-status-ordered { background: #fdf3e6; color: var(--warn); }
.parts-order-status-backordered { background: #fdecea; color: var(--danger); }
.parts-order-status-arrived { background: #e7f6ef; color: var(--price); }
.parts-order-arrived-toggle { border: 0; cursor: pointer; font-family: inherit; }
.parts-order-arrived-toggle:hover,
.parts-order-arrived-toggle:focus-visible { background: #ccefdc; outline: 2px solid var(--price); outline-offset: 2px; }
.parts-order-source-filter {
  appearance: none;
  -webkit-appearance: none;
  min-height: 40px;
  max-width: min(260px, 100%);
  padding: 0 46px 0 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font: 600 0.82rem var(--font-display);
  cursor: pointer;
  outline: none;
  box-shadow: none;
}
.parts-order-source-filter:focus,
.parts-order-source-filter:focus-visible { outline: none; box-shadow: none; border-color: var(--accent); }
.parts-orders-toggle-all {
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: 600 0.8rem var(--font-display);
  cursor: pointer;
  white-space: nowrap;
}
.parts-orders-toggle-all:hover,
.parts-orders-toggle-all:focus-visible { text-decoration: underline; outline: none; }
.parts-order-status-cancelled { background: var(--bg-soft); color: var(--text-dim); }
.parts-order-row.is-cancelled { opacity: 0.65; }
.parts-order-arrived-btn {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid #9ad9b8;
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--price);
  font: 500 0.82rem var(--font-display);
  cursor: pointer;
  white-space: nowrap;
}
.parts-order-arrived-btn:hover { background: #e7f6ef; }
.parts-order-payment-btn {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font: 500 0.82rem var(--font-display);
  cursor: pointer;
  white-space: nowrap;
}
.parts-order-payment-btn.is-pending {
  border: 1px solid #f3d9a7;
  background: #fffbeb;
  color: var(--warn);
}
.parts-order-payment-btn.is-pending:hover { background: #fdf3e6; }
.parts-order-payment-btn.is-collected {
  border: 1px solid #9ad9b8;
  background: var(--card);
  color: var(--price);
}
.parts-order-payment-btn.is-collected:hover { background: #e7f6ef; }
.parts-order-cost-sub {
  display: block;
  margin-top: 2px;
  color: var(--text-dim);
  font-size: 0.76rem;
}
.parts-order-empty-cell { color: var(--text-dim); }
.parts-order-customer-text { color: var(--text); }
.parts-order-link-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--accent);
  font: 500 0.82rem var(--font-display);
  width: 100%;
  max-width: 220px;
}
.parts-order-link-chip .icon { width: 14px; height: 14px; flex: none; }
.parts-order-destination-cell { display: flex; flex-direction: column; gap: 5px; }
.parts-order-match-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.parts-order-match {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px dashed rgba(31, 95, 191, 0.4);
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  font: 500 0.76rem var(--font-display);
  cursor: pointer;
  width: 100%;
  max-width: 220px;
  text-align: left;
}
.parts-order-match:hover { background: rgba(31, 95, 191, 0.08); }
.parts-order-match .icon { width: 12px; height: 12px; flex: none; }
.parts-order-link-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 0 14px;
  max-height: 240px;
  overflow-y: auto;
}
.parts-order-link-list:empty { display: none; margin: 0; }
.parts-order-inventory-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 30px;
  padding: 6px 9px;
  border: 1px dashed rgba(19, 126, 82, 0.44);
  border-radius: 8px;
  background: transparent;
  color: var(--price);
  font: 600 0.72rem var(--font-display);
  cursor: pointer;
  white-space: nowrap;
}
.parts-order-inventory-option:hover { background: rgba(19, 126, 82, 0.08); }
.parts-order-inventory-option .icon { width: 13px; height: 13px; }
.parts-order-inventory-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: 230px;
  padding: 6px 11px;
  border: 1px solid rgba(19, 126, 82, 0.24);
  border-radius: 8px;
  background: rgba(19, 126, 82, 0.08);
  color: var(--price);
  font: 600 0.78rem var(--font-display);
}
.parts-order-inventory-chip .icon { width: 14px; height: 14px; flex: none; }
.parts-order-inventory-new-fields > .form-grid { margin: 0; }
.parts-order-inventory-note { margin: 14px 0 0; }
.parts-order-chip-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.parts-order-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.parts-order-icon-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.parts-order-shipment-header td {
  padding: 0 !important;
  border-bottom: 0 !important;
}
.parts-order-shipment-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.parts-order-shipment-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  padding: 4px;
  margin: -4px;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.parts-order-shipment-info:hover { background: rgba(15, 23, 42, 0.05); }
.parts-order-shipment-info .icon { width: 20px; height: 20px; flex: none; color: var(--text-dim); }
.parts-order-shipment-chevron {
  transition: transform 0.15s ease;
}
.parts-order-shipment-chevron.is-collapsed { transform: rotate(-90deg); }
.parts-order-shipment-info strong { display: block; }
.parts-order-shipment-info small { display: block; color: var(--text-dim); font-size: 0.78rem; }
.parts-order-shipment-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.parts-order-shipment-item td:first-child { padding-left: 30px; }
.parts-order-review-row {
  display: grid;
  grid-template-columns: 1fr 70px 90px auto;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}
.parts-order-review-row .text-input { padding: 8px 10px; }
@media (max-width: 480px) {
  .parts-order-review-row { grid-template-columns: 1fr 1fr; grid-template-areas: "part part" "qty cost" "remove remove"; }
  .parts-order-review-row input[data-review-field="part"] { grid-area: part; }
  .parts-order-review-row input[data-review-field="quantity"] { grid-area: qty; }
  .parts-order-review-row input[data-review-field="unitCost"] { grid-area: cost; }
  .parts-order-review-row button { grid-area: remove; justify-self: end; }
}

/* ---- Reminder alert preferences (Settings › General) -------------------- */
.settings-divider { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.alert-prefs { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 12px; max-width: 460px; }
.expense-remind-btn { color: var(--accent); }
.alert-voice-field { max-width: 460px; margin-bottom: 12px; }
.rem-tag-appointment { background: #eff6ff; color: #2563eb; }
.reminder-alert.is-appointment { border-left-color: #2563eb; }
.reminder-alert.is-appointment .reminder-alert-icon { background: #eff6ff; color: #2563eb; }
.reminder-alert.is-appointment .reminder-alert-due { color: #2563eb; }

/* ---- Offline indicator -------------------------------------------------- */
/* Sits above the toast stack's anchor but below modals, so staff always know
   when a price on screen is the saved copy rather than a live one. */
.offline-pill {
  position: fixed;
  left: 50%;
  bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 4400;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.25);
  pointer-events: none;
  white-space: nowrap;
}
.offline-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f0b429;
  flex: none;
}

/* ---- Ticket notes (timeline modal) -------------------------------------- */
.ticket-note-form { margin: 0 0 8px; }
.ticket-note-input { width: 100%; }
.ticket-note-list { display: flex; flex-direction: column; gap: 6px; }
.ticket-note-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-soft);
}
/* The check-in note comes from the ticket form and prints on the customer's
   invoice, so it reads as a quieter, non-removable entry. */
.ticket-note-item.is-checkin { background: var(--card); border-style: dashed; }
.ticket-note-body { flex: 1; min-width: 0; }
.ticket-note-text { margin: 0; font-size: 0.86rem; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.ticket-note-when { display: block; margin-top: 2px; font-size: 0.72rem; color: var(--text-dim); }
.ticket-note-delete {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px;
  border-radius: var(--radius-sm);
}
.ticket-note-delete:hover { background: var(--card); color: var(--danger); }
.ticket-note-delete .icon { width: 14px; height: 14px; }
.ticket-note-empty { margin: 0; font-size: 0.82rem; color: var(--text-dim); }

/* ============ ACCOUNT — card takings ledger ============
   Money that has been taken but is sitting in someone else's account until
   they transfer it across. The three states each get their own hue so the
   answer to "what's actually owed to us" is readable without stopping to
   read numbers: amber = still in flight, teal = landed and owed, green =
   collected. Deliberately separate from the accent so a payment's state
   never reads as "selected". */
.acct-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin: 16px 0 4px;
}
.acct-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.acct-tile strong {
  font: 600 1.5rem/1.15 var(--font-display);
  font-variant-numeric: tabular-nums;
}
.acct-tile small { color: var(--text-dim); font-size: 0.76rem; }
/* Only the two tiles that answer "where is the money" carry a rail; giving
   every tile one would flatten them back into a uniform row. */
.acct-tile-owed { border-left: 3px solid #0f7285; }
.acct-tile-owed strong { color: #0f7285; }
.acct-tile-pending { border-left: 3px solid var(--warn); }
.acct-tile-pending strong { color: var(--warn); }
.bank-tile-deposit { border-left: 3px solid var(--price); }
.bank-tile-deposit strong, .bank-amount-deposit { color: var(--price); }
.bank-tile-withdrawal { border-left: 3px solid var(--danger); }
.bank-tile-withdrawal strong, .bank-amount-withdrawal, .money-negative { color: var(--danger) !important; }
.bank-amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.bank-pill-deposit { background: #e2f2e7; color: var(--price); }
.bank-pill-withdrawal { background: #fce8e6; color: var(--danger); }
.bank-transaction-row > div:first-child { min-width: 0; }

.acct-section { margin-top: 28px; }
.acct-overdue {
  border-color: var(--warn);
  background: #fdf6ec;
  color: #7c4409;
}

.acct-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font: 600 0.72rem var(--font-display);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.acct-pill-pending { background: #fbf1dd; color: #8a5a10; }
.acct-pill-settled { background: #ddf0f4; color: #0f7285; }
.acct-pill-collected { background: #e2f2e7; color: var(--price); }
.acct-pill-void { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }

.acct-row { align-items: flex-start; }
.acct-row small { display: block; color: var(--text-dim); font-size: 0.76rem; }
.acct-row small:empty { display: none; }
.acct-row-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex: none;
}
.acct-row.is-void > div:first-child > strong,
.acct-row.is-void > div:first-child > p { text-decoration: line-through; opacity: 0.65; }
.acct-void-note { color: var(--danger) !important; }
.acct-cardtype {
  font: 500 0.7rem var(--font-display);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: 4px;
}

/* Fee and net, side by side in the payment form: the customer's number and
   the shop's number are different, and the form should say so before saving. */
.acct-fee-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: var(--bg-soft);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}
.acct-fee-row strong {
  font: 600 1.15rem var(--font-display);
  font-variant-numeric: tabular-nums;
}

/* Payout picker: a checklist that arrives pre-ticked, because the usual case
   is "he sent the whole batch". */
.acct-pick-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 42vh;
  overflow-y: auto;
  padding: 2px;
}
.acct-pick {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
  background: var(--card);
}
.acct-pick.is-picked { border-color: var(--accent); background: var(--accent-soft); }
.acct-pick input { margin-top: 3px; flex: none; }
.acct-pick-body { display: flex; flex-direction: column; gap: 1px; }
.acct-pick-body strong { font-variant-numeric: tabular-nums; }
.acct-pick-body small { color: var(--text-dim); font-size: 0.76rem; }
.acct-payout-actions { display: flex; gap: 6px; }
.acct-payout-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding-bottom: 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.acct-payout-total span { color: var(--text-dim); font-size: 0.82rem; }
.acct-payout-total strong {
  font: 600 1.35rem var(--font-display);
  font-variant-numeric: tabular-nums;
  color: var(--price);
}
.chip-count {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}
.chip.active .chip-count { background: rgba(255, 255, 255, 0.25); }

@media (max-width: 560px) {
  .acct-row-side { align-items: flex-start; }
  .bank-transaction-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .bank-transaction-row .acct-row-side { align-items: flex-end; }
}
/* "$0.75" and "$0.00" side by side need almost no width, and this row sits
   inside a modal that is narrower than the viewport — stacking it at 560px
   spent ~50px of height for nothing and pushed the form's last field out of
   view. Only stack it where the two figures genuinely collide. */
@media (max-width: 330px) {
  .acct-fee-row { grid-template-columns: 1fr; gap: 6px; }
}
/* This form is filled in on a phone at the counter, so it has to fit without
   scrolling past "Save". The shared grid drops to one column under 460px,
   which stacks all seven fields and pushes the button off screen; these four
   are short enough to stay paired on a 360px phone. */
@media (max-width: 460px) {
  #cardPayForm .form-grid { grid-template-columns: 1fr 1fr; }
}
.ticket-card-hint { color: var(--text-dim); font-weight: 400; font-size: 0.82em; }
.acct-settings-grid { max-width: 560px; margin-bottom: 12px; }
.acct-overview-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* The card payment form is the one modal staff fill in at the counter with a
   customer waiting, so it earns more of the screen than the shared 82vh/640px
   allowance gives it — scrolling to reach "Save" while someone stands there is
   the whole complaint. Scoped rather than raising the global cap, which every
   other modal is sized against. */
#cardPayFormModal .modal-panel { max-height: min(92vh, 720px); }

/* Partial cash collections keep the original expense and remaining debt visible. */
.collection-totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 16px 0; }
.collection-totals > div { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px; }
.collection-totals span, .collection-history-row small { display: block; color: var(--text-dim); font-size: 0.78rem; }
.collection-totals strong { display: block; margin-top: 4px; overflow-wrap: anywhere; }
.collection-history-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--border); padding: 12px 0; }
.collection-history-row > div { min-width: 0; overflow-wrap: anywhere; }
.collection-history-row.is-voided { color: var(--text-dim); }
#expenseCollectionStatus { font-size: 0.85rem; }
#expenseCollectionFill { margin-top: 6px; }
@media (max-width: 480px) {
  .collection-totals { gap: 6px; }
  .collection-totals > div { padding: 8px; }
  .reclaim-strip-row { flex-wrap: wrap; }
}
