:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --ink: #1c2126;
  --muted: #5f6b73;
  --line: #e2e4de;
  --accent: #2f6f4f;
  --accent-ink: #ffffff;
  --accent-soft: #e7f1ec;
  --accent-strong: #245b40;
  --warn: #b4521f;
  --shadow: 0 1px 2px rgba(20, 30, 24, 0.06), 0 6px 20px rgba(20, 30, 24, 0.06);
  --radius: 12px;
  --maxw: 1180px;
  --stroke-frame: 6;
  --stroke-rail: 3;
  --stroke-detail: 1.5;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }

h1 { font-size: 28px; margin: 0 0 12px; line-height: 1.2; }
h2 { font-size: 21px; margin: 0 0 10px; }
h3 { font-size: 17px; margin: 0 0 6px; }
.muted { color: var(--muted); }

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.header-logo { font-weight: 800; font-size: 19px; color: var(--ink); letter-spacing: -.01em; }
.logo-mark { color: var(--accent); margin-right: 4px; }
.header-right { display: flex; align-items: center; gap: 14px; }
.header-user { color: var(--muted); font-size: 14px; }
.header-link { font-size: 14px; font-weight: 600; }

/* Nav */
.app-nav {
  display: flex;
  gap: 4px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.nav-tab {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.nav-tab:hover { background: var(--accent-soft); color: var(--accent); }
.nav-tab.active { background: var(--accent); color: var(--accent-ink); }

/* Main + footer */
#main-content {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px 20px 60px;
}
.app-footer {
  padding: 18px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

/* Buttons */
.btn {
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 16px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-lg { padding: 12px 22px; font-size: 16px; }

/* Hero / home */
.hero { padding: 18px 0 8px; }
.hero-text { max-width: 60ch; }
.kicker { color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: 12px; margin: 0 0 6px; }
.lede { font-size: 17px; color: var(--muted); margin: 0 0 22px; }
.hero-note { font-size: 13px; color: var(--muted); margin-top: 10px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 36px;
}
.card-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.tile-icon { font-size: 26px; color: var(--accent); margin-bottom: 8px; }
.card-tile p { color: var(--muted); font-size: 14px; margin: 0; }

/* Generic panel */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

/* Quote / chat two-column layout (populated in later stages) */
.quote-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}
.quote-layout .chat-col { min-width: 0; }
.quote-layout .quote-col { position: sticky; top: 16px; }

/* SVG product diagram: scales to container; stroke weights are set as
   attributes with vector-effect="non-scaling-stroke" so they stay crisp. */
.quote-diagram { display: block; max-width: 100%; height: auto; }
.quote-preview {
  background: linear-gradient(#f3f7f4, #e8efe9);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  margin: 10px 0 14px;
}

/* Chat column */
.chat-col {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.messages {
  padding: 18px;
  overflow-y: auto;
  max-height: 56vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.45;
}
.msg.assistant .bubble { background: var(--accent-soft); color: #1d3a2c; border-bottom-left-radius: 4px; }
.msg.user .bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }

.composer {
  border-top: 1px solid var(--line);
  padding: 16px 18px;
  background: #fcfdfc;
}
.composer-hint { margin: 0 0 10px; font-size: 14px; color: var(--muted); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.selected { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-check { width: 14px; display: inline-block; text-align: center; }
.swatch { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(0,0,0,.18); display: inline-block; }

/* Finish colour swatches (kept as classes so no inline styles are needed) */
.swatch-anthracite_grey { background: #383e42; }
.swatch-jet_black       { background: #101214; }
.swatch-heritage_green  { background: #2f4f3a; }
.swatch-gloss_white     { background: #eef0ee; }
.swatch-wood_effect     { background: #8a5a2b; }

/* Forms in composer */
.dim-form, .contact-form { display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.dim-form { flex-flow: row wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.field input, .field textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
}
.field input:focus, .field textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* Quote panel */
.quote-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.quote-title { font-size: 16px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.quote-empty { font-size: 14px; }
.quote-lines { list-style: none; margin: 8px 0 14px; padding: 0; }
.quote-line { padding: 10px 0; border-bottom: 1px solid var(--line); }
.ql-main { display: flex; justify-content: space-between; gap: 10px; font-weight: 600; }
.ql-price { white-space: nowrap; }
.ql-detail { font-size: 13px; color: var(--muted); margin-top: 2px; }
.quote-totals { margin: 0; }
.quote-totals > div { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; color: var(--muted); }
.quote-totals dt, .quote-totals dd { margin: 0; }
.quote-totals .grand { font-size: 19px; font-weight: 800; color: var(--ink); border-top: 2px solid var(--line); margin-top: 6px; padding-top: 10px; }

.quote-card-head { display: flex; align-items: center; justify-content: space-between; }
.quote-close { display: none; border: none; background: none; font-size: 18px; color: var(--muted); cursor: pointer; }

/* Quote tables + detail */
.quote-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.quote-table th, .quote-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
.quote-table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.status-pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; text-transform: capitalize; }
.status-draft { background: var(--accent-soft); color: var(--accent-strong); }
.status-accepted { background: #e7eefb; color: #2a4d8f; }

.qd-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.qd-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.qd-preview { max-width: 520px; }
.qd-totals { max-width: 320px; margin-left: auto; }
.qd-notes { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.qd-notes p { white-space: pre-line; color: var(--muted); }

/* Auth + account */
.auth-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.auth-card { max-width: 100%; }
.accept-card { max-width: 520px; margin: 0 auto; }
.stack-form { display: flex; flex-direction: column; gap: 12px; max-width: 420px; }
.stack-form select { border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; font-size: 15px; font-family: inherit; }
.form-error { background: #fdecec; color: #9a2c2c; border: 1px solid #f1c4c4; border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.panel + .panel { margin-top: 18px; }

/* Order progress */
.order-list { list-style: none; padding: 0; margin: 0; }
.order-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.oi-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.progress { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 8px 18px; }
.progress.mini { font-size: 13px; }
.step { position: relative; padding-left: 20px; color: var(--muted); font-size: 14px; }
.step::before { content: ""; position: absolute; left: 0; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.step-done { color: var(--ink); }
.step-done::before { background: var(--accent); }
.step-current { color: var(--accent-strong); font-weight: 700; }
.step-current::before { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Uploads */
.upload-list { list-style: none; padding: 0; margin: 12px 0 0; }
.upload-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.upload-label em { color: var(--muted); font-style: normal; font-size: 13px; }

/* Mobile sticky summary bar + drawer backdrop (hidden on desktop) */
.quote-bar { display: none; }
.quote-backdrop { display: none; }

/* Mobile: stack, then turn the quote panel into a bottom-sheet drawer */
@media (max-width: 820px) {
  .quote-layout { grid-template-columns: 1fr; }
  .quote-layout .quote-col { position: static; }
  .messages { max-height: 48vh; }
  .auth-wrap { grid-template-columns: 1fr; }
  .qd-totals { margin-left: 0; }
  h1 { font-size: 24px; }

  /* Bottom summary bar, always visible */
  .quote-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: 0 -4px 16px rgba(20,30,24,.10);
    z-index: 40;
  }
  .qbar-total { display: flex; flex-direction: column; line-height: 1.15; }
  .qbar-total span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
  .qbar-total strong { font-size: 19px; }
  .qbar-btn { padding: 9px 16px; }

  /* The full card becomes a slide-up sheet */
  .quote-col .quote-card {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    max-height: 82vh;
    overflow-y: auto;
    border-radius: 16px 16px 0 0;
    transform: translateY(110%);
    transition: transform .25s ease;
    z-index: 60;
  }
  body.quote-open .quote-col .quote-card { transform: translateY(0); }
  body.quote-open .quote-backdrop {
    display: block;
    position: fixed; inset: 0; background: rgba(15,20,17,.45); z-index: 55;
  }
  .quote-close { display: inline-block; }

  /* keep content clear of the fixed bar */
  #main-content { padding-bottom: 92px; }
}
