:root {
  --bg: #f5f5f7;
  --panel: #ffffff;
  --panel-soft: linear-gradient(180deg, rgba(255,250,241,.98), rgba(250,240,227,.98));
  --card-bg: linear-gradient(180deg, rgba(255,255,255,.85), rgba(255,250,241,.98));
  --ink: #1f2430;
  --muted: #6c7280;
  --line: #d4d7e2;
  --accent: #ff7a1a;
  --accent-soft: rgba(255, 122, 26, 0.12);
  --accent-strong: #2ecc71;
  --danger: #e74c3c;
  --shadow: 0 14px 30px rgba(15, 20, 40, 0.1);
  --invoice-font-scale: 1.0;
  --field-bg: #fdfdff;
  --simple-note-bg: #fff;
  --flash-bg: #fff;
  --ghost-hover-bg: rgba(255, 122, 26, 0.12);
  --ghost-hover-ink: #ff7a1a;
}

html[data-theme="light"] {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --panel-soft: linear-gradient(180deg, rgba(255,255,255,.98), rgba(248,250,255,.98));
  --card-bg: linear-gradient(180deg, rgba(255,255,255,.98), rgba(249,250,253,.98));
  --ink: #1f2430;
  --muted: #6c7280;
  --line: #d6dbe5;
  --field-bg: #ffffff;
  --simple-note-bg: #fbfcff;
  --flash-bg: #ffffff;
  --shadow: 0 14px 30px rgba(15, 20, 40, 0.08);
}

html[data-theme="warm"] {
  --bg: #f5f5f7;
  --panel: #ffffff;
  --panel-soft: linear-gradient(180deg, rgba(255,250,241,.98), rgba(250,240,227,.98));
  --card-bg: linear-gradient(180deg, rgba(255,255,255,.85), rgba(255,250,241,.98));
  --ink: #1f2430;
  --muted: #6c7280;
  --line: #d4d7e2;
  --field-bg: #fdfdff;
  --simple-note-bg: #fff;
  --flash-bg: #fff;
}

html[data-theme="dark"] {
  --bg: #0f141d;
  --panel: #161d29;
  --panel-soft: linear-gradient(180deg, rgba(26,34,46,.98), rgba(20,27,38,.98));
  --card-bg: linear-gradient(180deg, rgba(24,32,44,.98), rgba(19,26,37,.98));
  --ink: #eef3fb;
  --muted: #95a1b4;
  --line: #2c384a;
  --accent-soft: rgba(255, 122, 26, 0.18);
  --shadow: 0 18px 36px rgba(0, 0, 0, 0.34);
  --field-bg: #111823;
  --simple-note-bg: #121926;
  --flash-bg: #161d29;
  --ghost-hover-bg: rgba(255, 122, 26, 0.14);
  --ghost-hover-ink: #ffd1b0;
}

html[data-theme="dark"] .topbar,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .card,
html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .invoice-page,
html[data-theme="dark"] .summary-panel-inline,
html[data-theme="dark"] .activity-card,
html[data-theme="dark"] .admin-table,
html[data-theme="dark"] .metric,
html[data-theme="dark"] .profit-block {
  border-color: var(--line);
}

html[data-theme="dark"] .theme-switcher {
  background: rgba(17, 24, 35, 0.92);
}

html[data-theme="dark"] .simple-note,
html[data-theme="dark"] .profit-block,
html[data-theme="dark"] .summary-panel-inline,
html[data-theme="dark"] .activity-card,
html[data-theme="dark"] .metric,
html[data-theme="dark"] .admin-table,
html[data-theme="dark"] .pricing-toggle-row,
html[data-theme="dark"] .smart-suggestions,
html[data-theme="dark"] .preset-admin-form,
html[data-theme="dark"] .preset-admin-card,
html[data-theme="dark"] .preset-problem-row {
  background: #121926;
}

html[data-theme="dark"] .metric.optional {
  background: #172235;
}

html[data-theme="dark"] .admin-table th,
html[data-theme="dark"] .admin-table td,
html[data-theme="dark"] th,
html[data-theme="dark"] td {
  border-bottom-color: var(--line);
}

html[data-theme="dark"] .topbar h1,
html[data-theme="dark"] .card h2,
html[data-theme="dark"] .metric strong,
html[data-theme="dark"] .activity-card strong,
html[data-theme="dark"] .legacy-brand-title {
  color: #f3f7ff;
}

html[data-theme="dark"] .muted,
html[data-theme="dark"] .formula-note,
html[data-theme="dark"] .topbar .muted,
html[data-theme="dark"] .activity-meta,
html[data-theme="dark"] .legacy-brand-meta,
html[data-theme="dark"] .invoice-scale-control,
html[data-theme="dark"] label span,
html[data-theme="dark"] .field-label,
html[data-theme="dark"] .rows-head,
html[data-theme="dark"] .metric span,
html[data-theme="dark"] .admin-table th,
html[data-theme="dark"] .ghost-btn,
html[data-theme="dark"] .icon-btn {
  color: #aab6c8;
}

html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select,
html[data-theme="dark"] .table-field {
  color: #eef3fb;
  background: #111823;
  border-color: #344255;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: #77859a;
}

html[data-theme="dark"] .smart-pill {
  background: #172235;
  color: #eef3fb;
  border-color: rgba(255, 122, 26, 0.32);
}

html[data-theme="dark"] input[disabled],
html[data-theme="dark"] select[disabled] {
  background: #182130;
  color: #8d99ab;
}

html[data-theme="dark"] .chip {
  background: #141c28;
  color: #d8e0ec;
  border-color: #39485d;
}

html[data-theme="dark"] .chip.active {
  background: rgba(255, 122, 26, 0.18);
  color: #ffd1b0;
  border-color: #ff7a1a;
}

html[data-theme="dark"] .pricing-preset-chip {
  background: #141c28;
  border-color: #39485d;
  color: #eef3fb;
}

html[data-theme="dark"] .pricing-preset-chip.active {
  background: linear-gradient(135deg, rgba(255, 122, 26, 0.24), rgba(245, 197, 66, 0.12));
  border-color: #ff7a1a;
}

html[data-theme="dark"] .my-cost-head {
  color: #f3f7ff;
}

html[data-theme="dark"] .my-cost-field input {
  background: #17202d;
  color: #f6f9ff;
  border-color: #4a5b73;
}

html[data-theme="dark"] .profit-metric {
  background: #17202d;
  border-color: #344255;
}

html[data-theme="dark"] .profit-metric.accent {
  background: rgba(255, 122, 26, 0.12);
  border-color: rgba(255, 122, 26, 0.3);
}

html[data-theme="dark"] .alert,
html[data-theme="dark"] .error-box {
  background: #2a1820;
  color: #ffd9d9;
}

html[data-theme="dark"] .legacy-invoice,
html[data-theme="dark"] .invoice-page-inner {
  color: #eef3fb;
}

