:root {
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f6f8fb;
  color: #1f2937;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

.topbar {
  background: #1e3a5f;
  color: #fff;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-brand { font-weight: 700; font-size: 1rem; letter-spacing: 0.01em; }
.topbar-right { display: flex; align-items: center; gap: 1rem; font-size: 0.85rem; }
.topbar-right span { color: #cbd5e1; }
.topbar-right a { color: #93c5fd; text-decoration: none; font-weight: 500; }
.topbar-right a:hover { text-decoration: underline; }
.btn-logout-top {
  background: transparent;
  border: 1px solid #93c5fd;
  color: #93c5fd;
  padding: 0.28rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
}
.btn-logout-top:hover { background: rgba(255,255,255,0.1); }

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px;
}

header {
  margin-bottom: 24px;
}

h1 {
  margin: 0 0 6px;
  font-size: clamp(2rem, 2.5vw, 2.8rem);
}

p {
  margin: 0;
  color: #525f7f;
}

main {
  display: grid;
  gap: 24px;
}

.panel {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

.field,
.group-row {
  margin-bottom: 18px;
}

.field {
  display: flex;
  flex-direction: column;
}

.field label {
  font-weight: 600;
  margin-bottom: 8px;
}

.field input,
.field select {
  padding: 12px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  font-size: 1rem;
}

.group-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.actions {
  display: flex;
  justify-content: flex-end;
}

button {
  border: none;
  background: #2563eb;
  color: white;
  padding: 14px 22px;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
}

button:hover {
  background: #1d4ed8;
}

.validation {
  color: #b91c1c;
  font-weight: 600;
}

.quote-summary table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 18px;
}

.quote-summary th,
.quote-summary td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
}

.total-row th,
.total-row td {
  border-top: 2px solid #cbd5e1;
  font-size: 1.1rem;
}

.breakdown ul {
  margin: 0;
  padding-left: 20px;
}

.breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.breakdown-table th,
.breakdown-table td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid #e2e8f0;
}

.breakdown-table thead th {
  background: #f8fafc;
  font-weight: 600;
  color: #475569;
}

.error {
  color: #b91c1c;
}

/* Dimension unit + stepper */
.dim-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.dim-header-label {
  font-weight: 600;
  font-size: 1rem;
}

.req {
  color: #ef4444;
}

.dim-inputs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dim-row-input {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dim-label {
  font-weight: 600;
  font-size: 0.9rem;
  min-width: 28px;
  color: #374151;
}

.dim-stepper {
  flex: 1;
  display: flex;
  align-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  overflow: hidden;
  background: white;
}

.dim-stepper input {
  flex: 1;
  border: none;
  outline: none;
  padding: 12px 14px;
  font-size: 1rem;
  background: transparent;
  -moz-appearance: textfield;
  appearance: textfield;
}

.dim-stepper input::-webkit-inner-spin-button,
.dim-stepper input::-webkit-outer-spin-button {
  display: none;
}

.btn-stepper {
  background: #f8fafc;
  border: none;
  border-left: 1px solid #e2e8f0;
  width: 44px;
  height: 44px;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  color: #374151;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-stepper:hover {
  background: #e2e8f0;
}

.area-display {
  margin-top: 6px;
  font-weight: 500;
}

/* Cornice button group */
.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-option {
  background: white;
  color: #374151;
  border: 1.5px solid #cbd5e1;
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: 10px;
  cursor: pointer;
}

.btn-option:hover {
  border-color: #2563eb;
  color: #2563eb;
}

.btn-option.selected {
  background: #eff6ff;
  border-color: #2563eb;
  color: #2563eb;
  font-weight: 700;
}

/* Motif counter */
.counter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.counter-value {
  font-size: 1.1rem;
  font-weight: 600;
  min-width: 48px;
  text-align: center;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 8px 16px;
}

.btn-counter {
  background: #f1f5f9;
  color: #374151;
  border: 1px solid #cbd5e1;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-counter:hover {
  background: #e2e8f0;
}

.price-hint {
  font-weight: 400;
  font-size: 0.85rem;
  color: #64748b;
  margin-left: 6px;
}

/* Infill section */
.infill-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.infill-title {
  font-weight: 600;
}

.infill-unit-toggle {
  display: flex;
  gap: 14px;
  font-size: 0.9rem;
}

.infill-unit-toggle label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
  cursor: pointer;
}

.infill-row {
  display: grid;
  grid-template-columns: 1fr 100px 42px 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.infill-row select,
.infill-row input {
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 0.95rem;
}

.infill-unit-label {
  font-size: 0.9rem;
  color: #64748b;
  text-align: center;
}

.infill-remove {
  background: #fee2e2;
  color: #b91c1c;
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}

.infill-remove:hover {
  background: #fecaca;
}

.btn-add {
  background: none;
  color: #2563eb;
  border: 1.5px dashed #93c5fd;
  padding: 9px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 4px;
}

.btn-add:hover {
  background: #eff6ff;
  border-color: #2563eb;
}

.btn-add:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.hint {
  font-size: 0.85rem;
  color: #64748b;
  margin: 4px 0 8px;
}

.hint-ok {
  color: #16a34a;
}

.hint-warn {
  color: #b45309;
}

/* ── Cart panel ──────────────────────────────────────────────────────────── */

.cart-count {
  font-size: 0.85rem;
  color: #64748b;
  font-weight: 500;
}

.cart-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #e2e8f0;
}

.cart-item-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cart-item-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.cart-item-sub {
  font-size: 0.82rem;
  color: #64748b;
}

.cart-item-total {
  font-weight: 700;
  font-size: 1rem;
  color: #1f2937;
  white-space: nowrap;
}

.cart-item-remove {
  background: #fee2e2;
  color: #b91c1c;
  border: none;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-item-remove:hover {
  background: #fecaca;
}

.cart-total {
  font-weight: 700;
  font-size: 1rem;
  text-align: right;
  padding: 10px 0 0;
  color: #374151;
}

/* ── Multi-item quote summary ────────────────────────────────────────────── */

.quote-id-line {
  font-size: 0.85rem;
  color: #64748b;
  margin: 0 0 16px;
}

.item-section-heading {
  font-weight: 700;
  font-size: 1rem;
  color: #2563eb;
  margin: 18px 0 8px;
  padding-bottom: 6px;
  border-bottom: 2px solid #eff6ff;
}

.quote-item-block {
  margin-bottom: 8px;
}

.grand-total-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  padding: 14px 16px;
  background: #1e3a8a;
  color: white;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 700;
}

.breakdown-heading {
  margin: 14px 0 6px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #374151;
}

/* ── Optional label ──────────────────────────────────────────────────────── */

.optional-label {
  font-weight: 400;
  font-size: 0.82rem;
  color: #94a3b8;
}

/* ── Quote result header ─────────────────────────────────────────────────── */

.quote-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.quote-result-header h2 {
  margin: 0;
}

.btn-pdf {
  background: #0f766e;
  color: white;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  border: none;
}

.btn-pdf:hover {
  background: #0d6460;
}

/* ── Customer name modal ─────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-box {
  background: white;
  border-radius: 18px;
  padding: 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-box h3 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.modal-hint {
  font-size: 0.85rem;
  color: #64748b;
  margin: 0 0 18px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.btn-secondary {
  background: #f1f5f9;
  color: #374151;
  border: 1px solid #cbd5e1;
}

.btn-secondary:hover {
  background: #e2e8f0;
}

/* ── Print area (screen: hidden) ─────────────────────────────────────────── */

#printArea {
  display: none;
}

