@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;500;600;700;800;900&display=swap");

:root {
  --bg: #F4F4F5;
  --surface: #ffffff;
  --surface-soft: #F4F4F5;
  --text: #0C0B3A;
  --muted: #667085;
  --line: #d8dee8;
  --line-strong: #0C0B3A;
  --brand: #B12423;
  --brand-dark: #8b1c1b;
  --brand-soft: #fff1f2;
  --ink: #0C0B3A;
  --ok: #0f8a5f;
  --warn: #b7791f;
  --danger: #B12423;
  --blue: #15328A;
  --accent: #809EDD;
  --shadow: 0 16px 42px rgba(16, 24, 40, 0.08);
  --radius: 10px;
  --font: "Noto Sans Thai", "Sarabun", "Leelawadee UI", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #ffffff 0, #f7f9fc 260px, var(--bg) 100%);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: 0;
  overflow-x: hidden;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.hidden {
  display: none !important;
}

.login-screen,
.setup-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    linear-gradient(135deg, rgba(177, 36, 35, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(21, 50, 138, 0.08), transparent 38%),
    #f7f9fc;
}

.login-card,
.setup-panel {
  width: min(520px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.setup-panel img,
.login-brand img {
  width: 160px;
  height: 86px;
  object-fit: contain;
}

.login-brand {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
}

.login-brand h1,
.setup-panel h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
}

.login-brand p,
.setup-panel p {
  margin: 5px 0 0;
  color: var(--muted);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #eef2f7;
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 18px;
}

.auth-tab {
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  padding: 10px;
  font-weight: 700;
}

.auth-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08);
}

.auth-form,
.compact-form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  min-height: 42px;
  padding: 10px 12px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.02);
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #809EDD;
  box-shadow: 0 0 0 3px rgba(21, 50, 138, 0.12);
}

.auth-form button,
.setup-panel button,
.topbar-actions button,
.editor-actions button,
.section-heading button,
.compact-form button,
#saveTermsBtn,
.report-filters button {
  background: var(--brand);
  color: white;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 800;
  box-shadow: 0 10px 20px rgba(177, 36, 35, 0.18);
}

.text-button {
  background: transparent;
  color: var(--blue);
  margin-top: 12px;
  padding: 8px 0;
  font-weight: 700;
}

.form-message {
  min-height: 20px;
  color: var(--danger);
  font-weight: 700;
}

code {
  display: block;
  margin: 14px 0;
  padding: 12px;
  border-radius: 8px;
  background: #111827;
  color: #e5e7eb;
  overflow-wrap: anywhere;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  padding: 18px 16px;
  border-right: 1px solid var(--line);
  box-shadow: 10px 0 30px rgba(15, 23, 42, 0.04);
}

.sidebar-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 26px;
}

.brand-mark {
  width: 62px;
  height: 42px;
  display: grid;
  place-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.brand-mark img {
  width: 52px;
  height: 32px;
  object-fit: contain;
}

.sidebar-brand strong {
  display: block;
  font-size: 18px;
}

.sidebar-brand span {
  color: var(--muted);
  font-size: 12px;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #475467;
  border-radius: 8px;
  padding: 12px;
  font-weight: 800;
  border: 1px solid transparent;
}

.nav-item.active,
.nav-item:hover {
  background: #fff5f5;
  color: var(--brand-dark);
  border-color: #ffd1d3;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.sidebar-footer strong {
  color: var(--text);
}

.sidebar-footer button {
  background: #253244;
  color: white;
  border-radius: 8px;
  padding: 9px 12px;
  font-weight: 800;
}

.content {
  min-width: 0;
  padding: 24px 28px 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 20px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

.topbar p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.topbar-actions button:nth-child(2) {
  background: #253244;
  box-shadow: 0 10px 20px rgba(37, 50, 68, 0.16);
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.workspace-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.quote-list-panel,
.quote-editor,
.data-panel,
.report-filters,
.editor-band {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.quote-list-panel {
  position: sticky;
  top: 24px;
  padding: 16px;
}

.panel-title-row,
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.panel-title-row h2,
.section-heading h2,
.data-panel h2 {
  margin: 0;
  font-size: 17px;
}

.panel-title-row span {
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  background: #eef2f7;
  border-radius: 99px;
  font-weight: 900;
}

.quote-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: calc(100vh - 180px);
  overflow: auto;
}

.quote-card {
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.03);
}

.quote-card.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(177, 36, 35, 0.12);
}

.quote-card-head,
.quote-card strong,
.quote-card span,
.quote-card small {
  display: block;
}

.quote-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.quote-card strong {
  font-size: 14px;
}

.quote-card em {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #fff5f5;
  color: var(--brand-dark);
  border: 1px solid #ffd1d3;
  padding: 3px 8px;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.quote-card span {
  margin-top: 4px;
  color: var(--text);
}

.quote-card small {
  color: var(--muted);
}

.quote-editor {
  display: grid;
  gap: 12px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.editor-band {
  padding: 18px 20px;
}

.editor-band .section-heading {
  border-bottom: 1px solid #edf1f6;
  padding-bottom: 12px;
}

.section-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.so-data-band {
  border-left: 4px solid var(--blue);
}

.so-data-hint {
  margin: 12px 0 0;
}

.so-data-grid {
  margin-top: 12px;
}

.so-data-grid input[readonly] {
  background: #f8fafc;
  color: #0f766e;
  font-weight: 900;
}

.so-export-button {
  background: #0f766e !important;
  box-shadow: 0 10px 20px rgba(15, 118, 110, 0.18) !important;
}

.section-heading h2::before,
.panel-title-row h2::before,
.data-panel h2::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 16px;
  margin-right: 8px;
  border-radius: 99px;
  background: var(--brand);
  vertical-align: -2px;
}

.document-strip {
  display: grid;
  grid-template-columns: 1fr 1fr minmax(260px, 1.2fr);
  gap: 12px;
  align-items: stretch;
}

.document-tile,
.document-strip p {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
  padding: 14px 16px;
}

.document-tile {
  border-left: 4px solid var(--brand);
}

.document-tile span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.document-tile strong {
  display: block;
  margin-top: 5px;
  font-size: 20px;
  letter-spacing: 0;
}

.document-tile.muted-tile {
  border-left-color: #cbd5e1;
  opacity: 0.72;
}

.document-strip p {
  display: grid;
  align-items: center;
  color: #475467;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.55;
}

.agent-section {
  border-left: 4px solid #f59e0b;
}

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

.address-editor {
  padding: 14px;
  border: 1px solid #dce4ee;
  border-radius: 9px;
  background: #f8fafc;
}

.address-editor-title {
  color: #26364a;
  font-size: 12px;
  font-weight: 900;
}

.delivery-address-editor {
  border-left: 3px solid #0f766e;
}

.address-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid #cfe3e1;
  border-radius: 8px;
  background: #f0fdfa;
}

.address-action-row strong,
.address-action-row span {
  display: block;
}

.address-action-row strong {
  color: #115e59;
  font-size: 12px;
  font-weight: 900;
}

.address-action-row span {
  margin-top: 2px;
  color: #52706f;
  font-size: 11px;
  font-weight: 700;
}

.address-copy-action {
  flex: 0 0 auto;
  min-height: 34px;
  white-space: nowrap;
}

.address-same-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 9px 12px;
  border: 1px solid #dce4ee;
  border-radius: 8px;
  background: #ffffff;
  color: #344054;
  font-size: 12px;
  font-weight: 800;
}

.address-same-toggle input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: #0f766e;
}

.address-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 11px 12px;
  margin-top: 11px;
}

.generated-address-field {
  margin-top: 12px;
}

.generated-address-field textarea {
  min-height: 52px;
  background: #ffffff;
  color: #344054;
}

.ship-to-preview {
  display: grid;
  grid-template-columns: minmax(160px, 0.7fr) minmax(0, 2.3fr);
  gap: 12px;
  align-items: end;
  margin-top: 12px;
}

.ship-to-preview input[readonly] {
  color: #0f766e;
  font-weight: 900;
}

.ship-to-preview .hint {
  padding-bottom: 10px;
}

.compact-address-editor {
  margin-top: 2px;
}

.span-2 {
  grid-column: span 2;
}

.span-3 {
  grid-column: span 3;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 99px;
  background: #eef2f7;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
}

.status-pill.pending {
  background: #fff7ed;
  color: var(--warn);
}

.status-pill.approved {
  background: #ecfdf3;
  color: var(--ok);
}

.status-pill.rejected {
  background: #fef3f2;
  color: var(--danger);
}

.line-table-wrap {
  margin-top: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.03);
}

.line-table,
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.line-table th,
.line-table td,
.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px;
  vertical-align: top;
  font-size: 13px;
}

.line-table th,
.data-table th {
  background: #f2f5f9;
  text-align: left;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
}

.report-table {
  table-layout: fixed;
}

.report-table th:nth-child(1) {
  width: 112px;
}

.report-table th:nth-child(3),
.report-table th:nth-child(4) {
  width: 130px;
}

.report-table th:nth-child(6) {
  width: 22%;
}

.report-table th:nth-child(7) {
  width: 84px;
}

.report-table th:nth-child(8) {
  width: 112px;
}

.report-table th:nth-child(11),
.report-table th:nth-child(12) {
  width: 108px;
}

.report-product-cell,
.report-quantity-cell,
.report-price-cell {
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.report-quantity-cell,
.report-price-cell {
  text-align: right;
  white-space: nowrap;
}

#reportsView .data-panel {
  overflow-x: auto;
}

#reportsView .report-table {
  min-width: 2140px;
}

#reportsView .report-table th:nth-child(1) {
  width: 110px;
}

#reportsView .report-table th:nth-child(2) {
  width: 180px;
}

#reportsView .report-table th:nth-child(3) {
  width: 110px;
}

#reportsView .report-table th:nth-child(4) {
  width: 130px;
}

#reportsView .report-table th:nth-child(5) {
  width: 170px;
}

#reportsView .report-table th:nth-child(6) {
  width: 125px;
}

#reportsView .report-table th:nth-child(7) {
  width: 230px;
}

#reportsView .report-table th:nth-child(8),
#reportsView .report-table th:nth-child(9) {
  width: 78px;
}

#reportsView .report-table th:nth-child(10),
#reportsView .report-table th:nth-child(11) {
  width: 115px;
}

#reportsView .report-table th:nth-child(12),
#reportsView .report-table th:nth-child(13) {
  width: 105px;
}

#reportsView .report-table th:nth-child(14) {
  width: 135px;
}

#reportsView .report-table th:nth-child(15) {
  width: 160px;
}

#reportsView .report-table th:nth-child(16) {
  width: 115px;
}

#reportsView .report-table td {
  vertical-align: middle;
}

#reportsView .report-product-cell strong {
  display: block;
  overflow-wrap: anywhere;
}

#reportsView .report-table tbody tr.report-group-start td {
  border-top: 2px solid #aebdce;
}

#reportsView .report-table tbody tr.report-group-row td {
  padding-top: 10px;
  padding-bottom: 10px;
}

#reportsView .report-table tbody td.report-group-cell {
  vertical-align: top;
  background: #f8fafc;
  color: #1f3046;
  font-weight: 700;
}

#reportsView .report-table tbody td.report-quote-no {
  color: var(--blue);
  font-weight: 900;
  white-space: nowrap;
}

#reportsView .report-table tbody td.report-quote-party {
  overflow-wrap: anywhere;
}

#reportsView .report-table tbody tr.report-group-row:not(.report-group-start) td:not(.report-group-cell) {
  background: #fff;
}

#reportsView .report-status-select {
  min-width: 132px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

#reportsView .report-delivery-select {
  min-width: 156px;
}

#reportsView .report-status-select:disabled {
  cursor: not-allowed;
  opacity: 0.82;
  background: #eef8f2;
  color: #12633d;
}

.line-table input,
.line-table select {
  min-width: 100px;
  padding: 8px;
}

.line-table .code-input {
  min-width: 140px;
}

.product-picker-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  gap: 6px;
  align-items: center;
  min-width: 190px;
}

.line-table .product-picker-control .code-input {
  min-width: 0;
  width: 100%;
}

.product-search-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #f8fafc;
  color: var(--blue);
  box-shadow: none;
}

.product-search-button:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.product-search-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-table .name-input {
  min-width: 260px;
}

.line-table .number-input {
  min-width: 92px;
  text-align: right;
}

.line-table .remove-line {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #fef3f2;
  color: var(--danger);
  font-weight: 900;
  box-shadow: none;
}

.agent-pricing-table th {
  background: #eef3f9;
  color: #182230;
}

.agent-line-row > td {
  padding: 0;
  background: #f8fafc;
}

.agent-line-item {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.agent-line-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #111827;
  padding-bottom: 2px;
}

.agent-product-row,
.agent-price-row {
  display: grid;
  gap: 10px;
  align-items: end;
}

.agent-product-row {
  grid-template-columns: 200px minmax(280px, 1fr) 160px 110px 110px;
}

.agent-price-row {
  grid-template-columns: minmax(210px, 1fr) 130px 130px 130px 140px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: white;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}

.agent-price-row--dealer {
  border-left: 4px solid var(--brand);
}

.agent-price-row--customer {
  border-left: 4px solid var(--blue);
  grid-template-columns: minmax(210px, 1fr) 130px 130px 140px;
}

.agent-price-label strong,
.agent-price-total strong {
  display: block;
  color: #111827;
}

.agent-price-label span,
.agent-price-total span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.agent-price-total {
  min-height: 42px;
  display: grid;
  align-content: center;
  justify-items: end;
  border-left: 1px solid var(--line);
  padding-left: 10px;
  background: #f8fafc;
  border-radius: 6px;
  padding: 8px 10px;
}

.agent-total,
.customer-total {
  font-size: 15px;
}

.product-search-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
}

.product-search-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
}

.product-search-card {
  position: relative;
  width: min(760px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
  padding: 18px;
}

.product-search-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.product-search-head h2 {
  margin: 0;
  font-size: 20px;
}

.product-search-head p {
  margin: 3px 0 0;
  color: var(--muted);
}

.product-search-close {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #f2f4f7;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  box-shadow: none;
}

.product-search-field {
  display: grid;
  gap: 6px;
}

.product-search-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.product-search-field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  outline: none;
}

.product-search-field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.product-search-results {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 4px;
}

