/* ezSrv design system — "terminal, elevated" (2026-07-05 UI overhaul)
   Loaded on every page via Views/Shared/_Layout.cshtml. Additive to Tailwind
   (Play CDN) — provides tokens, the self-hosted font, the app shell, and a
   semantic component vocabulary. Component class names (btn/card/panel/pill/
   data-table/modal/stat) are distinctive and do not collide with Tailwind
   utilities. Dark base #08090a + cyan #1ef4ed brand. */

/* ---------- fonts (self-hosted; CSP-safe, no external font host) ----------
   Body: Plus Jakarta Sans — a warm humanist geometric sans (friendly, premium,
   deliberately NOT the technical/grotesque feel of Inter).
   Display: Bricolage Grotesque — characterful headings for that editorial POP. */
@font-face{
  font-family:"Jakarta";
  src:url("/fonts/PlusJakartaSans.woff2") format("woff2");
  font-weight:200 800; font-style:normal; font-display:swap;
}
@font-face{
  font-family:"Bricolage";
  src:url("/fonts/BricolageGrotesque.woff2") format("woff2");
  font-weight:200 800; font-style:normal; font-display:swap;
}

:root{
  --ground:#08090a; --surface:#101215; --surface-2:#16191d; --raised:#1b1f24;
  --line:rgba(255,255,255,.07); --line-2:rgba(255,255,255,.12);
  --ink:#e9edf1; --muted:#8b95a1; --faint:#5b636d;
  --accent:#1ef4ed; --accent-hover:#0dffef; --accent-ink:#04211f; --accent-dim:rgba(30,244,237,.14);
  --crit:#ff5c6c; --warn:#f7b955; --good:#43d6a0; --info:#6ea8ff; --violet:#b58cff;
  --sans:"Jakarta","Plus Jakarta Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  --display:"Bricolage","Jakarta",-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  /* 2026-07-05 — softened from true monospace to the humanist sans. The
     terminal/mono treatment of references, status chips, dates and numbers
     read as "too techy" for a professional-services (law-firm) audience.
     Kept the token name + tabular figures so every existing var(--mono) /
     .mono usage across the app aligns numbers WITHOUT the developer feel. */
  --mono:"Jakarta","Plus Jakarta Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  --r:14px; --r-sm:10px;
  --glow:0 0 0 1px rgba(30,244,237,.10), 0 18px 60px -20px rgba(30,244,237,.22);
  --shadow:0 24px 60px -24px rgba(0,0,0,.7);
  --side-w:236px;
}

html{scroll-behavior:smooth}
body{
  font-family:var(--sans);
  -webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility;
  letter-spacing:-.006em;
}
.mono{font-family:var(--mono); font-variant-numeric:tabular-nums; letter-spacing:0}
.eyebrow{font-size:11px; letter-spacing:.16em; text-transform:uppercase; color:var(--muted); font-weight:600}

