/* === Manuel Capital / BuildBook design system ===
   Owner brand: cream bg, title blue, warm brown subheads, chocolate headings.
   Shell: desktop rail + command surface; compact mobile nav at 375px.
   ================================================== */

:root {
  --mc-bg: #FEFAEC;
  --mc-bg-muted: #F7F1E3;
  --mc-surface: #FFFFFF;
  --mc-surface-tint: #EDF6FA;
  --mc-row-hover: #FBF6EC;
  --mc-title-blue: #96D8E8;
  --mc-accent: #B2D9E8;
  --mc-accent-hover: #8AC4D9;
  --mc-border-strong: #D4ECF3;
  --mc-border: #E8DFD0;
  --mc-ink: #3B1D18;
  --mc-heading: #4A3728;
  --mc-label: #6F342E;
  --mc-subhead: #7A6245;
  --mc-muted: #8A4A42;
  --mc-rail: #3B1D18;
  --mc-rail-border: #5C3A35;
  --mc-rail-text: #D4ECF3;
  --mc-warm-tint: #E4CCC9;
  --mc-warm-tint-hover: #D4B5B1;
  --mc-success: #2E7D32;
  --mc-success-bg: #D6EDDF;
  --mc-danger: #c62828;
  --mc-danger-bg: #fce4ec;
  --mc-warn-bg: #FFF3E0;
  --mc-warn: #A0785A;
  --mc-rail-width: 232px;
  --mc-topbar-height: 56px;
  --mc-radius: 10px;
  --mc-shadow: 0 1px 4px rgba(59, 29, 24, 0.06);
  --mc-shadow-lg: 0 8px 28px rgba(59, 29, 24, 0.12);
  --mc-font: 'San Francisco Pro', 'SF Pro Display', 'SF Pro Rounded', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'Segoe UI', Roboto, sans-serif;
  --mc-font-mono: 'SF Mono Pro', 'SF Mono', ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  max-width: 100%;
  /* Do not use overflow-x: clip/hidden here — it masks real overflow from assertions. */
}

body {
  font-family: var(--mc-font);
  background: var(--mc-bg);
  color: var(--mc-ink);
  font-size: 14px;
  letter-spacing: -0.01em;
  line-height: 1.45;
  width: 100%;
  min-width: 0;
}

/* ---------- App shell ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
  max-width: 100%;
  min-width: 0;
  background: var(--mc-bg);
}

.app-rail.header {
  position: sticky;
  top: 0;
  z-index: 40;
  width: var(--mc-rail-width);
  min-width: var(--mc-rail-width);
  height: 100vh;
  background: var(--mc-rail);
  color: var(--mc-rail-text);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid rgba(150, 216, 232, 0.12);
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 10px;
  border-bottom: 1px solid rgba(150, 216, 232, 0.18);
}

.rail-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--mc-title-blue), var(--mc-accent));
  color: var(--mc-heading);
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.rail-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  line-height: 1.15;
}

.rail-subtitle {
  font-size: 11px;
  color: var(--mc-title-blue);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 2px;
}

.header h1,
.app-rail .rail-title-legacy {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.app-rail nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
  padding-right: 2px;
}

.app-rail nav button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--mc-rail-text);
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  width: 100%;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.app-rail nav button:hover:not(.active) {
  border-color: rgba(150, 216, 232, 0.35);
  color: var(--mc-title-blue);
  background: rgba(150, 216, 232, 0.06);
}

.app-rail nav button.active {
  background: var(--mc-title-blue);
  color: var(--mc-heading);
  border-color: var(--mc-title-blue);
  font-weight: 700;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--mc-rail-text);
  padding-top: 12px;
  border-top: 1px solid rgba(150, 216, 232, 0.18);
  flex-wrap: wrap;
}

.user-menu .btn-logout,
.user-menu button {
  background: none;
  border: 1px solid var(--mc-rail-border);
  color: var(--mc-rail-text);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.user-menu button:hover {
  border-color: var(--mc-title-blue);
  color: var(--mc-title-blue);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--mc-title-blue);
}

.app-main {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--mc-topbar-height);
  min-height: var(--mc-topbar-height);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  background: rgba(254, 250, 236, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--mc-border);
}

.nav-toggle {
  display: none;
  background: var(--mc-surface);
  border: 1px solid var(--mc-border);
  color: var(--mc-heading);
  width: 38px;
  height: 38px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.command-surface {
  position: relative;
  flex: 1;
  min-width: 0;
  max-width: 520px;
}

.command-surface input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  border: 1px solid var(--mc-border);
  border-radius: 10px;
  background: var(--mc-surface);
  color: var(--mc-ink);
  font-size: 13px;
  box-shadow: var(--mc-shadow);
}

.command-surface input:focus {
  outline: none;
  border-color: var(--mc-title-blue);
  box-shadow: 0 0 0 3px rgba(150, 216, 232, 0.35);
}

.command-surface::before {
  content: '⌘';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--mc-subhead);
  font-weight: 700;
  pointer-events: none;
}

.command-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--mc-surface);
  border: 1px solid var(--mc-border);
  border-radius: 10px;
  box-shadow: var(--mc-shadow-lg);
  overflow: hidden;
  z-index: 50;
}

.command-results button {
  display: flex;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  color: var(--mc-heading);
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--mc-bg-muted);
}

.command-results button:last-child { border-bottom: 0; }
.command-results button:hover,
.command-results button[aria-selected="true"] {
  background: var(--mc-surface-tint);
}

.command-results .cmd-empty {
  padding: 12px 14px;
  color: var(--mc-subhead);
  font-size: 12px;
}

.topbar-page {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mc-subhead);
  white-space: nowrap;
}

.rail-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(59, 29, 24, 0.4);
  z-index: 35;
}

.app-content {
  flex: 1;
  min-width: 0;
  max-width: 100%;
}

.container {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  min-width: 0;
}

/* Local horizontal scroll for wide data tables (never document-level) */
.table-scroll {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border-radius: 8px;
}

.table-scroll .txn-table {
  margin: 0;
  width: max-content;
  min-width: 100%;
}

/* Mobile shell */
@media (max-width: 900px) {
  .app-shell { display: block; min-height: 100vh; max-width: 100%; }
  .app-main { max-width: 100%; min-width: 0; }
  .app-rail.header {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--mc-shadow-lg);
  }
  body.rail-open .app-rail.header { transform: translateX(0); }
  body.rail-open .rail-backdrop { display: block; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .command-surface { max-width: none; min-width: 0; }
  .topbar-page { display: none; }
}

