/* S2S Office. Layout: sidebar on desktop, top bar + bottom tabs on phones; cards on a granite-mist ground. */
:root {
  --bg: #EEF1EE; --surface: #FFFFFF; --surface-2: #F5F8F6; --ink: #13221E; --muted: #5A6A64; --line: #D7DFDA;
  --forest: #13221E; --teal: #1D5B57; --teal-soft: #DDEDEA; --glacier: #9FD0CA; --cedar: #B85E24; --cedar-ink: #FFFFFF;
  --brand-line: #9FD0CA;
  --ok: #2F7D4F; --ok-soft: #E1F1E7; --warn: #9A5B0C; --warn-soft: #FBEEDB; --bad: #B23A2E; --bad-soft: #F8E2DF; --info: #1D5B57; --info-soft: #DDEDEA;
  --f-display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --f-body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --r: 12px; --shadow: 0 1px 2px rgb(19 34 30 / .05), 0 6px 20px rgb(19 34 30 / .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0C1513; --surface: #142120; --surface-2: #1A2A28; --ink: #E4EDE9; --muted: #9BADA7; --line: #263835;
    --teal: #74BDB4; --teal-soft: #1C3532; --cedar: #E0884A; --cedar-ink: #1A0E05;
    --ok: #6CC48F; --ok-soft: #173326; --warn: #E6A84B; --warn-soft: #33270F; --bad: #F08A7E; --bad-soft: #3A1B17; --info: #74BDB4; --info-soft: #1C3532;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 20px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--f-body); -webkit-font-smoothing: antialiased; }
a { color: var(--teal); }
h1, h2, h3 { font-family: var(--f-display); font-stretch: 108%; line-height: 1.15; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.8rem); font-weight: 800; }
h2 { font-size: 1.05rem; font-weight: 800; margin-bottom: 12px; }
p { margin: 0 0 10px; }
small, .small { font-size: .82rem; }
.muted { color: var(--muted); }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; font-size: .9em; }
.pre { white-space: pre-wrap; font: inherit; margin: 0; }
.center { text-align: center; }
.mt { margin-top: 22px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid var(--cedar); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
@media (min-width: 901px) { .shell { background: linear-gradient(90deg, var(--forest) 232px, transparent 232px); } }
.side { position: sticky; top: 0; height: 100vh; background: var(--forest); color: #fff; padding: 20px 12px; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font: 800 1.05rem/1 var(--f-display); font-stretch: 112%; padding: 4px 10px; }
.brand b { color: var(--glacier); }
.side nav { display: grid; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #CFDCD8; text-decoration: none; font-weight: 600; }
.side nav a:hover { background: rgb(255 255 255 / .06); color: #fff; }
.side nav a.on { background: rgb(159 208 202 / .14); color: #fff; box-shadow: inset 3px 0 0 var(--cedar); }
.logout { margin-top: auto; padding: 0 12px; }
.logout .link { color: #9FB2AC; font-size: .8rem; text-align: left; }
.main { padding: 22px clamp(16px, 3vw, 36px) 48px; padding-left: max(clamp(16px, 3vw, 36px), env(safe-area-inset-left)); padding-right: max(clamp(16px, 3vw, 36px), env(safe-area-inset-right)); min-width: 0; display: grid; gap: 16px; align-content: start; max-width: 1240px; }
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.top h1 { margin-right: auto; }
.top-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.brand-m { display: none; }
.tabs { display: none; }

@media (max-width: 900px) {
  .shell { display: block; }
  .side { display: none; }
  .main { padding-top: calc(env(safe-area-inset-top) + 12px); padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .brand-m { display: flex; width: 100%; padding: 0; color: var(--ink); font-size: .95rem; }
  .brand-m b { color: var(--teal); }
  :root { --brand-line: var(--teal); }
  .tabs { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line); padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .tabs > a, .tabs summary { display: grid; justify-items: center; gap: 2px; padding: 6px 2px; color: var(--muted); text-decoration: none; font-size: .7rem; font-weight: 600; border-radius: 10px; cursor: pointer; list-style: none; }
  .tabs summary::-webkit-details-marker { display: none; }
  .tabs > a.on { color: var(--teal); background: var(--teal-soft); }
  .more { position: relative; }
  .more-menu { position: absolute; right: 0; bottom: calc(100% + 10px); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 8px; display: grid; min-width: 210px; }
  .more-menu a, .more-menu .link { display: flex; gap: 12px; align-items: center; padding: 11px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: 600; }
  .more-menu a.on { background: var(--teal-soft); }
}

/* ---------- building blocks ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card.attention { border-color: color-mix(in oklab, var(--cedar) 50%, var(--line)); box-shadow: inset 4px 0 0 var(--cedar), var(--shadow); }
details.card > summary { cursor: pointer; list-style: none; }
details.card > summary h2 { display: inline; margin: 0; }
details.card > summary::after { content: " +"; color: var(--muted); font-weight: 700; }
details.card[open] > summary { margin-bottom: 14px; }
details.card[open] > summary::after { content: " −"; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 16px; align-items: start; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: grid; gap: 2px; }
.stat span { font-size: .78rem; color: var(--muted); font-weight: 600; }
.stat b { font: 800 1.45rem/1.2 var(--f-display); font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); }
.stat.ok b { color: var(--ok); } .stat.bad b { color: var(--bad); } .stat.warn b { color: var(--warn); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 700 .9rem/1 var(--f-body); padding: 11px 16px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; cursor: pointer; white-space: nowrap; min-height: 42px; }
.btn:hover { border-color: var(--teal); }
.btn.primary { background: var(--cedar); border-color: var(--cedar); color: var(--cedar-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); border-color: color-mix(in oklab, var(--bad) 40%, var(--line)); background: transparent; }
.btn.sm { padding: 7px 12px; min-height: 34px; font-size: .82rem; }
.btn.wide { width: 100%; }
.link { background: none; border: 0; padding: 0; color: var(--teal); font: inherit; cursor: pointer; text-decoration: underline; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { margin: 0; }

.pill { display: inline-flex; align-items: center; font: 700 .72rem/1 var(--f-body); padding: 5px 9px; border-radius: 999px; white-space: nowrap; }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.done { background: var(--teal); color: #fff; }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

.flash { padding: 12px 16px; border-radius: 10px; font-weight: 600; margin: 0; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.bad { background: var(--bad-soft); color: var(--bad); }

.list { display: grid; }
.card.list { padding: 4px 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; min-height: 58px; }
.card:not(.list) .row { padding-left: 0; padding-right: 0; }
.row:last-child { border-bottom: 0; }
a.row:hover { background: var(--surface-2); }
.row .grow { flex: 1; min-width: 0; }
.grow { flex: 1; min-width: 0; }
.row .grow b, .row .grow small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .grow small { color: var(--muted); }
.row .end { display: grid; justify-items: end; }
.row form { margin: 0; }
.row-link { display: flex; justify-content: space-between; gap: 12px; text-decoration: none; color: var(--ink); }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); background: var(--surface); border: 1.5px dashed var(--line); border-radius: var(--r); }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips a { flex: none; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font-size: .82rem; font-weight: 600; }
.chips a b { color: var(--muted); margin-left: 4px; font-variant-numeric: tabular-nums; }
.chips a.on { background: var(--forest); border-color: var(--forest); color: #fff; }
.chips a.on b { color: var(--glacier); }

.search input, .filters select { font: inherit; }
.search input { width: 100%; padding: 12px 14px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters select { padding: 8px 10px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 14px 16px; align-items: start; }
.form-grid.inline { align-items: end; }
.form-grid .wide, .field.wide { grid-column: 1 / -1; }
fieldset { border: 1px dashed var(--line); border-radius: 10px; padding: 12px; margin: 0; }
legend { font-weight: 700; font-size: .85rem; padding: 0 6px; }
.field { display: grid; gap: 5px; min-width: 0; }
.field > span { font-size: .82rem; font-weight: 700; }
.field > span i { color: var(--cedar); font-style: normal; }
.field small { color: var(--muted); }
input, select, textarea { font: inherit; font-size: 16px; color: var(--ink); background: var(--surface-2); border: 1.5px solid var(--line); border-radius: 9px; padding: 10px 12px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px color-mix(in oklab, var(--teal) 22%, transparent); }
input[readonly] { background: transparent; }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--teal); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-btn { font: 600 .8rem var(--f-body); padding: 7px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.receipt-thumb { max-width: 220px; max-height: 260px; border-radius: 8px; border: 1px solid var(--line); margin-top: 6px; object-fit: contain; }
.share { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.share input { flex: 1; min-width: 200px; font-family: var(--f-mono); font-size: .8rem; }
.note-form { display: grid; gap: 8px; margin-bottom: 12px; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: .82rem; font-weight: 600; }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- dashboard ---------- */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: 10px; }
.qa { display: grid; gap: 2px; padding: 14px 16px; border-radius: var(--r); background: var(--forest); color: #fff; text-decoration: none; }
.qa b { font: 800 1rem var(--f-display); }
.qa small { color: var(--glacier); }
.qa:first-child { background: var(--cedar); }
.qa:first-child small { color: #FFE2CC; }
.pipeline { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.pipeline a { display: grid; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.pipeline b { font: 800 1.3rem var(--f-display); }
.pipeline span { font-size: .75rem; color: var(--muted); }

/* ---------- schedule ---------- */
.week-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.week-nav b { font-family: var(--f-display); margin: 0 4px; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 8px; display: grid; gap: 6px; align-content: start; min-height: 150px; }
.day.today { border-color: var(--teal); box-shadow: inset 0 3px 0 var(--teal); }
.day header { display: flex; align-items: baseline; gap: 6px; }
.day header span { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.day header b { font: 800 1.15rem var(--f-display); }
.day header a { margin-left: auto; text-decoration: none; font-weight: 800; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); }
.appts { display: grid; gap: 8px; }
.appt { display: grid; gap: 2px; padding: 8px 10px; border-radius: 9px; text-decoration: none; color: var(--ink); background: var(--teal-soft); border-left: 4px solid var(--teal); }
.appt.estimate { background: var(--warn-soft); border-left-color: var(--cedar); }
.appt.requested { border-left-style: dashed; }
.appt.done { opacity: .6; }
.appt .mono { font-size: .72rem; color: var(--muted); }
.appt b { font-size: .88rem; line-height: 1.25; overflow-wrap: anywhere; }
.appt small { color: var(--muted); font-size: .74rem; }
.appt .pill { justify-self: start; }
@media (max-width: 900px) {
  .week { grid-template-columns: minmax(0, 1fr); }
  .day { min-height: 0; }
}

/* ---------- jobs ---------- */
.job-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: end; }
.job-head > .grow { flex: 1 1 260px; }
.status-form { flex: 1 1 200px; }
.job-head .meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; }
.job-head .addr { display: block; margin-bottom: 8px; }
.contact { display: flex; flex-wrap: wrap; gap: 6px; }
.status-form { margin: 0; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.timeline li { display: grid; gap: 1px; padding-left: 12px; border-left: 2px solid var(--line); }
.timeline small { color: var(--muted); }

/* ---------- quotes & invoices ---------- */
.doc-bar { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.doc-bar .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 4px; }
.doc-bar .big { display: block; font-size: 1.6rem; }
.lines { display: grid; gap: 8px; margin-bottom: 10px; }
.line { display: grid; grid-template-columns: minmax(0, 3fr) 70px 80px 100px 44px 34px; gap: 8px; align-items: center; }
.line.head { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.line .tax { display: grid; place-items: center; }
.line .x { border: 0; background: none; color: var(--muted); font-size: 1.3rem; cursor: pointer; }
@media (max-width: 700px) {
  .line { grid-template-columns: 1fr 1fr 1fr 34px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
  .line.head { display: none; }
  .line [name="desc"] { grid-column: 1 / -1; }
  .line .tax { grid-column: 4; grid-row: 2; }
  .line .x { grid-column: 4; grid-row: 1; position: absolute; }
  .line { position: relative; }
}
.totals { display: flex; justify-content: flex-end; margin: 8px 0 14px; }
.totals dl, .doc-totals dl { display: grid; grid-template-columns: auto auto; gap: 4px 24px; margin: 0; font-variant-numeric: tabular-nums; }
.totals dd, .doc-totals dd { margin: 0; text-align: right; font-family: var(--f-mono); }
.total { font-weight: 800; font-size: 1.05rem; }
.preview { margin-top: 8px; }

/* customer document */
.doc { background: #fff; color: #13221E; border: 1px solid #D7DFDA; border-radius: var(--r); padding: clamp(18px, 4vw, 44px); max-width: 860px; margin: 0 auto; display: grid; gap: 22px; box-shadow: var(--shadow); --brand-line: #1D5B57; --cedar: #B85E24; }
.doc a { color: #1D5B57; }
.doc-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 18px; }
.doc-brand { display: flex; align-items: center; gap: 10px; font: 800 1.3rem var(--f-display); font-stretch: 112%; margin-bottom: 8px; }
.doc-title { text-align: right; }
.doc-title h1 { font-size: 2rem; letter-spacing: .02em; text-transform: uppercase; color: #1D5B57; }
.doc-title dl { display: grid; grid-template-columns: auto auto; gap: 2px 14px; margin: 8px 0 0; justify-content: end; font-size: .9rem; }
.doc-title dt { color: #5A6A64; } .doc-title dd { margin: 0; font-weight: 600; }
.stamp { display: inline-block; margin-top: 10px; padding: 6px 14px; border: 3px solid; border-radius: 8px; font: 900 1.1rem var(--f-display); text-transform: uppercase; transform: rotate(-4deg); }
.stamp.paid { color: #2F7D4F; } .stamp.void { color: #B23A2E; }
.doc-to { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; padding: 14px 0; border-block: 1px solid #D7DFDA; }
.eyebrow { display: block; font: 700 .7rem var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: #1D5B57; margin-bottom: 4px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
.doc-lines th, .grid th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid currentColor; }
.doc-lines th { color: #5A6A64; }
.doc-lines td, .grid td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.doc-lines td { border-bottom-color: #E4E9E6; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc-totals { display: flex; justify-content: flex-end; }
.doc-notes { padding: 12px 14px; background: #F5F8F6; border-radius: 8px; }
.doc-pay { padding: 14px 16px; border-radius: 10px; background: #DDEDEA; }
.doc-pay p { margin: 0; }
.doc-foot { color: #5A6A64; border-top: 1px solid #D7DFDA; padding-top: 12px; }
.doc-accept { display: grid; gap: 10px; justify-items: center; text-align: center; padding: 16px; border: 2px dashed #B85E24; border-radius: 12px; }
.grid tfoot td { border-bottom: 0; }

/* ---------- tax ---------- */
.meter { height: 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; margin: 8px 0; }
.meter span { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--cedar)); }
.checklist { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }

/* ---------- login / public pages ---------- */
body.bare { min-height: 100vh; }
body.bare.paper { background: #EEF1EE; color: #13221E; padding: 24px max(12px, env(safe-area-inset-right)) 48px max(12px, env(safe-area-inset-left)); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(100%, 400px); display: grid; gap: 14px; }
.login-brand { display: flex; align-items: center; gap: 10px; font: 800 1.1rem var(--f-display); --brand-line: var(--teal); }
.login-brand b { color: var(--teal); }

@media print {
  body, body.bare.paper { background: #fff; padding: 0; }
  .side, .tabs, .top, .no-print, .flash { display: none !important; }
  .doc { border: 0; box-shadow: none; padding: 0; max-width: none; }
}
