/* Alpha1 Ventures Back Office
   Layout: navy top bar, content column on a cool paper ground; panels for each record section.
   Built phone-first for crews on site; tables scroll inside their own box. */
:root {
  --bg: #eef2f8; --surface: #ffffff; --surface-2: #f6f8fc; --ink: #0e1b3d; --muted: #56647f; --line: #d8e0ec;
  --navy: #13307a; --bar: #0b1f52; --bar-ink: #eaf1fb; --cyan: #1aa6d3; --cyan-ink: #0a7aa3;
  --good: #1f8a52; --good-bg: #e3f5ea; --warn: #9a5b00; --warn-bg: #fff3dc; --bad: #b42318; --bad-bg: #fde8e6; --info-bg: #e5f4fb;
  --f-display: "Josefin Slab", Rockwell, Georgia, serif;
  --f-body: "Hanken Grotesk", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #07122b; --surface: #0e1d40; --surface-2: #0b1836; --ink: #e7eef9; --muted: #9eb0cf; --line: #1f3566;
    --navy: #8fb2ff; --bar: #050e24; --bar-ink: #eaf1fb; --cyan: #3cc4ec; --cyan-ink: #5fd0f2;
    --good: #5ad38f; --good-bg: #0f3324; --warn: #f2b84b; --warn-bg: #3a2a08; --bad: #ff8a80; --bad-bg: #3d1414; --info-bg: #0d2c44;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.55 var(--f-body); }
a { color: var(--navy); }
img { max-width: 100%; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 700; line-height: 1.12; margin: 0 0 .5rem; text-wrap: balance; }
h1 { font-size: clamp(1.7rem, 4.5vw, 2.4rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 .8rem; }
code, .mono { font-family: var(--f-mono); font-size: .85em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.warn-text { color: var(--warn); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.nowrap { white-space: nowrap; }
.wrap { word-break: break-word; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }

/* Top bar */
.bar { position: sticky; top: 0; z-index: 30; background: var(--bar); color: var(--bar-ink); display: flex; align-items: center; gap: 1rem;
  padding: .5rem max(16px, env(safe-area-inset-right)) .5rem max(16px, env(safe-area-inset-left)); padding-top: calc(.5rem + env(safe-area-inset-top)); }
.brand { display: flex; align-items: center; gap: .7rem; color: var(--bar-ink); text-decoration: none; }
.brand img { height: 38px; width: auto; }
.brand span { font: 600 .72rem var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: #8fdcf5; border-left: 1px solid rgba(255,255,255,.2); padding-left: .7rem; }
.bar nav { margin-left: auto; display: flex; align-items: center; gap: .15rem; flex-wrap: wrap; }
.bar nav a { color: var(--bar-ink); text-decoration: none; padding: .5rem .7rem; border-radius: 3px; font-weight: 600; font-size: .92rem; }
.bar nav a:hover { background: rgba(255,255,255,.08); }
.bar nav a[aria-current="page"] { background: rgba(60,196,236,.18); color: #fff; box-shadow: inset 0 -2px 0 #3cc4ec; }
.bar .who { font-size: .8rem; color: #a9bbdb; padding: 0 .5rem; }
.bar form { margin: 0; }
.bar .link { color: #a9bbdb; }
.menu { display: none; margin-left: auto; background: transparent; color: var(--bar-ink); border: 1px solid rgba(255,255,255,.3); border-radius: 3px; padding: .45rem .8rem; font: 600 .9rem var(--f-body); }
.dot { display: inline-grid; place-items: center; min-width: 1.35em; height: 1.35em; padding: 0 .35em; border-radius: 99px; background: var(--cyan); color: #04122e; font: 700 .72rem/1 var(--f-body); vertical-align: middle; }
@media (max-width: 980px) {
  .menu { display: inline-flex; gap: .4rem; align-items: center; }
  .bar { flex-wrap: wrap; }
  .bar nav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding: .5rem 0; }
  .bar nav.open { display: flex; }
  .bar nav a { padding: .8rem .6rem; border-bottom: 1px solid rgba(255,255,255,.08); }
  .bar .who { padding: .8rem .6rem 0; }
  .bar .link { padding: .4rem .6rem; }
}

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem max(16px, env(safe-area-inset-right)) 4rem max(16px, env(safe-area-inset-left)); display: grid; gap: 1.2rem; align-content: start; }
main.wide { max-width: 1320px; }
main > * { min-width: 0; }

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; }
.page-head .actions, .row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.eyebrow { font: 600 .72rem/1.3 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--cyan-ink); margin: 0 0 .35rem; }
.eyebrow a { color: inherit; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: clamp(1rem, 2.5vw, 1.5rem); min-width: 0; }
.panel > :last-child { margin-bottom: 0; }
.panel.narrow, .narrow { max-width: 460px; }
.cols { display: grid; gap: 1.2rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); align-items: start; }
.split { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.count { font: 600 .8rem var(--f-mono); color: var(--muted); }
.sep { margin-top: 1.2rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }

/* Buttons and forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 42px; padding: .55rem 1rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 4px; font: 600 .93rem/1.1 var(--f-body); text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--navy); }
.btn.primary { background: var(--cyan); border-color: var(--cyan); color: #04122e; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); border-color: currentColor; }
.btn.small { min-height: 34px; padding: .35rem .7rem; font-size: .85rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; color: var(--navy); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link.danger { color: var(--bad); }
form { margin: 0; }
form.inline { display: inline; }
.stack { display: grid; gap: .9rem; }
.inline-form { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; margin-top: 1rem; }
.inline-form .field { min-width: 180px; }
.grid2, .grid3 { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.field { display: grid; gap: .3rem; min-width: 0; }
.field label, label { font: 600 .74rem/1.2 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
input, select, textarea { font: 400 1rem/1.35 var(--f-body); color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: .65rem .7rem; width: 100%; min-height: 44px; }
input[type="checkbox"] { width: 1.15rem; height: 1.15rem; min-height: 0; accent-color: var(--cyan); }
input[type="file"] { padding: .5rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--cyan); outline-offset: 0; border-color: var(--cyan); }
textarea { resize: vertical; }
fieldset.group { border: 1px solid var(--line); border-radius: 6px; padding: .9rem; margin: 0; display: grid; gap: .8rem; }
fieldset.bare { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: 1rem; }
legend { font: 600 .74rem var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--cyan-ink); padding: 0 .3rem; }
.check { display: flex; gap: .6rem; align-items: flex-start; font: 500 .95rem var(--f-body); text-transform: none; letter-spacing: 0; color: var(--ink); }
.searchbar { display: flex; gap: .5rem; }
.searchbar input { flex: 1; }
.filters { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); align-items: end; }

/* Flashes, pills */
.flash { padding: .8rem 1rem; border-radius: 5px; background: var(--good-bg); border-left: 4px solid var(--good); }
.flash.warn { background: var(--warn-bg); border-color: var(--warn); }
.flash.info { background: var(--info-bg); border-color: var(--cyan); }
.pill { display: inline-block; font: 600 .7rem/1 var(--f-mono); letter-spacing: .05em; text-transform: uppercase; padding: .38em .6em; border-radius: 3px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.st-estimating { background: #eef0ff; color: #4049a8; border-color: #c9cdf5; }
.st-scheduled, .st-submitted, .st-invited { background: var(--info-bg); color: var(--cyan-ink); border-color: transparent; }
.st-in-progress, .st-approved-–-budget { background: #e6ecfb; color: var(--navy); border-color: transparent; }
.st-awaiting-sign-off, .st-submitted-for-review, .st-signed-–-review, .st-signed-by-customer, .st-submitted-for-admin-review, .st-coming-soon { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.st-completed, .st-done, .st-reviewed, .st-reviewed-and-accepted, .st-active, .st-on, .st-login-on, .st-paid-in-full, .st-job-created { background: var(--good-bg); color: var(--good); border-color: transparent; }
.st-archived, .st-inactive, .st-closed, .st-login-off { background: var(--surface-2); color: var(--muted); }
.st-expired, .st-overdue { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
@media (prefers-color-scheme: dark) { .st-estimating { background: #1d2255; color: #b7bdf7; border-color: transparent; } .st-in-progress { background: #172b5c; } }

/* KPI tiles */
.kpis { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: .9rem 1rem; display: grid; gap: .2rem; text-decoration: none; color: var(--ink); }
.kpi span { font: 600 .7rem var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.kpi b { font: 700 1.55rem/1.1 var(--f-body); }
.kpi small { color: var(--muted); font-size: .8rem; }
.kpi.alert { border-color: var(--bad); box-shadow: inset 4px 0 0 var(--bad); }
.kpi.credit b, td.credit { color: var(--good); }

/* Tables */
.tblwrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 4px; }
.tbl { width: 100%; border-collapse: collapse; font-size: .93rem; }
.tbl th { text-align: left; font: 600 .68rem var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: .55rem .6rem; border-bottom: 2px solid var(--line); white-space: nowrap; }
.tbl td { padding: .65rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tfoot th { border-top: 2px solid var(--line); border-bottom: 0; color: var(--ink); font-size: .78rem; }
.tbl .r, .r { text-align: right; }
.tbl .c { text-align: center; }
.tbl td.neg, .neg { color: var(--bad); }
.tbl td.pos { color: var(--good); }
.tbl a { text-decoration: none; }
.tbl a:hover { text-decoration: underline; }
.tbl.jobs td { min-width: 110px; }
.tbl.jobs td:first-child { min-width: 200px; }

/* Lists */
.joblist, .datelist, .cards, .inbox, .tasks { list-style: none; margin: 0; padding: 0; }
.joblist li { padding: .7rem 0; border-bottom: 1px solid var(--line); display: grid; gap: .35rem; }
.joblist li:last-child { border-bottom: 0; }
.joblist a { display: grid; gap: .1rem; text-decoration: none; color: var(--ink); }
.joblist .jn { font-size: .78rem; color: var(--muted); }
.datelist li { display: grid; grid-template-columns: 64px 1fr; gap: .8rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.datelist .d { font: 600 .82rem var(--f-mono); color: var(--cyan-ink); }
.datelist li.late .d, .datelist li.late b { color: var(--bad); }
.cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.cards li { display: grid; gap: .5rem; align-content: start; }
.cardlink { text-decoration: none; color: var(--ink); }
.prog { display: inline-block; width: 110px; height: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; vertical-align: middle; }
.prog.wide { width: 100%; max-width: 360px; margin: .3rem 0; }
.prog i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--navy)); }
.progcell { min-width: 150px; }
.empty { padding: 1.4rem; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 6px; }
.empty p { margin-bottom: .6rem; }
.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: .55rem 1.2rem; margin: 0 0 1rem; }
.kv dt { font: 600 .7rem/1.9 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.kv dd { margin: 0; min-width: 0; word-break: break-word; }
@media (max-width: 520px) { .kv { grid-template-columns: 1fr; gap: .1rem; } .kv dd { margin-bottom: .6rem; } }

/* Tabs */
.tabs, .subtabs { display: flex; gap: .2rem; overflow-x: auto; border-bottom: 2px solid var(--line); -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.tabs a, .subtabs a { padding: .7rem .9rem; text-decoration: none; color: var(--muted); font-weight: 600; white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs a[aria-current="page"], .subtabs a[aria-current="page"] { color: var(--ink); border-color: var(--cyan); }
.subtabs { border-bottom-width: 1px; }

/* Photos */
.thumbs { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); margin: .6rem 0; }
.thumb { position: relative; display: block; aspect-ratio: 1; overflow: hidden; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb span { position: absolute; left: 0; right: 0; bottom: 0; padding: .3rem .45rem; font-size: .72rem; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.75)); }
.thumb.doc { display: grid; place-content: center; text-align: center; padding: .5rem; gap: .3rem; }
.thumb.doc span { position: static; background: none; color: var(--muted); }
.thumb.doc b { font: 700 1rem var(--f-mono); color: var(--cyan-ink); }
.lb { position: fixed; inset: 0; z-index: 100; background: rgba(3,9,25,.94); display: grid; place-items: center; padding: 1rem; }
.lb img { max-width: 100%; max-height: 86vh; }
.lb p { color: #dfe8f7; text-align: center; margin-top: .6rem; }
.lb button { position: absolute; top: calc(.6rem + env(safe-area-inset-top)); right: .8rem; background: #fff; border: 0; border-radius: 99px; width: 40px; height: 40px; font-size: 1.2rem; cursor: pointer; }

/* Checklist */
.task { border-bottom: 1px solid var(--line); }
.task summary { list-style: none; display: flex; align-items: center; gap: .8rem; padding: .75rem 0; cursor: pointer; flex-wrap: wrap; }
.task summary::-webkit-details-marker { display: none; }
.task .tt { display: grid; flex: 1; min-width: 200px; }
.tick { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.task.done .tick { background: var(--good); border-color: var(--good); box-shadow: inset 0 0 0 3px var(--surface); }
.task.submitted .tick { border-color: var(--warn); background: var(--warn-bg); }
.task.done .tt b { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }
.taskbody { padding: 0 0 1rem 2.2rem; display: grid; gap: .6rem; }
@media (max-width: 560px) { .taskbody { padding-left: 0; } }

/* Crew rows */
.crewrow { display: grid; gap: .8rem; grid-template-columns: minmax(180px, 1fr) 2fr minmax(120px, 160px) auto; align-items: end; padding: 1rem 0; border-bottom: 1px solid var(--line); }
.crewbtns { display: flex; gap: .6rem; align-items: center; }
@media (max-width: 860px) { .crewrow { grid-template-columns: 1fr; } }

/* Messages */
.chat .msgs { display: grid; gap: .7rem; max-height: 60vh; overflow-y: auto; padding: .5rem .2rem 1rem; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: .8rem; }
.msg { max-width: min(560px, 92%); justify-self: start; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px 10px 10px 2px; padding: .6rem .8rem; }
.msg.mine { justify-self: end; background: var(--info-bg); border-color: transparent; border-radius: 10px 10px 2px 10px; }
.msg.r-client:not(.mine) { border-left: 3px solid var(--warn); }
.msg .meta { font-size: .78rem; color: var(--muted); margin-bottom: .2rem; }
.msg .meta b { color: var(--ink); }
.msg .body { white-space: normal; word-break: break-word; }
.msg .thumbs { grid-template-columns: repeat(auto-fill, minmax(160px, 220px)); }
.composer { display: grid; grid-template-columns: 1fr auto auto; gap: .5rem; align-items: end; }
.composer textarea { min-height: 48px; }
.attach { position: relative; display: inline-flex; align-items: center; min-height: 44px; padding: 0 .9rem; border: 1px solid var(--line); border-radius: 4px; cursor: pointer; text-transform: none; letter-spacing: 0; font: 600 .9rem var(--f-body); color: var(--ink); }
.attach input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.attach.has span::after { content: " ✓"; color: var(--good); }
@media (max-width: 560px) { .composer { grid-template-columns: 1fr 1fr; } .composer textarea { grid-column: 1 / -1; } }
.inbox li { position: relative; border-bottom: 1px solid var(--line); }
.inbox a { display: grid; gap: .15rem; padding: .85rem 2.5rem .85rem .2rem; text-decoration: none; color: var(--ink); }
.inbox li.unread b { color: var(--navy); }
.inbox .dot { position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); }

/* Estimate */
.estlines input, .estlines select { min-height: 38px; padding: .4rem .45rem; font-size: .92rem; }
.estlines td { padding: .35rem .3rem; }
.estlines td:nth-child(2) { min-width: 220px; }
.estlines td:nth-child(3), .estlines td:nth-child(5), .estlines td:nth-child(6) { min-width: 90px; }
.esttotals { display: flex; justify-content: flex-end; }
.esttotals dl { display: grid; grid-template-columns: auto auto; gap: .35rem 1.6rem; margin: 0; min-width: 280px; }
.esttotals dd { margin: 0; text-align: right; }

/* Signature */
.signbox { margin-top: 1.2rem; padding: 1rem; border: 1px dashed var(--cyan); border-radius: 6px; display: grid; gap: .6rem; justify-items: start; }
.sigpad { position: relative; background: #fff; border: 2px solid var(--line); border-radius: 6px; touch-action: none; }
.sigpad canvas { display: block; width: 100%; height: auto; aspect-ratio: 900 / 260; cursor: crosshair; }
.sigpad [data-sig-clear] { position: absolute; right: .6rem; top: .4rem; color: #3b4a6b; }
.sigpad::after { content: "Sign here"; position: absolute; left: 1rem; bottom: 22%; font: 600 .7rem var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: #9aa6bd; border-top: 1px solid #c7cfdd; width: calc(100% - 2rem); padding-top: .3rem; pointer-events: none; }
.sigform { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.sigimg { background: #fff; border: 1px solid var(--line); border-radius: 4px; max-width: 320px; margin-top: .4rem; }
.sharelink { display: grid; grid-template-columns: auto 1fr auto; gap: .6rem; align-items: center; background: var(--info-bg); padding: .7rem; border-radius: 6px; margin-bottom: 1rem; }
.sharelink .k { font: 600 .72rem var(--f-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--cyan-ink); }
.sharelink input { min-height: 36px; font-family: var(--f-mono); font-size: .8rem; }
@media (max-width: 640px) { .sharelink { grid-template-columns: 1fr; } }
.steps { padding-left: 1.2rem; display: grid; gap: .6rem; }
code.key { font-size: 1.05rem; background: var(--surface-2); padding: .2rem .45rem; border-radius: 4px; letter-spacing: .05em; }

/* Sign-in screens */
.auth { max-width: 440px; margin: 6vh auto 0; display: grid; gap: 1.2rem; justify-items: center; }
.auth.wide-auth { max-width: 760px; margin-top: 2rem; justify-items: stretch; }
.auth.wide-auth .auth-logo { justify-self: center; }
.auth .panel { width: 100%; }
.auth-logo { height: 76px; width: auto; }
.auth-logo.dark { display: none; }
@media (prefers-color-scheme: dark) { .auth-logo { display: none; } .auth-logo.dark { display: block; } }