/* ── Print styles ────────────────────────────────────────────────────────── */

@media print {
  body > * { display: none !important; }
  #printArea { display: block !important; }

  .pq {
    padding: 28px 36px;
    background: #faf9f5;
    color: #1a1a1a;
    font-family: Inter, Arial, sans-serif;
    font-size: 9pt;
    line-height: 1.4;
  }

  .pq-doctag {
    font-size: 6pt;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #888;
    margin-bottom: 8px;
  }

  .pq-masthead {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #5c6b2e;
  }

  .pq-masthead-l {
    font-size: 28pt;
    font-weight: 900;
    letter-spacing: -0.02em;
    color: #1a1a1a;
  }

  .pq-em { color: #5c6b2e; }

  .pq-masthead-r { font-size: 16pt; color: #1a1a1a; }
  .pq-masthead-r strong { font-weight: 900; }
  .pq-masthead-r sup { font-size: 8pt; vertical-align: super; }

  .pq-meta-bar {
    display: flex;
    border-top: 1px solid #d4cdb5;
    border-bottom: 1px solid #d4cdb5;
    margin-bottom: 16px;
    background: #f5f3ec;
  }

  .pq-meta-cell {
    flex: 1;
    padding: 6px 10px;
    border-right: 1px solid #d4cdb5;
  }

  .pq-meta-cell:last-child { border-right: none; }

  .pq-ml {
    font-size: 6pt;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #888;
    font-variant: small-caps;
    margin-bottom: 2px;
  }

  .pq-mv { font-size: 9pt; font-weight: 600; color: #1a1a1a; }

  .pq-project {
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #d4cdb5;
  }

  .pq-tag {
    font-size: 6pt;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #888;
    margin-bottom: 4px;
  }

  .pq-project-body {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-top: 4px;
  }

  .pq-pnum {
    font-size: 22pt;
    font-weight: 900;
    color: #5c6b2e;
    line-height: 1;
    min-width: 44px;
  }

  .pq-ptitle {
    font-size: 16pt;
    font-weight: 700;
    margin: 0 0 4px;
    color: #1a1a1a;
    line-height: 1.2;
  }

  .pq-pdesc { font-size: 7.5pt; color: #666; margin: 0; }

  .pq-parties {
    display: flex;
    margin-bottom: 16px;
    background: #f5f3ec;
    padding: 10px 12px;
  }

  .pq-party { flex: 1; }
  .pq-party-gap { flex: 2; }
  .pq-pname { font-size: 10pt; font-weight: 700; color: #1a1a1a; margin-bottom: 2px; }
  .pq-pdetail { font-size: 7.5pt; color: #666; }

  .pq-sh {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 14px 0 6px;
    border-top: 1.5px solid #1a1a1a;
    padding-top: 5px;
  }

  .pq-sn { color: #5c6b2e; font-weight: 700; font-size: 9pt; }

  .pq-st {
    font-size: 8pt;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-variant: small-caps;
    color: #1a1a1a;
  }

  .pq-sc {
    font-size: 6.5pt;
    letter-spacing: 0.1em;
    color: #888;
    font-variant: small-caps;
  }

  .pq-tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 8.5pt;
    margin-bottom: 6px;
  }

  .pq-tbl thead tr {
    border-top: 1.5px solid #1a1a1a;
    border-bottom: 1px solid #d4cdb5;
  }

  .pq-tbl thead th {
    text-align: left;
    padding: 5px 7px;
    font-size: 6.5pt;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #666;
    font-weight: 600;
    background: transparent;
  }

  .pq-tbl .pq-qty,
  .pq-tbl .pq-unit,
  .pq-tbl .pq-amt { text-align: right; }

  .pq-tbl thead .pq-no { width: 28px; color: #5c6b2e; font-weight: 700; }

  .pq-room-row td {
    padding: 8px 7px 4px;
    font-size: 7pt;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #5c6b2e;
    border-top: 1px solid #d4cdb5;
    background: #f5f3ec;
  }

  .pq-spec-row td {
    padding: 5px 7px;
    border-bottom: 0.5px solid #e8e5da;
    vertical-align: top;
  }

  .pq-no {
    font-size: 8pt;
    font-weight: 700;
    color: #5c6b2e;
    white-space: nowrap;
    min-width: 24px;
  }

  .pq-cat {
    font-size: 6pt;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #888;
    font-variant: small-caps;
    margin-bottom: 1px;
  }

  .pq-name { font-size: 9pt; font-weight: 700; color: #1a1a1a; }
  .pq-detail { font-size: 7pt; color: #666; margin-top: 1px; }

  .pq-subtotal-row td {
    text-align: right;
    padding: 5px 7px;
    font-size: 8pt;
    font-weight: 600;
    border-top: 1px solid #d4cdb5;
    border-bottom: 1px solid #d4cdb5;
    color: #444;
    background: #f5f3ec;
  }

  .pq-summation {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-top: 12px;
    padding: 12px 0;
    border-top: 2px solid #1a1a1a;
    border-bottom: 2px solid #1a1a1a;
    margin-bottom: 16px;
  }

  .pq-sl { display: flex; flex-direction: column; gap: 2px; }

  .pq-scurr {
    font-size: 7pt;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #888;
  }

  .pq-stotal {
    font-size: 28pt;
    font-weight: 900;
    color: #1a1a1a;
    line-height: 1;
    letter-spacing: -0.02em;
  }

  .pq-sr { text-align: right; font-size: 8.5pt; min-width: 180px; }

  .pq-sline {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    padding: 2px 0;
    color: #444;
  }

  .pq-srule { border: none; border-top: 1px solid #d4cdb5; margin: 6px 0; }
  .pq-sfinal { font-weight: 700; color: #1a1a1a; font-size: 9.5pt; }

  .pq-foot {
    display: flex;
    justify-content: space-between;
    font-size: 6.5pt;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #aaa;
    border-top: 1px solid #d4cdb5;
    padding-top: 8px;
  }
}