.product-result-button {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 4px 14px;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  box-shadow: none;
}

.product-result-button:hover {
  border-color: #bfdbfe;
  background: #f8fbff;
}

.product-result-button strong {
  color: var(--brand);
  font-weight: 900;
}

.product-result-button span {
  color: var(--text);
  font-weight: 800;
}

.product-result-button small {
  grid-column: 2;
  color: var(--muted);
}

.product-search-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
  background: #f8fafc;
}

.summary-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
}

.summary-panel {
  display: grid;
  gap: 0;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  align-self: start;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.06);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #edf1f6;
  padding: 10px 0;
  font-size: 13px;
}

.summary-row strong {
  white-space: nowrap;
  color: #111827;
}

.summary-row.total {
  border: 0;
  font-size: 18px;
  color: var(--brand-dark);
  padding-top: 12px;
}

.summary-row.total strong {
  color: var(--brand-dark);
}

.summary-row.summary-note {
  color: var(--blue);
  font-weight: 800;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.checkbox-field input {
  width: 18px;
  height: 18px;
}

.outcome-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.outcome-control button {
  min-height: 38px;
  border-radius: 7px;
  background: #fff;
  color: #475467;
  border: 1px solid var(--line);
  font-weight: 900;
}

.outcome-control button.active {
  background: #111827;
  color: #fff;
  border-color: #111827;
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.16);
}

.outcome-control button[data-outcome="win"].active {
  background: var(--ok);
  border-color: var(--ok);
}

.outcome-control button[data-outcome="loss"].active {
  background: var(--danger);
  border-color: var(--danger);
}

.danger-alert {
  margin: 14px 0 0;
  border: 1px solid #fda29b;
  background: #fff1f0;
  color: var(--danger);
  border-radius: 8px;
  padding: 12px;
  font-weight: 800;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 4px 0 24px;
}

.editor-actions button:nth-child(2) {
  background: #253244;
  box-shadow: 0 10px 20px rgba(37, 50, 68, 0.16);
}

.editor-actions button:nth-child(3) {
  background: var(--ok);
  box-shadow: 0 10px 20px rgba(15, 138, 95, 0.16);
}

.danger-button {
  background: #fef3f2 !important;
  color: var(--danger) !important;
}

.report-filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  padding: 16px;
  margin-bottom: 16px;
}

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

.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.data-panel {
  padding: 16px;
}

.import-panel {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  border-left: 4px solid var(--blue);
}

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

.import-actions button {
  background: #111827;
  color: white;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 800;
  white-space: nowrap;
}

.masters-view .master-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.full-width {
  grid-column: 1 / -1;
}

.compact-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 12px 0;
}

.compact-form textarea,
.compact-form button {
  grid-column: 1 / -1;
}

.master-search {
  display: grid;
  gap: 6px;
  margin: 10px 0 12px;
}

.master-search label {
  display: grid;
  gap: 6px;
}

.master-search-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 8px;
}

.master-search-control input {
  width: 100%;
}

.master-search-control button {
  width: 40px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #f8fafc;
  color: var(--blue);
  box-shadow: none;
}

.master-search-control button:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.master-search-control svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.master-search small,
.master-empty {
  color: var(--muted);
  font-size: 12px;
}

.master-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  background: #f8fafc;
}

.master-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.master-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-soft);
}

.master-row small {
  display: block;
  color: var(--muted);
}

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

.row-actions button {
  background: #e2e8f0;
  color: #334155;
  border-radius: 7px;
  padding: 7px 9px;
  font-weight: 800;
}

.row-actions .delete-small {
  background: #fef3f2;
  color: var(--danger);
}

.terms-editor {
  margin: 12px 0;
}

.bulk-import-panel p {
  margin: 6px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.bulk-import-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.bulk-import-grid button {
  min-height: 42px;
  background: #253244;
  color: white;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 800;
}

.bulk-import-grid .secondary-action {
  background: #eef2f7;
  color: #253244;
  border: 1px solid #cbd5e1;
}

.bulk-import-example {
  border: 1px solid #d7dee8;
  background: #f8fafc;
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
}

.bulk-import-example-head {
  border-bottom: 1px solid #d7dee8;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
  padding: 8px 10px;
}

.bulk-import-example pre {
  margin: 0;
  max-height: 150px;
  overflow: auto;
  padding: 10px;
  color: #111827;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre;
}

.bulk-import-textarea {
  min-height: 180px;
  font-family: "SFMono-Regular", Consolas, monospace;
  line-height: 1.55;
  white-space: pre;
}

/* Polished production UI */
.app-shell {
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  background: #ffffff;
  border-right: 1px solid #e4e9f1;
  padding: 20px 16px;
}

.brand-mark {
  border-color: #eef1f5;
  box-shadow: 0 8px 18px rgba(16, 24, 40, 0.05);
}

.sidebar-brand strong {
  color: #141b24;
  font-size: 19px;
  font-weight: 900;
}

.sidebar-brand span,
.sidebar-footer {
  font-weight: 600;
}

.nav-item {
  min-height: 42px;
  border-radius: 7px;
  padding: 11px 12px;
  font-size: 13px;
  font-weight: 800;
}

.nav-item.active,
.nav-item:hover {
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-color: #ffc9cf;
}

.content {
  padding: 22px 28px 36px;
}

.topbar {
  border-color: #e6ebf2;
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.06);
}

.topbar p {
  color: #697386;
  font-size: 12px;
  font-weight: 800;
}

.topbar h1 {
  color: #121a26;
  font-size: 25px;
  font-weight: 900;
}

.topbar-actions button,
.editor-actions button,
.section-heading button,
.compact-form button,
#saveTermsBtn,
.report-filters button,
.auth-form button,
.setup-panel button {
  min-height: 40px;
  border-radius: 7px;
  padding: 10px 15px;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(177, 36, 35, 0.16);
}

.workspace-layout {
  grid-template-columns: 296px minmax(760px, 1fr);
  gap: 18px;
}

.quote-list-panel,
.quote-editor,
.data-panel,
.report-filters,
.editor-band {
  border-color: #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.055);
}

.quote-list-panel {
  padding: 15px;
}

.quote-card {
  border-color: #e6ebf2;
  border-radius: 8px;
  padding: 12px 13px;
}

.quote-card.active {
  border-color: #e65b61;
  box-shadow: 0 0 0 3px rgba(177, 36, 35, 0.1);
}

.quote-card strong {
  color: #121a26;
  font-weight: 900;
}

.quote-editor {
  gap: 14px;
}

.document-strip {
  grid-template-columns: minmax(210px, 0.9fr) minmax(210px, 0.9fr) minmax(320px, 1.2fr);
  gap: 12px;
}

.document-tile,
.document-strip p {
  border-color: #e1e7ef;
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.98));
  box-shadow: 0 14px 30px rgba(16, 24, 40, 0.06);
  padding: 15px 16px;
}

.document-tile {
  position: relative;
  overflow: hidden;
  border-left: 0;
}

.document-tile::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--brand);
}

.document-tile:nth-child(2)::before {
  background: #15328A;
}

.document-tile span {
  color: #667085;
  font-size: 11px;
  font-weight: 900;
}

.document-tile strong {
  margin-top: 6px;
  color: #121a26;
  font-size: 21px;
  font-weight: 900;
  line-height: 1.15;
}

.document-strip p {
  color: #475467;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.65;
}

.editor-band {
  padding: 18px 20px 20px;
}

.editor-band .section-heading {
  padding-bottom: 12px;
}

.panel-title-row h2,
.section-heading h2,
.data-panel h2 {
  color: #121a26;
  font-size: 16px;
  font-weight: 900;
}

.form-grid {
  gap: 13px 14px;
}

label {
  gap: 7px;
  color: #586474;
  font-size: 12px;
  font-weight: 800;
}

input,
select,
textarea {
  min-height: 40px;
  border-color: #d7dee8;
  border-radius: 7px;
  background: #ffffff;
  padding: 9px 11px;
  color: #111827;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 1px 0 rgba(16, 24, 40, 0.02);
}

textarea {
  line-height: 1.55;
}

input[readonly] {
  background: #f3f6fa;
  color: #475467;
  font-weight: 800;
}

input::placeholder,
textarea::placeholder {
  color: #98a2b3;
  font-weight: 500;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #e65b61;
  box-shadow: 0 0 0 3px rgba(177, 36, 35, 0.1);
}

.status-pill {
  border-radius: 7px;
  font-size: 11px;
  font-weight: 900;
}

.line-table-wrap {
  border-color: #d9e1ec;
  border-radius: 9px;
  box-shadow: none;
}

.line-table th,
.data-table th {
  background: #f6f8fb;
  color: #273549;
  font-size: 11px;
  letter-spacing: 0;
}

.line-table th,
.line-table td,
.data-table th,
.data-table td {
  padding: 8px;
  font-size: 12.5px;
}

.line-table input,
.line-table select {
  min-height: 36px;
  padding: 7px 8px;
  font-size: 12.5px;
}

.line-table .code-input {
  min-width: 155px;
  color: var(--brand-dark);
  font-weight: 900;
}

.line-table .name-input {
  min-width: 320px;
}

.summary-layout {
  grid-template-columns: minmax(0, 1fr) 340px;
}

.summary-panel {
  border-color: #dfe6ef;
  border-radius: 9px;
  padding: 8px 15px;
}

.summary-row {
  font-size: 12.5px;
}

.summary-row.total {
  font-size: 19px;
}

.checkbox-field,
.outcome-control {
  border-radius: 8px;
  border-color: #dfe6ef;
}

/* 100% viewport fit and modern bottom actions */
.app-shell {
  grid-template-columns: 238px minmax(0, 1fr);
  overflow-x: hidden;
}

.content {
  min-width: 0;
  overflow-x: hidden;
  padding: 20px clamp(16px, 2vw, 26px) 34px;
}

.workspace-layout {
  grid-template-columns: minmax(236px, 282px) minmax(0, 1fr);
  max-width: 100%;
}

.quote-editor,
.editor-band,
.summary-layout {
  min-width: 0;
}

.line-table-wrap {
  max-width: 100%;
}

.editor-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  padding: 14px 16px;
  border: 1px solid #dfe6ef;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 -12px 34px rgba(16, 24, 40, 0.08);
  backdrop-filter: blur(10px);
}

.editor-actions button {
  min-width: 112px;
}

.editor-actions .primary-action {
  background: var(--brand);
}

.editor-actions .dark-action {
  background: #253244;
  box-shadow: 0 10px 20px rgba(37, 50, 68, 0.16);
}

.editor-actions .success-action {
  background: var(--ok);
  box-shadow: 0 10px 20px rgba(15, 138, 95, 0.16);
}

.editor-actions .print-action {
  margin-left: auto;
  background: #111827;
  box-shadow: 0 10px 20px rgba(17, 24, 39, 0.18);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  max-width: 420px;
  border-radius: 10px;
  background: #111827;
  color: white;
  box-shadow: var(--shadow);
  padding: 13px 16px;
  font-weight: 800;
}

.print-sheet {
  display: none;
}

