/* Aurora Quotes: brand tokens match site/styles.css */
:root {
  --bg: #0C0D10;
  --surface: #16181C;
  --surface-2: #1E2126;
  --text: #F5F6F7;
  --muted: #A2A8B1;
  --green: #2EE89C;
  --green-ink: #00170D;
  --violet: #9D72D9;
  --danger: #FF7A7A;
  --aurora: linear-gradient(100deg, var(--green) 0%, #5FC7C0 55%, var(--violet) 100%);
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.26);
  --font: "Archivo", system-ui, -apple-system, sans-serif;
  --font-display: "Montserrat", "Archivo", system-ui, sans-serif;
  --r: 16px;
  --gut: clamp(16px, 3vw, 32px);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2 { margin: 0; font-family: var(--font-display); font-weight: 400; letter-spacing: -0.01em; }
h1 { font-size: clamp(28px, 4vw, 40px); }
h2 { font-size: 15px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 14px; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.pre { white-space: pre-wrap; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) var(--gut) 10px;
  background: rgba(12, 13, 16, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-logo { height: 34px; width: auto; }
.topbar-right { justify-self: end; display: flex; gap: 8px; align-items: center; }
.qnum { color: var(--muted); font-size: 15px; }
body[data-view="sign"] .topbar { display: none; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font: 600 16px/1 var(--font);
  cursor: pointer;
  text-align: center;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--green); border-color: var(--green); color: var(--green-ink); }
.btn.big { min-height: 56px; font-size: 17px; padding: 0 22px; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.danger { color: var(--danger); border-color: rgba(255, 122, 122, 0.4); }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.back { padding-left: 12px; }

input, textarea, select {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.3 var(--font);
  outline: none;
}
input[type="date"] { -webkit-appearance: none; appearance: none; display: flex; align-items: center; }
textarea { resize: vertical; }
input:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(46, 232, 156, 0.2); }
input::placeholder, textarea::placeholder { color: #6B717A; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
fieldset:disabled { opacity: 0.6; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 14px; color: var(--muted); }
.field > small { color: var(--muted); font-size: 13px; }

input[type="range"] { padding: 0; min-height: 44px; border: 0; background: none; accent-color: var(--green); box-shadow: none; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }

.chip { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; border: 1px solid var(--line-strong); color: var(--muted); }
.chip.sent { color: #B9A0E8; border-color: rgba(157, 114, 217, 0.5); }
.chip.signed { color: var(--green-ink); background: var(--green); border-color: var(--green); }

.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 12px; padding: 3px; }
.seg button { min-height: 42px; padding: 0 16px; border: 0; border-radius: 9px; background: none; color: var(--muted); font: 600 15px var(--font); cursor: pointer; }
.seg button.on { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.seg.small button { min-height: 40px; }

/* switch */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; cursor: pointer; }
.switch-row span { display: grid; gap: 2px; }
.switch-row small { color: var(--muted); font-size: 14px; }
.switch { -webkit-appearance: none; appearance: none; flex: none; width: 56px; min-height: 0; height: 32px; padding: 0; border-radius: 99px; border: 0; background: #3A3E45; position: relative; cursor: pointer; transition: background 0.2s; box-shadow: none !important; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(24px); }
.switch:disabled { opacity: 0.4; }

/* ---------- list ---------- */
.list-view, .settings { max-width: 980px; margin: 0 auto; padding: 28px var(--gut) 60px; }
.list-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; }
.list-head p { margin-top: 6px; }
.list-tools { display: flex; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.list-tools input { flex: 1 1 280px; }
.qlist { display: grid; gap: 10px; }
.qrow { display: flex; align-items: center; gap: 8px; }
.qrow .qcard { flex: 1; min-width: 0; }
.qrow .qdel { flex: none; width: 52px; height: 52px; display: grid; place-items: center; }
button.qdel:active { color: var(--danger); }
.list-bulk { display: flex; justify-content: flex-end; margin-top: 16px; }
.qcard { display: flex; justify-content: space-between; gap: 16px; padding: 16px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.qcard:active { background: var(--surface-2); }
.qcard-main, .qcard-side { display: grid; gap: 3px; align-content: start; }
.qcard-main { min-width: 0; }
.qcard-main b, .qcard-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qcard-side { justify-items: end; text-align: right; }
.qcard-side b { font-size: 19px; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--r); }

/* ---------- editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; max-width: 1240px; margin: 0 auto; padding: 22px var(--gut) 40px; align-items: start; }
.editor-side { position: sticky; top: calc(env(safe-area-inset-top) + 78px); display: grid; gap: 14px; }
.side-actions { display: grid; gap: 10px; }
.side-row { display: flex; gap: 10px; }
.side-row > * { flex: 1; }

.banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 12px 12px 18px; margin-bottom: 16px; border-radius: var(--r); background: rgba(46, 232, 156, 0.1); border: 1px solid rgba(46, 232, 156, 0.4); }

.sec-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 110px 44px; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.sec-row:first-child { padding-top: 0; }
.stepper { display: flex; align-items: center; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 12px; overflow: hidden; }
.stepper button { width: 50px; height: 50px; border: 0; background: none; color: var(--text); font-size: 24px; cursor: pointer; }
.stepper button:active { background: var(--surface-2); }
.stepper input { width: 80px; min-height: 50px; border: 0; border-radius: 0; text-align: right; padding: 0 4px; font-size: 20px; font-weight: 600; background: none; box-shadow: none; }
.stepper .unit { color: var(--muted); padding: 0 4px 0 4px; }
.sec-amt { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.icon-btn { width: 44px; height: 44px; border: 0; border-radius: 10px; background: none; color: var(--muted); font-size: 18px; cursor: pointer; }
.icon-btn:active { background: var(--surface-2); color: var(--danger); }

.add-chips, .rate-chips, .pct-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.add-chips button, .rate-chips button, .pct-chips button {
  min-height: 42px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line-strong);
  background: none; color: var(--text); font: 600 15px var(--font); cursor: pointer;
}
.rate-chips button, .pct-chips button { min-width: 62px; }
.rate-chips button.on, .pct-chips button.on { background: var(--green); border-color: var(--green); color: var(--green-ink); }
.add-chips button:active { background: var(--surface-2); }

.rate-big { font-family: var(--font-display); font-size: 34px; font-weight: 500; }
.rate-big small { font-size: 16px; color: var(--muted); margin-left: 2px; }
.range-ends { display: flex; justify-content: space-between; }

.disc { padding: 4px 0; border-bottom: 1px solid var(--line); }
.disc:last-child { border-bottom: 0; }
.disc-detail { padding: 2px 0 14px; display: grid; gap: 8px; }
.disc-detail .pct-chips { margin-top: 0; }
.disc-detail output { color: var(--green); font-weight: 600; }
.disc-detail.custom { grid-template-columns: auto 120px 1fr; align-items: center; }
.warn { color: #FFC478; font-size: 14px; padding-bottom: 10px; }

.summary { padding: 22px; }
.sum-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.sum-feet { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 14px; margin-bottom: 10px; border-bottom: 1px solid var(--line); }
.sum-feet b { font-family: var(--font-display); font-size: 26px; font-weight: 500; }
.sum-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-variant-numeric: tabular-nums; }
.disc-line { color: var(--green); }
.sum-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--line-strong); }
.sum-total b { font-family: var(--font-display); font-size: 38px; font-weight: 500; background: var(--aurora); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sum-note { margin-top: 6px; text-align: right; }

.mobile-bar { display: none; }

/* photos */
.switch-row.inline { min-height: 0; gap: 10px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.thumb { aspect-ratio: 4 / 3; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg); cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-btns { margin-top: 14px; }
.photo-btns .btn { cursor: pointer; }
.lightbox { width: min(1100px, 96vw); max-height: 94dvh; padding: 0; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); color: var(--text); overflow: hidden; }
.lightbox::backdrop { background: rgba(0, 0, 0, 0.8); }
.lightbox img { display: block; width: 100%; max-height: calc(94dvh - 90px); object-fit: contain; background: #000; }
.lightbox-bar .btn { white-space: nowrap; }
.lightbox-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; flex-wrap: wrap; }

/* ---------- customer review & sign ---------- */
.sign { max-width: 1000px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 24px) var(--gut) 48px; }
.sign-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 28px; text-align: right; }
.sign-head img { height: 52px; width: auto; }
.sign h1 { margin-bottom: 6px; }
.sign > .muted { margin-bottom: 22px; font-size: 19px; }
.sign-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; align-items: start; }
.sign-grid .card + .card { margin-top: 0; }
.sign-card { margin-top: 16px; }
.lines { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.lines th { text-align: left; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; padding: 0 0 10px; }
.lines td { padding: 9px 0; border-top: 1px solid var(--line); }
.lines th:not(:first-child), .lines td:not(:first-child) { text-align: right; }
.lines tfoot td { border-top: 0; padding: 5px 0; }
.lines tfoot tr:first-child td { border-top: 1px solid var(--line-strong); padding-top: 12px; }
.lines .grand td { padding-top: 14px; font-family: var(--font-display); font-size: 30px; font-weight: 500; }
.saves { margin-top: 6px; text-align: right; color: var(--green); font-weight: 600; }
.incl { margin: 0 0 18px; padding: 0; list-style: none; display: grid; gap: 10px; }
.incl li { position: relative; padding-left: 30px; }
.incl li::before { content: ""; position: absolute; left: 0; top: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--green) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5.5 10.5l3 3 6-7' fill='none' stroke='%2300170D' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/100% no-repeat; }
.terms { color: var(--muted); margin-bottom: 16px; }
.sign-card .field { max-width: 420px; margin-bottom: 14px; }
.pad-wrap { position: relative; height: 220px; border-radius: 14px; background: #fff; overflow: hidden; }
#pad { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.pad-hint { position: absolute; left: 24px; bottom: 44px; right: 24px; border-bottom: 2px solid #C9CDD3; color: #8A9099; font-size: 15px; padding-bottom: 4px; pointer-events: none; }
#pad-clear { position: absolute; top: 10px; right: 10px; color: #333; border-color: #ccc; }
.sig-done { background: #fff; color: #111; border-radius: 14px; padding: 16px 20px; }
.sig-done img { max-height: 120px; width: auto; max-width: 100%; }
.sig-done p { border-top: 1px solid #ddd; padding-top: 8px; margin-top: 6px; }
.sign-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; }

/* ---------- settings ---------- */
.settings h1 { margin-bottom: 20px; }
.settings .card .field + .field { margin-top: 14px; }
.settings .grid2 + .field, .settings .grid3 + .field, .settings .switch-row + .grid3 { margin-top: 14px; }
.settings p.muted { margin-bottom: 14px; }
.settings label.btn { cursor: pointer; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 90px); z-index: 50;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: min(560px, calc(100vw - 32px)); padding: 12px 18px; border-radius: 12px;
  background: #F5F6F7; color: #0C0D10; font-weight: 600; text-align: center;
  transition: opacity 0.2s, transform 0.2s; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- iPad portrait & smaller ---------- */
@media (max-width: 960px) {
  .editor { grid-template-columns: 1fr; padding-bottom: 120px; }
  .editor-side { position: static; }
  .mobile-bar {
    display: flex; justify-content: space-between; align-items: center; gap: 16px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 9;
    padding: 12px var(--gut) calc(env(safe-area-inset-bottom) + 12px);
    background: rgba(22, 24, 28, 0.94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }
  .mobile-bar div { display: grid; }
  .mobile-bar b { font-family: var(--font-display); font-size: 26px; font-weight: 500; }
  .sign-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .sec-row { grid-template-columns: minmax(0, 1fr) 44px; }
  .sec-row .stepper { grid-column: 1; }
  .sec-row .sec-amt { grid-column: 2; grid-row: 1; display: none; }
  .disc-detail.custom { grid-template-columns: 1fr; }
  .topbar-logo { height: 26px; }
}
