/* Stagg Window Cleaning. One stylesheet for the customer site and Luke's backend. */

:root {
  --ink: #13212F;
  --glass: #1F5F99;
  --glass-dark: #174a78;
  --owed: #A4231B;
  --settled: #1C6B3F;
  --pane: #F4F7F9;
  --frame: #C9D3DB;
  --white: #FFFFFF;
  --muted: #4A5866;
  --focus: #1F5F99;
  --font: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 4px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--pane);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: clamp(1.6rem, 4.5vw, 2.1rem); }
h2 { font-size: 1.25rem; margin-top: 1.75em; }
p { margin: 0 0 1em; max-width: 68ch; }
a { color: var(--glass); text-underline-offset: .15em; }
a:hover { color: var(--glass-dark); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
img, svg { max-width: 100%; }
code { font-size: .9em; background: var(--white); border: 1px solid var(--frame); padding: 0 .3em; border-radius: 3px; overflow-wrap: anywhere; }

[hidden] { display: none !important; }
.sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--white); padding: .5rem 1rem; z-index: 2000; }
.skip:focus { left: 0; }
.muted, .opt { color: var(--muted); }
.opt { font-weight: 400; }
.hint { color: var(--muted); font-size: .95rem; }
.empty { padding: 1rem 0; color: var(--muted); }
.wrap { width: 100%; max-width: 60rem; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 34rem; }