@media (max-width: 1200px) {
  .workspace-layout,
  .summary-layout,
  .document-strip,
  .report-filters,
  .metric-grid,
  .masters-view .master-grid {
    grid-template-columns: 1fr;
  }

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

  .bulk-import-grid label {
    grid-column: 1 / -1;
  }

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

  .quote-list-panel {
    position: static;
  }

  .agent-product-row,
  .agent-price-row,
  .agent-price-row--customer {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .agent-price-label,
  .agent-price-total {
    grid-column: 1 / -1;
  }

  .agent-price-total {
    justify-items: start;
    border-left: 0;
  }

  .product-result-button {
    grid-template-columns: 120px minmax(0, 1fr);
  }
}

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

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

  .form-grid,
  .compact-form {
    grid-template-columns: 1fr;
  }

  .address-grid,
  .ship-to-preview {
    grid-template-columns: 1fr;
  }

  .address-action-row {
    align-items: stretch;
    flex-direction: column;
  }

  .address-copy-action {
    width: 100%;
  }

  .span-2,
  .span-3,
  .full-width {
    grid-column: auto;
  }

  .content {
    padding: 14px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .editor-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .editor-actions .print-action {
    margin-left: 0;
  }

  .bulk-import-grid {
    grid-template-columns: 1fr;
  }

  .bulk-import-grid label {
    grid-column: auto;
  }

  .product-search-modal {
    padding: 12px;
  }

  .product-search-card {
    max-height: calc(100vh - 24px);
  }

  .product-result-button {
    grid-template-columns: 1fr;
  }

  .product-result-button small {
    grid-column: auto;
  }

  .import-panel {
    align-items: stretch;
    flex-direction: column;
  }
}

@media print {
  body {
    background: white;
  }

  .app-shell,
  .login-screen,
  .setup-screen,
  .toast {
    display: none !important;
  }

  .print-sheet {
    display: block;
    width: 210mm;
    min-height: auto;
    margin: 0 auto;
    padding: 0;
    box-sizing: border-box;
    background: white;
    color: #111827;
    font-family: "Noto Sans Thai", "Tahoma", sans-serif;
    font-size: 9.2px;
    line-height: 1.3;
  }

  @page {
    size: A4 portrait;
    margin: 0;
  }

  .print-document {
    display: grid;
    grid-template-rows: auto auto minmax(76mm, 1fr) minmax(50mm, auto) auto auto;
    align-content: stretch;
    width: 198mm;
    height: 284.5mm;
    min-height: 284.5mm;
    margin: 6mm auto;
    border: 1px solid #111827;
    break-after: page;
    break-inside: avoid;
    page-break-inside: avoid;
    box-sizing: border-box;
    overflow: visible;
  }

  .print-document:last-child {
    break-after: auto;
  }

  .print-header {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.75fr);
    border-bottom: 1px solid #111827;
  }

  .print-company,
  .print-title {
    padding: 4px 7px;
  }

  .print-company {
    display: grid;
    grid-template-columns: 62px 1fr;
    gap: 7px;
    align-items: start;
    border-right: 1px solid #111827;
    min-width: 0;
  }

  .print-logo {
    width: 58px;
    height: 37px;
    display: grid;
    place-items: center;
  }

  .print-logo img {
    width: 58px;
    height: 37px;
    object-fit: contain;
  }

  .print-logo span {
    display: none;
    color: #B12423;
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 0;
  }

  .print-company strong,
  .print-title strong {
    display: block;
    font-size: 10.7px;
    line-height: 1.25;
  }

  .print-company div:last-child {
    line-height: 1.2;
  }

  .print-company span {
    font-size: 8.7px;
    line-height: 1.22;
  }

  .print-title {
    display: grid;
    align-content: center;
    justify-items: center;
    text-align: center;
    background: #fbfcfe;
    min-width: 0;
    overflow: hidden;
  }

  .print-title span {
    font-size: 10px;
    font-weight: 800;
  }

  .print-title h1 {
    margin: 1px 0 2px;
    color: #111827;
    font-size: 18.5px;
    letter-spacing: 0;
    line-height: 1.05;
  }

  .print-title strong {
    width: 84%;
    min-width: 0;
    max-width: 100%;
    border-top: 1px solid #111827;
    padding-top: 3px;
    font-size: 9.1px;
    font-weight: 800;
    line-height: 1.18;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .print-info-grid {
    display: grid;
    grid-template-columns: 1.08fr 1.08fr 0.92fr 0.92fr;
    border-bottom: 1px solid #111827;
  }

  .print-box {
    min-height: 22px;
    padding: 3.5px 5.5px;
    border-right: 1px solid #111827;
    border-bottom: 1px solid #111827;
  }

  .print-box:nth-child(4n) {
    border-right: 1px solid #111827;
  }

  .print-box--span-2 {
    grid-column: span 2;
  }

  .print-box label {
    display: block;
    color: #2f3847;
    font-size: 8.1px;
    font-weight: 800;
    line-height: 1.16;
  }

  .print-box strong {
    display: block;
    margin-top: 1px;
    color: #111827;
    font-size: 9.7px;
    font-weight: 800;
    line-height: 1.22;
  }

  .print-items {
    display: grid;
    grid-template-rows: auto 1fr;
    min-height: 76mm;
    border-bottom: 1px solid #111827;
    background: #fff;
  }

  .print-lines {
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
  }

  .print-lines th,
  .print-lines td {
    padding: 3.5px 4.8px;
    vertical-align: top;
    overflow-wrap: anywhere;
  }

  .print-lines th {
    border-right: 1px solid #111827;
    border-bottom: 1px solid #111827;
    text-align: center;
    font-size: 8.4px;
    line-height: 1.18;
    background: #f6f7f9;
  }

  .print-lines th:last-child {
    border-right: 0;
  }

  .print-lines tbody tr {
    min-height: 8mm;
  }

  .print-lines td {
    height: 8mm;
    font-size: 9.2px;
    line-height: 1.24;
    border-right: 0;
    border-bottom: 1px solid #e2e7ef;
  }

  .print-lines tbody tr:last-child td {
    border-bottom-color: #eef1f5;
  }

  .print-lines td:nth-child(2) {
    color: #b91c1c;
    font-weight: 800;
  }

  .print-lines td:nth-child(3) {
    font-weight: 700;
  }

  .print-lines td:nth-child(1),
  .print-lines td:nth-child(4),
  .print-lines td:nth-child(5) {
    vertical-align: middle;
  }

  .print-items-space {
    min-height: 15mm;
    background:
      linear-gradient(to bottom, rgba(226, 232, 240, 0.45), rgba(226, 232, 240, 0.08) 1px, transparent 1px) top / 100% 9mm no-repeat;
  }

  .num {
    text-align: right;
  }

  .center {
    text-align: center;
  }

  .print-bottom {
    display: grid;
    grid-template-columns: 1.04fr 0.96fr;
    min-height: 50mm;
  }

  .print-terms,
  .print-totals {
    padding: 7px;
  }

  .print-terms {
    border-right: 1px solid #111827;
    white-space: pre-line;
    font-size: 8.25px;
    line-height: 1.32;
  }

  .print-totals {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
  }

  .print-total-row {
    display: grid;
    grid-template-columns: 1fr 90px;
    border: 1px solid #111827;
    border-bottom: 0;
    background: #fff;
  }

  .print-total-row:last-child {
    border-bottom: 1px solid #111827;
    background: #f8fafc;
  }

  .print-total-row span,
  .print-total-row strong {
    padding: 4.5px 5px;
    font-size: 8.7px;
    line-height: 1.2;
  }

  .print-total-row strong {
    text-align: right;
    border-left: 1px solid #111827;
    font-weight: 900;
  }

  .print-approvals {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    padding: 8px 8px;
    border-top: 1px solid #111827;
  }

  .signature-box {
    min-height: 78px;
    border: 1px solid #111827;
    border-radius: 5px;
    padding: 7px 8px;
    text-align: center;
    display: grid;
    align-content: start;
  }

  .signature-line {
    min-height: 20px;
    margin-top: 22px;
    border-top: 1px solid #111827;
    padding-top: 4px;
    font-weight: 800;
    font-size: 8.9px;
  }

  .signature-box strong {
    font-size: 9px;
    line-height: 1.2;
  }

  .signature-box small {
    display: block;
    margin-top: 3px;
    font-size: 8px;
    line-height: 1.2;
  }

  .signature-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 5px;
    font-size: 8px;
  }

  .purchase-confirmation {
    border-top: 1px solid #111827;
    padding: 7px 10px 6px;
  }

  .purchase-confirmation h3 {
    margin: 0 0 3px;
    color: #B12423;
    font-size: 10.1px;
    line-height: 1.2;
  }

  .purchase-confirmation h3 span {
    margin-left: 5px;
    font-size: 9.4px;
    font-weight: 900;
  }

  .purchase-confirmation p {
    margin: 0 0 10px;
    font-size: 8.3px;
  }

  .purchase-fields {
    display: grid;
    grid-template-columns: 1.25fr 0.85fr 0.85fr;
    gap: 14px 16px;
  }

  .purchase-line {
    height: 16px;
    border-bottom: 1px solid #111827;
    margin-bottom: 3px;
  }

  .purchase-field strong,
  .purchase-field small {
    display: block;
    font-size: 8px;
    line-height: 1.18;
  }

  .purchase-field small {
    color: #374151;
  }
}

.sales-dashboard-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 16px;
  padding: 20px 22px;
  border: 1px solid #223852;
  border-radius: var(--radius);
  background: #0C0B3A;
  color: #fff;
  box-shadow: 0 14px 28px rgba(23, 43, 70, 0.14);
}

.sales-dashboard-hero h2 {
  margin: 4px 0 3px;
  font-size: 23px;
  line-height: 1.25;
}

.sales-dashboard-hero p {
  margin: 0;
  color: #c8d6e7;
  font-size: 12px;
  font-weight: 600;
}

.dashboard-kicker {
  display: block;
  color: #9eb8d4;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.dashboard-kicker-soft {
  color: #7789a3;
}

.dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.dashboard-actions button {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.dashboard-actions button:hover {
  background: rgba(255, 255, 255, 0.18);
}

.dashboard-actions .dashboard-target-button {
  border-color: #8be0bb;
  background: #0f8a5f;
}

.dashboard-actions .dashboard-export-button {
  border-color: #8bb9f4;
  background: #15328A;
}

#reportsView .metric-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

#reportsView .metric-card {
  min-height: 126px;
  border-top: 3px solid #cbd5e1;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}

#reportsView .metric-card strong {
  font-size: 22px;
  line-height: 1.2;
}

#reportsView .metric-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}

#reportsView .metric-card.kpi-card-opp { border-top-color: #d6a72c; }
#reportsView .metric-card.kpi-card-win { border-top-color: var(--ok); }
#reportsView .metric-card.kpi-card-rate { border-top-color: var(--blue); }
#reportsView .metric-card.kpi-card-target { border-top-color: #7c5ac7; }
#reportsView .metric-card.kpi-card-gap { border-top-color: var(--brand); }
#reportsView .metric-card.kpi-card-over { border-top-color: var(--ok); }

.sales-dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 16px;
  margin-bottom: 16px;
}

.dashboard-panel {
  min-width: 0;
  padding: 18px;
}

.dashboard-panel h3 {
  margin: 2px 0 0;
  color: #0C0B3A;
  font-size: 16px;
}

.dashboard-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.dashboard-panel-note {
  margin: 8px 0 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.dashboard-period-badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid #d9e4f0;
  border-radius: 6px;
  background: #f5f8fc;
  color: #52657d;
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.group-performance-list,
.sales-performance-list {
  display: grid;
  gap: 12px;
}

.group-performance-card {
  padding: 12px 13px;
  border: 1px solid #dbe3ed;
  border-radius: 8px;
  background: #fbfcfe;
}

.group-performance-head,
.group-performance-meta,
.group-performance-bottom,
.sales-person-head,
.sales-person-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.group-performance-head strong,
.sales-person-head strong {
  display: block;
  color: #20344e;
  font-size: 13px;
}

.group-performance-head small,
.sales-person-head small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.group-performance-head .group-actual,
.sales-person-value {
  color: var(--ok);
  font-size: 14px;
  white-space: nowrap;
}

.performance-track,
.sales-bar-track {
  height: 8px;
  margin: 11px 0 9px;
  overflow: hidden;
  border-radius: 99px;
  background: #e7edf4;
}

.performance-track span,
.sales-bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--ok);
}

