:root {
  --navy: #0b2447;
  --navy-2: #19376d;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e2ef;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --accent: #1f5f99;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(11, 36, 71, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 56px);
  color: #fff;
  background: var(--navy);
}

.brand-block,
.print-brand {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-logo {
  width: clamp(150px, 18vw, 240px);
  height: auto;
  padding: 10px 14px;
  border-radius: 8px;
  background: #fff;
}

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

.app-header h1,
.print-title h2 {
  margin: 0;
  font-size: clamp(1.45rem, 2.3vw, 2.3rem);
  line-height: 1.15;
}

.eyebrow {
  margin: 0 0 6px;
  color: #b7d5f6;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 48px;
}

.form-section,
.quote-preview,
.authorization-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.form-section,
.quote-preview,
.authorization-panel {
  margin-top: 18px;
  padding: clamp(18px, 3vw, 28px);
}

.section-heading,
.print-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.section-heading h2,
.print-title h2 {
  color: var(--navy);
}

.section-heading h2 {
  margin: 0;
  font-size: 1.15rem;
}

#quoteDate,
#printDate {
  color: var(--muted);
  font-size: 0.92rem;
  white-space: nowrap;
}

.form-grid,
.item-form,
.sheets-config,
.transfer-grid {
  display: grid;
  gap: 16px;
}

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

.item-form {
  grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(120px, 1fr)) auto auto;
  align-items: end;
}

.sheets-config {
  grid-template-columns: minmax(240px, 1fr) auto;
  align-items: end;
}

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

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 0.9rem;
  font-weight: 700;
}

.wide {
  grid-column: span 3;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #c8d3e1;
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
}

input:disabled {
  color: #475467;
  background: #eef3f8;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(31, 95, 153, 0.18);
  border-color: var(--accent);
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
}

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

.primary-button:hover {
  background: var(--navy);
}

.secondary-button {
  color: var(--navy);
  background: #e9eff7;
}

.secondary-button:hover {
  background: #dbe6f3;
}

.danger-button {
  color: var(--danger);
  background: #fff1f0;
}

.helper-text {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.helper-text.success {
  color: #067647;
}

.helper-text.error {
  color: var(--danger);
}

.hidden {
  display: none;
}

.authorization-panel {
  border-left: 6px solid var(--navy-2);
}

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

.authorization-summary div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #fbfcff;
}

.authorization-summary span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.authorization-summary strong {
  display: block;
  margin-top: 4px;
  color: var(--navy);
}

.authorization-comment {
  margin-top: 16px;
}

.authorization-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary-grid div,
.text-block {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #fbfcff;
}

.summary-grid span,
.text-block span,
.totals-panel span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.summary-grid strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.text-block {
  margin-bottom: 14px;
}

.text-block p {
  margin: 6px 0 0;
  white-space: pre-wrap;
}

.transfer-summary {
  margin: 18px 0;
}

.transfer-summary h3 {
  margin: 0 0 12px;
  color: var(--navy);
  font-size: 1rem;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: #fff;
  background: var(--navy);
  font-size: 0.84rem;
}

td:nth-child(2),
td:nth-child(4),
td:nth-child(5),
th:nth-child(2),
th:nth-child(4),
th:nth-child(5) {
  text-align: right;
}

.empty-row td {
  color: var(--muted);
  text-align: center;
}

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

.row-actions button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.84rem;
}

.totals-panel {
  width: min(360px, 100%);
  margin: 18px 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

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

.totals-panel div:last-child {
  border-bottom: 0;
}

.grand-total {
  color: #fff;
  background: var(--navy) !important;
}

.grand-total span {
  color: #dce9f7;
}

@media (max-width: 980px) {
  .app-header,
  .section-heading,
  .print-title {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-block,
  .print-brand {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    justify-content: flex-start;
  }

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

  .wide {
    grid-column: span 2;
  }

  .item-form,
  .sheets-config,
  .transfer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    margin-top: 10px;
  }

  .form-grid,
  .summary-grid,
  .item-form,
  .sheets-config,
  .transfer-grid,
  .authorization-summary {
    grid-template-columns: 1fr;
  }

  .wide,
  .item-description {
    grid-column: auto;
  }

  .header-actions button,
  .sheets-config button,
  .item-form button {
    width: 100%;
  }
}

@media print {
  body {
    background: #fff;
  }

  .no-print,
  .app-header,
  .form-section {
    display: none !important;
  }

  .app-shell {
    width: 100%;
    margin: 0;
  }

  .quote-preview {
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .print-logo {
    width: 165px;
  }

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

  .table-wrap {
    overflow: visible;
  }

  table {
    min-width: 0;
    font-size: 0.86rem;
  }

  th {
    color: #fff !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .totals-panel {
    page-break-inside: avoid;
  }
}
