/* =========================================================================
   RPM Quote Calculator — STYLES
   Brand colours are placeholders: change --brand / --brand-ink to RPM's.
   ========================================================================= */
:root {
  --brand: #ffb020;          /* RPM primary (placeholder) */
  --brand-ink: #1a1200;      /* text on brand */
  --bg: #0d1117;
  --bg-2: #121821;
  --card: #161d27;
  --card-2: #1c2531;
  --line: #263142;
  --text: #e8edf3;
  --muted: #8a97a8;
  --ok: #3ccf91;
  --warn: #ffb020;
  --night: #8b9cff;
  --radius: 18px;
  --shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 10px 30px -12px rgba(0,0,0,.55);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f7; --bg-2: #eceef2; --card: #ffffff; --card-2: #f6f7f9; --line: #e2e6ec;
    --text: #121721; --muted: #5e6b7c; --ok: #12925e; --warn: #b26b00; --night: #4b5ce0;
    --shadow: 0 1px 2px rgba(16,24,40,.05), 0 8px 24px -14px rgba(16,24,40,.18);
    color-scheme: light;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  font-size: 16px; line-height: 1.4; min-height: 100dvh;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
  background-image: radial-gradient(1200px 400px at 50% -200px, color-mix(in srgb, var(--brand) 10%, transparent), transparent);
  background-repeat: no-repeat;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
h2, h3 { margin: 0; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-weight: 900; font-size: 13px; letter-spacing: .04em;
  background: var(--brand); color: var(--brand-ink);
  box-shadow: 0 6px 18px -6px color-mix(in srgb, var(--brand) 70%, transparent);
}
.brand img { height: 42px; width: auto; }
.brand-title { font-weight: 750; font-size: 17px; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); display: grid; place-items: center; color: var(--muted);
}
.icon-btn:active { transform: scale(.95); }

/* ---------- categories ---------- */
.cats {
  display: flex; gap: 8px; overflow-x: auto; padding: 14px 16px 6px;
  scrollbar-width: none; scroll-snap-type: x proximity;
}
.cats::-webkit-scrollbar { display: none; }
.cat {
  flex: none; scroll-snap-align: start;
  display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--card);
  color: var(--muted); font-weight: 600; font-size: 14px; transition: .15s;
}
.cat.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); box-shadow: 0 6px 20px -8px color-mix(in srgb, var(--brand) 80%, transparent); }

/* ---------- layout ---------- */
.layout { display: grid; gap: 14px; padding: 10px 16px 16px; max-width: 1180px; margin: 0 auto; }
.form, .results { display: grid; gap: 14px; align-content: start; min-width: 0; }
@media (min-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 22px; padding-top: 16px; }
  .results { padding-bottom: 40px; }
  body { padding-bottom: 140px; }
  .cats { justify-content: center; }
}

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card:empty { display: none; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.muted { color: var(--muted); font-size: 13px; }
.info { margin: 0; color: var(--muted); font-size: 15px; }

/* ---------- fields ---------- */
.grid2, .grid3 { display: grid; gap: 12px; }
.grid2 { grid-template-columns: 1fr 1fr; }
.grid3 { grid-template-columns: 1fr 1fr; }
.grid3 .span3-sm { grid-column: 1 / -1; }
@media (min-width: 520px) { .grid3 { grid-template-columns: 1.4fr 1fr 1fr; } .grid3 .span3-sm { grid-column: auto; } }
.grid2 + .switch, .seg + .field { margin-top: 12px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 600; }
.field small { font-size: 12px; color: var(--muted); }
input[type=date], input[type=time], input[type=number], select {
  width: 100%; height: 50px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card-2); outline: none;
  font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; appearance: none; -webkit-appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
input::-webkit-calendar-picker-indicator { filter: invert(var(--invert, .7)); opacity: .8; }
@media (prefers-color-scheme: light) { input::-webkit-calendar-picker-indicator { --invert: 0; } }
.input-affix { display: flex; align-items: center; position: relative; }
.input-affix em { font-style: normal; color: var(--muted); font-weight: 600; position: absolute; pointer-events: none; }
.input-affix em:first-child { left: 14px; }
.input-affix em:last-child { right: 14px; }
.input-affix em:first-child + input { padding-left: 28px; }
.input-affix input:not(:last-child) { padding-right: 46px; }
.select-wrap { position: relative; }
.select-wrap::after {
  content: ""; position: absolute; right: 16px; top: 50%; width: 8px; height: 8px; margin-top: -6px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); pointer-events: none;
}
select { padding-right: 40px; text-overflow: ellipsis; }