.group-performance-meta {
  justify-content: flex-start;
  gap: 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.group-performance-meta strong {
  margin-right: 8px;
  color: #263b54;
  font-size: 11px;
}

.positive-gap { color: var(--ok) !important; }
.negative-gap { color: var(--brand) !important; }

.group-performance-bottom {
  align-items: flex-end;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid #e3e9f1;
}

.target-input-label {
  display: grid;
  grid-template-columns: auto 112px;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.report-target-input {
  min-height: 32px;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 800;
}

.target-readonly {
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.target-readonly strong {
  color: #263b54;
  font-size: 12px;
}

.group-status-metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.group-status-metrics b {
  color: #263b54;
  font-size: 10px;
}

.sales-person-row {
  padding: 2px 0 12px;
  border-bottom: 1px solid #e4eaf1;
}

.sales-person-row:last-child {
  padding-bottom: 2px;
  border-bottom: 0;
}

.sales-person-head { align-items: center; }

.sales-rank {
  display: grid;
  flex: 0 0 30px;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: #edf3fa;
  color: #38526f;
  font-size: 11px;
  font-weight: 900;
}

.sales-person-head > div {
  flex: 1 1 auto;
  min-width: 0;
}

.sales-bar-track {
  height: 7px;
  margin: 9px 0 7px 40px;
}

.sales-bar-track span { background: var(--blue); }

.sales-person-meta {
  justify-content: flex-start;
  gap: 12px;
  margin-left: 40px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.dashboard-chart-legend {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.legend-dot-win { background: var(--ok); }
.legend-dot-opp { margin-left: 8px; background: #d6a72c; }

.dashboard-trend-panel { margin-bottom: 16px; }

.daily-trend-axis {
  display: flex;
  justify-content: space-between;
  margin: 14px 0 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.daily-trend-bars {
  display: flex;
  align-items: stretch;
  gap: 10px;
  min-height: 210px;
  padding: 8px 4px 0;
  overflow-x: auto;
  border-top: 1px solid #e5ebf2;
}

.daily-trend-column {
  display: grid;
  flex: 0 0 58px;
  grid-template-rows: 25px minmax(0, 1fr) 24px;
  gap: 5px;
  min-height: 195px;
  text-align: center;
}

.daily-trend-values {
  overflow: hidden;
  color: #52657d;
  font-size: 9px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daily-trend-bars-inner {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  min-height: 0;
  border-bottom: 1px solid #b8c6d5;
  background: repeating-linear-gradient(to top, transparent 0, transparent 39px, #edf1f5 40px);
}

.trend-bar {
  display: block;
  width: 15px;
  border-radius: 3px 3px 0 0;
}

.trend-bar-opp { background: #d6a72c; }
.trend-bar-win { background: var(--ok); }

.daily-trend-column small {
  color: #52657d;
  font-size: 10px;
  font-weight: 800;
}

.dashboard-empty {
  display: grid;
  min-height: 92px;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 1200px) {
  #reportsView .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sales-dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .sales-dashboard-hero { align-items: stretch; flex-direction: column; padding: 16px; }
  .sales-dashboard-hero h2 { font-size: 20px; }
  .dashboard-actions { justify-content: stretch; }
  .dashboard-actions button { flex: 1 1 130px; }
  #reportsView .metric-grid { grid-template-columns: 1fr; }
  .dashboard-panel-head,
  .group-performance-bottom { align-items: stretch; flex-direction: column; }
  .target-input-label { grid-template-columns: 1fr; }
  .group-status-metrics,
  .sales-person-meta { justify-content: flex-start; margin-left: 0; }
  .sales-bar-track { margin-left: 0; }
}

.sales-dashboard-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
  padding: 22px 24px;
  border: 1px solid #243b5a;
  border-radius: 10px;
  background: #0C0B3A;
  color: #fff;
  box-shadow: 0 14px 30px rgba(23, 43, 70, 0.16);
}

.sales-dashboard-hero h2 {
  margin: 4px 0 2px;
  font-size: 24px;
  line-height: 1.2;
}

.sales-dashboard-hero p {
  margin: 0;
  color: #cbd8e8;
  font-size: 13px;
  font-weight: 600;
}

.dashboard-kicker {
  display: block;
  color: #9fb8d4;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.dashboard-kicker-soft {
  color: #637a98;
}

.dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.dashboard-actions button {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.dashboard-actions button:hover {
  background: rgba(255, 255, 255, 0.18);
}

.dashboard-actions .dashboard-target-button {
  border-color: #76d1a9;
  background: #0f8a5f;
}

.dashboard-actions .dashboard-export-button {
  border-color: #f0a0a4;
  background: #B12423;
}

#reportsView .metric-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

#reportsView .metric-card {
  min-height: 126px;
  border-top: 3px solid #c7d2e0;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}

#reportsView .metric-card strong {
  font-size: 22px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

#reportsView .metric-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}

#reportsView .metric-card.kpi-card-opp {
  border-top-color: #e0a126;
}

#reportsView .metric-card.kpi-card-win {
  border-top-color: #0f8a5f;
}

#reportsView .metric-card.kpi-card-rate {
  border-top-color: #15328A;
}

#reportsView .metric-card.kpi-card-target {
  border-top-color: #64748b;
}

#reportsView .metric-card.kpi-card-gap {
  border-top-color: #B12423;
}

#reportsView .metric-card.kpi-card-over {
  border-top-color: #0f8a5f;
}

.sales-dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 16px;
  margin-bottom: 16px;
}

.dashboard-panel {
  min-width: 0;
  padding: 18px;
}

.dashboard-panel h3 {
  margin: 4px 0 0;
  color: #1d2e45;
  font-size: 17px;
}

.dashboard-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.dashboard-panel-note {
  margin: 8px 0 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.dashboard-period-badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid #d4deeb;
  border-radius: 6px;
  background: #f5f8fc;
  color: #51657e;
  font-size: 11px;
  font-weight: 900;
}

.group-performance-list,
.sales-performance-list {
  display: grid;
  gap: 12px;
}

.group-performance-card {
  padding: 13px 14px;
  border: 1px solid #dbe3ed;
  border-radius: 8px;
  background: #fbfcfe;
}

.group-performance-head,
.group-performance-meta,
.group-performance-bottom,
.sales-person-head,
.sales-person-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.group-performance-head strong,
.sales-person-head strong {
  color: #1e2f46;
  font-size: 14px;
}

.group-performance-head small,
.sales-person-head small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.group-actual,
.sales-person-value {
  color: #0f8a5f !important;
  white-space: nowrap;
}

.performance-track,
.sales-bar-track {
  height: 8px;
  margin: 12px 0 10px;
  overflow: hidden;
  border-radius: 99px;
  background: #e7edf4;
}

.performance-track span,
.sales-bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #0f8a5f;
}

.group-performance-meta {
  justify-content: flex-start;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.group-performance-meta strong {
  margin-right: 8px;
  color: #1e2f46;
  font-size: 12px;
}

.group-performance-meta .negative-gap {
  color: #B12423;
}

.group-performance-meta .positive-gap {
  color: #0f8a5f;
}

.group-performance-bottom {
  align-items: flex-end;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #e4eaf2;
}

.target-input-label,
.target-readonly {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.target-input-label input {
  width: 142px;
  min-height: 32px;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 800;
}

.target-readonly strong {
  color: #344861;
  font-size: 12px;
}

.group-status-metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-align: right;
}

.group-status-metrics b {
  color: #344861;
  font-weight: 900;
}

.sales-person-row {
  padding: 11px 0 12px;
  border-bottom: 1px solid #e3eaf2;
}

.sales-person-row:last-child {
  border-bottom: 0;
}

.sales-person-head {
  justify-content: flex-start;
}

.sales-person-head > div {
  min-width: 0;
  flex: 1;
}

.sales-rank {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: #eef3f8;
  color: #50647d;
  font-size: 11px;
  font-weight: 900;
}

.sales-bar-track {
  height: 7px;
  margin: 9px 0 7px 40px;
}

.sales-bar-track span {
  background: #15328A;
}

.sales-person-meta {
  justify-content: flex-start;
  margin-left: 40px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.dashboard-chart-legend {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-dot-win {
  background: #0f8a5f;
}

.legend-dot-opp {
  margin-left: 7px;
  background: #e0a126;
}

.daily-trend-axis {
  display: flex;
  justify-content: space-between;
  margin: 18px 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.daily-trend-bars {
  display: flex;
  align-items: stretch;
  gap: 12px;
  min-height: 230px;
  overflow-x: auto;
  padding: 10px 4px 0;
  border-bottom: 1px solid #cfd9e5;
}

.daily-trend-column {
  display: grid;
  flex: 0 0 56px;
  grid-template-rows: 24px minmax(0, 1fr) 24px;
  min-height: 210px;
  text-align: center;
}

.daily-trend-values {
  color: #0f8a5f;
  font-size: 9px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
}

.daily-trend-bars-inner {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  min-height: 0;
  border-bottom: 1px solid #e2e8f0;
  background: repeating-linear-gradient(to top, transparent 0, transparent 49px, #eef2f7 50px);
}

.trend-bar {
  display: block;
  width: 14px;
  min-height: 0;
  border-radius: 4px 4px 0 0;
}

.trend-bar-opp {
  background: #e0a126;
}

.trend-bar-win {
  background: #0f8a5f;
}

.daily-trend-column small {
  align-self: end;
  padding-top: 6px;
  color: #53677f;
  font-size: 10px;
  font-weight: 800;
}

.dashboard-empty {
  padding: 24px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

@media (max-width: 1200px) {
  #reportsView .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sales-dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .sales-dashboard-hero {
    align-items: stretch;
    flex-direction: column;
    padding: 18px;
  }

  .sales-dashboard-hero h2 {
    font-size: 20px;
  }

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

  .dashboard-actions button {
    flex: 1 1 135px;
  }

  #reportsView .metric-grid {
    grid-template-columns: 1fr;
  }

  .group-performance-bottom,
  .sales-person-head,
  .sales-person-meta {
    align-items: flex-start;
  }

  .group-performance-bottom {
    flex-direction: column;
  }

  .group-status-metrics,
  .sales-person-meta {
    justify-content: flex-start;
    margin-left: 0;
    text-align: left;
  }
}

/* Final A4 print layout: keep every section on one visual grid. */
@media print {
  :root {
    color-scheme: light;
  }

  html,
  body {
    margin: 0;
    padding: 0;
    background: #fff;
  }

  .print-sheet {
    width: 210mm;
    margin: 0;
    padding: 0;
    background: #fff;
    color: #172033;
    font-family: "Noto Sans Thai", "Tahoma", sans-serif;
    font-size: 9.3px;
    line-height: 1.28;
  }

  .print-document {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 196mm;
    height: auto;
    min-height: 283mm;
    margin: 6.5mm auto;
    border: 0.7px solid #1f2b3d;
    border-radius: 0;
    box-sizing: border-box;
    background: #fff;
    overflow: visible;
    break-inside: avoid;
    page-break-inside: avoid;
    break-after: page;
    page-break-after: always;
  }

  .print-document::before {
    position: absolute;
    top: -0.7px;
    right: -0.7px;
    left: -0.7px;
    height: 1.4mm;
    background: #B12423;
    content: "";
  }

  .print-document:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .print-header {
    display: grid;
    grid-template-columns: minmax(0, 1.86fr) minmax(0, 0.74fr);
    flex: 0 0 auto;
    min-height: 22.5mm;
    border-bottom: 0.7px solid #1f2b3d;
  }

  .print-company,
  .print-title {
    box-sizing: border-box;
    padding: 2.5mm 3.5mm;
  }

  .print-company {
    display: grid;
    grid-template-columns: 22mm minmax(0, 1fr);
    gap: 3mm;
    align-items: start;
    border-right: 0.7px solid #1f2b3d;
    min-width: 0;
  }

  .print-logo {
    width: 20mm;
    height: 13.5mm;
    display: grid;
    place-items: center;
  }

  .print-logo img {
    display: block;
    width: 20mm;
    height: 13.5mm;
    object-fit: contain;
  }

  .print-logo span {
    display: none;
    color: #B12423;
    font-size: 17px;
    font-weight: 900;
  }

  .print-company > div:last-child {
    min-width: 0;
  }

  .print-company strong {
    display: block;
    margin: 0 0 0.5mm;
    color: #172033;
    font-size: 9.4px;
    font-weight: 900;
    line-height: 1.18;
  }

  .print-company span {
    display: inline;
    color: #29364a;
    font-size: 8.1px;
    line-height: 1.2;
  }

  .print-title {
    display: grid;
    align-content: center;
    justify-items: center;
    min-width: 0;
    overflow: hidden;
    background: #f7f9fc;
    text-align: center;
  }

  .print-title span {
    color: #4b5870;
    font-size: 9px;
    font-weight: 900;
    line-height: 1.15;
  }

  .print-title h1 {
    margin: 0.8mm 0 1.1mm;
    color: #172033;
    font-size: 17.5px;
    letter-spacing: 0;
    line-height: 1;
  }

  .print-title strong {
    width: 86%;
    box-sizing: border-box;
    border-top: 0.7px solid #1f2b3d;
    padding-top: 1.2mm;
    color: #172033;
    font-size: 8.6px;
    font-weight: 900;
    line-height: 1.15;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .print-info-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    flex: 0 0 auto;
    border-bottom: 0;
  }

  .print-box {
    display: grid;
    align-content: center;
    min-width: 0;
    min-height: 9.8mm;
    box-sizing: border-box;
    padding: 1.55mm 2.5mm;
    border: 0;
    border-right: 0.7px solid #1f2b3d;
    border-bottom: 0.7px solid #1f2b3d;
    overflow: hidden;
  }

  .print-box--span-2 {
    grid-column: span 2;
  }

  .print-box--span-full {
    grid-column: 1 / -1;
    border-right: 0;
  }

  .print-box--end {
    border-right: 0;
  }

  .print-box label {
    display: block;
    min-width: 0;
    color: #5b687d;
    font-size: 7.35px;
    font-weight: 900;
    line-height: 1.14;
    overflow-wrap: anywhere;
  }

  .print-box strong {
    display: block;
    min-width: 0;
    margin-top: 0.45mm;
    color: #172033;
    font-size: 8.55px;
    font-weight: 900;
    line-height: 1.18;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .print-items {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 52mm;
    border-bottom: 0.7px solid #1f2b3d;
    background: #fff;
  }

  .print-lines {
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
    empty-cells: show;
  }

  .print-lines thead {
    display: table-header-group;
  }

  .print-lines tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-lines th,
  .print-lines td {
    box-sizing: border-box;
    padding: 1.7mm 2mm;
    vertical-align: middle;
    overflow-wrap: anywhere;
  }

  .print-lines th {
    border-right: 0.7px solid #1f2b3d;
    border-bottom: 0.7px solid #1f2b3d;
    background: #edf2f7;
    color: #172033;
    font-size: 7.8px;
    font-weight: 900;
    line-height: 1.14;
    text-align: center;
  }

  .print-lines th:last-child {
    border-right: 0;
  }

  .print-lines td {
    height: 7mm;
    border-right: 0;
    border-bottom: 0.7px solid #cfd7e3;
    color: #172033;
    font-size: 8.8px;
    line-height: 1.2;
  }

  .print-lines tbody tr:last-child td {
    border-bottom-color: #aeb9c8;
  }

  .print-lines td:nth-child(2) {
    color: #b4232a;
    font-weight: 900;
  }

  .print-lines td:nth-child(3) {
    font-weight: 700;
  }

  .print-items-space {
    flex: 1 1 auto;
    min-height: 14mm;
    background: #fff;
  }

  .num {
    text-align: right;
    white-space: nowrap;
  }

  .center {
    text-align: center;
  }

  .print-bottom {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
    flex: 0 0 auto;
    min-height: 40mm;
    border-bottom: 0.7px solid #1f2b3d;
  }

  .print-terms,
  .print-totals {
    box-sizing: border-box;
    padding: 2.5mm 3mm;
  }

  .print-terms {
    border-right: 0.7px solid #1f2b3d;
    color: #29364a;
    font-size: 7.6px;
    line-height: 1.18;
    white-space: pre-line;
    overflow-wrap: anywhere;
  }

  .print-totals {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 2.5mm 3mm;
  }

  .print-total-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 29mm;
    border: 0.7px solid #1f2b3d;
    border-bottom: 0;
    background: #fff;
  }

  .print-total-row:last-child {
    border-bottom: 0.7px solid #1f2b3d;
    background: #eef3f8;
  }

  .print-total-row span,
  .print-total-row strong {
    box-sizing: border-box;
    padding: 1.55mm 2.2mm;
    font-size: 7.55px;
    line-height: 1.16;
  }

  .print-total-row span {
    overflow-wrap: anywhere;
  }

  .print-total-row strong {
    border-left: 0.7px solid #1f2b3d;
    color: #172033;
    font-size: 8.3px;
    font-weight: 900;
    text-align: right;
    white-space: nowrap;
  }

  .print-approvals {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2.4mm;
    flex: 0 0 auto;
    padding: 2.5mm 3mm;
    border-bottom: 0.7px solid #1f2b3d;
  }

  .signature-box {
    display: grid;
    align-content: start;
    min-width: 0;
    min-height: 27mm;
    box-sizing: border-box;
    padding: 2.2mm 2.8mm;
    border: 0.7px solid #1f2b3d;
    border-radius: 1.6mm;
    background: #fff;
    text-align: center;
    break-inside: avoid;
  }

  .signature-box > strong {
    color: #172033;
    font-size: 8.7px;
    font-weight: 900;
    line-height: 1.16;
  }

  .signature-box small {
    display: block;
    margin-top: 0.8mm;
    color: #455269;
    font-size: 7.3px;
    line-height: 1.14;
  }

  .signature-line {
    min-height: 7.5mm;
    margin-top: 5.5mm;
    border-top: 0.7px solid #1f2b3d;
    padding-top: 1.5mm;
    color: #172033;
    font-size: 8px;
    font-weight: 900;
    line-height: 1.18;
    overflow-wrap: anywhere;
  }

  .signature-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2mm;
    margin-top: 1.5mm;
    font-size: 7.6px;
  }

  .purchase-confirmation {
    flex: 0 0 auto;
    display: block;
    min-height: 31mm;
    box-sizing: border-box;
    padding: 2.5mm 3.5mm 2.2mm;
    border-top: 0;
    break-inside: avoid;
  }

  .purchase-confirmation h3 {
    margin: 0 0 0.8mm;
    color: #B12423;
    font-size: 8.5px;
    font-weight: 900;
    line-height: 1.16;
  }

  .purchase-confirmation h3 span {
    margin-left: 2mm;
    color: #172033;
    font-size: 7.7px;
    font-weight: 900;
  }

  .purchase-confirmation p {
    margin: 0 0 2.2mm;
    color: #29364a;
    font-size: 7.2px;
    line-height: 1.16;
  }

  .purchase-fields {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2mm 5mm;
  }

  .purchase-line {
    height: 4.8mm;
    margin-bottom: 1mm;
    border-bottom: 0.7px solid #1f2b3d;
  }

  .purchase-field strong,
  .purchase-field small {
    display: block;
    font-size: 7.15px;
    line-height: 1.14;
    overflow-wrap: anywhere;
  }

  .purchase-field strong {
    color: #172033;
    font-weight: 900;
  }

  .purchase-field small {
    color: #455269;
  }

  .purchase-field--signature .purchase-line {
    height: 6mm;
  }
}

@media print {
  .print-terms {
    padding: 3.2mm 3.5mm;
    color: #29364a;
    font-size: 7.6px;
    line-height: 1.18;
  }

  .print-term-group {
    margin: 0 0 1.4mm;
  }

  .print-term-group:last-child {
    margin-bottom: 0;
  }

  .print-term-group h4 {
    margin: 0 0 0.6mm;
    padding-bottom: 0.45mm;
    border-bottom: 0.5px solid #d9e0ea;
    color: #B12423;
    font-size: 7.65px;
    font-weight: 900;
    line-height: 1.16;
  }

  .print-term-line {
    margin: 0 0 0.35mm;
    overflow-wrap: anywhere;
  }

  .print-term-line:last-child {
    margin-bottom: 0;
  }
}

.monthly-target-panel {
  margin-bottom: 16px;
}

.target-table-wrap {
  overflow-x: auto;
  border: 1px solid #dbe3ed;
  border-radius: 8px;
}

.target-month-table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
  background: #fff;
}

.target-month-table th,
.target-month-table td {
  padding: 10px 12px;
  border-right: 1px solid #e0e7f0;
  border-bottom: 1px solid #e0e7f0;
  text-align: right;
  font-size: 12px;
  white-space: nowrap;
}

.target-month-table thead th {
  background: #edf3f9;
  color: #324760;
  font-size: 11px;
  font-weight: 900;
}

.target-month-table th:first-child,
.target-month-table tbody th {
  min-width: 150px;
  background: #f8fafc;
  color: #1d2e45;
  text-align: left;
  font-weight: 900;
}

.target-month-table th:last-child,
.target-month-table td:last-child {
  border-right: 0;
}

.target-month-table tbody tr:last-child th,
.target-month-table tbody tr:last-child td {
  border-bottom: 0;
}

.report-target-month-input {
  width: 118px;
  min-height: 34px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}

.target-month-value,
.target-month-total {
  color: #344861;
  font-weight: 800;
}

.target-month-total {
  background: #f5f8fc;
  color: #0C0B3A;
  font-weight: 900;
}

.target-month-table thead th small,
.target-month-total small,
.target-month-total em,
.target-month-cell small,
.target-month-cell em,
.target-readonly small {
  display: block;
  margin-top: 4px;
  color: #77869a;
  font-size: 9px;
  font-style: normal;
  font-weight: 700;
  line-height: 1.25;
}

.target-month-cell em,
.target-month-total em {
  color: #0f8a5f;
}

.target-month-cell {
  min-width: 118px;
}

.target-month-cell .report-target-month-input {
  display: block;
  margin-left: auto;
}

.group-summary-panel {
  margin-bottom: 16px;
}

.group-year-summary {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid #e4eaf2;
  color: #63748a;
  font-size: 10px;
  font-weight: 700;
}

#reportsView .group-performance-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.group-salespeople {
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid #e4eaf2;
}

.group-salespeople > span {
  display: block;
  margin-bottom: 6px;
  color: #63748a;
  font-size: 10px;
  font-weight: 900;
}

.group-salespeople > div {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.group-salespeople > div > span {
  padding: 4px 7px;
  border: 1px solid #dbe4ee;
  border-radius: 5px;
  background: #fff;
  color: #52657d;
  font-size: 10px;
  font-weight: 700;
}

.group-salespeople b {
  color: #1d2e45;
  font-weight: 900;
}

.cross-analysis-panel {
  margin-bottom: 16px;
}

.cross-analysis-head {
  align-items: flex-end;
}

.cross-analysis-head .dashboard-panel-note {
  margin-bottom: 0;
}

.cross-analysis-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 8px;
  min-width: min(430px, 100%);
}

.cross-analysis-controls label {
  min-width: 0;
}

.cross-analysis-controls select {
  min-height: 36px;
  padding: 7px 9px;
  font-size: 12px;
  font-weight: 800;
}

.cross-analysis-results {
  margin-top: 18px;
}

.cross-analysis-summary {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
}

.cross-analysis-summary strong {
  margin-left: auto;
  color: #0f8a5f;
  font-size: 18px;
}

.cross-analysis-summary small {
  color: #64748b;
  font-size: 10px;
  font-weight: 800;
}

.cross-analysis-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 28px;
  margin-top: 14px;
}

.cross-analysis-row {
  min-width: 0;
}

.cross-analysis-row-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #253a55;
  font-size: 12px;
  font-weight: 900;
}

.cross-analysis-row-head strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cross-analysis-row-head span {
  color: #0f8a5f;
  white-space: nowrap;
}

.cross-analysis-track {
  height: 8px;
  margin: 8px 0 5px;
  overflow: hidden;
  border-radius: 99px;
  background: #e8eef5;
}

.cross-analysis-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #15328A;
}

