/* Partner Connect — Innovate Solution
   Harbour teal + marigold (from the logo). Bricolage Grotesque for headings and
   figures, Instrument Sans for the interface. Both fonts are self-hosted (OFL).
   CSP: no inline styles anywhere — every visual lives here. */

@font-face {
  font-family: "Bricolage";
  src: url(../fonts/bricolage.woff2) format("woff2-variations"), url(../fonts/bricolage.woff2) format("woff2");
  font-weight: 200 800; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url(../fonts/instrument-sans.woff2) format("woff2-variations"), url(../fonts/instrument-sans.woff2) format("woff2");
  font-weight: 400 700; font-style: normal; font-display: swap;
}

:root {
  --harbour: #0f3d3e;      /* brand, sidebar */
  --harbour-deep: #0a2b2c;
  --teal: #14595a;          /* primary actions, links */
  --marigold: #e8a33d;      /* accent, the scanner */
  --marigold-ink: #6b4508;

  --bg: #eef2ef;
  --surface: #ffffff;
  --surface-2: #f6f8f6;
  --line: #dde4e1;
  --line-strong: #c6d1cd;
  --ink: #13201f;
  --ink-2: #445755;
  --muted: #6f817f;
  --link: var(--teal);
  --field: #ffffff;
  --bed: #0b1d1d;           /* scanner bed / photo backdrop */

  --ok: #1d7a50;  --ok-bg: #e3f3ea;  --ok-ink: #135c3b;
  --err: #b83a26; --err-bg: #fbe9e5; --err-ink: #8a2717;
  --warn-bg: #fbefd8; --warn-ink: #7c5210;
  --info-bg: #e8f0f8; --info-ink: #1f4a76;

  --r-sm: 6px; --r: 10px; --r-lg: 16px;
  --font: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Bricolage", "Instrument Sans", ui-sans-serif, system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --side-w: 240px;
  --paper-shadow: 0 1px 1px rgba(10, 30, 30, .12), 0 8px 24px -8px rgba(10, 30, 30, .35);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1717;
    --surface: #112221;
    --surface-2: #0e1c1c;
    --line: #213634;
    --line-strong: #2d4644;
    --ink: #e3ecea;
    --ink-2: #b5c5c2;
    --muted: #869b98;
    --link: #6cc4bd;
    --field: #0c1a1a;
    --bed: #061111;
    --teal: #1d7473;
    --ok: #4cc08a;  --ok-bg: #12352a;  --ok-ink: #8fe0b8;
    --err: #f07a63; --err-bg: #3a1a14; --err-ink: #f6b0a2;
    --warn-bg: #3a2c12; --warn-ink: #f1c983;
    --info-bg: #13283d; --info-ink: #a9c8ea;
    --paper-shadow: 0 1px 1px rgba(0,0,0,.4), 0 10px 28px -10px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.55 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--marigold); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--display); margin: 0 0 .5rem; line-height: 1.15; font-weight: 650; letter-spacing: -.015em; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1vw, 1.95rem); font-weight: 700; letter-spacing: -.025em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
