/* Ennovantiv brand: Deep Navy / Electric Blue / Off-White, Inter. No red or green accents. */
:root {
  --navy: #0B1F3A;
  --navy-2: #122B50;
  --blue: #5B7FD4;
  --cerulean: #4A90D9;
  --steel: #2A4A72;
  --grey-1: #C8D4E8;
  --bg: #F4F6FA;
  --card: #FFFFFF;
  --text: #0B1F3A;
  --muted: #5A6B85;
  --line: #DCE3EE;
  --warn: #B26B00;
  --warn-bg: #FFF4E0;
  --radius: 10px;
  --nav-h: 64px;
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { min-height: 100vh; font-size: 15px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
h1 { font-weight: 300; font-size: 1.9rem; margin: 0; letter-spacing: -0.01em; }
h2 { font-weight: 600; font-size: 1.05rem; margin: 0 0 .9rem; }
a { color: var(--cerulean); }
code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: .85em; background: #EEF2F8; padding: .05em .35em; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.r { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .6rem 1rem; padding-top: max(.6rem, env(safe-area-inset-top)); background: var(--navy); color: #fff; }
.topbar-right { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.brandmark { display: flex; align-items: center; gap: .6rem; color: inherit; text-decoration: none; }
.brandmark img { height: 34px; width: auto; }
.brandmark .wm { font-weight: 300; font-size: 1.35rem; letter-spacing: .01em; line-height: 1; display: flex; flex-direction: column; }
.brandmark .wm small { font-weight: 600; font-size: .5rem; letter-spacing: .38em; margin-top: .3rem; color: var(--grey-1); }
.brandmark.big { justify-content: center; margin-bottom: 1rem; gap: .9rem; }
.brandmark.big img { height: 64px; }
.brandmark.big .wm { font-size: 2rem; color: var(--navy); }
.brandmark.big .wm small { color: var(--steel); }
.filechip { display: inline-flex; align-items: center; gap: .45rem; color: var(--grey-1); text-decoration: none; font-size: .82rem;
  border: 1px solid var(--steel); padding: .3rem .7rem; border-radius: 999px; max-width: 46vw; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.filechip:hover { color: #fff; border-color: var(--blue); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); flex: none; box-shadow: 0 0 0 3px rgba(91,127,212,.25); }
.dot.off { background: var(--muted); box-shadow: none; }
.iconbtn { background: none; border: 1px solid var(--steel); color: var(--grey-1); border-radius: 8px; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; }
.iconbtn:hover { color: #fff; border-color: var(--blue); }
.iconbtn svg { width: 18px; height: 18px; }
.pill { display: inline-block; font-size: .72rem; font-weight: 500; padding: .1rem .5rem; border-radius: 999px; border: 1px solid var(--line); color: var(--steel); margin-right: .25rem; white-space: nowrap; }
.pill.solid { background: var(--navy); color: #fff; border-color: var(--navy); }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: #F1D3A1; }
.pill.demo { background: var(--blue); color: #fff; border: none; }

.nav { position: fixed; z-index: 15; background: var(--card); }
.nav a { display: flex; align-items: center; gap: .7rem; color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a svg { width: 22px; height: 22px; flex: none; }
.nav a.active { color: var(--navy); }
.nav a.active svg { color: var(--blue); }

.view { padding: 1.25rem 1rem 2rem; max-width: 1240px; margin: 0 auto; }

@media (min-width: 900px) {
  .nav { top: 57px; bottom: 0; left: 0; width: 200px; padding: 1rem .6rem; border-right: 1px solid var(--line); }
  .nav a { padding: .6rem .8rem; border-radius: 8px; margin-bottom: .15rem; }
  .nav a:hover { background: var(--bg); }
  .nav a.active { background: #E8EEFA; }
  .view { margin-left: 200px; padding: 1.75rem 2rem 3rem; }
}
@media (max-width: 899px) {
  .nav { left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    display: grid; grid-template-columns: repeat(6, 1fr); border-top: 1px solid var(--line); }
  .nav a { flex-direction: column; justify-content: center; gap: .15rem; font-size: .68rem; }
  .view { padding-bottom: calc(var(--nav-h) + 2rem + env(safe-area-inset-bottom)); }
  .hide-sm { display: none; }
  .brandmark .wm { font-size: 1.1rem; }
  .filechip { max-width: 38vw; }
}

/* ---------- layout ---------- */
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; min-width: 0; }
.card.narrow { max-width: 440px; width: 100%; text-align: center; padding: 2.25rem 1.75rem; }
.card.narrow h1 { margin-bottom: .5rem; }
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.grid2 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 1100px) { .grid2 { grid-template-columns: minmax(360px, 420px) 1fr; } .grid2 > .card { margin-bottom: 0; } }
.entry .form { align-self: start; }
@media (min-width: 1100px) { .entry .form { position: sticky; top: 76px; } }

.quick { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.stat label { display: block; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stat b { display: block; font-size: 1.55rem; font-weight: 500; margin: .25rem 0 .1rem; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); font-size: .8rem; }
.stat.accent { background: var(--navy); border-color: var(--navy); color: #fff; }
.stat.accent label, .stat.accent small { color: var(--grey-1); }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 500; font-size: .92rem;
  padding: .6rem 1rem; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--navy); cursor: pointer; text-decoration: none; min-height: 42px; }
.btn:hover { border-color: var(--blue); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #4A6FC4; }
.btn.danger { color: var(--warn); border-color: #F1D3A1; margin-left: auto; }
.btn.sm { padding: .3rem .7rem; min-height: 32px; font-size: .82rem; }
.btn.lg { padding: .85rem 1.5rem; font-size: 1rem; width: 100%; margin: 1rem 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.form .field { margin-bottom: .85rem; }
.field label { display: block; font-size: .78rem; font-weight: 500; color: var(--muted); margin-bottom: .3rem; letter-spacing: .02em; }
.field small { display: block; color: var(--muted); font-size: .8rem; margin-top: .3rem; }
input, select, textarea { font: inherit; font-size: 16px; /* no iOS zoom */ width: 100%; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--text); min-height: 44px; }
input:focus, select:focus { outline: 2px solid var(--blue); outline-offset: -1px; border-color: var(--blue); }
.field .btn { margin-top: .45rem; }
.suffix { display: flex; align-items: center; gap: .5rem; } .suffix input { width: 7rem; }
.checks { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; margin: .25rem 0 .75rem; }
.check { display: inline-flex; align-items: center; gap: .5rem; font-size: .92rem; padding: .3rem 0; cursor: pointer; }
.check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--blue); }
details.group, details.odo { margin-bottom: .75rem; }
details summary { cursor: pointer; color: var(--steel); font-weight: 500; font-size: .9rem; padding: .3rem 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .4rem; }
.row-inline { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.form.editing { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(91,127,212,.15); }
.dest { display: flex; gap: .5rem; align-items: flex-start; font-size: .8rem; color: var(--muted); background: var(--bg); border-radius: 8px; padding: .55rem .7rem; margin: .5rem 0 0; }
.dest svg { width: 16px; height: 16px; flex: none; margin-top: .1rem; color: var(--steel); }
.warnbox { background: var(--warn-bg); color: var(--warn); border-left: 3px solid var(--warn); padding: .6rem .8rem; border-radius: 4px; }

.receipt { border: 1px dashed var(--grey-1); border-radius: var(--radius); padding: .9rem; margin-bottom: 1rem; background: #FAFBFE; }
.receipt-btns { display: flex; gap: .5rem; flex-wrap: wrap; }
.receipt p { margin: .6rem 0 0; }
.rcpt-preview { display: flex; gap: .8rem; align-items: flex-start; margin-top: .8rem; }
.rcpt-preview img { width: 92px; max-height: 140px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.ocr { font-size: .85rem; color: var(--steel); }

/* ---------- lists ---------- */
.list-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .75rem; }
.list-head h2 { margin: 0; margin-right: auto; }
.list-head select { width: auto; } .list-head input { flex: 1; min-width: 140px; }
.list-head #sum { margin-left: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.list th { text-align: left; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 500; padding: .4rem .5rem; border-bottom: 1px solid var(--line); }
table.list th.r { text-align: right; }
table.list td { padding: .6rem .5rem; border-bottom: 1px solid #EEF2F7; vertical-align: top; }
table.list td:first-child { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
table.list.clickable tbody tr { cursor: pointer; }
table.list.clickable tbody tr:hover { background: #F6F8FC; }
table.list tr.sel { background: #E8EEFA !important; }
td.grow { width: 40%; }
ul.log { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
ul.log li { padding: .55rem 0; border-bottom: 1px solid #EEF2F7; }
ul.tight { padding-left: 1.1rem; } ul.tight li { margin-bottom: .35rem; }

/* ---------- feedback ---------- */
.toasts { position: fixed; z-index: 50; right: 1rem; bottom: calc(var(--nav-h) + 1rem + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: .5rem; max-width: min(440px, calc(100vw - 2rem)); }
@media (min-width: 900px) { .toasts { bottom: 1.25rem; } }
.toast { background: var(--navy); color: #fff; padding: .75rem 1rem; border-radius: 8px; box-shadow: 0 6px 24px rgba(11,31,58,.25); font-size: .9rem; border-left: 4px solid var(--blue); animation: rise .2s ease-out; }
.toast code { background: var(--navy-2); color: var(--grey-1); }
.toast a { color: #9DB8F0; }
.toast.warn { border-left-color: #F0A830; }
.toast.info { border-left-color: var(--grey-1); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.busy { position: fixed; z-index: 60; inset: 0; background: rgba(244,246,250,.7); display: grid; place-content: center; justify-items: center; gap: .75rem; font-weight: 500; color: var(--navy); }
.busy[hidden] { display: none; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--grey-1); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- invoice (screen preview + print). Designed to work in B&W first. ---------- */
.preview-wrap { background: #E9EDF3; border-radius: var(--radius); padding: 1rem; margin: 1rem 0; overflow-x: auto; }
.invoice { background: #fff; color: #000; max-width: 820px; margin: 0 auto; padding: 2.5rem 2.75rem; font-size: 13px; line-height: 1.45; box-shadow: 0 2px 12px rgba(11,31,58,.08); }
.inv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 2rem; border-bottom: 2px solid #000; padding-bottom: 1.25rem; }
.inv-brand .brandmark, .invoice .brandmark { color: var(--navy); }
.invoice .brandmark img { height: 52px; }
.invoice .brandmark { gap: .8rem; }
.invoice .brandmark .wm { font-size: 2rem; }
.invoice .brandmark .wm small { color: #404040; font-size: .55rem; }
.inv-title { text-align: right; }
.inv-title h1 { font-size: 2.2rem; font-weight: 300; margin-bottom: .5rem; }
.inv-title dl { display: grid; grid-template-columns: auto auto; gap: .1rem 1rem; margin: 0; justify-content: end; }
.inv-title dt { color: #767676; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; align-self: center; }
.inv-title dd { margin: 0; text-align: right; }
.inv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin: 1.5rem 0; }
.inv-parties h4, .invoice h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; color: #404040; margin: 0 0 .4rem; font-weight: 600; }
.inv-parties p { margin: 0; }
.invoice h3 { margin-top: 1.5rem; }
.inv-table { width: 100%; border-collapse: collapse; }
.inv-table th { background: #000; color: #fff; font-weight: 600; text-align: left; padding: .45rem .55rem; font-size: .78rem; }
.inv-table th.r { text-align: right; }
.inv-table td { padding: .45rem .55rem; border-bottom: .5pt solid #404040; }
.inv-table tbody tr:nth-child(even) td { background: #E8E8E8; }
.inv-totals { margin: 1.5rem 0 0 auto; border-collapse: collapse; min-width: 300px; }
.inv-totals td { padding: .35rem .55rem; }
.inv-totals small { color: #767676; }
.inv-totals tr.due td { border-top: 2px solid #000; font-weight: 600; font-size: 1.1rem; padding-top: .6rem; }
.inv-foot { margin-top: 2.5rem; font-size: .85rem; color: #404040; }
.inv-rule { border-top: 1pt solid #000; margin-top: 1.5rem; padding-top: .5rem; text-align: center; font-size: .68rem; letter-spacing: .25em; }
.record { margin-top: .5rem; }
#print-root { display: none; }

@media print {
  @page { size: letter; margin: 14mm; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; }
  .invoice { box-shadow: none; padding: 0; max-width: none; font-size: 11pt; }
  .inv-table th, .inv-table tbody tr:nth-child(even) td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .inv-table tr { break-inside: avoid; }
}
@media (max-width: 640px) {
  .invoice { padding: 1.25rem; font-size: 12px; }
  .inv-head, .inv-parties { display: block; }
  .inv-title { text-align: left; margin-top: 1rem; } .inv-title dl { justify-content: start; }
  .inv-parties > div + div { margin-top: 1rem; }
}
@media (max-width: 600px) {
  .filechip { font-size: 0; padding: .5rem; gap: 0; }
}
#listwrap, .card:has(> table.list) { overflow-x: auto; }
.check-wrap[hidden], .field[hidden] { display: none; }
.check-wrap small { display: block; color: var(--muted); font-size: .8rem; }
.form > .field > .check { padding-top: 0; }
dialog.modal { border: none; border-radius: var(--radius); padding: 1.5rem; width: min(480px, calc(100vw - 2rem)); box-shadow: 0 20px 60px rgba(11,31,58,.3); color: var(--text); }
dialog.modal::backdrop { background: rgba(11,31,58,.45); }
dialog.modal details { margin: .5rem 0; max-height: 40vh; overflow: auto; }
.inv-table td.amt { font-weight: 600; }
dialog.modal.wide { width: min(760px, calc(100vw - 2rem)); }
dialog.modal .scroll { max-height: 55vh; overflow: auto; margin: .75rem 0; border: 1px solid var(--line); border-radius: 8px; }
dialog.modal .scroll table.list td { vertical-align: middle; }
.stat b.sm { font-size: 1.05rem; line-height: 1.3; }
.inv-table tr.sub td { font-weight: 600; border-bottom: none; background: none !important; }
.inv-table tr.sub td:nth-child(3) { text-align: right; }
.invoice h3 small { font-weight: 400; letter-spacing: 0; text-transform: none; color: #767676; }
.bulk { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; background: #E8EEFA; border-left: 3px solid var(--blue); border-radius: 6px; padding: .6rem .8rem; margin-bottom: .75rem; font-size: .88rem; }
.bulk span { flex: 1; min-width: 200px; }
.list-head #lf { width: auto; max-width: 220px; }
/* budget panel (Time) and project list */
.budget { margin-top: .5rem; padding: .6rem .75rem; border-radius: 8px; background: var(--bg); font-size: .85rem; }
.budget:empty { display: none; }
#budget:empty { display: none; }
.budget-top span { color: var(--muted); }
.budget small { display: block; color: var(--muted); margin-top: .3rem; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: .45rem; }
.bar i { display: block; height: 100%; background: var(--blue); }
.budget.over, .budget.over b { color: var(--warn); }
.budget.over .bar i, .bar.over i { background: #F0A830; }
.group-h { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 1rem 0 .25rem; font-weight: 600; }
.mini { display: inline-block; min-width: 150px; text-align: right; }
.mini .bar { margin: 0 0 .2rem; }
.mini span { font-size: .8rem; color: var(--muted); }
.proj-info { white-space: nowrap; font-size: .85rem; }
.signoff { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; margin-top: 3rem; }
.signoff div { border-top: 1px solid #000; padding-top: .35rem; font-size: .75rem; color: #404040; }
.nav i { font-style: normal; }
.mobile-only { display: none !important; }
@media (max-width: 899px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: inline-grid !important; }
  .nav i.mobile-only { display: inline !important; }
}
.nextbill { display: flex; gap: .6rem; align-items: center; background: var(--navy); color: #fff; border-radius: var(--radius); padding: .75rem 1rem; margin: 0 0 1rem; font-size: .92rem; }
.nextbill svg { width: 20px; height: 20px; color: var(--blue); flex: none; }
#invcheck select { min-height: 34px; padding: .25rem .4rem; font-size: 14px; width: auto; }
a.pill { text-decoration: none; }
