:root {
  color-scheme: light dark;

  --ink:        #15191f;
  --ink-2:      #39424e;
  --ink-3:      #6b7684;
  --line:       #e1e5ea;
  --line-2:     #eef1f4;
  --bg:         #f7f8fa;
  --surface:    #ffffff;
  --surface-2:  #fbfcfd;

  --brand:      #1d3a5f;
  --brand-ink:  #ffffff;
  --brand-soft: #eaf0f7;

  --ok:         #1b6b47;
  --ok-soft:    #e6f3ec;
  --warn:       #8a5a12;
  --warn-soft:  #fdf2dd;
  --bad:        #9c2b2b;
  --bad-soft:   #fbeaea;
  --mute-soft:  #f0f2f5;

  --radius: 7px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink:       #e8ecf1;
    --ink-2:     #b3bcc8;
    --ink-3:     #828d9b;
    --line:      #2b3340;
    --line-2:    #222a35;
    --bg:        #11151b;
    --surface:   #181d25;
    --surface-2: #1d232c;

    --brand:      #8fb4e0;
    --brand-ink:  #10151c;
    --brand-soft: #1b2634;

    --ok:        #6fcfa0;  --ok-soft:   #15291f;
    --warn:      #e0b269;  --warn-soft: #2a2114;
    --bad:       #e89494;  --bad-soft:  #2c1818;
    --mute-soft: #222a35;
  }
}

