:root{
  --bg:#F4F7FB;--surface:#FFFFFF;--surface2:#F8FAFC;--sidebar:#071A33;--sidebar-sel:#1268F3;
  --primary:#146BFA;--accent:#19C6E6;--success:#16A873;--warning:#E59A18;--critical:#D94452;
  --text:#0B172A;--text2:#526176;--border:#DCE4EE;--rc:12px;--ri:8px;--font:'Inter',system-ui,sans-serif;
}
[data-theme="dark"]{--bg:#07111F;--surface:#101C2C;--surface2:#172538;--sidebar:#050E1B;
  --sidebar-sel:#176BEB;--text:#F2F7FD;--text2:#BAC7D8;--border:#2B3B50}
*{margin:0;padding:0;box-sizing:border-box}
html,body{max-width:100%;overflow-x:hidden}
body{font-family:var(--font);background:var(--bg);color:var(--text);line-height:1.5;-webkit-font-smoothing:antialiased}
a{color:var(--primary);text-decoration:none}
button{font-family:var(--font)}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.shell{display:flex;min-height:100vh}
.sidebar{width:248px;background:var(--sidebar);position:fixed;top:0;bottom:0;left:0;z-index:1000;
  display:flex;flex-direction:column;overflow-y:auto;transition:transform .22s}
.side-logo{padding:18px 16px;color:#fff;font-weight:700;font-size:1.05em}
.side-logo b{color:var(--accent)}
.side-nav{padding:4px 8px;flex:1}
.side-group{font-size:.68em;letter-spacing:.08em;text-transform:uppercase;color:#5F7495;padding:14px 10px 6px}
.side-item{display:flex;gap:10px;padding:10px 12px;min-height:44px;align-items:center;border-radius:8px;
  margin-bottom:2px;color:#BAC7D8;font-size:.875em;text-decoration:none}
.side-item:hover{background:rgba(255,255,255,.07);color:#fff}
.side-item.active{background:var(--sidebar-sel);color:#fff;font-weight:600}
.side-backdrop{display:none;position:fixed;inset:0;background:rgba(4,12,24,.5);z-index:999}
.main{margin-left:248px;flex:1;min-width:0;display:flex;flex-direction:column}
.topbar{background:var(--surface);border-bottom:1px solid var(--border);padding:10px 20px;
  display:flex;align-items:center;gap:10px;position:sticky;top:0;z-index:40;flex-wrap:wrap}
.env-badge{background:rgba(229,154,24,.15);color:#A8730F;font-weight:700;font-size:.72em;
  letter-spacing:.08em;padding:4px 10px;border-radius:6px;border:1px solid rgba(229,154,24,.4)}
[data-theme="dark"] .env-badge{color:var(--warning)}
.spacer{flex:1}
.hamburger{width:44px;height:44px;border-radius:8px;border:1px solid var(--border);
  background:var(--surface);cursor:pointer;color:var(--text2);font-size:1.1em;display:none}
.workspace{padding:28px;max-width:1800px;width:100%;margin:0 auto}
.page-head{display:flex;align-items:flex-start;gap:12px;margin-bottom:20px;flex-wrap:wrap}
h1{font-size:28px;font-weight:600;flex:1;min-width:180px}
.sub{color:var(--text2);font-size:.9em}
.page-actions{display:flex;gap:10px;flex-wrap:wrap}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:7px;padding:0 18px;
  min-height:44px;border-radius:8px;font-weight:600;font-size:.9em;cursor:pointer;border:none}
.btn:disabled{opacity:.55;cursor:not-allowed}
.btn-p{background:var(--primary);color:#fff}
.btn-p:hover:not(:disabled){filter:brightness(1.08)}
.btn-s{background:var(--surface);color:var(--text);border:1px solid var(--border)}
.btn-s:hover:not(:disabled){background:var(--surface2)}
.btn-d{background:var(--critical);color:#fff}
.btn-sm{min-height:36px;padding:0 12px;font-size:.82em}
.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--rc);padding:20px;margin-bottom:16px}
.card h3{font-size:16px;font-weight:600;margin-bottom:14px}
.tbl-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--rc);
  overflow:hidden;margin-bottom:16px}
.tbl-scroll{overflow-x:auto;-webkit-overflow-scrolling:touch}
table.tbl{width:100%;border-collapse:collapse;font-size:.875em;min-width:640px}
.tbl th{text-align:left;padding:10px 14px;color:var(--text2);font-weight:600;font-size:.86em;
  border-bottom:1px solid var(--border);background:var(--surface2);white-space:nowrap}
.tbl td{padding:11px 14px;border-bottom:1px solid var(--border);word-break:break-word}
.tbl tbody tr:hover td{background:var(--surface2)}
.tbl .num{font-variant-numeric:tabular-nums;white-space:nowrap}
.toolbar{display:flex;gap:10px;padding:14px 16px;border-bottom:1px solid var(--border);
  flex-wrap:wrap;align-items:center}
.toolbar .input,.toolbar .select{flex:1;min-width:150px;max-width:300px}
.pager{display:flex;justify-content:space-between;align-items:center;padding:12px 16px;
  color:var(--text2);font-size:.85em;flex-wrap:wrap;gap:8px}
.badge{display:inline-flex;align-items:center;gap:5px;padding:3px 10px;border-radius:14px;
  font-size:.75em;font-weight:600;white-space:nowrap}
.badge:before{content:"";width:6px;height:6px;border-radius:50%;background:currentColor}
.b-green{background:rgba(22,168,115,.12);color:var(--success)}
.b-blue{background:rgba(20,107,250,.1);color:var(--primary)}
.b-cyan{background:rgba(25,198,230,.12);color:#0E8FA8}
.b-amber{background:rgba(229,154,24,.14);color:#A8730F}
.b-red{background:rgba(217,68,82,.12);color:var(--critical)}
.b-grey{background:var(--surface2);color:var(--text2)}
[data-theme="dark"] .b-amber{color:var(--warning)}
[data-theme="dark"] .b-cyan{color:var(--accent)}
.input,.select{min-height:44px;border:1px solid var(--border);border-radius:var(--ri);
  padding:0 12px;background:var(--surface);color:var(--text);font-family:var(--font);font-size:.9em}
textarea.select{padding:8px 12px;min-height:80px}
.input:focus,.select:focus{outline:none;border-color:var(--primary);
  box-shadow:0 0 0 3px rgba(20,107,250,.12)}
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.form-grid3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:14px}
.fld{min-width:0}
.fld label{display:block;font-size:.82em;font-weight:600;margin-bottom:5px}
.fld .hint{font-size:.75em;color:var(--text2)}
.fld input,.fld select,.fld textarea{width:100%;min-height:44px;border:1px solid var(--border);
  border-radius:var(--ri);padding:8px 12px;font-family:var(--font);font-size:.9em;
  background:var(--surface);color:var(--text)}
.kpis{display:grid;grid-template-columns:repeat(4,1fr);gap:14px;margin-bottom:20px}
.kpi{background:var(--surface);border:1px solid var(--border);border-radius:var(--rc);padding:16px;min-width:0}
.kpi .lbl{color:var(--text2);font-size:.8em}
.kpi .val{font-size:1.6em;font-weight:700;margin-top:4px;font-variant-numeric:tabular-nums;
  overflow:hidden;text-overflow:ellipsis}
.kpi .delta{font-size:.75em;margin-top:2px}
.icon-btn{width:44px;height:44px;border-radius:8px;border:1px solid var(--border);
  background:var(--surface);cursor:pointer;color:var(--text2);display:flex;
  align-items:center;justify-content:center;font-size:1em}
.dots{min-width:36px;height:36px;border-radius:8px;border:1px solid var(--border);
  background:var(--surface);cursor:pointer;color:var(--text2);font-weight:700}
.empty{text-align:center;padding:56px 20px;color:var(--text2)}
.empty .big{font-size:2.4em;margin-bottom:10px}
.empty b{display:block;margin-bottom:4px;color:var(--text)}
.skeleton{background:linear-gradient(90deg,var(--surface2),var(--border),var(--surface2));
  background-size:200% 100%;animation:sk 1.2s infinite;border-radius:8px;min-height:14px}
@keyframes sk{to{background-position:-200% 0}}
.modal-bg{position:fixed;inset:0;background:rgba(4,12,24,.5);z-index:80;display:none;
  align-items:flex-start;justify-content:center;padding:60px 16px;overflow-y:auto}
.modal-bg.open{display:flex}
.modal{background:var(--surface);border-radius:16px;width:620px;max-width:100%;
  box-shadow:0 24px 60px rgba(4,12,24,.3);max-height:calc(100vh - 80px);
  display:flex;flex-direction:column}
.modal-head{padding:16px 22px;border-bottom:1px solid var(--border);display:flex;
  justify-content:space-between;align-items:center;flex-shrink:0}
.modal-head h3{font-size:16px}
.modal-body{padding:22px;overflow-y:auto}
#toast-box{position:fixed;bottom:20px;right:20px;z-index:200;display:flex;
  flex-direction:column;gap:8px;max-width:min(380px,90vw)}
.toast{background:#0B172A;color:#fff;padding:13px 18px;border-radius:10px;font-size:.88em;
  border-left:4px solid var(--accent);box-shadow:0 8px 30px rgba(0,0,0,.3);
  animation:tin .2s ease-out;word-break:break-word}
.toast.err{border-left-color:var(--critical)}.toast.warn{border-left-color:var(--warning)}
.toast.ok{border-left-color:var(--success)}
@keyframes tin{from{transform:translateX(20px);opacity:0}}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:16px}
.grid3{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}
@media(max-width:1000px){.grid2,.grid3{grid-template-columns:1fr}}
.notice{background:rgba(25,198,230,.08);border:1px solid rgba(25,198,230,.3);border-radius:10px;
  padding:12px 16px;font-size:.85em;color:var(--text2);margin-bottom:14px}
.timeline{list-style:none}
.timeline li{padding:9px 0 9px 26px;position:relative;border-left:2px solid var(--border);
  margin-left:10px;font-size:.88em}
.timeline li:before{content:"";position:absolute;left:-7px;top:13px;width:12px;height:12px;
  border-radius:50%;background:var(--primary);border:2px solid var(--surface)}
.timeline li.ok:before{background:var(--success)}
.timeline li.bad:before{background:var(--critical)}
.hidden{display:none!important}
.tabs{display:flex;gap:2px;border-bottom:2px solid var(--border);margin-bottom:18px;
  overflow-x:auto;scrollbar-width:none}
.tabs::-webkit-scrollbar{display:none}
.tab{padding:10px 14px;min-height:44px;font-size:.86em;font-weight:600;color:var(--text2);
  cursor:pointer;border:none;border-bottom:3px solid transparent;background:none;
  white-space:nowrap;font-family:var(--font)}
.tab.active{color:var(--primary);border-bottom-color:var(--primary)}
.sticky-actions{display:flex;gap:10px;flex-wrap:wrap;margin-top:8px}
.sticky-actions .btn{flex:1;min-width:130px}
@media(max-width:900px){
  .sidebar{transform:translateX(-102%);width:280px;visibility:hidden}
  .sidebar.open{transform:translateX(0);-webkit-transform:translateX(0);visibility:visible}
  .main{margin-left:0}
  .hamburger{display:flex}
  .workspace{padding:16px}
  h1{font-size:24px}
  .side-backdrop.open{display:block;position:fixed;inset:0;background:rgba(4,12,24,.5);z-index:999}
}


/* ===================== MOBILE RESPONSIVE LAYER (2026-09-13) ===================== */
html{ -webkit-text-size-adjust:100%; }
body{ min-height:100dvh; }
body.drawer-open{ overflow:hidden; }
img,svg,canvas{max-width:100%}
pre{white-space:pre-wrap;word-break:break-word}

/* iOS: 16px inputs prevent auto-zoom */
@media(max-width:767px){
  .input,.select,.fld input,.fld select,.fld textarea{font-size:16px!important}
}

/* ---- KPI grids: 2-up on phones/tablets, 4-up desktop ---- */
@media(max-width:1023px){
  .kpis{grid-template-columns:1fr 1fr!important;gap:10px!important;margin-bottom:14px}
  .kpis[style*="repeat(4"]{grid-template-columns:1fr 1fr!important}
}
@media(max-width:374px){
  .kpis{gap:8px!important}
  .kpi{padding:12px}
}
@media(min-width:1024px){
  .kpis{grid-template-columns:repeat(4,1fr)}
}

/* KPI text: never truncate values */
.kpi .val{overflow:visible;text-overflow:clip;word-break:break-word;line-height:1.2}
.kpi .lbl{white-space:normal}

/* ---- Breakpoint: large mobile 480-767 ---- */
@media(max-width:767px){
  .workspace{padding:14px 12px}
  .card{padding:14px;margin-bottom:12px}
  .card h3{font-size:15px}
  h1{font-size:21px}
  .page-actions{width:100%}
  .page-actions .btn{flex:1;min-width:0}
  /* charts one-per-row */
  .grid2,.grid3{grid-template-columns:1fr!important}
  /* modals become bottom sheets */
  .modal-bg{padding:0;align-items:flex-end}
  .modal{width:100%;max-width:100%;border-radius:16px 16px 0 0;max-height:calc(100dvh - 40px);
    padding-bottom:env(safe-area-inset-bottom)}
  .form-grid,.form-grid3{grid-template-columns:1fr;gap:10px}
}

/* ---- Mobile small 320-479: tables become contained scroll w/ sticky first col ---- */
@media(max-width:767px){
  .tbl-card{overflow-x:auto;-webkit-overflow-scrolling:touch}
  table.tbl{min-width:640px}
  .tbl th:first-child,.tbl td:first-child{position:sticky;left:0;background:var(--surface);
    z-index:1;box-shadow:2px 0 4px -2px rgba(4,12,24,.12)}
  .tbl tbody tr:hover td:first-child{background:var(--surface)}
  .toolbar{padding:10px 12px}
  .toolbar .input,.toolbar .select{max-width:none}
  .pager{font-size:.92em}
  .btn-sm{min-height:40px}
}

/* ---- Drawer: proper overlay + safe areas (<=1023px) ---- */
@media(max-width:1023px){
  .sidebar{width:min(86vw,320px);padding-top:env(safe-area-inset-top);
    padding-bottom:env(safe-area-inset-bottom);
    transform:translateX(-102%);visibility:hidden;transition:transform .25s ease;
    -webkit-transform:translateX(-102%)}
  .sidebar.open{transform:translateX(0);-webkit-transform:translateX(0);visibility:visible;
    box-shadow:8px 0 40px rgba(4,12,24,.35)}
  .side-backdrop.open{display:block}
}

/* ---- Tablet 768-1023 ---- */
@media(min-width:768px) and (max-width:1023px){
  .workspace{padding:18px}
  .kpis{gap:12px}
}

/* ---- Topbar: compact on mobile ---- */
@media(max-width:767px){
  .topbar{padding:8px 10px;gap:8px}
  .env-badge{font-size:.65em;padding:3px 8px}
  h1{font-size:20px}
  .sub{font-size:.82em}
  #toast-box{left:12px;right:12px;max-width:none;bottom:calc(12px + env(safe-area-inset-bottom))}
}

/* ---- Zero page-level horizontal overflow guarantee ---- */
@media(max-width:1023px){
  html,body{overflow-x:clip}
  .workspace>*{max-width:100%}
}

/* ---- Mobile record cards (tables -> cards <768px) ---- */
.mob-cards{display:flex;flex-direction:column;gap:10px}
.mob-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--rc);padding:12px 14px}
.mob-card-top{display:flex;justify-content:space-between;align-items:center;gap:8px;margin-bottom:8px;flex-wrap:wrap}
.mob-card-top b{word-break:break-word;font-size:.95em}
.mob-rows{display:flex;flex-direction:column;gap:5px}
.mob-rows>div{display:flex;justify-content:space-between;gap:12px;font-size:.88em}
.mob-rows>div span{color:var(--text2)}
.mob-rows>div b{text-align:right;word-break:break-word;font-variant-numeric:tabular-nums}
.mob-exact{color:var(--text2);font-weight:400;font-size:.85em}
@media(min-width:768px){.mob-cards{display:none!important}}