/* Stack filters + tighten shell under phone widths (incl. 375px) */
@media (max-width: 480px) {
  .app-topbar { padding: 0 10px; gap: 8px; }
  .command-surface input { font-size: 12px; padding-left: 32px; }
  .container { padding: 12px; }
  .filters {
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
    gap: 8px;
  }
  .filters select,
  .filters input,
  .filters input[type="text"],
  .filters input[type="date"],
  .filters .btn,
  .filters .btn-ai-suggest {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  .filters .count {
    margin-left: 0;
    width: 100%;
  }
  .bulk-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .bulk-bar select,
  .bulk-bar .btn {
    width: 100%;
    max-width: 100%;
  }
  /* Page toolbars with inline flex/widths must not force document overflow */
  #page-merchants > div:first-child,
  #page-rules > div:first-child,
  #page-users > div:first-child,
  #page-reimburse > div:first-child {
    flex-wrap: wrap;
    gap: 8px;
  }
  #merchant-search {
    width: 100% !important;
    max-width: 100%;
    box-sizing: border-box;
  }
  #page-accounts .card > div:first-child {
    flex-wrap: wrap;
    gap: 8px;
  }
}

/* ---------- Shared login / runner chrome ---------- */
.auth-page {
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(150, 216, 232, 0.35), transparent 60%),
    var(--mc-bg);
  color: var(--mc-ink);
  padding: 0;
  box-sizing: border-box;
}

.login-container {
  width: 100%;
  max-width: min(400px, 100%);
  min-width: 0;
  flex: 0 1 auto;
  padding: 16px;
  box-sizing: border-box;
}

.login-card {
  background: var(--mc-surface);
  border-radius: 16px;
  padding: 40px 32px;
  box-shadow: var(--mc-shadow-lg);
  text-align: center;
  border: 1px solid var(--mc-border);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow-wrap: anywhere;
}

@media (max-width: 480px) {
  .login-container { padding: 12px; }
  .login-card { padding: 24px 14px; }
}

