:root {
  --ink: #101114;         /* near-black base */
  --ink-2: #474a50;
  --ink-3: #85888e;
  --line: #e4e5e8;
  --bg: #f5f6f7;
  --card: #ffffff;
  --brand: #e0301f;        /* PowerHouse logo red */
  --brand-ink: #b42415;
  --go: #1f9d55;
  --stop: #c0392b;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(16, 18, 22, .04), 0 8px 24px rgba(16, 18, 22, .05);
  --side: 252px;
  --side-bg: #231f20;         /* the logo's own background */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* ── Chrome ──────────────────────────────────────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px;
  background: #231f20;
  border-bottom: 3px solid var(--brand);
}
.topbar .logo { height: 34px; width: auto; display: block; }
.topbar .spacer { flex: 1; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  padding: 6px 11px; border-radius:var(--radius-sm); text-decoration: none;
  color: #b9bcc1; font-size: 13px; font-weight: 600;
}
.topbar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.topbar nav a[aria-current="page"] { background: var(--brand); color: #fff; }
.topbar select {
  width: auto; background: rgba(255,255,255,.07); color: #e6e7e9;
  border-color: rgba(255,255,255,.14); font-size: 13px; padding: 6px 9px;
}
.topbar .who { font-size: 12px; color: #9da1a7; font-weight: 600; white-space: nowrap; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 20px 18px 96px; }
.wrap.narrow { max-width: 860px; }

/* ── Cards ───────────────────────────────────────────────────────────────── */

.card {
  background: var(--card); border: 1px solid rgba(16, 18, 22, .05);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; margin-bottom: 16px;
}
.card > h2 {
  margin: 0 0 14px; font-size: 18px; font-weight: 700;
  letter-spacing: -.01em; color: var(--ink);
}

/* ── Forms ───────────────────────────────────────────────────────────────── */

label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }

input, select, textarea, button {
  font: inherit; color: inherit;
}
input[type="text"], input[type="email"], input[type="tel"], input[type="number"],
input[type="password"], input[type="search"],
select, textarea {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand);
}
textarea { min-height: 74px; resize: vertical; }

.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 720px) { .grid.two, .grid.four { grid-template-columns: 1fr; } }

button {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
button:hover { background: var(--bg); }
button.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
button.primary:hover { background: #000; }
button.brand { background: var(--brand); border-color: var(--brand); color: #fff; }
button.brand:hover { background: var(--brand-ink); }
button.ghost { border-color: transparent; background: transparent; color: var(--ink-3); }
button.ghost:hover { color: var(--stop); background: transparent; }
button:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Line editor ─────────────────────────────────────────────────────────── */

/* Jump between trades without stepping back through every screen. */
.tradetabs {
  display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 12px;
}
.tradetabs button {
  font-size: 13px; font-weight: 700; padding: 7px 13px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2); cursor: pointer;
}
.tradetabs button.on { background: var(--ink); border-color: var(--ink); color: #fff; }

/* A trade you can switch off and back on, rather than delete. */
.sum-row.switchable { cursor: pointer; gap: 12px; align-items: center; }
.sum-row.switchable span { flex: 1 1 auto; }
.sum-row.switchable input { width: auto; margin: 0; flex: 0 0 auto; }
.sum-row.switchable.off span,
.sum-row.switchable.off strong { color: var(--ink-3); text-decoration: line-through; }
.sum-row.switchable.off strong { text-decoration: none; font-weight: 600; font-style: italic; }

tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--bg); }

.trade-block { margin-bottom: 22px; }
.trade-block > h3 {
  font-size: 12px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-3); margin: 0 0 8px; font-weight: 700;
}

.line {
  display: grid; grid-template-columns: 1fr 116px 120px 36px;
  gap: 8px; align-items: center; margin-bottom: 7px;
}
@media (max-width: 720px) {
  .line { grid-template-columns: 1fr 88px 1fr 34px; }
}
.line .amount {
  text-align: right; font-variant-numeric: tabular-nums;
  font-weight: 600; padding-right: 2px;
}
.line .unit { font-size: 12px; color: var(--ink-3); }