.timing-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 4px; font-size: 14px; color: var(--muted); }
.timing-meta b { color: var(--text); }
.dot { width: 4px; height: 4px; border-radius: 50%; background: var(--line); }
.warn-text { color: var(--warn); font-weight: 600; }

.pill { font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 999px; letter-spacing: .02em; }
.pill-ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.pill-warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 15%, transparent); }
.pill-night { color: var(--night); background: color-mix(in srgb, var(--night) 16%, transparent); }

/* switch */
.switch { display: flex; align-items: center; gap: 12px; padding: 12px 0 2px; cursor: pointer; }
.switch + .switch { border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent); margin-top: 10px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.track { width: 48px; height: 28px; flex: none; border-radius: 999px; background: var(--line); position: relative; transition: .2s; }
.thumb { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track .thumb { transform: translateX(20px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 35%, transparent); }
.switch-label { display: grid; font-weight: 600; font-size: 15px; }
.switch-label small { font-weight: 500; font-size: 12.5px; color: var(--muted); }

/* segmented */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { height: 40px; border: 0; border-radius: 9px; background: transparent; font-weight: 650; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.25); }

/* stepper */
.stepper { display: grid; grid-template-columns: 50px 1fr 50px; height: 50px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card-2); }
.stepper button { border: 0; background: transparent; font-size: 22px; font-weight: 600; }
.stepper button:active { background: var(--line); }
.stepper output { display: grid; place-items: center; font-weight: 750; font-size: 18px; font-variant-numeric: tabular-nums; }

/* size picker */
.sizes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 520px) { .sizes { grid-template-columns: repeat(3, 1fr); } }
.size {
  text-align: left; padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--card-2); display: grid; gap: 8px; transition: .15s;
}
.size strong { font-size: 15px; }
.size .tags { display: flex; gap: 5px; }
.size i { font-style: normal; font-size: 10.5px; font-weight: 800; letter-spacing: .06em; padding: 3px 6px; border-radius: 6px; background: var(--line); color: var(--muted); }
.size.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, var(--card-2)); }
.size.on i { background: color-mix(in srgb, var(--brand) 25%, transparent); color: var(--text); }