/* scrollbars */
*{scrollbar-width:thin; scrollbar-color:rgba(255,255,255,.16) transparent}
*::-webkit-scrollbar{width:10px;height:10px}
*::-webkit-scrollbar-thumb{background:rgba(255,255,255,.14);border-radius:8px;border:2px solid transparent;background-clip:padding-box}
*::-webkit-scrollbar-thumb:hover{background:rgba(255,255,255,.24);background-clip:padding-box}
::selection{background:rgba(30,244,237,.28);color:#fff}
:focus-visible{outline:2px solid var(--accent); outline-offset:2px; border-radius:6px}

/* ambient backdrop (fixed, behind everything) */
.app-field{position:fixed;inset:0;z-index:0;pointer-events:none;overflow:hidden}
.app-field::before{content:"";position:absolute;inset:-20%;
  background:radial-gradient(55% 45% at 16% 4%,rgba(30,244,237,.08),transparent 60%),
            radial-gradient(45% 40% at 90% 96%,rgba(110,168,255,.05),transparent 60%)}
.app-grid{position:absolute;inset:0;
  background-image:linear-gradient(var(--line) 1px,transparent 1px),linear-gradient(90deg,var(--line) 1px,transparent 1px);
  background-size:46px 46px;opacity:.4;
  -webkit-mask-image:radial-gradient(120% 80% at 50% 0%,#000,transparent 70%);
  mask-image:radial-gradient(120% 80% at 50% 0%,#000,transparent 70%)}

/* ---------- brand mark ---------- */
.mark{width:30px;height:30px;flex:0 0 auto;display:grid;place-items:center;border-radius:9px;
  background:linear-gradient(160deg,rgba(30,244,237,.16),rgba(30,244,237,.02));border:1px solid rgba(30,244,237,.3)}
.mark svg{width:17px;height:17px}
.wordmark{font-family:var(--display);font-weight:800;letter-spacing:-.02em;font-size:18px;color:var(--ink)}
.wordmark b{color:var(--accent);font-weight:700}

/* ======================= APP SHELL ======================= */
.app-shell{position:relative;z-index:2;min-height:100vh;display:grid;grid-template-columns:var(--side-w) 1fr}
.app-side{border-right:1px solid var(--line);padding:18px 14px;display:flex;flex-direction:column;gap:5px;
  position:sticky;top:0;height:100vh;background:linear-gradient(180deg,rgba(16,18,21,.55),rgba(8,9,10,.15))}
.app-brand{display:flex;align-items:center;gap:10px;padding:6px 8px 16px}
.nav-sec{font-size:10.5px;letter-spacing:.14em;text-transform:uppercase;color:var(--faint);font-weight:700;padding:14px 10px 6px}
.nav-item{display:flex;align-items:center;gap:11px;padding:9px 11px;border-radius:9px;color:var(--muted);
  font-size:13.5px;font-weight:500;transition:background .15s,color .15s;position:relative}
.nav-item svg{width:17px;height:17px;flex:0 0 auto;opacity:.85}
.nav-item:hover{background:rgba(255,255,255,.04);color:var(--ink)}
.nav-item.active{color:var(--accent);background:var(--accent-dim)}
.nav-item.active::before{content:"";position:absolute;left:-14px;top:8px;bottom:8px;width:3px;border-radius:0 3px 3px 0;
  background:var(--accent);box-shadow:0 0 12px var(--accent)}
.nav-count{margin-left:auto;font-family:var(--mono);font-size:11px;color:var(--muted);background:rgba(255,255,255,.06);border-radius:6px;padding:1px 7px}
.app-side-user{margin-top:auto;display:flex;align-items:center;gap:10px;padding:10px;border-radius:11px;border:1px solid var(--line);background:rgba(255,255,255,.02)}
.app-avatar{width:32px;height:32px;border-radius:9px;background:linear-gradient(150deg,var(--accent),#0aa89f);color:var(--accent-ink);
  display:grid;place-items:center;font-weight:700;font-size:13px;flex:0 0 auto}

.app-main{min-width:0;display:flex;flex-direction:column}
.app-topbar{display:flex;align-items:center;gap:14px;padding:14px 28px;border-bottom:1px solid var(--line);
  position:sticky;top:0;z-index:20;background:rgba(8,9,10,.72);backdrop-filter:blur(12px)}
.app-crumbs{font-size:13px;color:var(--muted)}
.app-crumbs b{color:var(--ink);font-weight:600}
.app-search{margin-left:6px;flex:1;max-width:340px;position:relative;display:flex;align-items:center;gap:9px;height:36px;padding:0 12px;
  background:rgba(255,255,255,.03);border:1px solid var(--line);border-radius:10px}
.app-search:focus-within{border-color:rgba(30,244,237,.5);box-shadow:0 0 0 3px rgba(30,244,237,.10)}
.app-search svg{width:15px;height:15px;color:var(--faint);flex:0 0 auto}
.app-search input{flex:1;min-width:0;height:100%;background:transparent;border:0;outline:0;color:var(--ink);font-family:var(--sans);font-size:13px;padding:0}
.app-search input::placeholder{color:var(--faint)}
.app-search input::-webkit-search-cancel-button{-webkit-appearance:none;appearance:none}
/* live results dropdown (HTMX-filled; hidden when empty) */
.app-search-results{position:absolute;top:calc(100% + 7px);left:0;right:0;z-index:120;
  background:var(--raised);border:1px solid var(--line-2);border-radius:12px;box-shadow:var(--shadow);
  max-height:min(70vh,460px);overflow-y:auto;padding:6px}
.app-search-results:empty{display:none}
.as-group{display:flex;align-items:center;gap:8px;padding:9px 10px 5px;font-size:10.5px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:var(--accent)}
.as-count{font-size:10px;color:var(--faint);background:rgba(255,255,255,.05);border-radius:20px;padding:1px 7px;font-weight:600;letter-spacing:0}
.as-item{display:flex;align-items:center;gap:10px;padding:9px 10px;border-radius:8px;text-decoration:none;color:var(--ink)}
.as-item:hover,.as-item:focus{background:var(--accent-dim);outline:none}
.as-ref{font-weight:650;font-size:13.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:44%}
.as-sub{flex:1;min-width:0;font-size:12.5px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.as-chip{flex:0 0 auto;font-size:11px;color:var(--muted);border:1px solid var(--line-2);border-radius:20px;padding:2px 9px;white-space:nowrap}
.as-empty{padding:16px 12px;font-size:13px;color:var(--muted);text-align:center}
.as-more{display:block;margin-top:4px;padding:10px;text-align:center;font-size:12.5px;font-weight:600;color:var(--accent);text-decoration:none;border-top:1px solid var(--line)}
.as-more:hover{background:var(--accent-dim)}
/* results page (/search) */
.as-page-form{display:flex;gap:10px;max-width:560px;margin-bottom:22px}
.as-page-group{font-size:13px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;color:var(--muted);margin:24px 0 10px;display:flex;align-items:center;gap:9px}
.app-top-actions{margin-left:auto;display:flex;align-items:center;gap:10px}
.icon-btn{width:36px;height:36px;border-radius:10px;display:grid;place-items:center;color:var(--muted);border:1px solid var(--line);background:rgba(255,255,255,.02);cursor:pointer}
.icon-btn:hover{color:var(--ink);background:rgba(255,255,255,.06)}
.icon-btn svg{width:17px;height:17px}
.app-content{padding:26px 28px 60px;width:100%;max-width:1360px;margin:0 auto}
.mobile-nav-btn{display:none}

/* page header helpers */
.page-head{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;margin-bottom:22px;flex-wrap:wrap}
.page-title{font-family:var(--display);font-size:26px;font-weight:700;letter-spacing:-.02em;margin:0;text-wrap:balance}
.page-sub{color:var(--muted);font-size:13.5px;margin:6px 0 0}
/* display face for the big editorial headings (Login hero + section titles) */
.auth-title,.auth-headline,.panel-title{font-family:var(--display)}
.panel-title{letter-spacing:-.015em}

/* ======================= COMPONENTS ======================= */
/* buttons */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;height:38px;padding:0 16px;border-radius:10px;
  font-weight:600;font-size:13.5px;font-family:var(--sans);cursor:pointer;border:0;
  transition:transform .12s ease,box-shadow .2s ease,background .2s ease,border-color .2s ease;white-space:nowrap;text-decoration:none}
.btn:active{transform:translateY(1px)}
.btn-primary{background:var(--accent);color:var(--accent-ink);box-shadow:0 8px 26px -10px rgba(30,244,237,.55)}
.btn-primary:hover{background:var(--accent-hover);box-shadow:0 10px 34px -8px rgba(30,244,237,.75)}
.btn-ghost{background:rgba(255,255,255,.04);color:var(--ink);border:1px solid var(--line-2)}
.btn-ghost:hover{background:rgba(255,255,255,.08)}
.btn-danger{background:rgba(255,92,108,.14);color:var(--crit);border:1px solid rgba(255,92,108,.35)}
.btn-danger:hover{background:rgba(255,92,108,.22)}
.btn-sm{height:30px;padding:0 12px;font-size:12.5px;border-radius:8px}
.btn svg{width:15px;height:15px}

/* pills / badges */
.pill{display:inline-flex;align-items:center;gap:6px;height:22px;padding:0 10px;border-radius:999px;
  font-size:11.5px;font-weight:600;border:1px solid;font-family:var(--mono);letter-spacing:0;vertical-align:middle}
.p-crit{color:var(--crit);background:rgba(255,92,108,.10);border-color:rgba(255,92,108,.32)}
.p-warn{color:var(--warn);background:rgba(247,185,85,.10);border-color:rgba(247,185,85,.3)}
.p-good{color:var(--good);background:rgba(67,214,160,.10);border-color:rgba(67,214,160,.3)}
.p-info{color:var(--info);background:rgba(110,168,255,.10);border-color:rgba(110,168,255,.3)}
.p-violet{color:var(--violet);background:rgba(181,140,255,.10);border-color:rgba(181,140,255,.3)}
.p-accent{color:var(--accent);background:var(--accent-dim);border-color:rgba(30,244,237,.4)}
.p-muted{color:var(--muted);background:rgba(255,255,255,.05);border-color:var(--line-2)}
.dot{width:6px;height:6px;border-radius:50%;background:currentColor;box-shadow:0 0 8px currentColor;flex:0 0 auto}

/* cards / panels */
.card{background:linear-gradient(165deg,rgba(22,25,29,.62),rgba(16,18,21,.5));border:1px solid var(--line);
  border-radius:var(--r);padding:18px}
.card-glass{backdrop-filter:blur(10px)}

/* 2026-08-31 — FLOATING overlay surface. Use this, never .card, for anything
   absolutely/fixed positioned above page content (popovers, dropdown panels,
   the live-estimate panel).
   .card is deliberately TRANSLUCENT (background alpha .5-.62) because it is
   designed to sit flat in the page flow and blend with the ground. Reused as a
   floating overlay it lets whatever sits underneath read straight through it —
   which is exactly how the estimate panel came to show the Documents tab and
   the conduct-money field bleeding through its own line items.
   Opaque background + real elevation shadow + a slightly brighter border so the
   panel reads as a layer above the page rather than a hole in it. */
.popover{background:var(--raised);border:1px solid var(--line-2);
  border-radius:var(--r);
  box-shadow:0 18px 48px -12px rgba(0,0,0,.75), 0 4px 12px rgba(0,0,0,.45);
  backdrop-filter:blur(12px)}
.panel{background:linear-gradient(180deg,rgba(18,21,24,.6),rgba(14,16,19,.5));border:1px solid var(--line);
  border-radius:var(--r);overflow:hidden}
.panel-head{display:flex;align-items:center;gap:12px;padding:15px 18px;border-bottom:1px solid var(--line)}
.panel-title{font-size:14.5px;font-weight:650;letter-spacing:-.01em;color:var(--ink)}
.panel-body{padding:18px}

/* stat cards */
.stats{display:grid;grid-template-columns:repeat(4,1fr);gap:16px}
.stat{position:relative;background:linear-gradient(165deg,rgba(22,25,29,.7),rgba(16,18,21,.55));
  border:1px solid var(--line);border-radius:var(--r);padding:17px 18px;overflow:hidden}
.stat:hover{border-color:var(--line-2)}
.stat-top{display:flex;align-items:center;gap:8px;margin-bottom:12px}
.stat-ico{width:30px;height:30px;border-radius:8px;display:grid;place-items:center;flex:0 0 auto}
.stat-ico svg{width:16px;height:16px}
.stat-label{font-size:12.5px;color:var(--muted);font-weight:500}
.stat-val{font-family:var(--mono);font-variant-numeric:tabular-nums;font-size:32px;font-weight:700;letter-spacing:-.02em;line-height:1;color:var(--ink)}
.stat-row{display:flex;align-items:flex-end;justify-content:space-between;gap:10px;margin-top:9px}
.spark{width:82px;height:30px;opacity:.9}
.trend{font-family:var(--mono);font-size:11.5px;font-weight:600;display:inline-flex;align-items:center;gap:3px}
.trend.up{color:var(--good)} .trend.down{color:var(--crit)} .trend.flat{color:var(--muted)}

/* inputs */
.input,.select,.textarea{width:100%;min-height:40px;padding:9px 13px;background:rgba(8,9,10,.6);border:1px solid var(--line-2);
  border-radius:10px;color:var(--ink);font-size:13.5px;font-family:var(--sans);transition:border .18s,box-shadow .18s}
.input::placeholder,.textarea::placeholder{color:var(--faint)}
.input:focus,.select:focus,.textarea:focus{outline:none;border-color:rgba(30,244,237,.55);box-shadow:0 0 0 4px rgba(30,244,237,.12)}
.textarea{resize:vertical;min-height:72px;line-height:1.5}
.select{appearance:none;padding-right:36px;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%238b95a1' stroke-width='2'><path d='M2 4l4 4 4-4'/></svg>");
  background-repeat:no-repeat;background-position:right 13px center}
.field-label{font-size:12px;font-weight:600;color:var(--muted);margin:0 0 7px;display:block}

/* segmented control */
.seg{display:inline-flex;background:rgba(8,9,10,.6);border:1px solid var(--line);border-radius:9px;padding:3px;gap:2px}
.seg button,.seg a{padding:5px 11px;border-radius:7px;font-size:12.5px;font-weight:600;color:var(--muted);cursor:pointer;border:0;background:none;text-decoration:none}
.seg button.on,.seg a.on{background:rgba(255,255,255,.08);color:var(--ink)}

/* filter pills (Cases pill-bar; these class strings are also referenced by
   the inline pill-swap JS in _PillBar.cshtml — keep the names in sync) */
.pill-tab{padding:8px 14px;border-radius:9px;font-size:13px;font-weight:600;color:var(--muted);
  border:1px solid var(--line-2);background:rgba(255,255,255,.02);cursor:pointer;transition:background .15s,color .15s,border-color .15s;white-space:nowrap}
.pill-tab:hover{color:var(--ink);background:rgba(255,255,255,.06)}
.pill-tab.on{background:var(--accent);color:var(--accent-ink);border-color:var(--accent);box-shadow:0 6px 20px -10px rgba(30,244,237,.6)}

/* tabs */
.tab-bar{display:inline-flex;border:1px solid var(--line-2);border-radius:10px;overflow:hidden;background:rgba(16,18,21,.6)}
.tab{padding:8px 22px;background:transparent;border:0;color:var(--muted);cursor:pointer;font-size:13px;font-weight:600;transition:background .15s,color .15s}
.tab:hover{color:var(--ink)}
.tab.active{background:var(--accent);color:var(--accent-ink)}

/* data table */
.data-table{width:100%;border-collapse:collapse;font-size:13px}
.data-table thead th{text-align:left;font-size:10.5px;letter-spacing:.1em;text-transform:uppercase;color:var(--faint);
  font-weight:700;padding:11px 18px;border-bottom:1px solid var(--line);white-space:nowrap}
.data-table tbody td{padding:13px 18px;border-bottom:1px solid rgba(255,255,255,.04);vertical-align:middle;color:var(--ink)}
.data-table tbody tr{transition:background .12s}
.data-table tbody tr:hover{background:rgba(30,244,237,.035)}
.data-table tbody tr:last-child td{border-bottom:0}
.data-table .right{text-align:right}
.ref{font-family:var(--mono);color:var(--accent);font-size:12.5px;font-weight:600}
.sub{color:var(--muted);font-size:12px}
.stripe{position:relative}
.stripe::before{content:"";position:absolute;left:0;top:6px;bottom:6px;width:3px;border-radius:3px;background:var(--sc,transparent)}

/* case-queue row grid (Cases _CaseQueue partial — clickable-row <a> + HTMX swap) */
.qrow{display:grid;grid-template-columns:88px 130px 1.4fr 1fr 1fr 130px;gap:14px;align-items:center;
  padding:13px 18px;border-bottom:1px solid rgba(255,255,255,.045);min-width:720px}
.qrow-full{grid-template-columns:88px 130px 1.5fr 1fr 1fr 1fr 110px}
.qrow:last-child{border-bottom:0}
.qhead{font-size:10.5px;letter-spacing:.1em;text-transform:uppercase;color:var(--faint);font-weight:700;
  border-bottom:1px solid var(--line);background:rgba(255,255,255,.015)}
.qrow-link{text-decoration:none;transition:background .12s}
.qrow-link:hover{background:rgba(30,244,237,.04)}
.qc-est,.qc-act{text-align:right;justify-self:end}
.qc-ref,.qc-org,.qc-law,.qc-due{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* allocation queues (Internal + Supplier) — shared filter + row grid */
.alloc-filter{display:grid;grid-template-columns:2fr 1fr 1fr 1fr auto;gap:12px;align-items:end}
.arow{display:grid;grid-template-columns:96px 1.1fr 1.5fr 1fr 130px 120px;gap:14px;align-items:center;
  padding:13px 18px;border-bottom:1px solid rgba(255,255,255,.045);min-width:820px}
.arow:last-child{border-bottom:0}
.arow.ahead{font-size:10.5px;letter-spacing:.1em;text-transform:uppercase;color:var(--faint);font-weight:700;
  border-bottom:1px solid var(--line);background:rgba(255,255,255,.015)}
.arow .acell{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
@media (max-width:820px){.alloc-filter{grid-template-columns:1fr 1fr}}

/* dialog / modal */
dialog.modal{border:0;padding:0;background:transparent;color:var(--ink);max-width:none}
dialog.modal::backdrop{background:rgba(4,6,8,.66);backdrop-filter:blur(3px)}
.modal-inner{width:440px;max-width:92vw;background:linear-gradient(180deg,rgba(22,25,29,.98),rgba(16,18,21,.99));
  border:1px solid var(--line-2);border-radius:18px;box-shadow:var(--shadow),var(--glow);overflow:hidden}
dialog.modal[open] .modal-inner{animation:ezs-pop .28s cubic-bezier(.2,.9,.25,1) both}
.modal-head{padding:18px 20px 14px;border-bottom:1px solid var(--line)}
.modal-h{font-size:16px;font-weight:700;margin:0;color:var(--ink)}
.modal-body{padding:18px 20px;display:flex;flex-direction:column;gap:15px}
.modal-foot{padding:14px 20px;border-top:1px solid var(--line);display:flex;gap:10px;justify-content:flex-end}

/* empty state / skeleton */
.empty-state{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:56px 24px;color:var(--muted)}
.empty-state .es-ico{width:52px;height:52px;border-radius:14px;display:grid;place-items:center;background:var(--accent-dim);color:var(--accent);margin-bottom:16px}
.empty-state h3{color:var(--ink);font-size:16px;font-weight:650;margin:0 0 6px}
.skeleton{background:linear-gradient(90deg,rgba(255,255,255,.04),rgba(255,255,255,.09),rgba(255,255,255,.04));
  background-size:200% 100%;animation:ezs-shimmer 1.3s linear infinite;border-radius:8px}

/* banners */
.banner{border-radius:12px;padding:12px 15px;font-size:13.5px;border:1px solid;display:flex;gap:10px;align-items:flex-start}
.banner-error{background:rgba(255,92,108,.10);border-color:rgba(255,92,108,.3);color:#ffd0d5}
.banner-success{background:rgba(67,214,160,.10);border-color:rgba(67,214,160,.3);color:#c9f6e6}
.banner-info{background:rgba(110,168,255,.10);border-color:rgba(110,168,255,.3);color:#d6e6ff}

/* utility */
.glow{box-shadow:var(--glow)}
.hairline{height:1px;background:var(--line);border:0;margin:0}

/* motion */
.rise{animation:ezs-rise .6s cubic-bezier(.2,.7,.2,1) both}
@keyframes ezs-rise{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:none}}
@keyframes ezs-pop{from{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:none}}
@keyframes ezs-shimmer{from{background-position:200% 0}to{background-position:-200% 0}}

/* responsive shell */
@media (max-width:1080px){.stats{grid-template-columns:repeat(2,1fr)}}
@media (max-width:860px){
  .app-shell{grid-template-columns:1fr}
  .app-side{position:fixed;left:0;top:0;bottom:0;z-index:60;width:260px;transform:translateX(-102%);transition:transform .25s ease;background:#0c0e11}
  .app-shell.nav-open .app-side{transform:none;box-shadow:var(--shadow)}
  .app-shell.nav-open::after{content:"";position:fixed;inset:0;background:rgba(0,0,0,.5);z-index:55}
  .mobile-nav-btn{display:grid}
  .app-content{padding:20px 16px 48px}
  .app-search{display:none}
}


/* ══════════════════════════════════════════════════════════════════════════
   MOBILE & TABLET LAYER — 2026-09-15
   ~85% of ezSrv traffic is phone-based, but the design system was built
   desktop-first: the only responsive rules were the nav drawer and two grid
   tweaks. Everything below closes that gap at the DESIGN-SYSTEM level so it
   applies across all 97 views at once, rather than patching them one by one.

   Patterns follow the Myroomz mobile layer (app/src/app/globals.css), which
   solves the same problems on a Next.js/Tailwind stack.
   ══════════════════════════════════════════════════════════════════════════ */

/* 1. HORIZONTAL DRIFT GUARD.
   One over-wide child (a table, a fixed-px block) makes the WHOLE page pan
   sideways, which reads as the layout "drifting" and misaligns every sticky
   header. `clip` not `hidden`: hidden creates a scroll container and would
   silently break position:sticky on .app-side and the table headers. */
html,body{max-width:100%;overflow-x:clip}

/* 2. iOS ZOOM-ON-FOCUS — the single worst offender on this app.
   Mobile Safari auto-zooms when focusing any control whose font-size is under
   16px, and ezSrv's .input/.select/.textarea are 13.5px. Every tap into every
   field on a form-heavy product zoomed the page and left it offset, which is
   most of the "drifting" users see. 16px is the threshold, not a preference. */
@media screen and (max-width:1023px){
  /* Bare element selectors + !important, deliberately.
     The first cut of this listed .input/.select/.textarea and input[type=...]
     and MISSED most of the app, in two ways found by sweeping the detail pages:
       1. input[type=text] does not match <input> with no type attribute at all
          — 18 such inputs exist;
       2. page-specific control classes (.ex-select on the case-execution screen,
          85 controls app-wide not using the shared classes) declare their own
          font-size, and a class selector outranks a bare element selector, so
          the rule lost on specificity and silently did nothing. That left the
          screen process servers actually work from still zooming on every tap.
     16px is a platform constraint imposed by Mobile Safari, not a style
     preference, so it legitimately outranks component styling. Buttons are
     excluded: they are sized by .btn, and their text is not a zoom trigger. */
  input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=reset]):not([type=range]),
  select,textarea,.input,.select,.textarea{font-size:16px!important}
}

/* 3. WIDE TABLES SCROLL THEMSELVES instead of pushing the page.
   .data-table is width:100% with nowrap headers; below ~700px its natural
   width exceeds the viewport. Wrap a table in .table-scroll and it scrolls in
   its own box, leaving the page still. */
.table-scroll{overflow-x:auto;-webkit-overflow-scrolling:touch;overscroll-behavior-x:contain}

/* The table becomes its OWN scroll container below the breakpoint. Done in CSS
   rather than by wrapping 14 tables across 13 views: fewer places to get wrong,
   and it cannot be forgotten on the next table someone adds.
   display:block is what allows overflow to apply to a <table>; the rows still
   form an anonymous table box inside, so column alignment is preserved.
   This also has to happen here because .panel sets overflow:hidden for its
   border radius — a wide table inside one was CLIPPED, not scrollable, so the
   right-hand columns were simply unreachable on a phone rather than merely
   awkward. */
@media (max-width:860px){
  .data-table{display:block;overflow-x:auto;-webkit-overflow-scrolling:touch;
    overscroll-behavior-x:contain;font-size:12.5px}
  .data-table thead th{padding:9px 12px}
  .data-table tbody td{padding:10px 12px}
}

/* 4. MOMENTUM SCROLLING on every scroll container (iOS inertial scroll). */
.table-scroll,.overflow-x-auto,.overflow-y-auto,.overflow-auto{-webkit-overflow-scrolling:touch}

/* 5. TOUCH TARGETS — 44px minimum (Apple HIG). .btn is 38px and .btn-sm is
   30px, both under the threshold. Inline text links and pills keep their own
   size — blanket-sizing every <a> would wreck body copy.
   The query is deliberately doubled. pointer:coarse is the semantically correct
   test, but it is UNVERIFIABLE from a desktop browser (which reports
   pointer:fine even in a phone-width frame), so on its own it ships untested.
   Adding max-width:640px makes the rule provable in the harness and also covers
   a touch laptop or a tablet a user has forced to desktop mode. .btn-sm goes to
   the full 44px rather than a compromise 38px because rule 11 has already
   stacked those action rows full-width, so there is no density left to protect. */
@media (pointer:coarse),(max-width:640px){
  .btn,.nav-item,.tab-btn,.btn-sm{min-height:44px}
  .btn-sm{padding:0 14px}
  input[type=checkbox],input[type=radio]{min-width:20px;min-height:20px}
}

/* 6. SAFE-AREA INSETS — iPhone home indicator overlaps the last row of a
   scrolled page and the bottom of the open nav drawer. */
@supports (padding:env(safe-area-inset-bottom)){
  .app-content{padding-bottom:calc(60px + env(safe-area-inset-bottom))}
  .app-side{padding-bottom:calc(18px + env(safe-area-inset-bottom))}
}

/* 7. MULTI-COLUMN GRIDS COLLAPSE.
   66 Tailwind grid-cols-N usages across 21 views carry no responsive prefix,
   so a 3-column form row became three ~110px columns on a phone — the field
   overlap in the screenshots. !important is required, not lazy: the Tailwind
   Play CDN injects its utilities into <head> at runtime, AFTER this stylesheet,
   so it wins on equal specificity.
   A view that opts in properly (grid-cols-1 md:grid-cols-2) is unaffected —
   its md: rule simply doesn't match below the breakpoint. */
@media (max-width:640px){
  .grid-cols-2,.grid-cols-3,.grid-cols-4,
  .grid-cols-5,.grid-cols-6{grid-template-columns:1fr!important}
  .stats{grid-template-columns:1fr}
  .app-topbar{padding:12px 16px}
}
@media (min-width:641px) and (max-width:1024px){
  .grid-cols-3,.grid-cols-4,
  .grid-cols-5,.grid-cols-6{grid-template-columns:repeat(2,1fr)!important}
}

/* 8. TAB BAR scrolls rather than crushing its tabs.
   .tab-bar is inline-flex with overflow:hidden, so a 3-tab wizard bar clipped
   its last tab on a phone instead of letting you reach it. */
@media (max-width:860px){
  .tab-bar{display:flex;width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
  .tab-bar>*{flex:1 0 auto;white-space:nowrap}
}

/* 9. FLOATING PANELS stay inside the viewport. .popover is used at a fixed
   320px (the live-estimate panel); on a 390px screen with side padding that
   is already touching both edges. */
.popover{max-width:calc(100vw - 24px)}

/* 10. LONG UNBROKEN STRINGS (case references, GUIDs, emails, file names) are
   a classic source of sideways drift on a narrow viewport. */
.ref,.mono,.as-ref,.as-sub{overflow-wrap:anywhere}
.card,.panel,.stat{min-width:0}


/* 11. TABLE-LIKE 12-COLUMN ROW GRIDS — internal users, members, organisations.
   Seven views emulate a table with `grid grid-cols-12` + `col-span-*`. At a
   377px viewport each column is ~31px, so a col-span-2 action cell holding four
   buttons (View/Edit/Suspend/Archive) spilled straight over the neighbouring
   name and email text. That is the overlap measured on /internalusers (28
   collisions), /members (18) and /superadmin (4) — not a z-index problem, just
   a 12-column grid with nowhere to put 12 columns.
   Stack each row into a card instead, and drop the column-header strip, which
   is meaningless once the columns are gone. The header is identifiable as the
   12-col grid that also carries .eyebrow. */
@media (max-width:1024px){
  .grid-cols-12.eyebrow{display:none}
  .grid-cols-12{grid-template-columns:1fr!important;gap:6px!important}
  .grid-cols-12>[class*="col-span-"]{grid-column:1/-1!important}
  .grid-cols-12 .flex{flex-wrap:wrap}
}

/* 12. HORIZONTAL TOOLBARS AND FILTER ROWS MUST WRAP.
   /superadmin's filter form is `flex items-center gap-3` holding a 16rem text
   input, two auto-width selects and a button, with no flex-wrap — about 650px
   of controls on a 377px screen. That is what pushed the whole PAGE sideways by
   274px, which is the "drift" in its most literal form: every sticky header and
   the content beneath it shifted with it.
   The width override needs !important to beat the inline style="width:16rem" —
   an author !important rule outranks a non-important inline declaration.
   Scoped to .app-content so the sidebar's nav items keep icon and label on one
   line rather than wrapping the label under the icon. */
@media (max-width:1024px){
  form.flex,
  .app-content .flex.items-center.gap-3,
  .app-content .flex.gap-3{flex-wrap:wrap}
  form.flex>.input,form.flex>.select{width:100%!important;flex:1 1 100%}
}


/* 13. PAGE-HEADER ACTION GROUPS.
   .page-head already wraps, but the action cluster inside it is usually an
   unclassed inline-styled flex div, which does not — so on /admin/templates a
   button group ran to 509px in a 380px viewport and pushed the page 116px.
   Selecting it by class is not possible (it has none), so target the structural
   position instead: the direct children of a page header. */
@media (max-width:1024px){
  .page-head{row-gap:10px}
  .page-head>div{flex-wrap:wrap;min-width:0;max-width:100%}
}


/* 14. ALLOCATION-QUEUE FILTER — single column on a phone.
   .alloc-filter already dropped 5 columns to 2 at 820px, but two date inputs
   side by side do not fit 390px: a date field has a wide intrinsic minimum, and
   raising controls to 16px (rule 2, to stop iOS zooming) widened it further, so
   the row overflowed by ~5px and clipped. Caught by re-measuring after the fix
   rather than assuming the earlier breakpoint still held — a fix that changes
   metrics has to be re-measured against the layouts that depended on them.
   min-width:0 lets a control shrink inside a grid track instead of forcing it. */
@media (max-width:640px){
  .alloc-filter{grid-template-columns:1fr}
  /* A child carries inline style="grid-column:span 2". Collapsing the track list
     to ONE column does not stop it spanning two — CSS just creates an implicit
     second column, and the grid is wide again. Resetting the track list without
     resetting the spans is a no-op, which is why the first attempt at this rule
     changed nothing. Same failure the col-span-* reset in rule 11 exists for.
     !important beats the inline style. */
  .alloc-filter>*{grid-column:auto!important}
}
.input,.select,.textarea{min-width:0}


/* 15. A WIDE .data-table IS CLIPPED BY ITS .panel AT ANY WIDTH.
   .panel sets overflow:hidden for its border radius, so a table wider than the
   panel loses its right-hand columns outright rather than scrolling. Rule 3
   fixes this below 860px; the desktop regression pass found the same fault at
   1440px, where /Execute/CaseExecution's list table runs ~25px past the edge and
   the last column is simply unreachable.
   PRE-EXISTING — confirmed by neutralising the overflow-x:clip guard added in
   rule 1 and re-measuring: the page still did not scroll, so the clipping is the
   panel's, not the guard's.
   :has() only engages when a panel actually contains a data-table, and
   overflow-x:auto only shows a scrollbar when content actually overflows, so
   nothing changes on the panels that already fit. Browsers without :has()
   degrade to today's behaviour. */
.panel:has(> .data-table){overflow-x:auto}

@media (prefers-reduced-motion:reduce){
  *{animation:none!important;transition:none!important;scroll-behavior:auto!important}
}
