/* ============================================================
   Borealis Technical Innovations — Mobile Catalog
   Brand theme: white/gray surfaces, charcoal type, brand red #770909
   ============================================================ */
:root {
  --bg: #f4f4f2;
  --bg2: #ffffff;
  --card: #ffffff;
  --card2: #f0efec;
  --line: #e2e1dd;
  --text: #232222;
  --muted: #6b6d6e;
  --accent: #770909;      /* brand red */
  --accent2: #9b3a3a;
  --green: #2e7d32;
  --amber: #b26a00;
  --blue: #1f4e79;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(35,34,34,.08);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 76px;
  font-size: 15px;
}
/* header */
header {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  padding: 10px 14px 8px;
  display: flex; align-items: center; gap: 10px;
}
header .logo {
  width: 36px; height: 36px; border-radius: 9px;
  background: var(--bg2);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; box-shadow: var(--shadow); flex: none;
  overflow: hidden;
}
header .logo img { width: 100%; height: 100%; object-fit: contain; }
header h1 { font-size: 15px; margin: 0; line-height: 1.15; color: var(--text); }
header h1 small { display: block; color: var(--accent); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; }
header .badge { margin-left: auto; }
.install-btn {
  background: var(--accent); color: #fff; border: 0; border-radius: 9px;
  padding: 7px 11px; font-size: 12px; font-weight: 800; cursor: pointer;
}
.install-btn:active { opacity: .8; }

/* search */
.searchbar {
  position: sticky; top: 57px; z-index: 15;
  padding: 8px 12px;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
  display: flex; gap: 8px;
}
.searchbar input {
  flex: 1; background: var(--bg2); border: 1px solid var(--line);
  color: var(--text); border-radius: 10px; padding: 10px 12px; font-size: 15px;
}
.searchbar input::placeholder { color: var(--muted); }

