/**
 * App shell + domain styles for expense-bot admin.
 * Base primitives (forms, buttons, tables) come from Bootstrap + theme.css.
 * Tokens live in theme.css (:root / [data-bs-theme=dark]).
 */

html, body { height: 100%; }
html { overflow-x: hidden; }
body {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(91, 124, 250, 0.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(52, 211, 153, 0.08), transparent 50%),
    var(--bs-body-bg, var(--bg));
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  margin: 0;
  padding: 0;
  max-width: none;
}
body > #app,
body > main {
  max-width: none;
  padding: 0;
  margin: 0;
}
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: rgba(91, 124, 250, 0.35); color: #fff; }
.muted { color: var(--text2); }
.mono { font-family: var(--mono); font-size: 0.85em; }

/* Bootstrap complements */
.btn-xs { padding: 0.2rem 0.5rem; font-size: 0.75rem; }

/* Form field groups (Bootstrap mb-3 + form-label used in JS) */
.mb-3 label,
.form-group label {
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  color: var(--text2);
  font-weight: 500;
}
.form-group {
  margin-bottom: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.form-group input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.form-group select,
.form-group textarea,
.toolbar input,
.toolbar select,
.page-actions input,
.page-actions select {
  margin-bottom: 0;
  width: 100%;
}
.toolbar input,
.toolbar select,
.filter-input {
  width: auto;
  min-width: 10rem;
  max-width: 100%;
  margin-bottom: 0;
}

/* Compact controls in dense toolbars */
.toolbar button,
.toolbar .btn,
.page-actions button,
.page-actions .btn,
.pagination button,
.modal-actions button,
.modal-actions .btn,
.action-btns-exp .btn,
.step-actions .btn {
  margin-bottom: 0;
  width: auto;
}

/* Tables: dense admin density on top of Bootstrap */
.table-wrap { overflow-x: auto; margin-bottom: 0.5rem; }
.table-wrap table,
table.data-table {
  margin-bottom: 0;
  font-size: 0.875rem;
}
.table-wrap th,
.table-wrap td,
table.data-table th,
table.data-table td {
  padding: 0.55rem 0.65rem;
}

/* Cards as surface panels */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1rem;
  box-shadow: none;
}
.card h3 {
  font-size: 0.9rem;
  margin: 0 0 0.85rem;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: #3a4660 transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: #3a4660; border-radius: 99px;
  border: 2px solid transparent; background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: #4a5875; border: 2px solid transparent; background-clip: padding-box; }

/* ── Login (admin-bot style) ── */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, rgba(28, 37, 56, 0.95), rgba(21, 28, 44, 0.98));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px;
  --bs-card-bg: transparent;
  --bs-card-border-color: var(--border);
  box-shadow: var(--shadow);
}
.login-brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 28px;
  text-align: left;
  flex-direction: row;
}
.login-brand h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}
.login-card .login-sub,
.login-brand .login-sub,
.login-brand .muted {
  color: var(--text2);
  font-size: 0.88rem;
  margin: 2px 0 0;
}
.brand-mark {
  width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent), #8b5cf6);
  color: #fff; font-weight: 700; font-size: 1.2rem;
  box-shadow: 0 8px 24px rgba(91, 124, 250, 0.35);
  flex-shrink: 0;
}
.brand-mark.sm { width: 36px; height: 36px; border-radius: 10px; font-size: 0.95rem; }
.login-card .error {
  color: var(--red); font-size: 0.88rem; min-height: 1.2em;
  margin: 10px 0 0; text-align: left;
}
.login-card .btn-primary { width: 100%; margin-bottom: 0; }
.login-card label {
  display: block; font-size: 0.82rem; color: var(--text2);
  font-weight: 500; margin-bottom: 0.85rem;
}
.login-card form { margin: 0; }

/* layout shell — flex row: sidebar + scrollable main */
.layout {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  min-height: 100vh;
  height: 100vh;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
}
.sidebar {
  flex: 0 0 var(--sidebar-w, 260px);
  width: var(--sidebar-w, 260px);
  max-width: var(--sidebar-w, 260px);
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
  position: relative;
  z-index: 40;
}
.main,
.layout > main.main {
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
  width: auto;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  margin: 0;
  padding: clamp(18px, 2.5vw, 36px);
}
.main > * {
  max-width: min(1280px, 100%);
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
/* Dashboard uses full available width beside sidebar */
.main[data-page="dashboard"] > * {
  max-width: none;
  width: 100%;
}

/* Sidebar nav groups — custom details accordion */
.sidebar details.nav-section,
.sidebar details {
  border: none;
  margin: 0;
  padding: 0;
  background: transparent;
}
.sidebar details summary {
  list-style: none;
  background: transparent;
  border: none;
  width: auto;
  margin: 0;
}
.sidebar details summary::-webkit-details-marker { display: none; }
.sidebar details summary::after { /* chevron handled by .nav-section rules */ }
.sidebar nav a,
.sidebar nav a:link,
.sidebar nav a:visited {
  text-decoration: none;
  width: auto;
  margin-bottom: 0;
}
.sidebar .bot-controls .btn,
.sidebar .bot-pill {
  width: auto;
  margin-bottom: 0;
}

/* ── Mobile nav (drawer) — hidden on desktop ── */
.mobile-topbar { display: none; }
.nav-toggle { background: transparent; border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); padding: 6px 10px; font-size: 1.1rem; cursor: pointer; }
.nav-backdrop { display: none; }
.filter-input { width: 240px; }

/* ── Stats grid ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-card .label { font-size: 0.8rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card .value { font-size: 1.8rem; font-weight: 700; margin-top: 4px; }
.stat-card .value.green { color: var(--green); }
.stat-card .value.red { color: var(--red); }

/* ── Charts ── */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.chart-container { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.chart-container h3 { font-size: 0.9rem; color: var(--text2); margin-bottom: 12px; }
.chart-container canvas { max-height: 300px; }

/* Dense table extras */
td.amount { font-variant-numeric: tabular-nums; text-align: right; }
td .tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; background: var(--surface2); color: var(--text2); }

/* ── Modal (custom overlay; panel uses surface tokens) ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(5px); animation: overlay-in 0.14s ease; }
.modal { display: block; position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 32px; width: 480px; max-width: 90vw; max-height: 80vh; overflow-y: auto; }
.modal h2 { font-size: 1.2rem; margin-bottom: 12px; padding-right: 28px; }
.modal-close { position: absolute; top: 12px; right: 16px; background: transparent; border: none; color: var(--text2); font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 4px; border-radius: 6px; }
.modal-close:hover { color: var(--text); background: var(--surface2); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 24px; }
.modal-wide { width: min(920px, 96vw); }
.modal-split { display: grid; grid-template-columns: minmax(200px, 1fr) minmax(260px, 1.2fr); gap: 24px; align-items: start; }

.image-overlay-close { position: absolute; top: 16px; right: 24px; background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.2); color: #fff; font-size: 1.5rem; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 10000; }
.image-overlay-close:hover { background: rgba(255,255,255,0.15); }

.dup-compare-list { display: flex; flex-direction: column; gap: 16px; margin-top: 12px; }
.dup-compare-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.dup-card { padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }
.dup-card-title { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text2); margin-bottom: 8px; }
.dup-card-merchant { font-weight: 700; font-size: 1rem; margin-bottom: 4px; }
.dup-card-detail { font-size: 0.85rem; color: var(--text2); margin-top: 2px; }
.dup-card-meta { display: flex; gap: 6px; margin-top: 8px; }
.dup-actions { display: flex; flex-direction: column; gap: 8px; justify-content: center; align-items: stretch; }
.dup-actions-divider { height: 1px; background: var(--border); margin: 4px 0; }
.dup-current { border-left: 3px solid var(--accent); }
.dup-match { border-left: 3px solid var(--orange); border-color: var(--orange); }
.modal-split-single { grid-template-columns: 1fr; }
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 1.25rem; height: 1.25rem; padding: 0 5px; margin-left: 4px; border-radius: 99px; font-size: 0.7rem; font-weight: 700; background: var(--orange); color: #1a1200; vertical-align: middle; }

/* ── Search/Filter ── */
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input { width: 260px; }

/* ── Pagination ── */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.pagination button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm, 8px);
  cursor: pointer;
  width: auto;
  margin: 0;
  min-height: 36px;
}
.pagination button:hover { background: var(--surface2); }
.pagination button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pagination span { color: var(--text2); font-size: 0.85rem; }

/* ── Setup guide ── */
.setup-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 24px; flex-wrap: wrap; }
.setup-progress-wrap { min-width: 220px; }
.setup-progress-label { font-size: 0.85rem; color: var(--text2); margin-bottom: 6px; text-align: right; }
.setup-progress { height: 8px; background: var(--surface2); border-radius: 99px; overflow: hidden; }
.setup-progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--green)); transition: width 0.3s; }

.key-status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }
.key-status-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.key-status-card.configured { border-color: rgba(52,211,153,0.4); }
.key-status-title { font-size: 0.8rem; color: var(--text2); margin-bottom: 8px; }
.key-masked { font-family: monospace; font-size: 0.75rem; color: var(--text2); margin-top: 6px; }
.required { color: var(--orange); }