.cross-analysis-row small {
  color: #77869a;
  font-size: 10px;
  font-weight: 700;
}

@media (max-width: 900px) {
  #reportsView .group-performance-list,
  .cross-analysis-list {
    grid-template-columns: 1fr;
  }

  .cross-analysis-head {
    align-items: stretch;
    flex-direction: column;
  }

  .cross-analysis-controls {
    min-width: 0;
  }
}

@media (max-width: 560px) {
  .cross-analysis-controls {
    grid-template-columns: 1fr;
  }
}

/* Report dashboard V26: summary-first layout and a single cross-data chart surface. */
#reportsView .group-summary-top-panel {
  margin-bottom: 16px;
  border-top: 3px solid #0C0B3A;
}

#reportsView .group-summary-top-panel .dashboard-panel-note {
  margin-bottom: 16px;
}

#reportsView .group-kpi-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

#reportsView .summary-kpi-card {
  position: relative;
  min-height: 250px;
  padding: 16px;
  overflow: hidden;
  border: 1px solid #d9e3ee;
  border-top: 4px solid #8797aa;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 9px 22px rgba(22, 43, 70, 0.06);
}

#reportsView .summary-kpi-card::after {
  position: absolute;
  right: -28px;
  bottom: -28px;
  width: 112px;
  height: 112px;
  border-radius: 18px;
  background: #f4f7fb;
  content: "";
  transform: rotate(24deg);
  pointer-events: none;
}

#reportsView .summary-kpi-card:not(.summary-total) { border-top-color: #15328A; }
#reportsView .summary-total { border-top-color: #B12423; }
#reportsView .summary-kpi-card:not(.summary-total)::after { background: #edf4ff; }
#reportsView .summary-total::after { background: #fff0f1; }

#reportsView .summary-kpi-card > * {
  position: relative;
  z-index: 1;
}

#reportsView .summary-kpi-card .group-performance-head {
  align-items: flex-start;
  min-height: 62px;
}

#reportsView .summary-kpi-card .group-performance-head > div {
  min-width: 0;
}

#reportsView .summary-kpi-label {
  display: block;
  margin-bottom: 6px;
  color: #61748c;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#reportsView .summary-kpi-card .group-performance-head strong {
  display: block;
  color: #0C0B3A;
  font-size: 23px;
  line-height: 1.15;
}

#reportsView .summary-kpi-card .group-performance-head small {
  margin-top: 7px;
  color: #74859a;
  font-size: 10px;
}

#reportsView .summary-kpi-mark {
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #d5e0ec;
  border-radius: 8px;
  background: #f6f9fc;
  color: #253b56;
  font-size: 13px;
  font-weight: 950;
}

#reportsView .summary-kpi-card:not(.summary-total) .summary-kpi-mark { color: #15328A; background: #edf4ff; border-color: #c8dcff; }
#reportsView .summary-total .summary-kpi-mark { color: #B12423; background: #fff0f1; border-color: #f3c4c7; }

#reportsView .summary-kpi-card .performance-track {
  height: 9px;
  margin: 15px 0 14px;
  background: #edf1f6;
}

#reportsView .summary-kpi-card:not(.summary-total) .performance-track span { background: #15328A; }
#reportsView .summary-total .performance-track span { background: #B12423; }

#reportsView .summary-kpi-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 11px 0;
  border-top: 1px solid #e5ebf2;
  border-bottom: 1px solid #e5ebf2;
}

#reportsView .summary-kpi-metrics > div {
  min-width: 0;
}

#reportsView .summary-kpi-metrics span,
#reportsView .summary-kpi-metrics strong {
  display: block;
}

#reportsView .summary-kpi-metrics span {
  margin-bottom: 4px;
  color: #7a8b9e;
  font-size: 9px;
  font-weight: 800;
}

#reportsView .summary-kpi-metrics strong {
  overflow: hidden;
  color: #263b54;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#reportsView .summary-kpi-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  color: #687b91;
  font-size: 9px;
  font-weight: 800;
}

#reportsView .summary-kpi-footer span:last-child {
  color: #B12423;
  text-align: right;
  white-space: nowrap;
}

#reportsView .summary-kpi-card:not(.summary-total) .summary-kpi-footer span:last-child { color: #15328A; }

#reportsView .summary-kpi-card .group-salespeople {
  margin-top: 12px;
  padding-top: 10px;
}

#reportsView .summary-kpi-card .group-salespeople > span {
  margin-bottom: 7px;
  color: #52677f;
  font-size: 10px;
}

#reportsView .summary-kpi-card .group-salespeople > div {
  max-height: 43px;
  overflow: hidden;
}

#reportsView .summary-kpi-card .group-salespeople > div > span {
  padding: 4px 6px;
  border-radius: 5px;
  font-size: 9px;
}

#reportsView > .metric-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
}

#reportsView .cross-analysis-panel {
  border-top: 3px solid #15328A;
  background: #fbfdff;
}

#reportsView .cross-analysis-results {
  display: grid;
  grid-template-columns: minmax(210px, 0.42fr) minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
}

#reportsView .cross-analysis-summary {
  display: flex;
  min-height: 212px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  padding: 18px;
  border: 1px solid #d8e4f1;
  border-radius: 9px;
  background: #f3f7fc;
}

#reportsView .cross-summary-kicker {
  color: #66809f;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

#reportsView .cross-analysis-summary strong {
  margin: 5px 0 0;
  color: #0C0B3A;
  font-size: 24px;
  line-height: 1.15;
}

#reportsView .cross-analysis-summary small {
  color: #61748c;
  font-size: 10px;
  font-weight: 900;
}

#reportsView .cross-analysis-summary p {
  margin: 12px 0 0;
  color: #708298;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.5;
}

#reportsView .cross-chart-area {
  min-width: 0;
  padding: 2px 0;
}

#reportsView .cross-chart-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: #253b56;
  font-size: 12px;
}

#reportsView .cross-chart-heading span {
  color: #7b8ba0;
  font-size: 10px;
  font-weight: 800;
}

#reportsView .cross-analysis-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 0;
}

#reportsView .cross-analysis-row-head {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: #253b56;
}

#reportsView .cross-chart-rank {
  color: #91a0b2;
  font-size: 10px;
  font-weight: 900;
}

#reportsView .cross-analysis-row-head strong {
  min-width: 0;
  font-size: 12px;
}

#reportsView .cross-analysis-row-head em {
  color: #0f8a5f;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
  white-space: nowrap;
}

#reportsView .cross-analysis-track {
  height: 10px;
  margin: 7px 0 5px 34px;
  border-radius: 4px;
  background: #e4ebf4;
}

#reportsView .cross-analysis-track span {
  border-radius: 4px;
  background: #15328A;
}

#reportsView .cross-analysis-row small {
  display: block;
  margin-left: 34px;
  color: #7b8ba0;
  font-size: 9px;
}

@media (max-width: 1100px) {
  #reportsView .group-kpi-list,
  #reportsView > .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  #reportsView .cross-analysis-results {
    grid-template-columns: 1fr;
  }

  #reportsView .cross-analysis-summary {
    min-height: 0;
  }
}

@media (max-width: 640px) {
  #reportsView .group-kpi-list,
  #reportsView > .metric-grid {
    grid-template-columns: 1fr;
  }

  #reportsView .summary-kpi-card {
    min-height: 0;
  }

  #reportsView .summary-kpi-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  #reportsView .summary-kpi-footer span:last-child {
    text-align: left;
  }
}

/* Report dashboard V28: keep the group name visible in the Target table. */
#reportsView .target-month-table .target-group-name {
  min-width: 158px;
  vertical-align: top;
}

#reportsView .target-group-name strong,
#reportsView .target-group-name small {
  display: block;
}

#reportsView .target-group-name strong {
  color: #0C0B3A;
  font-size: 13px;
  font-weight: 950;
}

#reportsView .target-group-name small {
  margin-top: 4px;
  color: #7b8ba0;
  font-size: 9px;
  font-weight: 800;
}

#reportsView .report-closed-date {
  white-space: nowrap;
}

/* Report dashboard V29: make each summary metric a distinct scannable tile. */
#reportsView .summary-kpi-card .group-performance-head {
  min-height: 48px;
  margin-bottom: 13px;
}

#reportsView .summary-kpi-card .group-performance-head small {
  margin-top: 3px;
}

#reportsView .summary-kpi-metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
  border: 0;
}

#reportsView .summary-kpi-metrics > div {
  min-height: 64px;
  padding: 10px 11px;
  border: 1px solid #dfe7f0;
  border-radius: 7px;
  background: #f8fafc;
}

#reportsView .summary-kpi-metrics > div span {
  margin-bottom: 7px;
  color: #6d8097;
  font-size: 9px;
  font-weight: 900;
}

#reportsView .summary-kpi-metrics > div strong {
  overflow: hidden;
  color: #1c304a;
  font-size: 13px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#reportsView .summary-kpi-metrics .summary-metric-sales {
  border-color: #b9e6d1;
  background: #effaf4;
}

#reportsView .summary-kpi-metrics .summary-metric-sales strong {
  color: #0f8a5f;
}

#reportsView .summary-kpi-metrics .summary-metric-target {
  border-color: #c9dcfa;
  background: #f2f7ff;
}

#reportsView .summary-kpi-metrics .summary-metric-target strong {
  color: #15328A;
}

#reportsView .summary-kpi-metrics .summary-metric-gap strong.negative-gap {
  color: #B12423;
}

#reportsView .summary-kpi-metrics .summary-metric-gap strong.positive-gap {
  color: #0f8a5f;
}

#reportsView .summary-progress-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 13px;
  color: #75879b;
  font-size: 9px;
  font-weight: 800;
}