small, .muted { color: var(--muted); }
.right { text-align: right; }
.inline { display: inline; margin: 0; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.err-text { color: var(--err); }
code, .mono { font-family: var(--mono); font-size: .86em; }
.mt { margin-top: 1rem; }
.mt-sm { margin-top: .75rem; }
.ico { width: 20px; height: 20px; flex: none; }
::selection { background: color-mix(in srgb, var(--marigold) 40%, transparent); }

/* ---------- shell: sidebar on desktop, tab bar on phones ---------- */
.app { padding-left: var(--side-w); }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); z-index: 30;
  display: flex; flex-direction: column; gap: 1.5rem; padding: 1.25rem .9rem 1rem;
  background: var(--harbour); color: #d5e5e2;
  background-image: linear-gradient(180deg, var(--harbour) 0%, var(--harbour-deep) 100%);
}
.brand { display: flex; align-items: center; gap: .65rem; color: #fff; padding: 0 .4rem; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 9px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-family: var(--display); font-weight: 700; font-size: 1.08rem; letter-spacing: -.01em; }
.brand-text small { color: var(--marigold); font-size: .74rem; font-weight: 600; margin-top: 2px; }

.sidenav { display: flex; flex-direction: column; gap: 2px; }
.sidenav a { display: flex; align-items: center; gap: .7rem; padding: .6rem .7rem; border-radius: 8px; color: #c4d8d5; font-weight: 550; position: relative; }
.sidenav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidenav a.on { background: rgba(255,255,255,.1); color: #fff; }
.sidenav a.on::before { content: ""; position: absolute; left: -.9rem; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--marigold); }
.sidenav a.on .ico { color: var(--marigold); }
.sidenav-group { margin: 1rem .7rem .3rem; font-size: .74rem; color: #7fa19d; font-weight: 600; }

.side-foot { margin-top: auto; display: flex; align-items: center; gap: .25rem; padding-top: .9rem; border-top: 1px solid rgba(255,255,255,.08); }
.me { flex: 1; min-width: 0; display: flex; align-items: center; gap: .6rem; padding: .4rem; border-radius: 8px; color: #fff; }
.me:hover, .me.on { background: rgba(255,255,255,.07); text-decoration: none; }
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.me-text b { font-size: .88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { color: #8fb0ac; font-size: .74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iconbtn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 8px; background: none; color: #a9c4c0; cursor: pointer; }
.iconbtn:hover { background: rgba(255,255,255,.08); color: #fff; }

.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--marigold); color: var(--harbour-deep); font-weight: 700; font-size: .76rem; letter-spacing: .02em; }
.avatar:hover { text-decoration: none; }
.avatar.sm { width: 26px; height: 26px; font-size: .66rem; margin-right: .45rem; vertical-align: middle; }
.avatar.lg { width: 52px; height: 52px; font-size: 1.05rem; font-family: var(--display); }

.mobilebar, .tabbar { display: none; }

.container { max-width: 1240px; margin: 0 auto; padding: 2rem 2rem 4rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem 1rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.page-head h1, .page-head h2 { margin: 0; }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.count { font-family: var(--font); font-size: .95rem; font-weight: 600; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: .1rem .6rem; vertical-align: middle; margin-left: .35rem; letter-spacing: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .6rem; }
.section-head h2 { margin: 0; font-size: 1.05rem; }
.section-head a { font-size: .88rem; font-weight: 600; }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.4rem; }
.panel + .panel, .panel + details.panel { margin-top: 1rem; }
.panel.narrow { max-width: 560px; }
.panel > h2 { margin-bottom: 1rem; }
.panel-sub { margin: -.55rem 0 1.1rem; color: var(--muted); font-size: .9rem; max-width: 72ch; }
.panel .page-head { margin-bottom: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.1rem; align-items: start; }
.grid-form .full { grid-column: 1 / -1; }
details.panel > summary { list-style: none; display: flex; align-items: center; gap: .5rem; }
details.panel > summary::-webkit-details-marker { display: none; }
details > summary { cursor: pointer; font-weight: 600; color: var(--ink-2); }
details.panel > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
details.panel[open] > summary::before { transform: rotate(45deg); }

/* tally: the counters, set as one strip rather than separate boxes */
.tally { display: grid; grid-template-columns: repeat(2, 1fr); margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.tally > div { padding: .85rem 1rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.tally > div:nth-child(2n) { border-right: 0; }
.tally > div:nth-last-child(-n+2) { border-bottom: 0; }
.tally dt { color: var(--muted); font-size: .8rem; font-weight: 550; }
.tally dd { margin: 0; font-family: var(--display); font-size: 1.75rem; font-weight: 700; line-height: 1.1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.tally .is-bad dd { color: var(--err); }
.tally-row { grid-template-columns: repeat(4, 1fr); margin-bottom: 1.25rem; }
.tally-row > div { border-bottom: 0; }
.tally-row > div:nth-child(2n) { border-right: 1px solid var(--line); }
.tally-row > div:last-child { border-right: 0; }
/* legacy stat boxes */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem 1.1rem; }
.stat b { display: block; font-family: var(--display); font-size: 1.6rem; }
.stat span { color: var(--muted); font-size: .85rem; }

/* ---------- forms ---------- */
.stack { display: grid; gap: 1rem; }
label { display: grid; gap: .35rem; font-weight: 550; font-size: .88rem; color: var(--ink-2); }
label.check { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .55rem; font-weight: 500; color: var(--ink); }
label.check > .hint { flex-basis: 100%; padding-left: calc(18px + .55rem); }
input, select, textarea {
  width: 100%; font: inherit; font-size: .95rem; color: var(--ink); background: var(--field);
  border: 1px solid var(--line-strong); border-radius: 8px; padding: .62rem .75rem; min-height: 42px;
  transition: border-color .12s, box-shadow .12s;
}
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; accent-color: var(--teal); }
input[type=file] { padding: .45rem; background: var(--surface-2); }
textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 22%, transparent); }
::placeholder { color: var(--muted); opacity: .8; }
.hint { font-weight: 400; color: var(--muted); font-size: .8rem; line-height: 1.4; }
.input-group { display: flex; gap: .4rem; }
.input-group input { flex: 1; }
.inline-label { display: flex; align-items: center; gap: .45rem; font-weight: 550; white-space: nowrap; }
.inline-label input { width: auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 40px;
  padding: .55rem 1rem; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink); font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { text-decoration: none; background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn .ico { width: 18px; height: 18px; }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--harbour); border-color: var(--harbour); }
.btn-accent { background: var(--marigold); border-color: var(--marigold); color: var(--harbour-deep); }
.btn-accent:hover { background: #d9942a; border-color: #d9942a; }
.btn-danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 35%, transparent); background: transparent; }
.btn-danger:hover { background: var(--err-bg); border-color: var(--err); }
.btn-sm { min-height: 32px; padding: .3rem .7rem; font-size: .84rem; border-radius: 7px; }
.btn-lg { min-height: 50px; padding: .8rem 1.35rem; font-size: 1rem; border-radius: 11px; }
.btn-block { width: 100%; }

.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-top: 1.25rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }
form > .form-actions:first-child { margin-top: 0; }
.secret-state { font-size: .76rem; color: var(--ok); font-weight: 600; margin-left: .3rem; }

/* ---------- flash / badges ---------- */
.flash { position: relative; padding: .8rem 1rem .8rem 1.15rem; border-radius: var(--r); margin-bottom: 1rem; font-weight: 500; line-height: 1.45; border: 1px solid transparent; }
.flash::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: currentColor; opacity: .7; }
.flash a { color: inherit; font-weight: 650; text-decoration: underline; text-underline-offset: 2px; }
.flash-ok { background: var(--ok-bg); color: var(--ok-ink); }
.flash-err { background: var(--err-bg); color: var(--err-ink); }
.flash-info { background: var(--info-bg); color: var(--info-ink); }
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .14rem .55rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); font-size: .76rem; font-weight: 600; white-space: nowrap; }
.badge-accent, .status-draft { background: var(--warn-bg); border-color: transparent; color: var(--warn-ink); }
.badge-ok, .status-sent { background: var(--ok-bg); border-color: transparent; color: var(--ok-ink); }
.badge-err, .status-failed { background: var(--err-bg); border-color: transparent; color: var(--err-ink); }
.status-sending { background: var(--info-bg); border-color: transparent; color: var(--info-ink); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .4rem; vertical-align: middle; }
.dot-ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
.dot-off { background: var(--line-strong); }