html[data-theme="dark"] .legacy-invoice {
  background: #141b27;
  border-color: #2d3a4c;
}

html[data-theme="dark"] .legacy-card,
html[data-theme="dark"] .legacy-pay-block,
html[data-theme="dark"] .legacy-side-note {
  background: #17202d;
  border-color: #344255;
}

html[data-theme="dark"] .legacy-k,
html[data-theme="dark"] .legacy-section-title,
html[data-theme="dark"] .legacy-deposit-status,
html[data-theme="dark"] .legacy-pay-note {
  color: #aab6c8;
}

html[data-theme="dark"] .legacy-v,
html[data-theme="dark"] .legacy-copy,
html[data-theme="dark"] .legacy-pay-row,
html[data-theme="dark"] .legacy-totals-table,
html[data-theme="dark"] .legacy-formula-note {
  color: #eef3fb;
}

html[data-theme="dark"] .legacy-inline-fill {
  border-bottom-color: #6b7b94;
}

html[data-theme="dark"] .legacy-pay-box,
html[data-theme="dark"] .legacy-status-box {
  border-color: #6b7b94;
  background: #111823;
  color: #f6f9ff;
}

html[data-theme="dark"] .status-pill-active {
  background: rgba(46, 204, 113, 0.18);
  color: #8df0b8;
}

html[data-theme="dark"] .status-pill-inactive {
  background: rgba(231, 76, 60, 0.18);
  color: #ffb4aa;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.flash-stack {
  position: sticky;
  top: 8px;
  z-index: 30;
  width: min(1580px, calc(100vw - 8px));
  margin: 8px auto 0;
  display: grid;
  gap: 8px;
}

.flash {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--flash-bg);
  box-shadow: 0 10px 24px rgba(15, 20, 40, 0.08);
  font-size: 13px;
}

.flash-success {
  border-color: rgba(46, 204, 113, 0.35);
  background: #f2fff7;
}

.flash-error {
  border-color: rgba(231, 76, 60, 0.28);
  background: #fff4f2;
}

textarea, input, select, button { font: inherit; }

.page-shell, .invoice-shell {
  width: min(1580px, calc(100vw - 8px));
  margin: 6px auto 14px;
}

.topbar, .panel, .card, .auth-card, .invoice-page {
  background: var(--panel);
  border: 1px solid rgba(93, 77, 61, 0.14);
  box-shadow: var(--shadow);
}

.topbar, .panel, .auth-card { border-radius: 28px; }

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  margin-bottom: 6px;
  background: var(--panel-soft);
}

.topbar-actions,
.app-nav,
.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.panel { padding: 8px; }
.summary-panel { margin-top: 6px; }
.card { border-radius: 12px; padding: 8px; background: var(--card-bg); }

.card-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.card-kicker {
  margin-bottom: 10px;
}

.compact-panel {
  padding: 6px;
}

.simple-note {
  margin-bottom: 6px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(212, 215, 226, 0.9);
  background: var(--simple-note-bg);
  color: var(--muted);
  font-size: 11px;
}

.topbar-brand {
  min-width: 0;
}

.topbar-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.theme-switcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
}

.theme-switcher span {
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.theme-switcher select {
  min-height: 30px;
  width: auto;
  min-width: 108px;
  padding: 4px 28px 4px 10px;
  border-radius: 999px;
}

.compact-grid {
  grid-template-columns: 1fr;
  gap: 6px;
}

.compact-card {
  padding: 6px;
}

.backup-actions {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}

.backup-import-form {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}

.backup-file-field,
.backup-mode-field {
  min-width: 220px;
}

.job-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.95fr);
  gap: 10px;
  align-items: start;
}

.job-left,
.job-right {
  min-width: 0;
}

.job-right {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.compact-fields {
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 5px;
}

.compact-fields-main {
  grid-template-columns: repeat(8, minmax(0, 1fr));
}

.compact-fields-job {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.compact-fields-pricing {
  grid-template-columns: repeat(8, minmax(0, 1fr));
}

.compact-fields-pricing-tight {
  grid-template-columns: repeat(6, minmax(78px, 1fr));
  gap: 5px 7px;
}

.section-grid {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 18px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.field-grid .span-2 { grid-column: span 2; }
.field-grid .span-3 { grid-column: span 3; }
.field-grid .span-4 { grid-column: span 4; }
.field-grid .span-full { grid-column: 1 / -1; }

label, .stack, .stack-12, .stack-24 {
  display: flex;
  flex-direction: column;
}

.stack, .stack-12, .stack-24 { gap: 16px; }
.stack-12 { gap: 12px; }
.stack-24 { gap: 24px; }

label span {
  margin-bottom: 2px;
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--field-bg);
  border-radius: 7px;
  padding: 3px 6px;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
  font-size: 11px;
  min-height: 28px;
}

textarea { min-height: 54px; resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #cf6d46;
  box-shadow: 0 0 0 2px rgba(187, 77, 36, 0.12);
}

.toggle {
  flex-direction: row;
  align-items: center;
  gap: 5px;
  padding-top: 12px;
  min-height: 26px;
  font-size: 10px;
}

.toggle span { margin: 0; }
.toggle input { width: auto; min-height: auto; }

.toggle-inline {
  padding-top: 16px;
  min-height: 28px;
}

.primary-btn, .secondary-btn, .ghost-btn, .icon-btn {
  border: 0;
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 18px rgba(255, 122, 26, 0.45);
}

.secondary-btn {
  background: var(--accent-strong);
  color: white;
  box-shadow: 0 8px 18px rgba(46, 204, 113, 0.28);
}

.ghost-btn, .icon-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
}
.primary-btn:hover, .secondary-btn:hover, .ghost-btn:hover, .icon-btn:hover {
  transform: translateY(-1px);
}

.ghost-btn:hover, .icon-btn:hover {
  background: var(--ghost-hover-bg);
  color: var(--ghost-hover-ink);
}

.icon-btn { align-self: stretch; }

.calculator-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 184px;
  gap: 10px;
  align-items: start;
}

.calculator-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 328px;
  gap: 10px;
  align-items: start;
}

.calculator-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.calculator-actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
  justify-self: end;
  width: 100%;
  max-width: 184px;
}

.calculator-actions .primary-btn,
.calculator-actions .secondary-btn,
.calculator-actions .ghost-btn {
  width: 100%;
  justify-content: center;
}

.calc-btn-calc {
  background: #f5c542;
  color: #000;
  box-shadow: 0 8px 18px rgba(245, 197, 66, 0.35);
}

.calc-btn-generate {
  background: #2ecc71;
  color: #fff;
  box-shadow: 0 8px 18px rgba(46, 204, 113, 0.28);
}

.calc-btn-pdf {
  background: transparent;
  color: var(--muted);
}

.calc-btn-clear {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 8px 18px rgba(231, 76, 60, 0.25);
}

.calc-btn-st {
  padding: 6px 12px;
}

