:root {
  --navy: #1b2a8f;
  --navy-light: #e8eaf8;
  --ink: #111;
  --bg: #f4f5f9;
  --panel: #fff;
  --line: #d7d9e4;
  --accent: #1b2a8f;
  --danger: #b3261e;
  --ok: #1e7d32;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--navy);
  color: #fff;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  height: 34px; width: auto;
  background: #fff; padding: 4px 8px;
  border-radius: 6px;
}
.topbar h1 { font-size: 17px; margin: 0; }
.topbar p { margin: 0; font-size: 12px; opacity: .8; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.chip {
  font-size: 12px; padding: 5px 10px; border-radius: 999px;
  background: #ffffff26; max-width: 320px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip-ok { background: #1e7d32; }
.chip-warn { background: #b3261e; }

.btn {
  border: 0; border-radius: 6px; cursor: pointer;
  font-size: 13px; font-weight: 600; padding: 8px 14px;
}
.btn-primary { background: #fff; color: var(--navy); }
.btn-primary:hover { background: #e8eaf8; }
.panel .btn-primary { background: var(--navy); color: #fff; }
.panel .btn-primary:hover { background: #14217a; }
.btn-ghost {
  background: transparent; color: var(--navy);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: var(--navy-light); }

/* ---------- drop zone / empty state ---------- */
.dropzone {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(27, 42, 143, .25);
  display: grid; place-items: center;
}
.dropzone-inner {
  background: #fff; border: 3px dashed var(--navy);
  border-radius: 12px; padding: 48px 64px;
  font-size: 20px; font-weight: 700; color: var(--navy);
}
.empty-state { display: grid; place-items: center; padding: 60px 20px; }
.empty-card {
  max-width: 560px; background: #fff; border: 2px dashed var(--line);
  border-radius: 12px; padding: 32px; text-align: center;
}
.empty-card h2 { margin-top: 0; color: var(--navy); }
.muted { color: #666; font-size: 13px; }

/* ---------- app layout ---------- */
.app {
  display: grid;
  grid-template-columns: minmax(360px, 460px) 1fr;
  gap: 16px;
  padding: 16px 20px 40px;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}
.panel-title { margin: 0 0 12px; font-size: 15px; color: var(--navy); }

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0 0 14px;
  padding: 10px 12px 12px;
}
legend { font-size: 12px; font-weight: 700; color: var(--navy); padding: 0 6px; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.field > span { font-size: 11px; font-weight: 600; color: #555; text-transform: uppercase; letter-spacing: .03em; }
.field input, .field select {
  border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 9px; font-size: 14px; width: 100%;
  background: #fff;
}
.field input:focus, .field select:focus { outline: 2px solid var(--navy-light); border-color: var(--navy); }
.field.total input { font-weight: 800; border-width: 2px; border-color: var(--navy); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

.radios, .checks { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; margin: 6px 0; align-items: center; }
.radios > span, .checks > span { font-size: 11px; font-weight: 700; color: #555; text-transform: uppercase; }
.radios label, .checks label { display: flex; align-items: center; gap: 4px; }

.hint { font-size: 12px; color: #666; margin: 4px 0 8px; }
#offer-hint { color: var(--ok); font-weight: 600; }

.extra-row { display: grid; grid-template-columns: 1fr 120px 28px; gap: 6px; margin-bottom: 6px; }
.extra-row input { border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font-size: 13px; }
.extra-row button { border: 0; background: none; color: var(--danger); font-size: 16px; cursor: pointer; }

.settings summary { cursor: pointer; font-size: 13px; font-weight: 700; color: var(--navy); }
.settings .field { margin-top: 10px; max-width: 180px; }

/* ---------- preview pane ---------- */
.preview-wrap { overflow-x: auto; }
.preview-actions {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; gap: 10px; flex-wrap: wrap;
}
.nextno { font-size: 13px; color: #555; }
.preview-actions div { display: flex; gap: 8px; }

/* ---------- A4 quotation replica ---------- */
.quotation {
  width: 794px;            /* ~A4 @96dpi */
  min-height: 1050px;
  margin: 0 auto;
  background: #fff;
  color: var(--navy);
  border: 2px solid var(--navy);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11px;
  padding: 10px 12px;
}
.fill { color: #111; font-weight: 600; }

.q-header .q-title-row { display: flex; align-items: center; gap: 14px; }
.q-suzuki { height: 26px; width: auto; }
.q-company { font-size: 24px; font-weight: 800; letter-spacing: 1px; }

.q-addr { display: grid; grid-template-columns: 1.05fr 1fr 1fr; gap: 10px; margin-top: 4px; }
.q-addr-col p { margin: 0; line-height: 1.35; font-weight: 700; font-size: 10.5px; }

.q-meta-row {
  display: flex; justify-content: space-between; align-items: center;
  border-top: 2px solid var(--navy); border-bottom: 2px solid var(--navy);
  margin-top: 6px; padding: 3px 2px;
}
.q-no { font-size: 15px; font-weight: 700; min-width: 110px; }
.q-doc-title { font-size: 14px; font-weight: 800; letter-spacing: .5px; }
.q-date { min-width: 110px; text-align: right; font-weight: 700; }

.q-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.q-table th, .q-table td { border: 1.5px solid var(--navy); }
.q-table thead th { font-size: 12px; font-weight: 800; padding: 3px 4px; text-align: center; }
.c-model { width: 13%; } .c-type { width: 10%; } .c-option { width: 10%; }
.c-colour { width: 12%; } .c-part { width: 36%; } .c-amt { width: 19%; }

.q-table td { padding: 4px 5px; height: 22px; font-size: 11.5px; vertical-align: middle; }
td.plabel { font-weight: 700; }
td.amt { text-align: right; }
td.clabel, td.purchase { font-weight: 700; }
.q-total-row td { border-top: 2px solid var(--navy); }
td.plabel.total, td.amt.total { font-weight: 800; font-size: 12.5px; }

.q-finance { border-top: 0; }
.q-finance td { vertical-align: top; }
.fin-left { width: 45%; font-weight: 700; }
.fin-right { width: 55%; }
.q-finance p { margin: 4px 0; font-weight: 700; }

.q-terms { border: 1.5px solid var(--navy); border-top: 0; padding: 5px 8px 8px; }
.q-terms-title { font-weight: 800; margin: 2px 0 4px; font-size: 12px; }
.q-terms ol { margin: 0; padding-left: 18px; }
.q-terms li { font-weight: 700; font-size: 10.5px; line-height: 1.45; }

.q-signblock { border: 1.5px solid var(--navy); border-top: 0; padding: 8px 10px 14px; }
.q-for { text-align: right; font-weight: 800; font-size: 12.5px; margin: 0 0 26px; }
.q-exec { font-weight: 800; font-size: 12px; margin: 0 0 34px; }
.q-sign-row {
  display: flex; justify-content: space-between; align-items: flex-end;
  font-weight: 700; font-size: 11.5px;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #222; color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 13px; z-index: 60;
}
.toast.err { background: var(--danger); }

.hidden { display: none !important; }

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