/* ================= IBI Document Vault — design system (v3) ================= */
:root {
  --brand: #00c5ff;
  --brand-ink: #00232e;
  --danger: #ff5470;
  --ok: #24d18d;
  --amber: #ffb020;
  --radius: 14px;
  --radius-sm: 10px;
  --header-h: 58px;
  --maxw: 1180px;
  --font: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --shadow: 0 6px 24px rgba(0,0,0,.28);
  --shadow-sm: 0 2px 10px rgba(0,0,0,.18);
}
:root[data-theme="dark"] {
  --bg: #0a0e12;
  --surface: #12181f;
  --surface-2: #1a222b;
  --surface-3: #222c37;
  --text: #e8eef4;
  --muted: #92a1ad;
  --border: #242e38;
  --input: #0e141a;
  --cover-bg: #0e141a;
}
:root[data-theme="light"] {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f1f4f8;
  --surface-3: #e6ebf1;
  --text: #101a24;
  --muted: #5a6a77;
  --border: #dbe2ea;
  --input: #ffffff;
  --cover-bg: #f4f7fa;
  --shadow: 0 6px 22px rgba(20,30,45,.12);
  --shadow-sm: 0 2px 8px rgba(20,30,45,.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
body.locked, body.modal-open, body.viewer-open { overflow: hidden; }
img { max-width: 100%; }
h1, h2, h3 { margin: 0; font-weight: 700; }
button { font-family: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.skiplink {
  position: absolute; left: -999px; top: 0; z-index: 200;
  background: var(--brand); color: #000; padding: 10px 16px; border-radius: 0 0 8px 0; font-weight: 600;
}
.skiplink:focus { left: 0; }

/* ---------- header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  background: #000; color: var(--brand);
  height: calc(var(--header-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0 12px;
  border-bottom: 1px solid #1a1a1a;
}
.version-badge {
  font-size: 11px; font-weight: 700; letter-spacing: .5px;
  color: #000; background: var(--brand);
  padding: 3px 7px; border-radius: 20px; flex: none;
}
.brand-home { background: none; border: 0; padding: 0; cursor: pointer; display: flex; align-items: center; }
.brand-logo { height: 32px; width: auto; flex: none; }
.header-spacer { flex: 1; }
.header-right { display: flex; align-items: center; gap: 4px; flex: none; }
.icon-btn {
  background: transparent; border: 0; color: var(--brand);
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px; transition: background .15s;
}
.icon-btn:hover { background: rgba(0,197,255,.14); }
#btnInstall { width: auto; padding: 0 12px; gap: 6px; font-size: 13px; font-weight: 600; border: 1px solid var(--brand); }

/* ---------- clock bar ---------- */
.clock-bar {
  background: var(--surface); color: var(--muted);
  font-size: 13px; font-weight: 500; text-align: center;
  padding: 7px 12px; border-bottom: 1px solid var(--border);
  letter-spacing: .2px;
}

/* ---------- layout ---------- */
main { display: block; }
.container { max-width: var(--maxw); margin: 0 auto; padding: 8px 16px 130px; }
.toolbar {
  display: flex; gap: 10px; align-items: center;
  position: sticky; top: calc(var(--header-h) + env(safe-area-inset-top)); z-index: 20;
  background: var(--bg); padding: 12px 16px; max-width: var(--maxw); margin: 0 auto;
}
.search-wrap { flex: 1; position: relative; }
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
#searchInput {
  width: 100%; padding: 11px 12px 11px 38px; border-radius: 40px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 15px; font-family: var(--font);
}
#searchInput:focus { outline: none; border-color: var(--brand); }

/* ---------- KPI row ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 2px; text-align: left;
  color: var(--text); font: inherit; cursor: default; position: relative; overflow: hidden;
}
button.kpi { cursor: pointer; transition: border-color .15s, transform .12s; }
button.kpi:hover { border-color: var(--brand); transform: translateY(-2px); }
.kpi-ic { color: var(--brand); opacity: .5; position: absolute; right: 10px; top: 10px; }
.kpi-ic svg { width: 22px; height: 22px; }
.kpi-v { font-size: 26px; font-weight: 700; line-height: 1.1; }
.kpi-l { color: var(--muted); font-size: 12.5px; }
.kpi.amber .kpi-v { color: var(--amber); }
.kpi.amber .kpi-ic { color: var(--amber); opacity: .7; }

/* ---------- panels ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 16px;
}
.panel-amber { border-color: rgba(255,176,32,.45); }
.panel-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.panel-head h3 { font-size: 15px; flex: 1; }

/* ---------- section head ---------- */
.section-head {
  display: flex; align-items: center; gap: 10px;
  background: #000; color: var(--brand);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 12px;
}
.sh-title { flex: 1; min-width: 0; }
.section-head h2 { color: var(--brand); font-size: 17px; }
.sh-sub { color: #6ea9c0; font-size: 12px; display: block; }
.sh-count { color: var(--brand); font-size: 13px; opacity: .8; }
.back-btn {
  background: transparent; border: 0; color: var(--brand); font-size: 26px; line-height: 1;
  cursor: pointer; font-weight: 600; padding: 0 4px 4px;
}

/* ---------- list bar (sort / filter / view) ---------- */
.listbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.chip {
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  border-radius: 30px; padding: 6px 13px; font-size: 12.5px; font-weight: 500; cursor: pointer;
  transition: .15s;
}
.chip:hover { border-color: var(--brand); color: var(--text); }
.chip-active { background: var(--brand); border-color: var(--brand); color: #00232e; font-weight: 600; }
.listbar-right { display: flex; gap: 8px; align-items: center; }
.listbar-right select {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 13px; font-family: var(--font);
}
.viewtoggle { display: flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.vt {
  background: var(--surface); border: 0; color: var(--muted); width: 36px; height: 34px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.vt svg { width: 17px; height: 17px; }
.vt.on { background: var(--brand); color: #00232e; }

/* ---------- shelves + category tiles ---------- */
.shelf { margin-bottom: 20px; }
.shelf-head { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; padding: 0 2px; }
.shelf-ic { color: var(--brand); display: flex; }
.shelf-ic svg { width: 19px; height: 19px; }
.shelf-head h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .7px; }
.shelf-count {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  font-size: 11.5px; font-weight: 600; border-radius: 20px; padding: 1px 9px;
}
.shelf-head .linkbtn { margin-left: auto; }
.shelf-toggle { text-align: center; padding: 6px 0 10px; }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 10px; }
.cat-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 13px; text-align: left; cursor: pointer; color: var(--text);
  display: flex; flex-direction: column; gap: 6px;
  transition: transform .12s, border-color .15s, box-shadow .15s;
}
.cat-tile:hover { transform: translateY(-2px); border-color: var(--brand); box-shadow: var(--shadow-sm); }
.cat-tile.is-empty { opacity: .55; }
.cat-ic { color: var(--brand); }
.cat-ic svg { width: 26px; height: 26px; }
.cat-name { font-weight: 600; font-size: 14px; line-height: 1.3; }
.cat-count { color: var(--muted); font-size: 12px; }

/* ---------- document grid (cover-forward) ---------- */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.doc-card2 {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0; overflow: hidden; text-align: left; cursor: pointer; color: var(--text);
  display: flex; flex-direction: column; transition: transform .12s, border-color .15s, box-shadow .15s;
}
.doc-card2:hover { transform: translateY(-2px); border-color: var(--brand); box-shadow: var(--shadow); }
.dc-cover {
  display: block; background: var(--cover-bg); height: 150px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; border-bottom: 1px solid var(--border);
}
.dc-cover img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.dc-ph { color: var(--brand); opacity: .45; }
.dc-ph svg { width: 40px; height: 40px; }
.dc-body { padding: 11px 12px 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dc-title {
  font-weight: 600; font-size: 14px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.dc-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dc-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.dc-cat { color: var(--brand); font-size: 11px; font-weight: 600; opacity: .85; }

/* card + row share a kebab actions button */
.doc-card2 { position: relative; }
.dc-hit {
  background: none; border: 0; padding: 0; margin: 0; text-align: left; cursor: pointer;
  color: inherit; display: flex; flex-direction: column; width: 100%; height: 100%;
}
.dr-hit {
  background: none; border: 0; padding: 0; margin: 0; text-align: left; cursor: pointer;
  color: inherit; display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0;
}
.dc-menu {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  background: rgba(0,0,0,.55); border: 0; color: #fff; cursor: pointer;
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; opacity: .85;
}
.dc-menu:hover { opacity: 1; background: var(--brand); color: #00232e; }

/* ---------- document rows (compact list) ---------- */
.doc-list { display: flex; flex-direction: column; gap: 8px; }
.doc-row {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; color: var(--text); transition: border-color .15s, box-shadow .15s;
  position: relative;
}
.doc-row .dc-menu { position: static; background: transparent; color: var(--muted); flex: none; }
.doc-row:hover { border-color: var(--brand); box-shadow: var(--shadow-sm); }
.dr-cover {
  flex: none; width: 42px; height: 54px; border-radius: 6px; overflow: hidden;
  background: var(--cover-bg); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.dr-cover img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.dr-cover .dc-ph svg { width: 20px; height: 20px; }
.dr-main { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dr-title { font-weight: 600; font-size: 14.5px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.dr-sub, .dr-meta { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dr-arrow { color: var(--muted); font-size: 22px; flex: none; }

.doc-ic { color: var(--brand); flex: none; }
.doc-ic svg { width: 24px; height: 24px; }
.doc-main { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.doc-title { font-weight: 600; font-size: 14.5px; }
.doc-sub { color: var(--muted); font-size: 12.5px; }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; line-height: 1.6; }
.empty-hero {
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 40px 24px; margin-bottom: 16px;
}
.empty-hero .empty-ic { color: var(--brand); opacity: .5; display: block; margin-bottom: 10px; }
.empty-hero .empty-ic svg { width: 46px; height: 46px; }
.empty-hero b { display: block; color: var(--text); font-size: 17px; margin-bottom: 6px; }
.empty-hero p { max-width: 460px; margin: 0 auto 16px; font-size: 13.5px; }

/* ---------- bulk select ---------- */
.doc-card2.picked, .doc-row.picked { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand) inset; }
.doc-card2.picked .dc-cover::after, .doc-row.picked .dr-cover::after {
  content: "✓"; position: absolute; top: 6px; left: 6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--brand); color: #00232e; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.doc-card2 .dc-cover, .doc-row .dr-cover { position: relative; }
.bulkbar {
  position: sticky; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 25;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px; margin-top: 14px;
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow);
}
.bulkbar.has-picks { border-color: var(--brand); }
.bulkbar select {
  padding: 6px 9px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--input); color: var(--text); font-size: 12.5px; font-family: var(--font);
  max-width: 190px;
}

/* ---------- drag to re-arrange ---------- */
.arrangebar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--surface-3); border: 1px solid var(--brand); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 12px; font-size: 12.5px; color: var(--muted);
}
.arrangebar .ab-ic { color: var(--brand); display: flex; flex: none; }
.arrangebar #arrangeMsg { flex: 1; min-width: 180px; line-height: 1.5; }
.arrangebar .btn { margin-left: auto; }

.draghandle {
  position: absolute; top: 6px; left: 6px; z-index: 3;
  background: rgba(0,0,0,.55); border: 0; color: #fff;
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: grab; opacity: .9;
  touch-action: none;                 /* a drag must not scroll the page */
}
.draghandle:hover, .draghandle:focus-visible { opacity: 1; background: var(--brand); color: #00232e; }
.doc-row .draghandle { position: static; flex: none; background: transparent; color: var(--muted); }
.doc-row .draghandle:hover, .doc-row .draghandle:focus-visible { color: var(--brand); background: transparent; }

/* Cards stop inviting a tap once they are being arranged. */
.arranging .doc-card2, .arranging .doc-row { cursor: default; }
.arranging .doc-card2:hover { transform: none; }
.arranging .dc-hit, .arranging .dr-hit { cursor: default; }

.drag-src { opacity: .3; border-style: dashed !important; border-color: var(--brand) !important; }
.drag-src * { visibility: hidden; }
.drag-ghost {
  position: fixed; top: 0; left: 0; z-index: 200; margin: 0;
  pointer-events: none; opacity: .95;
  border-color: var(--brand) !important;
  box-shadow: 0 14px 34px rgba(0,0,0,.5); transform-origin: top left;
}
.drag-ghost .draghandle { cursor: grabbing; }
body.is-dragging { user-select: none; -webkit-user-select: none; cursor: grabbing; }

.tag-name {
  background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit;
  cursor: pointer; text-align: left;
}
.tag-name:hover { color: var(--brand); text-decoration: underline; }

/* ---------- split a bundle ---------- */
.splitgrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px; max-height: 46vh; overflow-y: auto; padding: 4px;
  border: 1px solid var(--border); border-radius: var(--radius); margin: 12px 0;
}
.sp {
  position: relative; background: var(--surface); border: 2px solid var(--border);
  border-radius: 8px; padding: 5px; cursor: pointer; color: var(--text);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.sp:hover:not(:disabled) { border-color: var(--brand); }
.sp:disabled { cursor: default; opacity: .95; }
.sp-img {
  width: 100%; height: 110px; background: var(--cover-bg); border-radius: 4px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.sp-img canvas { max-width: 100%; max-height: 100%; display: block; }
.sp-n { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.sp-flag { display: none; font-size: 10px; font-weight: 700; color: var(--brand); }
.sp.is-start { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset; }
.sp.is-start .sp-flag { display: block; }

.sp-part {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.sp-range { flex: none; min-width: 140px; font-size: 12.5px; font-weight: 600; color: var(--brand); }
.sp-title { flex: 1; min-width: 180px; }
.sp-part select { max-width: 220px; }

/* ---------- duplicates ---------- */
.dupgroups { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.dupgroup { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.dg-head {
  background: var(--surface-2); padding: 8px 12px; font-size: 12.5px; font-weight: 600;
  color: var(--brand); border-bottom: 1px solid var(--border);
}
.dupgroup-soft { border-style: dashed; }
.dg-warn {
  background: rgba(255,176,32,.12); color: var(--amber); font-size: 12px;
  padding: 7px 12px; border-bottom: 1px solid var(--border); line-height: 1.5;
}
.dupopts { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.dup-cover {
  flex: none; width: 40px; height: 52px; border-radius: 5px; overflow: hidden;
  background: var(--cover-bg); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.dup-cover img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.dup-cover .dc-ph svg { width: 18px; height: 18px; }
.dup {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-bottom: 1px solid var(--border); cursor: pointer;
}
.dup:last-child { border-bottom: 0; }
.dup input { width: 17px; height: 17px; flex: none; accent-color: var(--danger); }
.dup-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dup-title { font-size: 13.5px; font-weight: 600; }
.dup.is-keep { background: rgba(36,209,141,.07); }
.dup.is-keep .dup-title::after {
  content: "KEEP"; margin-left: 8px; font-size: 10px; font-weight: 700;
  background: rgba(36,209,141,.15); color: var(--ok); border-radius: 20px; padding: 2px 7px;
}

/* ---------- pills / badges ---------- */
.pill { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.pill-red { background: rgba(255,84,112,.16); color: var(--danger); }
.pill-amber { background: rgba(255,176,32,.16); color: var(--amber); }
.pill-ok { background: rgba(36,209,141,.15); color: var(--ok); }
.pill-soft { background: var(--surface-3); color: var(--muted); }
.pill-files { background: rgba(0,197,255,.13); color: var(--brand); }
.chip-ok { background: rgba(36,209,141,.15); color: var(--ok); border-color: transparent; }
.chip-info { background: rgba(0,197,255,.13); color: var(--brand); border-color: transparent; }
.chip-warn { background: rgba(255,176,32,.16); color: var(--amber); border-color: transparent; }

.taglist { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px 0; }
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px;
  padding: 4px 10px; font-size: 12.5px;
}
.tag button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 12px; padding: 0 0 0 2px; }
.tag button:hover { color: var(--danger); }

.note { border-radius: var(--radius-sm); padding: 10px 12px; font-size: 12.5px; line-height: 1.5; margin-bottom: 12px; }
.note-amber { background: rgba(255,176,32,.1); border: 1px solid rgba(255,176,32,.4); color: var(--amber); }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font); font-size: 14px; font-weight: 600; cursor: pointer;
  border-radius: 10px; padding: 10px 16px; border: 1px solid transparent; transition: filter .15s, background .15s;
}
.btn-primary { background: var(--brand); color: #00232e; }
.btn-primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-block { display: block; width: 100%; margin-top: 8px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.linkbtn { background: none; border: 0; color: var(--brand); cursor: pointer; font-size: 13px; padding: 0; text-decoration: underline; }

/* ---------- FAB ---------- */
.fab {
  position: fixed; right: calc(18px + env(safe-area-inset-right));
  bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 30;
  background: var(--brand); color: #00232e; border: 0; cursor: pointer;
  width: 56px; height: 56px; border-radius: 50%; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
}
body:not(.unlocked) .fab { display: none; }
.blurred { filter: blur(3px); pointer-events: none; user-select: none; }

/* ---------- fields ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--input); color: var(--text);
  font-size: 15px; font-family: var(--font);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); }
.filehint { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkline { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; margin: 4px 0 10px; cursor: pointer; line-height: 1.45; }
.warn { background: rgba(255,176,32,.12); border: 1px solid rgba(255,176,32,.4); color: var(--amber); padding: 10px 12px; border-radius: var(--radius-sm); font-size: 12.5px; line-height: 1.5; }
.scanning { color: var(--amber); }
.detected { color: var(--ok); }
.needs { color: var(--amber); }
.loading { padding: 40px; color: var(--muted); text-align: center; }

/* ---------- toggle switch ---------- */
.switch { position: relative; display: inline-block; width: 48px; height: 27px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 30px; cursor: pointer; transition: .2s; }
.slider::before { content: ""; position: absolute; height: 19px; width: 19px; left: 3px; top: 3px; background: var(--muted); border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: rgba(0,197,255,.25); border-color: var(--brand); }
.switch input:checked + .slider::before { transform: translateX(21px); background: var(--brand); }

/* ---------- gate ---------- */
.gate {
  position: fixed; inset: 0; z-index: 100; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  padding-top: calc(20px + env(safe-area-inset-top));
}
.gate-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 20px; padding: 28px 22px; text-align: center; box-shadow: var(--shadow);
}
.gate-logo { height: 46px; margin-bottom: 16px; }
.gate-title { color: var(--brand); font-size: 22px; margin-bottom: 6px; }
.gate-sub { color: var(--muted); font-size: 14px; margin: 0 0 18px; line-height: 1.5; }
.gate-card .field input { text-align: center; letter-spacing: 2px; }
.gate-card .field label { text-align: left; }
/* The username is a name, not a secret — read it as text, not as a passcode. */
.gate-card .field input[name="username"] { text-align: left; letter-spacing: 0; }
.gate-card form { margin: 0; }
.shake { animation: shake .4s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%,60%{transform:translateX(-8px)} 40%,80%{transform:translateX(8px)} }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.6);
  display: flex; align-items: flex-end; justify-content: center; padding: 0;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); width: 100%; max-width: 580px;
  border-radius: 18px 18px 0 0; max-height: 92vh; display: flex; flex-direction: column;
  animation: slideUp .22s ease; box-shadow: var(--shadow);
}
.modal-wide { max-width: 900px; }
.modal-tall { height: 92vh; }
@keyframes slideUp { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head {
  display: flex; align-items: center; background: #000; color: var(--brand);
  padding: 13px 16px; border-radius: 18px 18px 0 0; flex: none;
}
.modal-head h2 { color: var(--brand); font-size: 16.5px; flex: 1; }
.modal-x { background: transparent; border: 0; color: var(--brand); cursor: pointer; display: flex; padding: 4px; }
.modal-body { padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; }
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; flex: none;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border);
}

/* ---------- chooser ---------- */
.chooser {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px; margin-bottom: 10px; cursor: pointer; color: var(--text); transition: border-color .15s;
}
.chooser:hover { border-color: var(--brand); }
.chooser-ic { color: var(--brand); flex: none; }
.chooser-ic svg { width: 28px; height: 28px; }
.chooser-txt { display: flex; flex-direction: column; gap: 3px; }
.chooser-txt small { color: var(--muted); font-size: 12.5px; line-height: 1.45; }

/* ---------- document actions sheet ---------- */
.act-sub { margin-bottom: 12px; }
.chooser.act { padding: 12px 14px; margin-bottom: 8px; }
.chooser.act.danger:hover { border-color: var(--danger); }
.chooser.act.danger .chooser-ic { color: var(--danger); }
.act-h { font-size: 13px; color: var(--brand); text-transform: uppercase; letter-spacing: .7px; margin: 18px 0 8px; }
.verlist { display: flex; flex-direction: column; gap: 8px; }
.ver {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 11px;
}
.ver-main { flex: 1; min-width: 150px; display: flex; flex-direction: column; gap: 2px; }
.ver-main b { font-size: 13px; font-weight: 600; word-break: break-word; }
.ver-main small { font-size: 11.5px; }

/* ---------- tidy names ---------- */
.renlist { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.ren {
  display: flex; align-items: flex-start; gap: 10px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 11px;
}
.ren:hover { border-color: var(--brand); }
.ren-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.ren-from { color: var(--muted); font-size: 12px; text-decoration: line-through; word-break: break-word; }
.ren-to { font-size: 13.5px; font-weight: 600; word-break: break-word; }
.ren-cat { font-size: 11.5px; }

/* ---------- settings ---------- */
.settings section { border-top: 1px solid var(--border); padding: 16px 0; }
.settings section:first-child { border-top: 0; padding-top: 0; }
.settings h3 { color: var(--brand); font-size: 13px; margin-bottom: 10px; text-transform: uppercase; letter-spacing: .7px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0; }
.set-row select { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--input); color: var(--text); font-family: var(--font); }
.ios-help { margin: 0; padding-left: 20px; line-height: 1.9; }

/* ---------- drive ---------- */
.drive-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.drive-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
.drive-item .doc-main { min-width: 0; }
.drive-status {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 11px; margin: 10px 0; font-size: 12.5px; line-height: 1.5;
}

/* ---------- install banner / toast ---------- */
.install-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border-top: 1px solid var(--brand);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 24px rgba(0,0,0,.25);
}
.ib-ic img { width: 40px; height: 40px; border-radius: 9px; }
.ib-txt { flex: 1; display: flex; flex-direction: column; }
.ib-txt b { font-size: 14px; }
.ib-txt small { color: var(--muted); font-size: 12px; }
.ib-actions { display: flex; gap: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px); z-index: 300;
  background: #000; color: #fff; padding: 12px 18px; border-radius: 30px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: .25s;
  border: 1px solid var(--border); max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-success { border-color: var(--ok); }
.toast-error { border-color: var(--danger); }
/* Snackbar with an action button (v4.5) */
.toast-action { pointer-events: auto; display: flex; align-items: center; gap: 14px; text-align: left; }
.toast-btn {
  flex: none; background: none; border: 0; color: var(--accent, #22c3ff); font: inherit;
  font-weight: 700; letter-spacing: .02em; padding: 4px 2px; cursor: pointer; min-height: 32px;
}

/* ---------- drag & drop veil ---------- */
.dropveil {
  position: fixed; inset: 0; z-index: 150; background: rgba(0,0,0,.72);
  display: flex; align-items: center; justify-content: center; pointer-events: none;
}
.dropveil-in {
  border: 2px dashed var(--brand); border-radius: 20px; padding: 40px 54px;
  color: var(--brand); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.dropveil-in b { font-size: 18px; }
.dropveil-in small { color: #9fd8ee; font-size: 13px; }

/* =====================================================================
   Bulk intake
   ===================================================================== */
.ik-progress { margin-bottom: 14px; }
.ik-bar { height: 6px; background: var(--surface-2); border-radius: 20px; overflow: hidden; margin-bottom: 8px; }
.ik-bar span { display: block; height: 100%; background: var(--brand); transition: width .25s; }
.ik-scanlist { display: flex; flex-direction: column; gap: 1px; border-radius: var(--radius-sm); overflow: hidden; }
.ik-scanrow { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--surface-2); font-size: 13px; }
.ik-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border); flex: none; }
.ik-scanrow.busy .ik-dot { background: var(--amber); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.ik-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ik-state { font-size: 12px; color: var(--muted); flex: none; }
.ik-state.is-ok { color: var(--ok); }
.ik-state.is-warn { color: var(--amber); }
.ik-state.is-dup { color: var(--muted); }
.ik-state.is-busy { color: var(--amber); }

.ik-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.ik-stat {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; display: flex; flex-direction: column;
}
.ik-stat b { font-size: 20px; line-height: 1.2; }
.ik-stat span { color: var(--muted); font-size: 11.5px; }
.ik-stat.warn { border-color: rgba(255,176,32,.5); }
.ik-stat.warn b { color: var(--amber); }
.ik-stat.muted-stat b { color: var(--muted); }

.ik-groups { display: flex; flex-direction: column; gap: 12px; }
.ik-group { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.ik-group.is-needs { border-color: rgba(255,176,32,.5); }
.ik-group.is-dups { opacity: .8; }
.ik-ghead {
  display: flex; align-items: center; gap: 10px; background: var(--surface-2);
  padding: 8px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.ik-gtoggle {
  display: flex; align-items: center; gap: 9px; background: none; border: 0;
  color: var(--text); cursor: pointer; flex: 1; min-width: 180px; text-align: left; padding: 4px 0;
}
.ik-gchev { color: var(--muted); transition: transform .18s; display: inline-block; font-size: 17px; }
.ik-gchev.open { transform: rotate(90deg); }
.ik-gic { color: var(--brand); display: flex; }
.ik-gic svg { width: 19px; height: 19px; }
.ik-gname { font-weight: 600; font-size: 14px; flex: 1; }
.ik-gcount { background: var(--brand); color: #00232e; font-size: 11.5px; font-weight: 700; border-radius: 20px; padding: 1px 9px; }
.ik-group.is-needs .ik-gcount { background: var(--amber); }
.ik-gactions { display: flex; gap: 8px; align-items: center; }
.ik-gmove {
  padding: 6px 9px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--input); color: var(--text); font-size: 12.5px; font-family: var(--font); max-width: 170px;
}
.ik-gitems { display: flex; flex-direction: column; }

.ik-item { display: flex; gap: 11px; padding: 12px; border-top: 1px solid var(--border); }
.ik-item:first-child { border-top: 0; }
.ik-item.needs-input { background: rgba(255,176,32,.05); }
.ik-check { flex: none; padding-top: 2px; }
.ik-cover {
  flex: none; width: 54px; height: 70px; border-radius: 6px; overflow: hidden;
  background: var(--cover-bg); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.ik-cover img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.ik-cover-ph { color: var(--muted); font-size: 10px; font-weight: 600; }
.ik-fields { flex: 1; min-width: 0; }
.ik-filerow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.ik-filename { font-size: 12.5px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ik-x { background: none; border: 0; color: var(--muted); cursor: pointer; margin-left: auto; font-size: 13px; }
.ik-x:hover { color: var(--danger); }
.ik-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ik-f { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ik-f-wide { grid-column: span 2; }
.ik-f span { font-size: 11px; color: var(--muted); font-weight: 500; }
.ik-f input, .ik-f select {
  padding: 8px 9px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--input); color: var(--text); font-size: 13px; font-family: var(--font); width: 100%;
}
.ik-f input:focus, .ik-f select:focus { outline: none; border-color: var(--brand); }
.ik-dup { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.ik-dup .ik-filename { flex: 1; }

.ik-selbar {
  position: sticky; bottom: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface-3); border: 1px solid var(--brand); border-radius: var(--radius);
  padding: 9px 12px; margin-top: 12px; font-size: 13px; font-weight: 600;
}
.ik-selbar select {
  padding: 6px 9px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--input); color: var(--text); font-size: 12.5px; font-family: var(--font);
}

/* =====================================================================
   Document viewer
   ===================================================================== */
.vw {
  position: fixed; inset: 0; z-index: 120; background: var(--bg);
  display: flex; flex-direction: column;
}
.vw-top {
  display: flex; align-items: center; gap: 8px; background: #000; color: var(--brand);
  padding: calc(8px + env(safe-area-inset-top)) 10px 8px; flex: none; border-bottom: 1px solid #1c1c1c;
}
.vw-title { flex: 1; font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vw-top-actions { display: flex; gap: 2px; flex: none; }
.vw-btn {
  background: transparent; border: 0; color: var(--brand); cursor: pointer;
  min-width: 36px; height: 36px; border-radius: 9px; font-size: 19px;
  display: inline-flex; align-items: center; justify-content: center; transition: background .15s;
}
.vw-btn:hover:not(:disabled) { background: rgba(0,197,255,.15); }
.vw-btn:disabled { opacity: .3; cursor: not-allowed; }
.vw-btn-wide { min-width: 66px; font-size: 12.5px; font-weight: 600; padding: 0 8px; }

/* strip of files when one document holds several */
.vw-files {
  flex: none; display: flex; align-items: center; gap: 6px; background: #000;
  border-bottom: 1px solid #1c1c1c; padding: 7px 10px; overflow-x: auto;
  scrollbar-width: thin;
}
.vw-files .vf-label {
  flex: none; color: var(--muted); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px; padding-right: 4px;
}
.vf {
  flex: none; max-width: 260px; background: #141414; border: 1px solid #262626;
  color: var(--muted); border-radius: 30px; padding: 5px 13px; font-size: 12.5px;
  font-family: var(--font); cursor: pointer; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.vf:hover { border-color: var(--brand); color: var(--text); }
.vf.on { background: var(--brand); border-color: var(--brand); color: #00232e; font-weight: 600; }

.vw-body { flex: 1; display: flex; min-height: 0; }
.vw-rail {
  flex: none; width: 116px; overflow-y: auto; background: var(--surface);
  border-right: 1px solid var(--border); padding: 8px; display: flex; flex-direction: column; gap: 8px;
}
.vw-thumb {
  background: var(--cover-bg); border: 2px solid transparent; border-radius: 7px;
  cursor: pointer; padding: 4px; display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.vw-thumb:hover { border-color: var(--border); }
.vw-thumb.active { border-color: var(--brand); }
.vw-thumb-img { display: block; width: 100%; min-height: 90px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.vw-thumb-img canvas { width: 100%; height: auto; display: block; }
.vw-thumb-n { color: var(--muted); font-size: 10.5px; }

.vw-main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.vw-stage {
  flex: 1; overflow: auto; background: var(--surface-2); padding: 16px;
  display: flex; align-items: flex-start; justify-content: center;
  /* A swipe that runs off the end of a page must not reach the browser: on
     Android that is pull-to-refresh, and a refresh re-locks the whole vault. */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.vw-stage.busy { opacity: .55; }
.vw-page { background: #fff; box-shadow: var(--shadow); border-radius: 3px; max-width: 100%; }

/* Every page of a PDF, stacked in one column, so the wheel runs through the
   whole document. `margin:auto` rather than justify-content — an auto margin
   collapses to 0 once the column outgrows the stage, where centring would
   instead push the left edge out of reach behind the scroller. */
.vw-doc { display: flex; flex-direction: column; align-items: center; gap: 14px; margin: auto; }
.vw-pg {
  position: relative; flex: none; background: #fff;
  box-shadow: var(--shadow); border-radius: 3px; overflow: hidden;
}
/* The canvas fills its box, so a page already drawn stays on screen and simply
   stretches while the sharper redraw is prepared — zooming never flashes white. */
.vw-pg canvas { display: block; width: 100%; height: 100%; }
.vw-pg-err {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 12.5px; text-align: center; padding: 12px;
}

/* The page pill shown while turning pages by touch. The bottom pager is too
   small to read mid-swipe, and is often under the thumb doing the swiping. */
.vw-flash {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(.9);
  z-index: 5; pointer-events: none; opacity: 0;
  background: rgba(0,0,0,.78); color: #fff; border-radius: 30px;
  padding: 9px 20px; font-size: 15px; font-weight: 700; letter-spacing: .3px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
  transition: opacity .18s ease, transform .18s ease;
}
.vw-flash.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
@media (prefers-reduced-motion: reduce) {
  .vw-flash { transition: none; }
}
.vw-img { user-select: none; -webkit-user-drag: none; }
.vw-img.zoomed { cursor: grab; }
.vw-img.grabbing { cursor: grabbing; }
.vw-msg { color: var(--muted); text-align: center; padding: 60px 20px; line-height: 1.6; margin: auto; }

.vw-find {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 5;
  width: min(520px, calc(100% - 24px)); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.vw-find-bar { display: flex; gap: 8px; padding: 9px; align-items: center; }
.vw-find-bar input {
  flex: 1; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--input); color: var(--text); font-size: 14px; font-family: var(--font);
}
.vw-find-bar input:focus { outline: none; border-color: var(--brand); }
.vw-find-results { max-height: 42vh; overflow-y: auto; padding: 0 9px 9px; display: flex; flex-direction: column; gap: 5px; }
.vw-hit {
  text-align: left; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; cursor: pointer; color: var(--text); display: flex; flex-direction: column; gap: 2px;
}
.vw-hit:hover { border-color: var(--brand); }
.vw-hit b { color: var(--brand); font-size: 11.5px; }
.vw-hit span { font-size: 12px; color: var(--muted); line-height: 1.45; }

.vw-info {
  flex: none; width: 320px; background: var(--surface); border-left: 1px solid var(--border);
  padding: 16px; overflow-y: auto;
}
.vw-info h3 { color: var(--brand); font-size: 13px; text-transform: uppercase; letter-spacing: .7px; margin-bottom: 12px; }
.vw-meta { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.vw-meta .mk { color: var(--muted); flex: none; width: 42%; }
.vw-meta .mv { flex: 1; word-break: break-word; }

.vw-bottom {
  flex: none; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}
.vw-pager, .vw-zoom { display: flex; align-items: center; gap: 2px; }
.vw-zoom { flex: 1; justify-content: center; }
.vw-pageno { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 4px; }
.vw-pageno input {
  width: 52px; padding: 5px 6px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--input); color: var(--text); font-size: 13px; text-align: center; font-family: var(--font);
}
.vw-doc-actions { display: flex; gap: 8px; }

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 900px) {
  .vw-info { position: absolute; right: 0; top: 0; bottom: 0; width: min(340px, 88%); z-index: 6; box-shadow: var(--shadow); }
  .vw-rail { width: 92px; }
}
@media (max-width: 640px) {
  .container { padding: 8px 10px 130px; }
  .toolbar { padding: 10px; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .kpi-v { font-size: 22px; }
  .cat-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .doc-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .dc-cover { height: 118px; }
  .brand-logo { height: 28px; }
  .modal { max-width: 100%; }
  .modal-tall { height: 94vh; }
  .ik-summary { grid-template-columns: repeat(2, 1fr); }
  .ik-grid { grid-template-columns: 1fr 1fr; }
  .ik-f-wide { grid-column: span 2; }
  .row2 { grid-template-columns: 1fr; }
  .vw-rail { display: none; }
  .vw-bottom { justify-content: center; }
  .vw-doc-actions { width: 100%; justify-content: center; }
  .listbar-right { width: 100%; }
  .listbar-right select { flex: 1; }
}
@media (min-width: 641px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 18px; }
  .modal-head { border-radius: 18px 18px 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── IBI Apps edition: the account chip joins the header. On phones the right-hand group drops to its own row
   instead of pushing the page wider than the screen (360px audit, 30 Sep 2026). ── */
@media (max-width: 560px) {
  .app-header { flex-wrap: wrap; row-gap: 6px; height: auto; min-height: calc(var(--header-h) + env(safe-area-inset-top)); padding-bottom: 6px; }
  .header-spacer { display: none; }
  .header-right { margin-left: auto; width: 100%; justify-content: flex-end; }
  .header-right .ibi-chip { max-width: min(52vw, 210px); }
}