#reportsView .summary-progress-label b {
  color: #253b56;
  font-size: 10px;
}

#reportsView .summary-kpi-card .performance-track {
  margin: 6px 0 0;
}

@media (max-width: 420px) {
  #reportsView .summary-kpi-metrics > div {
    min-height: 58px;
    padding: 8px;
  }

  #reportsView .summary-kpi-metrics > div strong {
    font-size: 12px;
  }
}

/* Report dashboard V30: make the product group column easy to scan. */
#reportsView .report-product-group-cell {
  color: #36516f;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

/* UI polish V33: tighten hierarchy and make the report a calm work surface. */
@media screen {
  :root {
    --bg: #f1f4f8;
    --surface: #ffffff;
    --surface-soft: #f7f9fc;
    --text: #0C0B3A;
    --muted: #6b7c91;
    --line: #dbe3ec;
    --shadow: 0 10px 30px rgba(28, 48, 74, 0.06);
  }

  body {
    background: #f1f4f8;
    color: #0C0B3A;
  }

  .app-shell {
    grid-template-columns: 248px minmax(0, 1fr);
  }

  .sidebar {
    background: #0C0B3A;
    border-right: 0;
    box-shadow: 12px 0 28px rgba(18, 36, 59, 0.12);
  }

  .sidebar-brand {
    margin: 2px 4px 30px;
  }

  .brand-mark {
    border-color: rgba(255, 255, 255, 0.18);
    background: #fff;
    box-shadow: 0 5px 16px rgba(0, 0, 0, 0.12);
  }

  .sidebar-brand strong {
    color: #fff;
    letter-spacing: 0.01em;
  }

  .sidebar-brand span,
  .sidebar-footer,
  .sidebar-footer small {
    color: #9fb0c5;
  }

  .side-nav {
    gap: 6px;
  }

  .nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid transparent;
    color: #c1ccda;
    font-size: 13px;
    transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
  }

  .nav-item:hover {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
    transform: translateX(2px);
  }

  .nav-item.active {
    border-color: rgba(255, 255, 255, 0.1);
    background: #B12423;
    color: #fff;
    box-shadow: 0 9px 18px rgba(177, 36, 35, 0.22);
  }

  .nav-icon {
    display: inline-grid;
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    place-items: center;
    border: 1px solid currentColor;
    border-radius: 7px;
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
  }

  .sidebar-footer {
    border-top-color: rgba(255, 255, 255, 0.13);
  }

  .sidebar-footer strong {
    color: #fff;
  }

  .sidebar-footer button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.14);
  }

  .content {
    max-width: 1800px;
    width: 100%;
    margin: 0 auto;
    padding: 22px 28px 40px;
  }

  .topbar {
    min-height: 72px;
    margin-bottom: 20px;
    border-color: #d9e2ec;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 8px 24px rgba(28, 48, 74, 0.05);
  }

  .topbar p {
    color: #7b8da2;
    font-size: 11px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
  }

  .topbar h1 {
    color: #0C0B3A;
    font-size: 24px;
  }

  .topbar-actions button,
  .report-filters button,
  .dashboard-actions button {
    min-height: 38px;
    border-radius: 8px;
    box-shadow: none;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
  }

  .topbar-actions button:hover,
  .report-filters button:hover,
  .dashboard-actions button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(20, 42, 69, 0.12);
  }

  #reportsView {
    max-width: 1680px;
    margin: 0 auto;
  }

  #reportsView .report-filters {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(180px, 1.25fr) repeat(3, minmax(135px, 0.8fr)) auto auto;
    align-items: end;
    gap: 12px;
    margin-bottom: 16px;
    padding: 16px;
    border-color: #d8e2ed;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(28, 48, 74, 0.045);
  }

  .report-filters-head {
    display: flex;
    grid-column: 1 / -1;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding-bottom: 3px;
  }

  .report-filters-head h2 {
    margin: 3px 0 0;
    color: #0C0B3A;
    font-size: 16px;
    line-height: 1.25;
  }

  .report-eyebrow,
  .dashboard-kicker {
    color: #7a8ca1;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.1em;
  }

  .report-filter-note {
    color: #8998aa;
    font-size: 11px;
    font-weight: 700;
  }

  #reportsView .report-filters label {
    gap: 5px;
    color: #62758b;
    font-size: 11px;
  }

  #reportsView .report-filters input,
  #reportsView .report-filters select {
    min-height: 38px;
    border-color: #d8e2ed;
    border-radius: 8px;
    background: #fbfcfe;
    color: #203650;
    font-size: 12px;
    font-weight: 700;
  }

  #reportsView .report-filters button {
    padding: 9px 12px;
    background: #0C0B3A;
    color: #fff;
    font-size: 11px;
    white-space: nowrap;
  }

  #reportsView .report-filters .so-export-button {
    background: #0f8a5f;
  }

  #reportsView .sales-dashboard-hero {
    min-height: 124px;
    margin-bottom: 16px;
    padding: 22px 24px;
    border: 0;
    border-radius: 12px;
    background: #0C0B3A;
    box-shadow: 0 13px 26px rgba(23, 43, 70, 0.14);
  }

  #reportsView .sales-dashboard-hero h2 {
    margin: 5px 0 4px;
    font-size: 24px;
    letter-spacing: 0;
  }

  #reportsView .sales-dashboard-hero p {
    color: #b6c7d9;
    font-size: 11px;
  }

  #reportsView .dashboard-actions {
    gap: 7px;
  }

  #reportsView .dashboard-actions button {
    border-color: rgba(255, 255, 255, 0.17);
    background: rgba(255, 255, 255, 0.08);
    font-size: 11px;
  }

  #reportsView .dashboard-actions .dashboard-export-button {
    background: #15328A;
  }

  #reportsView .dashboard-actions .dashboard-target-button {
    background: #0f8a5f;
  }

  #reportsView .dashboard-panel,
  #reportsView .data-panel {
    border-color: #d8e2ed;
    border-radius: 12px;
    box-shadow: 0 8px 22px rgba(28, 48, 74, 0.045);
  }

  #reportsView .group-summary-top-panel {
    padding: 20px;
    border-top: 3px solid #0C0B3A;
  }

  #reportsView .dashboard-panel h3 {
    color: #0C0B3A;
    font-size: 17px;
  }

  #reportsView .dashboard-panel-note {
    max-width: 760px;
    margin: 7px 0 16px;
    color: #75869a;
    font-size: 11px;
  }

  #reportsView .dashboard-period-badge {
    padding: 6px 10px;
    border-color: #d5e1ed;
    border-radius: 7px;
    background: #f7fafd;
    color: #49627e;
  }

  #reportsView .group-kpi-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }

  #reportsView .summary-kpi-card {
    min-height: 0;
    padding: 17px;
    border-radius: 10px;
    box-shadow: 0 7px 17px rgba(28, 48, 74, 0.05);
  }

  #reportsView .summary-kpi-card::after {
    width: 96px;
    height: 96px;
    border-radius: 14px;
  }

  #reportsView .summary-kpi-card .group-performance-head {
    min-height: 58px;
  }

  #reportsView .summary-kpi-label {
    margin-bottom: 5px;
    font-size: 10px;
  }

  #reportsView .summary-kpi-card .group-performance-head small {
    margin-top: 6px;
    font-size: 10px;
  }

  #reportsView .summary-kpi-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 10px 0;
  }

  #reportsView .summary-kpi-metrics > div {
    min-height: 58px;
    padding: 8px 7px;
    border: 1px solid #e4eaf1;
    border-radius: 7px;
    background: #fafbfd;
  }

  #reportsView .summary-kpi-metrics span {
    min-height: 28px;
    margin-bottom: 3px;
    font-size: 9px;
    line-height: 1.3;
  }

  #reportsView .summary-kpi-metrics strong {
    font-size: 12px;
  }

  #reportsView .summary-kpi-card .group-salespeople {
    margin-top: 10px;
  }

  #reportsView > .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 16px 0;
  }

  #reportsView .metric-card {
    min-height: 112px;
    padding: 16px;
    border: 1px solid #dbe4ee;
    border-top-width: 3px;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 7px 17px rgba(28, 48, 74, 0.045);
  }

  #reportsView .metric-card span {
    color: #718399;
    font-size: 10px;
    font-weight: 900;
  }

  #reportsView .metric-card strong {
    margin-top: 8px;
    color: #0C0B3A;
    font-size: 21px;
  }

  #reportsView .metric-card small {
    margin-top: 5px;
    color: #7f8ea1;
    font-size: 10px;
  }

  #reportsView .monthly-target-panel,
  #reportsView .cross-analysis-panel {
    margin-bottom: 16px;
  }

  #reportsView .target-table-wrap {
    border: 1px solid #dbe4ee;
    border-radius: 9px;
    background: #fbfcfe;
  }

  #reportsView .target-month-table {
    border: 0;
  }

  #reportsView .cross-analysis-panel {
    border-top: 3px solid #15328A;
    background: #fff;
  }

  #reportsView .cross-analysis-controls select {
    min-height: 36px;
    border-color: #d5e1ed;
    border-radius: 8px;
    background: #fbfcfe;
  }

  #reportsView > .data-panel:last-child {
    overflow: hidden;
    padding: 0;
  }

  #reportsView > .data-panel:last-child h2 {
    padding: 18px 20px 14px;
    border-bottom: 1px solid #e3eaf2;
    color: #0C0B3A;
    font-size: 16px;
  }

  #reportsView .report-table {
    min-width: 1500px;
    margin: 0;
    border: 0;
  }

  #reportsView .report-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    border-color: #d5e0eb;
    background: #f3f7fb;
    color: #4e657f;
    font-size: 10px;
    letter-spacing: 0;
  }

  #reportsView .report-table tbody td {
    border-color: #e1e8f0;
    color: #304862;
    font-size: 11px;
  }

  #reportsView .report-table tbody tr.report-group-start td {
    border-top-color: #c8d6e5;
  }

  #reportsView .report-table tbody tr:hover td {
    background: #f8fbff;
  }

  #reportsView .report-table select {
    min-height: 32px;
    padding: 6px 8px;
    border-radius: 7px;
    font-size: 10px;
  }
}

@media screen and (max-width: 1180px) {
  #reportsView .report-filters {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  #reportsView .report-filters-head {
    grid-column: 1 / -1;
  }

  #reportsView .report-filters button {
    width: 100%;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    padding: 12px;
  }

  .sidebar-brand {
    margin: 0 4px 12px;
  }

  .side-nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .nav-item {
    justify-content: center;
    padding: 9px 6px;
    font-size: 11px;
  }

  .sidebar-footer {
    display: none;
  }

  .content {
    padding: 16px;
  }

  #reportsView .group-kpi-list,
  #reportsView > .metric-grid {
    grid-template-columns: 1fr;
  }

  #reportsView .report-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #reportsView .report-filters-head {
    align-items: flex-start;
    flex-direction: column;
  }

  #reportsView .sales-dashboard-hero {
    align-items: stretch;
    flex-direction: column;
  }

  #reportsView .dashboard-actions {
    justify-content: flex-start;
  }
}

@media screen and (max-width: 520px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions button {
    flex: 1;
  }

  #reportsView .report-filters {
    grid-template-columns: 1fr;
  }

  #reportsView .report-filters-head,
  #reportsView .report-filters button {
    grid-column: 1;
  }

  #reportsView .summary-kpi-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #reportsView .sales-dashboard-hero h2 {
    font-size: 20px;
  }

  #reportsView .dashboard-actions button {
    flex: 1 1 120px;
  }
}

