/* Caston QuoteOS — brand: #ffc400 yellow, #101113/#050505 dark, stone neutrals, Geist */

@font-face {
  font-family: 'Geist';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../assets/geist-sans.woff2') format('woff2');
}
@font-face {
  font-family: 'Geist Mono';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../assets/geist-mono.woff2') format('woff2');
}

:root {
  --yellow: #ffc400;
  --yellow-deep: #ca8a04;
  --ink: #050505;
  --dark: #101113;
  --dark-2: #1c1d20;
  --paper: #f7f7f4;
  --card: #ffffff;
  --stone-1: #f5f5f4;
  --stone-2: #d6d3d1;
  --stone-3: #a8a29e;
  --stone-4: #78716c;
  --stone-5: #57534e;
  --stone-6: #44403c;
  --red: #b91c1c;
  --green: #15803d;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(5,5,5,.06), 0 4px 16px rgba(5,5,5,.07);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Geist', ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
input, select, textarea { width: 100%; }

/* ---------- App shell ---------- */
#app { max-width: 640px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }

header.topbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--dark);
  color: #fff;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  display: flex; align-items: center; gap: 12px;
}
header.topbar img.logo { height: 34px; width: auto; display: block; }
header.topbar .tb-title { font-weight: 650; font-size: 15px; letter-spacing: .01em; }
header.topbar .tb-sub { font-size: 11px; color: var(--stone-3); margin-top: 1px; }
header.topbar .tb-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.tb-btn {
  color: var(--stone-2); font-size: 13px; font-weight: 550;
  padding: 7px 12px; border-radius: 9px; background: var(--dark-2);
}
.tb-btn.warn { color: #fca5a5; }

main { flex: 1; padding: 16px 16px calc(96px + var(--safe-b)); }

/* ---------- Bottom tab bar ---------- */
nav.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: var(--dark);
  border-top: 1px solid #26272b;
  display: flex; justify-content: space-around;
  padding: 6px 8px calc(6px + var(--safe-b));
  max-width: 640px; margin: 0 auto;
}
@media (min-width: 640px) { nav.tabbar { left: 50%; transform: translateX(-50%); width: 640px; } }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--stone-3); font-size: 10.5px; font-weight: 550; padding: 6px 0 4px;
  border-radius: 10px;
}
.tab svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.active { color: var(--yellow); }
.tab.tab-new { color: var(--ink); }
.tab.tab-new .tab-plus {
  width: 44px; height: 44px; margin-top: -22px; border-radius: 50%;
  background: var(--yellow); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(255,196,0,.4);
}
.tab.tab-new .tab-plus svg { width: 24px; height: 24px; stroke: var(--ink); stroke-width: 2.4; }
body.in-wizard nav.tabbar { display: none; }

/* ---------- Generic components ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px;
}
.card h2 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--stone-4); margin-bottom: 12px; }
.card h2 .h2-note { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--stone-3); float: right; }

.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--stone-5); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  border: 1.5px solid var(--stone-2); border-radius: 10px; background: #fff;
  padding: 11px 12px; font-size: 16px; outline: none;
  appearance: none; -webkit-appearance: none;
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--yellow-deep); }
.field .hint { font-size: 11.5px; color: var(--stone-3); margin-top: 4px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.sel-wrap { position: relative; }
.sel-wrap::after {
  content: ''; position: absolute; right: 13px; top: 50%; width: 8px; height: 8px;
  border-right: 2px solid var(--stone-4); border-bottom: 2px solid var(--stone-4);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 12px; font-weight: 650; font-size: 15px;
  padding: 14px 20px; width: 100%; text-decoration: none;
  transition: transform .06s ease;
}
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--yellow); color: var(--ink); }
.btn-dark { background: var(--dark); color: #fff; }
.btn-ghost { background: var(--stone-1); color: var(--ink); border: 1.5px solid var(--stone-2); }
.btn-danger { background: #fef2f2; color: var(--red); border: 1.5px solid #fecaca; }
.btn-sm { padding: 9px 14px; font-size: 13.5px; width: auto; border-radius: 10px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.seg { display: flex; background: var(--stone-1); border: 1.5px solid var(--stone-2); border-radius: 11px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; padding: 9px 6px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--stone-4);
}
.seg button.on { background: var(--dark); color: var(--yellow); }

.chip { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px; text-transform: uppercase; letter-spacing: .04em; }
.chip.draft { background: var(--stone-1); color: var(--stone-4); border: 1px solid var(--stone-2); }
.chip.sent { background: #fffbeb; color: var(--yellow-deep); border: 1px solid #fde047; }
.chip.accepted { background: #f0fdf4; color: var(--green); border: 1px solid #bbf7d0; }
.chip.declined { background: #fef2f2; color: var(--red); border: 1px solid #fecaca; }

/* ---------- Home ---------- */
.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat {
  background: var(--dark); border-radius: var(--radius); padding: 13px 12px; color: #fff;
}
.stat .s-val { font-size: 19px; font-weight: 750; color: var(--yellow); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .s-lbl { font-size: 10.5px; color: var(--stone-3); font-weight: 550; text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }

.search { position: relative; margin-bottom: 12px; }
.search input {
  border: 1.5px solid var(--stone-2); border-radius: 12px; background: #fff;
  padding: 11px 12px 11px 38px; font-size: 15px; outline: none;
}
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; stroke: var(--stone-3); fill: none; stroke-width: 2; }