/* ---------- tables ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .75rem 1rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: .8rem; color: var(--muted); background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.right { white-space: nowrap; }
.table td.right .badge + .badge, .table td.right .badge + .btn { margin-left: .25rem; }
.cell-main { font-weight: 650; color: var(--ink); }
a.cell-main:hover { color: var(--link); }
.cell-sub { color: var(--muted); font-size: .84rem; }
.empty { padding: 3.5rem 1rem; text-align: center; color: var(--muted); }
.empty a { font-weight: 600; }
.empty-note { color: var(--muted); margin: .5rem 0 0; }

/* card photo thumbnails keep the business-card ratio (3.5 × 2) */
.card-thumb, .table .thumb { display: block; width: 70px; aspect-ratio: 7 / 4; height: auto; object-fit: cover; border-radius: 4px; background: var(--bed); box-shadow: var(--paper-shadow); }

.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; padding: .6rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.toolbar input, .toolbar select, .toolbar .btn { min-height: 38px; }
.toolbar input[type=search] { flex: 1 1 240px; max-width: 360px; }
.toolbar select { width: auto; max-width: 220px; }
.toolbar input[type=date] { width: auto; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; color: var(--muted); font-size: .9rem; }
.pager .btns { display: flex; gap: .4rem; }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: .5rem 1rem; margin: 0; }
.kv dt { color: var(--muted); font-size: .9rem; }
.kv dd { margin: 0; word-break: break-word; }