.login-card .logo { margin-bottom: 24px; min-width: 0; }
.login-card .logo h1 {
  font-size: 22px;
  color: var(--mc-heading);
  font-weight: 700;
  overflow-wrap: anywhere;
}
.login-card .logo p {
  font-size: 14px;
  color: var(--mc-subhead);
  margin-top: 4px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0;
  min-width: 0;
  max-width: 100%;
}
.divider span {
  font-size: 12px;
  color: var(--mc-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.divider::before,
.divider::after {
  content: '';
  flex: 1;
  min-width: 0;
  height: 1px;
  background: var(--mc-title-blue);
}

#google-signin-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 20px 0;
  min-height: 44px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* GSI injects a fixed-width iframe/div; force it inside the card */
#google-signin-container > div,
#google-signin-container iframe {
  max-width: 100% !important;
}

.pin-section {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.pin-section input {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 12px 16px;
  border: 1px solid var(--mc-border-strong);
  border-radius: 8px;
  font-size: 15px;
  margin-bottom: 10px;
  color: var(--mc-ink);
  background: var(--mc-surface);
}
.pin-section input:focus {
  outline: none;
  border-color: var(--mc-title-blue);
  box-shadow: 0 0 0 2px rgba(150, 216, 232, 0.35);
}

.btn-pin {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 12px;
  background: var(--mc-surface-tint);
  color: var(--mc-label);
  border: 1px solid var(--mc-border-strong);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-pin:hover { background: var(--mc-border-strong); }

.error-msg {
  color: var(--mc-danger);
  font-size: 13px;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--mc-danger-bg);
  border-radius: 6px;
  display: none;
}

.not-configured {
  color: var(--mc-muted);
  font-size: 13px;
  padding: 16px;
  background: var(--mc-warn-bg);
  border-radius: 8px;
  margin-bottom: 16px;
  line-height: 1.5;
}
.not-configured code {
  background: var(--mc-bg-muted);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: var(--mc-font-mono);
}

/* Runner page shell pieces (styles.css shared) */
.runner-header {
  background: var(--mc-rail);
  color: var(--mc-accent);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.runner-header h1 { font-size: 17px; font-weight: 600; color: var(--mc-title-blue); }
.runner-header .user-info {
  font-size: 13px;
  color: var(--mc-rail-text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.runner-header button {
  background: none;
  border: 1px solid var(--mc-rail-border);
  color: var(--mc-rail-text);
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

#login-view,
#main-view {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.runner-container {
  width: 100%;
  max-width: min(600px, 100%);
  min-width: 0;
  margin: 0 auto;
  padding: 16px;
  box-sizing: border-box;
}

.runner-login-card {
  background: var(--mc-surface);
  border-radius: 12px;
  padding: 32px 20px;
  box-shadow: var(--mc-shadow);
  text-align: center;
  margin-top: 40px;
  border: 1px solid var(--mc-border);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow-wrap: anywhere;
}
.runner-login-card h2 { color: var(--mc-label); font-size: 20px; margin-bottom: 8px; }
.runner-login-card p {
  color: var(--mc-muted);
  font-size: 14px;
  margin-bottom: 24px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.runner-login-card input {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 12px 16px;
  border: 1px solid var(--mc-border-strong);
  border-radius: 8px;
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--mc-ink);
  box-sizing: border-box;
}

@media (max-width: 480px) {
  .runner-login-card { margin-top: 24px; padding: 24px 14px; }
  .runner-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 14px;
  }
  .runner-header h1 { font-size: 15px; min-width: 0; }
  .runner-header .user-info { min-width: 0; flex-wrap: wrap; }
  .upload-zone { padding: 32px 14px; }
}
.runner-login-card input:focus {
  outline: none;
  border-color: var(--mc-title-blue);
  box-shadow: 0 0 0 2px rgba(150, 216, 232, 0.3);
}
.login-error {
  color: var(--mc-danger);
  font-size: 13px;
  margin-bottom: 12px;
  display: none;
}

.btn-block {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.upload-zone {
  background: var(--mc-surface);
  border: 3px dashed var(--mc-accent);
  border-radius: 12px;
  padding: 48px 20px;
  text-align: center;
  margin-bottom: 20px;
  cursor: pointer;
  transition: all 0.2s;
}
.upload-zone.dragover {
  border-color: var(--mc-accent-hover);
  background: var(--mc-surface-tint);
}
.upload-zone .icon { font-size: 48px; margin-bottom: 8px; }
.upload-zone h2 { font-size: 17px; color: var(--mc-label); margin-bottom: 4px; }
.upload-zone p { color: var(--mc-muted); font-size: 13px; margin-bottom: 16px; }
.upload-zone input[type="file"] { display: none; }

.receipt-card {
  background: var(--mc-surface);
  border-radius: 10px;
  box-shadow: var(--mc-shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.receipt-card.processing { opacity: 0.7; }
.receipt-card.submitted { border-left: 4px solid var(--mc-success); }
.receipt-preview {
  background: var(--mc-bg-muted);
  padding: 16px;
  text-align: center;
  position: relative;
}
.receipt-preview img {
  max-width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: 6px;
}
.receipt-preview .processing-text {
  position: absolute;
  inset: 0;
  background: rgba(254, 250, 236, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--mc-label);
}
.receipt-details { padding: 16px; }
.receipt-details h3 { font-size: 15px; color: var(--mc-label); margin-bottom: 8px; }
.receipt-extracted { font-size: 13px; color: var(--mc-label); line-height: 1.6; margin-bottom: 12px; }
.receipt-extracted strong { color: var(--mc-ink); }
.field-group { margin-bottom: 10px; }
.field-group label {
  font-size: 11px;
  color: var(--mc-label);
  text-transform: uppercase;
  font-weight: 600;
  display: block;
  margin-bottom: 3px;
}
.field-group select,
.field-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--mc-border-strong);
  border-radius: 6px;
  font-size: 14px;
  color: var(--mc-ink);
}
.field-group select:focus,
.field-group input:focus {
  outline: none;
  border-color: var(--mc-title-blue);
}
.receipt-actions { display: flex; gap: 8px; margin-top: 12px; }
.receipt-actions .btn { padding: 10px 16px; font-size: 14px; }
.receipt-status { font-size: 14px; font-weight: 600; color: var(--mc-success); padding: 8px 0; }
.receipt-error {
  color: var(--mc-danger);
  font-size: 12px;
  background: var(--mc-danger-bg);
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 8px;
}
.submissions-header {
  font-size: 15px;
  color: var(--mc-label);
  font-weight: 600;
  margin: 24px 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.submission-item {
  background: var(--mc-surface);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
  box-shadow: var(--mc-shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.submission-item .info { flex: 1; }
.submission-item .info .date { font-size: 12px; color: var(--mc-muted); }
.submission-item .info .desc { font-size: 14px; color: var(--mc-ink); }
.submission-item .amount { font-size: 15px; font-weight: 600; color: var(--mc-ink); }
.submission-item .status-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}
.status-pending { background: var(--mc-warn-bg); color: var(--mc-warn); }
.status-approved { background: #D6EDE8; color: #2E6B5C; }
.status-paid { background: var(--mc-border-strong); color: #2A6F8A; }
.status-denied { background: var(--mc-danger-bg); color: var(--mc-danger); }

.toast.toast-center {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}



/* Filters */
.filters {
  background: white;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  box-shadow: 0 1px 4px rgba(59,29,24,0.06);
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.filters select, .filters input {
  padding: 6px 10px;
  border: 1px solid var(--mc-border-strong);
  border-radius: 6px;
  font-size: 13px;
  color: var(--mc-ink);
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.filters select:focus, .filters input:focus { outline: none; border-color: var(--mc-accent); box-shadow: 0 0 0 2px rgba(178,217,232,0.3); }
.filters input[type="text"] { width: 200px; max-width: 100%; }
.filters .count { margin-left: auto; font-size: 13px; color: var(--mc-label); font-weight: 500; }

/* Phone: full-width filter stack (must follow base .filters rules for cascade) */
@media (max-width: 480px) {
  .filters {
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
    gap: 8px;
  }
  .filters select,
  .filters input,
  .filters input[type="text"],
  .filters input[type="date"],
  .filters .btn,
  .filters .btn-ai-suggest {
    width: 100% !important;
    max-width: 100%;
    min-width: 0;
    flex: 1 1 auto;
  }
  .filters .count {
    margin-left: 0;
    width: 100%;
  }
}

/* Table */
.txn-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(59,29,24,0.06);
}
.txn-table th { background: var(--mc-surface-tint); text-align: left; padding: 10px 12px; font-size: 12px; font-weight: 600; color: var(--mc-label); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 2px solid var(--mc-border-strong); }
.txn-table td { padding: 8px 12px; border-bottom: 1px solid var(--mc-bg-muted); font-size: 13px; vertical-align: middle; }
.txn-table tr:hover { background: var(--mc-row-hover); }

.txn-table select { padding: 4px 6px; border: 1px solid var(--mc-border-strong); border-radius: 4px; font-size: 12px; max-width: 150px; color: var(--mc-ink); }
.txn-table select:focus { border-color: var(--mc-accent); outline: none; }
.txn-table select:disabled { background: var(--mc-bg-muted); color: #999; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.badge-amex { background: var(--mc-border-strong); color: #2A6F8A; }
.badge-relay { background: var(--mc-warm-tint); color: var(--mc-label); }
.badge-homedepot { background: #F5E6D0; color: #8B5E34; }
.badge-amazon { background: #FFF3E0; color: #A0785A; }
.badge-venmo { background: #D6EDE8; color: #2E6B5C; }
.badge-receipt_upload { background: var(--mc-warm-tint); color: var(--mc-label); }
.badge-api { background: #D6EDDF; color: #2E7D32; }
.badge-plaid { background: #E8E0F0; color: #5E35B1; }
.badge-email_invoice { background: #FFF3E0; color: #A0785A; }
.badge-runner { background: #D6EDE8; color: #2E6B5C; }
.badge-admin { background: var(--mc-border-strong); color: #2A6F8A; }

.amount { font-variant-numeric: tabular-nums; font-weight: 500; }
.amount.expense { color: var(--mc-ink); }
.amount.income { color: #2E7D32; }

/* Buttons */
.btn { padding: 4px 10px; border: none; border-radius: 4px; cursor: pointer; font-size: 12px; font-weight: 500; }
.btn-save { background: var(--mc-accent); color: var(--mc-ink); }
.btn-save:hover { background: var(--mc-accent-hover); }
.btn-skip { background: var(--mc-surface-tint); color: var(--mc-label); }
.btn-skip:hover { background: var(--mc-border-strong); }
.btn-primary { background: var(--mc-accent); color: var(--mc-ink); padding: 8px 16px; font-size: 14px; border-radius: 6px; font-weight: 600; }
.btn-primary:hover { background: var(--mc-accent-hover); }
.btn-export { background: white; border: 1px solid var(--mc-border-strong); padding: 10px 20px; border-radius: 6px; cursor: pointer; font-size: 14px; color: var(--mc-label); }
.btn-export:hover { background: var(--mc-bg-muted); border-color: var(--mc-accent); }

/* Bulk bar */
.bulk-bar { background: var(--mc-ink); color: var(--mc-border-strong); padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; display: none; align-items: center; gap: 12px; flex-wrap: wrap; }
.bulk-bar.visible { display: flex; }
.bulk-bar select { padding: 4px 8px; border-radius: 4px; font-size: 13px; }
.bulk-bar .bulk-count { font-weight: 600; color: var(--mc-accent); }

/* Pagination */
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.pagination button { padding: 6px 12px; border: 1px solid var(--mc-border-strong); border-radius: 6px; background: white; cursor: pointer; font-size: 13px; color: var(--mc-ink); }
.pagination button.active { background: var(--mc-accent); color: var(--mc-ink); border-color: var(--mc-accent); font-weight: 600; }
.pagination button:disabled { opacity: 0.4; cursor: default; }

/* Dashboard */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.card { background: white; border-radius: 8px; padding: 20px; box-shadow: 0 1px 4px rgba(59,29,24,0.06); }
.card h3 { font-size: 14px; color: var(--mc-label); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.card .big-number { font-size: 32px; font-weight: 700; color: var(--mc-ink); }
.card table { width: 100%; border-collapse: collapse; }
.card table th { text-align: left; font-size: 12px; color: var(--mc-label); padding: 6px 8px; border-bottom: 1px solid var(--mc-border-strong); }
.card table td { padding: 6px 8px; font-size: 13px; border-bottom: 1px solid var(--mc-bg-muted); }

.progress-bar { background: var(--mc-surface-tint); border-radius: 4px; height: 8px; margin-top: 8px; overflow: hidden; }
.progress-bar .fill { background: var(--mc-accent); height: 100%; border-radius: 4px; transition: width 0.3s; }

.project-spend-toolbar { align-items: center; background: white; border-radius: 8px; box-shadow: 0 1px 4px rgba(59,29,24,0.06); display: flex; gap: 10px; margin-bottom: 16px; padding: 10px 14px; }
.project-spend-toolbar label { color: var(--mc-label); font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.project-spend-toolbar select { border: 1px solid var(--mc-border-strong); border-radius: 6px; color: var(--mc-ink); font-size: 13px; max-width: 320px; padding: 6px 10px; }
.project-spend-toolbar select:focus { border-color: var(--mc-accent); box-shadow: 0 0 0 2px rgba(178,217,232,0.3); outline: none; }
.project-spend-toolbar select:disabled { background: var(--mc-bg-muted); color: #999; }
#dashboard-project-state { color: var(--mc-label); font-size: 12px; margin-left: auto; }
.dashboard-metric-note { margin-top: 8px; color: var(--mc-label); font-size: 12px; line-height: 1.45; }
.dashboard-budget-note { background: #FFF3E0; border-left: 3px solid #A0785A; border-radius: 4px; color: var(--mc-label); font-size: 12px; line-height: 1.4; margin-bottom: 12px; padding: 8px 10px; }
.dashboard-table-wrap { max-width: 100%; overflow-x: auto; }
.dashboard-placeholder td { color: var(--mc-muted); padding: 14px 8px !important; text-align: center; }
.dashboard-placeholder.is-error td { background: #fce4ec; color: #c62828; }

@media (max-width: 700px) {
    #page-dashboard.container { padding: 12px; }
    #page-dashboard .dashboard-grid { grid-template-columns: 1fr; }
    #page-dashboard .card { padding: 16px; }
    #page-dashboard .project-spend-toolbar { align-items: stretch; flex-direction: column; }
    #page-dashboard .project-spend-toolbar select { max-width: none; width: 100%; }
    #page-dashboard #dashboard-project-state { margin-left: 0; }
    #page-dashboard .dashboard-grid .card table,
    #page-dashboard .dashboard-table-wrap table { table-layout: fixed; }
    #page-dashboard .dashboard-grid .card table th,
    #page-dashboard .dashboard-grid .card table td,
    #page-dashboard .dashboard-table-wrap table th,
    #page-dashboard .dashboard-table-wrap table td { font-size: 10px; overflow-wrap: anywhere; padding: 6px 3px; white-space: normal; }
}

/* Source Health */
.source-health-card { background: var(--mc-bg); border: 1px solid var(--mc-title-blue); margin-bottom: 16px; font-family: 'San Francisco Pro', 'SF Mono Pro', 'Helvetica Neue', sans-serif; color: var(--mc-heading); overflow: hidden; }
.source-health-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 14px; border-bottom: 2px solid var(--mc-title-blue); }
.source-health-eyebrow { color: var(--mc-subhead); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 3px; }
.source-health-header h2 { color: var(--mc-heading); font-size: 20px; line-height: 1.2; }
.source-health-state { flex-shrink: 0; border-radius: 999px; padding: 5px 10px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.source-health-card.is-cleared .source-health-state { background: #D6EDDF; color: #2E7D32; }
.source-health-card.is-loading .source-health-state { background: var(--mc-title-blue); color: var(--mc-heading); }
.source-health-card.is-blocked .source-health-state,
.source-health-card.is-error .source-health-state { background: #fce4ec; color: #c62828; }
.source-health-summary { color: var(--mc-subhead); font-size: 13px; line-height: 1.5; margin: 12px 0; }
.source-health-blockers { background: #fce4ec; border-left: 3px solid #c62828; border-radius: 4px; margin-bottom: 14px; padding: 8px 10px; }
.source-health-blockers ul { list-style: none; display: grid; gap: 6px; }
.source-health-blockers li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; color: var(--mc-heading); font-size: 12px; line-height: 1.4; }
.source-health-blockers code { color: var(--mc-subhead); font-family: 'SF Mono Pro', 'Helvetica Neue', monospace; font-size: 10px; white-space: nowrap; }
.source-health-table-wrap { width: 100%; max-width: 100%; min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.source-health-table { width: 100%; border-collapse: collapse; }
.source-health-table th { color: var(--mc-subhead) !important; border-bottom-color: var(--mc-title-blue) !important; font-family: 'SF Mono Pro', 'Helvetica Neue', monospace; font-size: 10px !important; letter-spacing: 0.03em; text-transform: uppercase; }
.source-health-table td { color: var(--mc-heading); font-size: 12px !important; vertical-align: top; }
.source-health-table tbody tr:last-child td { border-bottom: 0; }
.source-health-count { font-family: 'SF Mono Pro', 'Helvetica Neue', monospace; font-variant-numeric: tabular-nums; white-space: nowrap; }
.source-health-issues { display: flex; flex-wrap: wrap; gap: 4px; }
.source-health-issue { background: #fce4ec; color: #c62828; border-radius: 999px; font-size: 10px; font-weight: 700; padding: 2px 6px; white-space: nowrap; }
.source-health-no-issues { color: #2E7D32; font-size: 11px; font-weight: 600; }
.source-health-extra { background: var(--mc-title-blue); color: var(--mc-heading); border-radius: 999px; font-size: 9px; font-weight: 700; margin-left: 6px; padding: 2px 5px; text-transform: uppercase; }
.source-health-placeholder td { color: var(--mc-subhead); padding: 14px 8px !important; text-align: center; }

@media (max-width: 700px) {
    .source-health-card { padding: 16px; }
    .source-health-header h2 { font-size: 18px; }
    .source-health-blockers li { align-items: flex-start; flex-direction: column; gap: 2px; }
    .source-health-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .source-health-table,
    .source-health-table tbody,
    .source-health-table tr,
    .source-health-table td { display: block; width: 100%; }
    .source-health-table tr { border-bottom: 1px solid var(--mc-title-blue); display: grid; gap: 8px 14px; grid-template-columns: 1fr 1fr; padding: 12px 0; }
    .source-health-table tr:last-child { border-bottom: 0; }
    .source-health-table td { border: 0 !important; padding: 0 !important; min-width: 0; }
    .source-health-table td:first-child,
    .source-health-table td:last-child { grid-column: 1 / -1; }
    .source-health-table td::before { color: var(--mc-subhead); content: attr(data-label); display: block; font-family: 'SF Mono Pro', 'Helvetica Neue', monospace; font-size: 9px; font-weight: 700; letter-spacing: 0.03em; margin-bottom: 2px; text-transform: uppercase; }
    .source-health-placeholder { display: block !important; }
    .source-health-placeholder td { text-align: left; }
    .source-health-placeholder td::before { display: none; }
}

/* Variance */
.variance-positive { color: #2E7D32; }
.variance-negative { color: #c62828; }

/* Export page */
.export-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.export-card { background: white; border-radius: 8px; padding: 24px; box-shadow: 0 1px 4px rgba(59,29,24,0.06); text-align: center; }
.export-card h3 { margin-bottom: 8px; color: var(--mc-label); }
.export-card p { color: var(--mc-muted); font-size: 13px; margin-bottom: 16px; }

/* Checkbox */
.txn-table input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--mc-accent); }

/* Split Modal */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(59,29,24,0.45); z-index: 900; display: flex; align-items: center; justify-content: center; }
.modal { background: white; border-radius: 12px; width: 900px; max-width: 95vw; max-height: 85vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(59,29,24,0.2); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--mc-border-strong); }
.modal-header h2 { font-size: 16px; color: var(--mc-label); }
.modal-header button { font-size: 18px; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; }
.modal-info { padding: 12px 20px; background: var(--mc-bg-muted); font-size: 13px; color: var(--mc-label); border-bottom: 1px solid var(--mc-border-strong); }
.modal-info strong { color: var(--mc-ink); }

.split-line { display: grid; grid-template-columns: 100px 1fr 1fr 1fr 1fr 1fr 36px; gap: 8px; padding: 10px 20px; border-bottom: 1px solid var(--mc-bg-muted); align-items: center; }
.split-line:first-child { padding-top: 14px; }
.split-line label { font-size: 11px; color: var(--mc-label); text-transform: uppercase; font-weight: 600; }
.split-line input, .split-line select { padding: 6px 8px; border: 1px solid var(--mc-border-strong); border-radius: 4px; font-size: 13px; width: 100%; color: var(--mc-ink); }
.split-line input:focus, .split-line select:focus { border-color: var(--mc-accent); outline: none; }
.split-line input[type="number"] { font-variant-numeric: tabular-nums; }
.split-line .remove-line { background: none; border: none; color: #c62828; cursor: pointer; font-size: 18px; padding: 4px; }
.split-line .remove-line:hover { background: #fce4ec; border-radius: 4px; }

.split-footer { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-top: 1px solid var(--mc-border-strong); background: var(--mc-bg-muted); border-radius: 0 0 12px 12px; }
.split-total { font-size: 14px; font-weight: 600; color: var(--mc-ink); }
.split-total.over { color: #c62828; }
.split-total.balanced { color: #2E7D32; }
.split-actions { display: flex; gap: 8px; }

/* Receipt button & icon */
.btn-receipt { background: var(--mc-border-strong); color: #2A6F8A; padding: 4px 6px; border: none; border-radius: 4px; cursor: pointer; font-size: 13px; }
.btn-receipt:hover { background: var(--mc-accent); }
.btn-receipt:disabled { opacity: 0.5; cursor: default; }
.receipt-icon { text-decoration: none; font-size: 14px; margin-right: 4px; cursor: pointer; }
.receipt-icon:hover { opacity: 0.7; }

/* Auto Split button */
.btn-auto-split { background: var(--mc-warm-tint); color: var(--mc-label); padding: 4px 8px; border: none; border-radius: 4px; cursor: pointer; font-size: 11px; font-weight: 600; }
.btn-auto-split:hover { background: var(--mc-warm-tint-hover); }

/* Split badge on triage table */
.badge-split { background: var(--mc-border-strong); color: #2A6F8A; font-size: 10px; padding: 1px 6px; border-radius: 8px; margin-left: 4px; }

/* Magic Upload */
.magic-dropzone { background: white; border: 3px dashed var(--mc-accent); border-radius: 12px; padding: 60px 20px; text-align: center; margin-bottom: 24px; transition: all 0.2s; cursor: pointer; box-shadow: 0 1px 4px rgba(59,29,24,0.06); }
.magic-dropzone.dragover { border-color: var(--mc-accent-hover); background: var(--mc-bg-muted); }
.magic-dropzone-icon { font-size: 48px; margin-bottom: 12px; }
.magic-dropzone h2 { font-size: 18px; margin-bottom: 6px; color: var(--mc-label); }
.magic-dropzone p { color: var(--mc-muted); font-size: 13px; margin-bottom: 16px; }

.magic-card { background: white; border-radius: 10px; box-shadow: 0 2px 8px rgba(59,29,24,0.08); margin-bottom: 16px; overflow: hidden; display: grid; grid-template-columns: 300px 1fr; min-height: 280px; }
.magic-card.processing { opacity: 0.7; }
.magic-card.approved { border-left: 4px solid var(--mc-accent); }

.magic-card-preview { background: var(--mc-bg-muted); display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.magic-card-preview img { max-width: 100%; max-height: 350px; object-fit: contain; }
.magic-card-preview .pdf-label { color: var(--mc-label); font-size: 14px; }
.magic-card-preview .processing-overlay { position: absolute; inset: 0; background: rgba(244,249,252,0.85); display: flex; align-items: center; justify-content: center; font-size: 14px; color: var(--mc-label); }

.magic-card-details { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.magic-card-header { display: flex; justify-content: space-between; align-items: flex-start; }
.magic-card-header h3 { font-size: 15px; color: var(--mc-label); }
.magic-card-match { font-size: 12px; padding: 3px 10px; border-radius: 10px; font-weight: 600; }
.magic-card-match.existing { background: var(--mc-border-strong); color: #2A6F8A; }
.magic-card-match.new { background: var(--mc-warm-tint); color: var(--mc-label); }

.magic-card-extracted { font-size: 13px; color: var(--mc-label); line-height: 1.5; }
.magic-card-extracted strong { color: var(--mc-ink); }

.magic-card-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.magic-card-fields label { font-size: 11px; color: var(--mc-label); text-transform: uppercase; font-weight: 600; display: block; margin-bottom: 2px; }
.magic-card-fields select { width: 100%; padding: 6px 8px; border: 1px solid var(--mc-border-strong); border-radius: 4px; font-size: 13px; color: var(--mc-ink); }
.magic-card-fields select:focus { border-color: var(--mc-accent); outline: none; }

.magic-card-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 8px; }
.magic-card-actions .btn { padding: 8px 16px; font-size: 13px; }
.magic-card-status { font-size: 13px; font-weight: 600; color: #2A6F8A; padding: 8px 0; }

.magic-card-error { color: #c62828; font-size: 12px; background: #fce4ec; padding: 6px 10px; border-radius: 4px; }

@media (max-width: 700px) {
    .magic-card { grid-template-columns: 1fr; }
    .magic-card-preview { max-height: 200px; }
}

/* 1099 Tracker */
.ten99-summary-row:hover { background: var(--mc-bg-muted); }
.ten99-arrow { display: inline-block; width: 16px; font-size: 10px; color: var(--mc-label); transition: transform 0.2s; }

/* AI Suggest button */
.btn-ai-suggest { background: var(--mc-accent); color: var(--mc-ink); padding: 6px 14px; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; }
.btn-ai-suggest:hover { background: var(--mc-accent-hover); }
.btn-ai-suggest:disabled { opacity: 0.6; cursor: default; }

/* Recurring checkbox */
.recurring-label { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--mc-label); cursor: pointer; vertical-align: middle; margin-right: 4px; }
.recurring-label input { width: 13px; height: 13px; accent-color: var(--mc-accent); cursor: pointer; }
.recurring-label span { font-weight: 500; }

/* Rules page */
.rule-form-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.rule-form-grid label { font-size: 11px; color: var(--mc-label); text-transform: uppercase; font-weight: 600; display: block; margin-bottom: 3px; }
.rule-form-grid input, .rule-form-grid select { width: 100%; padding: 6px 8px; border: 1px solid var(--mc-border-strong); border-radius: 4px; font-size: 13px; color: var(--mc-ink); }
.rule-form-grid input:focus, .rule-form-grid select:focus { border-color: var(--mc-accent); outline: none; }

/* Merchants page */
.merchant-grid { display: flex; flex-direction: column; gap: 8px; }
.merchant-card { background: white; border-radius: 8px; padding: 14px 16px; box-shadow: 0 1px 4px rgba(59,29,24,0.06); }
.merchant-card-header { display: flex; align-items: center; gap: 12px; }
.merchant-logo { width: 32px; height: 32px; border-radius: 6px; flex-shrink: 0; background: var(--mc-bg-muted); }
.merchant-info { flex: 1; min-width: 0; }
.merchant-name { font-size: 14px; font-weight: 600; color: var(--mc-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.merchant-meta { font-size: 12px; color: var(--mc-muted); margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.merchant-amount { font-size: 16px; font-weight: 700; color: var(--mc-ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.merchant-projects { font-size: 12px; color: var(--mc-label); margin-top: 6px; }
.merchant-dates { font-size: 11px; color: #999; margin-top: 2px; }

/* Toast */
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--mc-ink); color: var(--mc-border-strong); padding: 12px 20px; border-radius: 8px; font-size: 14px; z-index: 1000; opacity: 0; transition: opacity 0.3s; pointer-events: none; }
.toast.show { opacity: 1; }
.focus-spend { margin-bottom: 16px; }
.focus-spend-heading { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; margin-bottom:12px; }
.focus-spend-heading h2 { color:var(--mc-ink); font-size:20px; }
.focus-spend-heading > span { color:var(--mc-label); font-size:12px; padding-top:4px; }
.focus-spend-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }
.focus-spend-card { border-top:4px solid var(--mc-accent); }
.focus-spend-card-header { display:flex; justify-content:space-between; gap:10px; align-items:flex-start; }
.focus-spend-card-header h3 { margin:0; color:var(--mc-ink); }
.focus-spend-card-header span { color:var(--mc-label); font-size:11px; text-align:right; }
.focus-spend-total { color:var(--mc-ink); font-size:34px; font-weight:750; letter-spacing:-1px; margin-top:16px; }
.focus-spend-label,.focus-spend-method { color:var(--mc-label); font-size:12px; }
.focus-spend-breakdown { margin:16px 0; }
.focus-spend-breakdown div { display:flex; justify-content:space-between; gap:12px; padding:7px 0; border-top:1px solid var(--mc-border); }
.focus-spend-breakdown dt { color:var(--mc-label); }
.focus-spend-breakdown dd { color:var(--mc-ink); font-weight:650; text-align:right; }
.focus-spend-method { margin-top:8px; }
.badge-audited { display:block; width:max-content; max-width:100%; margin-top:5px; padding:3px 6px; border-radius:999px; background:#E6F4EA; color:#1B5E20; font-size:10px; font-weight:700; }
@media (max-width: 760px) {
    .focus-spend-grid { grid-template-columns:1fr; }
    .focus-spend-heading { display:block; }
    .focus-spend-total { font-size:30px; }
}

/* ==========================================================================
   Needs You -- attention-first triage surface (decision cards, piles,
   Power Through, case chat) and the Pulse panel. See needs-you.js / pulse.js.
   ========================================================================== */

.ny-session-banner {
  margin: 0 0 16px; padding: 10px 14px; border-radius: var(--mc-radius);
  background: var(--mc-surface-tint); border: 1px solid var(--mc-border-strong);
  color: var(--mc-label); font-size: 12px; line-height: 1.5;
}

.ny-toolbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  justify-content: space-between; margin-bottom: 18px;
}
.ny-toolbar-actions { display: flex; gap: 8px; }

.pile-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.pile-tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border: 1px solid var(--mc-border); border-radius: 999px;
  background: var(--mc-surface); color: var(--mc-label);
  font-size: 13px; font-weight: 500; cursor: pointer;
}
.pile-tab:hover { background: var(--mc-row-hover); }
.pile-tab.active {
  background: var(--mc-accent); border-color: var(--mc-accent-hover);
  color: var(--mc-ink); font-weight: 600;
}
.pile-count {
  min-width: 20px; padding: 1px 6px; border-radius: 999px;
  background: var(--mc-bg-muted); color: var(--mc-subhead);
  font-size: 11px; font-weight: 600; text-align: center;
}
.pile-tab.active .pile-count { background: var(--mc-surface); color: var(--mc-ink); }

.decision-card-grid { display: flex; flex-direction: column; gap: 14px; }
.ny-empty {
  padding: 32px 16px; text-align: center; color: var(--mc-subhead); font-size: 14px;
}

.decision-card {
  background: var(--mc-surface); border: 1px solid var(--mc-border);
  border-radius: var(--mc-radius); box-shadow: var(--mc-shadow); padding: 16px 18px;
  min-width: 0; overflow-wrap: anywhere;
}
.decision-card .btn:disabled { opacity: 0.55; cursor: not-allowed; }
.decision-card-head {
  display: flex; gap: 12px; align-items: flex-start; justify-content: space-between;
}
.decision-card-merchant { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 0; }
.decision-card-desc { color: var(--mc-heading); font-size: 15px; font-weight: 600; }
.decision-card-amount { font-size: 18px; font-weight: 700; white-space: nowrap; }
.decision-card-amount.expense { color: var(--mc-ink); }
.decision-card-amount.income { color: var(--mc-success); }

.decision-card-meta {
  display: flex; flex-wrap: wrap; gap: 14px; margin-top: 6px;
  color: var(--mc-subhead); font-size: 12px;
}

.case-proposal {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin: 12px 0; padding: 10px 12px; border-radius: 8px;
  background: var(--mc-bg-muted); color: var(--mc-heading); font-size: 13px;
}
.case-proposal-project { font-weight: 600; }
.case-proposal-sep { color: var(--mc-subhead); }
.case-proposal-qb { color: var(--mc-subhead); }
.case-proposal-corrected { color: var(--mc-warn); font-weight: 600; }
.case-proposal-empty { background: var(--mc-warn-bg); color: var(--mc-warn); }

.decision-card-reason { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; color: var(--mc-subhead); }
.confidence-pill {
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--mc-border-strong); color: #2A6F8A;
}
.confidence-none { background: var(--mc-warn-bg); color: var(--mc-warn); }
.confidence-manual, .confidence-auto_hd { background: var(--mc-success-bg); color: var(--mc-success); }

.decision-card-evidence, .decision-card-agent { margin-top: 8px; font-size: 12px; color: var(--mc-subhead); }
.case-evidence-none { color: var(--mc-muted); }

.decision-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.decision-card-secondary { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
.link-action {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--mc-label); font-size: 12px; text-decoration: underline;
}
.link-action:hover { color: var(--mc-ink); }

.bundle-card { border-left: 3px solid var(--mc-accent-hover); }

/* -- Reference cases (reference-cases.js): source-verified, session-only -- */
.reference-card { border-left: 3px solid var(--mc-warn); }
.badge-reference { background: var(--mc-warn-bg); color: var(--mc-warn); }
.ref-headline { margin: 12px 0 8px; color: var(--mc-heading); font-size: 14px; font-weight: 600; }
.ref-alloc { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ref-alloc-row {
  display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 2px 12px;
  padding: 8px 10px; border-radius: 8px; background: var(--mc-bg-muted); font-size: 13px;
  min-width: 0;
}
.ref-alloc-amount { grid-row: span 2; font-weight: 700; color: var(--mc-ink); }
.ref-alloc-label { color: var(--mc-heading); font-weight: 600; }
.ref-alloc-note { color: var(--mc-subhead); font-size: 12px; line-height: 1.45; }
.ref-alloc-blocked { background: var(--mc-warn-bg); }
.ref-net { margin: 0 0 10px; font-size: 13px; color: var(--mc-heading); }
.ref-why-blank, .ref-blocking {
  margin: 0 0 10px; font-size: 12px; line-height: 1.55; color: var(--mc-subhead);
}
.ref-blocking { padding-left: 10px; border-left: 2px solid var(--mc-border); }
.ref-question {
  margin-top: 12px; padding: 12px 14px; border-radius: 8px;
  background: var(--mc-surface-tint); border: 1px solid var(--mc-border-strong);
}
.ref-question-prompt { margin: 0 0 4px; font-size: 14px; font-weight: 600; color: var(--mc-heading); }
.ref-question-scope { margin: 0 0 10px; font-size: 12px; color: var(--mc-subhead); }
.ref-question-answers { display: flex; flex-wrap: wrap; gap: 8px; }
.ref-refused { margin: 10px 0 0; font-size: 12px; color: var(--mc-muted); }
.ref-answered {
  margin-top: 12px; padding: 10px 12px; border-radius: 8px;
  background: var(--mc-success-bg); color: var(--mc-heading); font-size: 13px; line-height: 1.5;
}
.ref-answered-scope { display: block; margin-top: 4px; color: var(--mc-subhead); font-size: 11px; }
.ref-provenance { margin: 10px 0 0; font-size: 11px; color: var(--mc-muted); line-height: 1.5; }

/* -- Power Through -- */
.power-through-overlay {
  position: fixed; inset: 0; z-index: 900; display: flex; flex-direction: column;
  background: var(--mc-bg); padding: 20px;
}
.power-through-overlay[hidden] { display: none; }
.power-through-shell {
  display: flex; flex-direction: column; flex: 1; min-height: 0;
  max-width: 720px; width: 100%; margin: 0 auto;
}
.power-through-header {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  justify-content: space-between; margin-bottom: 16px; color: var(--mc-subhead); font-size: 13px;
}
.power-through-card { flex: 1; min-height: 0; overflow-y: auto; }
.power-through-keys {
  display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px;
  color: var(--mc-subhead); font-size: 12px;
}
.power-through-keys kbd {
  padding: 1px 6px; border: 1px solid var(--mc-border); border-radius: 4px;
  background: var(--mc-surface); font-size: 11px; font-family: inherit;
}
body.power-through-active { overflow: hidden; }

/* -- Case chat -- */
.chat-panel {
  position: fixed; right: 0; top: 0; bottom: 0; width: min(420px, 100%);
  z-index: 950; flex-direction: column;
  background: var(--mc-surface); border-left: 1px solid var(--mc-border);
  box-shadow: -2px 0 12px rgba(59, 29, 24, 0.10);
}
.chat-shell { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-header {
  display: flex; gap: 12px; align-items: flex-start; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--mc-border);
}
.chat-title { color: var(--mc-heading); font-size: 14px; font-weight: 600; }
.chat-context { margin-top: 4px; color: var(--mc-subhead); font-size: 12px; }
.chat-log { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 88%; padding: 9px 12px; border-radius: 12px; font-size: 13px; line-height: 1.5; }
.chat-msg-agent { align-self: flex-start; background: var(--mc-bg-muted); color: var(--mc-heading); }
.chat-msg-user { align-self: flex-end; background: var(--mc-accent); color: var(--mc-ink); }
.chat-input-row { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--mc-border); }
.chat-input-row input {
  flex: 1; min-width: 0; padding: 8px 10px;
  border: 1px solid var(--mc-border); border-radius: 6px; font-size: 13px;
}
.chat-mic { flex: 0 0 auto; }
.chat-disclaimer {
  margin: 0; padding: 10px 16px; border-top: 1px solid var(--mc-border);
  background: var(--mc-bg-muted); color: var(--mc-subhead); font-size: 11px; line-height: 1.5;
}

/* -- Pulse -- */
.pulse-coverage-banner {
  margin: 0 0 16px; padding: 10px 14px; border-radius: var(--mc-radius);
  border: 1px solid var(--mc-border); font-size: 13px; line-height: 1.5;
}
.pulse-coverage-banner.is-unknown { background: var(--mc-bg-muted); color: var(--mc-subhead); }
.pulse-coverage-banner.is-cleared { background: var(--mc-success-bg); color: var(--mc-success); border-color: var(--mc-success-bg); }
.pulse-coverage-banner.is-blocked { background: var(--mc-warn-bg); color: var(--mc-warn); border-color: var(--mc-warn-bg); }

.pulse-stat-row { display: flex; flex-wrap: wrap; gap: 20px; }
.pulse-stat-num { color: var(--mc-heading); font-size: 26px; font-weight: 700; }
.pulse-stat-label { color: var(--mc-subhead); font-size: 12px; }

.pulse-bar-list, .pulse-vendor-list, .pulse-opportunity-list { list-style: none; margin: 0; padding: 0; }
.pulse-bar-list li { margin-bottom: 12px; }
.pulse-bar-label { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 4px; font-size: 13px; color: var(--mc-heading); }
.pulse-bar-track { height: 8px; border-radius: 999px; background: var(--mc-bg-muted); overflow: hidden; }
.pulse-bar-fill { height: 100%; background: var(--mc-accent-hover); }

.pulse-vendor-list li {
  display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline;
  padding: 8px 0; border-bottom: 1px solid var(--mc-border);
}
.pulse-vendor-name { color: var(--mc-heading); font-size: 13px; font-weight: 600; }
.pulse-vendor-meta { color: var(--mc-subhead); font-size: 12px; }
.pulse-vendor-flag { color: var(--mc-warn); font-size: 11px; font-weight: 600; }
.pulse-opportunity-list li { padding: 6px 0; color: var(--mc-heading); font-size: 13px; line-height: 1.5; }

@media (max-width: 700px) {
  .ny-toolbar { flex-direction: column; align-items: stretch; }
  .ny-toolbar-actions .btn { flex: 1; }
  .decision-card-head { flex-direction: column; }
  .decision-card-amount { font-size: 20px; }
  .decision-card-actions .btn { flex: 1 1 100%; }
  .ref-alloc-row { grid-template-columns: 1fr; }
  .ref-alloc-amount { grid-row: auto; }
  .ref-question-answers .btn { flex: 1 1 100%; }
  .power-through-overlay { padding: 12px; }
  .pulse-stat-row { gap: 14px; }
}

/* Truth boundaries on the triage surface: loaded-vs-total scope, entity on
   pattern cards, and money-in direction. See needs-you.js. */

.ny-scope {
  margin: -6px 0 16px; padding: 8px 12px; border-radius: 8px;
  background: var(--mc-bg-muted); color: var(--mc-subhead);
  font-size: 12px; line-height: 1.5;
}
.ny-scope.is-truncated {
  background: var(--mc-warn-bg); color: var(--mc-warn); font-weight: 500;
}

.badge-entity { background: var(--mc-success-bg); color: var(--mc-success); }
.badge-entity-missing { background: var(--mc-warn-bg); color: var(--mc-warn); }
.bundle-entity-warning {
  margin: 0 0 10px; padding: 9px 11px; border-radius: 8px;
  background: var(--mc-warn-bg); color: var(--mc-warn);
  font-size: 12px; line-height: 1.5;
}

.inflow-notice {
  margin: 12px 0 0; padding: 10px 12px; border-radius: 8px;
  background: var(--mc-success-bg); color: var(--mc-heading);
  font-size: 12px; line-height: 1.55;
}
.inflow-direction {
  margin: 0; padding: 10px 20px;
  background: var(--mc-success-bg); color: var(--mc-heading);
  font-size: 13px; line-height: 1.5;
}
.inflow-direction[hidden] { display: none; }

.ny-scope.is-unverified {
  background: var(--mc-warn-bg); color: var(--mc-warn); font-weight: 600;
  border: 1px solid var(--mc-warn);
}