.setup-steps { display: flex; flex-direction: column; gap: 20px; }
.setup-step { margin-bottom: 0; }
.step-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 16px; cursor: pointer; user-select: none; }
.step-head:hover h2 { color: var(--accent); }
.step-toggle { margin-left: auto; flex-shrink: 0; width: 16px; height: 16px; position: relative; align-self: center; transition: transform 0.18s ease; opacity: 0.6; }
.step-toggle::before { content: ''; position: absolute; left: 3px; top: 1px; border: solid currentColor; border-width: 0 2px 2px 0; width: 7px; height: 7px; transform: rotate(45deg); }
.setup-step.collapsed .step-toggle { transform: rotate(-90deg); }
.setup-step.collapsed .step-head { margin-bottom: 0; }
.setup-step.collapsed > :not(.step-head) { display: none; }
.step-num { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.step-head h2 { font-size: 1.1rem; margin-bottom: 6px; }
.step-instructions { margin: 0 0 16px 1.2rem; color: var(--text2); font-size: 0.9rem; }
.step-instructions li { margin-bottom: 8px; }
.step-instructions code { background: var(--surface2); padding: 2px 6px; border-radius: 4px; font-size: 0.85rem; }
.step-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.test-result { margin-top: 12px; }

.sync-quickstart { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 20px; }
.sync-quickstart-card {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; font-size: 0.85rem; color: var(--text2); line-height: 1.45;
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.sync-quickstart-card:hover { border-color: var(--accent); }
.sync-quickstart-card h4 { font-size: 0.9rem; color: var(--text); margin-bottom: 8px; }
.sync-quickstart-card.active { border-color: var(--accent); background: rgba(108,140,255,0.08); }
.sync-quickstart-card.recommended h4::after { content: ' · recommended'; color: var(--green); font-weight: 600; font-size: 0.75rem; }
.sync-quickstart-steps { margin: 0; padding-left: 1.1rem; }
.sync-quickstart-steps li { margin-bottom: 4px; }
.sync-restart-note {
  margin-top: 16px; padding: 12px 14px; border-radius: var(--radius);
  background: rgba(251,191,36,0.1); border: 1px solid rgba(251,191,36,0.3); color: var(--text); font-size: 0.875rem;
}
.sync-csv-only-panel {
  margin-bottom: 16px; padding: 14px 16px; border-radius: var(--radius);
  background: rgba(52,211,153,0.08); border: 1px solid rgba(52,211,153,0.25); font-size: 0.9rem;
}

.badge { display: inline-block; font-size: 0.75rem; padding: 3px 10px; border-radius: 99px; font-weight: 600; }
.badge-ok { background: rgba(52,211,153,0.15); color: var(--green); }
.badge-pending { background: rgba(251,191,36,0.15); color: var(--orange); }
.badge-failed { background: rgba(248,113,113,0.15); color: var(--red); }

/* ── Bot status pill ── */
.bot-pill { display: flex; align-items: center; gap: 8px; margin: 0 20px 16px; padding: 6px 12px; border-radius: 99px; font-size: 0.8rem; font-weight: 600; border: 1px solid var(--border); background: var(--surface2); }
.bot-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.bot-pill .bot-pill-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot-pill-running { color: var(--green); }
.bot-pill-running .bot-dot { background: var(--green); box-shadow: 0 0 6px var(--green); }
.bot-pill-error, .bot-pill-stopped { color: var(--red); }
.bot-pill-error .bot-dot, .bot-pill-stopped .bot-dot { background: var(--red); }
.bot-pill-disabled, .bot-pill-unknown { color: var(--text2); }
.bot-pill-disabled .bot-dot, .bot-pill-unknown .bot-dot { background: var(--text2); }
.bot-controls { display: flex; gap: 6px; margin: 0 20px 18px; }
.bot-btn { flex: 1; justify-content: center; background: transparent; color: var(--text2); border: 1px solid var(--border); }
.bot-btn:hover:not(:disabled) { background: var(--surface2); color: var(--text); }
.bot-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.action-btns { display: flex; flex-wrap: wrap; gap: 4px; }

.secret-field { display: flex; gap: 8px; align-items: center; }
.secret-field input { flex: 1; }

.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 0.9rem; }
.alert-success { background: rgba(52,211,153,0.12); border: 1px solid rgba(52,211,153,0.35); color: var(--green); }
.alert-error { background: rgba(248,113,113,0.12); border: 1px solid rgba(248,113,113,0.35); color: var(--red); }
.alert-info { background: rgba(91,124,250,0.12); border: 1px solid rgba(91,124,250,0.35); color: var(--accent); }
#config-flash { margin: 0 0 16px; padding: 10px 14px; border-radius: var(--radius); }
.card-header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-header-row h3 { margin: 0; }

/* ── Logs ── */
.log-level { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; }
.log-error { background: rgba(248,113,113,0.2); color: var(--red); }
.log-warn { background: rgba(251,191,36,0.2); color: var(--orange); }
.log-info { background: rgba(108,140,255,0.2); color: var(--accent); }
.log-details { max-width: 320px; white-space: normal; font-size: 0.8rem; color: var(--text2); word-break: break-word; }

/* ── Config page ── */
.config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.config-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.config-section h3 { font-size: 1rem; margin-bottom: 16px; }
.config-section .form-group.half { display: inline-block; width: calc(50% - 6px); }
.config-section .form-group.half:first-child { margin-right: 12px; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .layout { flex-direction: column; }

  /* Hamburger drawer (T3) */
  .mobile-topbar { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 150; }
  .sidebar { position: fixed; top: 0; left: 0; height: 100%; width: 260px; max-width: 80vw; transform: translateX(-100%); transition: transform 0.2s ease; z-index: 200; padding-top: 16px; box-shadow: none; }
  .sidebar.open { transform: none; box-shadow: 2px 0 20px rgba(0,0,0,0.4); }
  .nav-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 190; }

  /* Stacked page headers (T4) */
  .main .flex.justify-between { flex-direction: column; align-items: stretch; gap: 12px; }
  .main .flex.justify-between > .flex { flex-wrap: wrap; gap: 8px; }

  /* Toolbar inputs (T5) */
  .filter-input { width: 100%; }

  /* Login (T6) */
  .login-card { padding: 24px; }

  /* Modal + stats polish (T7) */
  .modal { width: 100%; max-width: none; padding: 20px; }
  .modal-actions { flex-wrap: wrap; }
  .dup-compare-row { grid-template-columns: 1fr; gap: 10px; }
  .dup-actions { flex-direction: row; flex-wrap: wrap; justify-content: center; margin: 4px 0; }
  .image-overlay-close { top: 8px; right: 8px; }
  .stat-card .value { font-size: 1.4rem; }
  .chart-container canvas { max-height: 240px; }

  /* Touch scroll for tables (T8) */
  .table-wrap { -webkit-overflow-scrolling: touch; }

  .main { padding: 16px; }
  .chart-grid { grid-template-columns: 1fr; }
  .config-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Utilities ── */
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.text-2 { color: var(--text2); font-size: 0.85rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Budget bars ── */
.budget-bar-wrap { display:flex;align-items:center;gap:12px; }
.budget-bar { flex:1;height:12px;background:var(--surface2);border-radius:99px;overflow:hidden; }
.budget-bar-fill { height:100%;border-radius:99px;transition:width 0.3s; }
.budget-bar-green { background:var(--green); }
.budget-bar-yellow { background:var(--orange); }
.budget-bar-red { background:var(--red); }

/* ── Split cards ── */
.split-card { background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:16px;margin-bottom:12px; }
.split-card .split-amount { font-size:1.2rem;font-weight:700; }
.split-card .split-note { color:var(--text2);font-size:0.85rem; }

/* ── Import preview ── */
.import-preview-table { font-size:0.8rem; }
.import-preview-table td, .import-preview-table th { padding:6px 8px; }

/* ── Alias grid ── */
.alias-form-grid { display:grid;grid-template-columns:1fr 1fr 1fr auto;gap:12px;align-items:end; }
@media (max-width:768px) {
  .alias-form-grid { grid-template-columns:1fr; }
  .budget-bar-wrap { flex-direction:column;align-items:stretch; }
}

/* ── Toasts (app-toast-* avoids Bootstrap 5 .toast:not(.show){display:none}) ── */
.app-toast-stack { position: fixed; bottom: 24px; right: 24px; z-index: 10050; display: flex; flex-direction: column; gap: 10px; max-width: min(360px, calc(100vw - 32px)); pointer-events: none; }
.app-toast-stack .app-toast { pointer-events: auto; }
.app-toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  font-size: 0.875rem; line-height: 1.4; animation: toast-in 0.25s ease; word-break: break-word;
}
.app-toast.leaving { animation: toast-out 0.2s ease forwards; }
.app-toast-success { border-left: 3px solid var(--green); }
.app-toast-error { border-left: 3px solid var(--red); }
.app-toast-info { border-left: 3px solid var(--accent); }
.app-toast-icon { font-size: 1rem; line-height: 1.2; flex-shrink: 0; }
.app-toast-success .app-toast-icon { color: var(--green); }
.app-toast-error .app-toast-icon { color: var(--red); }
.app-toast-info .app-toast-icon { color: var(--accent); }
.app-toast-body { flex: 1; }
.app-toast-close { background: transparent; border: none; color: var(--text2); cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0 2px; flex-shrink: 0; }
.app-toast-close:hover { color: var(--text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(40px); } }

/* ── Skeletons ── */
.skeleton { background: linear-gradient(90deg, var(--surface2) 25%, #2f3346 50%, var(--surface2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 4px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skeleton-row td { padding: 14px 12px; border-bottom: 1px solid var(--border); }

/* ── Empty states ── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text2); }
.empty-state-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.6; }
.empty-state-title { font-size: 1.05rem; color: var(--text); margin-bottom: 6px; font-weight: 600; }
.empty-state-sub { font-size: 0.875rem; margin-bottom: 16px; }

/* ── Custom confirm modal ── */
.confirm-modal-body { margin: 8px 0 4px; font-size: 0.95rem; line-height: 1.5; }

.nav-group-label { padding: 14px 20px 4px; font-size: 0.68rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.08em; }
@media (max-width: 768px) { .nav-group-label { padding-top: 10px; } }

/* ── Sortable columns ── */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--accent); }
.sort-arrow { font-size: 0.7rem; }

/* ── Keyboard shortcuts ── */
kbd { display:inline-block;padding:2px 6px;border:1px solid var(--border);border-radius:4px;font-size:0.8rem;font-family:monospace;color:var(--text2);background:var(--surface2); }

/* ── Mobile table cards ── */
@media (max-width: 768px) {
  table { display: block; }
  thead { display: none; }
  tbody { display: block; }
  tbody tr {
    display: block; padding: 12px; margin-bottom: 8px; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--surface);
  }
  tbody td {
    display: flex; justify-content: space-between; align-items: center;
    padding: 4px 0; border: none; white-space: normal; text-align: right;
    font-size: 0.85rem;
  }
  tbody td::before { content: attr(data-label); font-weight: 600; color: var(--text2); text-align: left; margin-right: 8px; }
  tbody td:last-child { justify-content: flex-end; }
  tbody td.amount { justify-content: flex-end; font-weight: 700; }

}

