:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #657080;
  --line: #dde3ea;
  --accent: #176b87;
  --accent-strong: #0f5268;
  --danger: #a33a3a;
  --success: #287447;
}

* {
  box-sizing: border-box;
}

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

a {
  color: inherit;
  text-decoration: none;
}

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

.auth-box {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 45px rgba(23, 32, 42, 0.08);
}

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #111827;
  color: #f8fafc;
  padding: 22px 16px;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 22px;
}

.nav {
  display: grid;
  gap: 3px;
}

.nav a {
  border-radius: 6px;
  color: #d1d7e0;
  display: block;
  padding: 9px 10px;
  font-size: 14px;
}

.nav a.active,
.nav a:hover {
  background: #253145;
  color: #ffffff;
}

.main {
  min-width: 0;
}

.topbar {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 28px;
}

.content {
  padding: 28px;
}

.page-title {
  margin: 0;
  font-size: 24px;
}

.grid {
  display: grid;
  gap: 18px;
}

.compact-grid {
  display: grid;
  gap: 10px;
}

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

.two-col {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.panel h2 {
  font-size: 17px;
  margin: 0 0 14px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 6px;
}

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

.form-row {
  display: grid;
  gap: 6px;
}

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

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

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

.check-item {
  align-items: center;
  display: flex;
  gap: 8px;
}

.check-item input {
  width: auto;
}

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

.package-panel {
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  padding: 10px 11px;
  width: 100%;
}

textarea {
  min-height: 80px;
  resize: vertical;
}

.button {
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 700;
  justify-content: center;
  padding: 10px 14px;
}

.button:hover {
  background: var(--accent-strong);
}

.button-muted {
  background: transparent;
  color: var(--muted);
}

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

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 9px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.badge {
  background: #e8eef3;
  border-radius: 999px;
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.thumb {
  border: 1px solid var(--line);
  border-radius: 6px;
  display: block;
  height: 44px;
  object-fit: cover;
  width: 64px;
}

.thumb-large {
  height: 96px;
  margin-bottom: 10px;
  width: 140px;
}

.image-choice-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  margin-bottom: 10px;
}

.image-choice-card {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 8px;
  text-align: center;
}

.image-choice-card span {
  color: var(--muted);
  font-size: 12px;
}

.quote-item {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.quote-item:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.builder-table input,
.builder-table select,
.builder-table textarea {
  min-width: 120px;
}

.builder-table textarea {
  min-height: 42px;
  min-width: 260px;
}

.image-select-cell {
  align-items: center;
  display: flex;
  gap: 8px;
}

.image-select-cell select {
  min-width: 96px;
}

.image-select-cell .quote-product-image[hidden] {
  display: none;
}

.print-page {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0 auto;
  max-width: 920px;
  padding: 34px;
}

.print-header {
  align-items: flex-start;
  border-bottom: 2px solid var(--ink);
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 18px;
}

.print-logo {
  display: block;
  max-height: 72px;
  max-width: 160px;
  object-fit: contain;
  margin-bottom: 10px;
}

.print-header h1,
.print-header h2,
.print-header p {
  margin: 0 0 6px;
}

.print-title {
  text-align: right;
}

.print-company {
  text-align: right;
}

.print-company h2 {
  font-size: 18px;
}

.print-title h1 {
  font-size: 34px;
  text-transform: uppercase;
}

.print-meta,
.print-totals {
  display: grid;
  gap: 0;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 18px;
}

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

.print-meta div,
.print-totals div {
  border: 1px solid var(--line);
  display: grid;
  gap: 5px;
  padding: 10px;
}

.print-meta strong,
.print-totals strong {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.print-totals span {
  font-size: 18px;
  font-weight: 700;
}

.print-section {
  margin-top: 24px;
}

.print-section h2 {
  border-bottom: 1px solid var(--line);
  font-size: 16px;
  padding-bottom: 7px;
}

.print-items-table {
  table-layout: fixed;
}

.print-items-table th,
.print-items-table td {
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  vertical-align: top;
  white-space: normal;
  word-break: normal;
}

.print-items-table th:nth-child(1),
.print-items-table td:nth-child(1) {
  width: 5%;
}

.print-items-table th:nth-child(2),
.print-items-table td:nth-child(2) {
  width: 8%;
}

.print-items-table th:nth-child(3),
.print-items-table td:nth-child(3) {
  width: 19%;
}

.print-items-table th:nth-child(4),
.print-items-table td:nth-child(4) {
  width: 27%;
}

.print-items-table th:nth-child(5),
.print-items-table td:nth-child(5) {
  width: 10%;
}

.print-items-table th:nth-child(6),
.print-items-table td:nth-child(6),
.print-items-table th:nth-child(7),
.print-items-table td:nth-child(7),
.print-items-table th:nth-child(8),
.print-items-table td:nth-child(8) {
  width: 10.333%;
}

.print-included {
  color: var(--muted);
  font-size: 12px;
}

.quote-product-image {
  border: 1px solid var(--line);
  border-radius: 4px;
  display: block;
  height: 42px;
  object-fit: cover;
  width: 56px;
}

.quotation-summary-table td:first-child,
.quotation-summary-table th {
  font-weight: 700;
  text-align: center;
}

.quotation-summary-table td:last-child {
  text-align: right;
}

.quotation-summary-table .summary-total-row td {
  font-size: 18px;
  font-weight: 700;
}

.print-terms,
.terms-box {
  border: 1px solid var(--line);
  line-height: 1.6;
  padding: 12px;
}

.print-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  margin-top: 28px;
  padding-top: 12px;
}

.print-actions {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 18px auto 0;
  max-width: 920px;
}

.modal-backdrop {
  align-items: center;
  background: rgba(17, 24, 39, 0.42);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 50;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(17, 24, 39, 0.25);
  max-width: 460px;
  padding: 22px;
  width: 100%;
}

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

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

  .sidebar,
  .topbar,
  .print-actions,
  .modal-backdrop {
    display: none;
  }

  .app {
    display: block;
  }

  .content {
    padding: 0;
  }

  .print-page {
    border: 0;
    border-radius: 0;
    max-width: none;
    padding: 0;
  }
}

.flash {
  border-radius: 6px;
  margin-bottom: 18px;
  padding: 12px 14px;
}

.flash.success {
  background: #e9f6ef;
  color: var(--success);
}

.flash.error {
  background: #fbebeb;
  color: var(--danger);
}

.empty {
  color: var(--muted);
  padding: 18px 0;
}

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

  .sidebar {
    position: static;
  }

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

  .stats,
  .two-col,
  .form-grid,
  .package-grid {
    grid-template-columns: 1fr;
  }
}