/* ---- Mobile filter sheet ---- */
.mfilter-bar{display:none;margin-bottom:10px}
.mfilter-bar .mfilter-count{margin-left:6px}
.mfilter-sheet{display:none}
@media(max-width:767px){
  .mfilter-bar{display:flex;gap:8px}
  .mfilter-toggle{min-height:44px;flex:1;justify-content:center}
  .mfilter-sheet{position:fixed;left:0;right:0;bottom:0;z-index:90;background:var(--surface);
    border-radius:16px 16px 0 0;box-shadow:0 -12px 40px rgba(4,12,24,.3);
    padding:18px 16px calc(18px + env(safe-area-inset-bottom));max-height:80dvh;overflow-y:auto;
    transform:translateY(105%);transition:transform .22s ease;flex-direction:column}
  .mfilter-sheet.open{display:flex;transform:translateY(0)}
  .mfilter-sheet>div{width:100%}
  .mfilter-sheet .input{width:100%!important}
  /* sticky behind sheet */
  .mfilter-bar.open + * {}
}
/* bigger touch targets everywhere on mobile */
@media(max-width:767px){
  .btn-sm{min-height:44px;padding:0 14px}
  .pager .btn{min-height:44px}
  .tab{min-height:48px}
  .icon-btn,.dots{width:44px;height:44px}
  /* readable charts */
  #tov-trend,#ts-trend,#ts-money{min-height:220px}
  /* more vertical rhythm */
  .mob-card{padding:14px}
}
/* drawer close button */
.side-close{position:absolute;top:10px;right:10px;background:none;border:none;color:#BAC7D8;
  font-size:1.3em;width:44px;height:44px;cursor:pointer;display:none}
