/* Encinitas Ortho — Proposals admin console. Clean, dense, professional. */
:root {
  --brand: #0f7d8c; --brand-2: #14b8a6; --brand-ink: #06363c;
  --ink: #14242c; --soft: #44565f; --muted: #7a8a92;
  --line: #e4e9e8; --line-2: #eef2f1; --bg: #f3f6f5; --surface: #fff; --surface-2: #f8faf9;
  --ok: #15924f; --ok-bg: #e7f5ec; --warn: #b4690e; --warn-bg: #fdf1e3;
  --info: #1a6fb0; --info-bg: #e7f0f8; --danger: #c0392b; --danger-bg: #fdecec; --neutral-bg: #eef2f1;
  --shadow: 0 4px 16px rgba(16,42,55,.08); --shadow-lg: 0 18px 50px rgba(16,42,55,.18);
  --r: 14px; --r-sm: 9px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
.hide { display: none !important; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.grow { flex: 1; }

/* buttons + inputs */
button { font-family: inherit; cursor: pointer; }
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: var(--r-sm);
  padding: 9px 15px; font-weight: 600; font-size: 14px; transition: .12s; }
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border: none; box-shadow: 0 6px 16px rgba(15,125,140,.25); }
.btn.primary:hover { filter: brightness(1.05); color: #fff; }
.btn.cta { background: #e0603e; color: #fff; border: none; box-shadow: 0 4px 12px rgba(224,96,62,.28); }
.btn.cta:hover { background: #cf5535; color: #fff; }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.ghost { background: transparent; border-color: transparent; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,125,140,.12); }
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--soft); margin: 0 0 5px; }
.field { margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* customize-treatment (one-off pricing) block inside the option builder */
.cust-wrap { margin-top: 10px; }
.cust-toggle.on { color: var(--accent); border-color: var(--accent); }
.coord-toggle.on { background: var(--ok-soft, #e7f5ec); color: var(--ok, #15924f); border-color: var(--ok, #15924f); font-weight: 700; }
.cust-fields { margin-top: 10px; padding: 12px; border: 1px dashed var(--line); border-radius: 10px; background: var(--panel-2, rgba(0,0,0,.02)); }
.custom-section { margin-top: 8px; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(20,184,166,.12), transparent), var(--bg); }
.login-card { width: 380px; max-width: calc(100vw - 40px); background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; box-shadow: var(--shadow-lg); padding: 32px 28px; }
.login-card .brand-mark { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--brand-ink); margin-bottom: 20px; }
.login-card .brand-dot { width: 30px; height: 30px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.login-card h1 { font-size: 19px; margin: 0 0 4px; }
.err { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 16px; }

/* app shell */
.topnav { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topnav .inner { max-width: 1180px; margin: 0 auto; padding: 0 18px; height: 58px; display: flex; align-items: center; gap: 20px; }
.brand-mark { display: flex; align-items: center; gap: 9px; font-weight: 800; color: var(--brand-ink); font-size: 15px; }
.brand-dot { width: 24px; height: 24px; border-radius: 8px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.tabs { display: flex; gap: 4px; }
.tab { padding: 8px 14px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--soft); cursor: pointer; }
.tab:hover { background: var(--surface-2); }
.tab.on { background: rgba(15,125,140,.1); color: var(--brand); }
.who { font-size: 13px; color: var(--muted); }
.hamburger { display: none; align-items: center; justify-content: center; width: 36px; height: 34px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font-size: 17px; line-height: 1; cursor: pointer; flex: none; }
.navmenu { min-width: 180px; }
.navmenu button.on { color: var(--brand); font-weight: 700; }
.main { max-width: 1180px; margin: 0 auto; padding: 22px 18px 60px; }

/* toolbar */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-size: 13px; font-weight: 600; color: var(--soft); cursor: pointer; }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.chip .n { opacity: .7; margin-left: 5px; }
.search { min-width: 230px; flex: 1; max-width: 340px; }

/* table */
.tablewrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); font-weight: 700; }
tbody td { padding: 13px 14px; border-bottom: 1px solid var(--line-2); font-size: 14px; vertical-align: middle; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
.t-name { font-weight: 600; }
.t-sub { font-size: 12.5px; color: var(--muted); }

/* status badges */
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.tag-pill { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .02em; padding: 2px 8px; border-radius: 999px; background: var(--accent, #f4a259); color: #6b3d12; text-transform: uppercase; white-space: nowrap; }
.b-draft { background: var(--neutral-bg); color: var(--soft); }
.b-active, .b-sent { background: var(--info-bg); color: var(--info); }
.b-viewed { background: var(--warn-bg); color: var(--warn); }
.b-accepted { background: var(--ok-bg); color: var(--ok); }
.b-declined, .b-expired { background: var(--danger-bg); color: var(--danger); }
.b-archived { background: var(--neutral-bg); color: var(--muted); }

/* link-expiry hint on a proposal row */
.exp { font-size: 12px; color: var(--muted); margin-top: 3px; }
.exp.soon { color: var(--warn); font-weight: 600; }
.exp.past { color: var(--danger); font-weight: 600; }

/* treatment-coordinator pill + the coordinator/link row */
.tc-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tc-tag { font-size: 13px; color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tc-pill { display: inline-block; padding: 3px 11px; border-radius: 999px; font-weight: 700; font-size: 12.5px; }
.tc-a { background: rgba(15,125,140,.12); color: var(--brand); }
.tc-b { background: #ede9fe; color: #6d28d9; }
.tc-c { background: #fdf1e3; color: #b4690e; }
.tc-d { background: var(--neutral-bg); color: var(--soft); }
.linkbox.grow { flex: 0 1 50%; min-width: 0; margin-left: auto; }

/* modal / drawer */
.overlay { position: fixed; inset: 0; background: rgba(16,42,55,.45); backdrop-filter: blur(2px); z-index: 40;
  display: grid; place-items: center; padding: 18px; }
.modal { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); width: 620px; max-width: 100%;
  max-height: 92vh; overflow: auto; }
.modal.wide { width: 820px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; background: var(--surface); }
.x { font-size: 22px; line-height: 1; color: var(--muted); border: none; background: none; }

/* context menu */
.ctx { position: fixed; z-index: 60; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 6px; min-width: 190px; }
.ctx button { display: block; width: 100%; text-align: left; padding: 9px 12px; border: none; background: none;
  border-radius: 8px; font-size: 13.5px; color: var(--ink); }
.ctx button:hover { background: var(--surface-2); }
.ctx .sep { height: 1px; background: var(--line-2); margin: 5px 4px; }
.ctx button.danger { color: var(--danger); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.archived-row { opacity: .55; }
.archived-row:hover { opacity: .8; }
.arch-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.arch-toggle input { width: auto; }

/* detail */
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 14px; margin-bottom: 16px; }
.kv .k { color: var(--muted); }
.opt-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 10px; }
.opt-card.rec { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(15,125,140,.1); }
.opt-addons { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.oa-chip { font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); }
.oa-chip.on { background: color-mix(in srgb, var(--brand) 12%, var(--surface)); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); color: var(--brand-ink); font-weight: 600; }
.oa-h { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-top: 8px; }
.oa-legend { font-size: 11px; color: var(--muted); margin-top: 5px; }
.icon-btn { display: inline-flex; align-items: center; gap: 5px; padding: 8px 12px; }
.icon-btn svg { display: block; }
.linkbox { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 8px 10px; font-size: 13px; }
.linkbox input { border: none; background: none; padding: 0; font-size: 13px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--line); position: relative; font-size: 13.5px; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 13px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.timeline .ts { color: var(--muted); font-size: 12px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin: 18px 0 8px; }
/* accepted-proposal contract breakdown */
.bd { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-top: 4px; }
.bd .r { display: flex; justify-content: space-between; gap: 12px; padding: 9px 14px; font-size: 14px; border-bottom: 1px solid var(--line-2); }
.bd .r:last-child { border-bottom: none; }
.bd .r.ai { padding-left: 26px; color: var(--soft); font-size: 13.5px; }
.bd .r.head { font-weight: 700; font-size: 15px; background: var(--surface-2); }
.bd .r.sub { background: var(--surface-2); font-weight: 700; }
.bd .r.grand { background: rgba(15,125,140,.08); font-weight: 800; color: var(--brand-ink); }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 11px 18px; border-radius: 10px; font-size: 14px; z-index: 80; box-shadow: var(--shadow-lg); }
.tmpl-pre { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; font-size: 13.5px; }
.palette button { font-size: 12px; padding: 4px 9px; margin: 0 5px 5px 0; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--soft); }
.palette button:hover { border-color: var(--brand); color: var(--brand); }
/* settings sub-nav */
.subnav { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 18px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.subtab { padding: 7px 13px; border-radius: 9px; font-weight: 600; font-size: 13.5px; color: var(--soft); cursor: pointer; }
.subtab:hover { background: var(--surface-2); }
.subtab.on { background: rgba(15,125,140,.1); color: var(--brand); }

/* sectioned modal forms */
.formsec { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  font-weight: 700; margin: 20px 0 10px; padding-top: 14px; border-top: 1px solid var(--line-2); }
.formsec:first-of-type { border-top: none; padding-top: 0; margin-top: 4px; }
.preset-box { background: linear-gradient(135deg, rgba(15,125,140,.06), rgba(20,184,166,.05));
  border: 1px solid rgba(15,125,140,.25); border-radius: 12px; padding: 14px 14px 2px; margin: 6px 0 4px; }
.preset-box .ph { font-size: 12.5px; font-weight: 700; color: var(--brand); margin: 0 0 10px; display: flex; align-items: center; gap: 6px; }

/* per-treatment add-on checklist */
.addon-grid { display: flex; flex-direction: column; gap: 8px; }
.addon-check { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.addon-check .nm { flex: 1; font-weight: 600; font-size: 14px; }
.addon-check .pr { color: var(--muted); font-size: 13px; }
.addon-check label { display: inline-flex; align-items: center; gap: 5px; margin: 0; font-size: 12.5px; color: var(--soft); white-space: nowrap; }
.addon-check input[type=checkbox] { width: auto; }
.filterbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.filterbar select { width: auto; min-width: 120px; flex: 1; padding: 8px 10px; font-size: 13px; }

/* custom treatment picker (name on line 1, fee indented on line 2) */
.tx-pick { position: relative; flex: 1; min-width: 0; }
.tx-pick-btn { width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface);
  border-radius: var(--r-sm); padding: 10px 30px 10px 12px; font-size: 14px; color: var(--ink); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-pick-btn::after { content: "▾"; position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.tx-pick-menu { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); max-height: 300px; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 4px; }
.tx-item { padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.tx-item:hover { background: var(--surface-2); }
.tx-item .tx-nm { font-weight: 600; font-size: 14.5px; color: var(--ink); }
.tx-item .tx-fee { padding-left: 18px; margin-top: 1px; color: var(--brand); font-weight: 700; font-size: 13.5px; }

/* per-option treatment card + add-on visibility toggles (New Proposal) */
.opt-row { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.opt-row .rec-lab { display: flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; margin: 0; }
.addon-toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.atog { display: inline-block; padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); font-size: 12.5px; font-weight: 600; cursor: pointer; user-select: none; }
.atog::before { content: "+ "; }
.atog.on { background: rgba(15,125,140,.1); border-color: var(--brand); color: var(--brand); }
.atog.on::before { content: "✓ "; }

/* accepted "needs contract" panel */
.acc-panel { background: linear-gradient(135deg, rgba(21,146,79,.07), rgba(20,184,166,.06)); border: 1px solid var(--ok); border-radius: var(--r); padding: 14px 16px; margin-bottom: 14px; }
.acc-head { font-weight: 800; color: var(--ok); font-size: 14.5px; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.acc-count { background: var(--ok); color: #fff; border-radius: 999px; padding: 1px 9px; font-size: 12.5px; }
.acc-list { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.acc-card { display: flex; align-items: center; gap: 10px; justify-content: space-between; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.acc-card:hover { border-color: var(--ok); }
.acc-card .btn { flex: none; }

/* active-filter indicator */
.active-filters { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.filt-pill { display: inline-flex; align-items: center; gap: 5px; background: rgba(15,125,140,.1); color: var(--brand); border-radius: 999px; padding: 4px 6px 4px 11px; font-size: 12.5px; font-weight: 600; }
.filt-pill button { border: none; background: none; color: var(--brand); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }

/* KPI strip */
.kpi-strip { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.kpi-strip:empty { display: none; }
.kpi-strip b { color: var(--ink); font-size: 15px; }
.kpi-strip span { display: inline-flex; gap: 6px; align-items: baseline; }

/* grouped status subheaders */
tr.grp td { background: var(--surface-2); padding: 8px 14px; border-bottom: 1px solid var(--line); }

/* right-click header filter menu */
.hcol { cursor: context-menu; }
.ctx-filter { min-width: 210px; }
.ctx-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 6px 10px 4px; }
.ctx-check { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.ctx-check:hover { background: var(--surface-2); }
.ctx-check input { width: auto; }

/* ---- proposals table: customizable columns ---- */
table.proposals { table-layout: fixed; }
table.proposals th.pcol { position: relative; user-select: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.proposals .t-name, table.proposals .t-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sort-arr { font-size: 10px; color: var(--brand); margin-left: 3px; }
.col-rsz { position: absolute; top: 0; right: 0; width: 9px; height: 100%; cursor: col-resize; }
.col-rsz:hover { box-shadow: inset -2px 0 0 var(--brand); }
body.col-resizing { cursor: col-resize; user-select: none; }
.collist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.colrow { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.colrow.dragging { opacity: .45; }
.colrow .drag { cursor: grab; color: var(--muted); font-size: 15px; }
.colrow label { display: flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer; margin: 0; }
.colrow input { width: auto; }

/* ---- reporting ---- */
.rep-filters { display: flex; flex-wrap: wrap; gap: 12px 18px; margin-bottom: 18px; }
.rep-filters label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.rep-filters select { font-size: 14px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); min-width: 150px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 8px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi-big { font-size: 26px; font-weight: 800; color: var(--brand-ink); line-height: 1.1; }
.kpi-lab { font-size: 13px; font-weight: 600; color: var(--ink); margin-top: 4px; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.rep-h { font-size: 14px; font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.rep-h.section { margin: 22px 0 10px; }
.rep-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 18px; }
.rep-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); }
.rep-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rep-table th { text-align: right; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 0 0 6px; font-weight: 700; }
.rep-table th:first-child { text-align: left; }
.rep-table td { padding: 6px 0; border-top: 1px solid var(--line); text-align: right; }
.rep-table td:first-child { text-align: left; font-weight: 600; }
.funnel { display: flex; flex-direction: column; gap: 8px; }
.fn-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.fn-lab { width: 64px; color: var(--muted); }
.fn-bar { flex: 1; height: 18px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.fn-fill { height: 100%; background: linear-gradient(135deg, var(--brand), var(--brand-2)); border-radius: 6px; }
.fn-n { width: 28px; text-align: right; font-weight: 700; color: var(--ink); }

@media (min-width: 701px) {
  .toolbar .chips { display: none; }       /* desktop: filter via right-click headers, not pills */
  .hcol::after { content: " ⌄"; color: var(--muted); font-size: 11px; }
}

@media (max-width: 700px) {
  .subnav { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .subtab { white-space: nowrap; }
  .addon-check { flex-wrap: wrap; }
  .filterbar select { min-width: 0; }
  /* top nav: single line, no title; tabs + New + Sign out inline */
  .topnav .inner { height: 54px; gap: 8px 10px; padding: 8px 12px; flex-wrap: nowrap; }
  .brand-mark { display: none; }                          /* no title on mobile */
  .topnav .inner .grow { display: block; flex: 1; min-width: 0; }
  #navNew, #logoutBtn { margin-left: 0; flex: none; }
  .who { display: none; }
  .kpi-strip { display: none; }                            /* drop the stats row on mobile */
  .tabs { overflow-x: auto; flex-wrap: nowrap; gap: 2px; min-width: 0; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; padding: 7px 12px; font-size: 13.5px; }
  .main { padding: 16px 12px 60px; }

  /* toolbar: chips scroll on one row; search + primary button go full width */
  .toolbar { gap: 10px; }
  .toolbar .grow { display: none; }
  .toolbar > h2 { width: 100%; }
  .chips { width: 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { white-space: nowrap; }
  .search { width: 100%; max-width: none; min-width: 0; }
  .toolbar .btn.primary { width: 100%; }

  /* tables -> stacked cards */
  .tablewrap { overflow-x: auto; }
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: auto; }
  table.cards tr { position: relative; padding: 9px 14px; }
  table.cards td { border: none; padding: 1px 0; }
  table.cards td.hidem, table th.hidem { display: none; }  /* after the block rule so it wins */
  table.cards td.col-rp { padding-right: 110px; }
  table.cards td.col-coordinator, table.cards td.col-agegroup, table.cards td.col-modality,
  table.cards td.col-age, table.cards td.col-updated { display: none; }   /* card stays 2 lines on mobile */
  table.cards td.col-status { position: absolute; top: 9px; right: 34px; padding: 0; text-align: right; }
  table.cards td.col-expiring { position: absolute; top: 31px; right: 34px; padding: 0; text-align: right; }
  table.cards td.col-expiring .exp { font-size: 11px; }
  table.cards td.col-actions { position: absolute; top: 5px; right: 6px; padding: 0; }
  table.proposals { table-layout: auto; }   /* cards: let content flow, ignore fixed widths */

  /* modals: bottom sheet, full width */
  .overlay { padding: 0; align-items: flex-end; }
  .modal, .modal.wide { width: 100%; max-width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; }
  .modal-head { padding: 15px 16px; }
  .modal-body { padding: 16px; }
  .modal-foot { padding: 12px 16px; flex-wrap: wrap; }
  .modal-foot .btn { flex: 1 1 auto; }
  .grid2 { gap: 9px; }                 /* keep 2 fields per line on mobile */
  .grid3 { grid-template-columns: 1fr 1fr; gap: 9px; }
  .kv { grid-template-columns: 104px 1fr; }
  .linkbox { flex-wrap: wrap; }
  .linkbox.grow { flex: 1 1 100%; margin-left: 0; }
  /* 16px inputs prevent iOS Safari from auto-zooming on focus (e.g. the login fields) */
  input, select, textarea { font-size: 16px; }
}

th.hdr-active { color: var(--accent); font-weight: 700; }
.filter-chips { font-size: 12px; color: var(--accent); font-weight: 600; background: var(--accent-bg); padding: 3px 10px; border-radius: 12px; margin-right: 8px; white-space: nowrap; }

/* very narrow: collapse the nav into a hamburger (tabs + Sign out live in the menu) */
@media (max-width: 480px) {
  .hamburger { display: inline-flex; }
  .topnav .inner .tabs { display: none; }
  #logoutBtn { display: none; }
}