.combo { position: relative; }
.combo-menu {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
  background: #fff; border: 1px solid var(--line); border-radius:var(--radius-sm);
  box-shadow: 0 10px 30px rgba(16,18,22,.14);
  max-height: 300px; overflow-y: auto; padding: 4px;
}
.combo-menu[hidden] { display: none; }
.combo-option {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
}
.combo-option:hover, .combo-option.active { background: var(--bg); }
.combo-option .name { font-weight: 600; }
.combo-option .meta { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.combo-group {
  padding: 8px 10px 4px; font-size: 11px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
}
.flag {
  display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 4px;
  background: #eceef0; color: #4a5058; font-size: 10px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; vertical-align: 1px;
}

/* ── Price bar ───────────────────────────────────────────────────────────── */

.pricebar {
  position: sticky; bottom: 0; z-index: 35;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 62%, rgba(246,247,248,0));
}
.pricebar-inner {
  max-width: 1120px; margin: 0 auto;
  /* price · commission · retail · money down · the button */
  display: grid; grid-template-columns: 1.3fr 1fr 1fr 0.9fr auto; gap: 10px; align-items: stretch;
}
.pricebar .stat {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 14px; display: flex; flex-direction: column; justify-content: center;
}
.pricebar .row {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 10px; align-items: stretch;
}
.pricebar .row button { width: 100%; height: 100%; font-size: 15px; }
@media (max-width: 1000px) {
  .pricebar-inner { grid-template-columns: 1fr 1fr 1fr; }
  .pricebar .row { grid-column: 1 / -1; }
}
@media (max-width: 620px) {
  .pricebar-inner { grid-template-columns: 1fr 1fr; }
  .pricebar .stat:first-child, .pricebar .row { grid-column: 1 / -1; }
  .pricebar .stat .v { font-size: 22px; }
}
.pricebar input[type="number"] { padding: 6px 9px; }
.stat .k {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 700;
}
/* A figure you can type into, sized like the figure it replaces. */
.bigbox {
  font: inherit; font-size: 26px; font-weight: 800; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; width: 100%;
  padding: 2px 6px; margin: 0 0 2px -7px;
  border: 1px solid transparent; border-radius:var(--radius-sm); background: transparent;
  color: var(--ink);
}
.bigbox:hover { border-color: var(--line); }
.bigbox:focus { outline: none; border-color: var(--brand); background: #fff; }
.bigbox.go { color: var(--go); }
@media (max-width: 560px) { .bigbox { font-size: 22px; } }

.stat .v { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat .v.go { color: var(--go); }
input[type="range"] { width: 100%; accent-color: var(--brand); }

/* ── Tables ──────────────────────────────────────────────────────────────── */

.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 9px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th {
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 700; position: sticky; top: 0; background: var(--card);
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #fafbfc; }
table input { padding: 5px 7px; border-radius: 6px; }
table input.num { text-align: right; width: 92px; }

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}
.pill.draft { background: #eef0f2; color: var(--ink-2); }
.pill.issued { background: #e6f6ec; color: #16663a; }
.pill.draft { background: #eef0f2; color: var(--ink-2); }

.empty { padding: 26px; text-align: center; color: var(--ink-3); }
.err {
  background: #fdecea; border: 1px solid #f5c6c2; color: #8f2c22;
  padding: 10px 13px; border-radius:var(--radius-sm); margin-bottom: 14px; font-size: 14px;
}
.note-line { font-size: 12px; color: var(--ink-3); margin-top: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 13px; font-weight: 600; z-index: 80; box-shadow: var(--shadow);
}
.toast[hidden] { display: none; }

/* ── Wizard ──────────────────────────────────────────────────────────────── */

.step-head { margin: 6px 0 18px; }
.step-head h2 { margin: 0; font-size: 26px; letter-spacing: -.025em; }
.step-head p { margin: 6px 0 0; color: var(--ink-2); font-size: 14.5px; }

.pips { display: flex; gap: 5px; margin-bottom: 14px; }
.pip { width: 26px; height: 4px; border-radius: 2px; background: var(--line); }
.pip.on { background: var(--brand); }

/* Trade selection */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 12px; }
.choice {
  position: relative; display: flex; flex-direction: column; align-items: flex-start;
  gap: 3px; padding: 22px 20px; min-height: 128px; text-align: left;
  border: 2px solid var(--line); border-radius: 12px; background: var(--card);
}
.choice:hover { border-color: var(--ink-3); background: var(--card); }
.choice.on { border-color: var(--brand); background: #fafafa; }
.choice .tick {
  position: absolute; top: 14px; right: 14px;
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 800;
  background: var(--line); color: transparent;
}
.choice.on .tick { background: var(--brand); color: #fff; }
.choice.on .choice-label { color: var(--ink); }
.choice-label { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.choice-sub { font-size: 12.5px; color: var(--ink-3); font-weight: 600; }

/* Quantity rows */
.card > h2 .sub-total {
  float: right; font-size: 14px; color: var(--ink); letter-spacing: 0;
  text-transform: none; font-variant-numeric: tabular-nums;
}
.qline {
  display: grid; grid-template-columns: 1fr 104px 92px 30px;
  gap: 10px; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
.qline:last-child { border-bottom: none; }
.qline-name { font-weight: 600; font-size: 14.5px; min-width: 0; }
.qline-rate { font-size: 12px; color: var(--ink-3); font-weight: 500; margin-top: 1px; }
.qline input { text-align: right; font-variant-numeric: tabular-nums; }
.qline-total {
  text-align: right; font-weight: 700; font-variant-numeric: tabular-nums;
  font-size: 14.5px; color: var(--ink-3);
}
.qline.filled .qline-total { color: var(--go); }
.qline.filled input { border-color: var(--brand); }
.qline-drop { width: 30px; display: inline-block; }
@media (max-width: 560px) {
  .qline { grid-template-columns: 1fr 86px 80px 26px; gap: 7px; }
  .qline-drop { width: 26px; }
}

/* Summary rows */
.sum-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px;
}
.sum-row strong { font-variant-numeric: tabular-nums; }
.sum-row.total {
  border-bottom: none; border-top: 2px solid var(--ink);
  margin-top: 4px; padding-top: 13px; font-size: 17px; font-weight: 700;
}

/* Library picker */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(16,18,22,.42);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 700px) { .sheet-overlay { align-items: center; } }
.sheet {
  background: var(--card); width: 100%; max-width: 620px; max-height: 82vh;
  border-radius: 14px 14px 0 0; display: flex; flex-direction: column; overflow: hidden;
}
@media (min-width: 700px) { .sheet { border-radius: 14px; } }
.sheet-head { display: flex; gap: 8px; align-items: center; padding: 12px; border-bottom: 1px solid var(--line); }
.sheet-head input { flex: 1; }
.jn-job { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.jn-job .sum-row { gap: 12px; align-items: center; }
.sheet-head button { font-size: 22px; line-height: 1; padding: 4px 10px; }
.sheet-tabs {
  display: flex; gap: 4px; padding: 9px 12px; overflow-x: auto;
  border-bottom: 1px solid var(--line); -webkit-overflow-scrolling: touch;
}
.sheet-tabs button { font-size: 12.5px; padding: 5px 11px; white-space: nowrap; }
.sheet-tabs button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.sheet-body { overflow-y: auto; padding: 6px; -webkit-overflow-scrolling: touch; }
.pick {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  width: 100%; text-align: left; border: none; background: none;
  padding: 11px 12px; border-radius:var(--radius-sm);
}
.pick:hover:not(.already) { background: var(--bg); }
.pick.already { opacity: .4; cursor: default; }
.pick-name { font-weight: 600; font-size: 14.5px; }
.pick .in {
  margin-left: 7px; font-size: 11px; font-weight: 700; color: var(--ink-3);
  letter-spacing: .05em; text-transform: uppercase;
}
.pick .meta { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }

/* ── Estimate list actions ───────────────────────────────────────────────── */

.list-actions { display: flex; gap: 6px; justify-content: flex-end; }
.list-actions button { padding: 5px 10px; font-size: 12.5px; }
td.actions { width: 1%; white-space: nowrap; }
.req {
  font-size: 10px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
  color: var(--brand); margin-left: 5px; vertical-align: 1px;
}

.who-box { display: flex; align-items: center; gap: 10px; }
.topbar .signout {
  background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.16);
  color: #d7d9dc; font-size: 12px; padding: 5px 10px;
}
.topbar .signout:hover { background: rgba(255,255,255,.16); color: #fff; }


/* ── App shell: left sidebar (iPad and computer), drawer (phone) ─────────── */

.sidebar, .mobilebar, .scrim { display: none; }
body.has-shell { padding-left: var(--side); }
body.has-shell .topbar { display: none; }
body.has-shell .sidebar {
  display: flex; flex-direction: column; gap: 6px;
  position: fixed; inset: 0 auto 0 0; width: var(--side); z-index: 60;
  padding: 18px 14px; background: var(--side-bg); color: #d9dadc;
  overflow-y: auto;
}
.sidebar-logo { display: block; padding: 6px 10px 18px; }
.sidebar-logo img { height: 34px; width: auto; display: block; }
.sidebar nav, .sidebar-foot { display: flex; flex-direction: column; gap: 2px; }
.sidebar a[data-nav] {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 12px;
  color: #b7b9bd; text-decoration: none; font-weight: 600; font-size: 15px;
}
.sidebar a[data-nav] svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sidebar a[data-nav]:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar a[data-nav][aria-current] { background: var(--brand); color: #fff; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-me { display: flex; flex-direction: column; gap: 10px; padding: 12px 12px 4px; min-width: 0; }
.sidebar-me div { min-width: 0; }
.sidebar-me strong { display: block; color: #fff; font-size: 14px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-me span { font-size: 12px; color: #8d9096; }
.sidebar-me .signout { align-self: flex-start; background: rgba(255,255,255,.08); border: 0; color: #d9dadc; padding: 7px 14px; font-size: 12px; }
.sidebar-me .signout:hover { background: rgba(255,255,255,.16); }

@media (max-width: 900px) {
  body.has-shell { padding-left: 0; }
  body.has-shell .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  body.has-shell.drawer-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  body.has-shell.drawer-open .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.35); }
  body.has-shell .mobilebar {
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 50;
    padding: 10px 14px; background: var(--side-bg); color: #fff;
  }
  .mobilebar .menu { background: transparent; border: 0; padding: 6px; border-radius: 10px; }
  .mobilebar .menu svg { width: 24px; height: 24px; stroke: #fff; stroke-width: 2; stroke-linecap: round; fill: none; display: block; }
  .mobilebar-logo img { height: 26px; display: block; }
  .mobilebar span { margin-left: auto; font-size: 14px; font-weight: 600; color: #b7b9bd; }
}

/* ── "⋯" menu: one main button per screen, the rest tucked in here ─────── */

.more { position: relative; display: inline-block; }
.more-toggle { padding: 9px 14px; letter-spacing: .1em; font-weight: 800; }
.more-menu {
  display: none; position: fixed; z-index: 70;
  min-width: 220px; padding: 6px; background: #fff; border-radius: 14px;
  box-shadow: 0 12px 40px rgba(16, 18, 22, .16), 0 0 0 1px rgba(16, 18, 22, .05);
}
.more.open .more-menu { display: flex; flex-direction: column; }
.more-menu a, .more-menu button {
  display: block; width: 100%; text-align: left; padding: 10px 12px;
  border: 0; border-radius: 10px; background: transparent;
  color: var(--ink); text-decoration: none; font-weight: 600; font-size: 14px;
}
.more-menu a:hover, .more-menu button:hover { background: var(--bg); }
.more-menu .danger { color: var(--stop); }
