/* Hardwood Floor Hero — styles (brand palette: navy/amber/red/cream/slate) */
:root {
  --navy: #1B2A4A;        /* Hero Navy — primary, headlines, chrome */
  --amber: #C77B2E;       /* Plank Amber — secondary, wood, accents */
  --amber-light: #E8A14D; /* Plank Light — gradients, highlights */
  --red: #C8402F;         /* Cape Red — CTAs, alerts, the star */
  --cream: #F5EDDE;       /* Sawdust Cream — light bg, text on navy */
  --slate: #5A6A85;       /* Slate — body text, captions, dividers */

  --bg: #F1E7D2;
  --panel: #FFFDF7;
  --ink: #1B2A4A;
  --ink-soft: #5A6A85;
  --line: #e7dcc4;
  --line-strong: #d7caab;
  --gold: #E8A14D;        /* legacy alias -> Plank Light */
  --start: #1B2A4A;       /* reused offcut — navy */
  --cut: #C8402F;         /* end cut — cape red */
  --fresh: #C77B2E;       /* fresh-cut starter — amber */
  --rip: #5A6A85;         /* ripped row — slate */
  --shadow: 0 1px 2px rgba(27,42,74,.07), 0 8px 22px rgba(27,42,74,.08);
  --radius: 12px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
/* brand headlines: Archivo Black, tight, often caps */
h1, h2, .section-title h2, legend, .stat .k, .subhead, .meas-card h4 {
  font-family: "Archivo Black", "Arial Black", Inter, Helvetica, Arial, sans-serif;
  font-weight: 400;
}

/* ---------- header ---------- */
header.app {
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.05) 0 2px, transparent 2px 34px),
    linear-gradient(180deg, #213357, #16223C);
  color: var(--cream);
  padding: 15px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
  border-bottom: 3px solid var(--amber);
}
header.app .brand { display: flex; align-items: center; gap: 13px; margin-right: auto; }
header.app h1 {
  font-size: 22px; margin: 0; letter-spacing: .4px; line-height: 1; text-transform: uppercase;
  color: var(--cream);
}
header.app h1 .hero { color: var(--red); }
header.app .tag { font-size: 12px; color: #c7d2e4; margin: 5px 0 0; letter-spacing: .3px; font-weight: 600; }
header.app .logo {
  width: 46px; height: 46px; flex: none; display: grid; place-items: center;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.35));
}
header.app .logo img, header.app .logo svg { width: 100%; height: 100%; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.ic { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- buttons ---------- */
button {
  font: inherit; cursor: pointer; border-radius: 9px; border: 1px solid transparent;
  padding: 8px 13px; background: var(--cream); color: var(--ink); transition: .12s;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
button:hover { filter: brightness(.97); }
button:active { transform: translateY(1px); }
/* CTA — always Cape Red with cream text */
button.primary { background: var(--red); color: var(--cream); font-weight: 700; border-color: rgba(0,0,0,.08); }
button.primary:hover { background: #b4382a; filter: none; }
button.ghost { background: rgba(255,255,255,.10); border-color: rgba(245,237,222,.4); color: var(--cream); }
button.ghost:hover { background: rgba(255,255,255,.18); }
button.mini { padding: 5px 10px; font-size: 13px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--navy); font-weight: 600; }
button.mini:hover { border-color: var(--amber); }
button.danger { color: var(--red); }

/* ---------- layout ---------- */
.wrap { display: grid; grid-template-columns: 340px 1fr; gap: 20px; padding: 20px; align-items: start; max-width: 1500px; margin: 0 auto; }
@media (max-width: 880px) { .wrap { grid-template-columns: 1fr; padding: 14px; gap: 14px; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.controls { position: sticky; top: 16px; }
@media (max-width: 880px) { .controls { position: static; } }

fieldset { border: none; border-top: 1px solid var(--line); margin: 0; padding: 16px 18px; }
fieldset:first-of-type { border-top: none; }
legend { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--amber); padding: 0; margin-bottom: 4px; }
.hint { font-size: 12px; color: var(--ink-soft); margin: -2px 0 10px; }

.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
label.lab { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

input[type=text], input[type=number], select {
  width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--line-strong);
  border-radius: 8px; background: #fffefb; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--gold); outline-offset: -1px; border-color: var(--gold); }
.with-unit { position: relative; }
.with-unit .u { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--ink-soft); pointer-events: none; }
.with-unit input { padding-right: 38px; }

.seg { display: inline-flex; background: #efe4d2; border-radius: 9px; padding: 3px; gap: 3px; }
.seg button { background: transparent; padding: 6px 12px; border-radius: 7px; font-size: 13.5px; }
.seg button[aria-pressed=true] { background: var(--panel); box-shadow: var(--shadow); font-weight: 700; }

.check { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--amber); }

/* ---------- room tabs ---------- */
.rooms { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.room-tab { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--panel); font-size: 13px; cursor: pointer; }
.room-tab[aria-selected=true] { background: var(--navy); color: var(--cream); border-color: var(--navy); }
.room-tab .x { opacity: .6; font-weight: 700; }
.room-tab .x:hover { opacity: 1; }

/* ---------- per-room subsections (cutouts / transitions) ---------- */
.subsec { margin-top: 14px; border-top: 1px dashed var(--line-strong); padding-top: 12px; }
.subhead { font-size: 12px; font-weight: 800; color: var(--ink-soft); margin-bottom: 8px; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; text-transform: uppercase; letter-spacing: .04em; }
.hint-inline { font-weight: 400; font-size: 11px; color: var(--ink-soft); text-transform: none; letter-spacing: 0; }
.xcard { border: 1px solid var(--line-strong); border-radius: 9px; padding: 8px; margin-bottom: 8px; background: #fffefb; }
.xcard-top { display: flex; gap: 6px; margin-bottom: 6px; }
.xcard-top input { flex: 1; padding: 5px 8px; font-size: 13px; }
.xcard .rm { padding: 4px 8px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--cut); border-radius: 7px; font-size: 12px; }
.row4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.row4 label, .trow label { font-size: 10.5px; color: var(--ink-soft); font-weight: 700; display: block; }
.row4 input { padding: 5px 6px; font-size: 12.5px; width: 100%; }
.trow { display: grid; grid-template-columns: 1.3fr 1fr; gap: 6px; }
.trow select, .trow input { padding: 5px 6px; font-size: 12.5px; width: 100%; }

/* ---------- results ---------- */
.results { display: grid; gap: 18px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 12px; }
.section-title h2 { font-size: 15px; margin: 0; text-transform: uppercase; letter-spacing: .04em; color: var(--navy); }
.section-title .sub { font-size: 12.5px; color: var(--ink-soft); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; padding: 16px; }
.stat { background: linear-gradient(180deg, #fffdf8, #fbf4e8); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; }
.stat .k { font-size: 11.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.stat .v { font-size: 22px; font-weight: 800; margin-top: 3px; line-height: 1.1; }
.stat .v small { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.stat.accent { background: linear-gradient(160deg, var(--amber-light), var(--amber)); border-color: rgba(0,0,0,.06); }
.stat.accent .k { color: #142038; } .stat.accent .v { color: var(--navy); }

.mapwrap { padding: 14px 16px 18px; }
.maptools { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--ink-soft); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.swatch { width: 13px; height: 13px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); display: inline-block; }
.floor-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: #efe6d6; }
svg.floor { display: block; width: 100%; height: auto; }
svg.floor text { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- cut list ---------- */
.cutlist { padding: 6px 0 8px; }
.cut-row { border-top: 1px solid var(--line); padding: 11px 16px; display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: start; }
.cut-row:first-child { border-top: none; }
.cut-row .rlabel { font-weight: 800; font-size: 13px; color: var(--navy); }
.cut-row .rlabel small { display: block; font-weight: 600; color: var(--ink-soft); font-size: 11px; }
.pieces { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12.5px; padding: 4px 9px; border-radius: 7px; border: 1px solid var(--line-strong); background: #fff; font-family: ui-monospace, Menlo, monospace; white-space: nowrap; }
.chip .src { font-family: inherit; color: var(--ink-soft); font-size: 11px; }
.chip.full { background: #faf3e6; }
.chip.start { border-color: var(--start); color: #1B2A4A; background: #e9edf5; }
.chip.fresh { border-color: var(--fresh); color: #8a5316; background: #fbf2e1; }
.chip.end { border-color: var(--cut); color: #9a3526; background: #fbeee9; }
.chip.solo { border-color: var(--amber); background: #fbf2e4; }
.chip.gap { border-style: dashed; border-color: #b9a884; color: #6b5d4d; background: #f4eee2; }
.chip.notched { box-shadow: inset 0 0 0 1.5px #8c7a59; }
.cut-row .rip { font-size: 11.5px; color: var(--rip); font-weight: 700; margin-top: 5px; }

/* ---------- messages ---------- */
.msg { margin: 0 0 10px; padding: 10px 13px; border-radius: 9px; font-size: 13px; display: flex; gap: 8px; }
.msg.warn { background: #fbf0df; border: 1px solid #e9c98a; color: #8a5316; }
.msg.note { background: #eaeef6; border: 1px solid #c3cee0; color: #233f69; }
.msg.err { background: #fbeae6; border: 1px solid #e6b3a6; color: #9a3526; }
.empty { padding: 40px 16px; text-align: center; color: var(--ink-soft); }

.footnote { font-size: 11.5px; color: var(--ink-soft); padding: 0 18px 18px; }
.footnote a { color: var(--amber); }

/* ---------- Pro: cut-sheet branding ---------- */
.pro-badge { display: inline-block; background: var(--navy); color: var(--cream); font-size: 9.5px; font-weight: 800; padding: 1px 6px; border-radius: 999px; letter-spacing: .06em; vertical-align: middle; margin-left: 4px; }
.brand-preview { margin-top: 8px; padding: 8px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; display: inline-block; }
.brand-preview img { max-height: 46px; max-width: 170px; display: block; }
#proBrandSheet { display: none; }

/* ---------- shopping list (monetization) ---------- */
.shop { padding: 4px 16px 2px; }
.shop-item { display: flex; gap: 12px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); }
.shop-item:first-child { border-top: none; }
.shop-info { flex: 1; min-width: 0; }
.shop-name { font-weight: 800; color: var(--navy); font-size: 14px; }
.shop-spec { font-size: 12.5px; color: var(--ink-soft); margin-top: 1px; }
.shop-note { font-size: 11.5px; color: var(--slate); margin-top: 2px; font-style: italic; }
.shop-buy { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.buybtn { display: inline-flex; align-items: center; gap: 3px; font-size: 12.5px; font-weight: 600; text-decoration: none; padding: 6px 11px; border-radius: 8px; border: 1px solid var(--amber); color: var(--amber); white-space: nowrap; background: #fff; }
.buybtn:hover { background: var(--amber); color: #fff; }
.findpro { margin: 8px 16px 0; padding: 13px 15px; border-radius: 10px; background: linear-gradient(120deg, rgba(27,42,74,.06), rgba(199,123,46,.10)); border: 1px solid var(--line-strong); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.findpro-txt { flex: 1; font-size: 13.5px; color: var(--navy); min-width: 180px; }
.findpro-btn { background: var(--red); color: var(--cream); font-weight: 700; text-decoration: none; padding: 10px 16px; border-radius: 9px; white-space: nowrap; }
.findpro-btn:hover { background: #b4382a; }
.shop-disclosure { font-size: 11px; color: var(--slate); padding: 10px 16px 16px; }

/* ---------- share modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 18px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(43,33,24,.5); backdrop-filter: blur(2px); }
.modal-card { position: relative; background: var(--panel); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.3); padding: 22px; width: min(380px, 92vw); text-align: center; }
.modal-card h3 { margin: 0 0 4px; font-size: 18px; }
.modal-sub { margin: 0 0 14px; font-size: 12.5px; color: var(--ink-soft); }
.modal-x { position: absolute; top: 10px; right: 10px; background: transparent; padding: 4px 8px; color: var(--ink-soft); }
.qrbox { width: 240px; height: 240px; margin: 0 auto 14px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: grid; place-items: center; }
.qrbox svg { width: 100%; height: 100%; display: block; }
.qrbox.toobig { font-size: 13px; color: var(--ink-soft); padding: 24px; }
.shareurl { width: 100%; font: 12px ui-monospace, Menlo, monospace; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; resize: none; color: var(--ink); background: #fffefb; word-break: break-all; }
.auth-input { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 9px; color: var(--ink); background: #fffefb; }
.auth-input:focus { outline: 2px solid var(--gold); outline-offset: -1px; border-color: var(--gold); }
.job-list { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow: auto; margin-top: 4px; text-align: left; }
.job-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; }
.job-meta { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.job-meta b { font-size: 13.5px; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-meta span { font-size: 11px; color: var(--slate); }
.job-act { display: flex; gap: 6px; flex: none; }
.modal-actions { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }

/* ---------- print: branded cut sheet ---------- */
@media print {
  @page { margin: 0.5in; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; }
  .wrap { display: block; padding: 0; max-width: none; }
  .panel { box-shadow: none; border: 1px solid #e2dac8; }
  .results { gap: 12px; }

  /* hide interactive chrome, keep the brand header + legend + content */
  header.app .toolbar, .controls,
  #viewSeg, #labelAllWrap, #btnShuffle,
  .room-tab .x, [data-cut-handle] { display: none !important; }

  /* branded header bar on the printed sheet */
  header.app {
    background: #16223C !important; color: var(--cream) !important;
    padding: 10px 16px; border-radius: 0; border-bottom: 3px solid var(--amber);
  }
  header.app .logo { width: 40px; height: 40px; }
  header.app h1 { font-size: 19px; }

  .floor-scroll { border: 1px solid #c9bfa8; overflow: visible; background: #fff; }
  svg.floor { width: 100% !important; height: auto; }
  .maptools { margin-bottom: 6px; }
  .legend { font-size: 11px; }
  .cut-row, .stat, .msg, .legend span, .shop-item { break-inside: avoid; }
  .section-title h2 { color: var(--navy) !important; }
  .footnote { color: var(--slate); padding-top: 6px; }
  /* shopping list prints as a tickable checklist; drop the buy links */
  .shop-buy, .findpro, .shop-disclosure { display: none !important; }
  .shop-name::before { content: "☐  "; }

  /* Pro white-label: swap the HFH header for the contractor's brand */
  body.has-probrand header.app { display: none !important; }
  body.has-probrand #proBrandSheet {
    display: flex !important; align-items: center; gap: 14px;
    padding: 10px 16px; background: #fff; color: var(--navy);
    border-bottom: 3px solid var(--amber); break-inside: avoid;
  }
  #proBrandSheet .pb-logo { max-height: 54px; max-width: 160px; object-fit: contain; }
  #proBrandSheet .pb-info { margin-right: auto; }
  #proBrandSheet .pb-co { font-size: 21px; font-weight: 800; font-family: "Archivo Black","Arial Black",sans-serif; line-height: 1.1; }
  #proBrandSheet .pb-ph { font-size: 12px; color: var(--slate); margin-top: 3px; }
  #proBrandSheet .pb-title { font-size: 11.5px; color: var(--slate); margin-top: 2px; }
  #proBrandSheet .pb-credit { font-size: 9px; color: var(--slate); text-align: right; line-height: 1.3; }
}