/* UPVC Roof brand system */
@media screen {
  :root {
    --bg: #F4F4F5;
    --surface: #ffffff;
    --surface-soft: #F4F4F5;
    --text: #0C0B3A;
    --muted: #626887;
    --line: #d9deef;
    --line-strong: #0C0B3A;
    --brand: #B12423;
    --brand-dark: #8b1c1b;
    --brand-soft: #faeeee;
    --ink: #0C0B3A;
    --blue: #15328A;
    --accent: #809EDD;
    --shadow: 0 16px 42px rgba(12, 11, 58, 0.09);
  }

  body {
    background: linear-gradient(180deg, #ffffff 0, #F4F4F5 280px, var(--bg) 100%);
    color: var(--text);
  }

  .login-screen,
  .setup-screen {
    background:
      linear-gradient(135deg, rgba(177, 36, 35, 0.11), transparent 36%),
      linear-gradient(315deg, rgba(128, 158, 221, 0.2), transparent 42%),
      #F4F4F5;
  }

  .login-card,
  .setup-panel {
    border-color: rgba(21, 50, 138, 0.2);
    border-top: 5px solid var(--brand);
  }

  .sidebar {
    background: #0C0B3A;
    box-shadow: 12px 0 30px rgba(12, 11, 58, 0.18);
  }

  .sidebar-brand {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .brand-mark {
    width: 196px;
    height: 105px;
    padding: 5px;
    border-color: rgba(128, 158, 221, 0.42);
    background: #ffffff;
  }

  .brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  .nav-item.active {
    background: #B12423;
    box-shadow: 0 9px 20px rgba(177, 36, 35, 0.28);
  }

  .nav-item:hover {
    border-color: rgba(128, 158, 221, 0.38);
  }

  input:focus,
  select:focus,
  textarea:focus {
    border-color: #809EDD;
    box-shadow: 0 0 0 3px rgba(128, 158, 221, 0.25);
  }

  .text-button {
    color: #15328A;
  }
}

@media screen and (max-width: 860px) {
  .sidebar-brand {
    align-items: center;
    flex-direction: row;
  }

  .brand-mark {
    width: 132px;
    height: 70px;
  }

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

@media screen and (max-width: 520px) {
  .sidebar-brand > div:last-child {
    display: none;
  }

  .brand-mark {
    width: 116px;
    height: 62px;
  }
}

/* Agent stock sales V39 */
@media screen {
  .agent-stock-view {
    max-width: 1720px;
  }

  .agent-stock-intro {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 18px;
    padding: 24px 26px;
    border-left: 5px solid #B12423;
    background: #0C0B3A;
    color: #fff;
    box-shadow: 0 14px 28px rgba(18, 36, 59, 0.14);
  }

  .agent-stock-intro h2,
  .agent-stock-form h3,
  .agent-stock-history h3 {
    margin: 0;
    letter-spacing: 0;
  }

  .agent-stock-intro h2 {
    margin-top: 5px;
    font-size: 25px;
  }

  .agent-stock-intro p {
    max-width: 850px;
    margin: 7px 0 0;
    color: #c8d5e4;
    font-size: 12px;
    line-height: 1.55;
  }

  .agent-stock-eyebrow,
  .section-kicker {
    color: #7fa6d8;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0;
  }

  .agent-stock-intro button {
    flex: 0 0 auto;
    min-height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
  }

  .agent-stock-form,
  .agent-stock-history {
    margin-bottom: 18px;
    border: 1px solid #dce5ef;
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(18, 36, 59, 0.06);
  }

  .agent-stock-form-head,
  .agent-stock-lines-head,
  .agent-stock-history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
  }

  .agent-stock-form h3,
  .agent-stock-history h3 {
    margin-top: 3px;
    color: #0C0B3A;
    font-size: 18px;
  }

  .agent-stock-edit-state,
  #agentStockCount {
    color: #60748b;
    font-size: 11px;
    font-weight: 900;
  }

  .agent-stock-edit-state.is-editing {
    color: #b45309;
  }

  .agent-stock-fields {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
  }

  .agent-stock-fields label {
    display: grid;
    gap: 6px;
    min-width: 0;
  }

  .agent-stock-fields label > span {
    color: #425a74;
    font-size: 11px;
    font-weight: 900;
  }

  .agent-stock-fields input,
  .agent-stock-fields select,
  .agent-stock-history-filters input {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    border: 1px solid #d8e2ec;
    border-radius: 7px;
    background: #fff;
    color: #1f3650;
    font-size: 12px;
  }

  .agent-stock-notes {
    grid-column: span 2;
  }

  .agent-stock-party-meta {
    display: flex;
    align-items: center;
    gap: 18px;
    min-height: 42px;
    margin-top: 12px;
    padding: 9px 12px;
    border-left: 3px solid #15328A;
    background: #f4f7fb;
    color: #63778e;
    font-size: 11px;
  }

  .agent-stock-party-meta strong {
    color: #1e3855;
    font-size: 12px;
  }

  .agent-stock-lines-head {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid #e2e9f1;
  }

  .agent-stock-lines-head button {
    min-height: 36px;
  }

  .agent-stock-lines-scroll,
  .agent-stock-history-scroll {
    width: 100%;
    overflow: auto;
    border: 1px solid #dce5ef;
  }

  .agent-stock-lines-table {
    width: 100%;
    min-width: 1550px;
    border-collapse: collapse;
    table-layout: fixed;
  }

  .agent-stock-lines-table th,
  .agent-stock-lines-table td {
    padding: 8px;
    border-bottom: 1px solid #e1e8f0;
    vertical-align: middle;
    font-size: 11px;
  }

  .agent-stock-lines-table th {
    background: #edf2f7;
    color: #425a74;
    font-size: 10px;
    font-weight: 900;
    text-align: left;
  }

  .agent-stock-lines-table th:nth-child(1) { width: 125px; }
  .agent-stock-lines-table th:nth-child(2) { width: 240px; }
  .agent-stock-lines-table th:nth-child(3) { width: 125px; }
  .agent-stock-lines-table th:nth-child(4) { width: 82px; }
  .agent-stock-lines-table th:nth-child(5) { width: 82px; }
  .agent-stock-lines-table th:nth-child(6) { width: 115px; }
  .agent-stock-lines-table th:nth-child(7) { width: 82px; }
  .agent-stock-lines-table th:nth-child(8) { width: 110px; }
  .agent-stock-lines-table th:nth-child(9) { width: 125px; }
  .agent-stock-lines-table th:nth-child(10) { width: 82px; }
  .agent-stock-lines-table th:nth-child(11) { width: 46px; }

  .agent-stock-lines-table input {
    width: 100%;
    min-width: 0;
    min-height: 35px;
    padding: 6px 7px;
    border: 1px solid #d8e2ec;
    border-radius: 6px;
    background: #fff;
    font-size: 11px;
  }

  .agent-stock-lines-table input:focus {
    border-color: #15328A;
    outline: 2px solid rgba(37, 99, 235, 0.14);
  }

  .agent-stock-cost-input {
    color: #7c3f00;
    font-weight: 800;
  }

  .agent-stock-group-cell {
    color: #50677f;
    font-weight: 800;
  }

  .agent-stock-line-total,
  .agent-stock-line-margin,
  .agent-stock-history-total {
    color: #0f7a53;
    font-weight: 900;
    white-space: nowrap;
  }

  .agent-stock-line-margin.negative,
  .negative-margin {
    color: #c81e1e !important;
    font-weight: 900;
  }

  .agent-stock-remove-line {
    width: 32px;
    height: 32px;
  }

  .agent-stock-form-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(540px, 1.2fr) auto;
    align-items: end;
    gap: 16px;
    margin-top: 16px;
  }

  .agent-stock-form-footer .danger-alert {
    margin: 0;
  }

  .agent-stock-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(110px, 1fr));
    border: 1px solid #dce5ef;
  }

  .agent-stock-summary > div {
    min-width: 0;
    padding: 10px 12px;
    border-right: 1px solid #dce5ef;
    background: #f7f9fc;
  }

  .agent-stock-summary > div:last-child {
    border-right: 0;
  }

  .agent-stock-summary span,
  .agent-stock-summary strong {
    display: block;
  }

  .agent-stock-summary span {
    color: #6b7e93;
    font-size: 9px;
    font-weight: 900;
  }

  .agent-stock-summary strong {
    margin-top: 5px;
    color: #1e3855;
    font-size: 15px;
  }

  .agent-stock-summary .agent-stock-total {
    background: #eef9f3;
  }

  .agent-stock-summary .agent-stock-total strong {
    color: #0f7a53;
  }

  #saveAgentStockBtn {
    min-height: 42px;
    white-space: nowrap;
  }

  .agent-stock-history-filters {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) 190px;
    gap: 10px;
    margin-bottom: 12px;
  }

  .agent-stock-history-table {
    min-width: 1250px;
  }

  .agent-stock-history-table th {
    position: sticky;
    top: 0;
    z-index: 1;
  }

  .agent-stock-row-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
  }

  .agent-stock-row-actions button {
    min-height: 32px;
    padding: 6px 9px;
  }
}

@media screen and (max-width: 1180px) {
  .agent-stock-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .agent-stock-form-footer {
    grid-template-columns: 1fr;
  }

  #saveAgentStockBtn {
    justify-self: end;
  }
}

@media screen and (max-width: 680px) {
  .agent-stock-intro {
    align-items: flex-start;
    flex-direction: column;
    padding: 20px;
  }

  .agent-stock-intro h2 {
    font-size: 21px;
  }

  .agent-stock-fields,
  .agent-stock-history-filters {
    grid-template-columns: 1fr;
  }

  .agent-stock-notes {
    grid-column: auto;
  }

  .agent-stock-party-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .agent-stock-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .agent-stock-summary > div:nth-child(2) {
    border-right: 0;
  }

  .agent-stock-summary > div:nth-child(-n+2) {
    border-bottom: 1px solid #dce5ef;
  }

  #saveAgentStockBtn {
    width: 100%;
  }
}

/* Report cards V34: keep all figures visible and promote salesperson performance. */
@media screen {
  #reportsView .summary-kpi-card {
    min-height: 360px;
  }

  #reportsView .summary-kpi-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  #reportsView .summary-kpi-metrics > div {
    min-height: 64px;
    padding: 9px 10px;
  }

  #reportsView .summary-kpi-metrics span {
    min-height: 0;
    margin-bottom: 6px;
    font-size: 9px;
  }

  #reportsView .summary-kpi-metrics strong {
    overflow: visible;
    color: #1c304a;
    font-size: 14px;
    line-height: 1.2;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  #reportsView .summary-kpi-metrics .summary-metric-sales strong {
    color: #0f8a5f;
  }

  #reportsView .summary-kpi-metrics .summary-metric-target strong {
    color: #15328A;
  }

  #reportsView .summary-kpi-metrics .summary-metric-opportunity strong {
    color: #b7791f;
  }

  #reportsView .summary-kpi-card .group-salespeople {
    margin-top: 13px;
    padding-top: 12px;
    border-top: 1px solid #dfe7ef;
  }

  #reportsView .group-salespeople-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
  }

  #reportsView .group-salespeople-head > span {
    margin: 0;
    color: #304862;
    font-size: 11px;
    font-weight: 900;
  }

  #reportsView .group-salespeople-head small {
    color: #8393a6;
    font-size: 9px;
    font-weight: 800;
  }

  #reportsView .summary-kpi-card .group-salespeople > div:last-child {
    display: grid;
    max-height: none;
    gap: 6px;
    overflow: visible;
  }

  #reportsView .summary-kpi-card .group-salespeople > div:last-child > span {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr) auto;
    align-items: center;
    gap: 7px;
    min-height: 30px;
    padding: 5px 7px;
    border: 1px solid #e0e8f0;
    border-radius: 7px;
    background: #fbfcfe;
    color: #536981;
    font-size: 10px;
    font-weight: 700;
  }

  #reportsView .summary-kpi-card .group-salespeople > div:last-child > span > i {
    display: grid;
    width: 20px;
    height: 20px;
    place-items: center;
    border-radius: 6px;
    background: #eaf0f6;
    color: #536981;
    font-size: 9px;
    font-style: normal;
    font-weight: 900;
  }

  #reportsView .summary-kpi-card .group-salespeople > div:last-child > span > b {
    min-width: 0;
    overflow: hidden;
    color: #263e59;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #reportsView .summary-kpi-card .group-salespeople > div:last-child > span > em {
    color: #0f8a5f;
    font-size: 9px;
    font-style: normal;
    font-weight: 900;
    text-align: right;
    white-space: nowrap;
  }

  #reportsView .summary-total .group-salespeople > div:last-child > span > em {
    color: #B12423;
  }
}

@media screen and (max-width: 1180px) {
  #reportsView .summary-kpi-card {
    min-height: 380px;
  }

  #reportsView .summary-kpi-card .group-salespeople > div:last-child > span {
    grid-template-columns: 20px minmax(0, 1fr);
  }

  #reportsView .summary-kpi-card .group-salespeople > div:last-child > span > em {
    grid-column: 2;
    text-align: left;
  }
}

@media screen and (max-width: 520px) {
  #reportsView .summary-kpi-card {
    min-height: 0;
  }
}

/* Report detail V35: keep the wide table inside its own scroll surface. */
@media screen {
  #reportsView .report-detail-panel {
    min-width: 0;
    overflow: hidden;
    padding: 0;
  }

  #reportsView .report-detail-panel h2 {
    margin: 0;
    padding: 18px 20px 14px;
    border-bottom: 1px solid #e3eaf2;
  }

  #reportsView .report-table-scroll {
    width: 100%;
    max-width: 100%;
    max-height: min(620px, calc(100vh - 290px));
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-color: #9aabbd #edf2f7;
    scrollbar-width: thin;
  }

  #reportsView .report-table-scroll::-webkit-scrollbar {
    width: 10px;
    height: 10px;
  }

  #reportsView .report-table-scroll::-webkit-scrollbar-track {
    background: #edf2f7;
  }

  #reportsView .report-table-scroll::-webkit-scrollbar-thumb {
    border: 2px solid #edf2f7;
    border-radius: 99px;
    background: #9aabbd;
  }

  #reportsView .report-table-scroll:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.2);
    outline-offset: -3px;
  }

  #reportsView .report-detail-panel .report-table {
    min-width: 1500px;
    margin: 0;
  }
}

/* Report table V39: cost, gross margin, VAT totals and direct close-date editing. */
@media screen {
  #reportsView .report-detail-panel .report-table {
    width: 2860px;
    min-width: 2860px;
    table-layout: fixed;
  }

  #reportsView .report-detail-panel .report-table th:nth-child(1),
  #reportsView .report-detail-panel .report-table td:nth-child(1) { width: 110px; }
  #reportsView .report-detail-panel .report-table th:nth-child(2),
  #reportsView .report-detail-panel .report-table td:nth-child(2) { width: 180px; }
  #reportsView .report-detail-panel .report-table th:nth-child(3),
  #reportsView .report-detail-panel .report-table td:nth-child(3) { width: 110px; }
  #reportsView .report-detail-panel .report-table th:nth-child(4),
  #reportsView .report-detail-panel .report-table td:nth-child(4) { width: 130px; }
  #reportsView .report-detail-panel .report-table th:nth-child(5),
  #reportsView .report-detail-panel .report-table td:nth-child(5) { width: 170px; }
  #reportsView .report-detail-panel .report-table th:nth-child(6),
  #reportsView .report-detail-panel .report-table td:nth-child(6) { width: 125px; }
  #reportsView .report-detail-panel .report-table th:nth-child(7),
  #reportsView .report-detail-panel .report-table td:nth-child(7) { width: 230px; }
  #reportsView .report-detail-panel .report-table th:nth-child(8),
  #reportsView .report-detail-panel .report-table td:nth-child(8) { width: 150px; }
  #reportsView .report-detail-panel .report-table th:nth-child(9),
  #reportsView .report-detail-panel .report-table td:nth-child(9) { width: 82px; }
  #reportsView .report-detail-panel .report-table th:nth-child(10),
  #reportsView .report-detail-panel .report-table td:nth-child(10) { width: 82px; }
  #reportsView .report-detail-panel .report-table th:nth-child(11),
  #reportsView .report-detail-panel .report-table td:nth-child(11) { width: 120px; }
  #reportsView .report-detail-panel .report-table th:nth-child(12),
  #reportsView .report-detail-panel .report-table td:nth-child(12) { width: 110px; }
  #reportsView .report-detail-panel .report-table th:nth-child(13),
  #reportsView .report-detail-panel .report-table td:nth-child(13) { width: 100px; }
  #reportsView .report-detail-panel .report-table th:nth-child(14),
  #reportsView .report-detail-panel .report-table td:nth-child(14) { width: 150px; }
  #reportsView .report-detail-panel .report-table th:nth-child(15),
  #reportsView .report-detail-panel .report-table td:nth-child(15) { width: 120px; }
  #reportsView .report-detail-panel .report-table th:nth-child(16),
  #reportsView .report-detail-panel .report-table td:nth-child(16) { width: 140px; }
  #reportsView .report-detail-panel .report-table th:nth-child(17),
  #reportsView .report-detail-panel .report-table td:nth-child(17) { width: 150px; }
  #reportsView .report-detail-panel .report-table th:nth-child(18),
  #reportsView .report-detail-panel .report-table td:nth-child(18) { width: 150px; }
  #reportsView .report-detail-panel .report-table th:nth-child(19),
  #reportsView .report-detail-panel .report-table td:nth-child(19) { width: 170px; }
  #reportsView .report-detail-panel .report-table th:nth-child(20),
  #reportsView .report-detail-panel .report-table td:nth-child(20) { width: 130px; }
  #reportsView .report-detail-panel .report-table th:nth-child(21),
  #reportsView .report-detail-panel .report-table td:nth-child(21) { width: 140px; }

  #reportsView .report-detail-panel .report-table th {
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  #reportsView .report-detail-panel .report-table td {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  #reportsView .report-detail-panel .report-table .report-status-select,
  #reportsView .report-detail-panel .report-table .report-delivery-select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding-right: 24px;
    font-size: 10px;
  }

  #reportsView .report-detail-panel .report-table .report-closed-date-input {
    width: 100%;
    min-width: 0;
    min-height: 34px;
    padding: 6px 7px;
    border: 1px solid #d8e2ec;
    border-radius: 7px;
    background: #fff;
    color: #243c59;
    font: inherit;
    font-size: 10px;
    font-weight: 800;
  }

  #reportsView .report-detail-panel .report-table .report-price-cell,
  #reportsView .report-detail-panel .report-table .report-cost-cell,
  #reportsView .report-detail-panel .report-table .report-margin-cell,
  #reportsView .report-detail-panel .report-table td:nth-child(20),
  #reportsView .report-detail-panel .report-table td:nth-child(21) {
    white-space: nowrap;
    text-align: right;
  }

  #reportsView .report-detail-panel .report-table .report-cost-cell {
    color: #7c3f00;
    font-weight: 800;
  }

  #reportsView .report-detail-panel .report-table .report-margin-cell {
    color: #0f7a53;
    font-weight: 900;
  }

  #reportsView .report-detail-panel .report-table .negative-margin {
    color: #c81e1e;
  }

  #reportsView .report-detail-panel .report-table .report-vat-total-cell {
    background: #f2fbf6;
    color: #0f7a53;
    font-weight: 900;
  }

  #reportsView .agent-stock-win-label {
    display: inline-block;
    color: #0f7a53;
    font-size: 10px;
    font-weight: 900;
  }
}