:root[data-theme="dark"] {
  --ink:       #e8ecf1;
  --ink-2:     #b3bcc8;
  --ink-3:     #828d9b;
  --line:      #2b3340;
  --line-2:    #222a35;
  --bg:        #11151b;
  --surface:   #181d25;
  --surface-2: #1d232c;

  --brand:      #8fb4e0;
  --brand-ink:  #10151c;
  --brand-soft: #1b2634;

  --ok:        #6fcfa0;  --ok-soft:   #15291f;
  --warn:      #e0b269;  --warn-soft: #2a2114;
  --bad:       #e89494;  --bad-soft:  #2c1818;
  --mute-soft: #222a35;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); }

/* ---- shell ---- */

.topbar {
  background: var(--brand);
  color: var(--brand-ink);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  min-height: 52px;
}
.topbar .mark { font-weight: 650; letter-spacing: -0.01em; }
.topbar .mark span { opacity: .62; font-weight: 400; }
.topbar nav { display: flex; gap: 2px; flex-wrap: wrap; margin-left: auto; }
.topbar nav a {
  color: inherit; text-decoration: none; opacity: .72;
  padding: 7px 11px; border-radius: var(--radius); font-size: 14px;
}
.topbar nav a:hover { opacity: 1; background: rgba(127,127,127,.18); }
.topbar nav a.on { opacity: 1; background: rgba(127,127,127,.26); font-weight: 550; }

.demo-note {
  background: var(--warn-soft);
  color: var(--warn);
  border-bottom: 1px solid var(--line);
  padding: 7px 20px;
  font-size: 13px;
}

main { max-width: 1180px; margin: 0 auto; padding-block: 24px; padding-inline: 20px; }

h1 { font-size: 21px; margin: 0 0 3px; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 26px 0 10px; letter-spacing: -0.005em; }
.sub { color: var(--ink-3); font-size: 14px; margin: 0 0 18px; }

/* ---- cards & tables ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.card + .card { margin-top: 14px; }
.card-head {
  padding: 12px 15px;
  border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--surface-2);
}
.card-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 15px; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th {
  text-align: left; font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-3); padding: 9px 15px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 11px 15px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 13px; }
.dim { color: var(--ink-3); }
.strong { font-weight: 600; }

/* ---- chips ---- */

.chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 550; white-space: nowrap;
  background: var(--mute-soft); color: var(--ink-2);
}
.chip.ok   { background: var(--ok-soft);   color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad  { background: var(--bad-soft);  color: var(--bad); }
.chip.brand{ background: var(--brand-soft);color: var(--brand); }

.tag {
  display: inline-block; padding: 1px 7px; margin: 1px 2px 1px 0;
  border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 12px; color: var(--ink-2);
}
.tag.cert { border-color: var(--brand); color: var(--brand); }

/* ---- stats ---- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px 15px;
}
.stat .v { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* ---- buttons & forms ---- */

button, .btn {
  font: inherit; font-size: 14px; font-weight: 550;
  padding: 7px 13px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); cursor: pointer; text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { background: var(--surface-2); }
button.primary, .btn.primary {
  background: var(--brand); border-color: var(--brand); color: var(--brand-ink);
}
button.primary:hover { filter: brightness(1.1); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.sm { padding: 4px 9px; font-size: 13px; }

select, input[type=text], input[type=number] {
  font: inherit; font-size: 14px; padding: 6px 9px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
}

/* ---- misc ---- */

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }
.empty { padding: 28px 15px; text-align: center; color: var(--ink-3); font-size: 14px; }
.blocked { color: var(--bad); font-size: 13px; }
.back { font-size: 13px; text-decoration: none; display: inline-block; margin-bottom: 10px; }

.pick {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px; margin-top: 22px;
}
.pick a {
  display: block; padding: 20px; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.pick a:hover { border-color: var(--brand); }
.pick strong { display: block; font-size: 16px; margin-bottom: 5px; }
.pick span { color: var(--ink-3); font-size: 14px; }

/* ---- pricing and quoting ------------------------------------------------- */

.lead { max-width: 62ch; color: var(--ink-2); margin: 0 0 1rem; }
.crumb { margin: 0 0 .5rem; font-size: .85rem; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }

.notice {
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink-3);
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: .75rem .9rem;
  margin: 0 0 1rem;
  font-size: .9rem;
  max-width: 78ch;
}
.notice.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.notice.ok   { border-left-color: var(--ok);   background: var(--ok-soft);   }
.notice.bad  { border-left-color: var(--bad);  background: var(--bad-soft);  }
.notice strong { font-weight: 600; }

.suggest {
  font-family: var(--mono);
  color: var(--ink-3);
  border-bottom: 1px dashed var(--ink-3);
}
tr.row-flag td { background: var(--warn-soft); }

.totals {
  margin: .9rem 0 0;
  border-top: 1px solid var(--line);
  padding-top: .6rem;
  max-width: 24rem;
  margin-left: auto;
}
.totals div { display: flex; justify-content: space-between; padding: .18rem 0; font-size: .9rem; }
.totals div.big {
  border-top: 1px solid var(--line);
  margin-top: .3rem; padding-top: .45rem; font-size: 1rem;
}
.totals strong { font-family: var(--mono); }

/* Coathanger only. Visually separated because it is the one place the two
   sides of the money are deliberately brought together. */
.margin-box {
  margin-top: 1rem;
  padding: .75rem .9rem;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
  background: var(--surface-2);
  max-width: 32rem;
}
.margin-box div { display: flex; justify-content: space-between; padding: .15rem 0; font-size: .9rem; }
.margin-box strong { font-family: var(--mono); }
.margin-box strong.bad { color: var(--bad); }
.margin-box p { margin: .5rem 0 0; }

/* The curtain job card in the field app. */
.measure-row { display: flex; gap: .5rem; }
.measure-row label { flex: 1; }
.derived {
  font-family: var(--mono); font-size: .9rem;
  color: var(--ink-2); padding: .4rem 0;
}
.derived strong { color: var(--ink); }

.set-line { display: inline-flex; gap: .35rem; align-items: center; justify-content: flex-end; }
.price-in {
  width: 5.5rem; text-align: right; font-family: var(--mono); font-size: .85rem;
  padding: .25rem .4rem; border: 1px solid var(--line-2);
  border-radius: 5px; background: var(--surface); color: var(--ink);
}
.price-in:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

/* The quote action forms. One panel on screen at a time, so they sit inline
   rather than in a modal — nothing to dismiss, nothing to lose behind. */
.qform {
  margin-top: 1rem; padding: .9rem;
  border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--surface-2); max-width: 44rem;
}
.qform h4 { margin: 0 0 .5rem; font-size: .95rem; }
.qform label {
  display: block; margin: .6rem 0 .2rem;
  font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3);
}
.qform input[type="text"] {
  width: 100%; padding: .45rem .55rem; font-size: .9rem;
  border: 1px solid var(--line-2); border-radius: 6px;
  background: var(--surface); color: var(--ink);
}
.qform input[type="text"]:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.qform .row { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .8rem; }
.card-head .chip { margin-right: .4rem; }

/* The sign-in gate. One narrow column, nothing else on the page — there is no
   navigation to offer somebody who is not signed in yet. */
.signin {
  max-width: 26rem;
  margin: 12vh auto 0;
  padding: 0 1rem;
}
.signin h1 { margin: 0 0 .4rem; }
.signin input[type="email"] {
  width: 100%;
  box-sizing: border-box;
  padding: .6rem .7rem;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}
.signin label { display: block; margin: 1rem 0 .3rem; font-weight: 600; }
.signin .row { margin-top: .9rem; }
.signin .notice { margin: 1rem 0 0; }
/* Nothing but the sign-in panel until somebody is through the gate. The
   navigation would route to screens that cannot be drawn yet, and the
   sample-data note is wrong in live mode before a workspace is loaded. */
body.gated .topbar,
body.gated .demo-note { display: none; }