.pricing-preset-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  align-items: stretch;
  max-width: 560px;
}

.pricing-preset-chip {
  border: 1px solid rgba(93, 77, 61, 0.16);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  min-height: 42px;
  padding: 6px 11px;
  text-align: left;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.pricing-preset-chip:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 122, 26, 0.42);
  box-shadow: 0 8px 18px rgba(255, 122, 26, 0.14);
}

.pricing-preset-chip strong {
  font-size: 12px;
  line-height: 1.05;
}

.pricing-preset-chip span {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.08em;
  line-height: 1.1;
  text-transform: uppercase;
}

.pricing-preset-chip.active {
  background: linear-gradient(135deg, rgba(255, 122, 26, 0.18), rgba(245, 197, 66, 0.14));
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 122, 26, 0.12);
}

.pricing-preset-feedback {
  color: var(--muted);
  font-size: 12px;
  margin: -2px 0 8px;
  min-height: 16px;
}

.pricing-rules-details {
  min-width: 0;
}

.pricing-rules-details summary {
  align-items: center;
  background: rgba(250, 252, 255, 0.92);
  border: 1px solid rgba(93, 77, 61, 0.12);
  border-radius: 12px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
  padding: 8px 12px;
  user-select: none;
}

.pricing-rules-details summary span {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pricing-rules-details summary small {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.pricing-rules-details[open] summary {
  margin-bottom: 8px;
}

html[data-theme="dark"] .pricing-rules-details summary {
  background: #121926;
  border-color: #2c384a;
}

.status-inline-group {
  display: grid;
  grid-template-columns: 118px auto auto;
  gap: 6px;
  align-items: end;
  justify-content: end;
  justify-items: start;
}

.deposit-preset-field,
.deposit-status-field {
  width: 118px;
  justify-self: end;
}

.deposit-preset-field select,
.deposit-status-field select {
  min-width: 0;
}

.zelle-field {
  width: 260px;
  max-width: 100%;
  justify-self: end;
  margin-left: auto;
}

.zelle-field select {
  min-width: 0;
}

.pricing-toggle-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px 8px;
  align-items: end;
  grid-column: 1 / -1;
  min-width: 0;
  padding: 4px 6px;
  border: 1px solid rgba(93, 77, 61, 0.12);
  border-radius: 10px;
  background: rgba(250, 252, 255, 0.92);
  overflow-x: auto;
}

.compact-inline-toggle {
  padding-top: 11px;
  min-height: 28px;
  white-space: nowrap;
  flex: 0 0 auto;
}

.compact-inline-field span {
  white-space: nowrap;
}

.compact-inline-field {
  min-width: 96px;
  flex: 0 0 108px;
}

.compact-inline-field input {
  min-height: 28px;
}

.deposit-amount-label {
  min-width: 0;
}

.label-inline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mini-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.02em;
  text-transform: none;
}

.mini-toggle input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.mini-toggle span {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.02em;
  text-transform: none;
}

input[disabled],
select[disabled] {
  background: #f3f4f8;
  color: #7b8191;
  cursor: not-allowed;
  opacity: 1;
}

.tech-percent-wrap label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tech-percent-wrap input {
  width: 100%;
}

.profit-block {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--field-bg);
  font-size: 12px;
  line-height: 1.45;
}

.profit-block strong {
  display: block;
  margin-bottom: 4px;
}

.profit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.profit-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 122, 26, 0.14);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.profit-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.profit-metric {
  padding: 8px 9px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
}

.profit-metric span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.profit-metric strong {
  margin: 0;
  font-size: 17px;
}

.profit-metric.accent {
  border-color: rgba(255, 122, 26, 0.26);
  background: rgba(255, 122, 26, 0.08);
}

.summary-panel-inline {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px 12px;
}

.summary-panel-inline h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.summary-grid-inline {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.summary-grid-inline .metric {
  padding: 8px;
}

.table-wrap {
  overflow-x: auto;
}

.history-filters,
.admin-inline-form {
  display: flex;
  gap: 8px;
  align-items: end;
  flex-wrap: wrap;
}

.history-filters {
  margin: 10px 0 14px;
}

.history-filters label {
  min-width: 180px;
  flex: 1 1 220px;
}

.history-filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.history-bulk-bar,
.history-bulk-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.history-bulk-bar {
  justify-content: space-between;
  margin: 0 0 10px;
}

.checkbox-col {
  width: 42px;
  text-align: center !important;
}

.checkbox-col input {
  width: 16px;
  height: 16px;
}

.danger-ghost {
  border-color: rgba(231, 76, 60, 0.28);
  color: var(--danger);
}

.activity-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.activity-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
}

.activity-card-head,
.activity-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
  flex-wrap: wrap;
}

.activity-card-head {
  margin-bottom: 10px;
}

.activity-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.activity-meta {
  font-size: 12px;
  color: var(--muted);
}

.technician-recent-block {
  margin-top: 16px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 14px;
}

.admin-table th,
.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.admin-inline-form input,
.admin-inline-form select {
  min-width: 120px;
}

.table-field {
  min-width: 110px;
  width: 100%;
}

.table-password {
  min-width: 132px;
}