/* Dashboard redesign V36: executive-first hierarchy with clear sales actions. */
@media screen {
  #reportsView.report-dashboard-page {
    --dashboard-ink: #0C0B3A;
    --dashboard-blue: #15328A;
    --dashboard-green: #0f8a5f;
    --dashboard-red: #B12423;
    --dashboard-gold: #b7791f;
    --dashboard-line: #d8e2ec;
    max-width: 1760px;
  }

  #reportsView.report-dashboard-page::before {
    content: "";
    display: block;
    height: 4px;
    margin: 0 0 14px;
    border-radius: 99px;
    background: #B12423;
  }

  #reportsView .report-filters {
    position: sticky;
    top: 12px;
    z-index: 20;
    margin-bottom: 18px;
    border-radius: 13px;
    box-shadow: 0 12px 26px rgba(18, 36, 59, 0.08);
  }

  #reportsView .report-filters-head {
    padding-bottom: 5px;
  }

  #reportsView .report-filters-head h2 {
    font-size: 17px;
    letter-spacing: -0.01em;
  }

  #reportsView .report-filter-note {
    padding: 6px 10px;
    border: 1px solid #e0e8f0;
    border-radius: 99px;
    background: #f7fafd;
    color: #70839a;
  }

  #reportsView .sales-dashboard-hero {
    min-height: 166px;
    align-items: stretch;
    margin-bottom: 25px;
    padding: 28px 30px;
    border-left: 6px solid var(--dashboard-red);
    border-radius: 16px;
    background: var(--dashboard-ink);
    box-shadow: 0 18px 36px rgba(18, 36, 59, 0.18);
  }

  #reportsView .dashboard-hero-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  #reportsView .sales-dashboard-hero .dashboard-kicker {
    color: #8fb4e3;
    font-size: 10px;
  }

  #reportsView .sales-dashboard-hero h2 {
    max-width: 760px;
    margin: 7px 0 5px;
    color: #fff;
    font-size: 30px;
    font-weight: 900;
    line-height: 1.15;
  }

  #reportsView .sales-dashboard-hero p {
    color: #b8c9db;
    font-size: 12px;
  }

  #reportsView .dashboard-hero-actions {
    align-content: center;
    max-width: 470px;
  }

  #reportsView .dashboard-hero-actions button {
    min-height: 40px;
    padding: 9px 13px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    font-size: 11px;
  }

  #reportsView .dashboard-hero-actions .dashboard-export-button {
    background: #2f6fe8;
  }

  #reportsView .dashboard-hero-actions .dashboard-target-button {
    background: #0f8a5f;
  }

  #reportsView .group-summary-top-panel {
    margin-bottom: 22px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  #reportsView .group-summary-top-panel .dashboard-panel-head {
    align-items: flex-end;
    margin-bottom: 12px;
    padding: 0 2px;
  }

  #reportsView .group-summary-top-panel .dashboard-panel-note {
    margin: -4px 2px 15px;
    color: #718399;
  }

  #reportsView .group-summary-top-panel .dashboard-kicker-soft {
    color: #7187a0;
  }

  #reportsView .group-summary-top-panel h3 {
    font-size: 20px;
  }

  #reportsView .group-kpi-list {
    gap: 16px;
  }

  #reportsView .summary-kpi-card {
    display: flex;
    flex-direction: column;
    min-height: 405px;
    padding: 21px;
    border: 1px solid var(--dashboard-line);
    border-top: 0;
    border-left: 5px solid #8797aa;
    border-radius: 13px;
    box-shadow: 0 12px 24px rgba(18, 36, 59, 0.07);
    transition: transform 160ms ease, box-shadow 160ms ease;
  }

  #reportsView .summary-kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 18px 32px rgba(18, 36, 59, 0.12);
  }

  #reportsView .summary-kpi-card:not(.summary-total) {
    border-left-color: var(--dashboard-blue);
  }

  #reportsView .summary-total {
    border-left-color: var(--dashboard-red);
  }

  #reportsView .summary-kpi-card::after {
    right: -42px;
    bottom: -42px;
    width: 150px;
    height: 150px;
    border-radius: 24px;
    opacity: 0.72;
  }

  #reportsView .summary-kpi-card .group-performance-head {
    min-height: 70px;
  }

  #reportsView .summary-kpi-label {
    margin-bottom: 7px;
    color: #7a8da3;
    font-size: 10px;
    letter-spacing: 0.12em;
  }

  #reportsView .summary-kpi-card .group-performance-head small {
    color: #7e90a5;
    font-size: 10px;
  }

  #reportsView .summary-kpi-mark {
    width: 39px;
    height: 39px;
    border-radius: 10px;
    font-size: 14px;
  }

  #reportsView .summary-kpi-metrics {
    gap: 9px;
    padding: 13px 0;
    border-top-color: #e0e8f0;
    border-bottom-color: #e0e8f0;
  }

  #reportsView .summary-kpi-metrics > div {
    min-height: 70px;
    padding: 10px;
    border-radius: 9px;
  }

  #reportsView .summary-kpi-metrics span {
    color: #778ba2;
    font-size: 9px;
    font-weight: 900;
  }

  #reportsView .summary-kpi-metrics strong {
    font-size: 15px;
    font-weight: 900;
  }

  #reportsView .summary-progress-label {
    margin-top: 15px;
    color: #718399;
  }

  #reportsView .summary-progress-label b {
    font-size: 11px;
  }

  #reportsView .summary-kpi-card .performance-track {
    height: 10px;
    margin: 7px 0 0;
    background: #edf1f6;
  }

  #reportsView .summary-kpi-footer {
    margin-top: 12px;
    color: #718399;
    font-size: 10px;
  }

  #reportsView .summary-kpi-card .group-salespeople {
    margin-top: auto;
    padding-top: 15px;
  }

  #reportsView .group-salespeople-head > span {
    color: #1c3552;
    font-size: 12px;
  }

  #reportsView .group-salespeople-head small {
    color: #8193a8;
    font-size: 9px;
  }

  #reportsView .summary-kpi-card .group-salespeople > div:last-child > span {
    min-height: 32px;
    border-color: #e0e8f0;
    background: #f8fafc;
  }

  #reportsView > .metric-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 11px;
    margin: 0 0 22px;
  }

  #reportsView .metric-card {
    min-height: 126px;
    padding: 16px 15px;
    border-top-width: 4px;
    border-radius: 11px;
    box-shadow: 0 8px 18px rgba(18, 36, 59, 0.055);
  }

  #reportsView .metric-card strong {
    font-size: 20px;
  }

  #reportsView .metric-card small {
    line-height: 1.45;
  }

  #reportsView .monthly-target-panel,
  #reportsView .cross-analysis-panel {
    padding: 21px;
    border-radius: 13px;
    box-shadow: 0 9px 22px rgba(18, 36, 59, 0.055);
  }

  #reportsView .monthly-target-panel .dashboard-panel-head,
  #reportsView .cross-analysis-panel .dashboard-panel-head {
    align-items: flex-end;
  }

  #reportsView .target-table-wrap {
    border-radius: 10px;
    background: #f8fafc;
  }

  #reportsView .target-month-table thead th {
    background: #eaf0f6;
    color: #4e657f;
  }

  #reportsView .target-month-table tbody th {
    background: #fbfcfe;
    color: #243c59;
  }

  #reportsView .cross-analysis-panel {
    border-top: 4px solid var(--dashboard-blue);
  }

  #reportsView .cross-analysis-summary {
    margin: 12px 0 0;
    padding: 15px 16px;
    border: 1px solid #dce6f0;
    border-radius: 10px;
    background: #f7fafd;
  }

  #reportsView .cross-analysis-summary strong {
    color: var(--dashboard-blue);
    font-size: 22px;
  }

  #reportsView .cross-analysis-summary p {
    width: 100%;
    margin: 5px 0 0;
    color: #7b8da2;
    font-size: 10px;
  }

  #reportsView .cross-chart-area {
    margin-top: 18px;
    padding-top: 1px;
  }

  #reportsView .cross-chart-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    color: #243c59;
    font-size: 12px;
  }

  #reportsView .cross-chart-heading span {
    color: #8494a7;
    font-size: 10px;
    font-weight: 800;
  }

  #reportsView .cross-analysis-list {
    gap: 10px;
  }

  #reportsView .cross-analysis-row {
    padding: 12px 13px;
    border: 1px solid #e0e8f0;
    border-radius: 9px;
    background: #fbfcfe;
  }

  #reportsView .cross-analysis-row-head {
    align-items: center;
  }

  #reportsView .cross-analysis-row-head em {
    color: var(--dashboard-blue);
    font-size: 11px;
    font-style: normal;
    font-weight: 900;
    white-space: nowrap;
  }

  #reportsView .cross-analysis-track {
    height: 9px;
    margin: 9px 0 6px;
    background: #e7eef6;
  }

  #reportsView .cross-analysis-track span {
    background: var(--dashboard-blue);
  }

  #reportsView .cross-analysis-row small {
    color: #7e90a5;
  }
}

@media screen and (max-width: 1350px) {
  #reportsView > .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media screen and (max-width: 1020px) {
  #reportsView .sales-dashboard-hero {
    min-height: 0;
    flex-direction: column;
    gap: 22px;
  }

  #reportsView .dashboard-hero-actions {
    max-width: none;
    justify-content: flex-start;
  }

  #reportsView .summary-kpi-card {
    min-height: 390px;
  }
}

@media screen and (max-width: 860px) {
  #reportsView .report-filters {
    position: static;
  }

  #reportsView .group-summary-top-panel .dashboard-panel-head,
  #reportsView .monthly-target-panel .dashboard-panel-head,
  #reportsView .cross-analysis-panel .dashboard-panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  #reportsView > .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media screen and (max-width: 520px) {
  #reportsView.report-dashboard-page::before {
    margin-bottom: 10px;
  }

  #reportsView .sales-dashboard-hero {
    padding: 22px 19px;
    border-left-width: 4px;
  }

  #reportsView .sales-dashboard-hero h2 {
    font-size: 23px;
  }

  #reportsView .dashboard-hero-actions button {
    flex: 1 1 130px;
  }

  #reportsView > .metric-grid {
    grid-template-columns: 1fr;
  }

  #reportsView .summary-kpi-card {
    min-height: 0;
  }
}

/* Final UPVC brand priority */
@media screen {
  :root {
    --bg: #F4F4F5;
    --surface-soft: #F4F4F5;
    --text: #0C0B3A;
    --muted: #626887;
    --line: #d9deef;
    --line-strong: #0C0B3A;
    --brand: #B12423;
    --brand-dark: #8b1c1b;
    --brand-soft: #faeeee;
    --ink: #0C0B3A;
    --blue: #15328A;
    --accent: #809EDD;
    --shadow: 0 16px 42px rgba(12, 11, 58, 0.09);
  }

  body {
    background: linear-gradient(180deg, #ffffff 0, #F4F4F5 280px, var(--bg) 100%);
    color: var(--text);
  }

  .sidebar {
    background: #0C0B3A;
    box-shadow: 12px 0 30px rgba(12, 11, 58, 0.18);
  }

  .sidebar-brand {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .brand-mark {
    width: 196px;
    height: 105px;
    padding: 5px;
    border-color: rgba(128, 158, 221, 0.42);
    background: #ffffff;
  }

  .brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  .nav-item.active {
    background: #B12423;
    box-shadow: 0 9px 20px rgba(177, 36, 35, 0.28);
  }

  .text-button {
    color: #15328A;
  }
}

@media screen and (max-width: 860px) {
  .sidebar-brand {
    align-items: center;
    flex-direction: row;
  }

  .brand-mark {
    width: 132px;
    height: 70px;
  }

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

@media screen and (max-width: 520px) {
  .sidebar-brand > div:last-child {
    display: none;
  }

  .brand-mark {
    width: 116px;
    height: 62px;
  }
}
