/* ---------- responsive layer (design revamp 2026-11-26): 1100 grids, 1024 drawer + touch, 640 phone ---------- */
body { overflow-x: clip; } /* nothing may scroll the page sideways; wide content scrolls inside its own box */
img, svg, video { max-width: 100%; }
.card, .kpi, .page-head > div:first-child { min-width: 0; }
#view { overflow-wrap: break-word; }
.tbl-wrap { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
/* the first column stays pinned while a wide table scrolls sideways */
.tbl-wrap td:first-child, .tbl-wrap th:first-child { position: sticky; left: 0; z-index: 1; background: var(--panel); box-shadow: 1px 0 0 var(--line); }
.tbl-wrap thead th:first-child { z-index: 3; background: var(--panel-2); } .tbl-wrap thead th { z-index: 2; }
tr.click:hover td:first-child { background: var(--panel-2); }
.tabs { scrollbar-width: none; -webkit-overflow-scrolling: touch; } .tabs::-webkit-scrollbar { display: none; } .tabs a { flex: none; }
#scrim { display: none; }
.colf-toggle { display: none; } /* filters sit under the headers; only phones fold them behind a button */
@media (max-width: 640px) { .colf-toggle { display: inline-flex; } }
/* a row's action buttons (Approve / Reject / Open) stay pinned on the right while a wide table scrolls, so they are never off-screen */
.tbl-wrap td:last-child:has(> .acts), .tbl-wrap:has(td > .acts) th:last-child { position: sticky; right: 0; z-index: 1; background: var(--panel); box-shadow: -1px 0 0 var(--line); }
.tbl-wrap:has(td > .acts) thead th:last-child { z-index: 3; background: var(--panel-2); }
.card > h2 { flex-wrap: wrap; row-gap: 8px; } /* heading buttons (period switches, actions) drop under the title instead of squeezing it */
@media (max-width: 1024px) {
  #app { grid-template-columns: minmax(0, 1fr); }
  #side { position: fixed; z-index: 30; left: 0; top: 0; width: min(300px, 86vw); transform: translateX(-100%); transition: transform .2s; visibility: hidden; }
  #side.open { transform: none; visibility: visible; box-shadow: 0 8px 32px rgba(0,0,0,.25); }
  #scrim.on { display: block; position: fixed; inset: 0; background: var(--scrim); z-index: 25; }
  #menuBtn { display: inline-flex; justify-content: center; min-width: var(--touch); min-height: var(--touch); font-size: 18px; }
  #top { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .search { flex: 1 1 200px; width: auto; }
  #view { padding: 16px; } .kpi .v { font-size: 22px; }
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #nav a { min-height: var(--touch); }
  #top > button, #top > .btn { min-height: var(--touch); min-width: var(--touch); justify-content: center; }
  .who { min-width: 0; } .who select { min-width: 0; max-width: 100%; }
}
@media (pointer: coarse) {
  button, .btn, input, select, textarea { min-height: var(--touch); } button.sm, .btn.sm { min-height: 40px; }
  .tabs a { padding: 12px 14px; } td, th { padding-top: 10px; padding-bottom: 10px; }
  input, select, textarea { font-size: 16px; } /* stops iOS zooming into a focused field */
  .chip, .gl-chips .chip button { min-height: 36px; }
}
@media (max-width: 760px) {
  .g2, .g3, .g4, .form { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } .kpi { padding: 10px 12px; } .kpi .v { font-size: 17px; overflow-wrap: anywhere; }
  .who span, .brand-chip { display: none !important; } .who { flex: 1 1 100%; order: 10; } .who select { flex: 1; width: 100%; }
  #top .search { order: 9; flex-basis: 100%; }
  #top { position: static; } /* on phones the bar scrolls away; the bottom bar keeps navigation in reach */
  .page-head .row { width: 100%; } .page-head .row > * { flex: 1 1 auto; justify-content: center; }
  .bar-row { grid-template-columns: 96px 1fr 72px; }
  .kv { grid-template-columns: minmax(0, 1fr); } .kv dd { margin-bottom: 6px; }
  .tbl-tools { flex-wrap: wrap; } .tbl-tools input { max-width: none; flex: 1 1 100%; }
  .actions > * { flex: 1 1 auto; justify-content: center; }
  /* dialogs take the whole phone screen */
  #modal { padding: 0; place-items: stretch; } .modal-card { width: 100%; max-height: none; height: 100%; border-radius: 0; border: 0; }
  .modal-card .actions { position: sticky; bottom: -16px; background: var(--panel); padding: 10px 0; margin-bottom: -16px; border-top: 1px solid var(--line); }
  #toast { left: 12px; right: 12px; bottom: 12px; } #toast .t { max-width: none; }
  h1 { font-size: 19px; }
  select { max-width: 100%; } .page-head .row > span { min-width: 0; max-width: 100%; } /* long fund names in pickers */
}
@media (max-width: 640px) {
  /* card mode: each grid row becomes a card, header label on the left, value on the right */
  .tbl-wrap.cards-ok { max-height: none !important; border: 0; overflow: visible; }
  .tbl-wrap.cards-ok table, .tbl-wrap.cards-ok tbody, .tbl-wrap.cards-ok tr, .tbl-wrap.cards-ok td { display: block; min-width: 0; width: auto; }
  .tbl-wrap.cards-ok thead tr:not(.colf) { display: none; } .tbl-wrap.cards-ok thead tr.colf { display: none; } .tbl-wrap.cards-ok.colf-open thead tr.colf { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; margin-bottom: 8px; }
  .tbl-wrap.cards-ok tbody tr { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 12px; margin-bottom: 8px; }
  .tbl-wrap.cards-ok td { position: static; box-shadow: none; display: flex; justify-content: space-between; gap: 12px; text-align: right; padding: 5px 0; border-bottom: 1px dashed var(--line); white-space: normal; overflow-wrap: anywhere; }
  .tbl-wrap.cards-ok td:last-child { border-bottom: 0; }
  .tbl-wrap.cards-ok td::before { content: attr(data-label); color: var(--ink-3); font-size: 12px; text-align: left; flex: none; max-width: 45%; font-family: var(--font); }
  .tbl-wrap.cards-ok td[data-label=""]::before { content: none; } .tbl-wrap.cards-ok td.empty { justify-content: center; }
  .tbl-wrap.cards-ok tfoot tr { display: block; } .tbl-wrap.cards-ok tfoot td { display: flex; }
}
/* phone bottom bar: 5 thumb-reach targets, above the iPhone home indicator; hidden while a dialog is open (its pinned actions own the bottom) */
#bbar { display: none; }
@media (max-width: 760px) {
  #bbar:not(:empty) { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--panel); border-top: 1px solid var(--line); padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
  #bbar > a, #bbar > button { flex: 1 1 0; min-width: 0; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; position: relative; padding: 4px 2px; border: 0; border-radius: 0; background: none; color: var(--ink-3); font-size: 11px; text-decoration: none; }
  #bbar .bb-ico { font-size: 18px; line-height: 1; } #bbar .bb-lbl { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #bbar [aria-current="page"] { color: var(--accent); font-weight: 600; box-shadow: inset 0 2px 0 currentColor; }
  #bbar .bb-badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: var(--accent-ink); font-size: 11px; line-height: 18px; text-align: center; }
  #bbar .bb-badge.hidden { display: none; }
  #app:has(#bbar:not(:empty)) #view { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  #app:has(#bbar:not(:empty)) ~ #toast { bottom: calc(68px + env(safe-area-inset-bottom)); }
  body:has(#modal:not(.hidden)) #bbar { display: none; }
}

/* System documents (IT → System): readable long-form text; wide tables scroll inside their box, never the page. */
.md-doc { line-height: 1.55; max-width: 72rem; }
.md-doc pre { overflow-x: auto; padding: .75rem; border-radius: 6px; background: var(--panel-2); }
.md-table { overflow-x: auto; margin: .5rem 0 1rem; }
.md-table table { border-collapse: collapse; min-width: 100%; }
.md-table th, .md-table td { border: 1px solid var(--line); padding: .35rem .5rem; text-align: left; vertical-align: top; }
.doc-list li { margin: .35rem 0; }
.facts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; }
.facts-grid h3 { margin: 0 0 .35rem; font-size: .95rem; }
.facts { border-collapse: collapse; width: 100%; }
.facts th { text-align: left; font-weight: 500; color: var(--ink-3); padding: .2rem .6rem .2rem 0; white-space: nowrap; vertical-align: top; }
.facts td { padding: .2rem 0; }