@media(max-width:1023px){ .side-close{display:block} }

/* ---- R3: landscape phones (height < 500) — tighten sheets & headers ---- */
@media(max-width:1023px) and (max-height:500px){
  .workspace{padding:10px 12px}
  .kpis,.kpis[style*="repeat(4"]{grid-template-columns:1fr 1fr 1fr 1fr!important}
  .kpi{padding:10px}
  .kpi .val{font-size:1.25em}
  .mfilter-sheet{max-height:88dvh}
  .modal{max-height:calc(100dvh - 24px)}
  h1{font-size:18px}
}
/* ---- date-range summary chip ---- */
.range-chip{display:none;align-items:center;gap:6px;background:var(--surface2);
  border:1px solid var(--border);border-radius:16px;padding:6px 12px;font-size:.8em;
  color:var(--text2);white-space:nowrap}
@media(max-width:767px){ .range-chip{display:inline-flex} }
/* ---- skeleton cards while loading ---- */
.mob-card.skeleton-card{pointer-events:none}
.mob-card.skeleton-card .skl{height:12px;border-radius:6px;margin:6px 0}
/* ---- double-tap guard ---- */
.btn[aria-busy="true"]{opacity:.6;pointer-events:none}

/* ---- R4: universal search + unified filter sheet ---- */
.mf2-root{position:sticky;top:52px;z-index:60;background:var(--bg);padding:6px 0;margin-bottom:4px}
.mf2-bar{display:flex;flex-direction:column;gap:8px;margin-bottom:12px}
.mf2-q{width:100%}
.mf2-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.mf2-open{min-height:44px}
.mf2-chips{display:flex;gap:6px;flex-wrap:wrap}
.chiprow{display:flex;gap:6px;flex-wrap:wrap}
.chip{border:1px solid var(--border);background:var(--surface);color:var(--text);
  border-radius:16px;padding:8px 14px;font-size:.85em;cursor:pointer;min-height:36px;font-family:var(--font)}
