:root {
  /* Engel & Völkers: charcoal wordmark, red accent (sampled from EV_Logo_RGB_R.png) */
  --ev-red: #e30b13; --ev-charcoal: #303031; --ev-black: #1b1b1b; --ev-grey: #9b9b9b;
  --bg: #f5f5f4; --panel: #fff; --ink: #303031; --muted: #6b6b6b; --line: #e3e3e1;
  --brand: #303031; --brand-2: #1b1b1b; --brand-soft: #efefee;
  --ok: #157f3c; --ok-soft: #e4f4ea; --warn: #9a6400; --warn-soft: #fdf3dc;
  --bad: #b42318; --bad-soft: #fde8e6; --info: #3f4f63; --info-soft: #eceff3;
  --radius: 4px; --shadow: 0 1px 2px rgba(0,0,0,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14.5px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--ink); text-decoration: underline; text-decoration-color: #c9c9c7; text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--ev-red); }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: #fff; color: var(--ink); border-right: 1px solid var(--line); padding: 22px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .logo { padding: 2px 10px 18px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.side .logo img { display: block; width: 100%; max-width: 190px; height: auto; }
.side .logo span { display: block; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-top: 8px; }
.side nav a { display: block; color: var(--ink); padding: 7px 10px 7px 12px; border-left: 2px solid transparent; margin-bottom: 1px; text-decoration: none; }
.side nav a:hover { background: var(--brand-soft); text-decoration: none; }
.side nav a.on { border-left-color: var(--ev-red); background: var(--brand-soft); font-weight: 600; }
.side nav .sec { font-size: 10.5px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); padding: 18px 12px 4px; }
.side .me { border-top: 1px solid var(--line); margin-top: 18px; padding: 12px 10px 0; font-size: 13px; }
.side .me .muted-link, .side .me .muted-link a { color: var(--muted); }
.side .me form { display: inline; }
.side .me button { background: none; border: 0; color: var(--muted); padding: 0; cursor: pointer; font: inherit; text-decoration: underline; text-decoration-color: #c9c9c7; }
.main { padding: 26px 32px 60px; min-width: 0; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

/* panels */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.card.tight { padding: 0; overflow: hidden; }
.card.tight > h2 { padding: 16px 20px 0; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .lbl { color: var(--muted); font-size: 12.5px; }
.stat .val { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .sub { font-size: 12px; color: var(--muted); }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafbfc; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafcff; }
tfoot td { font-weight: 650; background: #fafbfc; border-top: 2px solid var(--line); }
.tablewrap { overflow-x: auto; }
dl.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }

/* badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef0f3; color: #475467; white-space: nowrap; }
.b-draft { background: #eef0f3; color: #475467; }
.b-submitted { background: var(--info-soft); color: var(--info); }
.b-changes_requested { background: var(--warn-soft); color: var(--warn); }
.b-approved { background: var(--ok-soft); color: var(--ok); }
.b-closed { background: var(--brand-soft); color: var(--brand); }
.b-cancelled { background: var(--bad-soft); color: var(--bad); }
.b-missing { background: var(--bad-soft); color: var(--bad); }
.b-rejected { background: var(--bad-soft); color: var(--bad); }
.b-uploaded { background: var(--info-soft); color: var(--info); }
.b-waived { background: #eef0f3; color: #475467; }

/* forms */
label { display: block; font-weight: 550; font-size: 13px; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #cfd4dc; border-radius: 7px; font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(227,11,19,.25); border-color: var(--ev-charcoal); }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.field.needs input, .field.needs select { border-color: #e9a23b; background: #fffaf0; }
.field .ai { font-size: 11.5px; color: var(--info); font-weight: 600; margin-left: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 0 16px; }
.form-grid .span2 { grid-column: span 2; }
.form-grid .span3 { grid-column: span 3; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.check input { width: auto; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 7px; border: 1px solid #cfd4dc; background: #fff; color: var(--ink); font: inherit; font-weight: 550; cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.btn:hover { background: #f6f7f9; }
.btn.primary { background: var(--ev-charcoal); border-color: var(--ev-charcoal); color: #fff; }
.btn.primary:hover { background: var(--ev-black); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.warn { background: #fff; border-color: #e9a23b; color: var(--warn); }
.btn.danger { background: #fff; border-color: #f0b4ae; color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn.link { border: 0; background: none; padding: 0; color: var(--ink); font-weight: 500; text-decoration: underline; text-decoration-color: #c9c9c7; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

/* flashes */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.flash.success { background: var(--ok-soft); border-color: #b5dfc4; color: #0f5e2c; }
.flash.error { background: var(--bad-soft); border-color: #f4bfb9; color: #8d1c13; }
.flash.warning { background: var(--warn-soft); border-color: #f0d79b; color: #7a4f00; }
.flash.info { background: var(--info-soft); border-color: #c0d3f2; color: #1d4687; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 550; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--ev-red); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs .count { background: var(--bad); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 6px; margin-left: 4px; }

/* checklist */
.cl-item { border-bottom: 1px solid var(--line); padding: 12px 20px; display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; }
.cl-item:last-child { border-bottom: 0; }
.cl-item .name { font-weight: 600; }
.cl-item .docs { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 4px; }
.doc { display: flex; align-items: center; gap: 10px; font-size: 13px; flex-wrap: wrap; }
.doc .fname { font-weight: 500; }
.stage-h { padding: 10px 20px; background: #fafbfc; border-bottom: 1px solid var(--line); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; }
details.rev summary { cursor: pointer; color: var(--ink); text-decoration: underline; text-decoration-color: #c9c9c7; font-size: 12.5px; list-style: none; }
details.rev[open] { grid-column: 1 / -1; }
details.rev form { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
details.rev input[type=text] { flex: 1; min-width: 200px; }

/* notes */
.thread { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; background: #fff; }
.thread.resolved { opacity: .7; }
.note { padding: 12px 16px; }
.note + .note { border-top: 1px solid var(--line); background: #fbfcfd; padding-left: 32px; }
.note .meta { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.note .meta b { color: var(--ink); }
.note .body { white-space: pre-wrap; }
.thread .reply { border-top: 1px solid var(--line); padding: 10px 16px; display: flex; gap: 8px; }
.thread .reply textarea { min-height: 38px; height: 38px; }
.role-tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-weight: 600; }

/* questions */
.questions { background: var(--warn-soft); border: 1px solid #f0d79b; border-radius: var(--radius); padding: 14px 18px; margin-bottom: 18px; }
.questions ol { margin: 6px 0 0; padding-left: 20px; }
.concerns { background: var(--bad-soft); border: 1px solid #f4bfb9; border-radius: var(--radius); padding: 14px 18px; margin-bottom: 18px; }
.concerns ul { margin: 6px 0 0; padding-left: 20px; }

/* money */
.calc td { padding: 7px 12px; }
.calc .sub td { color: var(--muted); }
.calc .total td { font-weight: 700; border-top: 2px solid var(--ink); }
.bar { height: 8px; background: #e7eaee; border-radius: 99px; overflow: hidden; margin: 6px 0; }
.bar > div { height: 100%; background: var(--ok); }

/* dropzone */
.drop { border: 2px dashed #b9c4d3; border-radius: var(--radius); padding: 34px 20px; text-align: center; background: #fbfcfe; cursor: pointer; transition: .15s; }
.drop.over { border-color: var(--ev-red); background: var(--brand-soft); }
.drop input { display: none; }
.drop .big { font-size: 16px; font-weight: 600; }
.filelist { margin: 12px 0 0; padding: 0; list-style: none; text-align: left; }
.filelist li { padding: 6px 10px; background: #fff; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 4px; font-size: 13px; }

.loading { display: none; position: fixed; inset: 0; background: rgba(255,255,255,.85); z-index: 50; align-items: center; justify-content: center; flex-direction: column; gap: 14px; font-weight: 600; }
.loading.on { display: flex; }
.spinner { width: 38px; height: 38px; border: 4px solid var(--brand-soft); border-top-color: var(--ev-red); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--bg); }
.login-card { background: #fff; width: 100%; max-width: 400px; border-radius: 4px; padding: 36px 34px; border-top: 3px solid var(--ev-red); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.login-card .login-logo { display: block; width: 100%; max-width: 280px; margin: 0 auto 22px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin: 0; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* statement / print */
.statement { max-width: 820px; margin: 0 auto; background: #fff; padding: 40px; }
.statement table td, .statement table th { padding: 6px 8px; }
@media print {
  .side, .noprint, .flash { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; }
  .statement { padding: 0; }
}
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .split, .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2, .form-grid .span3 { grid-column: auto; }
  .main { padding: 18px 16px 40px; }
}

.navcount { background: var(--ev-red); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 0 7px; margin-left: 4px; }
.b-up, .b-unplaced { background: var(--ok-soft); color: var(--ok); }
.b-down { background: var(--warn-soft); color: var(--warn); }
.b-same { background: #eef0f3; color: #475467; }
.b-pending { background: var(--info-soft); color: var(--info); }
.b-info { background: #eef0f3; color: #475467; }
.b-override { background: #f4e8fd; color: #6b2fa3; }
.section-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.tier-ladder { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tier-ladder .step { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12.5px; background: #fff; }
.tier-ladder .step.on { border-color: var(--ok); background: var(--ok-soft); font-weight: 600; }

/* charts — reference palette slots 1-3 (validated together); app is light-only */
/* E&V red / charcoal / grey: lightness-separated, checked for CVD (min ΔE 15.4) */
.viz-root { --surface-1: #ffffff; --series-1: #e30b13; --series-2: #303031; --series-3: #9b9b9b;
  --viz-grid: #eceef1; --viz-ink: #1c2330; --viz-ink-2: #667085; }
.viz-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--viz-ink-2); margin-bottom: 6px; }
.viz-key { display: inline-flex; align-items: center; gap: 6px; }
.viz-key i { width: 14px; height: 2px; border-radius: 2px; display: inline-block; }
.viz-plot { position: relative; }
.viz-svg { width: 100%; height: auto; display: block; overflow: visible; }
.viz-grid { stroke: var(--viz-grid); stroke-width: 1; }
.viz-tick { font-size: 11px; fill: var(--viz-ink-2); font-variant-numeric: tabular-nums; }
.viz-label { font-size: 11.5px; fill: var(--viz-ink); font-weight: 600; }
.viz-value { font-size: 11px; fill: var(--viz-ink-2); font-variant-numeric: tabular-nums; }
.viz-cross { stroke: #c4cad3; stroke-width: 1; }
.viz-tip { position: absolute; top: 8px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
  padding: 8px 10px; font-size: 12.5px; pointer-events: none; min-width: 150px; }
.viz-tip-h { font-weight: 600; margin-bottom: 4px; }
.viz-tip-row { display: grid; grid-template-columns: 12px 1fr auto; gap: 6px; align-items: center; }
.viz-tip-row i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.viz-tip-row b { font-variant-numeric: tabular-nums; }
.st { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.st-ahead { color: var(--ok); } .st-behind { color: var(--bad); } .st-even { color: var(--info); }
.st-new, .st-none { color: var(--muted); }
.delta-up { color: var(--ok); } .delta-down { color: var(--bad); }
th a.sort { color: inherit; } th a.sort.on { color: var(--ink); }

/* E&V typography: understated, generous letter-spacing on labels */
h1 { font-weight: 600; letter-spacing: -.01em; }
th, .stat .lbl, .stage-h { letter-spacing: .08em; }
.btn { border-radius: 2px; }
.badge { border-radius: 2px; }
.card, .stat, .thread, .questions, .concerns { border-radius: 4px; }
.pagehead h1::after { content: ""; display: block; width: 28px; height: 2px; background: var(--ev-red); margin-top: 8px; }
.statement .stmt-logo { height: 26px; width: auto; display: block; margin-bottom: 10px; }
.brackets td { padding: 5px 8px; } .brackets input { padding: 6px 8px; }

.rate-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 6px; }
.rate-steps .step { border: 1px solid var(--line); border-radius: 2px; padding: 3px 8px; font-size: 12.5px; font-weight: 600; background: #fff; }
.rate-steps .step small { font-weight: 400; color: var(--muted); margin-left: 4px; }
.rate-steps .step.on { border-color: var(--ev-red); box-shadow: inset 3px 0 0 var(--ev-red); }
.rate-steps .step.next { border-style: dashed; color: var(--muted); }
.rate-steps .arrow { color: var(--muted); font-size: 12px; }

/* documents: versions, AI check, actions */
.doc-row { padding: 6px 0; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 3px; }
.doc-row:first-child { border-top: 0; }
.doc-row .concerns { margin: 4px 0 2px; padding: 8px 12px; }
.doc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.doc-actions form.inline { display: inline; }
.inline-d > summary { cursor: pointer; color: var(--link, var(--ev-red)); list-style: none; }
.inline-d > summary::-webkit-details-marker { display: none; }
.inline-d[open] { flex-basis: 100%; }
.replace-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0 4px; }
.replace-form input[type=text] { flex: 1; min-width: 200px; }
.history > summary { cursor: pointer; color: var(--muted); }
.doc.old { padding: 3px 0 3px 12px; border-left: 2px solid var(--line); margin: 3px 0; }
.ai-pending { color: var(--muted); display: flex; align-items: center; gap: 6px; }
.ok-text { color: var(--ok); }
.spinner { width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--ev-red); border-radius: 50%;
  display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.item-upload label.btn { cursor: pointer; margin: 0; }

/* emailed documents */
.email-row { padding: 8px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.email-row:first-of-type { border-top: 0; }
.email-body { white-space: pre-wrap; font: inherit; font-size: 12.5px; background: var(--bg); padding: 8px 10px; border-radius: 6px; max-height: 260px; overflow: auto; margin: 6px 0 0; }
.held-emails { border-color: #f0d9a7; background: var(--warn-soft); }
.copy-line { display: flex; gap: 8px; align-items: center; }
.copy-line code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 12.5px; background: var(--bg); padding: 6px 8px; border-radius: 6px; }
.inbox-assign { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.inbox-assign input[list] { min-width: 280px; flex: 1; }

/* critical dates timeline */
.timeline { list-style: none; margin: 0; padding: 8px 18px 14px; }
.timeline .ms { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.timeline .ms:first-child { border-top: 0; }
.ms-check { margin: 2px 0 0; }
.checkbox { width: 22px; height: 22px; border-radius: 6px; border: 2px solid #b9b9b6; background: var(--panel); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 14px; color: #fff; padding: 0; }
.checkbox:hover { border-color: var(--ok); }
.checkbox.on { background: var(--ok); border-color: var(--ok); }
.ms-body { flex: 1; min-width: 0; }
.ms-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.ms-name { font-weight: 600; }
.ms-date { font-variant-numeric: tabular-nums; color: var(--muted); }
.ms-badge { margin-left: auto; }
.ms-overdue .ms-badge { background: var(--bad-soft); color: var(--bad); }
.ms-overdue .ms-date { color: var(--bad); font-weight: 600; }
.ms-soon .ms-badge { background: var(--warn-soft); color: var(--warn); }
.ms-soon .ms-date { color: var(--warn); font-weight: 600; }
.ms-done .ms-name, .ms-done .ms-date { text-decoration: line-through; color: var(--muted); }
.ms-done .ms-badge { background: var(--ok-soft); color: var(--ok); }
.ms-nodate .ms-badge { background: var(--bg); color: var(--muted); }
.ms-edit { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
.ms-edit input[type=text] { flex: 1; min-width: 180px; }
.timeline.compact .ms { padding: 7px 0; }

/* view-as (impersonation) */
.viewas-banner { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between;
  background: var(--ev-charcoal); color: #fff; padding: 10px 16px; border-radius: var(--radius); margin-bottom: 16px; }
.viewas-banner b { color: #fff; }
.viewas-banner .btn { background: #fff; color: var(--ev-charcoal); border-color: #fff; }
.view-as { margin-top: 8px; }
.view-as select { width: 100%; font-size: 12.5px; padding: 4px 6px; }

.app-version { margin-top: 10px; font-size: 11px; letter-spacing: .04em; }

/* ---------- phones and small tablets ---------- */
.mobile-collapse > summary { display: none; }
.mobile-collapse[open] > summary { margin-bottom: 0; }
.topbar { display: none; }
.split > *, .grid > *, .main > * { min-width: 0; }
@media (max-width: 980px) {
  .topbar { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 30;
    background: #fff; border-bottom: 1px solid var(--line); padding: 10px 16px; height: 56px; }
  .topbar-logo img { height: 22px; width: auto; display: block; }
  .menu-btn { width: 44px; height: 44px; margin-right: -10px; border: 0; background: none; cursor: pointer;
    display: inline-flex; flex-direction: column; justify-content: center; align-items: center; gap: 5px; }
  .menu-btn span { display: block; width: 22px; height: 2px; background: var(--ink); border-radius: 2px; transition: transform .2s, opacity .2s; }
  .nav-open .menu-btn span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-open .menu-btn span:nth-child(2) { opacity: 0; }
  .nav-open .menu-btn span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
  .side { display: none; }
  .nav-open .side { display: block; position: fixed; top: 56px; left: 0; right: 0; bottom: 0; z-index: 29; height: auto;
    border-right: 0; overflow-y: auto; padding: 8px 16px 24px; }
  .nav-open { overflow: hidden; }
  .side .logo { display: none; }
  .side nav a { padding: 12px; font-size: 16px; }
  .side .me { font-size: 15px; }
  .view-as select { font-size: 16px; padding: 8px; }

  /* tabs: one row you can swipe */
  .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin-left: -16px; margin-right: -16px; padding: 0 12px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { white-space: nowrap; padding: 12px 12px; }

  /* thumb-sized controls (44px is Apple's minimum) */
  .btn { min-height: 44px; padding: 10px 16px; }
  .btn.sm { min-height: 40px; padding: 8px 14px; font-size: 14px; }
  .btn.link { min-height: 0; padding: 8px 0; }
  .checkbox { width: 36px; height: 36px; font-size: 19px; }
  .doc-actions { gap: 4px 18px; }
  .doc-actions a, .inline-d > summary, .history > summary, details > summary { display: inline-flex; align-items: center; min-height: 40px; }
  select { max-width: 100%; }
  .form-grid, .main [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  .main input, .main textarea { max-width: 100%; }
  /* wide tables scroll sideways inside their card instead of being cut off */
  .main table:not(.stack) { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tablewrap > table:not(.stack) { display: table; }
  .timeline { padding: 4px 16px 12px; }
  .ms-badge { margin-left: 0; }
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea { font-size: 16px; } /* stops iPhone zooming in */
  input[type=file] { max-width: 100%; font-size: 15px; }
  .pagehead h1 { font-size: 22px; }
  .pagehead > .btn, .pagehead > .actions { width: 100%; }
  .pagehead > .btn { justify-content: center; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters .field { min-width: 0 !important; }
  .filters .btn { width: 100%; justify-content: center; }
  .copy-line { flex-wrap: wrap; }
  .inbox-assign input[list] { min-width: 0; }
  .card { padding: 16px; }
  .card.tight > h2 { padding: 14px 16px 0; }
  .mobile-collapse > summary { display: flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 600; cursor: pointer; list-style: none; }
  .mobile-collapse > summary::-webkit-details-marker { display: none; }
  .mobile-collapse > summary::after { content: "▾"; margin-left: auto; color: var(--muted); }
  .mobile-collapse[open] > summary::after { content: "▴"; }
  .mobile-collapse[open] > summary { margin-bottom: 12px; }
  .mobile-collapse { padding-top: 6px; padding-bottom: 6px; }
}
@media (max-width: 640px) {
  .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
  .stat { padding: 12px; }
  .stat .val { font-size: 20px; }

  /* list tables become cards */
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  table.stack td { border: 0; padding: 2px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.stack td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; text-align: left; flex: none; }
  table.stack td.title { display: block; text-align: left; font-size: 15.5px; padding-bottom: 6px; }
  table.stack td.title::before { content: none; }
  table.stack td:empty, table.stack td.hide-phone { display: none; }
  table.stack tfoot { display: block; }
  .tablewrap:has(table.stack) { overflow: visible; }
}

/* product name beside the logo on phones, and the demo-site bar */
.topbar-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.topbar-logo span { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); border-left: 1px solid var(--line); padding-left: 10px; }
.demo-bar { background: #fff3c4; color: #5c4300; border-bottom: 1px solid #ecd27a; text-align: center; font-size: 12.5px; font-weight: 600; padding: 6px 12px; position: sticky; top: 0; z-index: 40; }
@media (max-width: 980px) { .demo-bar ~ .topbar { top: 31px; } }
