:root {
    color-scheme: light;
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    color: #172438;
    background: #f5f7fb;
    --ink: #172438;
    --dark: #14223a;
    --accent: #245de4;
    --border: #e2e8f2;
    --muted: #52627a;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
body.public { display: block; }
main { padding: 32px clamp(16px,4vw,56px); width: 100%; max-width: 1550px; margin: 0 auto; min-width: 0; }
.public main { max-width: 860px; }
a { color: #2255c3; text-underline-offset: 3px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.8rem,4vw,3rem); line-height: 1.1; margin-bottom: .4em; letter-spacing: -.04em; overflow-wrap: anywhere; }
h2 { font-size: 1.19rem; margin-bottom: .7em; }
h3 { font-size: 1rem; margin: .5rem 0 .1rem; }
p { line-height: 1.55; margin-bottom: .75rem; }
[hidden] { display: none !important; }
.sidebar { position: sticky; top: 0; height: 100dvh; padding: 20px 15px; display: flex; flex-direction: column; background: white; color: var(--ink); border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: .65rem; color: inherit; text-decoration: none; font-weight: 800; font-size: 1.15rem; }
.sidebar .brand { padding: 0 .4rem 1.5rem; }
.brand small { display: block; font-size: .58rem; letter-spacing: .13em; color: var(--muted); margin-top: .2rem; }
.mark { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 11px; color: white; background: #245de4; box-shadow: 0 4px 12px #245de438; font-weight: 850; font-size: 1.3rem; flex: none; }
.public-brand { justify-content: center; margin: 0 0 2rem; }
nav { display: grid; gap: .3rem; }
nav a { color: #465672; text-decoration: none; padding: .72rem .75rem; border-radius: 10px; display: flex; gap: .7rem; align-items: center; white-space: nowrap; }
nav a:hover, nav a[aria-current] { color: #194dbd; background: #eaf0ff; }
nav a span { width: 18px; color: #3765cc; text-align: center; }
.account-card { display: flex; align-items: center; gap: .65rem; padding: .7rem; margin-bottom: 1.35rem; background: #f5f7fb; border-radius: 12px; font-size: .84rem; overflow-wrap: anywhere; }
.account-card small { display: block; margin-top: .18rem; color: var(--muted); }
.account-avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: #415ee6; color: white; font-weight: 800; flex: none; }
.profile { margin-top: auto; padding: 1rem .4rem 0; border-top: 1px solid var(--border); }
.profile button { background: #fff0f1; color: #a5283c; border-color: #f5dce0; }
.workspace { min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: 12px clamp(14px,4vw,56px); background: white; border-bottom: 1px solid var(--border); }
.section-head, .actions, .filters, .picker { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; }
.section-head { justify-content: space-between; margin: 0 0 1rem; }
.section-head h2, .section-head h1 { margin: 0; }
.top { margin-bottom: 1.35rem; align-items: end; }
.filters, .picker { align-items: end; }
.eyebrow { font-weight: 800; color: var(--accent); font-size: .72rem; letter-spacing: .13em; margin-bottom: .45rem; text-transform: uppercase; }
.card, .event, .empty, .alert { background: white; border: 1px solid var(--border); border-radius: 15px; padding: clamp(14px,2.3vw,24px); }
.card { margin-bottom: 1rem; box-shadow: 0 3px 12px #172b2907; }
.card.login { max-width: 480px; margin: 0 auto; padding: clamp(20px,5vw,36px); }
.alert { margin-bottom: 1rem; color: #165540; background: #e3f6e9; }
.alert.error { color: #842f27; background: #fff0ed; border-color: #efc7c0; }
.columns { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.stats { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .85rem; margin-bottom: 1rem; }
.stats .stat { margin: 0; }
.stat-icon { display: grid; place-items: center; width: 32px; height: 32px; margin-bottom: .6rem; font-style: normal; font-weight: 800; border-radius: 9px; background: #eaf0ff; color: #2051c4; }
.stat:nth-child(2) .stat-icon { background: #fff0e5; color: #a34816; }
.stat:nth-child(3) .stat-icon { background: #f1eaff; color: #7040ac; }
.stat:nth-child(4) .stat-icon { background: #e2f7ed; color: #167654; }
.dashboard-banner { display: flex; justify-content: space-between; gap: .75rem; align-items: center; flex-wrap: wrap; }
.dashboard-banner p { margin: 0; }
.stat span, .stat strong { display: block; overflow-wrap: anywhere; }
.stat span, .muted, .meta, label small { color: var(--muted); }
.stat strong { font-size: clamp(1rem,2vw,1.7rem); margin-top: .55rem; }
.hero { padding: clamp(18px,4vw,32px); border-radius: 17px; background: linear-gradient(120deg,#202e46,#101b30 72%,#192e58); color: white; margin: .8rem 0 1rem; box-shadow: 0 8px 18px #182a4822; }
.hero .eyebrow, .hero p, .hero-balance span { color: #dce6f8; }
.hero-balance { display: flex; justify-content: space-between; flex-wrap: wrap; align-items: center; gap: .5rem; border-top: 1px solid #6e7f9d; padding-top: .85rem; }
.total { font-size: clamp(1.45rem,3vw,2.25rem); }
.back { display: inline-block; margin-bottom: .4rem; }
.form { display: grid; gap: .85rem; margin-top: .8rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
label { display: grid; gap: .33rem; font-size: .88rem; font-weight: 650; color: var(--ink); min-width: 0; }
input, select, textarea { border: 1px solid #c9d4e5; border-radius: 9px; padding: .65rem .7rem; color: inherit; background: #fff; width: 100%; font: inherit; min-height: 42px; }
textarea { resize: vertical; min-height: 74px; }
input[type=checkbox] { width: 1.1rem; min-height: 1.1rem; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: .5rem; }
button, .button { min-height: 42px; padding: .58rem .85rem; border: 1px solid transparent; border-radius: 9px; background: var(--accent); color: white; cursor: pointer; font: inherit; font-size: .88rem; font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; text-align: center; box-shadow: 0 3px 8px #245de426; }
button:hover, .button:hover { filter: brightness(.92); }
.quiet { background: #edf2fd; color: #214b9a; border-color: #d7e2f7; box-shadow: none; }
:focus-visible { outline: 3px solid #3568dc; outline-offset: 3px; }
.actions { margin: .75rem 0 .25rem; }
.customer-jumps { display: none; margin-bottom: 1rem; }
.uploads { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .4rem; }
.uploads label { position: relative; display: grid; place-content: center; text-align: center; overflow-wrap: anywhere; cursor: pointer; background: #f1f5fd; border: 1px dashed #95a9d0; border-radius: 8px; padding: .55rem .3rem; min-height: 48px; }
.uploads label::after { content: attr(data-selected); font-size: .68rem; color: var(--accent); }
.uploads label:focus-within { outline: 2px solid var(--accent); }
.uploads input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.timeline { display: grid; gap: .75rem; }
.event-head { display: flex; justify-content: space-between; gap: .65rem; }
.event-head strong { white-space: nowrap; }
.pill { display: inline-block; border-radius: 99px; background: #eaf0ec; color: #40574b; font-size: .73rem; font-weight: 750; padding: .26rem .55rem; }
.pill.work { color: #1d536d; background: #e5f1fb; }
.pill.payment { color: #1e6545; background: #e3f5e9; }
.pill.quote { color: #634e19; background: #f8f0d8; }
.pill.adjustment { color: #6b3b75; background: #f4eafa; }
.meta { font-size: .78rem; margin-top: .35rem; }
.note, pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,135px),1fr)); gap: .5rem; }
.media-grid figure { min-width: 0; margin: 0; }
.media-grid img, .media-grid video { width: 100%; max-height: 220px; object-fit: contain; border-radius: 8px; background: #eaf0ed; }
.media-grid figcaption { color: var(--muted); font-size: .72rem; overflow-wrap: anywhere; }
details { margin-top: .75rem; border-top: 1px solid var(--border); padding-top: .65rem; }
summary { cursor: pointer; color: #2451a3; font-weight: 650; overflow-wrap: anywhere; }
.empty { color: var(--muted); border-style: dashed; background: #f8faf9; }
.customer-row { display: flex; justify-content: space-between; gap: .6rem; padding: .85rem 0; border-bottom: 1px solid var(--border); text-decoration: none; overflow-wrap: anywhere; }
.customer-row small { display: block; color: var(--muted); }
.customer-row:hover strong { text-decoration: underline; }
.customer-row .pill { align-self: center; flex-shrink: 0; }
.balance-due { color: #a62539; background: #fff0f2; }
.balance-settled { color: #38536d; background: #eaf0f7; }
.balance-credit { color: #176346; background: #e3f5eb; }
.balance-filters { display: flex; flex-wrap: wrap; gap: .25rem; padding: .3rem; background: #eef2f8; border-radius: 10px; margin: .75rem 0; }
.balance-filters a { flex: 1 0 auto; padding: .5rem; border-radius: 7px; text-decoration: none; text-align: center; font-size: .78rem; font-weight: 700; }
.balance-filters a[aria-current] { background: white; box-shadow: 0 1px 5px #152c5120; }
.balance-filters small { color: var(--muted); margin-left: .2rem; }
.setup-link { margin-top: 1rem; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; text-align: left; }
th, td { border-bottom: 1px solid var(--border); padding: .7rem .6rem; }
th { color: var(--muted); font-size: .8rem; }
footer { margin: 1.75rem 0 0; color: var(--muted); font-size: .78rem; }
@media(max-width: 900px) {
    .stats { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .columns { grid-template-columns: 1fr; }
    .customer-jumps { display: flex; }
}
@media(max-width: 640px) {
    body { display: block; }
    .sidebar { position: static; height: auto; padding: .7rem .85rem; }
    .sidebar .brand { padding: 0 0 .55rem; }
    .account-card { display: none; }
    nav { display: flex; flex-wrap: wrap; gap: .25rem; }
    nav a { padding: .5rem; font-size: .84rem; gap: .25rem; }
    nav a span { display: none; }
    .profile { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; padding: .5rem 0 0; font-size: .76rem; }
    .profile small { margin: 0 auto 0 0; }
    .profile button { min-height: 34px; padding: .35rem .55rem; }
    main { padding: 18px 12px; }
    input, textarea, select { font-size: 16px; }
}

/* Compact screens and quick customer lookup */
:root { background: #eef3f8; --accent: #1854cb; }
.topbar .compact { gap: .55rem; font-size: 1rem; }
.topbar .mark { width: 34px; height: 34px; border-radius: 10px; }
.topbar .quiet { min-height: 38px; }
.bottom-nav { display: none; }
.search-hero { max-width: 680px; margin: 1.25rem auto; padding: clamp(18px,4vw,42px); background: #fff; border: 1px solid var(--border); border-radius: 24px; box-shadow: 0 14px 45px #1d365114; }
.search-hero h1 { font-size: clamp(1.65rem,5vw,2.55rem); margin-bottom: 1rem; }
.live-search { display: flex; align-items: end; gap: .45rem; }
.live-search label { flex: 1; }
.live-search input { min-height: 48px; background: #f6f8fc; }
.live-search button { min-height: 48px; }
[data-results]:not(:empty) { margin-top: .75rem; }
.chart-days { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: .4rem; text-align: center; }
.chart-day { min-width: 0; color: var(--muted); }
.chart-bars { height: 110px; display: flex; align-items: center; justify-content: center; gap: 3px; background: repeating-linear-gradient(to top,#e9eff7 0 1px,transparent 1px 27px); }
.chart-bars meter { width: 16px; max-width: 40%; height: 104px; writing-mode: vertical-lr; direction: rtl; accent-color: #2662e7; }
.chart-bars meter:nth-child(2) { accent-color: #15805e; }
.chart-bars meter::-webkit-meter-optimum-value { background: #2662e7; }
.chart-bars meter:nth-child(2)::-webkit-meter-optimum-value { background: #15805e; }
.chart-legend { display: flex; gap: .4rem; align-items: center; font-size: .78rem; color: var(--muted); }
.chart-legend i { width: .65rem; height: .65rem; border-radius: 3px; background: #2662e7; }
.chart-legend i:nth-child(2) { background: #15805e; }
#new-customer { max-width: 640px; }

.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
.customer-row { min-height:56px; align-items:center; }
.live-search { width:100%; }
.entry-form > summary { font-size:1.05rem; color:var(--ink); }
@media (max-width: 760px) {
    :root { background:#f4f7fb; }
    body { display:block; }
    .sidebar { display:none; }
    .topbar { position:sticky; top:0; z-index:2; padding:8px 14px; min-height:54px; }
    .topbar .mark { width:30px; height:30px; box-shadow:none; }
    .topbar .quiet { min-height:42px; }
    main { padding:14px 12px calc(82px + env(safe-area-inset-bottom)); }
    .public main { padding-bottom:20px; }
    .bottom-nav { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); position:fixed; z-index:3; inset:auto 0 0; background:#fff; border-top:1px solid var(--border); padding:5px 6px calc(5px + env(safe-area-inset-bottom)); }
    .bottom-nav a { display:flex; flex-direction:column; gap:3px; min-height:49px; padding:4px 1px; justify-content:center; font-size:.69rem; font-weight:700; }
    .bottom-nav a span { display:block; font-size:1.12rem; width:auto; }
    .section-head.top { align-items:stretch; flex-direction:column; gap:.55rem; margin-bottom:.75rem; }
    .top h1 { font-size:1.6rem; }
    .picker { width:100%; flex-wrap:nowrap; }
    .picker label { flex:1; }
    .card,.event,.hero,.search-hero { border-radius:14px; padding:14px; }
    .search-hero { margin:6px auto; }
    .search-hero h1 { font-size:1.65rem; }
    .customer-jumps { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:5px; }
    .customer-jumps a { min-height:44px; padding:4px; font-size:.74rem; }
    .customer-layout { gap:.7rem; }
    .customer-layout > div { min-width:0; }
    #new-entry,#customer-share,#customer-timeline { scroll-margin-top:66px; }
    .balance-filters { gap:3px; }
    .balance-filters a { min-height:42px; display:grid; place-items:center; font-size:.72rem; padding:.3rem; }
    .customer-row .pill { max-width:48%; overflow-wrap:anywhere; text-align:right; }
    .chart-bars { height:94px; }
    .chart-bars meter { height:90px; }
    .two { grid-template-columns:repeat(2,minmax(0,1fr)); }
    input,select,textarea { font-size:16px; }
}