/* ---------- results ---------- */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt {
  text-align: left; border-radius: var(--radius); border: 1.5px solid var(--line); background: var(--card);
  padding: 14px; display: grid; gap: 4px; box-shadow: var(--shadow); transition: .15s;
}
.opt.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 9%, var(--card)); }
.opt-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.opt-name { font-size: 13px; font-weight: 700; color: var(--muted); }
.opt-total { font-size: clamp(20px, 6vw, 26px); font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.opt-sub { font-size: 12px; color: var(--muted); }
.badge { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: 3px 7px; border-radius: 6px; color: var(--ok); background: color-mix(in srgb, var(--ok) 16%, transparent); }
.delta, .only { margin: -4px 2px 0; font-size: 13px; color: var(--muted); }

.quote { padding: 18px; }
.q-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding-bottom: 14px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.q-sup { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--brand); }
.q-head h3 { font-size: 20px; letter-spacing: -.01em; margin-top: 2px; }
.q-hours { text-align: right; display: grid; }
.q-hours b { font-size: 24px; font-variant-numeric: tabular-nums; }
.q-hours span { font-size: 12px; color: var(--muted); }
.ln { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px dashed color-mix(in srgb, var(--line) 80%, transparent); }
.ln-label { font-weight: 600; font-size: 15px; }
.ln-calc { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ln-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.atcost { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; margin-left: 4px; }
.ln-group { margin-top: 14px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.sum { margin-top: 14px; padding: 14px; border-radius: 14px; background: var(--card-2); display: grid; gap: 8px; }
.sum > div { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
.sum span { color: var(--muted); }
.sum .grand { padding-top: 10px; border-top: 1px solid var(--line); font-size: 18px; }
.sum .grand span { color: var(--text); font-weight: 650; }
.notes { margin: 14px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; display: grid; gap: 4px; }
.poa { font-size: 40px; font-weight: 900; color: var(--brand); padding: 10px 0; }
.empty { color: var(--muted); text-align: center; padding: 28px; }

/* ---------- total bar ---------- */
.totalbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: saturate(160%) blur(16px); -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid var(--line);
}
@media (min-width: 960px) {
  .totalbar { left: 50%; right: auto; transform: translateX(-50%); bottom: 16px; width: min(760px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 20px 40px -16px rgba(0,0,0,.5); padding-bottom: 12px; }
}
.tb-label { font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.tb-total { font-size: 26px; font-weight: 850; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tb-sub { font-size: 12px; color: var(--muted); }
.btn-primary {
  display: inline-flex; align-items: center; gap: 8px; height: 50px; padding: 0 20px; border-radius: 14px; border: 0;
  background: var(--brand); color: var(--brand-ink); font-weight: 750; font-size: 15px; flex: none;
  box-shadow: 0 8px 22px -8px color-mix(in srgb, var(--brand) 80%, transparent);
}
.btn-primary:active { transform: scale(.97); }
.btn-primary:disabled { opacity: .4; box-shadow: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); font-weight: 650; padding: 10px 18px; border-radius: 999px;
  opacity: 0; transition: .25s; pointer-events: none; z-index: 40;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- margin ---------- */
.chips { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.chips button { height: 50px; border-radius: 12px; border: 1px solid var(--line); background: var(--card-2); font-weight: 700; font-size: 13.5px; color: var(--muted); padding: 0; }
.chips button.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.mk-warn { margin: 10px 0 0; font-size: 13px; font-weight: 600; min-height: 0; }
.mk-warn:empty { display: none; }
.mk-warn.low { color: #ff6b6b; }
.mk-warn.high { color: var(--ok); }
.margin-box { margin-top: 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.margin-box > div { background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 2px; }
.margin-box span { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.margin-box b { font-size: 16px; font-variant-numeric: tabular-nums; }
.margin-box b.pos { color: var(--ok); }
.ln-cost { opacity: .75; }
.opt-margin { font-size: 12px; font-weight: 650; color: var(--ok); }
.switch.disabled { opacity: .5; cursor: not-allowed; }
.mk-row { display: grid; gap: 12px; }
@media (min-width: 520px) { .mk-row { grid-template-columns: 140px 1fr; } }
.mk-hint { margin: 10px 0 0; font-size: 12.5px; color: var(--muted); }

.margin-ln { margin-top: 10px; padding: 12px; border: 1.5px dashed color-mix(in srgb, var(--ok) 55%, transparent); border-radius: 12px; background: color-mix(in srgb, var(--ok) 8%, transparent); }
.margin-ln .ln-amt, .margin-ln .ln-label { color: var(--ok); }
.margin-ln.zero { border-color: color-mix(in srgb, #ff6b6b 55%, transparent); background: color-mix(in srgb, #ff6b6b 7%, transparent); }
.margin-ln.zero .ln-amt, .margin-ln.zero .ln-label { color: #ff6b6b; }

/* ---------- multi-item quote ---------- */
#current, #jobPanel { display: grid; gap: 14px; min-width: 0; }
#jobPanel:empty { display: none; }
.mt { margin-top: 14px; }
.btn-add {
  margin-top: 16px; width: 100%; height: 52px; border-radius: 14px; border: 1.5px dashed var(--brand);
  background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--text);
  font-weight: 750; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-add svg { color: var(--brand); }
.btn-add:active { transform: scale(.98); }
.job { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.job input[type=text] {
  width: 100%; height: 50px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card-2); outline: none; font-size: 16px; font-weight: 600;
}
.job input[type=text]:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
.link-btn { border: 0; background: none; color: #ff6b6b; font-weight: 650; font-size: 13px; padding: 4px; }
.job-items { display: grid; gap: 10px; margin-top: 14px; }
.job-item { border: 1px solid var(--line); border-radius: 14px; background: var(--card-2); overflow: hidden; }
.ji-main { display: flex; gap: 12px; align-items: flex-start; padding: 12px; }
.ji-num { width: 28px; height: 28px; flex: none; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: 13px; background: var(--brand); color: var(--brand-ink); }
.ji-text { flex: 1; min-width: 0; }
.ji-title { font-weight: 700; font-size: 15px; }
.ji-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.ji-amt { text-align: right; display: grid; white-space: nowrap; }
.ji-amt b { font-variant-numeric: tabular-nums; }
.ji-amt span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ji-actions { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.ji-actions button { height: 40px; border: 0; background: transparent; font-size: 13px; font-weight: 650; color: var(--muted); }
.ji-actions button + button { border-left: 1px solid var(--line); }
.ji-actions .danger { color: #ff6b6b; }
.totalbar.has-job .tb-label { color: var(--brand); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- hourly rates ---------- */
.rates { margin: 4px 0 6px; display: grid; gap: 10px; }
.rates-head { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding-top: 6px; }
.rates-head .ok { color: var(--ok); }
.rates-head .warn { color: #ff6b6b; }
.rate { border-radius: 14px; padding: 14px; background: color-mix(in srgb, var(--brand) 9%, var(--card-2)); border: 1.5px solid color-mix(in srgb, var(--brand) 45%, var(--line)); }
.rate.ot { background: color-mix(in srgb, var(--night) 9%, var(--card-2)); border-color: color-mix(in srgb, var(--night) 40%, var(--line)); }
.rate-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.rate-label { font-weight: 750; font-size: 15px; }
.rate-sub { font-size: 12px; color: var(--muted); }
.rate-val { font-size: clamp(24px, 7vw, 30px); font-weight: 850; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rate-val small { font-size: 14px; font-weight: 650; color: var(--muted); margin-left: 2px; }
.rate-split { margin-top: 6px; font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rate-foot { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); display: flex; justify-content: space-between; font-size: 13.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rate-foot b { color: var(--text); }
.rate-cost { margin-top: 4px; font-size: 11.5px; color: var(--muted); }
.opt-rates { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ji-rates { font-size: 12.5px; font-weight: 700; margin-top: 3px; font-variant-numeric: tabular-nums; }
.tb-actions { display: flex; gap: 8px; flex: none; }
.btn-ghost { height: 50px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card-2); font-weight: 700; font-size: 13.5px; color: var(--muted); }
.btn-ghost:disabled { opacity: .4; }
@media (max-width: 380px) { .btn-primary { padding: 0 14px; } .btn-ghost { padding: 0 10px; } }
.totalbar > div:first-child { min-width: 0; flex: 1; }
@media (max-width: 480px) {
  .totalbar { gap: 10px; padding-left: 14px; padding-right: 14px; }
  .tb-total { font-size: 22px; }
  .tb-sub { font-size: 11px; }
  .tb-actions { gap: 6px; }
  .btn-primary { padding: 0 14px; font-size: 14px; height: 48px; }
  .btn-primary svg { display: none; }
  .btn-ghost { padding: 0 10px; font-size: 13px; height: 48px; }
}

.preload-hrs { margin-top: 12px; }
