:root {
  color-scheme: light;
  --red: #c41230;
  --red-dark: #8f0d23;
  --ink: #171717;
  --muted: #666b73;
  --line: #d9dde5;
  --soft: #f4f6f8;
  --panel: #ffffff;
  --green: #0a7a55;
  --blue: #1d4f91;
  --shadow: 0 18px 40px rgba(21, 25, 32, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: #eceff3;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

button.primary {
  color: #fff;
  background: var(--red);
}

button.secondary {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

button:hover {
  filter: brightness(0.97);
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 22px;
  background: #15171c;
  color: #fff;
}

.brand-block img {
  width: 210px;
  max-width: 100%;
  height: auto;
  padding: 14px;
  border-radius: 8px;
  background: #fff;
}

.brand-block p,
.eyebrow {
  margin: 8px 0 0;
  color: #7e8796;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar .brand-block p {
  color: #c8ced8;
}

.deal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 22px 0;
}

.side-panel {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.side-panel h2 {
  margin: 0 0 12px;
  font-size: 15px;
}

.side-panel label,
.panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.side-panel input,
.panel input,
.panel select,
.panel textarea,
.status-strip input,
.status-strip select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
}

.side-panel input {
  margin-bottom: 10px;
}

.deal-list {
  display: grid;
  gap: 8px;
}

.deal-card {
  width: 100%;
  min-height: 58px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  text-align: left;
}

.deal-card strong {
  display: block;
  font-size: 14px;
}

.deal-card span {
  color: #c8ced8;
  font-size: 12px;
}

.deal-card.in-store-card strong {
  color: #44d36a;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1;
}

h2 {
  margin: 0;
  font-size: 22px;
}

h3 {
  margin: 20px 0 10px;
  font-size: 14px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-strip,
.tabs,
.panel,
.print-sheet {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.status-strip {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 180px minmax(160px, auto) auto;
  align-items: end;
  gap: 14px;
  padding: 14px;
  margin-bottom: 14px;
}

.save-state {
  align-self: center;
  justify-self: end;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 6px;
  margin-bottom: 14px;
  overflow: auto;
}

.tab {
  min-width: 102px;
  color: var(--muted);
  background: transparent;
}

.tab.active {
  color: #fff;
  background: var(--ink);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: grid;
  gap: 14px;
}

.dashboard-panel {
  overflow: hidden;
}

.dashboard-actions {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.dashboard-actions label {
  min-width: 260px;
}

.dashboard-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.dashboard-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
  font-size: 15px;
}

.dashboard-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 7px;
  color: #244f5d;
  background: #fff;
  text-align: left;
  font-weight: 900;
  white-space: nowrap;
}

.dashboard-table td {
  padding: 7px;
  border-top: 3px solid #fff;
  vertical-align: middle;
}

.dashboard-table tbody tr:nth-child(odd) {
  background: #e8f4fa;
}

.dashboard-table tbody tr:nth-child(even) {
  background: #fff;
}

.customer-in-store {
  color: #078425;
  font-weight: 900;
}

.dashboard-check {
  width: 18px;
  height: 18px;
  accent-color: #1f6fff;
}

.dashboard-icon-button,
.dashboard-row-actions button {
  min-height: 34px;
  border-radius: 8px;
  color: #fff;
  background: #244f5d;
  white-space: nowrap;
}

.dashboard-icon-button {
  padding: 0 10px;
}

.dashboard-row-actions {
  display: flex;
  gap: 6px;
}

.dashboard-count {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.dashboard-empty {
  padding: 24px !important;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.field-grid {
  display: grid;
  gap: 12px;
}

.field-grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.wide {
  grid-column: span 2;
}

.notes-label {
  margin-top: 12px;
}

textarea {
  resize: vertical;
}

.toggle-row {
  display: flex !important;
  flex-direction: row;
  align-items: center;
  gap: 8px !important;
  color: var(--ink) !important;
}

.toggle-row input {
  width: 18px !important;
  min-height: 18px !important;
}

.toggle-row.small {
  align-self: end;
  min-height: 40px;
}

.lookup-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.assist-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.assist-row .lookup-note {
  margin-top: 0;
}

.choice-grid,
.term-grid,
.tax-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.choice-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.choice-grid label,
.term-grid label,
.tax-options label {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--soft);
  font-size: 13px;
  font-weight: 800;
}

.choice-grid input,
.term-grid input,
.tax-options input {
  width: 18px;
  min-height: 18px;
}

.accessory-table {
  display: grid;
  gap: 8px;
}

.accessory-row {
  display: grid;
  grid-template-columns: minmax(150px, 2fr) minmax(100px, 1fr) minmax(100px, 1fr) auto auto;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.remove-accessory {
  width: 40px;
  padding: 0;
  color: #fff;
  background: var(--red-dark);
}

.totals-row {
  display: flex;
  justify-content: flex-end;
  gap: 20px;
  margin-top: 14px;
  color: var(--muted);
  font-weight: 800;
}

.totals-row strong {
  color: var(--ink);
}

.matrix-wrap {
  overflow: auto;
}

.payment-matrix {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 8px;
}

.payment-matrix th,
.payment-matrix td {
  border: 1px solid var(--line);
  padding: 12px;
  text-align: right;
}

.payment-matrix th:first-child,
.payment-matrix td:first-child {
  text-align: left;
}

.payment-matrix thead th {
  color: #fff;
  background: var(--ink);
}

.payment-matrix tbody tr:nth-child(even) {
  background: var(--soft);
}

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

.admin-grid > div {
  min-height: 130px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.admin-grid p,
.risk-panel li {
  color: var(--muted);
  line-height: 1.45;
}

.totals-panel dl {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
}

.totals-panel div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.totals-panel dt {
  color: var(--muted);
  font-weight: 800;
}

.totals-panel dd {
  margin: 0;
  font-weight: 900;
}

.print-sheet {
  padding: 28px;
}

.print-header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 3px solid var(--red);
}

.print-header img {
  width: 190px;
  height: auto;
}

.print-highlights {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.print-highlights div {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.print-highlights span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.print-highlights strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.print-notes {
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.writeup-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.writeup-box {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.writeup-box h3 {
  margin-top: 0;
}

.writeup-box p {
  margin: 6px 0;
  color: var(--muted);
  font-size: 13px;
}

.writeup-box strong {
  color: var(--ink);
}

.foursquare-sheet {
  max-width: 980px;
  min-height: 1260px;
  margin: 0 auto;
  color: #050505;
  font-family: Arial, Helvetica, sans-serif;
}

.foursquare-header {
  display: grid;
  grid-template-columns: 250px 1fr 1fr 220px;
  gap: 20px;
  align-items: start;
}

.foursquare-header img {
  width: 230px;
  height: auto;
  margin-top: 8px;
}

.foursquare-header h3,
.foursquare-customer h3,
.foursquare-payments h3 {
  margin: 0 0 4px;
  font-size: 21px;
  line-height: 1.1;
  text-align: center;
}

.foursquare-header p,
.foursquare-customer p {
  margin: 1px 0;
  font-size: 20px;
  line-height: 1.14;
  text-align: center;
}

.foursquare-consultant {
  display: grid;
  gap: 12px;
  min-height: 80px;
  font-size: 22px;
  text-align: right;
}

.foursquare-rule {
  height: 2px;
  margin: 16px 0;
  background: #2684e5;
}

.foursquare-customer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

.foursquare-customer h3 {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.foursquare-main {
  display: grid;
  grid-template-columns: minmax(300px, 0.95fr) minmax(420px, 1.1fr);
  gap: 44px;
  align-items: start;
  min-height: 430px;
}

.foursquare-purchase {
  display: grid;
  gap: 3px;
  padding-left: 6px;
}

.foursquare-purchase div {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) 140px;
  gap: 12px;
  align-items: baseline;
  font-size: 20px;
  line-height: 1.12;
}

.foursquare-purchase span {
  font-weight: 500;
}

.foursquare-purchase strong {
  text-align: right;
}

.foursquare-payments h3 {
  margin: 0 0 24px;
}

.foursquare-payments table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 28px;
}

.foursquare-payments th,
.foursquare-payments td {
  padding: 8px 10px;
  font-size: 19px;
  text-align: right;
  white-space: nowrap;
}

.foursquare-payments th:first-child,
.foursquare-payments td:first-child {
  text-align: left;
  font-weight: 700;
}

.foursquare-checks {
  display: grid;
  gap: 14px;
  padding: 14px 12px;
  border: 1px solid #333;
}

.foursquare-checks label {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  color: #000;
  font-size: 14px;
  line-height: 1.25;
}

.foursquare-checks span {
  width: 18px;
  height: 18px;
  border: 1px solid #333;
}

.foursquare-notes {
  min-height: 120px;
  font-size: 15px;
}

.foursquare-footer {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  min-height: 220px;
  color: #777;
  font-style: italic;
}

.foursquare-footer p {
  margin: 0;
  flex: 1;
  text-align: center;
}

.foursquare-footer strong {
  color: #111;
  font-style: normal;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .field-grid.four,
  .admin-grid,
  .summary-grid,
  .writeup-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .workspace {
    padding: 14px;
  }

  .topbar,
  .panel-heading {
    display: grid;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions button {
    flex: 1 1 160px;
  }

  .field-grid.four,
  .admin-grid,
  .summary-grid,
  .status-strip,
  .writeup-grid,
  .print-highlights,
  .accessory-row {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: auto;
  }

  .print-header {
    display: grid;
  }

  .foursquare-header,
  .foursquare-customer,
  .foursquare-main {
    grid-template-columns: 1fr;
  }

  .foursquare-consultant {
    text-align: left;
  }
}

@media print {
  @page {
    size: letter portrait;
    margin: 0.25in;
  }

  body {
    background: #fff;
  }

  .sidebar,
  .topbar,
  .status-strip,
  .tabs,
  .panel,
  .summary-grid {
    display: none !important;
  }

  .app-shell,
  .workspace,
  .tab-panel {
    display: block !important;
    padding: 0;
  }

  .print-sheet {
    display: none;
    box-shadow: none;
    border: 0;
    page-break-after: auto;
    padding: 0;
  }

  body.print-menu #customerMenu,
  body.print-writeup #internalWriteup {
    display: block;
  }

  .foursquare-sheet {
    width: 7.95in;
    max-width: 7.95in;
    height: 10.45in;
    min-height: 0;
    overflow: hidden;
  }

  .foursquare-header {
    grid-template-columns: 1.7in 1.75in 1.75in 1.25in;
    gap: 0.16in;
  }

  .foursquare-header img {
    width: 1.55in;
    margin-top: 0;
  }

  .foursquare-header h3,
  .foursquare-customer h3,
  .foursquare-payments h3 {
    font-size: 14px;
    margin-bottom: 2px;
  }

  .foursquare-header p,
  .foursquare-customer p,
  .foursquare-purchase div,
  .foursquare-payments th,
  .foursquare-payments td {
    font-size: 12px;
    line-height: 1.08;
  }

  .foursquare-consultant {
    min-height: 0;
    gap: 4px;
    font-size: 13px;
  }

  .foursquare-rule {
    height: 1px;
    margin: 0.08in 0;
  }

  .foursquare-customer {
    gap: 0.24in;
  }

  .foursquare-main {
    grid-template-columns: 3.15in 1fr;
    gap: 0.28in;
    min-height: 0;
  }

  .foursquare-purchase {
    gap: 1px;
    padding-left: 0;
  }

  .foursquare-purchase div {
    grid-template-columns: 1.85in 1in;
    gap: 0.08in;
  }

  .foursquare-payments h3 {
    margin-bottom: 0.08in;
  }

  .foursquare-payments table {
    margin-bottom: 0.12in;
  }

  .foursquare-payments th,
  .foursquare-payments td {
    padding: 0.035in 0.045in;
  }

  .foursquare-checks {
    gap: 0.05in;
    padding: 0.08in;
  }

  .foursquare-checks label {
    grid-template-columns: 0.13in 1fr;
    gap: 0.06in;
    font-size: 9px;
    line-height: 1.12;
  }

  .foursquare-checks span {
    width: 0.13in;
    height: 0.13in;
  }

  .foursquare-notes {
    min-height: 0.42in;
    font-size: 10px;
    line-height: 1.15;
  }

  .foursquare-notes p {
    margin: 0 0 0.04in;
  }

  .foursquare-footer {
    min-height: 0.55in;
    font-size: 9px;
    align-items: end;
  }
}
