/* The customer portal (0.49.0): ALS's brand (ink bar, the red, Oswald headings) on a light page that
   follows the device into dark mode. Mobile first: customers open it from an email on their phone. */
@font-face {
  font-family: "Oswald";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/oswald-600-latin.woff2") format("woff2");
}

:root {
  color-scheme: light dark;
  --red: #ea3324;
  --red-text: #c8281b;
  --ink: #1e1e1e;
  --ink-text: #f5f3f0;
  --bg: #f3f2f0;
  --surface: #ffffff;
  --surface-2: #faf9f7;
  --border: #e3e1dd;
  --text: #1f1f1f;
  --muted: #696661;
  --ok: #237a3b;
  --ok-soft: #e7f4ea;
  --info: #1f5d8c;
  --info-soft: #e6f0f8;
  --act: #8a5420;
  --act-soft: #fbefe2;
  --danger-soft: #fdeceb;
  --focus: #1f5d8c;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 10px rgba(0,0,0,.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --red: #f0503f;
    --red-text: #ff8576;
    --bg: #141414;
    --surface: #1e1e1e;
    --surface-2: #242424;
    --border: #353331;
    --text: #ece9e5;
    --muted: #a8a39d;
    --ok: #7ccf92;
    --ok-soft: #1d3324;
    --info: #8cc2ea;
    --info-soft: #1b2b38;
    --act: #f0b678;
    --act-soft: #3a2a19;
    --danger-soft: #3b1f1c;
    --focus: #8cc2ea;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--red-text); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
h1, h2, h3 { font-family: "Oswald", system-ui, sans-serif; font-weight: 600; letter-spacing: .2px; line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ---------------------------------------------------------------- the bar */
.p-bar { background: var(--ink); color: var(--ink-text); border-bottom: 4px solid var(--red); }
.p-bar-in { max-width: 960px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; gap: .75rem; }
.p-logo { display: block; height: 40px; width: auto; border-radius: 4px; }
.p-brand { display: flex; align-items: center; gap: .6rem; color: inherit; text-decoration: none; min-width: 0; }
.p-brand-name { font-family: "Oswald", sans-serif; font-weight: 600; font-size: 1.05rem; letter-spacing: .3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-who { margin-left: auto; text-align: right; font-size: .8rem; line-height: 1.3; min-width: 0; }
.p-who-name { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.p-who form { display: inline; }
.p-link-btn { background: none; border: 0; padding: 0; color: #ffb4ab; text-decoration: underline; font: inherit; cursor: pointer; }

/* The tabs under the bar: scroll sideways on a phone. */
.p-nav { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.p-nav-in { max-width: 960px; margin: 0 auto; display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none; padding: 0 .5rem; }
.p-nav-in::-webkit-scrollbar { display: none; }
.p-nav a {
  flex: 0 0 auto; padding: .8rem .8rem .7rem; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .95rem;
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.p-nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--red); }
.p-nav .p-count { display: inline-block; min-width: 1.4em; padding: 0 .35em; margin-left: .2rem; border-radius: 999px; background: var(--red); color: #fff; font-size: .75rem; text-align: center; }

.p-account { max-width: 960px; margin: .75rem auto 0; padding: 0 1rem; }
.p-account form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.p-account label { font-size: .85rem; color: var(--muted); }
.p-account select { flex: 1 1 14rem; max-width: 30rem; }

main.p-main { flex: 1; width: 100%; max-width: 960px; margin: 0 auto; padding: 1rem 1rem 2.5rem; }
.p-foot { border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem; padding: 1.25rem 1rem 2rem; text-align: center; }
.p-foot a { color: inherit; }

/* ---------------------------------------------------------------- pieces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem; }
.card > :last-child { margin-bottom: 0; }
.p-head { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: baseline; justify-content: space-between; margin-bottom: .75rem; }
.p-head h1 { margin: 0; }
.p-sub { color: var(--muted); font-size: .9rem; }

.chip { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.chip.act { background: var(--act-soft); color: var(--act); border-color: transparent; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .55rem 1.1rem;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-family: inherit; font-size: 1rem; font-weight: 600; line-height: 1.2;
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: #d32a1b; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0 1rem; }

/* Tabs inside a page (server-side: each is a link). */
.p-tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin: 0 0 1rem; overflow-x: auto; scrollbar-width: none; }
.p-tabs a { padding: .6rem .8rem; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.p-tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--red); }
.p-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 3px; margin-bottom: 1rem; background: var(--surface-2); }
.p-seg a { padding: .4rem 1rem; border-radius: 999px; color: var(--muted); text-decoration: none; font-weight: 600; }
.p-seg a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Lists: one row per record, tap anywhere on it. */
.p-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.p-list > li + li { border-top: 1px solid var(--border); }
.p-row { display: grid; grid-template-columns: 1fr auto; gap: .15rem 1rem; padding: .85rem 1rem; color: inherit; text-decoration: none; }
.p-row:hover { background: var(--surface-2); }
.p-row-title { font-weight: 600; }
.p-row-meta { color: var(--muted); font-size: .875rem; grid-column: 1; }
.p-row-side { grid-row: 1 / span 2; grid-column: 2; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; }
.p-row-amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.p-empty { padding: 1.5rem 1rem; text-align: center; color: var(--muted); }
.p-more { padding: 1rem; text-align: center; color: var(--muted); }
.p-total { color: var(--muted); font-size: .9rem; margin: 0 0 .5rem; }

.flash { border-radius: 10px; padding: .75rem 1rem; margin-bottom: 1rem; border: 1px solid transparent; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--danger-soft); color: var(--red-text); }
.flash-info { background: var(--info-soft); color: var(--info); }

/* Forms */
.field { margin-bottom: 1rem; }
.field label, .field .label { display: block; font-weight: 600; margin-bottom: .3rem; }
.field .hint { color: var(--muted); font-size: .85rem; margin-top: .25rem; }
input[type=text], input[type=email], input[type=tel], input:not([type]), select, textarea {
  width: 100%; min-height: 44px; padding: .55rem .7rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-size: 1rem;
}
textarea { min-height: 6rem; resize: vertical; }
input.code { font-size: 1.6rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; max-width: 14rem; }
.check { display: flex; gap: .6rem; align-items: flex-start; padding: .5rem 0; }
.check input { width: 1.3rem; height: 1.3rem; margin-top: .15rem; flex: 0 0 auto; accent-color: var(--red); }
.req { color: var(--red-text); }
.field .check { display: flex; font-weight: 400; margin: 0; }
.field.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: .75rem; }

/* The sign-in card */
.p-signin { max-width: 26rem; margin: 1.5rem auto; }
.p-signin h1 { font-size: 1.4rem; }

/* Documents: the quote and invoice as the customer's copy */
.doc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }
.doc-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1.5rem; margin-bottom: 1rem; }
.doc-facts { display: grid; grid-template-columns: auto auto; gap: .1rem .9rem; font-size: .9rem; margin: 0; }
.doc-facts dt { color: var(--muted); }
.doc-facts dd { margin: 0; font-weight: 600; text-align: right; }
.doc-parties { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: .75rem 1.25rem; margin-bottom: 1rem; font-size: .92rem; }
.doc-parties h3 { font-family: inherit; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .2rem; }
.doc-block { margin-bottom: 1rem; white-space: pre-line; }
.doc-block h3 { font-family: inherit; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .2rem; }
.doc-lines { list-style: none; margin: 0 0 1rem; padding: 0; border-top: 1px solid var(--border); }
.doc-lines li { display: grid; grid-template-columns: 1fr auto; gap: .1rem 1rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.doc-lines .d { overflow-wrap: anywhere; }
.doc-lines .q { color: var(--muted); font-size: .85rem; }
.doc-lines .a { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.doc-lines .opt { color: var(--act); font-size: .8rem; font-weight: 600; }
.doc-lines li.left-out .d, .doc-lines li.left-out .a { color: var(--muted); }
.doc-lines li.left-out .a { text-decoration: line-through; font-weight: 400; }
.doc-totals { margin: 0 0 0 auto; max-width: 20rem; display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem; font-variant-numeric: tabular-nums; }
.doc-totals dt { color: var(--muted); }
.doc-totals dd { margin: 0; text-align: right; }
.doc-totals .t { font-weight: 700; font-size: 1.15rem; color: var(--text); }
.doc-stamp { display: inline-block; margin-top: .75rem; padding: .35rem .8rem; border: 2px solid var(--ok); color: var(--ok); border-radius: 6px; font-weight: 700; letter-spacing: .04em; }
.doc-stamp.plain { border-color: var(--info); color: var(--info); }
.doc-stamp.void { border-color: var(--red-text); color: var(--red-text); }
.doc-pay { margin-top: 1rem; font-size: .9rem; }
.doc-pay table { width: 100%; border-collapse: collapse; }
.doc-pay td { padding: .3rem 0; border-bottom: 1px solid var(--border); }
.doc-pay td.n { text-align: right; font-variant-numeric: tabular-nums; }

/* The answer to a quote */
.choices { list-style: none; padding: 0; margin: 0 0 1rem; }
.choices li { border: 1px solid var(--border); border-radius: 10px; padding: .25rem .75rem; margin-bottom: .5rem; background: var(--surface); }
.choices .add { color: var(--act); font-weight: 700; white-space: nowrap; }
.answer-total { display: flex; justify-content: space-between; align-items: baseline; padding: .8rem 1rem; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 1rem; }
.answer-total strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.statement { background: var(--act-soft); border-radius: 10px; padding: .75rem 1rem; margin-bottom: 1rem; }

/* Photos and signatures */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; }
.gallery a { display: block; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); aspect-ratio: 1; }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sigs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem; }
.sigs figure { margin: 0; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: .5rem; }
.sigs img { width: 100%; height: auto; display: block; }
.sigs figcaption { color: #555; font-size: .85rem; margin-top: .3rem; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0 0 1rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }

.visits { list-style: none; margin: 0; padding: 0; }
.visits li { padding: .6rem 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

@media (min-width: 720px) {
  h1 { font-size: 1.8rem; }
  main.p-main { padding-top: 1.5rem; }
  .doc { padding: 1.5rem 1.75rem; }
  .card { padding: 1.25rem 1.5rem; }
  .p-logo { height: 46px; }
}

@media print {
  .p-bar, .p-nav, .p-account, .p-foot, .btn-row, .p-tabs { display: none !important; }
  body { background: #fff; }
  .doc { border: 0; box-shadow: none; padding: 0; }
}

/* A staff member viewing as a customer: a fixed strip, never mistaken for the customer's own page. */
.p-viewas {
  position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .4rem 1rem;
  padding: .55rem 1rem; background: #fff3cd; color: #5c4400; border-bottom: 2px solid #e0b100; font-size: .9rem; text-align: center;
}
.p-viewas form { display: inline; }
.p-viewas-back { border: 1px solid #b38b00; background: #fff; color: #5c4400; border-radius: 6px; padding: .3rem .8rem; font-family: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; }
body.p-viewing .p-nav { top: 2.6rem; }
@media (prefers-color-scheme: dark) {
  .p-viewas { background: #3d3000; color: #ffe08a; border-bottom-color: #b38b00; }
  .p-viewas-back { background: #2a2100; color: #ffe08a; }
}

/* A phone: the logo says who it is; the bar keeps room for who's signed in. */
@media (max-width: 520px) {
  .p-brand-name { display: none; }
  .p-who-name { max-width: 62vw; }
}
