:root {
  --bg: #3A3A3A;
  --accent: #A88F7B;
  --text: #E6CDB9;
  --muted: #D1D1D1;
  --muted2: #8C8C8C;
  --card: #424242;
  --iconbg: #585757;
  --progress: #828282;
  --accent2: #735F4F;
  --shadow: rgba(0, 0, 0, .25);

  --radius: 14px;
  --radius2: 18px;

  --font-head: "Montserrat", system-ui, sans-serif;
  --font-body: "Lato", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: linear-gradient(180deg, #3a3a3a 0%, #343434 100%);
  border-bottom: 1px solid rgba(232, 205, 185, .18);
}

.brand { display: flex; align-items: center; gap: 12px; }

.logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--iconbg);
  color: var(--text);
  font-family: var(--font-head);
  font-weight: 700;
  letter-spacing: .5px;
  border: 1px solid rgba(232, 205, 185, .18);
}

.brand-title { font-family: var(--font-head); font-weight: 700; }
.brand-sub { font-size: 12px; color: var(--muted); }

.top-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  border: 1px solid rgba(232, 205, 185, .22);
  background: #3f3f3f;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: none;
  transition: transform .08s ease, background .2s ease, border-color .2s ease;
  font-family: var(--font-body);
}

.btn:hover {
  background: var(--card);
  border-color: rgba(168, 143, 123, .65);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0px); }

.btn-accent {
  background: rgba(168, 143, 123, .18);
  border-color: rgba(168, 143, 123, .55);
}
.btn-accent:hover {
  background: rgba(168, 143, 123, .26);
  border-color: rgba(168, 143, 123, .8);
}

.btn-ghost { background: transparent; box-shadow: none; }

.btn-mini { padding: 8px 10px; border-radius: 10px; box-shadow: none; }

.btn-danger { border-color: rgba(255, 110, 110, .35); }
.btn-danger:hover { background: rgba(255, 110, 110, .10); border-color: rgba(255, 110, 110, .6); }

.layout {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 16px;
  padding: 16px;
  max-width: 1400px;
  margin: 0 auto;
}

.panel {
  background: #363636;
  border: 1px solid rgba(232, 205, 185, .16);
  border-radius: var(--radius2);
  padding: 16px;
  box-shadow: 0 14px 30px var(--shadow);
}

h2 {
  margin: 0 0 10px 0;
  font-family: var(--font-head);
  font-size: 16px;
  letter-spacing: .2px;
}

.divider { height: 1px; background: rgba(232, 205, 185, .14); margin: 14px 0; }

.field { display: flex; flex-direction: column; gap: 6px; }

label { font-size: 12px; color: var(--muted); }

input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(232, 205, 185, .18);
  background: #3c3c3c;
  color: var(--text);
  outline: none;
  font-family: var(--font-body);
}

input:focus, textarea:focus, select:focus {
  border-color: rgba(168, 143, 123, .9);
  box-shadow: 0 0 0 3px rgba(168, 143, 123, .15);
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.lines { display: flex; flex-direction: column; padding: 6px 0; gap: 14px; }

.line {
  display: grid;
  grid-template-columns: 1.4fr .4fr .5fr .6fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid rgba(232, 205, 185, .14);
  background: #3a3a3a;
}
.line:hover { background: var(--card); border-color: rgba(115, 95, 79, .6); }

.line-actions { margin: 10px 0; }

.hint { margin-top: 12px; font-size: 12px; color: var(--muted); }

.preview-wrap { padding: 0; overflow: hidden; }
.preview { padding: 16px; }

.quote {
  background: #2f2f2f;
  border: 1px solid rgba(232, 205, 185, .18);
  border-radius: 18px;
  padding: 18px;
}

.quote-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(232, 205, 185, .14);
}

.q-title { font-family: var(--font-head); font-weight: 700; font-size: 18px; }
.q-meta { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.q-ref { margin-top: 8px; color: var(--muted); font-size: 12px; }

.quote-meta { min-width: 210px; text-align: right; }

.pill {
  display: inline-block;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(168, 143, 123, .55);
  background: rgba(168, 143, 123, .16);
  font-family: var(--font-head);
  font-weight: 700;
  letter-spacing: .5px;
  margin-bottom: 10px;
}

/* ✅ Toegevoegd: logo-slot (logo i.p.v. pill) */
.logo-slot{
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 10px;
}
#pLogo{
  display: none;
  max-height: 44px;
  max-width: 220px;
  object-fit: contain;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}
.meta-row b { color: var(--text); font-weight: 700; }

.quote-to { padding: 14px 0; }

.section-title {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .12em;
  margin-bottom: 6px;
}

.q-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid rgba(232, 205, 185, .14);
}

.q-table thead th {
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  padding: 10px 12px;
  background: #3a3a3a;
  border-bottom: 1px solid rgba(232, 205, 185, .14);
}

.q-table tbody td {
  padding: 10px 12px;
  font-size: 13px;
  border-bottom: 1px solid rgba(232, 205, 185, .10);
}

.q-table tbody tr:hover td { background: rgba(66, 66, 66, .55); }
.q-table tbody tr:last-child td { border-bottom: none; }

.totals {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(232, 205, 185, .14);
}

.totals-left {
  flex: 1;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.totals-right { min-width: 260px; }

.t-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  color: var(--muted);
  font-size: 12px;
}
.t-row b { color: var(--text); }

.t-row.grand {
  padding-top: 10px;
  margin-top: 6px;
  border-top: 1px solid rgba(232, 205, 185, .14);
  font-size: 13px;
}
.t-row.grand b { font-family: var(--font-head); font-size: 16px; }

.footer-note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.quote .table-wrap { margin-top: 10px; }
.quote .table-wrap .q-table { min-width: 520px; }

#pClientName{
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

@media print {
  body { background: #fff; color: #111; }
  .topbar, .panel:first-child { display: none !important; }
  .layout { grid-template-columns: 1fr; padding: 0; }
  .panel.preview-wrap { border: none; box-shadow: none; background: transparent; }
  .quote { background: #fff; color: #111; border: 1px solid #ddd; }
  .q-meta, .meta-row, .section-title, .t-row, .totals-left, .footer-note { color: #444 !important; }

  @page { margin: 0; }
  body { margin: 0; }

  .quote {
    display: flex !important;
    flex-direction: column !important;
    min-height: calc(297mm - 24mm) !important;
  }
  .totals { margin-top: auto !important; page-break-inside: avoid !important; break-inside: avoid !important; }
  .totals-right, .totals-left { break-inside: avoid !important; }
}

img, svg, video { max-width: 100%; height: auto; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .topbar { flex-direction: column; align-items: stretch; }
  .top-actions { width: 100%; justify-content: flex-start; }
  .layout { padding: 12px; }
  .panel { padding: 14px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .quote-header { flex-direction: column; align-items: flex-start; }
  .quote-meta { text-align: left; min-width: 0; }
  .totals { flex-direction: column; }
  .totals-right { min-width: 0; }

  .line {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "desc desc"
      "qty price"
      "vat del";
    align-items: stretch;
  }

  .line .l-desc { grid-area: desc; }
  .line .l-qty { grid-area: qty; }
  .line .l-price { grid-area: price; }
  .line .l-vat { grid-area: vat; }
  .line .l-del { grid-area: del; width: 100%; }
}

@media (max-width: 420px) {
  .btn { width: 100%; justify-content: center; }
}
