/* Design system copied from support.mainit.ca (MainIT) — same variables, components, admin blue theme. */
:root {
  --red: #DA1F26;
  --green: #15924A;
  --ink: #141A21;
  --ink-2: #48586B;
  --ink-3: #93A1B2;
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --line: #E5E9EF;
  --shadow-card: 0 1px 2px rgba(15,23,42,.05);
  --radius-card: 14px;
  --radius-btn: 10px;
  --radius-input: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
svg { width: 18px; height: 18px; flex-shrink: 0; }
.x-btn svg { width: 17px; height: 17px; }
::selection { background: rgba(218,31,38,.18); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(100,116,139,.3); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
@keyframes mitFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes mitSheet { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

.grotesk { font-family: 'Space Grotesk', sans-serif; letter-spacing: -0.02em; }
.mono { font-family: 'IBM Plex Mono', monospace; }
.muted { color: var(--ink-3); }
.pre { white-space: pre-wrap; }
.section-label { font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }

/* ---------- toasts ---------- */
.toast-wrap { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 400; display: flex; flex-direction: column; gap: 8px; width: max-content; max-width: 92vw; }
.toast { padding: 11px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 600; box-shadow: 0 8px 24px rgba(15,23,42,.16); transition: opacity .4s; animation: mitFade .2s ease; }
.toast-error { background: #FCE8E9; color: #9b1c1c; border: 1px solid #f3b9bb; }
.toast-success { background: #E4F5EB; color: #15803d; border: 1px solid #a7e3bd; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; font-size: 14px; font-weight: 600; border-radius: var(--radius-btn); border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; white-space: nowrap; transition: filter .15s, background .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn:hover { filter: brightness(.98); }
.btn svg { width: 17px; height: 17px; }
.btn-sm { padding: 7px 12px; font-size: 13px; gap: 6px; }
.btn-sm svg { width: 15px; height: 15px; }
.btn-lg { padding: 13px 20px; font-size: 15px; }
.btn-full { width: 100%; }
.btn-primary { background: var(--red); color: #fff; border-color: var(--red); box-shadow: 0 1px 2px rgba(218,31,38,.25); }
.btn-dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-success { background: var(--green); color: #fff; border-color: var(--green); box-shadow: 0 1px 2px rgba(21,146,74,.25); }
.btn-outline { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: transparent; }
.btn-danger { background: var(--surface); color: var(--red); border-color: #DA1F2633; }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }

/* ---------- card ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 18px; box-shadow: var(--shadow-card); }
.card.pad0 { padding: 0; }
a.card, .card.clickable { display: block; transition: box-shadow .18s, transform .18s; }
a.card:hover, .card.clickable:hover { box-shadow: 0 6px 22px rgba(15,23,42,.09); transform: translateY(-1px); }
.card.alert { border-color: var(--red); }
.divider { height: 1px; background: var(--line); }

/* ---------- pills / tags ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600; line-height: 1; white-space: nowrap; }
.pill.sm { padding: 3px 9px; font-size: 11.5px; }
.pill .dot { width: 7px; height: 7px; border-radius: 999px; background: currentColor; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 7px; background: var(--bg); border: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 600; white-space: nowrap; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- fields ---------- */
.field { display: block; }
.field > .label { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.field > .hint { font-size: 12px; color: var(--ink-3); margin-top: 5px; }
.input, .select, .textarea, input:not([type]), input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=file], textarea, select {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-input); border: 1px solid var(--line);
  background: var(--surface); font-family: inherit; font-size: 14.5px; color: var(--ink); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(218,31,38,.12); }
.select-wrap { position: relative; }
.select-wrap select { appearance: none; padding-right: 36px; cursor: pointer; }
.select-wrap::after { content: ""; position: absolute; right: 14px; top: 50%; width: 9px; height: 9px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: translateY(-65%) rotate(45deg); pointer-events: none; }
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--ink-3); }
.search-wrap input { padding-left: 38px; }

/* ---------- layout: admin ---------- */
.admin { min-height: 100vh; display: flex; background: var(--bg); }
.sidebar { width: 232px; flex-shrink: 0; background: var(--ink); color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { padding: 20px 18px 18px; display: flex; align-items: center; gap: 10px; }
.sidebar .brand .word { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 16px; }
.sidebar nav { padding: 6px 12px; display: grid; gap: 4px; }
.side-btn { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; border: none; cursor: pointer; font-size: 14px; font-weight: 600; width: 100%; text-align: left; white-space: nowrap; background: transparent; color: rgba(255,255,255,.62); }
.side-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.side-btn.active { background: rgba(255,255,255,.13); color: #fff; }
.side-btn svg { width: 19px; height: 19px; }
.side-btn .grow { flex: 1; }
.nav-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff; font-size: 11.5px; font-weight: 700; display: grid; place-items: center; }
.sidebar .foot { margin-top: auto; padding: 14px; border-top: 1px solid rgba(255,255,255,.1); }
.admin-main { flex: 1; min-width: 0; padding: 26px 30px 40px; max-width: 1180px; margin: 0 auto; width: 100%; }
.page-title { font-family: 'Space Grotesk', sans-serif; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.page-sub { color: var(--ink-2); font-size: 14px; margin: 4px 0 0; }
.row-between { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- table ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 11px 16px; font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); background: var(--bg); border-bottom: 1px solid var(--line); cursor: pointer; user-select: none; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); font-size: 13.5px; color: var(--ink-2); vertical-align: middle; }
.table tr.clickable:hover td { background: var(--bg); }
.table .ttl { font-size: 14px; font-weight: 600; color: var(--ink); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.table .right { text-align: right; }

/* ---------- stats ---------- */
.stat-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.stat { flex: 1 1 120px; min-width: 110px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 13px; }
.stat.accent { background: var(--red); border-color: var(--red); }
.stat .k { font-size: 11.5px; font-weight: 600; color: var(--ink-3); margin-bottom: 3px; }
.stat.accent .k { color: rgba(255,255,255,.8); }
.stat .v { font-family: 'IBM Plex Mono', monospace; font-size: 18px; font-weight: 600; color: var(--ink); }
.stat.accent .v { color: #fff; }

/* ---------- sheets (dialog) ---------- */
dialog.sheet { padding: 0; border: none; border-radius: 18px; width: 100%; max-width: 480px; max-height: 92vh; box-shadow: 0 24px 60px rgba(15,23,42,.28); overflow: hidden; animation: mitSheet .22s cubic-bezier(.2,.8,.2,1); }
dialog.sheet.wide { max-width: 620px; }
dialog.sheet form { display: flex; flex-direction: column; max-height: 92vh; min-height: 0; }
.sheet .sh-bd { flex: 1 1 auto; min-height: 0; padding: 20px; overflow-y: auto; }
dialog.sheet::backdrop { background: rgba(15,23,42,.42); backdrop-filter: blur(2px); }
.sheet .sh-hd { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.sheet .sh-hd .t { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 17px; }
.sheet .sh-ft { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; background: var(--bg); }
.x-btn { background: var(--bg); border: 1px solid var(--line); border-radius: 9px; width: 32px; height: 32px; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stack { display: grid; gap: 16px; }
.stack-sm { display: grid; gap: 12px; }

/* ---------- dropzone / file inputs ---------- */
.dropzone { display: flex; align-items: center; gap: 11px; padding: 14px; border: 1px dashed var(--line); border-radius: 10px; color: var(--ink-3); font-size: 13.5px; flex-wrap: wrap; }
.dropzone input[type=file] { font-size: 14px; border: none; padding: 4px 0; width: 100%; min-width: 0; background: transparent; }
input[type=file]::file-selector-button {
  padding: 9px 14px; margin-right: 12px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--ink); font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
input[type=file]::file-selector-button:hover { background: var(--bg); }

/* ---------- empty ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--ink-3); }
.empty .ico { width: 56px; height: 56px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); display: grid; place-items: center; margin: 0 auto 14px; color: var(--ink-2); }
.empty .t { font-size: 15px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; background: var(--surface); }
.brand-panel { position: relative; overflow: hidden; background: var(--ink); color: #fff; flex: 1 1 0; padding: 48px 44px; display: flex; flex-direction: column; justify-content: space-between; }
.brand-panel .matrix { position: absolute; inset: 0; opacity: .16; background: repeating-linear-gradient(90deg, transparent 0 22px, rgba(43,212,74,.5) 22px 23px); -webkit-mask-image: linear-gradient(120deg,transparent,#000 60%); mask-image: linear-gradient(120deg,transparent,#000 60%); }
.brand-panel .top { position: relative; display: flex; align-items: center; gap: 12px; }
.brand-panel .top .word { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 27px; letter-spacing: -0.02em; }
.brand-panel h2 { position: relative; font-family: 'Space Grotesk', sans-serif; font-size: 30px; font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 12px; }
.brand-panel p { position: relative; font-size: 15px; color: rgba(255,255,255,.7); line-height: 1.6; max-width: 360px; margin: 0; }
.brand-panel .addr { position: relative; font-size: 12.5px; color: rgba(255,255,255,.5); font-family: 'IBM Plex Mono', monospace; }
.signin-pane { flex: 1 1 0; display: flex; align-items: center; justify-content: center; padding: 48px 44px; background: var(--bg); }
.signin { width: 100%; max-width: 380px; }
.signin h1 { font-family: 'Space Grotesk', sans-serif; font-size: 24px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.02em; }
.signin .sub { font-size: 14px; color: var(--ink-2); margin: 0 0 22px; }
.notice { margin-top: 20px; padding: 11px 13px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; font-size: 12.5px; color: var(--ink-3); line-height: 1.5; }
.notice strong { color: var(--ink-2); }

/* mobile */
.admin-topbar { display: none; }
.admin-bottomnav { display: none; }
@media (max-width: 760px) {
  .sidebar { display: none; }
  .admin-main { padding: 16px 16px 88px; }
  .grid2 { grid-template-columns: 1fr; }
  .login { flex-direction: column; }
  .brand-panel { padding: 30px 24px 26px; }
  .brand-panel h2, .brand-panel p { display: none; }
  .signin-pane { padding: 28px 20px 40px; }
  .hide-mobile { display: none !important; }
  dialog.sheet { max-width: 100%; margin: auto auto 0; border-radius: 20px 20px 0 0; }
  .admin-topbar { display: flex; position: sticky; top: 0; z-index: 50; background: #1E5FBF; color: #fff; padding: 12px 16px; align-items: center; gap: 10px; }
  .admin-topbar .word { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 16px; }
  .admin-bottomnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 8px 10px; }
  .admin-bottomnav a { flex: 1; display: grid; justify-items: center; gap: 3px; padding: 6px 0; color: var(--ink-3); font-size: 11px; font-weight: 600; position: relative; }
  .admin-bottomnav a.active { color: #1E5FBF; }
  .admin-bottomnav .fab-cam { width: 54px; height: 54px; border-radius: 50%; background: #2F80ED; color: #fff; display: grid; place-items: center; margin: -24px auto 0; font-size: 22px; box-shadow: 0 6px 16px rgba(47,128,237,.45); border: 4px solid var(--bg); }
  .admin-bottomnav a .fab-cam + span { color: transparent; height: 0; overflow: hidden; }
}
@media (min-width: 761px) { .only-mobile { display: none !important; } }

/* ===== Light-blue admin theme + larger fonts (same as support.mainit.ca admin) ===== */
.admin{ --blue:#2F80ED; --blue-dark:#1E5FBF; --blue-deep:#173F7D; --blue-soft:#EAF2FE; font-size:16px; }
.admin, .admin input, .admin textarea, .admin select, .admin button, .admin .btn{ font-size:15.5px; }
.admin .page-title{ font-size:30px; }
.admin .page-sub, .admin .hint, .admin .muted{ font-size:14.5px; }
.admin .section-label{ font-size:12.5px; }
.admin table, .admin table td, .admin table th{ font-size:15px; }
.admin .card{ font-size:15.5px; }
.admin .sidebar{ background:linear-gradient(180deg,#1E5FBF,#173F7D); color:#fff; }
.admin .side-btn{ color:rgba(255,255,255,.78); }
.admin .side-btn:hover{ background:rgba(255,255,255,.12); color:#fff; }
.admin .side-btn.active{ background:rgba(255,255,255,.2); color:#fff; }
.admin a{ color:var(--blue); }
.admin .btn-primary{ background:var(--blue); border-color:var(--blue); color:#fff; box-shadow:0 1px 2px rgba(47,128,237,.3); }
.admin .btn-primary:hover{ background:var(--blue-dark); border-color:var(--blue-dark); }
.admin input:focus, .admin textarea:focus, .admin select:focus{ border-color:var(--blue); box-shadow:0 0 0 3px rgba(47,128,237,.15); }
.admin .chip.active{ background:var(--blue); border-color:var(--blue); color:#fff; }
.admin .nav-badge{ background:var(--blue-soft); color:var(--blue-dark); }

/* ===== footer (same as support.mainit.ca admin) ===== */
.app-footer{ background:#173F7D; color:#CFE0FB; }
.app-footer-in{ max-width:1180px; margin:0 auto; padding:16px 30px; display:flex; align-items:center; justify-content:space-between; gap:16px; flex-wrap:wrap; font-size:15px; }
.app-footer .af-brand{ font-weight:700; color:#fff; letter-spacing:.02em; }
.app-footer .af-sep{ color:#8FBAF5; }
.app-footer .af-links a{ color:#CFE0FB; text-decoration:none; margin-right:16px; }
.app-footer .af-links a:hover{ color:#fff; }
.app-footer .af-status{ color:#7EE0A0; }
@media (max-width: 760px){ .app-footer{ display:none; } } /* bottom nav replaces it on mobile */

/* ===== mobile bottom nav content ===== */
.admin-bottomnav a{ cursor:pointer; font-size:16px; text-align:center; }
.admin-bottomnav a span{ display:block; font-size:10.5px; margin-top:1px; }

/* ===== extra mobile polish ===== */
@media (max-width: 760px){
  .filters-bar{ grid-template-columns: 1fr 1fr; }
  .stat-row .stat{ min-width: 90px; }
  .page-title{ font-size:24px !important; }
  .table th, .table td{ padding:9px 10px; font-size:13px !important; }
}

/* ===== acc-specific helpers (2A Refined Ledger) ===== */
.filters-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 0; padding: 16px 16px 8px; }
.amount-cell { font-family: 'IBM Plex Mono', monospace; font-weight: 600; color: var(--ink); }
.pill-biz { background: #EAF2FE; color: #1E5FBF; }
.pill-personal { background: #FBF0DD; color: #C2700A; }
.pill-unreviewed { background: var(--bg); color: var(--ink-3); border: 1px dashed var(--line); }
.pill-pending { background: #FCE8E9; color: var(--red); }
.pill-confirmed { background: #E4F5EB; color: #15803d; }
.src-tag { font-family: 'IBM Plex Mono', monospace; font-size: 11px; }
.receipt-thumb { max-width: 100%; border-radius: 12px; border: 1px solid var(--line); }

/* 2A refinements: table + rows — must fit without clipping the Amount column */
.table th, .table td { padding: 11px 10px; }
.table th:first-child, .table td:first-child { padding-left: 16px; }
.table th:last-child, .table td:last-child { padding-right: 16px; }
.table .ttl { max-width: 200px; }
.table .tag { font-size: 11px; padding: 3px 8px; white-space: nowrap; }
.table .amount-cell { white-space: nowrap; }
.table .pill.sm { font-size: 10.5px; padding: 3px 8px; }
.table td { border-bottom: 1px solid #EDF1F6; }
.table td.date-cell { font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.table .ttl { font-size: 14px; }
.table input[type=checkbox] { accent-color: #2F80ED; width: 16px; height: 16px; }

/* 2A stat cards */
.stat-row { gap: 12px; }
.stat[hidden] { display: none !important; }
.stat { background: var(--surface); border-radius: 12px; padding: 12px 15px; }
.stat .k { font-size: 12px; color: var(--ink-3); }
.stat .v { font-size: 22px; }
.admin .stat.accent { background: #2F80ED; border-color: #2F80ED; }
.stat.alert { background: #FCE8E9; border-color: #f3b9bb; }
.stat.alert .k { color: #9b1c1c; }
.stat.alert .v { color: var(--red); }

/* Reports page */
.rep-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; }
.rep-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.rep-card .hd { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.rep-card .hd .t { font-family: 'Space Grotesk', sans-serif; font-size: 16px; font-weight: 600; }
.rep-card .hd .mono { font-size: 12px; color: var(--ink-3); }
.bars { display: flex; align-items: flex-end; gap: 16px; height: 180px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; height: 100%; }
.bars .bar { width: 100%; background: #DCE9FB; border-radius: 8px 8px 0 0; min-height: 4px; }
.bars .col.cur .bar { background: #2F80ED; }
.bars .lbl { font-size: 11px; color: var(--ink-3); }
.bars .col.cur .lbl { color: var(--ink); font-weight: 600; }
.cat-rows { display: flex; flex-direction: column; gap: 15px; }
.cat-row .top { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 6px; }
.cat-row .top .nm { font-weight: 600; }
.cat-row .top .amt { font-family: 'IBM Plex Mono', monospace; color: var(--ink-2); }
.cat-row .track { height: 8px; border-radius: 999px; background: #EDF1F6; }
.cat-row .fill { height: 100%; border-radius: 999px; background: #2F80ED; }
.recent-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin-top: 16px; overflow: hidden; }
.recent-card .hd { padding: 14px 18px; font-family: 'Space Grotesk', sans-serif; font-size: 16px; font-weight: 600; border-bottom: 1px solid var(--line); }
.recent-row { display: flex; align-items: center; gap: 14px; padding: 13px 18px; border-bottom: 1px solid #EDF1F6; font-size: 13.5px; cursor: pointer; }
.recent-row:last-child { border-bottom: none; }
.recent-row:hover { background: var(--bg); }
.recent-row .dt { font-family: 'IBM Plex Mono', monospace; color: var(--ink-3); width: 100px; flex-shrink: 0; }
.recent-row .nm { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-row .amt { font-family: 'IBM Plex Mono', monospace; font-weight: 600; width: 84px; text-align: right; }

/* Import statement: blue info bar */
.info-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #EAF2FE; border: 1px solid #cfe0fb; border-radius: 12px; padding: 14px 18px; margin-bottom: 14px; flex-wrap: wrap; }
.info-bar .file { font-family: 'IBM Plex Mono', monospace; font-size: 14px; font-weight: 600; color: #1E5FBF; }
.info-bar .sub { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.info-bar .btn-cancel { height: 38px; padding: 0 15px; border-radius: 10px; border: 1px solid #cfe0fb; background: #fff; color: #1E5FBF; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.btn-import { height: 38px; padding: 0 16px; border-radius: 10px; border: none; background: var(--green); color: #fff; font-size: 13.5px; font-weight: 600; cursor: pointer; }

/* Upload receipt: two-column review */
.upload-grid { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
.photo-box { border-radius: 12px; border: 1px solid var(--line); background: repeating-linear-gradient(135deg, #F5F7FA 0 10px, #EDF1F6 10px 20px); min-height: 300px; display: grid; place-items: center; overflow: hidden; }
.photo-box img { width: 100%; height: auto; display: block; }
.ocr-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; background: #E4F5EB; color: #15803d; font-size: 11.5px; font-weight: 600; margin-top: 14px; }
.warn-box { display: flex; gap: 9px; background: #FEF6E7; border: 1px solid #F3D9A0; border-radius: 10px; padding: 11px 13px; margin-bottom: 14px; font-size: 12.5px; color: #8a5a12; line-height: 1.5; }
.warn-box.red { background: #FCE8E9; border-color: #f3b9bb; color: #9b1c1c; }
.warn-box.green { background: #E4F5EB; border-color: #a7e3bd; color: #15803d; }
.seg { display: flex; gap: 8px; max-width: 300px; }
.seg button { flex: 1; text-align: center; padding: 10px; border-radius: 9px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); font-size: 13.5px; font-weight: 600; cursor: pointer; }
.seg button.on { background: #2F80ED; border-color: #2F80ED; color: #fff; }
.seg button.on.personal { background: #E7A93B; border-color: #E7A93B; }

@media (max-width: 900px) {
  .rep-grid { grid-template-columns: 1fr; }
  .upload-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .filters-bar { grid-template-columns: 1fr 1fr; }
}

/* year tabs on Reports: visible on all screen sizes */
.year-tabs, #bizTabs, #yearTabs { display: flex !important; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.year-tabs .chip { flex: none; height: 32px; border-radius: 999px; font-family: 'IBM Plex Mono', monospace; }
.year-tabs .chip.active { background: #2F80ED; border-color: #2F80ED; color: #fff; }
.bars .bar { position: relative; }
.bars .val { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-family: 'IBM Plex Mono', monospace; font-size: 10px; color: var(--ink-3); white-space: nowrap; }

/* ===== 1A mobile layouts (dedicated designs, ≤760px) ===== */
.m-chips { display: none; }
.m-statmini { display: none; }
.exp-cards { display: none; }
.rep-split { display: none; }
.rep-review-banner { display: none; }
.prev-cards { display: none; }

@media (max-width: 760px) {
  /* Expenses: card list replaces the table */
  #expTable, #view-expenses .filters-bar, #view-expenses .stat-row { display: none; }
  .m-search { position: relative; margin: 12px 0; display: block; }
  .m-search input { background: var(--bg); padding-left: 38px; }
  .m-search::before { content: "🔍"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; opacity: .55; }
  .m-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 8px; }
  .m-chips .chip { flex: none; height: 32px; border-radius: 999px; }
  .m-chips .chip.active { background: #2F80ED; border-color: #2F80ED; color: #fff; }
  .m-statmini { display: flex; gap: 8px; margin-bottom: 10px; }
  .m-statmini > div { flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; }
  .m-statmini .k { font-size: 11px; color: var(--ink-3); font-weight: 600; }
  .m-statmini .v { font-family: 'IBM Plex Mono', monospace; font-size: 15px; font-weight: 600; }
  .m-statmini .biz { background: #2F80ED; border-color: #2F80ED; }
  .m-statmini .biz .k { color: rgba(255,255,255,.8); }
  .m-statmini .biz .v { color: #fff; }
  .exp-cards { display: flex; flex-direction: column; gap: 10px; }
  .exp-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; box-shadow: var(--shadow-card); cursor: pointer; }
  .exp-card .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
  .exp-card .nm { font-weight: 600; font-size: 15px; }
  .exp-card .amt { font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: 15px; white-space: nowrap; }
  .exp-card .meta { display: flex; align-items: center; gap: 8px; margin-top: 9px; flex-wrap: wrap; }
  .exp-card .dt { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--ink-3); }

  /* Reports: split bar + review banner */
  #view-reports .stat-row { display: none; }
  .rep-split { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: var(--shadow-card); margin-bottom: 12px; }
  .rep-split .k { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
  .rep-split .total { font-family: 'IBM Plex Mono', monospace; font-size: 34px; font-weight: 600; margin: 4px 0 14px; }
  .rep-split .track { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: #EDF1F6; }
  .rep-split .seg-biz { background: #2F80ED; }
  .rep-split .seg-per { background: #E7A93B; }
  .rep-split .legend { display: flex; justify-content: space-between; margin-top: 12px; }
  .rep-split .lg { font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
  .rep-split .lg .sw { width: 8px; height: 8px; border-radius: 2px; }
  .rep-split .lv { font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: 16px; margin-top: 3px; }
  .rep-review-banner { display: flex; align-items: center; gap: 10px; background: #FCE8E9; border: 1px solid #f3b9bb; border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; cursor: pointer; }
  .rep-review-banner .n { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--red); color: #fff; font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: 14px; }
  .rep-review-banner .t { flex: 1; font-size: 13.5px; font-weight: 600; color: #9b1c1c; }
  .rep-review-banner[hidden] { display: none; }

  /* Import preview: cards replace the table */
  #previewWrap .card.pad0 { display: none; }
  .prev-cards { display: flex; flex-direction: column; gap: 10px; }
  .prev-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
  .prev-card.off { opacity: .55; }
  .prev-card .top { display: flex; align-items: center; gap: 10px; }
  .prev-card .nm { flex: 1; font-weight: 600; font-size: 14.5px; min-width: 0; }
  .prev-card .nm input { padding: 6px 9px; font-size: 13.5px; }
  .prev-card .amt { font-family: 'IBM Plex Mono', monospace; font-weight: 600; white-space: nowrap; }
  .prev-card .row2 { display: flex; gap: 8px; margin-top: 9px; }
  .prev-card .row2 select { padding: 7px 9px; font-size: 13px; }
  .prev-card .dt { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--ink-3); margin-top: 8px; }
  .info-bar { position: sticky; top: 52px; z-index: 40; }
}
@media (min-width: 761px) {
  .m-search { display: none; }
}

/* files browser: thumbnail grid */
.fb-grid { display: grid; gap: 12px; }
.fb-grid.small { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.fb-grid.large { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.fb-grid[hidden] { display: none; }
.fb-tile { position: relative; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); cursor: pointer; }
.fb-tile.sel { outline: 3px solid #2F80ED; outline-offset: -3px; }
.fb-tile .im { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #EDF1F6; }
.fb-tile .doc { width: 100%; aspect-ratio: 1; display: grid; place-items: center; font-size: 34px; background: repeating-linear-gradient(135deg, #F5F7FA 0 10px, #EDF1F6 10px 20px); }
.fb-tile .nm { padding: 7px 9px; font-size: 11px; font-family: 'IBM Plex Mono', monospace; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-tile .sz { position: absolute; top: 6px; right: 6px; background: rgba(15,23,42,.62); color: #fff; font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 999px; }
.fb-tile .ck { position: absolute; top: 6px; left: 6px; width: 20px; height: 20px; accent-color: #2F80ED; }
.fb-tile .open { position: absolute; bottom: 34px; right: 6px; background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 8px; width: 28px; height: 28px; display: grid; place-items: center; font-size: 13px; text-decoration: none; }
.fb-grid.large .fb-tile .nm { font-size: 12px; }

/* no-code dashboard tiles */
.dash-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.dash-tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; min-height: 190px; display: flex; flex-direction: column; }
.dash-tile .hd { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.dash-tile .hd .t { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 15px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-tile .hd button { background: none; border: none; cursor: pointer; color: var(--ink-3); font-size: 14px; padding: 2px 4px; }
.dash-tile .big { font-family: 'IBM Plex Mono', monospace; font-size: 30px; font-weight: 700; margin: auto 0; }
.dash-tile .sub { font-size: 12px; color: var(--ink-3); }
.dash-tile .bars { height: 90px; gap: 3px; margin-top: auto; }
.dash-tile .bars .lbl { font-size: 8px; }
.dash-add { border: 2px dashed var(--line); border-radius: 14px; min-height: 190px; display: grid; place-items: center; color: var(--ink-3); cursor: pointer; font-weight: 600; background: transparent; font-size: 15px; }
.dash-add:hover { border-color: #2F80ED; color: #2F80ED; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }

/* detail sheet (tap an expense) */
.meta-row { display: flex; align-items: baseline; gap: 10px; padding: 8px 0; border-bottom: 1px solid #EDF1F6; }
.meta-row:last-child { border-bottom: none; }
.meta-row .k { font-size: 13px; color: var(--ink-3); width: 96px; flex-shrink: 0; }
.meta-row .v { font-size: 13.5px; color: var(--ink); font-weight: 500; text-align: right; margin-left: auto; font-family: 'IBM Plex Mono', monospace; }
.meta-row .v.sans { font-family: 'IBM Plex Sans', sans-serif; }
#dtPhoto img { width: 100%; border-radius: 12px; border: 1px solid var(--line); display: block; }
#dtPhoto .noimg { border-radius: 12px; border: 1px solid var(--line); background: repeating-linear-gradient(135deg, #F5F7FA 0 10px, #EDF1F6 10px 20px); height: 140px; display: grid; place-items: center; color: var(--ink-3); font-family: 'IBM Plex Mono', monospace; font-size: 12px; }

/* receipt review mobile: full-width green submit per design */
@media (max-width: 760px) {
  #receiptCommitBtn { flex: 1; }
  #receiptCancel { min-width: 110px; }
  .photo-box { min-height: 180px; max-height: 260px; }
  .photo-box img { max-height: 260px; object-fit: contain; }
}

/* =====================================================================
   MOBILE SAFETY NET — critical layout rules restated at end of file with
   !important so the phone layout holds even if an earlier block is broken.
   ===================================================================== */
@media (max-width: 760px) {
  .sidebar { display: none !important; }
  .app-footer { display: none !important; }
  .admin { display: block !important; }
  .admin-main { padding: 16px 16px 96px !important; max-width: 100% !important; }
  html, body { max-width: 100vw; overflow-x: hidden; }
  /* iOS zooms the page when focusing inputs < 16px — keep every control at 16px */
  input, select, textarea, .btn { font-size: 16px !important; }
  /* forms must be comfortably readable & tappable on the phone */
  #receiptCommitForm input, #receiptCommitForm select, #receiptCommitForm textarea,
  #detailForm input, #detailForm select, #detailForm textarea,
  #editForm input, #editForm select, #editForm textarea {
    padding: 14px !important; font-size: 17px !important; border-radius: 10px;
  }
  #receiptCommitForm .label, #detailForm .label, #editForm .label { font-size: 15px !important; font-weight: 700; }
  .seg button { padding: 15px 10px; font-size: 16px !important; }
  /* post-save chooser + saved-card actions: big thumb-friendly buttons */
  #nsButtons .btn { padding: 17px 16px; font-size: 17px !important; border-radius: 12px; }
  #receiptResult .btn { padding: 15px 16px; font-size: 16.5px !important; flex: 1; }
  dialog.sheet { width: 100vw !important; max-width: 100vw !important; box-sizing: border-box; }
  .sheet .sh-bd { padding: 16px !important; }
  .meta-row .k { width: 84px; }
  .meta-row .v { word-break: break-word; }
  /* top bar: white, centered, roomy logo */
  .admin-topbar { display: flex !important; position: sticky; top: 0; z-index: 50; background: #fff !important; color: var(--ink); padding: 10px 16px; align-items: center; justify-content: center; gap: 10px; border-bottom: 1px solid var(--line); }
  .admin-topbar .word { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 18px; color: var(--ink); }
  .admin-topbar img { height: 38px !important; width: auto !important; }
  /* Reports cards must never overflow the viewport */
  .rep-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .rep-card, .recent-card { min-width: 0; }
  .bars { gap: 5px !important; height: 150px; }
  .bars .lbl { font-size: 9px; }
  .bars .val { font-size: 9px; }
  .cat-row .top .amt { white-space: nowrap; }
  .recent-row .dt { width: 78px; font-size: 11px; }
  .admin-bottomnav { display: flex !important; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 8px 10px; }
  .admin-bottomnav a { flex: 1; display: grid; justify-items: center; gap: 3px; padding: 6px 0; color: var(--ink-3); font-size: 11px; font-weight: 600; position: relative; cursor: pointer; text-align: center; }
  .admin-bottomnav a.active { color: #1E5FBF; }
  .admin-bottomnav .fab-cam { width: 54px; height: 54px; border-radius: 50%; background: #2F80ED; color: #fff; display: grid; place-items: center; margin: -24px auto 0; font-size: 22px; box-shadow: 0 6px 16px rgba(47,128,237,.45); border: 4px solid var(--bg); }
  .admin-bottomnav a .fab-cam + span { color: transparent; height: 0; overflow: hidden; }
  .grid2 { grid-template-columns: 1fr !important; }
  dialog.sheet { max-width: 100% !important; margin: auto auto 0 !important; border-radius: 20px 20px 0 0 !important; }
  .hide-mobile { display: none !important; }
}
@media (min-width: 761px) {
  .only-mobile { display: none !important; }
  .admin-topbar, .admin-bottomnav { display: none !important; }
}

/* ===== print = "Export PDF" of the Reports page ===== */
@media print {
  .sidebar, .admin-topbar, .admin-bottomnav, .app-footer, .toast-wrap,
  #view-expenses, #view-upload, #view-statement, #view-rules,
  #view-categories, #view-items, #view-users, #view-backup,
  #yearTabs, #exportCsvBtn, #exportPdfBtn { display: none !important; }
  .admin { display: block; }
  .admin-main { padding: 0; max-width: none; }
  #view-reports { display: block !important; }
  body { background: #fff; }
  .card, .rep-card, .recent-card, .stat { box-shadow: none; }
}

/* ---------- inline-editable grid cells (Merchant rules) ---------- */
.rules-grid td { padding-top: 4px; padding-bottom: 4px; }
.table .cell-input {
  width: 100%; min-width: 90px; box-sizing: border-box;
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  padding: 6px 8px; font: inherit; color: inherit; box-shadow: none;
  transition: border-color .15s, background-color .3s;
}
.table select.cell-input { cursor: pointer; padding-right: 22px; }
.table .cell-input:hover { border-color: var(--line, #d0d5dd); }
.table .cell-input:focus { outline: none; border-color: var(--red); background: var(--bg, #fff); }
.table .cell-input.cell-saving { opacity: .6; }
.table .cell-input.cell-ok { background: rgba(34, 197, 94, .15); }
.table .cell-input.cell-err { background: rgba(239, 68, 68, .15); }

/* ---------- monthly report / alerts / integrations ---------- */
.mo-delta { font-size: 12px; color: var(--ink-3); margin-top: 3px; min-height: 15px; }
.stat.accent .mo-delta { color: rgba(255,255,255,.85); }
.mo-up { color: #b42318; font-weight: 600; }
.mo-down { color: #067647; font-weight: 600; }
.stat.accent .mo-up, .stat.accent .mo-down { color: #fff; }
.mo-mini { font-size: 11.5px; }
.mo-actions input[type=month] { padding: 8px 10px; }
.int-card { margin-top: 14px; max-width: 760px; }
.int-card .section-label { margin-bottom: 10px; }
.int-help { font-size: 13px; margin: 0 0 12px; }
.int-help code, .int-card code { font-size: 12px; background: var(--bg); padding: 1px 5px; border-radius: 5px; word-break: break-all; }
.int-check { display: flex !important; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; cursor: pointer; }
.int-check input { width: auto !important; padding: 0 !important; }
.int-btns { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.int-btns .field { min-width: 150px; }
.qbo-row { display: grid !important; grid-template-columns: minmax(140px, 220px) 1fr; gap: 10px; align-items: center; }
.qbo-row .label { margin: 0; }
@media (max-width: 760px) { .qbo-row { grid-template-columns: 1fr; } }
#bfRows td { vertical-align: middle; }
@media print {
  body.print-monthly #view-reports { display: none !important; }
  body.print-monthly #view-monthly { display: block !important; }
  body.print-monthly .mo-actions, body.print-monthly #view-dashboard, body.print-monthly #view-alerts,
  body.print-monthly #view-integrations, body.print-monthly #view-trips, body.print-monthly #view-files,
  body.print-monthly #view-settings, body.print-monthly #view-detail { display: none !important; }
}
