:root { --bg:#f6f7fb; --card:#ffffff; --ink:#172033; --muted:#657085; --line:#d9deea; --accent:#315efb; --danger:#b3261e; --good:#137333; --warn:#8a5a00; }
* { box-sizing: border-box; }
body { margin:0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; color:var(--ink); background:var(--bg); }
a { color: var(--accent); }
.container { max-width: 1240px; margin: 0 auto; padding: 24px; }
.login-shell { min-height:100vh; display:grid; place-items:center; padding: 24px; }
.login-card { width:min(440px, 100%); background:var(--card); border:1px solid var(--line); border-radius:22px; padding:32px; box-shadow:0 18px 60px rgba(16,24,40,.10); }
.logo { display:flex; align-items:center; gap:12px; margin-bottom:12px; }
.logo-mark { width:42px; height:42px; border-radius:14px; display:grid; place-items:center; background:var(--accent); color:white; font-weight:800; }
h1,h2,h3 { margin:0 0 12px; } p { color:var(--muted); line-height:1.45; }
input, select, textarea, button, .buttonlink { font:inherit; }
input, select, textarea { width:100%; padding:10px 12px; border:1px solid var(--line); border-radius:12px; background:white; color:var(--ink); }
textarea { resize: vertical; }
label { display:block; font-size:13px; font-weight:650; color:#2a3448; margin-bottom:6px; }
.form-grid { display:grid; grid-template-columns: repeat(3, 1fr); gap:14px; }
.form-grid .wide { grid-column: span 3; }
.form-grid .two { grid-column: span 2; }
.field { margin-bottom:14px; }
button, .buttonlink { border:0; border-radius:12px; padding:10px 14px; background:var(--accent); color:white; cursor:pointer; font-weight:700; text-decoration:none; display:inline-flex; align-items:center; justify-content:center; min-height:38px; line-height: normal; }
button.secondary, .buttonlink.secondary { background:#eef1f8; color:#26324a; }
button.danger { background:var(--danger); }
button.good { background:var(--good); }
button:disabled { opacity:.5; cursor:not-allowed; }
.topbar { background:#0f172a; color:white; }
.topbar .inner { max-width:1240px; margin:0 auto; padding:14px 24px; display:flex; align-items:center; justify-content:space-between; gap:14px; }
.tabs { display:flex; gap:8px; flex-wrap:wrap; }
.tabs button { background:rgba(255,255,255,.11); color:white; padding:8px 11px; }
.tabs button.active { background:white; color:#0f172a; }
.userbox { font-size:13px; color:#dbe3ff; text-align:right; }
.card { background:var(--card); border:1px solid var(--line); border-radius:18px; padding:18px; margin:18px 0; box-shadow:0 6px 24px rgba(16,24,40,.04); }
.card-header { display:flex; justify-content:space-between; gap:12px; align-items:flex-start; margin-bottom:12px; }
.kpis { display:grid; grid-template-columns: repeat(4, 1fr); gap:14px; margin:18px 0; }
.kpi { background:var(--card); border:1px solid var(--line); border-radius:18px; padding:18px; }
.kpi strong { display:block; font-size:28px; }
.table-wrap { overflow:auto; border:1px solid var(--line); border-radius:14px; }
table { width:100%; border-collapse:collapse; background:white; }
th, td { text-align:left; border-bottom:1px solid var(--line); padding:10px 12px; font-size:14px; vertical-align:top; }
th { background:#f0f3fa; color:#33405a; font-size:12px; text-transform:uppercase; letter-spacing:.04em; }
tr:last-child td { border-bottom:0; }
.badge { display:inline-flex; border-radius:999px; padding:4px 9px; font-size:12px; font-weight:750; background:#eef1f8; color:#2d3852; white-space:nowrap; }
.badge.open { background:#e8f0fe; color:#174ea6; }
.badge.local, .badge.sqlite, .badge.complete { background:#e6f4ea; color:#137333; }
.badge.submitted, .badge.optional, .badge.skipped, .badge.not_run { background:#fff4ce; color:#8a5a00; }
.badge.approved { background:#e6f4ea; color:#137333; }
.badge.rejected, .badge.failed { background:#fce8e6; color:#b3261e; }
.badge.sent-for-payment { background:#ede7f6; color:#5e35b1; }
.notice { padding:12px 14px; border:1px solid #bfdbfe; background:#eff6ff; color:#1e3a8a; border-radius:14px; margin:14px 0; }
.error { padding:12px 14px; border:1px solid #fecaca; background:#fef2f2; color:#991b1b; border-radius:14px; margin:14px 0; }
.actions { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.filters { display:grid; grid-template-columns: 2fr 1fr 1fr auto auto; gap:10px; margin:12px 0 16px; align-items:end; }
.small { font-size:12px; color:var(--muted); }
pre { white-space:pre-wrap; background:#0b1020; color:#e8edff; padding:14px; border-radius:14px; overflow:auto; }
#flash:empty { display:none; }
@media (max-width: 900px) { .form-grid, .kpis, .filters { grid-template-columns:1fr; } .form-grid .wide, .form-grid .two { grid-column:auto; } .topbar .inner { display:block; } .userbox { text-align:left; margin-top:12px; } .card-header { display:block; } }
.mapping-grid { display:grid; grid-template-columns: minmax(420px, 1fr) minmax(420px, 1fr); gap:18px; align-items:start; }
.receipt-frame { width:100%; height:420px; border:1px solid var(--line); border-radius:14px; background:#fff; }
.map-lines { max-height:520px; overflow:auto; border:1px solid var(--line); border-radius:14px; background:#fbfcff; }
.map-line { padding:10px 12px; border-bottom:1px solid var(--line); cursor:pointer; }
.map-line:hover { background:#eef4ff; }
.map-line:last-child { border-bottom:0; }
.map-chips { display:flex; gap:6px; flex-wrap:wrap; margin-top:6px; }
.chip, button.chip { min-height:auto; padding:4px 8px; border-radius:999px; background:#eef1f8; color:#26324a; font-size:12px; }
.form-grid.single { grid-template-columns:1fr; }
.map-field { position:relative; border:1px solid transparent; border-radius:14px; padding:8px; cursor:pointer; }
.map-field:hover { background:#f8fbff; border-color:#dbe7ff; }
.map-field.selected-map-field { background:#eff6ff; border-color:#315efb; box-shadow:0 0 0 2px rgba(49,94,251,.12); }
.map-field .tiny { position:absolute; right:8px; top:8px; min-height:auto; padding:4px 8px; border-radius:9px; font-size:12px; background:#eef1f8; color:#26324a; }
@media (max-width: 1000px) { .mapping-grid { grid-template-columns:1fr; } .receipt-frame { height:300px; } }

/* V1.1.5 visual invoice mapping */
.pdf-pages { display:flex; flex-direction:column; gap:18px; margin:12px 0; }
.pdf-page-block { border:1px solid #dbe3ef; border-radius:14px; padding:10px; background:#f8fafc; }
.pdf-page-wrap { position:relative; width:100%; overflow:auto; border-radius:10px; background:white; box-shadow: inset 0 0 0 1px #e5eaf3; }
.pdf-page-wrap img { display:block; width:100%; height:auto; }
.pdf-overlay { position:absolute; inset:0; }
.pdf-line-hit, .pdf-word-hit { position:absolute; border:0; padding:0; margin:0; background:rgba(49,94,251,0.00); cursor:crosshair; border-radius:3px; }
.pdf-line-hit:hover { background:rgba(49,94,251,0.10); outline:1px dashed rgba(49,94,251,0.45); }
.pdf-word-hit:hover { background:rgba(255,193,7,0.34); outline:1px solid rgba(255,193,7,0.9); }
.pdf-line-hit:active, .pdf-word-hit:active { background:rgba(34,197,94,0.25); }
.visual-map-note { margin:8px 0; }
.mapping-left { max-height:none; }
@media (max-width: 1000px) { .pdf-page-wrap { max-height:70vh; } }

/* V1.1.6 drag-to-select visual invoice mapping */
.drag-overlay { cursor: crosshair; touch-action: none; user-select: none; }
.pdf-selection-box { position:absolute; border:2px solid rgba(49,94,251,.95); background:rgba(49,94,251,.16); border-radius:4px; z-index:5; pointer-events:none; }
.pdf-word-zone { position:absolute; background:rgba(49,94,251,0.00); border-radius:2px; pointer-events:none; }
.drag-overlay:hover .pdf-word-zone { background:rgba(49,94,251,.035); }
.pdf-page-wrap img { user-select:none; -webkit-user-drag:none; }
.pdf-line-hit, .pdf-word-hit { display:none !important; }


/* V1.1.21 long-page browsing */
.large-page { display:grid; grid-template-columns: 230px minmax(0,1fr); gap:18px; align-items:start; }
.large-page-main { min-width:0; }
.sticky-page-header { position: sticky; top: 0; z-index: 30; background:rgba(246,247,251,.94); backdrop-filter: blur(10px); border:1px solid var(--line); border-radius:18px; padding:14px 16px; display:flex; align-items:flex-start; justify-content:space-between; gap:14px; margin-bottom:14px; box-shadow:0 8px 24px rgba(16,24,40,.06); }
.sticky-page-header h1 { margin:0 0 4px; }
.sticky-page-header p { margin:0; }
.section-nav { position: sticky; top: 14px; background:var(--card); border:1px solid var(--line); border-radius:18px; padding:12px; box-shadow:0 6px 24px rgba(16,24,40,.04); max-height:calc(100vh - 28px); overflow:auto; }
.section-nav-title { font-size:12px; font-weight:800; color:var(--muted); text-transform:uppercase; letter-spacing:.06em; margin:4px 6px 8px; }
.section-nav button { width:100%; background:transparent; color:#26324a; justify-content:flex-start; text-align:left; padding:8px 10px; border-radius:10px; min-height:34px; font-weight:650; }
.section-nav button:hover { background:#eef1f8; }
.section-card { background:var(--card); border:1px solid var(--line); border-radius:18px; margin:14px 0; box-shadow:0 6px 24px rgba(16,24,40,.04); overflow:hidden; scroll-margin-top:92px; }
.section-card-header { display:flex; align-items:center; gap:10px; padding:14px 16px; border-bottom:1px solid var(--line); background:#fbfcff; }
.section-card-header h2 { margin:0; font-size:18px; }
.section-arrow { width:34px; min-width:34px; height:34px; min-height:34px; padding:0; background:#eef1f8; color:#26324a; border-radius:10px; font-size:18px; }
.section-title-button { padding:0; background:transparent; color:var(--ink); justify-content:flex-start; min-height:0; flex:1; text-align:left; }
.section-title-button:hover h2 { color:var(--accent); }
.section-actions { display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end; }
.section-body { padding:16px; }
.section-card.collapsed .section-body { display:none; }
.section-card.collapsed .section-card-header { border-bottom:0; }
.page-actions { position:relative; }
.icon-button { width:38px; min-width:38px; height:38px; min-height:38px; padding:0; background:#eef1f8; color:#26324a; border-radius:12px; font-size:24px; line-height:1; }
.page-actions-menu { display:none; position:absolute; right:0; top:44px; min-width:180px; background:white; border:1px solid var(--line); border-radius:14px; box-shadow:0 18px 50px rgba(16,24,40,.16); padding:8px; z-index:50; }
.page-actions-menu.open { display:block; }
.page-actions-menu button { width:100%; background:transparent; color:#26324a; justify-content:flex-start; padding:9px 10px; min-height:34px; border-radius:10px; }
.page-actions-menu button:hover { background:#eef1f8; }
.section-card > .section-body > .card { margin:0; box-shadow:none; border:0; padding:0; background:transparent; }
.section-card > .section-body > .card > .card-header:first-child h2 { display:none; }
.section-card > .section-body > .card > h2:first-child { display:none; }

@media (max-width: 980px) {
  .large-page { grid-template-columns: 1fr; }
  .section-nav { position:relative; top:auto; max-height:none; display:flex; overflow:auto; gap:6px; }
  .section-nav-title { display:none; }
  .section-nav button { width:auto; white-space:nowrap; }
  .sticky-page-header { top:0; flex-wrap:wrap; }
}


/* V1.1.21 dashboard analytics */
.analytics-grid { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap:18px; align-items:start; }
.analytics-list { display:flex; flex-direction:column; gap:12px; }
.analytics-row { border:1px solid var(--line); border-radius:14px; padding:10px 12px; background:#fbfcff; }
.analytics-row-top { display:flex; justify-content:space-between; gap:12px; align-items:flex-start; margin-bottom:8px; }
.analytics-row-top strong { overflow:hidden; text-overflow:ellipsis; }
.analytics-bar { height:9px; background:#e8ecf6; border-radius:999px; overflow:hidden; }
.analytics-bar span { display:block; height:100%; background:var(--accent); border-radius:999px; }
.compact-kpis .kpi strong { font-size:24px; }
@media (max-width: 900px) {
  .analytics-grid { grid-template-columns:1fr; }
}


/* V1.1.22 admin import/export tools */
.import-export-tools { align-items:center; }
.file-import-label { position:relative; overflow:hidden; }
.file-import-label input[type=file] { position:absolute; inset:0; opacity:0; cursor:pointer; width:100%; height:100%; }
/* Ensure anchor/label action controls use the exact same typography and box model as real buttons. */
a.buttonlink, label.buttonlink { font-family: inherit; font-size: inherit; line-height: normal; font-weight:700; margin:0; }
.file-import-label { display:inline-flex; }
.notice.compact { margin:0 0 14px; padding:10px 12px; }


/* V1.1.23 role UI / permission matrix polish */
.role-card-grid { display:grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap:12px; margin-bottom:14px; }
.role-card, .role-preview-card { border:1px solid var(--line); border-radius:16px; background:#fbfcff; padding:14px; }
.role-card-head, .role-preview-title { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:10px; }
.role-card p, .role-preview-card p { margin:8px 0 0; font-size:13px; }
.role-badge { display:inline-flex; align-items:center; justify-content:center; border-radius:999px; padding:5px 10px; font-size:12px; font-weight:800; line-height:1; white-space:nowrap; background:#eef1f8; color:#26324a; }
.role-user { background:#eef1f8; color:#26324a; }
.role-manager { background:#fff4ce; color:#8a5a00; }
.role-finance-admin { background:#e6f4ea; color:#137333; }
.role-global-admin { background:#ede7f6; color:#5e35b1; }
.permission-matrix-wrap { margin-top:12px; }
.permission-matrix th:first-child { min-width:190px; }
.permission-matrix td { min-width:170px; }
.permission-cell { display:inline-flex; border-radius:999px; padding:5px 9px; font-size:12px; font-weight:750; line-height:1.15; background:#eef1f8; color:#26324a; }
.permission-yes { background:#e6f4ea; color:#137333; }
.permission-limited { background:#fff4ce; color:#8a5a00; }
.permission-no { background:#f1f3f7; color:#657085; }
.role-form-layout { display:grid; grid-template-columns: minmax(0,1fr) 320px; gap:16px; align-items:start; margin-bottom:16px; }
.role-preview { position:sticky; top:92px; }
.role-preview-grid { display:grid; grid-template-columns:1fr; gap:8px; margin-top:12px; }
.role-preview-grid div { border:1px solid var(--line); border-radius:12px; background:white; padding:9px 10px; }
.role-preview-grid strong { display:block; font-size:13px; margin-top:2px; }
.role-user-table td { vertical-align:middle; }
@media (max-width: 1100px) { .role-card-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } .role-form-layout { grid-template-columns:1fr; } .role-preview { position:relative; top:auto; } }
@media (max-width: 700px) { .role-card-grid { grid-template-columns:1fr; } }


/* V1.1.24 custom role creation */
.menu-permission-grid { display:grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap:10px; margin-top:8px; }
.menu-permission-card { display:flex; align-items:flex-start; gap:10px; border:1px solid var(--line); border-radius:14px; background:#fbfcff; padding:12px; margin:0; cursor:pointer; min-height:82px; }
.menu-permission-card input[type="checkbox"] { width:auto; margin-top:3px; }
.menu-permission-card strong { display:block; font-size:14px; color:var(--ink); margin-bottom:4px; }
.menu-permission-card small { display:block; color:var(--muted); line-height:1.3; font-weight:500; }
.role-builder-form { margin-bottom:14px; }
.notice.compact { margin:10px 0; padding:10px 12px; }
@media (max-width: 1100px) { .menu-permission-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 700px) { .menu-permission-grid { grid-template-columns:1fr; } }

/* V1.2.0 approval workflow */
.approval-level-grid { display:grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap:12px; margin:10px 0; }
.approval-level-card { border:1px solid var(--line); border-radius:16px; background:#fbfcff; padding:14px; min-height:110px; }
.approval-level-card strong { display:block; font-size:16px; margin:4px 0; }
.approval-level-card b, .approval-level-card span:not(.small) { display:block; font-weight:800; color:var(--accent); margin:4px 0 6px; }
.approval-level-card p { margin:6px 0 0; font-size:12px; color:var(--muted); line-height:1.35; }
.approval-chain { margin-top:14px; border:1px solid var(--line); border-radius:16px; background:#fbfcff; padding:12px; }
.approval-chain h3 { margin:0 0 8px; }
.subtle-card { background:#fbfcff; border:1px solid var(--line); border-radius:16px; }
@media (max-width: 1100px) { .approval-level-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 700px) { .approval-level-grid { grid-template-columns:1fr; } }

/* V1.2.2 GL allowance and spend policy indicators */
.policy-badges { display:flex; flex-wrap:wrap; gap:5px; margin-top:6px; }
.policy-badge { display:inline-flex; align-items:center; border-radius:999px; padding:4px 8px; font-size:11px; font-weight:800; line-height:1; white-space:nowrap; background:#eef1f8; color:#26324a; }
.policy-badge.warning { background:#fff4ce; color:#8a5a00; }
.policy-badge.blocker { background:#fde7e9; color:#a50e0e; }
.policy-badge.info { background:#e8f0fe; color:#174ea6; }

/* V1.2.3 advanced tax table */
.advanced-tax-form { margin:14px 0; }
.advanced-tax-table th, .advanced-tax-table td { vertical-align:top; }
.tax-rate-badge { display:inline-flex; align-items:center; border-radius:999px; padding:5px 9px; font-size:12px; font-weight:800; line-height:1; background:#e8f0fe; color:#174ea6; }
.muted-row { opacity:.62; }

/* V1.2.5 full user editor */
.user-editor-form .form-section { border-bottom:1px solid var(--line); padding-top:6px; margin-top:4px; }
.user-editor-form .form-section h3 { margin:0 0 2px; font-size:15px; color:#33405a; }
.user-editor-layout .role-preview { top:92px; }
.role-user-table th, .role-user-table td { white-space:normal; }

/* V1.2.6 user edit discoverability */
.editing-user-banner { display:flex; align-items:center; justify-content:space-between; gap:12px; border:1px solid #bfdbfe; background:#eff6ff; color:#1e3a8a; border-radius:14px; padding:12px 14px; margin:12px 0 14px; }
.editing-user-banner strong { font-size:15px; }
.editing-user-banner span { color:#1e3a8a; font-size:13px; }
.mini-edit-button { margin-top:8px; min-height:30px; padding:6px 10px; border-radius:10px; font-size:12px; }
.role-user-table th:first-child, .role-user-table td:first-child { min-width:220px; }
@media (max-width: 700px) { .editing-user-banner { display:block; } .editing-user-banner span { display:block; margin-top:4px; } }

/* V1.2.7 administrator queue */
.method-grid { display:grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap:12px; margin-top:14px; }
.method-card { border:1px solid var(--line); border-radius:16px; background:#fbfcff; padding:12px; }
.method-card strong { display:block; font-size:15px; margin-bottom:4px; color:var(--ink); }
.method-card span { display:inline-flex; border-radius:999px; padding:4px 8px; font-size:11px; font-weight:800; background:#eef1f8; color:#26324a; }
.method-card.active span { background:#e6f4ea; color:#137333; }
.method-card p { margin:8px 0 0; font-size:12px; color:var(--muted); line-height:1.35; }
.queue-table th, .queue-table td { vertical-align:top; }
.queue-table th:first-child, .queue-table td:first-child { min-width:170px; }
@media (max-width: 1100px) { .method-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 700px) { .method-grid { grid-template-columns:1fr; } }

/* ============================================================
   v2.5 — Mobile responsiveness
   Targets phones/tablets so the hosted web app is usable on a
   handset (the receipt-capture device) without a native app.
   ============================================================ */

/* Never let a wide element force horizontal page scroll. */
html, body { max-width: 100%; overflow-x: hidden; }
img, canvas, video, .receipt-frame, .pdf-page-wrap { max-width: 100%; }

/* Tablet and below: tighten the shell. */
@media (max-width: 820px) {
  .topbar .inner { padding: 12px 16px; }
  .container { padding-left: 14px; padding-right: 14px; }
  .card { padding: 14px; margin: 14px 0; border-radius: 14px; }

  /* Tab nav becomes a horizontally scrollable strip instead of a tall wrap. */
  .tabs {
    display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto;
    -webkit-overflow-scrolling: touch; padding-bottom: 6px; margin-top: 10px;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex: 0 0 auto; white-space: nowrap; }

  /* Mapping/two-up layouts must be allowed to stack (drop the 420px floor). */
  .mapping-grid { grid-template-columns: 1fr !important; }
}

/* Phone: comfortable touch targets and single-column everything. */
@media (max-width: 560px) {
  /* iOS minimum comfortable touch target is ~44px. */
  button, .buttonlink { min-height: 44px; padding: 12px 16px; }
  input, select, textarea { min-height: 44px; font-size: 16px; } /* 16px avoids iOS focus-zoom */

  .container { padding-left: 12px; padding-right: 12px; }
  .card { padding: 12px; border-radius: 12px; }

  /* Collapse any remaining multi-column grids to one column generically. */
  .form-grid, .kpis, .filters, .analytics-grid,
  .role-card-grid, .menu-permission-grid, .approval-level-grid,
  [class*="grid"] { grid-template-columns: 1fr !important; }

  /* Card headers stack so action buttons don't get squeezed off-screen. */
  .card-header { flex-direction: column; align-items: stretch; gap: 8px; }
  .card-header .actions, .card-header > div:last-child { display: flex; flex-wrap: wrap; gap: 8px; }

  /* KPI numbers a touch smaller so they don't overflow narrow cards. */
  .kpi strong { font-size: 24px; }

  /* Userbox: left-align under the logo, full-width logout. */
  .userbox { text-align: left; }
  .userbox button { width: 100%; margin-top: 8px; }

  /* Tables stay swipeable (already wrapped in .table-wrap); hint it. */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  th, td { font-size: 13px; padding: 8px 10px; }

  /* Receipt capture / preview frames fit the viewport height. */
  .receipt-frame { height: 56vh; }
}

/* Honor users who prefer reduced motion. */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Receipt camera-capture control: only meaningful on touch devices. Hidden on
   desktop (fine/hover pointers), shown on phones/tablets where the camera opens. */
.capture-only { display: none; }
@media (pointer: coarse) {
  .capture-only { display: block; }
}

/* ===== V2.6 mobile hardening + Phone capture queue ===== */

/* Prevent any stray wide element (tables, intrinsic-width file inputs) from
   creating page-level horizontal scroll, which visually shifts left-anchored
   chrome off-screen on phones. `clip` avoids creating a scroll container
   (keeps position:sticky working); `hidden` is the fallback. */
html { overflow-x: hidden; overflow-x: clip; }

/* File inputs have a large intrinsic min-content width on iOS — cap them. */
input[type="file"] { max-width: 100%; min-width: 0; }
.form-grid > * { min-width: 0; }

/* Section-card headers: let long titles truncate instead of pushing layout. */
.section-card-header { flex-wrap: wrap; }
.section-title-button { min-width: 0; }
.section-title-button h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Tablet strip nav: give the section buttons a visible chip affordance. */
@media (max-width: 980px) {
  .section-nav { padding: 8px; }
  .section-nav button { background: #eef1f8; }
}

/* Phones: the Sections jump-strip is redundant chrome (sections are stacked
   directly below) and was the source of the floating-box artifact. Hide it,
   and keep the page header tidy with the actions menu anchored right. */
@media (max-width: 700px) {
  .section-nav { display: none; }
  .sticky-page-header { position: static; }
  .page-actions { margin-left: auto; }
  .page-actions-menu { right: 0; left: auto; max-width: calc(100vw - 28px); }
}

/* Phone capture view */
.phone-capture { display: flex; flex-direction: column; gap: 10px; }
.phone-big-button { width: 100%; min-height: 56px; font-size: 17px; }
@media (min-width: 701px) {
  .phone-capture { max-width: 460px; }
}
.phone-queue-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.phone-item { border: 1px solid var(--line); border-radius: 14px; background: #fbfcff; overflow: hidden; display: flex; flex-direction: column; }
.phone-item img { width: 100%; height: 110px; object-fit: cover; display: block; background: #eef1f8; }
.phone-item-pdf { width: 100%; height: 110px; display: flex; align-items: center; justify-content: center; background: #eef1f8; font-weight: 700; }
.phone-item-meta { padding: 8px 10px 0; display: flex; flex-direction: column; gap: 2px; }
.phone-item-meta strong { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phone-item-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 10px 10px; }
.pq-badge { font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 999px; background: #e8ecf6; color: #26324a; }
.pq-badge.ok { background: #d9f3e3; color: #156a3a; }
.pq-badge.busy { background: #fff1d6; color: #8a5a00; }
.pq-badge.err { background: #ffe0e0; color: #a02020; }
.pq-remove { min-height: 30px; padding: 4px 10px; font-size: 12px; }
.phone-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.phone-controls label { display: flex; flex-direction: column; gap: 4px; font-weight: 650; font-size: 13px; }
@media (max-width: 560px) {
  .phone-controls { flex-direction: column; align-items: stretch; }
  .phone-controls button { width: 100%; }
}

/* ===== V2.7 receipt batch selection ===== */
.pick-col { width: 36px; text-align: center; }
input.receipt-pick, #receipt-pick-all { width: 20px; height: 20px; min-height: 20px; accent-color: var(--accent); cursor: pointer; }
.receipt-batch-bar { display: none; }
.receipt-batch-bar.active {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  position: sticky; top: 8px; z-index: 20;
  background: #eaf6f7; border: 1px solid var(--accent); border-radius: 14px;
  padding: 10px 14px; margin-bottom: 12px; box-shadow: 0 8px 24px rgba(16,24,40,.08);
}
.receipt-batch-bar input[type="text"] { flex: 1 1 220px; min-width: 0; }
@media (max-width: 560px) {
  .receipt-batch-bar.active { flex-direction: column; align-items: stretch; position: static; }
  .receipt-batch-bar button { width: 100%; }
  input.receipt-pick, #receipt-pick-all { width: 24px; height: 24px; min-height: 24px; }
}

/* v2.9.1 — busy-button feedback for slow actions (OCR runs take seconds) */
.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: -2px;
  animation: captrix-spin 0.7s linear infinite;
}
button.busy { opacity: 0.75; cursor: progress; pointer-events: none; }
@keyframes captrix-spin { to { transform: rotate(360deg); } }