/* chips */
.chips { display: flex; gap: 7px; overflow-x: auto; padding: 4px 12px 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; background: var(--bg2); border: 1px solid var(--line);
  color: var(--muted); border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* sub chips */
.subchips { display: flex; gap: 6px; overflow-x: auto; padding: 0 12px 10px; scrollbar-width: none; }
.subchips::-webkit-scrollbar { display: none; }
.subchip {
  flex: none; background: transparent; border: 1px dashed var(--line);
  color: var(--muted); border-radius: 999px; padding: 5px 11px; font-size: 12px; cursor: pointer;
}
.subchip.active { border-style: solid; border-color: var(--accent); color: var(--accent); }

/* section headers inside lists */
.cathead {
  color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; padding: 14px 14px 4px;
}

/* item rows */
.item {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  margin: 8px 12px; padding: 11px 12px;
  display: flex; gap: 10px; align-items: flex-start;
  box-shadow: var(--shadow);
}
.item .info { flex: 1; min-width: 0; }
.item .name { font-weight: 600; font-size: 14px; line-height: 1.3; }
.item .meta { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.badge { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 999px; margin-left: 4px; vertical-align: 1px; }
.badge.ok { background: rgba(46,125,50,.12); color: #2e7d32; }
.badge.low { background: rgba(178,106,0,.15); color: #b26a00; }
.badge.out { background: rgba(119,9,9,.12); color: #770909; }
.item .note { color: var(--muted); font-size: 12px; margin-top: 4px; font-style: italic; }
.item .price { font-weight: 800; color: var(--accent); font-size: 15px; white-space: nowrap; }
.item .price small { color: var(--muted); font-weight: 500; font-size: 10px; }
.item .qtybox { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.stepper { display: inline-flex; align-items: center; background: var(--card2); border-radius: 9px; overflow: hidden; border: 1px solid var(--line); }
.stepper button {
  width: 32px; height: 32px; border: 0; background: transparent; color: var(--text);
  font-size: 18px; cursor: pointer; font-weight: 700;
}
.stepper button:active { background: rgba(0,0,0,.08); }
.stepper input {
  width: 46px; text-align: center; border: 0; background: transparent; color: var(--text);
  font-size: 14px; font-weight: 700; height: 32px; padding: 0;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.qtylabel { color: var(--muted); font-size: 12px; }
.btn-add {
  margin-left: auto; background: var(--accent);
  color: #fff; border: 0; border-radius: 9px; padding: 8px 14px; font-weight: 800; font-size: 13px; cursor: pointer;
}

/* panels / cards */
.panel { margin: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.panel .phead {
  display: flex; align-items: center; gap: 8px; padding: 11px 12px;
  background: var(--card2); border-bottom: 1px solid var(--line); font-weight: 700; font-size: 13.5px;
}
.panel .pbody { padding: 12px; }
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: 10px 11px; font-size: 14px; font-family: inherit;
}
.field textarea { min-height: 70px; resize: vertical; }

/* BOM rows */
.bomrow { display: flex; gap: 8px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.bomrow .bname { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; }
.bomrow .bname small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; }
.bomrow input.px { width: 76px; background: var(--bg2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 6px 8px; font-size: 13px; text-align: right; }
.bomrow .lprice { width: 88px; text-align: right; font-weight: 700; font-size: 13px; }
.bomrow .del { background: none; border: 0; color: var(--accent); font-size: 16px; cursor: pointer; padding: 4px; }
.bomqty { display: flex; align-items: center; gap: 4px; }
.bomqty button { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line); background: var(--card2); color: var(--text); cursor: pointer; font-size: 14px; }
.bomqty span { width: 30px; text-align: center; font-weight: 700; font-size: 13px; }

/* totals */
.totals { background: var(--card2); border-top: 1px solid var(--line); padding: 10px 14px; }
.trow { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; color: var(--muted); }
.trow b { color: var(--text); }
.trow.grand { font-size: 17px; font-weight: 900; color: var(--accent); border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; }
.trow.grand b { color: var(--accent); }

/* buttons */
.btn {
  display: block; width: 100%; text-align: center; border: 0; border-radius: 11px;
  padding: 13px; font-size: 15px; font-weight: 800; cursor: pointer; margin-top: 8px;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.secondary { background: var(--card2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: rgba(119,9,9,.08); color: var(--accent); border: 1px solid rgba(119,9,9,.35); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.small { padding: 9px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .5; }

/* jobs list */
.jobcard { margin: 8px 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.jobcard .jtop { display: flex; justify-content: space-between; gap: 8px; }
.jobcard .jname { font-weight: 700; font-size: 14px; }
.jobcard .jmeta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.jobcard .jtotal { color: var(--accent); font-weight: 900; font-size: 15px; }
.jobcard .jacts { display: flex; gap: 8px; margin-top: 10px; }

/* scope */
.scopeout {
  width: 100%; min-height: 260px; background: var(--bg2); border: 1px solid var(--line);
  color: var(--text); border-radius: 10px; padding: 12px; font-size: 13.5px; font-family: inherit; line-height: 1.5;
}

/* settings rows */
.srow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.srow .sval { color: var(--accent); font-weight: 700; }

/* empty state */
.empty { text-align: center; color: var(--muted); padding: 46px 20px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }

/* bottom nav */
nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: rgba(255,255,255,.97); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
nav button {
  flex: 1; background: none; border: 0; color: var(--muted); padding: 8px 0 10px;
  font-size: 10px; font-weight: 700; cursor: pointer; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
nav button .ic { font-size: 21px; line-height: 1; }
nav button.active { color: var(--accent); }
nav .dot {
  position: absolute; top: 4px; right: calc(50% - 22px);
  background: var(--accent); color: #fff; font-size: 9px; font-weight: 800;
  border-radius: 999px; min-width: 16px; height: 16px; line-height: 16px; text-align: center; padding: 0 4px;
}

/* toast */
#toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 13px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 50; box-shadow: var(--shadow);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* modal (iOS-safe replacement for alert/confirm/prompt) */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(35, 34, 34, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal {
  background: var(--bg2); border-radius: 14px; width: 100%; max-width: 380px;
  box-shadow: var(--shadow); overflow: hidden;
}
.modal .mhead { padding: 14px 16px 4px; font-weight: 800; font-size: 15px; }
.modal .mbody { padding: 8px 16px 12px; font-size: 14px; }
.modal .mactions { display: flex; gap: 8px; padding: 0 16px 14px; }
.modal .mactions .btn { margin-top: 0; }
.modal .mactions .btn:first-child { flex: 1; }
.modal .mactions .btn:last-child { flex: 1; }

/* print area (hidden on screen) */
#printArea { display: none; }

/* ===== print ===== */
@media print {
  body { background: #fff; color: #000; padding: 0; font-size: 12px; }
  header, nav, .searchbar, main, #toast, .overlay { display: none !important; }
  #printArea { display: block !important; }
  .print-quote { max-width: 100%; }
  .print-quote h1 { font-size: 20px; margin: 0 0 2px; }
  .print-quote .sub { color: #555; margin-bottom: 14px; }
  .print-quote table { width: 100%; border-collapse: collapse; margin-top: 10px; }
  .print-quote th, .print-quote td { border: 1px solid #999; padding: 5px 7px; text-align: left; }
  .print-quote th { background: #eef2f7; }
  .print-quote .num { text-align: right; }
  .print-quote .tot { text-align: right; font-weight: bold; }
  .print-quote .grand { font-size: 15px; }
  .print-quote .sig { margin-top: 44px; display: flex; justify-content: space-between; gap: 30px; }
  .print-quote .sig div { flex: 1; border-top: 1px solid #000; padding-top: 4px; font-size: 11px; }
  .print-quote .foot { margin-top: 26px; font-size: 10px; color: #666; text-align: center; }
}