.chip.on{background:var(--primary);color:#fff;border-color:var(--primary)}
.chip-x{display:inline-flex;align-items:center;gap:5px}
.chip-x button{border:none;background:none;color:inherit;cursor:pointer;font-size:1em;padding:0 2px}
.chip-clear{background:var(--surface2)}
.mf2-backdrop{position:fixed;inset:0;background:rgba(4,12,24,.5);z-index:95;display:none}
.mf2-backdrop.open{display:block}
.mf2-sheet{position:fixed;left:0;right:0;bottom:0;top:auto;z-index:96;background:var(--surface);
  border-radius:16px 16px 0 0;box-shadow:0 -12px 40px rgba(4,12,24,.35);display:none;
  flex-direction:column;max-height:88dvh;padding-bottom:env(safe-area-inset-bottom);
  transform:translateY(105%);transition:transform .22s ease}
.mf2-sheet.open{display:flex;transform:translateY(0)}
.mf2-head{display:flex;justify-content:space-between;align-items:center;padding:14px 16px;
  border-bottom:1px solid var(--border);flex-shrink:0}
.mf2-scroll{overflow-y:auto;padding:14px 16px;flex:1}
.mf2-sec{font-size:.78em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;
  color:var(--text2);margin:12px 0 6px}
.mf2-custom label,.mf2-lbl{display:block;font-size:.8em;color:var(--text2);margin:8px 0 3px}
.mf2-custom .input{width:100%}
.mf2-actions{display:flex;gap:10px;padding:12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top:1px solid var(--border);flex-shrink:0}
.mf2-actions .btn{flex:1;min-height:48px}
@media(min-width:768px){
  .mf2-sheet{left:50%;right:auto;bottom:auto;top:8vh;transform:translate(-50%,-8px);
    width:560px;border-radius:16px;opacity:0;pointer-events:none;transition:opacity .15s}
  .mf2-sheet.open{transform:translate(-50%,0);opacity:1;pointer-events:auto}
}
@media(max-width:767px){
  body.drawer-open{overflow:hidden}
  .mf2-bar .input{font-size:16px}
}

/* hide legacy desktop filter card rows on mobile — replaced by mf2 sheet */
@media(max-width:767px){
  .card .mf2-legacy-hide{display:none}
}

/* R5: forms stack on mobile; all controls full width */
@media(max-width:767px){
  .stack-mobile{flex-direction:column!important;align-items:stretch!important}
  .stack-mobile>.input,.stack-mobile>.select,.stack-mobile>.btn{width:100%!important}
  .stack-mobile>.input,.stack-mobile>.select{min-height:44px}
  /* generic: any card's inline flex form rows with inputs stack */
  .card>div[style*="display:flex"]>.fld{width:100%}
}

/* R6 (rev2): on mobile hide only the legacy FILTER FORM ROWS inside filter cards —
   the card itself (and its results: groups/cards/tables) must stay visible.
   Fixes: results rendered inside .filtercard were invisible ≤767px. */
@media(max-width:767px){
  .filtercard>div[style*="display:flex"]{display:none!important}
}

/* ==== Traffic Overview Pro ==== */
#tov-events thead th{position:sticky;top:0;background:var(--surface);z-index:2;box-shadow:0 1px 0 var(--border)}
#tov-events tbody tr{transition:background .15s}
#tov-events tbody tr:hover{background:rgba(74,222,128,.05)}
.kpi{transition:transform .15s ease, box-shadow .15s ease}
.kpi:hover{transform:translateY(-2px);box-shadow:0 6px 18px rgba(0,0,0,.18)}
.card{transition:box-shadow .2s ease}
.card:hover{box-shadow:0 8px 24px rgba(0,0,0,.14)}
#tov-country > div, #tov-campaign > div, #tov-reseller > div, #tov-carrier > div{border-radius:6px;padding:2px 4px;margin-left:-4px;margin-right:-4px}
#tov-country > div:hover, #tov-campaign > div:hover, #tov-reseller > div:hover, #tov-carrier > div:hover{background:rgba(74,222,128,.07)}
@media(max-width:760px){ #tov-kpis{grid-template-columns:repeat(2,1fr)!important} }
@media(max-width:480px){ #tov-kpis{grid-template-columns:1fr!important} }


/* ==== UNIVERSAL RESPONSIVE POLISH (all pages) ==== */
/* Wider usable area with comfortable padding at every size */
@media(min-width:1600px){
  .workspace{padding:32px 40px}
}
/* Tablet: sidebar overlays, content full width */
@media(max-width:1023px){
  .kpis,.kpis[style*="repeat(4"]{grid-template-columns:1fr 1fr!important;gap:10px!important}
  .card{padding:14px}
  .kpi .val{font-size:1.4em}
}
/* Phones: single column, generous touch targets, no cramped tables */
@media(max-width:767px){
  .workspace{padding:12px 12px 90px}
  .kpis,.kpis[style*="repeat(4"]{grid-template-columns:1fr 1fr!important;gap:8px!important}
  .card{padding:12px;border-radius:10px}
  .card h3{font-size:.95em}
  /* every data table scrolls horizontally inside its card, never breaks layout */
  .card .tbl, .card table{display:block;overflow-x:auto;-webkit-overflow-scrolling:touch;white-space:nowrap}
  .tbl th,.tbl td{padding:8px 10px;font-size:.82em}
  /* touch targets */
  .btn,.btn-sm,.select,.input{min-height:40px}
  .btn-sm{padding:8px 12px}
  .input,.select{font-size:16px} /* prevents iOS zoom-on-focus */
  /* action bars wrap comfortably */
  .page-actions{gap:6px}
  .page-actions .btn{flex:0 1 auto}
  /* KPI values readable */
  .kpi .lbl{font-size:.68em}
  .kpi .val{font-size:1.5em}
  /* filter rows stack */
  .page-actions[style*="flex"],#tov-range{flex-wrap:wrap}
}
@media(max-width:374px){
  .kpis,.kpis[style*="repeat(4"]{grid-template-columns:1fr!important}
  .workspace{padding:10px 8px 90px}
}
/* Landscape phones: use the width */
@media(max-height:480px) and (orientation:landscape){
  .kpis{grid-template-columns:repeat(4,1fr)!important}
}

/* OWNER FIX (2026-10-30): mobile filter sheet must never open the sidebar */
@media (max-width: 1023px){
  body:has(.mf2-sheet.open) .sidebar { visibility: hidden !important; pointer-events: none !important; }
  .mf2-backdrop { position: fixed; inset: 0; z-index: 95; }
  .mf2-sheet { z-index: 96; }
}