/* ---------- tabs (settings) ---------- */
.tabs { display: flex; gap: .25rem; padding: .3rem; margin-bottom: 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; scrollbar-width: none; }
.tabs a { display: inline-flex; align-items: center; gap: .1rem; padding: .5rem .9rem; color: var(--ink-2); font-weight: 600; font-size: .9rem; border-radius: 8px; white-space: nowrap; }
.tabs a:hover { text-decoration: none; background: var(--surface-2); color: var(--ink); }
.tabs a.on { background: var(--harbour); color: #fff; }
.tabs a .dot { margin: 0 0 0 .45rem; }

/* ---------- capture ---------- */
.capture { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr); gap: 2rem; align-items: start; }
.capture-side { display: grid; gap: 1.25rem; position: sticky; top: 2rem; }
.stage {
  position: relative; display: grid; place-items: center; overflow: hidden; aspect-ratio: 16 / 10;
  border-radius: 20px; background: var(--bed);
  background-image: radial-gradient(120% 90% at 50% 0%, #163636 0%, var(--bed) 70%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.05);
}
.stage video, .stage > img { width: 100%; height: 100%; object-fit: contain; display: block; }
/* camera frame: four marigold corner brackets in business-card proportion */
.stage .frame { position: absolute; left: 50%; top: 50%; width: 82%; aspect-ratio: 7 / 4; max-height: 86%; transform: translate(-50%, -50%); pointer-events: none; }
.stage .frame i { position: absolute; width: 28px; height: 28px; border: 3px solid var(--marigold); }
.stage .frame i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 10px; }
.stage .frame i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 10px; }
.stage .frame i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 10px; }
.stage .frame i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 10px; }
.stage .placeholder { display: grid; justify-items: center; gap: .3rem; color: #93aeab; text-align: center; padding: 1.25rem; font-size: .92rem; }
.stage .placeholder b { color: #fff; font-family: var(--display); font-size: 1.2rem; font-weight: 650; margin-top: .9rem; }
.ghost-card { position: relative; width: 168px; aspect-ratio: 7 / 4; border-radius: 8px; border: 2px dashed rgba(232, 163, 61, .55); transform: rotate(-4deg); }
.ghost-card span { position: absolute; left: 14px; top: 16px; width: 22px; height: 22px; border-radius: 50%; background: rgba(232, 163, 61, .55); }
.ghost-card i { position: absolute; left: 48%; height: 6px; border-radius: 3px; background: rgba(255,255,255,.18); }
.ghost-card i:nth-of-type(1) { top: 20px; width: 38%; }
.ghost-card i:nth-of-type(2) { top: 34px; width: 28%; }
.ghost-card i:nth-of-type(3) { top: 48px; width: 33%; }
.overlay { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; text-align: center; color: #fff; font-weight: 600; background: rgba(6, 20, 20, .66); backdrop-filter: blur(1.5px); }
/* the one bit of motion: a scan line sweeps the card while travoPilot reads it */
.scanline { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--marigold); box-shadow: 0 0 18px 4px rgba(232, 163, 61, .55); animation: sweep 1.8s ease-in-out infinite alternate; }
@keyframes sweep { from { top: 6%; } to { top: 94%; } }
.spinner { width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.2); border-top-color: var(--marigold); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto .8rem; }
@keyframes spin { to { transform: rotate(360deg); } }
.capture-bar { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }
.capture-bar .btn { flex: 1 1 auto; }
.btn-snap { flex-grow: 2 !important; }
.sides { display: flex; gap: .6rem; margin-top: .75rem; }
.sides .side { flex: 1; display: flex; align-items: center; gap: .6rem; padding: .5rem .65rem; border: 1px dashed var(--line-strong); border-radius: 10px; font-size: .86rem; color: var(--muted); background: var(--surface); }
.sides .side small { display: block; font-size: .74rem; }
.sides .side.has { border-style: solid; border-color: var(--ok); color: var(--ink); font-weight: 600; }
.sides .side img { width: 56px; aspect-ratio: 7 / 4; object-fit: cover; border-radius: 3px; box-shadow: var(--paper-shadow); }

.recent ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.recent-item { display: flex; align-items: center; gap: .85rem; padding: .55rem .6rem; border-radius: 12px; color: var(--ink); }
.recent-item:hover { background: var(--surface); text-decoration: none; box-shadow: 0 0 0 1px var(--line); }
.recent-item .card-thumb { width: 76px; }
.recent-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.recent-text b { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-text > span { color: var(--ink-2); font-size: .86rem; }
.recent-text span span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-text small { font-size: .78rem; }

/* ---------- card review ---------- */
.review { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 1.5rem; align-items: start; }
.card-image { display: block; padding: 1.1rem; border-radius: var(--r-lg); background: var(--bed); background-image: radial-gradient(120% 90% at 50% 0%, #163636 0%, var(--bed) 70%); }
.card-image img { width: 100%; display: block; border-radius: 6px; box-shadow: 0 2px 4px rgba(0,0,0,.3), 0 14px 30px -10px rgba(0,0,0,.6); }
.meta-line { display: flex; flex-wrap: wrap; gap: .4rem 1rem; color: var(--muted); font-size: .85rem; margin-top: .85rem; align-items: center; }
.raw { max-height: 300px; overflow: auto; background: var(--bed); color: #cfe3e0; padding: .9rem 1rem; border-radius: 10px; font: 12px/1.5 var(--mono); white-space: pre-wrap; word-break: break-all; }
.quick { display: flex; gap: .45rem; flex-wrap: wrap; margin-top: 1rem; }
.contact-head { display: flex; align-items: center; gap: .9rem; margin-bottom: 1.1rem; }
.contact-head h2 { margin: 0; flex: 1; }
.company-logo { order: 2; max-height: 52px; max-width: 170px; object-fit: contain; border-radius: 8px; background: #fff; border: 1px solid var(--line); padding: 5px 8px; }
.company-cell { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.company-cell > span { min-width: 0; }
.table .col-company { min-width: 190px; }
.logo-sm { height: 28px; max-width: 64px; flex: none; object-fit: contain; border-radius: 5px; background: #fff; border: 1px solid var(--line); padding: 2px 4px; }
.logo-xs { height: 16px; max-width: 46px; flex: none; object-fit: contain; border-radius: 3px; background: #fff; }

.completeness .bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.completeness .bar span { display: block; height: 100%; width: 0; background: var(--teal); border-radius: 99px; transition: width .5s ease-out; }
.completeness .bar .lvl-perfect { background: var(--ok); }
.completeness .bar .lvl-high { background: #3a9a6a; }
.completeness .bar .lvl-medium { background: var(--marigold); }
.completeness .bar .lvl-low { background: var(--err); }
.pct { display: inline-block; margin-left: .35rem; font-weight: 700; font-size: .76rem; font-variant-numeric: tabular-nums; }
.pct-perfect, .pct-high { color: var(--ok); }
.pct-medium { color: #b07619; }
.pct-low { color: var(--err); }
.phones { list-style: none; margin: 0 0 .5rem; padding: 0; }
.phones li { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.phones li:last-child { border-bottom: 0; }
.phones .mono { font-size: .92rem; font-variant-numeric: tabular-nums; }

/* ---------- emails ---------- */
.step { display: inline-grid; place-items: center; width: 26px; height: 26px; margin-right: .6rem; border-radius: 50%; background: var(--teal); color: #fff; font-size: .82rem; font-weight: 700; vertical-align: 2px; }
.compose { display: grid; gap: 1rem; max-width: 880px; }
.compose .panel + .panel { margin-top: 0; }
.email-preview { width: 100%; height: 540px; border: 1px solid var(--line); border-radius: var(--r); background: #f4f6f3; }
.email-preview.tall { height: 780px; }
.history { list-style: none; margin: .25rem 0 0; padding: 0; }
.history li { padding: .7rem 0; border-bottom: 1px solid var(--line); }
.history li:last-child { border-bottom: 0; }
.history-row { display: flex; justify-content: space-between; gap: .6rem; align-items: baseline; }
.sendinfo { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: .8rem 1rem; font-size: .9rem; }
.email-status { display: flex; gap: .7rem; align-items: center; color: var(--muted); font-size: .9rem; flex-wrap: wrap; }
.plain { white-space: pre-wrap; font: 13px/1.55 var(--font); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: .9rem; margin: 0; }
.contact-chosen { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .85rem 1rem; border: 1px solid var(--line); border-left: 3px solid var(--marigold); border-radius: var(--r); background: var(--surface-2); }
.results { list-style: none; margin: .5rem 0 0; padding: .3rem; border: 1px solid var(--line); border-radius: var(--r); max-height: 340px; overflow: auto; background: var(--surface); }
.results:empty { display: none; }
.results li { padding: .6rem .75rem; cursor: pointer; border-radius: 7px; }
.results li:hover, .results li.active { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--marigold); }
.results li.disabled { cursor: not-allowed; opacity: .55; }

/* ---------- account ---------- */
.profile-head { display: flex; align-items: center; gap: 1rem; }
.profile-head h2 { margin: 0; }
.profile-head > div { flex: 1; min-width: 0; }
.admin-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.admin-links a { display: flex; align-items: center; gap: .9rem; padding: 1rem 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); color: var(--ink); }
.admin-links a:hover { text-decoration: none; border-color: var(--teal); }
.admin-links .ico { width: 24px; height: 24px; color: var(--teal); }
.admin-links span { display: flex; flex-direction: column; }
.admin-links small { font-size: .84rem; }

/* ---------- cards list: filters, logo tile, email count ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.show-sm { display: none; }
.filters { margin-bottom: 1rem; padding: .6rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.filters-main { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.filters-main input[type=search] { flex: 1 1 280px; }
.filters-main select { width: auto; flex: 0 1 190px; }
.filters input, .filters select, .filters .btn { min-height: 40px; }
.more-filters { margin-top: .5rem; }
.more-filters > summary { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .4rem; font-size: .88rem; color: var(--link); list-style: none; }
.more-filters > summary::-webkit-details-marker { display: none; }
.more-filters > summary::after { content: ""; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin: -3px 0 0 .2rem; transition: transform .15s; }
.more-filters[open] > summary::after { transform: rotate(-135deg); margin-top: 3px; }
.more-filters .count { margin-left: 0; font-size: .74rem; padding: 0 .45rem; }
.filters-more { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .6rem .8rem; padding: .6rem .4rem .3rem; }
.filters-more label { font-size: .8rem; gap: .25rem; }
.clear-filters { display: inline-block; margin: .35rem .4rem 0; font-size: .86rem; font-weight: 600; }

.card-table td { vertical-align: top; }
.card-table .col-brand { width: 104px; padding-right: .25rem; }
.brand-tile { display: grid; place-items: center; width: 92px; aspect-ratio: 7 / 4; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--bed); cursor: zoom-in; box-shadow: var(--paper-shadow); transition: transform .12s; }
.brand-tile:hover { transform: translateY(-1px); }
.brand-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-tile.has-logo { background: #fff; padding: 6px 8px; }
.brand-tile.has-logo img { object-fit: contain; }
.row-flags { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .3rem; }
.row-flags:empty { display: none; }
.email-count { display: inline-flex; align-items: baseline; gap: .25rem; padding: .12rem .55rem; border-radius: 999px; background: var(--ok-bg); color: var(--ok-ink); font-size: .82rem; font-weight: 600; white-space: nowrap; }
.email-count b { font-family: var(--display); font-size: .98rem; }
.email-count:hover { text-decoration: none; filter: brightness(.97); }
.email-count.is-zero { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.col-emails .cell-sub { margin-top: .2rem; font-size: .76rem; }
.card-table .col-captured { min-width: 120px; }
.card-table .col-company { min-width: 160px; }
.col-actions { display: flex; gap: .35rem; justify-content: flex-end; }
.table td.col-actions { white-space: nowrap; }
.card-table .col-actions { display: table-cell; }
.card-table .col-actions .btn + .btn { margin-left: .3rem; }

/* ---------- quick view modal ---------- */
.modal { width: min(920px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 0; border: 0; border-radius: 20px; background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(0,0,0,.55); overflow: hidden; }
.modal[open] { display: flex; flex-direction: column; animation: modal-in .16s ease-out; }
.modal::backdrop { background: rgba(6, 20, 20, .55); backdrop-filter: blur(2px); }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.99); } }
.modal-bar { display: flex; align-items: center; gap: .35rem; padding: .6rem .7rem; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.modal-bar .btn { min-width: 36px; font-size: 1.1rem; }
.modal-close { margin-left: auto; color: var(--ink-2); font-size: 1.05rem; }
.modal-close:hover { background: var(--line); color: var(--ink); }
.modal-body { overflow-y: auto; padding: 1.4rem; }
.modal-body[aria-busy] { opacity: .6; }
.modal-loading { display: grid; place-items: center; min-height: 260px; }
.modal-loading .spinner { border-color: var(--line); border-top-color: var(--marigold); }
.quick-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.2rem; }
.quick-head h2 { font-size: 1.45rem; margin: 0 0 .2rem; overflow-wrap: anywhere; }
.quick-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 1.4rem; align-items: start; }
.quick-photos { display: grid; gap: .6rem; }
.quick-photos .card-image { padding: .7rem; }
.quick-kv { grid-template-columns: 82px 1fr; }
.quick-kv dd div + div { margin-top: .2rem; }
.pre { white-space: pre-wrap; }
.quick-emails { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.quick-emails h3 { display: flex; align-items: center; gap: .3rem; }
.quick-emails .count { font-size: .78rem; }
.qv .form-actions { margin-top: 1.2rem; }

/* ---------- contact header with the company logo from the card ---------- */
.contact-hero { display: flex; align-items: center; gap: 1.1rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.contact-hero .actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-left: auto; }
.contact-logo { flex: none; display: grid; place-items: center; width: 132px; height: 84px; padding: 10px; border-radius: 14px; background: #fff; border: 1px solid var(--line); box-shadow: var(--paper-shadow); }
.contact-logo img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; display: block; }
.contact-logo.is-empty { width: 84px; font-family: var(--display); font-size: 1.6rem; font-weight: 700; color: var(--harbour); background: color-mix(in srgb, var(--marigold) 22%, var(--surface)); border-color: transparent; box-shadow: none; }
@media (prefers-color-scheme: dark) { .contact-logo.is-empty { color: var(--marigold); } }
.contact-hero-text { flex: 1 1 260px; min-width: 0; }
.contact-hero-text h1 { margin: .1rem 0 .25rem; overflow-wrap: anywhere; }
.contact-hero-text p { margin: 0; display: flex; flex-wrap: wrap; gap: .2rem .9rem; color: var(--ink-2); }
.contact-hero-text p b { color: var(--ink); font-weight: 650; }

/* ---------- company profiles ---------- */
.page-sub { margin: -.6rem 0 1.25rem; }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.profile-card { display: flex; flex-direction: column; gap: .9rem; padding: 1.2rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); color: var(--ink); min-width: 0; }
.profile-card:hover { text-decoration: none; border-color: var(--teal); }
.profile-card.is-off { opacity: .7; }
.profile-card-head { display: flex; align-items: center; gap: .85rem; min-width: 0; }
.profile-logo { height: 44px; max-width: 110px; object-fit: contain; flex: none; border-radius: 8px; background: #fff; border: 1px solid var(--line); padding: 4px 6px; }
.monogram { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; background: var(--harbour); color: var(--marigold); font-family: var(--display); font-weight: 700; }
.profile-card-title { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.profile-card-title b { font-family: var(--display); font-size: 1.08rem; font-weight: 650; overflow-wrap: anywhere; }
.profile-card-title small { font-size: .86rem; }
.profile-card-body { display: grid; gap: .45rem; font-size: .88rem; color: var(--ink-2); }
.profile-card-body > span { display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: .5rem; overflow-wrap: anywhere; }
.profile-card-body small { font-size: .8rem; }
.profile-card-foot { display: flex; align-items: center; margin-top: auto; padding-top: .8rem; border-top: 1px solid var(--line); font-size: .86rem; font-weight: 600; }
.edit-link { margin-left: auto; color: var(--link); }

/* ---------- sign in ---------- */
.guest { min-height: 100vh; background: var(--harbour-deep); background-image: radial-gradient(900px 520px at 15% 0%, #1b5d5e 0%, transparent 60%), radial-gradient(700px 480px at 100% 100%, #2d3b20 0%, transparent 60%); color-scheme: light; }
.guest-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.25rem; }
.login { width: 100%; max-width: 860px; display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 2.5rem; }
.login-hero { display: grid; place-items: center; min-height: 300px; }
.biz { position: relative; width: min(320px, 90%); aspect-ratio: 7 / 4; border-radius: 12px; background: #fbfcfa; transform: rotate(-6deg); box-shadow: 0 2px 3px rgba(0,0,0,.25), 0 30px 60px -20px rgba(0,0,0,.6); }
.login-hero > .biz { grid-area: 1 / 1; }
.biz.biz-back { background: #cfdcd9; transform: rotate(4deg) translate(22px, 14px); box-shadow: 0 20px 40px -20px rgba(0,0,0,.5); }
.biz-mark { position: absolute; left: 11%; top: 20%; width: 19%; aspect-ratio: 1; border-radius: 50%; background: var(--marigold); }
.biz-lines { position: absolute; left: 40%; right: 10%; top: 22%; display: grid; gap: 11%; height: 40%; align-content: start; }
.biz-lines i { display: block; height: 9px; border-radius: 5px; background: #c3d3d0; }
.biz-lines i:first-child { background: var(--teal); width: 92%; height: 11px; }
.biz-lines i:nth-child(2) { width: 70%; }
.biz-lines i:nth-child(3) { width: 82%; }
.biz-foot { position: absolute; left: 11%; bottom: 17%; width: 30%; height: 8px; border-radius: 4px; background: var(--marigold); opacity: .7; }
.login-card { background: #fff; color: #13201f; border-radius: 20px; padding: 2.25rem 2rem 2rem; box-shadow: 0 30px 70px -20px rgba(0,0,0,.5); }
.login-card h1 { font-size: 1.85rem; margin-bottom: .25rem; }
.login-sub { margin: 0 0 1.5rem; color: #6f817f; font-size: .92rem; }
.login-card label { color: #445755; }
.login-card input { background: #fff; color: #13201f; border-color: #c6d1cd; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .capture { grid-template-columns: 1fr; }
  .capture-side { position: static; grid-template-columns: 1fr 1fr; align-items: start; }
}
@media (max-width: 960px) {
  :root { --side-w: 76px; }
  .sidebar { padding: 1rem .5rem; align-items: center; }
  .brand-text, .me-text, .sidenav-group { display: none; }
  .brand { padding: 0; }
  .sidenav a { flex-direction: column; gap: .2rem; padding: .55rem .3rem; font-size: .7rem; width: 64px; text-align: center; }
  .sidenav a.on::before { left: -.5rem; }
  .sidenav-group { display: block; height: 1px; margin: .6rem .5rem; background: rgba(255,255,255,.1); font-size: 0; }
  .side-foot { flex-direction: column; border-top: 0; }
  .me { flex: none; padding: .2rem; }
  .review, .grid-2 { grid-template-columns: 1fr; }
  .container { padding: 1.5rem 1.25rem 4rem; }
}
@media (max-width: 720px) {
  .app { padding-left: 0; padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .sidebar { display: none; }
  .mobilebar { display: flex; position: sticky; top: 0; z-index: 30; align-items: center; justify-content: space-between; padding: .55rem 1rem; padding-top: calc(.55rem + env(safe-area-inset-top)); background: var(--harbour); }
  .mobilebar .brand-text { display: flex; }
  .mobilebar .brand-text b { font-size: 1rem; }
  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: .35rem .4rem calc(.35rem + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line);
    box-shadow: 0 -6px 20px -12px rgba(0,0,0,.25);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .35rem 0; border-radius: 10px; color: var(--muted); font-size: .72rem; font-weight: 600; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a .ico { width: 24px; height: 24px; }
  .tabbar a.on { color: var(--teal); }
  .tabbar a.on .ico { color: var(--marigold); }
  @media (prefers-color-scheme: dark) { .tabbar a.on { color: var(--link); } }

  .container { padding: 1.1rem .9rem 2rem; }
  .page-head { margin-bottom: 1rem; }
  .grid-form, .admin-links { grid-template-columns: 1fr; }
  .capture-side { grid-template-columns: 1fr; }
  .stage { border-radius: 16px; aspect-ratio: 4 / 3; }
  .capture-bar { position: sticky; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 5; padding: .5rem; margin: .75rem -.5rem 0; border-radius: 16px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); }
  .tally-row { grid-template-columns: repeat(2, 1fr); }
  .tally-row > div:nth-child(2n) { border-right: 0; }
  .tally-row > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .table .hide-sm { display: none; }
  .kv { grid-template-columns: 1fr; gap: .1rem; }
  .kv dd { margin-bottom: .45rem; }
  .toolbar input[type=search], .toolbar select { max-width: none; flex: 1 1 100%; }
  .email-preview.tall { height: 620px; }
  .panel { padding: 1.1rem; border-radius: 14px; }

  /* other tables: each row becomes a block, cells labelled via data-label */
  .table.stack thead { display: none; }
  .table.stack, .table.stack tbody, .table.stack tr { display: block; }
  .table.stack tr { padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
  .table.stack tr:last-child { border-bottom: 0; }
  .table.stack td { display: flex; gap: .75rem; padding: .15rem 0; border: 0; text-align: left; white-space: normal; }
  .table.stack td[data-label]::before { content: attr(data-label); flex: 0 0 88px; color: var(--muted); font-size: .8rem; padding-top: .1rem; }
  .table.stack td > div, .table.stack td > a { min-width: 0; overflow-wrap: anywhere; }
  .table.stack td.hide-sm { display: none; }
  .table.stack td.right { justify-content: flex-start; }

  .contact-hero { gap: .85rem; }
  .contact-logo { width: 104px; height: 66px; padding: 8px; }
  .contact-logo.is-empty { width: 66px; font-size: 1.3rem; }
  .contact-hero-text { flex-basis: 0; }
  .contact-hero .actions { margin-left: 0; width: 100%; }
  .contact-hero .actions .btn { flex: 1 1 auto; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; }
  .profile-grid { grid-template-columns: 1fr; }
  .form-actions .btn, .form-actions form { flex: 1 1 auto; }
  .form-actions form .btn { width: 100%; }
  .input-group { flex-wrap: wrap; }
  .input-group input { flex: 1 1 180px; }
  .email-preview { height: 480px; }
  .history-row { flex-wrap: wrap; }
  .sides { flex-direction: column; }
  .raw { max-height: 240px; }
  .inline-label { flex: 1 1 140px; }
  .inline-label input { flex: 1; }
  .contact-chosen { flex-wrap: wrap; }

  /* cards list: each row becomes a compact card */
  .table.rows thead { display: none; }
  .table.rows, .table.rows tbody { display: block; }
  .table.rows tr { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: .15rem .85rem; padding: .85rem 1rem; border-bottom: 1px solid var(--line); }
  .table.rows tr:last-child { border-bottom: 0; }
  .table.rows td { padding: 0; border: 0; }
  .table.rows td:first-child { grid-row: span 3; }
  .card-table .col-brand { width: auto; padding: 0; }
  .brand-tile { width: 76px; }
  .card-table .show-sm { display: block; }
  .card-table tr { grid-template-columns: 76px minmax(0, 1fr) auto; }
  .card-table td.col-brand { grid-row: 1 / span 2; grid-column: 1; }
  .card-table td.col-contact { grid-column: 2 / span 2; }
  .card-table td.col-emails { grid-column: 2; display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; margin-top: .4rem; }
  .card-table .col-emails .cell-sub { margin: 0; }
  .card-table td.col-actions { grid-column: 3; display: flex; align-items: center; margin-top: .4rem; }
  .filters-main select { flex: 1 1 calc(50% - .25rem); }
  .filters-main .btn { flex: 1 1 100%; }
  .modal { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 20px 20px 0 0; }
  .modal-body { padding: 1.1rem 1rem calc(1.2rem + env(safe-area-inset-bottom)); }
  .quick-grid { grid-template-columns: 1fr; }
  .quick-head .contact-logo { width: 96px; height: 60px; }
  .quick-head .contact-logo.is-empty { width: 60px; }
  .table.rows .card-thumb { width: 76px; }
  .table.rows .col-company { font-size: .88rem; color: var(--ink-2); }
  .table.rows .col-flags { text-align: left; display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
  .table.rows .col-flags:empty { display: none; }
  .table.rows .col-flags .btn { margin-left: auto !important; }
}
@media (max-width: 640px) {
  .login { grid-template-columns: 1fr; gap: 1.25rem; }
  .login-hero { min-height: 0; padding: 1.25rem 0 .5rem; }
  .biz { width: 220px; }
  .login-card { padding: 1.75rem 1.4rem 1.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  .scanline { top: 50%; }
}