.qcard {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 10px; display: block; width: 100%; text-align: left;
}
.qcard .q-top { display: flex; align-items: center; gap: 8px; }
.qcard .q-name { font-weight: 650; font-size: 15.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qcard .q-mid { font-size: 12.5px; color: var(--stone-4); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qcard .q-bot { display: flex; align-items: baseline; margin-top: 8px; }
.qcard .q-total { font-weight: 750; font-size: 17px; font-variant-numeric: tabular-nums; }
.qcard .q-date { margin-left: auto; font-size: 11.5px; color: var(--stone-3); }
.empty {
  text-align: center; padding: 48px 24px; color: var(--stone-4);
}
.empty svg { width: 44px; height: 44px; stroke: var(--stone-3); fill: none; stroke-width: 1.5; margin-bottom: 10px; }
.empty p { font-size: 14px; }

/* ---------- Wizard ---------- */
.wiz-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.wiz-head .wz-back { width: 38px; height: 38px; border-radius: 10px; background: #fff; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; flex: none; }
.wiz-head .wz-back svg { width: 18px; height: 18px; stroke: var(--ink); fill: none; stroke-width: 2.2; }
.wiz-head .wz-t { font-size: 17px; font-weight: 700; }
.wiz-head .wz-s { font-size: 11.5px; color: var(--stone-4); }
.dots { display: flex; gap: 5px; margin-left: auto; }
.dots i { width: 7px; height: 7px; border-radius: 99px; background: var(--stone-2); transition: all .2s; }
.dots i.on { background: var(--yellow); width: 18px; }
.dots i.done { background: var(--yellow-deep); }

.wiz-nav { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 12px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.wiz-nav::-webkit-scrollbar { display: none; }
.wiz-nav button {
  flex: none; font-size: 12.5px; font-weight: 600; padding: 7px 13px 7px 8px; border-radius: 99px;
  background: #fff; border: 1.5px solid var(--stone-2); color: var(--stone-4);
  white-space: nowrap; display: flex; align-items: center; gap: 6px;
}
.wiz-nav button .n {
  display: inline-flex; width: 18px; height: 18px; border-radius: 99px; background: var(--stone-1);
  color: var(--stone-5); font-size: 10.5px; align-items: center; justify-content: center; font-weight: 800;
}
.wiz-nav button.on { background: var(--dark); border-color: var(--dark); color: var(--yellow); }
.wiz-nav button.on .n { background: var(--yellow); color: var(--ink); }
.wiz-nav button.done { border-color: var(--yellow); color: var(--ink); }
.wiz-nav button.done .n { background: var(--yellow-deep); color: #fff; }

.matgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.matcard {
  border: 1.5px solid var(--stone-2); border-radius: 12px; background: #fff;
  padding: 12px; text-align: left; position: relative;
}
.matcard .m-l { font-weight: 650; font-size: 13.5px; line-height: 1.25; }
.matcard .m-s { font-size: 11px; color: var(--stone-4); margin-top: 3px; }
.matcard .m-p { font-size: 12px; font-weight: 700; color: var(--yellow-deep); margin-top: 7px; font-variant-numeric: tabular-nums; }
.matcard.on { border-color: var(--yellow); background: #fffdf2; box-shadow: 0 0 0 1.5px var(--yellow); }
.matcard.on::after {
  content: '✓'; position: absolute; top: 8px; right: 10px; width: 18px; height: 18px;
  background: var(--yellow); color: var(--ink); border-radius: 99px; font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}

.stepper { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--stone-1); gap: 10px; }
.stepper:last-child { border-bottom: 0; }
.stepper .st-l { font-size: 14px; font-weight: 550; flex: 1; }
.stepper .st-sub { display: block; font-size: 11px; color: var(--stone-3); font-weight: 500; }
.stepper .st-c { display: flex; align-items: center; gap: 0; flex: none; }
.stepper .st-c button {
  width: 38px; height: 38px; border-radius: 10px; background: var(--stone-1); border: 1.5px solid var(--stone-2);
  font-size: 19px; font-weight: 700; color: var(--stone-5); display: flex; align-items: center; justify-content: center;
}
.stepper .st-c .st-v { width: 52px; text-align: center; font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.stepper .st-c input.st-v { border: 0; background: transparent; padding: 0; }
.stepper.has-val .st-v { color: var(--yellow-deep); }

.secrow { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.secrow input { border: 1.5px solid var(--stone-2); border-radius: 10px; padding: 10px; font-size: 16px; text-align: center; }
.secrow .x { color: var(--stone-3); font-weight: 600; flex: none; }
.secrow .del { flex: none; width: 34px; height: 34px; color: var(--stone-3); font-size: 18px; }
.calc-out {
  background: var(--dark); color: #fff; border-radius: 12px; padding: 13px 15px; margin-top: 12px;
  display: flex; align-items: baseline; gap: 8px;
}
.calc-out .co-v { font-size: 22px; font-weight: 750; color: var(--yellow); font-variant-numeric: tabular-nums; }
.calc-out .co-l { font-size: 12px; color: var(--stone-3); }
.calc-out .co-d { margin-left: auto; font-size: 11px; color: var(--stone-3); text-align: right; }

/* toggle */
.tgl { position: relative; width: 48px; height: 28px; flex: none; }
.tgl input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; z-index: 2; }
.tgl .tr { position: absolute; inset: 0; background: var(--stone-2); border-radius: 99px; transition: background .15s; }
.tgl .tr::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 99px;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: left .15s;
}
.tgl input:checked + .tr { background: var(--yellow); }
.tgl input:checked + .tr::after { left: 23px; }

/* wizard footer */
.wizfoot {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  max-width: 640px; margin: 0 auto;
  background: var(--dark); padding: 10px 16px calc(12px + var(--safe-b));
  display: flex; align-items: center; gap: 12px;
  border-top: 1px solid #26272b;
}
@media (min-width: 640px) { .wizfoot { left: 50%; transform: translateX(-50%); width: 640px; } }
.wizfoot .wf-tot { color: #fff; flex: 1; }
.wizfoot .wf-tot .wf-l { font-size: 10.5px; color: var(--stone-3); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.wizfoot .wf-tot .wf-v { font-size: 20px; font-weight: 750; color: var(--yellow); font-variant-numeric: tabular-nums; }
.wizfoot .btn { width: auto; min-width: 128px; }

/* ---------- Line items ---------- */
.lgroup { margin-bottom: 4px; }
.lgroup .lg-t {
  font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .07em;
  color: var(--stone-4); padding: 10px 0 6px;
}
.litem { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--stone-1); }
.litem .li-d { flex: 1; min-width: 0; }
.litem .li-n { font-size: 13.5px; font-weight: 550; line-height: 1.3; }
.litem .li-m { font-size: 11.5px; color: var(--stone-4); margin-top: 1px; font-variant-numeric: tabular-nums; }
.litem .li-p { font-weight: 700; font-size: 14.5px; font-variant-numeric: tabular-nums; flex: none; }
.litem .li-e { flex: none; width: 30px; height: 30px; border-radius: 8px; color: var(--stone-3); display: flex; align-items: center; justify-content: center; }
.litem .li-e svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; }

.totrow { display: flex; justify-content: space-between; padding: 7px 0; font-size: 14px; }
.totrow .tr-l { color: var(--stone-5); }
.totrow .tr-v { font-weight: 650; font-variant-numeric: tabular-nums; }
.totrow.grand { border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 12px; }
.totrow.grand .tr-l { font-weight: 750; color: var(--ink); font-size: 16px; }
.totrow.grand .tr-v { font-weight: 800; font-size: 20px; }
.totrow.internal { background: var(--stone-1); margin: 8px -16px -16px; padding: 10px 16px 12px; border-radius: 0 0 var(--radius) var(--radius); }
.totrow.internal .tr-l, .totrow.internal .tr-v { color: var(--stone-4); font-size: 12px; }

/* ---------- Preview / quote doc ---------- */
.qdoc { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px; }
.qdoc .qd-head { background: var(--dark); color: #fff; padding: 18px 18px 16px; }
.qdoc .qd-head img { height: 30px; margin-bottom: 10px; }
.qdoc .qd-head .qd-t { font-size: 19px; font-weight: 750; color: var(--yellow); }
.qdoc .qd-head .qd-m { font-size: 11.5px; color: var(--stone-3); margin-top: 3px; font-family: 'Geist Mono', monospace; }
.qdoc .qd-body { padding: 16px 18px; }
.qdoc .qd-sec { margin-bottom: 14px; }
.qdoc .qd-sec h3 { font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; color: var(--stone-4); margin-bottom: 6px; }
.qdoc .qd-sec p, .qdoc .qd-sec li { font-size: 13px; color: var(--stone-6); }
.qdoc .qd-sec ul { padding-left: 18px; }
.qdoc .qd-sec li { margin-bottom: 3px; }

/* ---------- Modal ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(5,5,5,.55); z-index: 90;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadein .15s ease;
}
@keyframes fadein { from { opacity: 0; } }
.modal {
  background: var(--paper); border-radius: 18px 18px 0 0; width: 100%; max-width: 640px;
  max-height: 88dvh; overflow-y: auto; padding: 18px 18px calc(20px + var(--safe-b));
  animation: slideup .2s ease;
}
@keyframes slideup { from { transform: translateY(40px); opacity: .5; } }
.modal .mo-bar { width: 40px; height: 4px; background: var(--stone-2); border-radius: 99px; margin: -6px auto 14px; }
.modal h3 { font-size: 16px; font-weight: 700; margin-bottom: 14px; }

/* ---------- Price book / settings ---------- */
.pb-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--stone-1); }
.pb-row:last-child { border-bottom: 0; }
.pb-row .pb-l { flex: 1; font-size: 13.5px; font-weight: 550; line-height: 1.3; min-width: 0; }
.pb-row .pb-l small { display: block; color: var(--stone-3); font-size: 11px; font-weight: 500; }
.pb-row .pb-in { position: relative; flex: none; width: 108px; }
.pb-row .pb-in input {
  border: 1.5px solid var(--stone-2); border-radius: 9px; padding: 8px 8px 8px 22px;
  font-size: 15px; text-align: right; font-variant-numeric: tabular-nums;
}
.pb-row .pb-in::before { content: '$'; position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--stone-3); font-size: 13px; z-index: 1; }
.pb-row .pb-in.pct::before { content: ''; }
.pb-row .pb-in.pct::after { content: '%'; position: absolute; right: 9px; top: 50%; transform: translateY(-50%); color: var(--stone-3); font-size: 13px; }
.pb-row .pb-in.pct input { padding: 8px 24px 8px 8px; }
.pb-row .pb-u { flex: none; font-size: 11px; color: var(--stone-3); width: 40px; }

.toast {
  position: fixed; bottom: calc(86px + var(--safe-b)); left: 50%; transform: translateX(-50%);
  background: var(--dark); color: #fff; font-size: 13.5px; font-weight: 550;
  padding: 11px 18px; border-radius: 12px; z-index: 100; box-shadow: 0 6px 24px rgba(0,0,0,.3);
  white-space: nowrap; animation: toastin .2s ease;
}
.toast b { color: var(--yellow); }
@keyframes toastin { from { transform: translate(-50%, 12px); opacity: 0; } }

.note-hvhz {
  background: #fffbeb; border: 1px solid #fde047; border-radius: 10px;
  padding: 10px 12px; font-size: 12px; color: var(--yellow-deep); margin-top: 12px; line-height: 1.45;
}

/* ---------- Sync badge ---------- */
.sync-badge {
  margin-left: auto; font-size: 11px; font-weight: 650; padding: 4px 10px; border-radius: 99px;
  white-space: nowrap; letter-spacing: .01em; display: flex; align-items: center; gap: 5px;
}
.sync-badge::before { content: ''; width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.sync-badge.ok { background: rgba(21,128,61,.18); color: #86efac; }
.sync-badge.busy { background: rgba(255,196,0,.18); color: var(--yellow); }
.sync-badge.off { background: #26272b; color: var(--stone-3); }
header.topbar .sync-badge + .tb-right:empty { margin-left: 0; }

/* ---------- Login screen ---------- */
body.logged-out header.topbar .tb-right,
body.logged-out header.topbar .sync-badge { display: none !important; }
.login { max-width: 380px; margin: 0 auto; padding: 24px 4px 40px; text-align: center; }
.login-logo {
  width: 88px; height: 88px; margin: 18px auto 18px; border-radius: 22px; background: var(--dark);
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow);
}
.login-logo img { width: 58px; height: auto; }
.login h1 { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.login-sub { font-size: 13.5px; color: var(--stone-4); margin: 6px 0 22px; }
.login-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; text-align: left; }
.login-card .field label { font-size: 12px; }
.login-card .btn { margin-top: 6px; }
.login-msg { font-size: 12.5px; color: var(--stone-4); margin-top: 10px; text-align: center; min-height: 16px; }
.login-msg.err { color: var(--red); font-weight: 600; }
.login-foot { font-size: 11.5px; color: var(--stone-3); margin-top: 20px; line-height: 1.5; }