.table-toggle {
  padding-top: 0;
  min-height: auto;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-pill-active {
  background: rgba(46, 204, 113, 0.14);
  color: #198754;
}

.status-pill-inactive {
  background: rgba(231, 76, 60, 0.12);
  color: #b64a3a;
}

.empty-state {
  padding: 16px 6px;
}

.actions, .section-header, .invoice-toolbar, .invoice-header, .invoice-columns, .invoice-split, .invoice-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.actions-wrap { flex-wrap: wrap; }
.actions {
  gap: 6px;
}

.rows-head, .row-grid {
  display: grid;
  gap: 5px;
}

.parts-head, .parts-row {
  grid-template-columns: minmax(220px, 1.8fr) repeat(3, minmax(88px, 0.65fr)) minmax(72px, 0.35fr) auto;
}

.services-head, .services-row {
  grid-template-columns: minmax(220px, 1.8fr) minmax(88px, 0.75fr) minmax(72px, 0.35fr) minmax(72px, 0.35fr) auto;
}

.rows-head {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.my-cost-head {
  color: #111827;
  font-weight: 800;
}

.optional-line-toggle {
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.optional-line-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.my-cost-field input {
  background: #f7f9fc;
  border-color: #667085;
  color: #111827;
  font-weight: 700;
}

.my-cost-field input:focus {
  border-color: #4b5563;
  box-shadow: 0 0 0 2px rgba(75, 85, 99, 0.14);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric {
  border-radius: 16px;
  padding: 8px;
  background: #fff;
  border: 1px solid rgba(93, 77, 61, 0.12);
}

.metric span {
  display: block;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 9px;
}

.metric strong { font-size: 18px; }
.metric.accent { background: linear-gradient(135deg, #fff5ea, #f6dcc9); }
.metric.optional {
  border-style: dashed;
  background: linear-gradient(135deg, #fffaf2, #fff4df);
}
.formula-note, .muted { color: var(--muted); }

.eyebrow {
  margin: 0 0 2px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-size: 9px;
}

.topbar h1 {
  margin: 0 0 1px;
  font-size: 18px;
}

.topbar .muted {
  margin: 0;
  font-size: 11px;
}

.card h2 {
  margin: 0 0 4px;
  font-size: 14px;
}

.compact-card-main {
  width: 100%;
}

.field-label {
  margin-bottom: 2px;
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
}

.appliance-block {
  display: flex;
  flex-direction: column;
}

.chip-select {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  align-content: flex-start;
}

.chip {
  border: 1px solid rgba(212, 215, 226, 1);
  background: #fff;
  color: #4a423a;
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 9px;
  cursor: pointer;
}

.parts-row input[type="password"] {
  letter-spacing: 0.12em;
}

.chip.active {
  border-color: #ff7a1a;
  background: rgba(255, 122, 26, 0.1);
  color: #bb4d24;
  font-weight: 700;
}

.smart-assist {
  display: grid;
  gap: 6px;
}

.smart-suggestions {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  background: rgba(255, 250, 242, 0.78);
}

.smart-suggestions-title {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.smart-suggestions-content,
.smart-suggestion-group,
.smart-suggestion-group > div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.smart-suggestion-group {
  width: 100%;
  align-items: center;
}

.smart-suggestion-group strong {
  font-size: 11px;
}

.smart-pill {
  border: 1px solid rgba(255, 122, 26, 0.25);
  border-radius: 999px;
  padding: 6px 9px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.smart-pill span {
  color: var(--accent);
  margin-left: 4px;
}

.smart-empty {
  color: var(--muted);
  font-size: 12px;
}

.preset-admin-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.preset-admin-form,
.preset-admin-card,
.preset-problem-row {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: var(--card-bg);
}

.preset-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.preset-card-head,
.preset-problem-head,
.preset-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.preset-problem-list,
.preset-list {
  display: grid;
  gap: 7px;
}

.preset-problem-head code {
  display: inline-flex;
  margin-left: 8px;
  color: var(--muted);
  font-size: 11px;
}

.preset-list > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.preset-list-row {
  padding: 6px 0;
  border-top: 1px solid var(--line);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(460px, 100%);
  padding: 28px;
  border-radius: 28px;
}

.alert, .error-box {
  border-radius: 16px;
  padding: 14px 16px;
  background: #fff0ea;
  color: #8b2d0f;
}

.invoice-toolbar { margin-bottom: 8px; }
.invoice-toolbar-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.invoice-mobile-toggle {
  display: none;
}

.invoice-scale-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}
.invoice-scale-control span {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
}
.invoice-scale-control select {
  min-height: 28px;
  width: auto;
  padding-right: 24px;
}
.invoice-page { border-radius: 24px; padding: 0; overflow: hidden; }
.invoice-meta { min-width: 240px; }

.invoice-meta div, .invoice-footer div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.invoice-block { margin-top: 28px; }

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 12px 0;
  border-bottom: 1px solid rgba(93, 77, 61, 0.18);
}

.totals-table .strong td { font-weight: 700; }

.legacy-invoice {
  background: #fff;
  border: 1px solid #d4d7e2;
}

.invoice-page-inner {
  width: 100%;
  max-width: 1040px;
  min-height: auto;
  margin: 0 auto;
  padding: 6px;
  color: #1f2430;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.pdf-body .invoice-page-inner {
  max-width: 210mm;
  min-height: 297mm;
}

.legacy-topbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: start;
  gap: 10px;
  margin-bottom: 14px;
  padding-top: 6px;
}

.legacy-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.legacy-brand-line {
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #ff7a1a, transparent);
  margin-bottom: 6px;
}

.legacy-brand-title {
  font-size: 20px;
  margin: 0;
  line-height: 1.2;
  font-weight: 900;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.legacy-brand-meta {
  font-size: 10.5px;
  color: #6c7280;
  line-height: 1.2;
  word-break: break-word;
  opacity: .9;
}

.legacy-tag {
  font-size: 11px;
  color: #fff;
  background: #ff7a1a;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.legacy-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 6px;
  margin-bottom: 6px;
  align-items: start;
}

.legacy-card {
  border: 1px solid #d4d7e2;
  border-radius: 12px;
  padding: 6px;
  background: #fff;
}

.legacy-section-title {
  margin: 0 0 6px 0;
  font-size: 12px;
  font-weight: 700;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.legacy-kv {
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 3px 8px;
  font-size: 11.4px;
  align-items: start;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.legacy-k {
  color: #6c7280;
}

.legacy-v {
  white-space: normal;
  border: 2px solid #d4d7e2;
  border-radius: 8px;
  padding: 5px 8px;
  min-height: 22px;
  line-height: 1.2;
  background: #fff;
}

.legacy-v-multiline {
  min-height: 44px;
}

.legacy-problem-card,
.legacy-tech-card {
  margin-bottom: 8px;
}

.legacy-report {
  font-size: var(--legacy-report-font);
  line-height: 1.22;
  white-space: pre-wrap;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.legacy-problem-text {
  min-height: 0;
  padding: 0;
  white-space: normal;
  border: 0;
  background: transparent;
}

.legacy-tech-text {
  min-height: 0;
  padding: 0;
  white-space: normal;
  border: 0;
  background: transparent;
  min-height: 0;
}

.legacy-report-block + .legacy-report-block {
  margin-top: 6px;
}

.legacy-report-block .services-block {
  margin-top: 8px;
  padding-top: 5px;
  border-top: 1px solid rgba(31, 36, 48, 0.2);
}

.legacy-spacer {
  height: 6px;
}

.legacy-auth-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.legacy-copy {
  font-size: 11px;
  line-height: 1.35;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.legacy-inline-fill {
  display: inline-block;
  min-width: 120px;
  border-bottom: 1px solid #d4d7e2;
  padding: 0 2px 1px;
}

.legacy-inline-fill.small {
  min-width: 48px;
}

.legacy-signature-name {
  min-width: 155px;
}

.legacy-totals-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 10px;
  margin-top: 6px;
}

.legacy-left-column {
  display: flex;
  flex-direction: column;
  gap: 3px;
  order: 1;
}

.legacy-right-column {
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  order: 2;
}

.legacy-pay-block {
  border: 0;
  border-radius: 0;
  padding: 0;
  font-size: 11px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.legacy-pay-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px 0;
  flex-wrap: wrap;
}

.legacy-pay-title {
  margin: 0;
}

.legacy-deposit-status {
  margin-left: auto;
  font-size: 12px;
  color: #1f2430;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.legacy-pay-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  align-items: start;
}

.legacy-pay-column {
  display: grid;
  grid-auto-rows: minmax(18px, auto);
  row-gap: 2px;
  align-content: start;
  justify-items: start;
}

.legacy-pay-row {
  display: grid;
  grid-template-columns: 18px max-content;
  align-items: center;
  justify-content: start;
  column-gap: 6px;
  margin: 0;
  min-height: 18px;
  width: max-content;
  white-space: nowrap;
  color: #1f2430;
  font-weight: 800;
}

.legacy-pay-choice {
  cursor: pointer;
  user-select: none;
  justify-self: start;
}

.legacy-pay-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 1px solid #d4d7e2;
  border-radius: 3px;
  font-weight: 800;
  font-size: 11px;
}

.legacy-pay-note {
  border-bottom: 1px dotted #d4d7e2;
  padding: 0 2px;
  min-width: 140px;
  display: inline-block;
}

.legacy-hidden-radio,
.legacy-inline-radio input {
  position: absolute;
  width: 1px !important;
  min-width: 1px !important;
  height: 1px !important;
  min-height: 1px !important;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.legacy-inline-radio {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 12px;
  color: #1f2430;
  font-weight: 800;
}

.legacy-deposit-status-pills {
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
}

.legacy-status-box {
  width: 16px;
  height: 16px;
  font-size: 10px;
  flex: 0 0 16px;
}

.legacy-inline-radio input:checked + .legacy-status-box::after {
  content: "X";
}

.legacy-inline-radio input:checked + .legacy-status-box {
  color: #1f2430;
}

.legacy-side-note {
  font-size: 11px;
  line-height: 1.35;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.legacy-warranty-note {
  border: 2px dashed #ff7a1a;
  box-shadow: 0 10px 18px rgba(255, 122, 26, .18);
}

.legacy-warranty-extra {
  margin-top: 4px;
}

.legacy-damage-card {
  font-size: 9.9px;
  line-height: 1.16;
  break-inside: avoid;
  page-break-inside: avoid;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.legacy-totals-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.legacy-totals-table td,
.legacy-totals-table th {
  border: 1px solid #d4d7e2;
  padding: 6px;
  vertical-align: top;
}

.legacy-formula-note {
  margin-top: 3px;
  font-size: calc(9px * var(--invoice-font-scale));
  line-height: 1.1;
  color: #6c7280;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@page {
  size: A4 portrait;
  margin: 6mm;
}

.pdf-body {
  background: #fff;
}

.pdf-body .invoice-shell {
  width: 198mm;
  margin: 0;
}

.pdf-body .legacy-invoice {
  border: none;
  box-shadow: none;
}

.pdf-body .invoice-page-inner {
  width: 198mm;
  max-width: 198mm;
  min-height: 0;
  padding: 1mm;
  box-sizing: border-box;
}

.pdf-body .legacy-topbar {
  margin-bottom: 4px;
  padding-top: 0;
  gap: 6px;
}

.pdf-body .legacy-brand-line {
  margin-bottom: 3px;
}

.pdf-body .legacy-brand-title {
  line-height: 1.05;
}

.pdf-body .legacy-brand-meta {
  line-height: 1.05;
}

.pdf-body .legacy-tag {
  padding: 2px 8px;
}

.pdf-body .legacy-grid {
  gap: 4px;
  margin-bottom: 4px;
}

.pdf-body .legacy-card {
  padding: 4px;
  border-radius: 10px;
}

.pdf-body .legacy-section-title {
  margin: 0 0 3px 0;
}

.pdf-body .legacy-kv {
  grid-template-columns: 94px 1fr;
  gap: 2px 6px;
}

.pdf-body .legacy-v {
  padding: 4px 7px;
  min-height: 20px;
  line-height: 1.12;
}

.pdf-body .legacy-problem-card,
.pdf-body .legacy-tech-card {
  margin-bottom: 4px;
}

.pdf-body .legacy-report {
  line-height: 1.12;
}

.pdf-body .legacy-report-block + .legacy-report-block {
  margin-top: 4px;
}

.pdf-body .legacy-report-block .services-block {
  margin-top: 6px;
  padding-top: 4px;
  border-top-color: rgba(31, 36, 48, 0.22);
}

.legacy-report-line {
  display: block;
}

.legacy-optional-note,
.legacy-muted-inline {
  color: var(--muted);
  font-size: 0.82em;
  font-weight: 700;
}

.pdf-body .legacy-auth-grid {
  gap: 4px;
  margin-bottom: 4px;
}

.pdf-body .legacy-copy,
.pdf-body .legacy-side-note {
  line-height: 1.18;
}

.pdf-body .legacy-inline-fill {
  min-width: 96px;
}

.pdf-body .legacy-signature-name {
  min-width: 128px;
}

.pdf-body .legacy-inline-fill.small {
  min-width: 42px;
}

.pdf-body .legacy-totals-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 246px;
  gap: 8px;
  align-items: start;
  margin-top: 4px;
}

.pdf-body .legacy-totals-layout::after {
  content: none;
}

.pdf-body .legacy-left-column {
  display: block;
  overflow: visible;
  min-width: 0;
}

.pdf-body .legacy-right-column {
  float: none;
  width: auto;
  margin: 0;
  padding: 0;
  border-radius: 0;
  break-inside: avoid;
  page-break-inside: avoid;
}

.pdf-body .legacy-pay-block {
  padding: 0;
  border-radius: 0;
}

.pdf-body .legacy-pay-header {
  margin-bottom: 1px;
  gap: 4px;
  align-items: flex-start;
  flex-wrap: nowrap;
}

.pdf-body .legacy-deposit-status,
.pdf-body .legacy-inline-radio {
  font-size: 12px;
  line-height: 1;
  color: #1f2430;
  font-weight: 900;
}

.pdf-body .legacy-pay-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1px 8px;
  align-items: start;
}

.pdf-body .legacy-pay-column {
  align-items: flex-start;
}

.pdf-body .legacy-pay-row {
  grid-template-columns: 10px max-content;
  margin: 0;
  min-height: 11px;
  column-gap: 3px;
  line-height: 1;
  font-size: 11px;
  width: max-content;
  white-space: nowrap;
  color: #1f2430;
  font-weight: 800;
}

.pdf-body .legacy-pay-box {
  width: 14px;
  height: 14px;
  font-size: 9px;
  flex: 0 0 14px;
}

.pdf-body .legacy-pay-note {
  min-width: 110px;
}

.pdf-body .legacy-pay-title {
  font-size: 12px;
  line-height: 1;
}

.pdf-body .legacy-pay-choice span:last-child,
.pdf-body .legacy-pay-row span:last-child {
  letter-spacing: 0;
}

.pdf-body .legacy-deposit-status-pills {
  gap: 4px;
}

.pdf-body .legacy-deposit-status {
  margin-left: auto;
  white-space: nowrap;
}

.pdf-body .legacy-deposit-status span:first-child {
  margin-right: 4px;
}

.pdf-body .legacy-warranty-note {
  border-width: 1px;
  box-shadow: none;
}

.pdf-body .legacy-left-column > * {
  margin-bottom: 4px;
}

.pdf-body .legacy-damage-card {
  line-height: 1.08;
}

.pdf-body .legacy-totals-table {
}

.pdf-body .legacy-totals-table td,
.pdf-body .legacy-totals-table th {
  padding: 4px 5px;
}

.pdf-body .legacy-formula-note {
  display: none;
}

html.pdf-export body.pdf-body .invoice-page {
  width: 198mm !important;
  max-width: 198mm !important;
  box-shadow: none !important;
}

html.pdf-export body.pdf-body .invoice-page-inner {
  width: 198mm !important;
  max-width: 198mm !important;
  padding: 1mm !important;
}

html.pdf-export body.pdf-body .legacy-topbar {
  margin-bottom: 4px !important;
  padding-top: 0 !important;
  gap: 6px !important;
}

html.pdf-export body.pdf-body .legacy-brand-line {
  margin-bottom: 3px !important;
}

html.pdf-export body.pdf-body .legacy-grid {
  gap: 4px !important;
  margin-bottom: 4px !important;
}

html.pdf-export body.pdf-body .legacy-card {
  padding: 6px !important;
  border-radius: 12px !important;
}

html.pdf-export body.pdf-body .legacy-section-title {
  margin: 0 0 5px 0 !important;
}

html.pdf-export body.pdf-body .legacy-kv {
  gap: 2px 6px !important;
}

html.pdf-export body.pdf-body .legacy-v {
  padding: 5px 8px !important;
  min-height: 22px !important;
  line-height: 1.18 !important;
}

html.pdf-export body.pdf-body .legacy-problem-card,
html.pdf-export body.pdf-body .legacy-tech-card {
  margin-bottom: 4px !important;
}

html.pdf-export body.pdf-body .legacy-report {
  line-height: 1.18 !important;
}

html.pdf-export body.pdf-body .legacy-report-block + .legacy-report-block {
  margin-top: 4px !important;
}

html.pdf-export body.pdf-body .legacy-report-block .services-block {
  margin-top: 5px !important;
  padding-top: 3px !important;
}

html.pdf-export body.pdf-body .legacy-auth-grid {
  gap: 4px !important;
  margin-bottom: 4px !important;
}

html.pdf-export body.pdf-body .legacy-copy,
html.pdf-export body.pdf-body .legacy-side-note {
  font-size: 11px !important;
  line-height: 1.28 !important;
  font-weight: 400 !important;
}

html.pdf-export body.pdf-body .legacy-inline-fill {
  min-width: 96px !important;
}

html.pdf-export body.pdf-body .legacy-signature-name {
  min-width: 128px !important;
}

html.pdf-export body.pdf-body .legacy-inline-fill.small {
  min-width: 42px !important;
}

html.pdf-export body.pdf-body .legacy-totals-layout {
  grid-template-columns: minmax(0, 1fr) 246px !important;
  gap: 8px !important;
  margin-top: 4px !important;
  min-height: 132mm !important;
}

html.pdf-export body.pdf-body .legacy-left-column {
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
  gap: 4px !important;
}

html.pdf-export body.pdf-body .legacy-pay-header {
  margin-bottom: 1px !important;
  gap: 4px !important;
  flex-wrap: nowrap !important;
}

html.pdf-export body.pdf-body .legacy-deposit-status,
html.pdf-export body.pdf-body .legacy-inline-radio {
  font-size: 12px !important;
  line-height: 1 !important;
}

html.pdf-export body.pdf-body .legacy-pay-grid {
  gap: 1px 8px !important;
}

html.pdf-export body.pdf-body .legacy-pay-row {
  grid-template-columns: 10px max-content !important;
  min-height: 11px !important;
  column-gap: 3px !important;
  line-height: 1 !important;
  font-size: 11px !important;
  font-weight: 500 !important;
}

html.pdf-export body.pdf-body .legacy-pay-box {
  width: 14px !important;
  height: 14px !important;
  font-size: 9px !important;
  flex: 0 0 14px !important;
}

html.pdf-export body.pdf-body .legacy-pay-note {
  min-width: 110px !important;
}

html.pdf-export body.pdf-body .legacy-pay-title {
  font-size: 12px !important;
  line-height: 1 !important;
}

html.pdf-export body.pdf-body .legacy-left-column > * {
  margin-bottom: 5px !important;
}

html.pdf-export body.pdf-body .legacy-warranty-note {
  border-width: 1px !important;
  box-shadow: none !important;
}

html.pdf-export body.pdf-body .legacy-warranty-extra {
  margin-top: 4px !important;
}

html.pdf-export body.pdf-body .legacy-damage-card {
  font-size: 9.9px !important;
  line-height: 1.16 !important;
}

html.pdf-export body.pdf-body .legacy-totals-table {
  font-size: 11px !important;
  font-weight: 400 !important;
}

html.pdf-export body.pdf-body .legacy-totals-table td,
html.pdf-export body.pdf-body .legacy-totals-table th {
  padding: 6px !important;
}

html.pdf-export body.pdf-body .legacy-formula-note {
  display: none !important;
}

html.pdf-export body.pdf-body .legacy-v,
html.pdf-export body.pdf-body .legacy-k,
html.pdf-export body.pdf-body .legacy-report,
html.pdf-export body.pdf-body .legacy-inline-fill,
html.pdf-export body.pdf-body .legacy-pay-row span:last-child {
  font-weight: 400 !important;
}

html.pdf-export body.pdf-body .legacy-section-title,
html.pdf-export body.pdf-body .legacy-brand-title,
html.pdf-export body.pdf-body .legacy-pay-title,
html.pdf-export body.pdf-body .legacy-deposit-status,
html.pdf-export body.pdf-body .legacy-report strong,
html.pdf-export body.pdf-body .legacy-totals-table strong,
html.pdf-export body.pdf-body .legacy-pay-box {
  font-weight: 800 !important;
}

@media (max-width: 900px) {
  .job-layout {
    grid-template-columns: 1fr;
  }

  .calculator-shell,
  .calculator-layout {
    grid-template-columns: 1fr;
  }

  .calculator-actions {
    max-width: none;
    justify-self: stretch;
  }

  .section-grid, .field-grid, .summary-grid, .parts-head, .parts-row, .services-head, .services-row,
  .invoice-columns, .invoice-split, .topbar, .section-header, .backup-actions, .backup-import-form {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .preset-admin-grid,
  .preset-board {
    grid-template-columns: 1fr;
  }

  .field-grid .span-2,
  .field-grid .span-3,
  .field-grid .span-4,
  .field-grid .span-full { grid-column: auto; }
  .summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compact-fields,
  .compact-fields-main,
  .compact-fields-pricing {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .compact-fields-job {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .compact-fields-pricing-tight {
    grid-template-columns: repeat(4, minmax(112px, 1fr));
  }

  .status-inline-group {
    grid-template-columns: 1fr;
  }

  .zelle-field {
    width: auto;
    justify-self: stretch;
    margin-left: 0;
  }

  .pricing-toggle-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .legacy-grid,
  .legacy-totals-layout,
  .legacy-pay-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar,
  .topbar-actions,
  .app-nav {
    align-items: stretch;
    width: 100%;
  }

  .app-nav,
  .topbar-actions {
    gap: 8px;
  }

  .topbar .ghost-btn,
  .topbar .primary-btn,
  .topbar .secondary-btn {
    min-height: 44px;
    font-size: 15px;
  }

  .panel,
  .card,
  .compact-card {
    padding: 10px;
  }

  label span {
    font-size: 10px;
  }

  input,
  textarea,
  select {
    min-height: 44px;
    padding: 9px 11px;
    font-size: 16px;
    border-radius: 10px;
  }

  textarea {
    min-height: 92px;
  }

  .chip {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 14px;
  }

  .primary-btn,
  .secondary-btn,
  .ghost-btn,
  .icon-btn {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 15px;
  }

  .calculator-actions {
    max-width: none;
  }

  .calculator-actions .primary-btn,
  .calculator-actions .secondary-btn,
  .calculator-actions .ghost-btn {
    min-height: 46px;
  }

  .compact-fields,
  .compact-fields-main,
  .compact-fields-job,
  .compact-fields-pricing {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compact-fields-pricing-tight {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pricing-toggle-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .pricing-preset-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-width: none;
    width: 100%;
  }

  .pricing-preset-chip {
    min-height: 52px;
    padding: 7px 8px;
  }

  .pricing-preset-chip strong {
    font-size: 11px;
  }

  .pricing-preset-chip span {
    font-size: 8px;
  }

  .parts-head, .parts-row,
  .services-head, .services-row {
    grid-template-columns: 1fr;
  }

  .rows-head {
    display: none;
  }

  .parts-row,
  .services-row {
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--card-bg);
  }

  .parts-row .icon-btn,
  .services-row .icon-btn {
    justify-self: stretch;
    width: 100%;
    margin-top: 4px;
    background: rgba(231, 76, 60, 0.1);
    color: #c0392b;
    border-color: rgba(231, 76, 60, 0.35);
  }

  .parts-row label,
  .services-row label {
    gap: 4px;
  }

  .smart-suggestions-content,
  .smart-suggestion-group,
  .smart-suggestion-group > div {
    flex-direction: column;
    align-items: stretch;
  }

  .smart-pill {
    min-height: 40px;
    text-align: left;
    border-radius: 12px;
  }

  .page-shell, .invoice-shell {
    width: min(1580px, calc(100vw - 6px));
  }
}

@media (max-width: 420px) {
  .compact-fields,
  .compact-fields-main,
  .compact-fields-job,
  .compact-fields-pricing {
    grid-template-columns: 1fr;
  }

  .compact-fields-pricing-tight {
    grid-template-columns: 1fr;
  }
}

html.fixme-mobile-app,
html.fixme-mobile-app body {
  background: #f3f4f8;
}

html.fixme-mobile-app .invoice-shell {
  width: min(100%, calc(100vw - 16px));
  margin: 8px auto 20px;
}

html.fixme-mobile-app .invoice-toolbar {
  position: sticky;
  top: max(8px, env(safe-area-inset-top));
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: stretch;
  padding: 6px;
  border-radius: 0 0 18px 18px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 18px rgba(15, 20, 40, 0.1);
}

html.fixme-mobile-app .invoice-mobile-toggle {
  display: inline-flex;
  min-height: 34px;
  width: 100%;
  border: 0;
  border-radius: 14px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #1f2430;
  background: linear-gradient(180deg, #fff 0%, #f6f8fc 100%);
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.03em;
  box-shadow: inset 0 0 0 1px rgba(212, 215, 226, 0.95);
  cursor: pointer;
}

html.fixme-mobile-app .invoice-mobile-grip {
  width: 34px;
  height: 4px;
  border-radius: 99px;
  background: #b5bdcc;
}

html.fixme-mobile-app .invoice-toolbar.is-collapsed {
  width: min(230px, calc(100vw - 24px));
  margin: 6px auto 8px;
  padding: 5px;
  border-radius: 999px;
}

html.fixme-mobile-app .invoice-toolbar.is-collapsed .invoice-mobile-toggle {
  min-height: 32px;
  border-radius: 999px;
}

html.fixme-mobile-app .invoice-toolbar.is-collapsed .invoice-toolbar-edit,
html.fixme-mobile-app .invoice-toolbar.is-collapsed .invoice-toolbar-back,
html.fixme-mobile-app .invoice-toolbar.is-collapsed .invoice-toolbar-actions {
  display: none;
}

html.fixme-mobile-app .invoice-toolbar > a.invoice-toolbar-back {
  display: none;
}

html.fixme-mobile-app .invoice-toolbar > a.invoice-toolbar-edit {
  display: inline-flex;
  justify-content: center;
  flex: 0 0 auto;
  width: auto;
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

html.fixme-mobile-app .invoice-toolbar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  align-items: stretch;
  justify-content: stretch;
  min-width: 0;
}

html.fixme-mobile-app .invoice-scale-control {
  width: 100%;
  justify-content: center;
  font-size: 12px;
  gap: 4px;
}

html.fixme-mobile-app .invoice-scale-control span {
  display: none;
}

html.fixme-mobile-app .invoice-scale-control select {
  min-height: 34px;
  min-width: 68px;
  max-width: 76px;
  font-size: 13px;
  padding: 0 20px 0 8px;
}

html.fixme-mobile-app #download_pdf_btn,
html.fixme-mobile-app #download_iphone_pdf_btn {
  width: 100%;
  min-height: 34px;
  font-size: 13px;
  font-weight: 800;
  padding: 0 10px;
  grid-column: span 2;
}

html.fixme-mobile-app .invoice-toolbar .ghost-btn,
html.fixme-mobile-app .invoice-toolbar .primary-btn,
html.fixme-mobile-app .invoice-toolbar .secondary-btn {
  width: 100%;
  min-height: 34px;
  font-size: 12px;
  padding: 0 8px;
  white-space: nowrap;
}

html.fixme-mobile-app .invoice-page {
  border-radius: 20px;
}

html.fixme-mobile-app .invoice-page-inner {
  padding: 12px;
}

html.fixme-mobile-app .legacy-invoice {
  --legacy-report-font: 16px;
}

html.fixme-mobile-app .legacy-brand-title {
  font-size: 24px;
}

html.fixme-mobile-app .legacy-brand-meta {
  font-size: 12px;
}

html.fixme-mobile-app .legacy-section-title {
  font-size: 16px;
}

html.fixme-mobile-app .legacy-kv,
html.fixme-mobile-app .legacy-copy,
html.fixme-mobile-app .legacy-totals-table,
html.fixme-mobile-app .legacy-pay-block,
html.fixme-mobile-app .legacy-inline-radio {
  font-size: 15px;
}

html.fixme-mobile-app .legacy-v {
  min-height: 32px;
  padding: 8px 10px;
}

html.fixme-mobile-app .legacy-pay-row {
  grid-template-columns: 26px 1fr;
  min-height: 38px;
  width: 100%;
  column-gap: 10px;
  padding: 6px 4px;
  white-space: normal;
  border-bottom: 1px solid rgba(212, 215, 226, 0.75);
}

html.fixme-mobile-app .legacy-pay-row:last-child {
  border-bottom: 0;
}

html.fixme-mobile-app .legacy-pay-box {
  width: 24px;
  height: 24px;
  font-size: 14px;
}

html.fixme-mobile-app .legacy-status-box {
  width: 22px;
  height: 22px;
  flex-basis: 22px;
}

html.fixme-mobile-app .legacy-pay-note {
  min-width: 0;
}

html.fixme-mobile-app .legacy-pay-block {
  padding: 10px;
  border: 1px solid #dfe3ee;
  border-radius: 16px;
  background: #fff;
}

html.fixme-mobile-app .legacy-pay-header {
  gap: 8px;
  margin-bottom: 8px;
}

html.fixme-mobile-app .legacy-deposit-status {
  margin-left: 0;
  width: 100%;
  justify-content: flex-start;
  flex-wrap: wrap;
}

html.fixme-mobile-app .legacy-pay-grid {
  gap: 10px;
}

html.fixme-mobile-app .legacy-pay-column {
  gap: 0;
  padding: 8px;
  border: 1px solid #e7eaf2;
  border-radius: 14px;
  background: #fbfcff;
}

html.fixme-mobile-app .legacy-grid,
html.fixme-mobile-app .legacy-totals-layout,
html.fixme-mobile-app .legacy-pay-grid {
  grid-template-columns: 1fr;
}

html.fixme-mobile-app .legacy-kv {
  grid-template-columns: 88px 1fr;
  gap: 6px 8px;
}

html.fixme-mobile-app .legacy-topbar {
  grid-template-columns: 1fr;
  gap: 8px;
}

html.pdf-export .legacy-grid {
  grid-template-columns: 1.1fr 0.9fr !important;
}

html.pdf-export .invoice-page-inner,
html.pdf-export .legacy-invoice {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

html.pdf-export .legacy-totals-layout {
  grid-template-columns: minmax(0, 1fr) 260px !important;
  align-items: start !important;
}

html.pdf-export .legacy-pay-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
}

html.pdf-export .legacy-topbar {
  grid-template-columns: 1fr auto auto !important;
}

html.pdf-export .legacy-kv {
  grid-template-columns: 104px 1fr !important;
}

html.pdf-export .legacy-pay-block {
  border: 0 !important;
  border-radius: 0 !important;
  padding: 0 !important;
  background: transparent !important;
}

html.pdf-export .legacy-pay-column {
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  min-width: 0 !important;
}

html.pdf-export .legacy-pay-row {
  grid-template-columns: 18px max-content !important;
  min-height: 18px !important;
  width: max-content !important;
  padding: 0 !important;
  border-bottom: 0 !important;
  white-space: nowrap !important;
}

html.pdf-export .legacy-deposit-status {
  margin-left: auto !important;
  width: auto !important;
  justify-content: flex-end !important;
}

@media print {
  html.fixme-mobile-app,
  html.fixme-mobile-app body,
  body { background: white !important; }
  .no-print, .invoice-toolbar { display: none !important; }
  .invoice-shell { width: 100%; margin: 0; }
  .invoice-page {
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding: 0;
  }

  .invoice-page-inner {
    max-width: 210mm;
    min-height: auto;
    padding: 1.2mm;
  }

  html.fixme-mobile-app .legacy-invoice {
    --legacy-report-font: 13.2px;
  }

  html.fixme-mobile-app .legacy-topbar {
    grid-template-columns: 1fr auto auto !important;
    gap: 10px !important;
  }

  html.fixme-mobile-app .legacy-brand-title {
    font-size: 20px !important;
  }

  html.fixme-mobile-app .legacy-brand-meta {
    font-size: 10.5px !important;
  }

  html.fixme-mobile-app .legacy-section-title {
    font-size: 12px !important;
  }

  html.fixme-mobile-app .legacy-grid {
    grid-template-columns: 1.1fr 0.9fr !important;
  }

  html.fixme-mobile-app .legacy-totals-layout {
    grid-template-columns: minmax(0, 1fr) 260px !important;
    align-items: start !important;
  }

  html.fixme-mobile-app .legacy-pay-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  }

  html.fixme-mobile-app .legacy-kv {
    grid-template-columns: 104px 1fr !important;
    font-size: 11.4px !important;
  }

  html.fixme-mobile-app .legacy-kv,
  html.fixme-mobile-app .legacy-copy,
  html.fixme-mobile-app .legacy-totals-table,
  html.fixme-mobile-app .legacy-pay-block,
  html.fixme-mobile-app .legacy-inline-radio {
    font-size: inherit;
  }

  html.fixme-mobile-app .legacy-v {
    min-height: 22px !important;
    padding: 5px 8px !important;
  }

  html.fixme-mobile-app .legacy-pay-block,
  html.fixme-mobile-app .legacy-pay-column {
    border: 0 !important;
    border-radius: 0 !important;
    padding: 0 !important;
    background: transparent !important;
  }

  html.fixme-mobile-app .legacy-pay-row {
    grid-template-columns: 18px max-content !important;
    min-height: 18px !important;
    width: max-content !important;
    padding: 0 !important;
    border-bottom: 0 !important;
    white-space: nowrap !important;
  }

  html.fixme-mobile-app .legacy-pay-box {
    width: 18px !important;
    height: 18px !important;
    font-size: 11px !important;
  }

  html.fixme-mobile-app .legacy-deposit-status {
    margin-left: auto !important;
    width: auto !important;
    justify-content: flex-end !important;
  }
}
.legacy-invoice {
  --legacy-report-font: 13.2px;
}

.legacy-invoice[data-font="100"] { --legacy-report-font: 11px; }
.legacy-invoice[data-font="110"] { --legacy-report-font: 12.1px; }
.legacy-invoice[data-font="120"] { --legacy-report-font: 13.2px; }
.legacy-invoice[data-font="130"] { --legacy-report-font: 14.3px; }
.legacy-invoice[data-font="140"] { --legacy-report-font: 15.4px; }
.legacy-invoice[data-font="150"] { --legacy-report-font: 16.5px; }
.legacy-invoice[data-font="160"] { --legacy-report-font: 17.6px; }
.legacy-invoice[data-font="170"] { --legacy-report-font: 18.7px; }
.legacy-invoice[data-font="180"] { --legacy-report-font: 19.8px; }