/* ---------- Forms and buttons ---------- */
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; min-width: 0; }
label, legend { font-weight: 700; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--white);
  border: 1.5px solid #8796A4; border-radius: var(--r);
  padding: .6rem .7rem; min-height: 2.9rem; width: 100%; max-width: 100%;
}
textarea { min-height: auto; }
input[type="checkbox"], input[type="radio"] { width: 1.25rem; height: 1.25rem; min-height: 0; accent-color: var(--glass); margin: 0; flex: none; }
input[aria-invalid="true"] { border-color: var(--owed); }
.field-error { color: var(--owed); font-weight: 700; margin: 0; font-size: .95rem; }
fieldset { border: 0; border-top: 1px solid var(--frame); padding: 1rem 0 .25rem; margin: 0 0 1rem; min-width: 0; }
legend { padding: 0 .5rem 0 0; font-size: 1.1rem; }
.choice { display: flex; align-items: center; gap: .6rem; font-weight: 500; padding: .45rem 0; }
.choice.small { font-size: .95rem; }
.stack { max-width: 30rem; }
.row-2, .row-3 { display: grid; gap: 0 1rem; }
@media (min-width: 40rem) { .row-2 { grid-template-columns: 1fr 1fr; } .row-3 { grid-template-columns: 1fr 1fr 1fr; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 700; line-height: 1.2; text-decoration: none; cursor: pointer;
  min-height: 2.9rem; padding: .6rem 1.1rem; border-radius: var(--r);
  border: 1.5px solid var(--glass); background: var(--white); color: var(--glass);
}
.btn:hover { background: #E7EEF5; color: var(--glass-dark); }
.btn-main { background: var(--glass); color: var(--white); }
.btn-main:hover { background: var(--glass-dark); color: var(--white); }
.btn-go { background: var(--settled); border-color: var(--settled); color: var(--white); }
.btn-go:hover { background: #155532; color: var(--white); }
.btn-quiet { border-color: var(--frame); color: var(--ink); }
.btn[disabled] { opacity: .55; cursor: progress; }
.link-btn { font: inherit; background: none; border: 0; padding: .25rem 0; color: var(--glass); text-decoration: underline; text-underline-offset: .15em; cursor: pointer; }

.flash { padding: .75rem 1rem; border-left: 5px solid var(--settled); background: var(--white); margin: 1rem 0; max-width: none; }
.flash-error { border-left-color: var(--owed); }
.hp { position: absolute; left: -9999px; }

/* ---------- Customer site ---------- */
.site-head { background: var(--ink); color: var(--white); }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; min-height: 3.75rem; flex-wrap: wrap; }
.brand { color: inherit; text-decoration: none; font-weight: 800; font-size: 1.15rem; }
.site .brand:hover, .head-phone:hover { color: var(--white); text-decoration: underline; }
.head-phone { color: var(--white); font-weight: 700; text-decoration: none; }
.site main { padding-top: 2rem; padding-bottom: 3rem; }
.lede { font-size: 1.1rem; color: var(--muted); }

.lookup { padding: 1rem 0 2.5rem; border-bottom: 2px solid var(--ink); }
.lookup h1 { font-size: clamp(2.2rem, 8vw, 3.6rem); font-weight: 800; letter-spacing: -.01em; margin-bottom: .35em; }
.lookup-form { display: grid; gap: 0 1rem; margin-top: 1.5rem; }
.lookup-form input { font-size: 1.25rem; min-height: 3.4rem; }
.lookup-form .btn { min-height: 3.4rem; font-size: 1.15rem; }
@media (min-width: 46rem) {
  .lookup-form { grid-template-columns: 1fr 1fr auto; align-items: end; }
  .lookup-form .field, .lookup-form .btn { margin-bottom: 0; }
}
.resume { background: var(--white); padding: .6rem .9rem; border: 1px solid var(--frame); max-width: none; }

.about { padding-top: 1.5rem; }
.about-cols { display: grid; gap: 1.5rem; }
@media (min-width: 46rem) { .about-cols { grid-template-columns: 3fr 2fr; } }
.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; align-content: start; }
.facts dt { font-weight: 700; }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.balance { padding-bottom: 2rem; border-bottom: 2px solid var(--ink); }
.addr { font-weight: 700; margin-bottom: 1.5rem; }
.ref { display: block; font-weight: 400; color: var(--muted); }
.bal-label { font-size: 1.35rem; font-weight: 700; margin: 0; }
.figure { font-size: clamp(4rem, 22vw, 8.5rem); font-weight: 800; line-height: 1; letter-spacing: -.03em; margin: .1em 0 .25em; position: relative; display: inline-block; max-width: 100%; }
.figure.is-owed { color: var(--owed); }
.figure.is-settled { color: var(--settled); }
.figure span { display: inline-block; }
.next { color: var(--muted); }

/* The one moment: a squeegee pass reveals the figure on first view. */
@media (prefers-reduced-motion: no-preference) {
  .figure.wipe span { animation: wipe-reveal .9s cubic-bezier(.6, 0, .25, 1) .15s both; }
  .figure.wipe::after {
    content: ""; position: absolute; top: -6%; bottom: -6%; left: 0; width: 7px;
    background: var(--ink); border-radius: 3px;
    box-shadow: -10px 0 0 -2px rgba(31, 95, 153, .18);
    animation: wipe-blade .9s cubic-bezier(.6, 0, .25, 1) .15s both;
  }
}
@keyframes wipe-reveal { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes wipe-blade {
  0% { left: 0; opacity: 1; }
  85% { left: calc(100% - 7px); opacity: 1; }
  100% { left: calc(100% - 7px); opacity: 0; }
}

.pay { margin-top: 1.5rem; }
.pay-form .btn-main { font-size: 1.25rem; min-height: 3.6rem; padding: .7rem 1.6rem; }
.other-amount { margin: 1.25rem 0 1rem; }
.other-amount summary { cursor: pointer; color: var(--glass); font-weight: 700; padding: .3rem 0; }
.inline-field { margin-top: .75rem; max-width: 26rem; }
.inline-field .btn { align-self: flex-start; margin-top: .5rem; }
.pay-offline { background: var(--white); border-left: 5px solid var(--glass); padding: 1rem 1.25rem; }
.pay-offline h2 { margin-top: 0; }
.bank { font-weight: 700; margin: 0; }

.history { padding-top: .5rem; }
.ledger { width: 100%; border-collapse: collapse; margin: .5rem 0 1.5rem; }
.ledger th, .ledger td { text-align: left; padding: .55rem .5rem .55rem 0; border-bottom: 1px solid var(--frame); vertical-align: top; }
.ledger thead th { border-bottom: 2px solid var(--ink); font-size: .95rem; }
.num { text-align: right !important; white-space: nowrap; }
.is-pay { color: var(--settled); }
.sub { display: block; color: var(--muted); font-size: .92rem; }
.signout { margin-top: 1rem; }

.site-foot { border-top: 1px solid var(--frame); background: var(--white); }
.foot-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1.5rem; padding-top: 1.25rem; padding-bottom: 1.25rem; }
.foot-row p { margin: 0; }

/* ---------- Backend ---------- */
.admin-head { background: var(--ink); color: var(--white); position: sticky; top: 0; z-index: 1000; }
.admin-bar { display: flex; justify-content: space-between; align-items: center; padding: .55rem 16px 0; gap: 1rem; }
.admin-bar .brand { color: var(--white); }
.admin-bar .link-btn { color: var(--white); font-size: .95rem; }
.admin-nav { display: flex; flex-wrap: wrap; gap: 0 .25rem; padding: .25rem 10px .2rem; }
.admin-nav a { color: #D6E2EE; text-decoration: none; padding: .55rem .55rem; font-weight: 700; font-size: .98rem; border-bottom: 3px solid transparent; }
.admin-nav a:hover { color: var(--white); }
.admin-nav a[aria-current="page"] { color: var(--white); border-bottom-color: #7FB3E3; }
.count { display: inline-block; background: var(--white); color: var(--ink); border-radius: 999px; font-size: .8rem; padding: 0 .45rem; margin-left: .2rem; }
.admin-main { max-width: 60rem; margin: 0 auto; padding: 1.25rem 16px 4rem; }
.admin-main.is-wide { max-width: 90rem; }
.bare-main { max-width: 26rem; margin: 0 auto; padding: 2.5rem 16px; }
.bare-main .brand { display: block; font-size: 1.1rem; margin-bottom: 2rem; color: var(--ink); }
.steps { padding-left: 1.25rem; }
.steps li { margin-bottom: .4rem; }
.qr { width: 220px; height: 220px; background: var(--white); border: 1px solid var(--frame); margin: 1rem 0; }
.qr svg { width: 100%; height: 100%; display: block; }
.key code { font-size: 1rem; letter-spacing: .05em; }

.run-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: .5rem 1.5rem; }
.run-head h1 { margin-bottom: .2em; }
.run-head p { margin-bottom: .75rem; }
.progress { font-weight: 700; font-size: 1.1rem; }

.plan-form { max-width: 36rem; }
.sub-choice { padding: 0 0 .5rem 1.85rem; display: grid; gap: .25rem; }

.list { width: 100%; border-collapse: collapse; margin: .5rem 0 1.5rem; background: var(--white); }
.list th, .list td { text-align: left; padding: .65rem .75rem; border-bottom: 1px solid var(--frame); vertical-align: top; }
.list thead th { border-bottom: 2px solid var(--ink); font-size: .95rem; background: var(--pane); }
.list .is-new td:first-child { box-shadow: inset 4px 0 0 var(--glass); }
.is-due { color: var(--owed); font-weight: 700; }
.state-paid { color: var(--settled); }
.state-one, .state-many { color: var(--owed); font-weight: 700; }

/* Tables become stacked rows on phones. */
@media (max-width: 40rem) {
  .list thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .list, .list tbody, .list tr, .list td { display: block; width: 100%; }
  .list tr { border-bottom: 1px solid var(--frame); padding: .5rem 0; }
  .list td { border: 0; padding: .15rem .75rem; text-align: left !important; }
  .list td[data-label]::before { content: attr(data-label) ": "; font-weight: 700; color: var(--muted); font-size: .9rem; }
  .list td[data-label="Address"]::before, .list td[data-label="House"]::before, .list td[data-label="Round"]:first-child::before, .list td[data-label="Request"]::before { content: none; }
}

.filters { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: flex-end; margin-bottom: 1rem; }
.filters .field { margin-bottom: .5rem; flex: 1 1 10rem; }
.filters .field:first-child { flex: 3 1 16rem; }
.filters .btn, .filters .choice { margin-bottom: .5rem; }
.inline-filter { display: flex; align-items: center; gap: .5rem; }
.inline-filter select { width: auto; min-width: 10rem; }

.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); margin: 0 0 1rem; border-top: 2px solid var(--ink); }
.totals div { padding: .75rem 1rem .75rem 0; border-bottom: 1px solid var(--frame); }
.totals dt { font-weight: 500; color: var(--muted); font-size: .95rem; }
.totals dd { margin: 0; font-size: 1.6rem; font-weight: 800; }