/* ── Chat ── */
.chat-layout {
  --chat-canvas: #0d111c;
  --chat-panel: #151d2b;
  --chat-panel-hover: #1c2535;
  --chat-incoming: #1a2637;
  --chat-outgoing: #2b6ba8;
  --chat-outgoing-hover: #3278b8;
  display: flex; height: calc(100vh - 142px); min-height: 480px;
  overflow: hidden; background: var(--chat-canvas);
}
.chat-sidebar { width: 330px; flex-shrink: 0; background: var(--chat-panel); border-right: 1px solid #1a2434; overflow: hidden; display: flex; flex-direction: column; }
.chat-sidebar-head { padding: 14px 12px 10px; display: flex; flex-direction: column; gap: 10px; }
.chat-sidebar-title { display: flex; justify-content: space-between; align-items: center; color: #f0f3fa; font-size: 0.85rem; font-weight: 700; letter-spacing: 0.01em; }
.chat-filter-group { display: flex; gap: 3px; background: #101622; border-radius: 8px; padding: 3px; }
.chat-filter-group button { flex: 1; padding: 6px 10px; border: 0; border-radius: 6px; background: transparent; color: #5a6a7e; font-size: 0.78rem; font-weight: 600; cursor: pointer; transition: all 0.15s ease; font-family: inherit; }
.chat-filter-group button:hover { color: #d8e8f5; }
.chat-filter-group button.active { background: #2b5278; color: #fff; }
.chat-inbox-list { overflow-y: auto; flex: 1; }
.chat-inbox-list::-webkit-scrollbar { width: 4px; }
.chat-inbox-list::-webkit-scrollbar-track { background: transparent; }
.chat-inbox-list::-webkit-scrollbar-thumb { background: #2a3344; border-radius: 99px; }
.chat-user-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 72px; padding: 10px 12px; cursor: pointer; font: inherit; color: #dfe4ef; text-align: left; background: transparent; border: 0; border-bottom: 1px solid #1a2434; transition: background-color 0.12s ease; }
.chat-user-item:hover { background: var(--chat-panel-hover); }
.chat-user-item:focus-visible { outline: 2px solid #4d9bd4; outline-offset: -3px; }
.chat-user-item.active { background: #18273c; position: relative; }
.chat-user-item.active::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; background: #4d9bd4; border-radius: 0 3px 3px 0; }
.chat-user-avatar-wrap { position: relative; flex: 0 0 48px; width: 48px; height: 48px; }
.chat-user-avatar { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: linear-gradient(145deg, #5da7d8, #3979a9); color: #fff; font-size: 0.85rem; font-weight: 750; }
.chat-user-avatar-wrap .status-dot { position: absolute; bottom: 0; right: 0; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--chat-panel); }
.status-dot.online { background: #4fae4e; }
.status-dot.offline { background: #3a4a5e; }
.active .status-dot.offline { border-color: #18273c; }
.active .status-dot.online { border-color: #18273c; }
.chat-user-content { min-width: 0; flex: 1; overflow: hidden; }
.chat-user-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-user-name { font-weight: 650; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-user-time { color: #5a6a7e; font-size: 0.69rem; white-space: nowrap; flex-shrink: 0; }
.chat-user-lower { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.chat-user-preview { flex: 1; min-width: 0; font-size: 0.8rem; color: #5a6a7e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-unread-pill { min-width: 1.3rem; height: 1.3rem; padding: 0 5px; border-radius: 99px; background: #4fae4e; color: #fff; font-size: 0.66rem; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.chat-user-meta { display: flex; gap: 5px; margin-top: 4px; flex-wrap: wrap; }
.chat-user-meta:empty { display: none; }
.active .chat-user-time, .active .chat-user-preview { color: #8ca0b8; }
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--chat-canvas); background-image: radial-gradient(circle at 18px 18px, rgba(84,120,148,.05) 1.2px, transparent 1.4px), radial-gradient(circle at 48px 52px, rgba(84,120,148,.035) 1px, transparent 1.2px); background-size: 72px 72px; overflow: hidden; }
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: var(--chat-panel); min-height: 56px; }
.chat-header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-header-avatar { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: linear-gradient(145deg, #5da7d8, #3979a9); color: #fff; font-size: 0.8rem; font-weight: 750; flex-shrink: 0; }
.chat-header-info { min-width: 0; }
.chat-header-name { font-weight: 700; font-size: 0.95rem; color: #eef1f7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-header-status { font-size: 0.72rem; color: #5a6a7e; margin-top: 1px; }
.chat-header-status .sdot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.sdot.online { background: #4fae4e; }
.sdot.offline { background: #3a4a5e; }
.chat-header-actions { display: flex; gap: 6px; flex-shrink: 0; }
.chat-toolbar { display: flex; gap: 7px; padding: 8px 16px; background: var(--chat-panel); align-items: center; }
.chat-search-wrap { flex: 1; position: relative; min-width: 0; }
.chat-search-wrap .search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: #3a4a5e; font-size: 0.8rem; pointer-events: none; }
.chat-search { width: 100%; padding: 7px 11px 7px 32px; border-radius: 18px; border: 1px solid transparent; background: #101622; color: #edf0f7; font-size: 0.82rem; font-family: inherit; outline: none; transition: border-color 0.15s, background-color 0.15s; }
.chat-search::placeholder { color: #3a4a5e; }
.chat-search:focus { border-color: #4d9bd4; background: #18273c; }
.chat-filter-select { padding: 7px 28px 7px 10px; border-radius: 18px; border: 1px solid transparent; background: #101622; color: #8495a7; font-size: 0.82rem; font-family: inherit; outline: none; appearance: none; -webkit-appearance: none; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235a6a7e' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; transition: border-color 0.15s; }
.chat-filter-select:focus { border-color: #4d9bd4; }
.chat-messages { flex: 1; overflow-y: auto; padding: 14px clamp(14px, 5vw, 72px); display: flex; flex-direction: column; gap: 6px; scroll-behavior: smooth; }
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: #1a2434; border-radius: 99px; }
.chat-empty { margin: auto; max-width: 320px; text-align: center; color: #3a4a5e; padding: 48px 24px; font-size: 0.88rem; }
.chat-empty strong { display: block; color: #5a6a7e; font-size: 1rem; margin-bottom: 6px; }
.chat-empty .empty-icon { font-size: 2.8rem; margin-bottom: 12px; opacity: 0.3; }
.chat-date-sep { text-align: center; margin: 8px 0 4px; font-size: 0.72rem; color: #3a4a5e; font-weight: 600; }
.chat-date-sep span { background: var(--chat-panel); padding: 3px 12px; border-radius: 99px; }
.chat-load-more { text-align: center; margin-bottom: 6px; }
.chat-load-more button { display: inline-flex; align-items: center; gap: 5px; padding: 6px 16px; border: 1px solid #1a2434; border-radius: 99px; background: transparent; color: #3a4a5e; font-size: 0.78rem; font-family: inherit; font-weight: 600; cursor: pointer; transition: all 0.15s ease; }
.chat-load-more button:hover { color: #8495a7; background: rgba(255,255,255,.03); }
.chat-bubble { position: relative; max-width: min(72%, 620px); padding: 7px 10px 5px; border-radius: 9px; font-size: 0.875rem; line-height: 1.38; animation: bubble-in 0.14s ease-out both; box-shadow: 0 1px 2px rgba(0,0,0,.25); word-break: break-word; }
@keyframes bubble-in { from { opacity: 0; transform: translateY(3px) scale(.98); } to { opacity: 1; transform: none; } }
.chat-bubble-in { align-self: flex-start; background: var(--chat-incoming); color: #eef1f7; border-bottom-left-radius: 3px; }
.chat-bubble-in::after { content: ''; position: absolute; bottom: 0; left: -7px; width: 8px; height: 10px; background: linear-gradient(135deg, transparent 50%, var(--chat-incoming) 51%); }
.chat-bubble-out { align-self: flex-end; background: linear-gradient(145deg, #25609a, #1d4f7d); color: #fff; border-bottom-right-radius: 3px; }
.chat-bubble-out::after { content: ''; position: absolute; bottom: 0; right: -7px; width: 8px; height: 10px; background: linear-gradient(225deg, transparent 50%, #25609a 51%); }
.chat-bubble-text { white-space: pre-wrap; word-break: break-word; }
.chat-bubble-meta { display: flex; gap: 4px; justify-content: flex-end; align-items: center; margin: 2px 0 -1px 12px; font-size: 0.65rem; color: #5a6a7e; line-height: 1; }
.chat-bubble-out .chat-bubble-meta { color: #8cb8d8; }
.chat-delivery { color: #6fcaef; font-size: 0.68rem; letter-spacing: -3px; }
.chat-expense-card { margin-top: 7px; border-radius: 6px; background: rgba(5,12,19,.42); border-left: 3px solid #4d9bd4; overflow: visible; }
.chat-bubble-out .chat-expense-card { background: rgba(14,38,61,.38); border-color: #6ab2e3; }
.chat-expense-main { padding: 7px 9px 4px; font-size: 0.82rem; }
.chat-expense-main .exp-merchant { font-weight: 650; color: #eef1f7; }
.chat-expense-main .exp-amount { font-weight: 700; color: #fff; }
.chat-expense-main .exp-ref { color: #5a6a7e; font-size: 0.75rem; }
.chat-expense-main .exp-conf { display: inline-block; font-size: 0.68rem; font-weight: 700; padding: 1px 6px; border-radius: 99px; margin-left: 4px; }
.exp-conf.high { background: rgba(79,174,78,.15); color: #7ddf7d; }
.exp-conf.med { background: rgba(255,193,7,.15); color: #ffd54f; }
.chat-expense-main .exp-status { display: inline-flex; align-items: center; gap: 3px; font-size: 0.68rem; color: #5a6a7e; }
.exp-status.synced { color: #7ddf7d; }
.exp-status.pending { color: #ffd54f; }
.chat-expense-footer { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 2px 9px 6px; }
.chat-expense-footer .btn-xs { padding: 3px 9px; border: 1px solid rgba(255,255,255,.12); border-radius: 12px; background: rgba(0,0,0,0.08); color: #8495a7; font-size: 0.75rem; font-family: inherit; cursor: pointer; transition: all 0.12s; line-height: 1.6; }
.chat-expense-footer .btn-xs:hover { background: rgba(255,255,255,.08); color: #eef1f7; }
.chat-bubble-out .chat-expense-footer .btn-xs { border-color: rgba(255,255,255,.2); background: rgba(15,24,55,.14); }
.more-wrap { position: relative; display: inline-block; }
.more-btn { padding: 3px 8px; border: 1px solid rgba(255,255,255,.12); border-radius: 12px; background: rgba(0,0,0,0.08); color: #5a6a7e; font-size: 0.75rem; font-family: inherit; cursor: pointer; transition: all 0.12s; line-height: 1.6; }
.more-btn:hover { background: rgba(255,255,255,.08); color: #eef1f7; }
.chat-bubble-out .more-btn { border-color: rgba(255,255,255,.2); background: rgba(15,24,55,.14); color: #8cb8d8; }
.more-menu { display: none; position: fixed; min-width: 130px; background: #151d2b; border: 1px solid #1e2a3a; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.5); z-index: 10; padding: 4px; }
.more-menu.open { display: block; }
.more-menu button { display: block; width: 100%; padding: 6px 10px; border: 0; border-radius: 5px; background: transparent; color: #8495a7; font-size: 0.78rem; font-family: inherit; text-align: left; cursor: pointer; transition: background 0.1s; }
.more-menu button:hover { background: #1e2a3a; color: #eef1f7; }
.chat-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.chat-reply-chip { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 16px; border-left: 3px solid #4d9bd4; background: var(--chat-panel); font-size: 0.82rem; color: #d5dbea; }
.chat-reply-chip .rlabel { font-weight: 600; color: #4d9bd4; flex-shrink: 0; }
.chat-reply-chip .rpreview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; color: #5a6a7e; }
.chat-reply-chip .rclose { padding: 2px 6px; border: 0; border-radius: 4px; background: transparent; color: #3a4a5e; font-size: 1rem; cursor: pointer; flex-shrink: 0; transition: color 0.12s; }
.chat-reply-chip .rclose:hover { color: #eef1f7; }
.chat-input-bar { display: flex; align-items: flex-end; gap: 8px; padding: 10px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom)); background: var(--chat-panel); }
.chat-input { flex: 1; resize: none; min-height: 42px; max-height: 160px; border-radius: 21px; padding: 10px 16px; background: #101622; border: 1px solid transparent; color: #f1f3f8; font-size: 0.9rem; font-family: inherit; outline: none; transition: border-color 0.15s, box-shadow 0.15s; line-height: 1.4; }
.chat-input::placeholder { color: #3a4a5e; }
.chat-input:focus { border-color: #4d9bd4; box-shadow: 0 0 0 2px rgba(77,155,212,.12); }
.chat-send-btn { width: 42px; height: 42px; min-width: 42px; padding: 0; border-radius: 50%; border: 0; display: flex; align-items: center; justify-content: center; background: #4d9bd4; color: #fff; font-size: 1.1rem; cursor: pointer; transition: all 0.15s ease; }
.chat-send-btn:hover { background: #5aa8df; box-shadow: 0 0 12px rgba(77,155,212,.3); }
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.chat-mobile-back { display: none; }
.chat-inbox-error { padding: 14px 16px; color: #ff9b9b; font-size: 0.82rem; }

@media (max-width: 768px) {
  .chat-layout { display: block; height: calc(100svh - 112px); min-height: 440px; }
  .chat-sidebar { width: 100%; height: 100%; border-right: 0; }
  .chat-main { display: none; height: 100%; }
  .chat-layout.has-selection .chat-sidebar { display: none; }
  .chat-layout.has-selection .chat-main { display: flex; animation: slide-in 0.2s ease-out; }
  @keyframes slide-in { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
  .chat-mobile-back { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 0; border-radius: 8px; background: #101622; color: #eef1f7; cursor: pointer; flex-shrink: 0; font-size: 1.1rem; }
  .chat-header { padding: 8px 12px; min-height: 50px; }
  .chat-toolbar { padding: 8px 12px; flex-wrap: wrap; }
  .chat-search { width: 100%; }
  .chat-bubble { max-width: 88%; }
  .chat-messages { padding: 12px 10px; }
  .chat-input-bar { padding: 8px 12px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .chat-bubble { animation: none; }
  .chat-layout.has-selection .chat-main { animation: none; }
}

/* ── Operations workspace v2 ── */
button, input, select, textarea { font: inherit; }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.skip-link { position: fixed; left: 16px; top: 12px; z-index: 10000; padding: 9px 12px; border-radius: 8px; background: #fff; color: #111; transform: translateY(-150%); transition: transform 0.15s; }
.skip-link:focus { transform: none; }

.sidebar { width: var(--sidebar-w, 260px); display: flex; flex-direction: column; padding: 0; background: #10141c; flex: 0 0 var(--sidebar-w, 260px); }
.sidebar-brand { display: flex; align-items: center; gap: 11px; min-height: 72px; padding: 15px 18px; border-bottom: 1px solid var(--border-subtle); }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 9px; background: var(--action); color: #fff; font-weight: 800; }
.sidebar-brand strong { display: block; font-size: 0.94rem; }
.sidebar-brand small { display: block; margin-top: 1px; color: var(--text-secondary); font-size: 0.7rem; letter-spacing: 0.04em; text-transform: uppercase; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.sidebar nav a { min-height: 38px; padding: 8px 10px; margin: 1px 0; border: 0; border-radius: 7px; font-size: 0.84rem; }
.sidebar nav a:hover { background: var(--panel-hover); }
.sidebar nav a.active { background: var(--selection); color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
.nav-primary { padding-bottom: 9px; border-bottom: 1px solid var(--border-subtle); margin-bottom: 8px; }
.nav-icon { width: 19px; color: #aeb9cb; text-align: center; font-weight: 700; }
.nav-section { margin: 2px 0; }
.nav-section summary { padding: 9px 10px 6px; color: #7f899b; cursor: pointer; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; list-style: none; }
.nav-section summary::-webkit-details-marker { display: none; }
.nav-section summary::after { content: '›'; float: right; transform: rotate(0); transition: transform 0.15s; }
.nav-section[open] summary::after { transform: rotate(90deg); }
.nav-section a { padding-left: 14px !important; }
.sidebar-status { position: relative; padding: 10px; border-top: 1px solid var(--border-subtle); }
.sidebar-status .bot-pill { width: 100%; margin: 0; justify-content: flex-start; cursor: pointer; }
.sidebar-status .bot-pill-label { flex: 1; text-align: left; }
.bot-menu { position: absolute; left: 10px; right: 10px; bottom: calc(100% + 6px); padding: 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: #1a202c; box-shadow: 0 16px 36px rgba(0,0,0,0.4); }
.bot-menu[hidden] { display: none; }
.bot-menu p { margin-bottom: 9px; color: var(--text-secondary); font-size: 0.76rem; }
.bot-menu .bot-controls { margin: 0; }

.main { padding: clamp(22px, 3vw, 42px); flex: 1 1 auto; min-width: 0; }
.main > * { max-width: min(1280px, 100%); margin-left: 0; margin-right: auto; }
.main[data-page="dashboard"] > * { max-width: none; margin-right: 0; }
.page-enter { animation: page-enter 0.16s ease-out; }
@keyframes page-enter { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 26px; }
.page-heading h1 { font-size: clamp(1.55rem, 2.3vw, 2rem); line-height: 1.15; letter-spacing: -0.035em; }
.page-heading p { max-width: 650px; margin-top: 7px; color: var(--text-secondary); font-size: 0.88rem; }
.page-meta { margin-top: 8px; color: #758095; font-size: 0.74rem; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.legacy-page-header { margin-bottom: 24px !important; }
.legacy-page-header > h1 { font-size: clamp(1.5rem, 2.2vw, 1.9rem); letter-spacing: -0.03em; }
.page-description { max-width: 680px; margin-top: 6px; color: var(--text-secondary); font-size: 0.86rem; }
.scope-select { width: auto; min-width: 190px; }
.loading-block { display: flex; justify-content: center; align-items: center; gap: 10px; min-height: 110px; color: var(--text-secondary); font-size: 0.86rem; }
.loading-spinner { width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.card, .config-section, .split-card, .review-card { background: var(--panel); border-color: var(--border-subtle); box-shadow: none; }
.card h3, .config-section h3 { color: var(--text-primary); text-transform: none; letter-spacing: -0.01em; }
.workspace-section { padding: 20px 22px; border: 1px solid var(--border-subtle); border-radius: 11px; background: var(--panel); }
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 17px; }
.section-head h2 { font-size: 0.98rem; letter-spacing: -0.015em; }
.section-head p { color: var(--text-secondary); font-size: 0.78rem; margin-top: 3px; }
.section-meta { color: var(--text-secondary); font-size: 0.72rem; font-weight: 500; }

.metric-band { display: grid; grid-template-columns: 1.25fr repeat(3, 1fr); margin-bottom: 20px; border: 1px solid var(--border-subtle); border-radius: 11px; background: var(--panel); overflow: hidden; }
.metric { min-width: 0; padding: 20px; border-left: 1px solid var(--border-subtle); }
.metric:first-child { border-left: 0; }
.metric-label, .metric-note { display: block; color: var(--text-secondary); font-size: 0.73rem; }
.metric strong { display: block; margin: 6px 0 4px; font-size: clamp(1.18rem, 2vw, 1.6rem); font-variant-numeric: tabular-nums; letter-spacing: -0.035em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-primary strong { color: #8eacff; }
.metric .metric-merchant { font-size: 1rem; }
.trend-up { color: var(--red); }
.trend-down { color: var(--green); }
.trend-flat { color: var(--text2); }
.trend-new { color: var(--accent2); }

.dash-quick-actions {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px;
}
.dash-quick-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border: 1px solid var(--border-subtle); border-radius: 9px;
  background: var(--panel); color: var(--text-secondary); font-size: 0.82rem; font-weight: 600;
  text-decoration: none; transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.dash-quick-btn:hover {
  background: var(--surface2); border-color: var(--border-strong); color: var(--text-primary);
  text-decoration: none;
}
.dash-quick-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.25rem; height: 1.25rem; border-radius: 6px;
  background: rgba(91, 124, 250, 0.25); color: var(--accent2); font-size: 0.72rem;
}

/* Dashboard full-width grid */
.dash-layout {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
  align-items: stretch;
}
.dash-cell-full { grid-column: 1 / -1; }
.dash-cell-attention { grid-column: span 3; min-height: 300px; }
.dash-cell-month { grid-column: span 9; min-height: 300px; }
.dash-cell-pie { grid-column: 1 / -1; min-height: 0; }
.dash-cell-recent { grid-column: span 4; }
.dash-cell-daily { grid-column: span 4; }
.dash-cell-merchants { grid-column: span 4; }
.dash-cell-intent { grid-column: span 4; min-height: 220px; }
.dash-cell-refunds { grid-column: span 4; min-height: 220px; }
.dash-cell-insights { grid-column: span 4; min-height: 220px; }
.dash-layout .workspace-section {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  margin: 0;
}
.dash-layout .section-head { flex-shrink: 0; margin-bottom: 12px; }
.dash-layout #attention-list,
.dash-layout #ms-body,
.dash-layout #dash-recent-list,
.dash-layout .category-mix-layout,
.dash-layout #dash-intent-body,
.dash-layout #dash-refunds-body,
.dash-layout #dash-insights-body,
.dash-layout .chart-frame {
  flex: 1 1 auto;
  min-height: 0;
}
.dash-cell-attention #attention-list {
  display: flex; flex-direction: column; justify-content: center;
}

.dash-subhead {
  margin: 12px 0 8px; font-size: 0.72rem; font-weight: 650;
  color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.06em;
}
.dash-merchant-list { min-width: 0; }
.dash-merchant-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center;
  padding: 6px 0; border-bottom: 1px solid var(--border-subtle);
}
.dash-merchant-row:last-child { border-bottom: 0; }
.dash-merchant-rank {
  width: 1.25rem; height: 1.25rem; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; background: var(--surface2); color: var(--text3); font-size: 0.65rem; font-weight: 700;
}
.dash-merchant-name {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 0.84rem; color: var(--text-primary);
}
.dash-merchant-amt { font-size: 0.84rem; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; }

.dash-recent-row {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border-subtle);
  color: inherit; text-decoration: none;
}
.dash-recent-row:hover { background: var(--surface2); text-decoration: none; margin: 0 -6px; padding: 8px 6px; border-radius: 8px; }
.dash-recent-row:last-of-type { border-bottom: 0; }
.dash-recent-main { min-width: 0; }
.dash-recent-main strong {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 0.86rem; color: var(--text-primary);
}
.dash-recent-main small { display: block; margin-top: 2px; color: var(--text-secondary); font-size: 0.72rem; }
.dash-recent-amt { font-weight: 700; font-size: 0.86rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dash-recent-more {
  display: inline-block; margin-top: 10px; font-size: 0.78rem; font-weight: 600; color: var(--accent2);
}
.dash-recent-more:hover { color: var(--accent); }
.dash-empty { color: var(--text-secondary); font-size: 0.84rem; line-height: 1.5; }
.dash-empty a { color: var(--accent2); }

/* Category mix — full-width row, chart + ranked breakdown */
.category-mix-layout {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: 20px 36px;
  align-items: center;
  min-height: 300px;
  width: 100%;
}
.category-mix-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px 4px 4px 0;
}
.category-mix-row { min-width: 0; }
.category-mix-meta {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  align-items: center;
  font-size: 0.88rem;
  margin-bottom: 6px;
}
.category-mix-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.category-mix-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
  font-weight: 600;
}
.category-mix-pct {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.category-mix-amt {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.category-mix-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--border-subtle);
  overflow: hidden;
}
.category-mix-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  min-width: 2px;
  transition: width 0.25s ease;
}
.category-mix-empty {
  color: var(--text-secondary);
  font-size: 0.84rem;
  line-height: 1.5;
  padding: 8px 0;
}

/* Category doughnut — dashboard (large) */
.dash-cell-pie .chart-frame-pie {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 280px;
  height: 280px;
  max-height: none;
  overflow: visible;
}
.dash-cell-pie .chart-frame-pie canvas {
  width: 260px !important;
  height: 260px !important;
  max-width: 260px !important;
  max-height: 260px !important;
  margin: 0 auto;
}
.chart-frame-daily { min-height: 200px; max-height: 220px; height: 220px; }
.chart-frame-merchants { min-height: 200px; max-height: 220px; height: 220px; }
.chart-frame-trend { min-height: 240px; max-height: 280px; height: 260px; }

@media (max-width: 1400px) {
  .dash-cell-attention { grid-column: span 4; }
  .dash-cell-month { grid-column: span 8; }
}
@media (max-width: 900px) {
  .dash-cell-attention, .dash-cell-month { grid-column: 1 / -1; }
  .category-mix-layout {
    grid-template-columns: 1fr;
    min-height: 0;
    gap: 16px;
  }
  .dash-cell-pie .chart-frame-pie {
    min-height: 240px;
    height: 240px;
  }
  .dash-cell-pie .chart-frame-pie canvas {
    width: 220px !important;
    height: 220px !important;
    max-width: 220px !important;
    max-height: 220px !important;
  }
  .category-mix-list { max-height: none; }
}
@media (max-width: 1100px) {
  .dash-cell-attention, .dash-cell-month, .dash-cell-pie,
  .dash-cell-recent, .dash-cell-daily, .dash-cell-merchants,
  .dash-cell-intent, .dash-cell-refunds, .dash-cell-insights { grid-column: 1 / -1; }
  .metric-band { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.overview-grid { display: grid; grid-template-columns: minmax(280px, 0.85fr) minmax(360px, 1.15fr); gap: 18px; margin-bottom: 18px; }
.chart-frame-sm { min-height: 200px; }
.attention-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 10px 0; color: var(--text-primary); border-bottom: 1px solid var(--border-subtle); }
.attention-row:last-child { border-bottom: 0; }
.attention-row:hover { text-decoration: none; }
.attention-row small, .attention-clear small { display: block; color: var(--text-secondary); font-size: 0.75rem; margin-top: 2px; }
.attention-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); }
.attention-danger .attention-dot { background: var(--red); }
.attention-arrow { color: #758095; }
.attention-clear { display: flex; gap: 11px; align-items: center; color: var(--green); padding: 14px 0; }
.attention-clear strong { color: var(--text-primary); }
.chart-primary { margin-bottom: 18px; }
.chart-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.chart-frame { position: relative; min-height: 280px; }
.chart-primary .chart-frame { min-height: 320px; }

.filter-panel { margin-bottom: 14px; padding: 14px; border: 1px solid var(--border-subtle); border-radius: 10px; background: var(--panel); }
.filter-main { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(145px, 190px) minmax(145px, 180px) auto auto; gap: 9px; }
.search-field { display: flex; align-items: center; gap: 7px; min-width: 0; padding-left: 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface2); color: var(--text-secondary); }
.search-field input { padding-left: 0; border: 0; background: transparent; box-shadow: none !important; }
.filter-secondary { display: flex; align-items: flex-end; gap: 10px; margin-top: 11px; flex-wrap: wrap; }
.date-field label { display: block; margin-bottom: 3px; color: var(--text-secondary); font-size: 0.69rem; }
.date-field input { width: 145px; padding: 7px 9px; }
.preset-group { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-chip, .active-filter-chip { padding: 5px 9px; border: 1px solid var(--border); border-radius: 99px; background: transparent; color: var(--text-secondary); font-size: 0.72rem; cursor: pointer; }
.filter-chip:hover { color: var(--text-primary); border-color: var(--border-strong); }
.active-filters { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.active-filters:empty { display: none; }
.active-filter-label { color: var(--text-secondary); font-size: 0.7rem; }
.active-filter-chip { background: var(--selection); border-color: rgba(111,143,244,0.3); color: #cbd6ff; cursor: default; }
.result-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 10px 0; color: var(--text-secondary); font-size: 0.78rem; }
.result-actions { display: flex; align-items: center; gap: 8px; }
.rows-per-page {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  white-space: nowrap;
}
.rows-per-page label {
  margin: 0;
  font-size: inherit;
  color: inherit;
}
.result-actions select,
.per-page-select,
#exp-per-page {
  width: auto !important;
  min-width: 4.5rem;
  max-width: 100%;
  flex-shrink: 0;
  padding: 6px 28px 6px 10px;
}

.table-wrap { border: 1px solid var(--border-subtle); border-radius: 10px; background: var(--panel); }
.data-table th { position: sticky; top: 0; z-index: 2; padding: 11px 12px; background: #151a24; border-bottom-color: var(--border-strong); }
.data-table td { padding: 11px 12px; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: #171e2a; }
td.amount { font-weight: 700; color: #f2f4f8; }
.tag { border: 1px solid var(--border-subtle); }
.action-btns .btn { min-height: 30px; }
.review-tabs { display: flex; gap: 5px; margin-bottom: 16px; padding: 4px; overflow-x: auto; border: 1px solid var(--border-subtle); border-radius: 9px; background: var(--panel); }
.review-tab, .segment { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 34px; padding: 6px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--text-secondary); cursor: pointer; white-space: nowrap; font-size: 0.78rem; font-weight: 620; }
.review-tab strong { min-width: 19px; padding: 1px 5px; border-radius: 99px; background: var(--surface2); color: var(--text-secondary); font-size: 0.68rem; }
.review-tab:hover, .segment:hover { color: var(--text-primary); }
.review-tab.active, .segment.active { background: var(--selection); color: #dfe6ff; }
.review-tab.active strong { background: var(--accent); color: #fff; }
.segmented { display: inline-flex; gap: 3px; margin-bottom: 16px; padding: 4px; border: 1px solid var(--border-subtle); border-radius: 9px; background: var(--panel); }
.review-card { border-radius: 9px; }
.review-card-head { padding: 14px 16px; }
.review-item-row { min-height: 38px; background: var(--surface2); }

/* Review triage workspace */
.review-workspace-shell { opacity: .01; transform: translateY(4px); transition: opacity .18s ease, transform .18s ease; }
.review-workspace-shell.ready { opacity: 1; transform: none; }
.review-toolbar { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:10px 12px; margin-bottom:12px; }
.review-filter-strip { display:flex; gap:3px; flex:1 1 auto; min-width:0; max-width:100%; overflow-x:auto; scrollbar-width:thin; -webkit-overflow-scrolling:touch; }
.review-filter { display:inline-flex; align-items:center; gap:7px; min-height:34px; padding:6px 9px; border:0; border-radius:7px; background:transparent; color:var(--text-secondary); font:inherit; font-size:.78rem; font-weight:650; white-space:nowrap; cursor:pointer; flex-shrink:0; }
.review-filter span { color:#778196; font-size:.68rem; }
.review-filter:hover { color:var(--text-primary); background:var(--surface2); }
.review-filter.active { color:#e5ebff; background:rgba(91, 124, 250, 0.25); }
.review-filter.active span { color:#aebcf5; }
.review-tools { display:flex; gap:7px; flex:0 1 auto; flex-wrap:wrap; align-items:center; justify-content:flex-end; margin-left:auto; }
.review-search { width:190px; min-height:34px; min-width:0; max-width:100%; }
.review-tools select { width:auto !important; min-width:9rem; max-width:min(240px, 100%); min-height:34px; flex-shrink:0; }
.review-tools select.review-user-select { min-width:10rem; }
.review-updates { display:flex; justify-content:center; margin:-2px 0 10px; }
.review-bulk { min-height:42px; padding:7px 10px; display:flex; align-items:center; gap:8px; border:1px solid #33436b; border-radius:8px 8px 0 0; background:var(--surface2); }
.review-bulk[hidden] { display:none; }
.review-bulk strong { margin-right:auto; font-size:.8rem; }
.review-workspace { min-height:620px; height:calc(100vh - 245px); display:grid; grid-template-columns:minmax(330px, 390px) minmax(0,1fr); overflow:hidden; border:1px solid var(--border-subtle); border-radius:10px; background:var(--panel); }
.review-queue { min-width:0; display:flex; flex-direction:column; border-right:1px solid var(--border-subtle); }
.review-queue-head { min-height:44px; padding:0 14px; display:flex; align-items:center; justify-content:space-between; border-bottom:1px solid var(--border-subtle); font-size:.78rem; }
.review-queue-head span { color:var(--text-secondary); }
.review-queue-list { min-height:0; flex:1; overflow:auto; overscroll-behavior:contain; }
.review-queue-row { position:relative; min-height:102px; display:grid; grid-template-columns:22px 1fr 14px; gap:8px; padding:13px 11px; border-bottom:1px solid var(--border-subtle); cursor:pointer; transition:background .12s ease, box-shadow .12s ease; }
.review-queue-row:hover { background:var(--panel-hover); }
.review-queue-row.selected { background:var(--selection); box-shadow:inset 2px 0 0 var(--accent); }
.review-check { padding-top:2px; }
.review-check input { width:14px; height:14px; }
.review-row-main { min-width:0; display:flex; flex-direction:column; gap:4px; }
.review-row-main>strong { overflow:hidden; color:var(--text-primary); font-size:.88rem; text-overflow:ellipsis; white-space:nowrap; }
.review-row-top { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.review-row-top time { color:#778196; font-size:.68rem; white-space:nowrap; }
.review-kind { width:max-content; max-width:100%; flex-shrink:0; padding:2px 6px; border-radius:4px; color:#aebcf5; background:#222d49; font-size:.63rem; font-weight:750; letter-spacing:.03em; text-transform:uppercase; }
.kind-pending_parse,.kind-sync_failed { color:#efb5b5; background:#3a2228; }
.kind-awaiting_confirm { color:#f4d59a; background:#382f20; }
.kind-possible_duplicate { color:#c7b8ed; background:#2d2840; }
.kind-statement_import { color:#a9d7c0; background:#20362e; }
.review-row-sub,.review-row-reason { overflow:hidden; color:var(--text-secondary); font-size:.74rem; line-height:1.35; text-overflow:ellipsis; white-space:nowrap; }
.review-row-reason { color:#8993a8; }
.review-row-chevron { align-self:center; color:#667087; font-size:1.1rem; }
.review-inspector { min-width:0; overflow:auto; padding:26px 30px 36px; outline:none; background:var(--bg-elevated); }
.review-inspector-head { display:flex; justify-content:space-between; gap:20px; padding-bottom:22px; border-bottom:1px solid var(--border-subtle); }
.review-inspector-head h2 { margin:9px 0 5px; font-size:1.35rem; }
.review-inspector-head p { margin:0; color:var(--text-secondary); font-size:.82rem; }
.review-priority { color:#6f7a90; font-size:.7rem; font-weight:700; }
.review-inspector-actions { display:flex; flex-wrap:wrap; gap:8px; margin:22px 0; }
.review-amount { display:flex; align-items:baseline; gap:12px; margin-top:20px; font-size:1.65rem; font-weight:720; }
.review-amount span { color:var(--text-secondary); font-size:.78rem; font-weight:500; }
.review-meta { display:grid; grid-template-columns:120px minmax(0,1fr); gap:0; margin-top:20px; border-top:1px solid var(--border-subtle); }
.review-meta>* { min-height:42px; display:flex; align-items:center; border-bottom:1px solid var(--border-subtle); font-size:.78rem; }
.review-meta>span { color:var(--text-secondary); }
.review-meta>strong { overflow-wrap:anywhere; }
.review-error { color:#eeb1b1; }
.review-evidence h3 { margin:26px 0 10px; font-size:.8rem; text-transform:uppercase; letter-spacing:.05em; }
.review-evidence-row { display:flex; align-items:center; gap:12px; min-height:54px; padding:8px 4px; border-bottom:1px solid var(--border-subtle); cursor:pointer; }
.review-evidence-row span { display:flex; flex-direction:column; gap:3px; }
.review-evidence-row small { color:var(--text-secondary); }
.review-evidence-image { width:100%; min-height:92px; border:1px dashed #35415a; border-radius:8px; background:#151c29; color:#9ca8bf; cursor:pointer; }
.review-evidence-image:hover { border-color:#536990; color:#d6dded; }
.review-chat-link { margin-top:18px; padding:0; border:0; background:transparent; color:#91a7f5; font:inherit; font-size:.8rem; cursor:pointer; }
.review-compare { display:grid; grid-template-columns:1fr 1fr; gap:1px; margin-top:22px; background:var(--border-subtle); border:1px solid var(--border-subtle); border-radius:8px; overflow:hidden; }
.review-compare>div { min-width:0; display:flex; flex-direction:column; gap:8px; padding:18px; background:var(--surface); }
.review-compare small { color:#758096; font-size:.65rem; letter-spacing:.06em; }
.review-compare strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.review-compare span { color:var(--text-secondary); font-size:.76rem; }
.review-statement-summary { display:flex; gap:22px; align-items:center; padding:20px 0; border-bottom:1px solid var(--border-subtle); }
.review-statement-summary span { color:var(--text-secondary); font-size:.78rem; }
.review-statement-row { min-height:42px; display:grid; grid-template-columns:82px minmax(0,1fr) 90px 80px; align-items:center; gap:10px; border-bottom:1px solid var(--border-subtle); font-size:.74rem; }
.review-statement-row strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.review-statement-row span,.review-statement-row small { color:var(--text-secondary); }
.review-inspector-empty,.review-zero { height:100%; min-height:320px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:7px; color:var(--text-secondary); text-align:center; }
.review-inspector-empty strong,.review-zero strong { color:var(--text-primary); }
.review-zero-mark { width:42px; height:42px; display:grid; place-items:center; margin-bottom:5px; border-radius:50%; background:#1c342b; color:#8ed1ae; font-size:1.1rem; }
.review-zero div:last-child { display:flex; gap:14px; margin-top:9px; }
.review-mobile-back { display:none; }

@media (max-width: 1280px) {
  .review-filter-strip {
    flex: 1 1 100%;
    order: 1;
  }
  .review-tools {
    flex: 1 1 100%;
    order: 2;
    margin-left: 0;
    justify-content: flex-start;
  }
}

@media (max-width: 900px) {
  .review-toolbar { align-items:stretch; flex-direction:column; }
  .review-tools { width:100%; }
  .review-search { flex:1; width:auto; }
  .review-workspace { grid-template-columns:310px minmax(0,1fr); }
  .review-inspector { padding:22px; }
}
@media (max-width: 680px) {
  .review-workspace { position:relative; height:calc(100svh - 230px); min-height:520px; display:block; }
  .review-queue { height:100%; border-right:0; }
  .review-inspector { position:absolute; inset:0; z-index:3; display:none; padding:18px; background:var(--bg-elevated); }
  .review-workspace.has-selection .review-inspector { display:block; animation:reviewSlide .18s ease both; }
  .review-mobile-back { display:block; margin:0 0 16px; padding:0; border:0; background:transparent; color:#9dafed; }
  .review-filter-strip { margin-right:-14px; }
  .review-compare { grid-template-columns:1fr; }
  .review-statement-summary { align-items:flex-start; flex-direction:column; gap:7px; }
}
@keyframes reviewSlide { from { opacity:0; transform:translateX(12px); } to { opacity:1; transform:none; } }
@media (prefers-reduced-motion: reduce) { .review-workspace-shell,.review-queue-row { transition:none; } .review-workspace.has-selection .review-inspector { animation:none; } }

.setup-header { padding-bottom: 18px; border-bottom: 1px solid var(--border-subtle); }
.key-status-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.key-status-card { background: transparent; border-color: var(--border-subtle); }
.setup-steps { gap: 12px; }
.setup-step.card { border-radius: 10px; }
.setup-step:not(.collapsed) { border-color: #405073; }
.step-num { border-radius: 8px; background: #32477f; }
.config-grid { align-items: start; }
.config-section { border-radius: 10px; }
.compact-form-grid { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 12px; align-items: end; }
.split-form-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 12px; align-items: end; }
.import-steps { display: grid; grid-template-columns: repeat(3, 1fr); max-width: 620px; margin: 0 0 18px; padding: 0; list-style: none; }
.import-steps li { position: relative; display: flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 0.76rem; }
.import-steps li:not(:last-child)::after { content: ''; position: absolute; left: 30px; right: 10px; top: 12px; height: 1px; background: var(--border-strong); }
.import-steps span { position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center; width: 25px; height: 25px; border: 1px solid var(--border-strong); border-radius: 50%; background: var(--panel); }
.import-steps .active { color: var(--text-primary); }
.import-steps .active span { border-color: var(--accent); background: var(--accent); color: #fff; }
.import-stage { max-width: 980px; margin: 0 0 16px; }
.file-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 145px; padding: 24px; border: 1px dashed #46516b; border-radius: 10px; background: #10151e; color: var(--text-primary); cursor: pointer; }
.file-drop:hover { border-color: var(--accent); background: #121927; }
.file-drop span { margin-top: 4px; color: var(--text-secondary); font-size: 0.76rem; }
.file-drop input { width: auto; margin-top: 14px; padding: 0; border: 0; background: transparent; }
.import-preview { margin-top: 16px; }
.backup-status-grid { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--border-subtle); border-radius: 9px; background: var(--border-subtle); }
.backup-status-grid > div { padding: 13px; background: var(--panel); }
.backup-status-grid span, .backup-path span { display: block; color: var(--text-secondary); font-size: 0.69rem; margin-bottom: 4px; }
.backup-status-grid strong { font-size: 0.84rem; }
.backup-path { margin-top: 10px; padding: 11px 13px; border: 1px solid var(--border-subtle); border-radius: 8px; }
.backup-path code { word-break: break-all; font-size: 0.75rem; }

.empty-state-icon { filter: grayscale(1); opacity: 0.45; }
.alert { border-left-width: 3px; }
.badge { letter-spacing: 0; }
.modal { border-color: var(--border-strong); box-shadow: 0 24px 70px rgba(0,0,0,0.5); animation: dialog-in 0.18s ease; }
.modal-confirm { max-width: 420px; }
@keyframes overlay-in { from { opacity: 0; } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.985); } }

@media (max-width: 1100px) {
  .metric-band { grid-template-columns: 1fr 1fr; }
  .metric:nth-child(3) { border-left: 0; border-top: 1px solid var(--border-subtle); }
  .metric:nth-child(4) { border-top: 1px solid var(--border-subtle); }
  .filter-main { grid-template-columns: 1fr 1fr 1fr; }
  .filter-main .search-field { grid-column: 1 / -1; }
}

@media (max-width: 768px) {
  .mobile-topbar { min-height: 54px; }
  .mobile-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
  .mobile-brand .brand-mark { width: 28px; height: 28px; border-radius: 7px; }
  .sidebar { width: min(292px, 88vw); }
  .main { padding: 17px 14px; }
  .page-header { flex-direction: column; gap: 14px; margin-bottom: 20px; }
  .page-actions { width: 100%; }
  .page-actions > * { flex: 1; }
  .scope-select { width: 100%; }
  .metric-band { grid-template-columns: 1fr 1fr; }
  .metric { padding: 15px; }
  .metric strong { font-size: 1.05rem; }
  .overview-grid, .chart-detail-grid { grid-template-columns: 1fr; }
  .dash-cell-attention, .dash-cell-month, .dash-cell-pie,
  .dash-cell-recent, .dash-cell-daily, .dash-cell-merchants,
  .dash-cell-intent, .dash-cell-refunds, .dash-cell-insights { grid-column: 1 / -1; }
  .workspace-section { padding: 17px 15px; }
  .chart-frame, .chart-primary .chart-frame { min-height: 240px; }
  .filter-main { display: flex; flex-direction: column; }
  .filter-main > * { width: 100%; }
  .filter-secondary { align-items: stretch; }
  .date-field { flex: 1; }
  .date-field input { width: 100%; }
  .result-toolbar { align-items: flex-start; }
  .result-actions { flex-wrap: wrap; justify-content: flex-end; }
  .page-heading { flex: 0 1 auto; width: 100%; }
  a, button, .btn, [data-action], select, input[type=submit], input[type=button], .table-row-action { min-height: 44px; }
  table.data-table { min-width: 0; }
  .sidebar { max-width: min(292px, 88vw); flex-basis: auto; }
  .main[data-page="users"] tbody td[data-label="Telegram ID"],
  .main[data-page="users"] tbody td[data-label="Username"],
  .main[data-page="users"] tbody td[data-label="Last seen"],
  .main[data-page="users"] tbody td[data-label="Notion"] { display: none; }
  .main[data-page="logs"] tbody td[data-label="Source"],
  .main[data-page="logs"] tbody td[data-label="Details"] { display: none; }
  .main[data-page="corrections"] tbody td[data-label="Expense ID"],
  .main[data-page="corrections"] tbody td[data-label="Old Value"],
  .main[data-page="corrections"] tbody td[data-label="Reason"],
  .main[data-page="corrections"] tbody td[data-label="By"] { display: none; }
  .mobile-data-table tbody td[data-label="Actions"]::before { display: none; }
  .mobile-data-table tbody td[data-label="Actions"] {
    display: block;
    padding-top: 8px;
    margin-top: 4px;
    border-top: 1px solid var(--border);
    justify-content: flex-start;
  }
  .modal { max-height: 92svh; border-radius: 14px 14px 0 0; align-self: flex-end; }
  .modal-overlay { align-items: flex-end; }
  .segmented { display: flex; overflow-x: auto; }
  .compact-form-grid, .split-form-grid, .alias-form-grid { grid-template-columns: 1fr; }
  .import-steps { max-width: none; }
  .backup-status-grid { grid-template-columns: 1fr 1fr; }
  .config-section .form-group.half { width:100%; display:block; }
  .config-section .form-group.half:first-child { margin-right:0; }
  .key-masked { word-break:break-all; white-space:normal; }
  .file-drop { width:100%; box-sizing:border-box; }
  .import-stage { max-width:100%; }
  .import-preview-table { min-width:0; overflow-x:auto; }
  .config-section input.form-control { min-width:0; max-width:100%; }
  .file-drop > * { max-width:100%; }
  .config-section .form-group { min-width:0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ── Admin-bot visual parity overrides ── */
.layout { min-height: 100vh; height: 100vh; display: flex !important; }
.sidebar {
  width: var(--sidebar-w);
  background: rgba(17, 24, 39, 0.92);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(12px);
  box-shadow: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  flex: 0 0 var(--sidebar-w);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  min-height: auto; padding: 20px 18px 12px;
  border-bottom: 1px solid var(--border);
  background: transparent;
}
.sidebar-brand strong {
  display: block; font-weight: 700; letter-spacing: -0.02em; font-size: 0.98rem;
}
.sidebar-brand small {
  display: block; margin-top: 1px; color: var(--text3);
  font-size: 0.75rem; letter-spacing: 0; text-transform: none;
}
.sidebar nav {
  flex: 1; overflow-y: auto; padding: 8px 12px;
}
.sidebar nav a {
  min-height: auto;
  margin: 0 0 4px;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  border-left: 1px solid transparent;
  color: var(--text2);
  font-weight: 500;
  font-size: 0.92rem;
  box-shadow: none;
  background: transparent;
}
.sidebar nav a:hover {
  background: var(--surface2);
  color: var(--text);
  text-decoration: none;
}
.sidebar nav a.active {
  background: rgba(91, 124, 250, 0.25);
  color: var(--text);
  border-color: rgba(91, 124, 250, 0.25);
  box-shadow: none;
}
/* Force vertical app shell nav */
.sidebar nav,
.sidebar .nav-primary,
.sidebar details.nav-section {
  display: flex !important;
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  gap: 2px;
}
.sidebar nav a,
.sidebar nav a:link,
.sidebar nav a:visited {
  display: flex !important;
  width: 100% !important;
  max-width: 100%;
  flex: 0 0 auto;
  box-sizing: border-box;
}
.nav-primary {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.nav-icon { width: 1.25rem; text-align: center; opacity: 0.85; color: inherit; flex-shrink: 0; }
.nav-section summary {
  padding: 10px 12px 6px;
  color: var(--text3);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  width: 100%;
  box-sizing: border-box;
}
.sidebar-status {
  padding: 14px 16px 18px;
  border-top: 1px solid var(--border);
}
.sidebar-status .bot-pill {
  width: 100%;
  margin: 0;
  border-radius: 10px;
  background: var(--surface2);
  border-color: var(--border);
}
.bot-menu {
  background: var(--surface);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.main {
  background: transparent;
  padding: clamp(18px, 2.5vw, 36px);
  flex: 1 1 auto;
  min-width: 0;
}
.page-heading h1 {
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.03em;
}
.page-heading p, .page-description { color: var(--text2); }

/* Button density polish (bridge lives at top of file) */
.btn { min-height: 36px; font-weight: 600; }
.btn-sm { min-height: 30px; }

/* Keep toolbar controls compact (Bootstrap defaults to full width) */
.page-actions,
.toolbar,
.result-actions,
.filter-main,
.filter-secondary,
.form-actions,
.step-actions,
.modal-actions {
  flex-wrap: wrap;
}
.page-actions {
  flex: 0 1 auto !important;
  justify-content: flex-end;
  gap: 8px;
}
.page-actions select,
.page-actions .scope-select,
.scope-select,
#dash-user-filter,
.toolbar select,
.toolbar input[type="search"],
.toolbar input:not([type="checkbox"]):not([type="radio"]),
.filter-main select,
.filter-secondary input,
.filter-secondary select {
  width: auto !important;
  max-width: 100%;
  min-width: 0;
  margin-bottom: 0 !important;
}
.scope-select,
#dash-user-filter {
  width: min(240px, 100%) !important;
  flex: 0 1 240px;
}
.filter-main .search-field {
  flex: 1 1 220px;
  min-width: 0;
}
.filter-main .search-field input {
  width: 100% !important;
  margin-bottom: 0 !important;
}
.page-header {
  display: flex !important;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px 24px;
}
.page-heading { flex: 1 1 240px; min-width: 0; }

/* Card / section margins inside main */
.main article,
.main .card,
.main .workspace-section,
.main .config-section {
  margin-inline: 0;
}

.card, .workspace-section, .config-section, .filter-panel, .table-wrap,
.metric-band, .split-card, .review-card, .stat-card, .key-status-card {
  background: rgba(21, 28, 44, 0.88);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
}
.workspace-section:hover, .card:hover, .config-section:hover,
.stat-card:hover, .key-status-card:hover, .metric-band:hover {
  border-color: var(--border-strong);
  box-shadow: none;
  transform: none;
}

.metric-band { overflow: hidden; }
.metric { border-left-color: var(--border); }
.metric-primary strong { color: var(--accent2); }
.metric-label, .metric-note, .section-head p, .section-meta { color: var(--text2); }
.section-head h2 { color: var(--text); font-weight: 650; letter-spacing: -0.02em; }

.badge-ok, .badge-success { background: var(--green-soft); color: var(--green); border: 1px solid rgba(52,211,153,0.25); }
.badge-pending, .badge-warning { background: var(--orange-soft); color: var(--orange); border: 1px solid rgba(251,191,36,0.25); }
.badge-failed, .badge-danger { background: var(--red-soft); color: var(--red); border: 1px solid rgba(248,113,113,0.25); }

.data-table th {
  background: rgba(17, 24, 39, 0.95);
  color: var(--text3);
  border-bottom-color: var(--border);
  box-shadow: none;
}
.data-table tbody tr:nth-child(even) td { background: rgba(255,255,255,0.012); }
.data-table tbody tr:hover td { background: rgba(255,255,255,0.03) !important; }

.alert-success { background: var(--green-soft); border-color: rgba(52,211,153,0.35); color: var(--green); }
.alert-error { background: var(--red-soft); border-color: rgba(248,113,113,0.35); color: var(--red); }
.app-toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.mobile-topbar {
  background: rgba(17, 24, 39, 0.95);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}
.mobile-brand .brand-mark {
  background: linear-gradient(145deg, var(--accent), #8b5cf6);
}
.search-field {
  background: var(--bg-elevated);
  border-color: var(--border);
}
.filter-chip:hover, .filter-chip.active {
  border-color: rgba(91,124,250,0.35);
  background: rgba(91, 124, 250, 0.25);
  color: var(--text);
}
.attention-row:hover { background: var(--surface2); }
.budget-bar { background: var(--surface2); }
.budget-bar-fill.budget-bar-green { background: var(--green); box-shadow: none; }
.bot-pill-running { color: var(--green); }
.bot-pill-running .bot-dot { background: var(--green); }
.empty-state {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: rgba(0,0,0,0.12);
}
.review-tab.active, .segment.active, .review-filter.active {
  background: rgba(91, 124, 250, 0.25);
  color: var(--text);
}
.skip-link {
  background: #fff; color: #111; border-radius: 10px;
}

/* Soften previous gradient title override */
.page-heading h1 {
  background: none !important;
  color: var(--text) !important;
  -webkit-text-fill-color: var(--text);
}

/* Grids must allow shrink below content size */
.overview-grid,
.chart-detail-grid,
.chart-grid,
.metric-band,
.filter-main,
.config-grid,
.stats-grid,
.key-status-grid,
.backup-status-grid,
.compact-form-grid,
.split-form-grid,
.alias-form-grid {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}
.overview-grid {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}
.chart-detail-grid,
.chart-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.metric-band {
  grid-template-columns: minmax(0, 1.2fr) repeat(3, minmax(0, 1fr));
}
.filter-main {
  grid-template-columns: minmax(0, 1fr) minmax(0, 170px) minmax(0, 160px) auto auto;
}
.config-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.overview-grid > *,
.chart-detail-grid > *,
.chart-grid > *,
.metric-band > *,
.filter-main > *,
.config-grid > *,
.workspace-section,
.card,
.config-section,
.filter-panel,
.table-wrap,
.chart-frame,
.chart-primary,
.month-section,
.attention-section {
  min-width: 0;
  max-width: 100%;
}

.workspace-section,
.card,
.config-section,
.filter-panel,
.metric-band {
  overflow: hidden; /* keep children inside rounded frames */
  box-sizing: border-box;
}

.chart-frame {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  position: relative;
}
.chart-frame canvas {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
}

/* Tables scroll inside wrapper instead of blowing layout */
.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
.table-wrap table,
table.data-table {
  width: 100%;
  max-width: none; /* allow natural width inside scroll container */
  min-width: 720px;
}
.action-btns {
  max-width: 220px;
  flex-wrap: wrap;
}

/* Page header / toolbars */
.page-header,
.legacy-page-header,
.result-toolbar,
.review-toolbar,
.section-head,
.chat-page-head {
  min-width: 0;
  max-width: 100%;
}
.page-header {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.page-heading,
.page-actions {
  min-width: 0;
}
.page-actions {
  flex: 1 1 auto;
  justify-content: flex-end;
}
.scope-select {
  max-width: 100%;
  min-width: 0;
  width: min(220px, 100%);
}

/* Filter panel symmetry */
.filter-panel { box-sizing: border-box; }
.filter-secondary { min-width: 0; }
.preset-group { min-width: 0; flex-wrap: wrap; }
.date-field { min-width: 0; }
.date-field input { max-width: 100%; width: 100%; min-width: 0; }
.search-field { width: 100%; max-width: 100%; }
.search-field input { width: 100%; min-width: 0; }

/* Review workspace */
.review-workspace {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
}
.review-queue,
.review-inspector,
.review-toolbar,
.review-tools {
  min-width: 0;
  max-width: 100%;
}
.review-tools {
  flex-wrap: wrap;
}
.review-search {
  width: min(190px, 100%);
  min-width: 0;
}

/* Chat */
.chat-layout {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.chat-sidebar { min-width: 0; }
.chat-main { min-width: 0; }

/* Metric text shouldn't force column growth */
.metric strong,
.metric .metric-merchant {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Responsive stacking before overflow */
@media (max-width: 1100px) {
  .metric-band { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .overview-grid,
  .chart-detail-grid,
  .chart-grid,
  .config-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .filter-main {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .filter-main .search-field { grid-column: 1 / -1; }
  .filter-main .btn { width: 100%; }
}
@media (max-width: 900px) {
  .review-workspace {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 768px) {
  .sidebar { max-width: min(292px, 88vw); flex-basis: auto; }
  .metric-band { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .filter-main { grid-template-columns: minmax(0, 1fr); }
  .filter-main > * { width: 100%; }
  .page-actions { width: 100%; justify-content: stretch; }
  .page-actions > * { flex: 1 1 auto; }
  .page-heading { flex: 0 1 auto; width: 100%; }
  a, button, .btn, [onclick], select, input[type=submit], input[type=button], .table-row-action { min-height: 44px; }
  .scope-select { width: 100%; }
  table.data-table { min-width: 0; }
}

/* ── Chart + filter symmetry ── */
.chart-detail-grid,
.overview-grid {
  align-items: stretch;
}
.chart-detail-grid > .workspace-section,
.overview-grid > .workspace-section {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.chart-detail-grid .chart-frame {
  flex: 1 1 auto;
  min-height: 260px;
}
.chart-primary .chart-frame {
  min-height: 280px;
}
.section-head {
  flex-wrap: wrap;
  gap: 8px;
}
.page-header {
  align-items: flex-start;
}
.filter-main > select,
.filter-main > .btn {
  min-width: 0;
}
.result-toolbar {
  flex-wrap: wrap;
}
.result-actions {
  flex-wrap: wrap;
  min-width: 0;
}

@media (max-width: 1200px) {
  .overview-grid,
  .chart-detail-grid,
  .chart-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .metric-band {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

/* Clip any residual chart paint outside card bounds */
.chart-detail-grid > .workspace-section,
.chart-primary.workspace-section {
  overflow: hidden;
}
.chart-frame {
  contain: layout paint;
}


/* ── Expenses responsive ── */
.main[data-page="expenses"] .filter-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.main[data-page="expenses"] .filter-main {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 160px) minmax(0, 160px) auto auto;
  gap: 10px;
  align-items: stretch;
}
.main[data-page="expenses"] .filter-secondary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.main[data-page="expenses"] .date-field {
  flex: 0 1 150px;
  min-width: 0;
}
.main[data-page="expenses"] .date-field input {
  width: 100%;
}
.main[data-page="expenses"] .preset-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.main[data-page="expenses"] .result-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.main[data-page="expenses"] .result-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.main[data-page="expenses"] .expenses-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(21, 28, 44, 0.88);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.main[data-page="expenses"] .expenses-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}
.main[data-page="expenses"] .expenses-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(17, 24, 39, 0.98);
  white-space: nowrap;
}
.main[data-page="expenses"] .exp-col-ref {
  max-width: 140px;
  word-break: break-all;
  font-size: 0.8rem;
}
.main[data-page="expenses"] .exp-col-remark {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.main[data-page="expenses"] .exp-merchant {
  font-weight: 650;
}
.main[data-page="expenses"] .action-btns-exp {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: none;
  align-items: center;
}
.main[data-page="expenses"] .action-more {
  position: relative;
}
.main[data-page="expenses"] .action-more > summary {
  list-style: none;
  cursor: pointer;
}
.main[data-page="expenses"] .action-more > summary::-webkit-details-marker { display: none; }
.main[data-page="expenses"] .action-more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
  padding: 8px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.main[data-page="expenses"] .action-more-menu .btn {
  width: 100%;
  justify-content: flex-start;
}
.main[data-page="expenses"] .pagination {
  flex-wrap: wrap;
  gap: 6px;
}

/* Tablet: denser filters, still table with horizontal scroll */
@media (max-width: 1100px) {
  .main[data-page="expenses"] .filter-main {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .main[data-page="expenses"] .filter-main .search-field {
    grid-column: 1 / -1;
  }
  .main[data-page="expenses"] .filter-main .btn {
    width: 100%;
  }
}

/* Mobile: card list instead of wide table */
@media (max-width: 820px) {
  .main[data-page="expenses"] .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .main[data-page="expenses"] .page-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .main[data-page="expenses"] .page-actions .btn {
    width: 100%;
  }
  .main[data-page="expenses"] .filter-main {
    grid-template-columns: minmax(0, 1fr);
  }
  .main[data-page="expenses"] .filter-main > * {
    width: 100%;
  }
  .main[data-page="expenses"] .filter-secondary {
    flex-direction: column;
    align-items: stretch;
  }
  .main[data-page="expenses"] .date-field {
    flex: 1 1 auto;
    width: 100%;
  }
  .main[data-page="expenses"] .preset-group {
    width: 100%;
  }
  .main[data-page="expenses"] .preset-group .filter-chip {
    flex: 1 1 calc(50% - 6px);
    text-align: center;
    justify-content: center;
  }
  .main[data-page="expenses"] .result-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .main[data-page="expenses"] .result-actions {
    width: 100%;
    justify-content: space-between;
  }
  .main[data-page="expenses"] .result-actions select,
  .main[data-page="expenses"] .per-page-select,
  .main[data-page="expenses"] #exp-per-page {
    width: auto !important;
    min-width: 4.5rem;
    flex-shrink: 0;
  }

  .main[data-page="expenses"] .expenses-table-wrap {
    border: 0;
    background: transparent;
    overflow: visible;
  }
  .main[data-page="expenses"] .expenses-table,
  .main[data-page="expenses"] .expenses-table.data-table {
    min-width: 0 !important;
    width: 100%;
    display: block;
  }
  .main[data-page="expenses"] .expenses-table thead {
    display: none;
  }
  .main[data-page="expenses"] .expenses-table tbody {
    display: grid;
    gap: 10px;
  }
  .main[data-page="expenses"] .expenses-table tbody tr.exp-row,
  .main[data-page="expenses"] .expenses-table tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 10px;
    padding: 14px;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(21, 28, 44, 0.92);
    box-shadow: none;
  }
  .main[data-page="expenses"] .expenses-table tbody tr:hover td {
    background: transparent !important;
  }
  .main[data-page="expenses"] .expenses-table tbody td {
    display: block;
    border: 0 !important;
    padding: 0 !important;
    white-space: normal;
    text-align: left;
    background: transparent !important;
  }
  .main[data-page="expenses"] .expenses-table tbody td::before {
    content: none !important;
  }

  /* Card grid placement */
  .main[data-page="expenses"] .exp-col-merchant {
    grid-column: 1;
    grid-row: 1;
    font-size: 1rem;
  }
  .main[data-page="expenses"] .exp-col-amount {
    grid-column: 2;
    grid-row: 1;
    text-align: right !important;
    font-size: 1.05rem;
    font-weight: 750;
    color: var(--text);
  }
  .main[data-page="expenses"] .exp-col-date {
    grid-column: 1;
    grid-row: 2;
    color: var(--text2);
    font-size: 0.82rem;
  }
  .main[data-page="expenses"] .exp-col-status {
    grid-column: 2;
    grid-row: 2;
    text-align: right !important;
  }
  .main[data-page="expenses"] .exp-col-category {
    grid-column: 1;
    grid-row: 3;
  }
  .main[data-page="expenses"] .exp-col-user {
    grid-column: 2;
    grid-row: 3;
    text-align: right !important;
    font-size: 0.8rem;
  }
  .main[data-page="expenses"] .exp-col-source {
    grid-column: 1 / -1;
    grid-row: 4;
  }
  .main[data-page="expenses"] .exp-col-ref,
  .main[data-page="expenses"] .exp-col-remark {
    grid-column: 1 / -1;
    font-size: 0.8rem;
    color: var(--text2);
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }
  .main[data-page="expenses"] .exp-col-ref:not(:empty)::before {
    content: 'Ref · ';
    color: var(--text3);
    font-weight: 600;
  }
  .main[data-page="expenses"] .exp-col-remark:not(:empty)::before {
    content: 'Remark · ';
    color: var(--text3);
    font-weight: 600;
  }
  /* hide empty ref/remark rows (—) */
  .main[data-page="expenses"] .exp-col-ref:is(:empty),
  .main[data-page="expenses"] td.exp-col-ref {
    /* keep visible; dash is fine */
  }
  .main[data-page="expenses"] .exp-col-actions {
    grid-column: 1 / -1;
    grid-row: auto;
    padding-top: 8px !important;
    border-top: 1px solid var(--border) !important;
    margin-top: 4px;
  }
  .main[data-page="expenses"] .action-btns-exp {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 8px;
  }
  .main[data-page="expenses"] .action-btns-exp > .btn {
    width: 100%;
    min-height: 38px;
    justify-content: center;
  }
  .main[data-page="expenses"] .action-more {
    grid-column: 3;
  }
  .main[data-page="expenses"] .action-more > summary {
    width: 100%;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .main[data-page="expenses"] .action-more-menu {
    left: auto;
    right: 0;
    width: min(220px, 70vw);
  }
  .main[data-page="expenses"] .action-more[open] .action-more-menu {
    display: flex;
  }
  .main[data-page="expenses"] .pagination {
    justify-content: center;
  }
  .main[data-page="expenses"] .pagination button {
    min-width: 40px;
    min-height: 40px;
  }
}

@media (max-width: 480px) {
  .main[data-page="expenses"] .page-actions {
    grid-template-columns: 1fr;
  }
  .main[data-page="expenses"] .action-btns-exp {
    grid-template-columns: 1fr 1fr;
  }
  .main[data-page="expenses"] .action-more {
    grid-column: 1 / -1;
  }
  .main[data-page="expenses"] .preset-group .filter-chip {
    flex: 1 1 100%;
  }
}


/* ── Utilities ── */
.is-hidden { display: none !important; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.card-flush { margin-bottom: 1rem; }
.form-group.tight { margin-bottom: 0; }
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.form-row-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 0.875rem;
  color: var(--text2);
}
.inline-check {
  display: inline-flex !important;
  align-items: center;
  gap: 10px;
  margin: 0 !important;
  font-weight: 500;
  cursor: pointer;
  width: auto !important;
  max-width: 100%;
  color: var(--text-primary);
  line-height: 1.4;
}
.inline-check input[type="checkbox"],
.inline-check input[type="radio"] {
  width: 1.05rem !important;
  height: 1.05rem !important;
  min-width: 1.05rem;
  min-height: 1.05rem;
  margin: 0 !important;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.inline-check input {
  width: auto !important;
  margin: 0 !important;
  flex-shrink: 0;
}
.form-group .inline-check {
  align-self: flex-start;
}

/* Bootstrap form-check rows (modals, setup, config) */
.form-check-group .form-check {
  display: block;
  min-height: 1.5rem;
  padding-left: 1.75em;
  margin-bottom: 0;
}
.form-check-group .form-check-input {
  float: left;
  width: 1em !important;
  height: 1em !important;
  min-width: 1em;
  min-height: 1em;
  margin-left: -1.75em;
  margin-top: 0.2em;
  cursor: pointer;
}
.form-check-group .form-check-label {
  margin-bottom: 0;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
}
.form-check-group .field-hint {
  margin: 0.35rem 0 0 1.75em;
}
.modal .form-check-group .form-check-input:focus {
  box-shadow: 0 0 0 0.2rem rgba(91, 124, 250, 0.25);
}
.field-hint {
  display: block;
  margin: 0 0 0.75rem;
  color: var(--text2);
  font-size: 0.82rem;
  line-height: 1.45;
}
.table-empty,
.table-empty-cell {
  text-align: center !important;
  color: var(--text2) !important;
  padding: 1.5rem 1rem !important;
  white-space: normal !important;
}
.subline { font-size: 0.75rem; margin-top: 2px; }
.mono-tight { font-size: 0.8rem; white-space: nowrap; }
.badge-gap { margin-left: 8px; }

/* AI feature flags */
.feature-flags-section { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.feature-flags-section h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.feature-flags-grid { display: grid; gap: 0.65rem; }
.feature-flag-row { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.feature-flag-row:last-child { border-bottom: 0; }
.feature-flag-label { align-items: flex-start !important; gap: 0.6rem !important; }
.feature-flag-desc { display: block; color: var(--text2); font-size: 0.8rem; font-weight: 400; margin-top: 2px; }
.feature-global-off { font-size: 0.75rem; color: var(--orange); }

/* Intent badges */
.intent-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.intent-business { background: rgba(91, 124, 250, 0.18); color: #9cb4ff; border-color: rgba(91, 124, 250, 0.35); }
.intent-personal { background: rgba(167, 139, 250, 0.18); color: #c4b5fd; border-color: rgba(167, 139, 250, 0.35); }
.intent-reimbursement { background: rgba(52, 211, 153, 0.15); color: var(--green); border-color: rgba(52, 211, 153, 0.3); }
.intent-investment { background: rgba(56, 189, 248, 0.15); color: #7dd3fc; border-color: rgba(56, 189, 248, 0.3); }
.intent-transfer { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; border-color: rgba(148, 163, 184, 0.3); }
.intent-other { background: rgba(251, 191, 36, 0.12); color: var(--orange); border-color: rgba(251, 191, 36, 0.28); }

/* Tax badges */
.tax-badge {
  display: inline-flex;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(52, 211, 153, 0.12);
  color: var(--green);
  border: 1px solid rgba(52, 211, 153, 0.25);
}

/* Anomaly badges */
.anomaly-badge {
  display: inline-flex;
  margin-left: 6px;
  padding: 0.12rem 0.4rem;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(248, 113, 113, 0.15);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.35);
}
.exp-row-anomaly { background: rgba(248, 113, 113, 0.04); }
.review-row-anomaly { border-left: 3px solid var(--red); }
.review-anomaly-callout {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.2);
}

/* Forecast bars */
.forecast-panel { margin-bottom: 1rem; }
.forecast-row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}
.forecast-bar {
  height: 10px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
}
.forecast-bar-sm { height: 8px; max-width: 120px; }
.forecast-bar-fill { height: 100%; border-radius: 99px; transition: width 0.3s; }
.forecast-bar-green { background: var(--green); }
.forecast-bar-yellow { background: var(--orange); }
.forecast-bar-red { background: var(--red); }

/* Expense detail AI panels */
.expense-ai-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.expense-refund-link { margin-bottom: 10px; }
.expense-narrative-panel {
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface2);
}
.expense-narrative-panel summary { cursor: pointer; font-weight: 600; }
.expense-narrative-body { margin-top: 8px; }
.expense-narrative-text { margin: 0; line-height: 1.5; white-space: pre-wrap; }

/* Dashboard AI widgets */
.intent-breakdown-row {
  display: grid;
  grid-template-columns: 110px 1fr 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.intent-breakdown-bar {
  height: 8px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
}
.intent-breakdown-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
}
.dash-refund-summary { margin-bottom: 8px; }
.dash-refund-summary strong { font-size: 1.4rem; margin-right: 6px; }
.insights-digest-text { margin: 0; line-height: 1.55; white-space: pre-wrap; }

/* Reconciliation workspace */
.recon-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 10px;
}
.recon-panel h3 { margin-top: 0; font-size: 0.95rem; }
.recon-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; }
.recon-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
}
.recon-item small { grid-column: 1 / -1; }

.recon-item-selectable {
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.recon-item-selectable:hover { border-color: var(--accent); }
.recon-item-selectable.selected {
  border-color: var(--accent);
  background: rgba(91, 124, 250, 0.12);
  box-shadow: 0 0 0 1px var(--accent);
}
.recon-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.recon-matches-panel { margin-top: 16px; }
.recon-match-list { display: flex; flex-direction: column; gap: 10px; }
.recon-match-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
}

.digest-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 36%);
  gap: 16px;
  align-items: start;
}
.digest-detail-panel { min-height: 240px; }
.digest-detail-body { white-space: pre-wrap; line-height: 1.55; margin-top: 12px; }
.digest-detail-head h3 { margin: 0 0 4px; }

.config-section-wide { grid-column: 1 / -1; }

.review-kind.kind-anomaly { background: rgba(248, 113, 113, 0.15); color: var(--red); }

.filter-tax-toggle { white-space: nowrap; font-size: 0.85rem; }

@media (max-width: 900px) {
  .recon-panels { grid-template-columns: 1fr; }
  .forecast-row { grid-template-columns: 1fr; }
  .intent-breakdown-row { grid-template-columns: 1fr auto; }
  .digest-layout { grid-template-columns: 1fr; }
}
.summary-cat-row { margin-bottom: 10px; }
.summary-cat-label { font-size: 0.85rem; margin-bottom: 3px; }
.summary-total-row { margin-bottom: 4px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.summary-total { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tall-textarea { min-height: 200px; }
.modal-sm { width: min(380px, 92vw); }
.shortcut-table { width: 100%; font-size: 0.85rem; margin-bottom: 0; }
.shortcut-table td { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); }
.shortcut-table tr:last-child td { border-bottom: 0; }
.skeleton { height: 14px; }
.skeleton.skel-w-sm { width: 80px; }
.skeleton.skel-w-0 { width: 42%; }
.skeleton.skel-w-1 { width: 58%; }
.skeleton.skel-w-2 { width: 70%; }

/* Config sections */
article.config-section,
article.card,
.config-section.card {
  display: block;
}
article.config-section h3,
article.card h3,
.config-section.card h3 {
  margin-top: 0;
}

.main label { font-weight: 500; }
.main fieldset { margin: 0; padding: 0; border: 0; }

.setup-progress-bar { min-width: 0; }

.page-actions select.scope-select,
.page-actions #dash-user-filter,
#dash-user-filter.scope-select {
  width: 220px;
  max-width: min(220px, 50vw);
  flex: 0 0 auto;
}
.page-actions { flex: 0 0 auto; }

/* Ultra-narrow: all pages */
@media (max-width: 480px) {
  .page-actions { flex-direction: column; }
  .page-actions > * { width: 100%; }
  .page-actions .btn { justify-content: center; }
  .metric-band { grid-template-columns: 1fr; }
  .result-actions { flex-direction: column; align-items: stretch; }
  .result-actions > * { width: 100%; }
  .filter-main > select, .filter-main > input { width: 100%; }
  .preset-group .filter-chip { flex: 1 1 100%; text-align: center; justify-content: center; }
  .modal { max-width: 98vw; }
  .config-section { padding: 16px; }
  .key-status-grid { grid-template-columns: 1fr; }
  .card-grid, .workspace-section { padding: 14px; }
  .sidebar { max-width: 92vw; }
}