/* Map */
.map { width: 100%; background: #DDE5EC; border: 1px solid var(--frame); }
.map-big { height: min(72vh, 46rem); min-height: 22rem; }
.map-small { height: 16rem; margin-top: 1rem; }
.map-pick { height: 18rem; margin-bottom: 1rem; }
.map-run { height: 48vh; min-height: 18rem; }
.legend { list-style: none; padding: 0; margin: 0 0 .75rem; display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; align-items: center; }
.legend li { display: flex; align-items: center; gap: .45rem; }
.pin { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 3px solid; flex: none; }
.pin-paid { background: var(--glass); border-color: var(--glass); }
.pin-one { background: var(--white); border-color: var(--owed); }
.pin-many { background: var(--owed); border-color: var(--owed); }
.leaflet-container { font-family: var(--font); font-size: .95rem; }
.leaflet-popup-content { margin: .75rem 1rem; line-height: 1.45; }
.leaflet-popup-content p { margin: 0 0 .25rem; }
.run-pin { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; font-weight: 800; font-size: 13px; border: 3px solid; background: var(--white); color: var(--ink); box-sizing: border-box; }
.run-pin.paid { border-color: var(--glass); }
.run-pin.one { border-color: var(--owed); }
.run-pin.many { border-color: var(--owed); background: var(--owed); color: var(--white); }
.run-pin.done { background: var(--settled); border-color: var(--settled); color: var(--white); }
.run-pin.skip { background: #8796A4; border-color: #8796A4; color: var(--white); }
.start-pin { width: 16px; height: 16px; background: var(--ink); border: 3px solid var(--white); outline: 2px solid var(--ink); }

/* Day plan */
.run-layout { display: grid; gap: 1rem; }
@media (min-width: 64rem) {
  .run-layout { grid-template-columns: 1.1fr 1fr; align-items: start; }
  .map-run { position: sticky; top: 7.5rem; height: calc(100vh - 9rem); }
}
.nav-row { margin: 0 0 .5rem; }
.stops { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--ink); }
.stop { border-bottom: 1px solid var(--frame); padding: .9rem 0; background: var(--pane); }
.stop.is-active { background: var(--white); box-shadow: inset 4px 0 0 var(--glass); }
.stop-main { display: flex; gap: .75rem; }
.stop-n { flex: none; width: 2.1rem; height: 2.1rem; border-radius: 50%; border: 2px solid var(--ink); display: flex; align-items: center; justify-content: center; font-weight: 800; }
.stop.is-cleaned .stop-n { background: var(--settled); border-color: var(--settled); color: var(--white); }
.stop.is-skipped .stop-n { background: #8796A4; border-color: #8796A4; color: var(--white); }
.stop-text { min-width: 0; flex: 1; }
.stop-addr { font-size: 1.1rem; margin: .1rem 0 .15rem; }
.stop-addr a { color: var(--ink); }
.stop-meta, .stop-access, .stop-bal, .stop-status { margin: 0 0 .1rem; }
.stop-access { font-weight: 700; }
.stop-status { font-weight: 700; color: var(--settled); }
.stop.is-skipped .stop-status { color: var(--muted); }
.stop-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .65rem 0 0 2.85rem; }
.stop-actions .btn { min-height: 3rem; }
.stop.is-todo [data-act="undo"] { display: none; }
.stop:not(.is-todo) [data-act="cleaned"], .stop:not(.is-todo) [data-act="skip-open"] { display: none; }
.stop-form { margin: .75rem 0 0 2.85rem; display: grid; gap: .4rem; max-width: 22rem; }
.danger-row { margin-top: 2rem; }

/* House page */
.house-grid { display: grid; gap: 1rem 2.5rem; }
@media (min-width: 56rem) { .house-grid { grid-template-columns: 1fr 1fr; } }
.house-grid h2:first-child, .house-grid section > h2:first-of-type { margin-top: .25rem; }
.figure-sm { font-size: 2.2rem; font-weight: 800; margin: 0 0 .25rem; }
.house-summary .facts { margin-top: 1rem; }
.seg { display: inline-flex; border: 1.5px solid var(--glass); border-radius: var(--r); overflow: hidden; margin-bottom: 1rem; flex-wrap: wrap; }
.seg-btn { font: inherit; font-weight: 700; border: 0; background: var(--white); color: var(--glass); padding: .55rem .9rem; min-height: 2.75rem; cursor: pointer; }
.seg-btn + .seg-btn { border-left: 1.5px solid var(--glass); }
.seg-btn[aria-pressed="true"] { background: var(--glass); color: var(--white); }
.record-form { max-width: 26rem; }
.copy-row { display: flex; gap: .5rem; flex-wrap: wrap; max-width: none; }
.copy-input { flex: 1 1 14rem; font-size: .9rem; }
.link-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.slip { display: none; }
.house-form { max-width: 46rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.narrow-form { max-width: 24rem; }
.edit-round summary { cursor: pointer; color: var(--glass); font-weight: 700; }
.edit-round[open] { min-width: 14rem; }
.settings-form { max-width: 46rem; }

/* Printable slip: only the slip prints. */
@media print {
  body.printing-slip * { visibility: hidden; }
  body.printing-slip .slip, body.printing-slip .slip * { visibility: visible; }
  body.printing-slip .slip { display: block; position: absolute; left: 0; top: 0; width: 9cm; font-size: 11pt; color: #000; }
  .slip-name { font-weight: 800; font-size: 13pt; }
  .slip-qr { width: 3.5cm; height: 3.5cm; }
  .slip-qr svg { width: 100%; height: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
