/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green-900: #1b4332;
  --green-800: #2d6a4f;
  --green-700: #40916c;
  --green-600: #52b788;
  --green-100: #d8f3dc;
  --green-50:  #f0faf3;
  --amber-600: #d97706;
  --amber-400: #fbbf24;
  --amber-50:  #fffbeb;
  --red-500:   #ef4444;
  --red-50:    #fef2f2;
  --blue-500:  #3b82f6;
  --blue-50:   #eff6ff;
  --gray-900:  #111827;
  --gray-800:  #1f2937;
  --gray-700:  #374151;
  --gray-600:  #4b5563;
  --gray-500:  #6b7280;
  --gray-400:  #9ca3af;
  --gray-300:  #d1d5db;
  --gray-200:  #e5e7eb;
  --gray-100:  #f3f4f6;
  --gray-50:   #f9fafb;
  --white:     #ffffff;
  --sidebar-w: 240px;
  --topbar-h:  60px;
  --radius:    10px;
  --radius-sm: 6px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
}

html, body { height: 100%; font-family: 'Inter', system-ui, sans-serif; font-size: 14px; color: var(--gray-800); background: var(--gray-50); }

a { text-decoration: none; color: inherit; cursor: pointer; }

/* ===== LAYOUT ===== */
body { display: flex; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: var(--gray-900);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.25s ease, min-width 0.25s ease;
  z-index: 100;
}

.sidebar.collapsed { width: 60px; min-width: 60px; }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .farm-info,
.sidebar.collapsed .chevron,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-item span { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.logo-icon { display: flex; align-items: center; flex-shrink: 0; }
.logo-text { font-size: 18px; font-weight: 400; color: var(--white); letter-spacing: -0.3px; }
.logo-text strong { font-weight: 700; color: var(--green-600); }

.farm-selector {
  margin: 12px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,.08);
}
.farm-selector-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background .15s;
}
.farm-selector-inner:hover { background: rgba(255,255,255,.06); }
.farm-avatar {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--green-800);
  color: var(--green-100);
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.farm-info { flex: 1; min-width: 0; }
.farm-name { font-size: 12px; font-weight: 600; color: var(--white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.farm-year { font-size: 11px; color: var(--gray-500); }
.chevron { flex-shrink: 0; }

.nav-section { padding: 6px 0; }
.nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--gray-600);
  padding: 8px 16px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--gray-400);
  font-size: 13px;
  font-weight: 500;
  border-radius: 0;
  transition: background .12s, color .12s;
  cursor: pointer;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: var(--white); }
.nav-item.active {
  background: rgba(82, 183, 136, .12);
  color: var(--green-600);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--green-600);
  border-radius: 0 2px 2px 0;
}
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,.06);
  padding: 8px 0;
}

/* ===== TOPBAR ===== */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.topbar-center { flex: 1; max-width: 520px; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* ===== GLOBAL SEARCH ===== */
.global-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  padding: 7px 14px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.global-search:focus-within {
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(82,183,136,.12);
  background: var(--white);
}
.global-search input {
  border: none; background: none; outline: none;
  font-size: 13px; color: var(--gray-700); width: 100%;
  font-family: inherit;
}
.global-search input::placeholder { color: var(--gray-400); }

/* ===== SEARCH RESULTS DROPDOWN ===== */
.search-results {
  position: absolute;
  top: calc(var(--topbar-h) + 4px);
  left: 50%; transform: translateX(-50%);
  width: 520px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
  display: none;
}
.search-results.open { display: block; }
.search-section-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--gray-500);
  padding: 10px 16px 4px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-100);
}
.search-result-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; cursor: pointer;
  transition: background .1s;
  font-size: 13px;
}
.search-result-item:hover { background: var(--green-50); }
.search-result-icon {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--gray-100); display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; font-size: 14px;
}
.search-result-main { flex: 1; }
.search-result-title { font-weight: 600; color: var(--gray-800); }
.search-result-sub { font-size: 11px; color: var(--gray-500); }
.search-result-badge { font-size: 11px; color: var(--gray-400); }
.menu-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--gray-500); padding: 4px;
  display: flex; align-items: center;
  border-radius: 6px;
  transition: background .12s;
}
.menu-toggle:hover { background: var(--gray-100); color: var(--gray-700); }
.breadcrumb { font-size: 15px; font-weight: 600; color: var(--gray-800); }

.market-ticker {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 14px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  font-size: 12px;
  color: var(--gray-600);
}
.ticker-item { display: flex; align-items: center; gap: 5px; }
.ticker-item strong { color: var(--gray-800); }
.crop-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.crop-dot.corn { background: var(--amber-400); }
.crop-dot.soy { background: #84cc16; }
.crop-dot.wheat { background: #f59e0b; }
.crop-dot.milo { background: #c084fc; }

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--green-700);
  color: white;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}

/* ===== PAGES ===== */
.page { display: none; flex: 1; overflow-y: auto; padding: 28px 28px 40px; }
.page.active { display: block; }

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.page-header-left h1 { font-size: 22px; font-weight: 700; color: var(--gray-900); }
.page-header-left p { font-size: 13px; color: var(--gray-500); margin-top: 3px; }
.page-header-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ===== STAT CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-card-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}
.stat-card-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.5px;
}
.stat-card-value.green { color: var(--green-700); }
.stat-card-value.red { color: var(--red-500); }
.stat-card-value.amber { color: var(--amber-600); }
.stat-card-sub {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-card-sub .up { color: var(--green-700); }
.stat-card-sub .down { color: var(--red-500); }
.stat-card-icon {
  float: right;
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-top: -32px;
}
.stat-card-icon.green { background: var(--green-50); color: var(--green-700); }
.stat-card-icon.amber { background: var(--amber-50); color: var(--amber-600); }
.stat-card-icon.blue  { background: var(--blue-50);  color: var(--blue-500); }
.stat-card-icon.red   { background: var(--red-50);   color: var(--red-500); }

/* ===== CARDS ===== */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--gray-800); }
.card-subtitle { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.card-body { padding: 20px; }
.card-body.no-pad { padding: 0; }

/* ===== DASHBOARD GRID ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.dashboard-grid .span-2 { grid-column: span 2; }
@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-grid .span-2 { grid-column: 1; }
}

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 10px 16px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }
.td-amount { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.td-amount.income { color: var(--green-700); }
.td-amount.expense { color: var(--red-500); }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green  { background: var(--green-100); color: var(--green-800); }
.badge-amber  { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-gray   { background: var(--gray-100); color: var(--gray-700); }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* ===== PROGRESS ===== */
.progress-bar { height: 8px; background: var(--gray-100); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width .5s ease; }
.progress-fill.green  { background: var(--green-600); }
.progress-fill.amber  { background: var(--amber-400); }
.progress-fill.blue   { background: var(--blue-500); }
.progress-fill.red    { background: var(--red-500); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--green-700);
  color: white;
}
.btn-primary:hover { background: var(--green-800); }
.btn-secondary {
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-50); }
.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border: 1px solid transparent;
}
.btn-ghost:hover { background: var(--gray-100); }
.btn-danger { background: var(--red-500); color: white; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 11px; }
.btn-icon { padding: 6px; }

/* ===== CHARTS ===== */
.chart-area { padding: 16px 20px 8px; }
.bar-chart { display: flex; align-items: flex-end; gap: 10px; height: 140px; }
.bar-group { display: flex; align-items: flex-end; gap: 3px; flex: 1; }
.bar {
  flex: 1;
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: opacity .15s;
  cursor: pointer;
}
.bar:hover { opacity: .8; }
.bar.income-bar { background: var(--green-600); }
.bar.expense-bar { background: var(--red-500); opacity: .7; }
.chart-labels {
  display: flex;
  gap: 10px;
  padding: 8px 20px 12px;
  font-size: 11px;
  color: var(--gray-500);
}
.chart-labels span { flex: 1; text-align: center; }

.donut-wrap { display: flex; align-items: center; gap: 24px; }
.donut-legend { flex: 1; }
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 12px;
}
.legend-dot {
  width: 10px; height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.legend-label { flex: 1; color: var(--gray-700); }
.legend-val { font-weight: 600; color: var(--gray-800); }
.legend-pct { color: var(--gray-500); font-size: 11px; }

svg.donut { transform: rotate(-90deg); }
svg.donut circle { fill: none; }

/* ===== FIELDS ===== */
.fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.field-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow .15s;
}
.field-card:hover { box-shadow: var(--shadow-md); }
.field-card-map {
  height: 100px;
  background: linear-gradient(135deg, #d8f3dc 0%, #b7e4c7 50%, #95d5b2 100%);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.field-shape {
  opacity: .4;
  fill: var(--green-800);
}
.field-card-body { padding: 14px 16px; }
.field-card-name { font-size: 14px; font-weight: 700; color: var(--gray-900); }
.field-card-meta { display: flex; gap: 12px; margin-top: 6px; flex-wrap: wrap; }
.field-meta-item { font-size: 12px; color: var(--gray-600); }
.field-meta-item strong { color: var(--gray-800); font-weight: 600; }
.field-card-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

/* ===== GRAIN ===== */
/* ── Page tab bar ─────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--gray-200);
  padding-bottom: 0;
}
.tab-btn {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover  { color: var(--green-700); background: var(--green-50); }
.tab-btn.active { color: var(--green-700); border-bottom-color: var(--green-600); background: none; }

/* ── Export Center ────────────────────────────────────────── */
.export-option-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.export-option-card:hover { border-color: var(--green-400); background: var(--green-50); }
.export-option-icon { font-size: 22px; flex-shrink: 0; }
.export-option-body { flex: 1; min-width: 0; }
.export-option-title { font-weight: 700; font-size: 14px; color: var(--gray-900); margin-bottom: 2px; }
.export-option-desc  { font-size: 12px; color: var(--gray-500); line-height: 1.4; }
.export-option-arrow { color: var(--gray-400); flex-shrink: 0; }

.bin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.bin-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  text-align: center;
}
.bin-visual {
  width: 70px; height: 90px;
  margin: 0 auto 12px;
  position: relative;
}
.bin-body {
  position: absolute;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 56px; height: 70px;
  background: var(--gray-200);
  border-radius: 4px 4px 8px 8px;
  overflow: hidden;
}
.bin-fill {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  border-radius: 0 0 8px 8px;
  transition: height .5s ease;
}
.bin-fill.corn  { background: linear-gradient(to top, #d97706, #fbbf24); }
.bin-fill.soy   { background: linear-gradient(to top, #4d7c0f, #84cc16); }
.bin-fill.wheat { background: linear-gradient(to top, #b45309, #f59e0b); }
.bin-fill.milo  { background: linear-gradient(to top, #6d28d9, #a78bfa); }
.bin-roof {
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 33px solid transparent;
  border-right: 33px solid transparent;
  border-bottom: 20px solid var(--gray-300);
}
.bin-name { font-size: 13px; font-weight: 700; color: var(--gray-800); }
.bin-crop { font-size: 11px; color: var(--gray-500); margin: 2px 0; }
.bin-capacity { font-size: 18px; font-weight: 700; color: var(--gray-900); margin: 4px 0; }
.bin-pct { font-size: 12px; color: var(--gray-500); }

/* ===== EQUIPMENT ===== */
.equip-list .equip-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-100);
}
.equip-list .equip-item:last-child { border-bottom: none; }
.equip-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--amber-50);
  color: var(--amber-600);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 20px;
}
.equip-details { flex: 1; }
.equip-name { font-size: 13px; font-weight: 600; color: var(--gray-800); }
.equip-meta { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.equip-value { text-align: right; }
.equip-value .val { font-size: 14px; font-weight: 700; color: var(--gray-800); }
.equip-value .dep { font-size: 11px; color: var(--gray-500); }

/* ===== REPORTS ===== */
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.report-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
}
.report-card:hover { box-shadow: var(--shadow-md); border-color: var(--green-600); }
.report-card-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--green-50);
  color: var(--green-700);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.report-card-name { font-size: 14px; font-weight: 700; color: var(--gray-800); }
.report-card-desc { font-size: 12px; color: var(--gray-500); margin-top: 4px; line-height: 1.5; }

/* ===== P&L TABLE ===== */
.pl-section { padding: 0 20px; }
.pl-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
}
.pl-row.total {
  font-weight: 700;
  border-bottom: 2px solid var(--gray-300);
  padding: 10px 0;
}
.pl-row.net {
  font-size: 15px;
  font-weight: 700;
  color: var(--green-700);
  border-bottom: none;
  padding: 12px 0;
}
.pl-row.section-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-500);
  border-bottom: none;
  padding-bottom: 4px;
  margin-top: 8px;
}
.pl-label { color: var(--gray-700); }
.pl-value { font-variant-numeric: tabular-nums; }
.pl-value.income { color: var(--green-700); }
.pl-value.expense { color: var(--gray-800); }
.pl-value.net { color: var(--green-700); font-size: 16px; }

/* ===== SCHEDULE F ===== */
.schedulef-line {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
}
.line-num { width: 50px; color: var(--gray-500); font-size: 12px; flex-shrink: 0; }
.line-desc { flex: 1; color: var(--gray-700); }
.line-val { width: 120px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.line-val.income { color: var(--green-700); }
.line-val.expense { color: var(--gray-800); }

/* ===== BANKING ===== */
.account-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.account-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.account-card-type { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-500); margin-bottom: 8px; }
.account-card-name { font-size: 14px; font-weight: 700; color: var(--gray-800); }
.account-card-balance { font-size: 26px; font-weight: 700; color: var(--gray-900); margin: 8px 0; letter-spacing: -0.5px; }
.account-card-balance.credit { color: var(--red-500); }
.account-card-num { font-size: 12px; color: var(--gray-500); }
.account-card-bar { margin-top: 12px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: 14px;
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--gray-900); }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 22px; color: var(--gray-400); line-height: 1;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  transition: background .12s;
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-700); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ===== FORM ===== */
.form-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.form-tab {
  flex: 1;
  padding: 6px 12px;
  border: none;
  background: none;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.form-tab.active { background: var(--white); color: var(--gray-800); box-shadow: var(--shadow); }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--gray-700); margin-bottom: 5px; }
.form-control {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--gray-800);
  background: var(--white);
  transition: border-color .12s, box-shadow .12s;
  font-family: inherit;
}
.form-control:focus {
  outline: none;
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(82,183,136,.15);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--gray-900);
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  transition: transform .25s ease, opacity .25s ease;
  opacity: 0;
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ===== MISC ===== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--gray-500);
}
.empty-state svg { margin-bottom: 12px; opacity: .4; }
.empty-state h3 { font-size: 15px; font-weight: 600; color: var(--gray-700); }
.empty-state p { font-size: 13px; margin-top: 4px; }

.divider { height: 1px; background: var(--gray-100); margin: 16px 0; }

.text-green { color: var(--green-700); }
.text-red   { color: var(--red-500); }
.text-amber { color: var(--amber-600); }
.text-gray  { color: var(--gray-500); }
.fw-600     { font-weight: 600; }
.fw-700     { font-weight: 700; }
.fs-12      { font-size: 12px; }
.fs-13      { font-size: 13px; }
.mt-4       { margin-top: 4px; }
.mt-8       { margin-top: 8px; }
.mt-16      { margin-top: 16px; }
.flex       { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8      { gap: 8px; }
.gap-12     { gap: 12px; }

/* ===== SCROLLBARS ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .market-ticker { display: none; }
  :root { --sidebar-w: 200px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page { padding: 16px; }
}

/* ===== CROP COLORS ===== */
.crop-corn  { color: var(--amber-600); }
.crop-soy   { color: #4d7c0f; }
.crop-wheat { color: #b45309; }
.crop-milo  { color: #6d28d9; }

/* ===== CASH FLOW ===== */
.cf-period-toggle {
  display: flex; background: var(--gray-100); border-radius: var(--radius-sm);
  padding: 3px; gap: 0;
}
.cf-period-btn {
  padding: 5px 14px; border: none; background: none; border-radius: 5px;
  font-size: 12px; font-weight: 600; color: var(--gray-500); cursor: pointer;
  transition: background .12s, color .12s;
}
.cf-period-btn.active { background: var(--white); color: var(--gray-800); box-shadow: var(--shadow); }

/* Position strip */
.cf-position-strip {
  display: flex; align-items: center; gap: 0;
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 0; margin-bottom: 20px; overflow-x: auto;
}
.cf-pos-card {
  flex: 1; min-width: 130px; padding: 4px 20px; text-align: center;
}
.cf-pos-highlight { background: var(--gray-50); border-radius: var(--radius-sm); margin: -4px 0; padding: 8px 20px; }
.cf-pos-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--gray-500); margin-bottom: 4px; }
.cf-pos-value { font-size: 22px; font-weight: 700; color: var(--gray-900); letter-spacing: -.4px; }
.cf-pos-sub { font-size: 11px; color: var(--gray-400); margin-top: 3px; }
.cf-pos-sep { font-size: 24px; font-weight: 300; color: var(--gray-300); padding: 0 4px; flex-shrink: 0; }
.cf-pos-divider { width: 1px; background: var(--gray-200); align-self: stretch; margin: 0 8px; flex-shrink: 0; }

.cf-legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }

/* Debt items */
.cf-debt-item { padding: 16px 20px; border-bottom: 1px solid var(--gray-100); }
.cf-debt-item:last-child { border-bottom: none; }
.cf-debt-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 3px; }
.cf-debt-name { font-size: 13px; font-weight: 700; color: var(--gray-800); }
.cf-debt-meta { font-size: 11px; color: var(--gray-500); margin-bottom: 10px; }
.cf-debt-row { display: flex; gap: 24px; }
.cf-debt-balance { font-size: 17px; font-weight: 700; color: var(--gray-900); }

/* Harvest items */
.cf-harvest-item { padding: 14px 0; border-bottom: 1px solid var(--gray-100); }
.cf-harvest-item:last-child { border-bottom: none; }
.cf-harvest-stat { text-align: center; background: var(--gray-50); border-radius: 8px; padding: 8px 4px; }
.cf-harvest-num { font-size: 16px; font-weight: 700; color: var(--gray-900); }
.cf-harvest-label { font-size: 10px; color: var(--gray-500); margin-top: 2px; text-transform: uppercase; letter-spacing: .04em; }

/* ===== CREATE DROPDOWN ===== */
.create-wrap { position: relative; }
.create-btn { gap: 6px; }
.create-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 580px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.06);
  display: none;
  z-index: 500;
  overflow: hidden;
  animation: slideDown .15s ease;
}
@keyframes slideDown {
  from { transform: translateY(-6px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.create-dropdown.open { display: flex; }
.create-col {
  flex: 1;
  border-right: 1px solid var(--gray-100);
  padding: 8px 0 12px;
}
.create-col:last-child { border-right: none; }
.create-col-header {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--gray-500);
  padding: 8px 16px 6px;
}
.create-item {
  display: block;
  padding: 7px 16px;
  font-size: 13px;
  color: var(--gray-700);
  cursor: pointer;
  transition: background .1s, color .1s;
}
.create-item:hover { background: var(--green-50); color: var(--green-700); }
.create-item-add {
  color: var(--green-700);
  font-weight: 600;
  border-top: 1px solid var(--gray-100);
  margin-top: 4px;
  padding-top: 9px;
}
.create-item-add:hover { background: var(--green-50); }

/* ===== REPORTS PAGE REDESIGN ===== */
.reports-layout {
  display: flex;
  gap: 0;
  height: 100%;
  min-height: calc(100vh - var(--topbar-h));
  margin: -28px -28px -40px;
}
.reports-sidebar {
  width: 200px;
  min-width: 200px;
  border-right: 1px solid var(--gray-200);
  background: var(--white);
  padding: 16px 0;
}
.reports-sidebar-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--gray-500);
  padding: 4px 16px 12px;
}
.reports-nav-item {
  display: block; padding: 8px 16px;
  font-size: 13px; color: var(--gray-600);
  cursor: pointer; border-left: 3px solid transparent;
  transition: background .1s, color .1s;
}
.reports-nav-item:hover { background: var(--gray-50); color: var(--gray-800); }
.reports-nav-item.active { border-left-color: var(--green-600); background: var(--green-50); color: var(--green-800); font-weight: 600; }
.reports-nav-sub {
  display: block; padding: 6px 16px 6px 28px;
  font-size: 12px; color: var(--green-700);
  cursor: pointer;
  transition: background .1s;
}
.reports-nav-sub:hover { background: var(--gray-50); }

.reports-content {
  flex: 1;
  padding: 24px 28px 40px;
  overflow-y: auto;
}
.reports-search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 24px;
  background: var(--white);
  max-width: 400px;
}
.reports-search-bar input {
  border: none; outline: none; font-size: 13px;
  color: var(--gray-700); width: 100%; font-family: inherit;
}
.reports-search-bar input::placeholder { color: var(--gray-400); }

.reports-section { margin-bottom: 28px; }
.reports-section-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 4px; cursor: pointer;
}
.reports-section-title {
  font-size: 17px; font-weight: 700; color: var(--gray-900);
}
.reports-section-toggle {
  color: var(--gray-400); display: flex; align-items: center;
  transition: transform .2s;
}
.reports-section-toggle.collapsed { transform: rotate(-90deg); }

.reports-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--white);
  box-shadow: var(--shadow);
}
.report-row {
  display: flex; align-items: center; gap: 0;
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px; color: var(--gray-700);
  cursor: pointer;
  transition: background .1s;
}
.report-row:hover { background: var(--gray-50); }
.report-row:last-child { border-bottom: none; }
.report-row-name { flex: 1; }
.report-row-name a { color: var(--gray-700); }
.report-row-name a:hover { color: var(--green-700); text-decoration: underline; }
.report-star {
  background: none; border: none; cursor: pointer;
  padding: 4px; color: var(--gray-300); font-size: 14px;
  line-height: 1; border-radius: 4px;
  transition: color .12s;
}
.report-star:hover { color: var(--amber-400); }
.report-star.starred { color: var(--green-600); }
.report-3dot {
  background: none; border: none; cursor: pointer;
  padding: 4px 6px; color: var(--gray-400); font-size: 16px;
  line-height: 1; border-radius: 4px;
  transition: background .12s;
}
.report-3dot:hover { background: var(--gray-100); color: var(--gray-700); }

/* ===== BANKING TRANSACTION MATCH ===== */
.bank-filter-bar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.bank-search {
  display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
  padding: 7px 12px; background: var(--white); min-width: 220px;
}
.bank-search input {
  border: none; outline: none; font-size: 13px;
  color: var(--gray-700); font-family: inherit; width: 100%;
}
.bank-filter-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px; border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm); background: var(--white);
  font-size: 13px; color: var(--gray-600); cursor: pointer;
  white-space: nowrap;
}
.bank-filter-btn:hover { background: var(--gray-50); }
.bank-filter-btn.active { border-color: var(--green-600); color: var(--green-700); background: var(--green-50); }

.bank-txn-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.bank-txn-table th {
  text-align: left; font-size: 11px; font-weight: 600;
  color: var(--gray-500); text-transform: uppercase; letter-spacing: .05em;
  padding: 9px 10px; background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
.bank-txn-table td {
  padding: 9px 10px; border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.bank-txn-table tr:hover td { background: var(--gray-50); }
.bank-txn-table tr.selected td { background: #f0faf3; }

.txn-check { width: 32px; }
.txn-date { width: 100px; color: var(--gray-600); }
.txn-desc { max-width: 200px; }
.txn-desc-main { font-weight: 500; color: var(--gray-800); }
.txn-desc-sub { font-size: 11px; color: var(--gray-400); }
.txn-amount { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.txn-amount.spent { color: var(--red-500); }
.txn-amount.received { color: var(--green-700); }
.txn-icon-cell { width: 30px; text-align: center; }
.txn-icon-btn {
  background: none; border: 1px dashed var(--gray-300);
  border-radius: 4px; width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--gray-400); font-size: 13px;
  transition: border-color .1s, color .1s;
}
.txn-icon-btn:hover { border-color: var(--green-600); color: var(--green-700); }
.txn-tax { width: 90px; }
.txn-from { width: 140px; }
.txn-categorize { width: 180px; }
.txn-select {
  width: 100%; padding: 5px 7px;
  border: 1px solid var(--gray-200); border-radius: 5px;
  font-size: 12px; color: var(--gray-600); font-family: inherit;
  background: var(--white); cursor: pointer;
}
.txn-select:focus { outline: none; border-color: var(--green-600); }
.txn-select.placeholder { color: var(--gray-400); }

.rule-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 4px;
  background: #eff6ff; color: #1d4ed8;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
}
.match-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 4px;
  background: var(--green-50); color: var(--green-800);
  font-size: 11px; font-weight: 600;
}
.match-sub { font-size: 11px; color: var(--gray-500); }

.bank-bulk-bar {
  display: none; align-items: center; gap: 10px;
  padding: 10px 16px; background: var(--green-50);
  border: 1px solid var(--green-100); border-radius: var(--radius-sm);
  margin-bottom: 12px; font-size: 13px;
}
.bank-bulk-bar.visible { display: flex; }
.bank-bulk-bar span { color: var(--green-800); font-weight: 600; flex: 1; }

/* ===== CREATE FORM MODAL ===== */
.modal.modal-wide { max-width: 680px; }
.modal-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--gray-500);
  margin: 16px 0 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--gray-100);
}
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.line-items-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 12px; }
.line-items-table th {
  text-align: left; font-size: 11px; font-weight: 600; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: .05em;
  padding: 6px 8px; background: var(--gray-50); border-bottom: 1px solid var(--gray-200);
}
.line-items-table td { padding: 6px 8px; border-bottom: 1px solid var(--gray-100); }
.line-items-table td input, .line-items-table td select {
  width: 100%; border: 1px solid var(--gray-200); border-radius: 4px;
  padding: 5px 7px; font-size: 12px; font-family: inherit;
  background: var(--white);
}
.line-items-table td input:focus, .line-items-table td select:focus {
  outline: none; border-color: var(--green-600);
}
.li-total { text-align: right; font-weight: 700; padding: 8px 8px 0; font-size: 13px; color: var(--gray-800); }

/* ===== 3-DOT CONTEXT MENU ===== */
.context-menu {
  position: fixed;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 600;
  min-width: 160px;
  display: none;
  overflow: hidden;
}
.context-menu.open { display: block; }
.context-menu-item {
  display: block; padding: 8px 14px;
  font-size: 13px; color: var(--gray-700);
  cursor: pointer; transition: background .1s;
}
.context-menu-item:hover { background: var(--gray-50); }
.context-menu-item.danger { color: var(--red-500); }

/* ===== ACCOUNT CARD ENHANCEMENTS ===== */
.account-card {
  transition: box-shadow .15s, border-color .15s;
  border: 2px solid transparent;
}
.account-card.active {
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(82,183,136,.15);
}
.account-card-top {
  display: flex; align-items: center; gap: 6px; margin-bottom: 2px;
}
.account-card-cc { background: linear-gradient(135deg, #1a1a2e 0%, #16213e 60%, #0f3460 100%) !important; }
.account-card-cc .account-card-type,
.account-card-cc .account-card-name,
.account-card-cc .account-card-balance,
.account-card-cc .account-card-num,
.account-card-cc svg,
.account-card-cc .fs-12 { color: rgba(255,255,255,.85) !important; }
.account-card-cc .account-card-balance { color: #ff6b6b !important; }
.account-card-cc .progress-bar { background: rgba(255,255,255,.2) !important; }
.account-card-cc .progress-fill { background: #ff6b6b !important; }
.cc-balance-pill {
  background: var(--gray-100); border: 1px solid var(--gray-200);
  border-radius: 20px; padding: 4px 12px; font-size: 12px; color: var(--gray-600);
  white-space: nowrap;
}
.cc-balance-pill strong { color: var(--gray-900); }

/* ===== AI AGENT PANEL ===== */
#aiAgentOverlay {
  position: fixed; inset: 0; z-index: 1050;
  pointer-events: none; transition: background .2s;
}
#aiAgentOverlay.visible {
  pointer-events: all; background: rgba(0,0,0,.2);
}
#aiAgentPanel {
  position: fixed; right: 0; top: 0; bottom: 0; width: 400px; max-width: 95vw;
  background: var(--white); box-shadow: -4px 0 24px rgba(0,0,0,.12);
  display: flex; flex-direction: column; z-index: 1051;
  transform: translateX(100%); transition: transform .25s cubic-bezier(.4,0,.2,1);
}
#aiAgentPanel.open { transform: translateX(0); }

.agent-panel-header {
  padding: 16px 18px 14px;
  background: linear-gradient(135deg, #1b4332 0%, #2d6a4f 100%);
  display: flex; align-items: center; gap: 10px;
}
.agent-panel-title {
  flex: 1; display: flex; align-items: center; gap: 8px;
}
.agent-panel-title h3 { font-size: 14px; font-weight: 700; color: white; margin: 0; }
.agent-panel-title p  { font-size: 11px; color: rgba(255,255,255,.65); margin: 0; }
.agent-logo-icon {
  width: 32px; height: 32px; background: rgba(255,255,255,.15);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; color: white; flex-shrink: 0;
}
.agent-close-btn {
  width: 28px; height: 28px; border: none; border-radius: 6px; cursor: pointer;
  background: rgba(255,255,255,.15); color: white; font-size: 16px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.agent-close-btn:hover { background: rgba(255,255,255,.25); }

/* Quick actions */
.agent-quick-bar {
  padding: 8px 14px; display: flex; gap: 6px; flex-wrap: wrap;
  border-bottom: 1px solid var(--gray-200); background: var(--gray-50);
}
.agent-quick-chip {
  padding: 4px 11px; border-radius: 20px; font-size: 11px; font-weight: 600;
  border: 1px solid var(--gray-200); background: var(--white);
  cursor: pointer; color: var(--gray-600); transition: all .1s;
}
.agent-quick-chip:hover { border-color: var(--green-500); color: var(--green-700); background: var(--green-50); }

/* Feed */
#agentFeed {
  flex: 1; overflow-y: auto; padding: 16px 14px; display: flex;
  flex-direction: column; gap: 14px; min-height: 0;
}
.agent-msg { display: flex; align-items: flex-start; gap: 8px; }
.agent-msg-user { flex-direction: row-reverse; }
.agent-msg-user .agent-bubble {
  background: var(--green-600); color: white; border-radius: 16px 4px 16px 16px;
  max-width: 80%; font-size: 13px; line-height: 1.5; padding: 10px 14px;
}
.agent-avatar {
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, #2d6a4f, #52b788);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; color: white;
}
.agent-bubble-wrap { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.agent-bubble {
  background: var(--gray-100); border-radius: 4px 16px 16px 16px;
  font-size: 13px; line-height: 1.6; padding: 10px 14px; color: var(--gray-800);
}
.agent-bubble p  { margin: 0 0 8px; }
.agent-bubble p:last-child { margin: 0; }
.agent-bubble strong { color: var(--gray-900); }
.agent-bubble code { background: var(--gray-200); border-radius: 3px; padding: 1px 4px; font-size: 12px; }

/* Typing dots */
.agent-typing { display: flex; gap: 4px; align-items: center; padding: 12px 16px !important; }
.agent-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--gray-400);
  animation: typingDot 1.2s ease-in-out infinite;
}
.agent-typing span:nth-child(2) { animation-delay: .2s; }
.agent-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes typingDot { 0%,60%,100% { transform: translateY(0); opacity:.4; } 30% { transform: translateY(-4px); opacity:1; } }

/* Suggestion cards */
.suggestion-batch { display: flex; flex-direction: column; gap: 6px; }
.approve-all-btn { align-self: flex-start; margin-bottom: 4px; }
.suggestion-card {
  background: var(--white); border: 1.5px solid var(--gray-200);
  border-radius: 10px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 5px;
  transition: border-color .15s, opacity .2s;
}
.suggestion-card.conf-high { border-left: 3px solid var(--green-400); }
.suggestion-card.conf-med  { border-left: 3px solid var(--amber-400); }
.suggestion-card.conf-low  { border-left: 3px solid var(--gray-300); }
.suggestion-card.approved  { opacity: .55; }
.suggestion-card.skipped   { opacity: .35; }
.suggestion-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.suggestion-desc { font-size: 12px; font-weight: 600; color: var(--gray-800); }
.suggestion-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.suggestion-date   { font-size: 11px; color: var(--gray-400); }
.suggestion-amount { font-size: 12px; font-weight: 700; }
.sug-expense { color: var(--red-500, #ef4444); }
.sug-income  { color: var(--green-600); }
.suggestion-cat { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.suggestion-vendor { font-size: 11px; color: var(--gray-500); }
.suggestion-conf   { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin-left: auto; }
.conf-high .suggestion-conf { color: var(--green-600); }
.conf-med  .suggestion-conf { color: var(--amber-600); }
.conf-low  .suggestion-conf { color: var(--gray-400); }
.suggestion-reason { font-size: 11px; color: var(--gray-500); font-style: italic; }
.suggestion-actions { display: flex; gap: 6px; margin-top: 2px; }
.suggestion-approved-label { font-size: 11px; color: var(--green-600); font-weight: 600; }
.suggestion-skipped-label  { font-size: 11px; color: var(--gray-400); }

/* Input bar */
.agent-input-bar {
  padding: 12px 14px; border-top: 1px solid var(--gray-200);
  display: flex; gap: 8px; align-items: flex-end; background: var(--white);
}
#aiInput {
  flex: 1; border: 1.5px solid var(--gray-200); border-radius: 10px;
  padding: 8px 12px; font-size: 13px; resize: none; min-height: 38px; max-height: 120px;
  font-family: inherit; line-height: 1.4; outline: none;
  transition: border-color .15s;
}
#aiInput:focus { border-color: var(--green-400); }
#aiInput::placeholder { color: var(--gray-400); }
.agent-send-btn {
  width: 36px; height: 36px; border-radius: 9px; border: none;
  background: var(--green-600); color: white; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s; flex-shrink: 0;
}
.agent-send-btn:hover { background: var(--green-700); }

/* Topbar AI button */
.ai-agent-btn {
  position: relative; display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #1b4332, #2d6a4f);
  border: none; color: white; cursor: pointer; font-size: 12px;
  font-weight: 600; font-family: inherit; transition: opacity .15s;
}
.ai-agent-btn:hover { opacity: .9; }
.ai-agent-btn svg { flex-shrink: 0; }
#aiAgentBadge {
  position: absolute; top: -5px; right: -5px;
  min-width: 17px; height: 17px; border-radius: 9px;
  background: #ef4444; color: white; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px; border: 2px solid var(--white);
}

/* ===== AI CFO PANEL ===== */
#aiCFOOverlay {
  position: fixed; inset: 0; z-index: 1060;
  pointer-events: none; transition: background .2s;
}
#aiCFOOverlay.visible { pointer-events: all; background: rgba(0,0,0,.25); }

#aiCFOPanel {
  position: fixed; right: 0; top: 0; bottom: 0; width: 440px; max-width: 95vw;
  background: var(--white); box-shadow: -4px 0 32px rgba(0,0,0,.16);
  display: flex; flex-direction: column; z-index: 1061;
  transform: translateX(100%); transition: transform .25s cubic-bezier(.4,0,.2,1);
}
#aiCFOPanel.open { transform: translateX(0); }

.cfo-panel-header {
  padding: 18px 18px 14px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #1e3a5f 100%);
  display: flex; align-items: flex-start; gap: 12px;
}
.cfo-panel-title { flex: 1; }
.cfo-panel-title h3 { font-size: 15px; font-weight: 700; color: white; margin: 0 0 2px; }
.cfo-panel-title p  { font-size: 11px; color: rgba(255,255,255,.5); margin: 0; }
.cfo-credential {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(251,191,36,.15); border: 1px solid rgba(251,191,36,.3);
  border-radius: 4px; padding: 2px 7px; margin-top: 5px;
  font-size: 10px; font-weight: 700; color: #fbbf24; letter-spacing: .04em;
}
.cfo-logo-icon {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, #1e3a5f, #2563eb);
  border: 1px solid rgba(255,255,255,.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: white;
}
.cfo-close-btn {
  width: 28px; height: 28px; border: none; border-radius: 6px; cursor: pointer;
  background: rgba(255,255,255,.1); color: rgba(255,255,255,.7); font-size: 16px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  margin-top: 2px;
}
.cfo-close-btn:hover { background: rgba(255,255,255,.2); color: white; }

.cfo-quick-bar {
  padding: 8px 14px; display: flex; gap: 6px; flex-wrap: wrap;
  border-bottom: 1px solid var(--gray-200); background: #f8fafc;
}
.cfo-quick-chip {
  padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600;
  border: 1px solid #cbd5e1; background: var(--white);
  cursor: pointer; color: #475569; transition: all .1s;
}
.cfo-quick-chip:hover { border-color: #2563eb; color: #1d4ed8; background: #eff6ff; }

#cfoFeed {
  flex: 1; overflow-y: auto; padding: 18px 16px;
  display: flex; flex-direction: column; gap: 16px; min-height: 0;
}

.cfo-msg { display: flex; align-items: flex-start; gap: 10px; }
.cfo-msg-user { flex-direction: row-reverse; }
.cfo-bubble-user {
  background: #1e3a5f; color: white;
  border-radius: 16px 4px 16px 16px;
  max-width: 82%; font-size: 13px; line-height: 1.5; padding: 10px 14px;
}
.cfo-avatar {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(135deg, #0f172a, #2563eb);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 800; color: white; letter-spacing: .03em;
}
.cfo-bubble {
  flex: 1; background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 4px 16px 16px 16px;
  font-size: 13px; line-height: 1.65; padding: 12px 16px; color: #1e293b;
  min-width: 0;
}
.cfo-bubble p  { margin: 0 0 10px; }
.cfo-bubble p:last-child { margin: 0; }
.cfo-bubble ul { margin: 6px 0 10px 18px; padding: 0; }
.cfo-bubble li { margin-bottom: 4px; }
.cfo-bubble strong { color: #0f172a; }
.cfo-bubble code { background: #e2e8f0; border-radius: 3px; padding: 1px 5px; font-size: 11.5px; }
.cfo-heading { display: block; font-size: 13px; color: #0f172a; margin: 8px 0 4px; border-bottom: 1px solid #e2e8f0; padding-bottom: 4px; }

.cfo-typing { display: flex; gap: 5px; align-items: center; padding: 14px 16px !important; }
.cfo-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: #94a3b8;
  animation: typingDot 1.2s ease-in-out infinite;
}
.cfo-typing span:nth-child(2) { animation-delay: .2s; }
.cfo-typing span:nth-child(3) { animation-delay: .4s; }

.cfo-input-bar {
  padding: 12px 14px; border-top: 1px solid #e2e8f0;
  display: flex; gap: 8px; align-items: flex-end; background: var(--white);
}
#cfoInput {
  flex: 1; border: 1.5px solid #cbd5e1; border-radius: 10px;
  padding: 8px 12px; font-size: 13px; resize: none;
  min-height: 38px; max-height: 140px; font-family: inherit;
  line-height: 1.4; outline: none; transition: border-color .15s;
}
#cfoInput:focus { border-color: #2563eb; }
#cfoInput::placeholder { color: #94a3b8; }
.cfo-send-btn {
  width: 36px; height: 36px; border-radius: 9px; border: none;
  background: #1e3a5f; color: white; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s; flex-shrink: 0;
}
.cfo-send-btn:hover { background: #1e40af; }

/* AI CFO topbar button */
.ai-cfo-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #0f172a, #1e3a5f);
  border: 1px solid rgba(255,255,255,.08);
  color: white; cursor: pointer; font-size: 12px;
  font-weight: 600; font-family: inherit; transition: opacity .15s;
}
.ai-cfo-btn:hover { opacity: .88; }
.ai-cfo-btn .cfo-btn-badge {
  background: #fbbf24; color: #0f172a;
  font-size: 9px; font-weight: 800; padding: 1px 5px;
  border-radius: 4px; letter-spacing: .03em;
}

/* ===== RECEIPT SCANNER ===== */
.rs-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 1100; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.rs-modal-overlay.active { opacity: 1; pointer-events: all; }
.rs-modal {
  background: var(--white); border-radius: var(--radius-lg);
  width: 780px; max-width: 95vw; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  animation: modalIn .2s ease;
}
.rs-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px 14px; border-bottom: 1px solid var(--gray-200);
}
.rs-modal-header h3 { font-size: 15px; font-weight: 600; color: var(--gray-900); }
.rs-modal-close {
  width: 28px; height: 28px; border: none; background: none;
  cursor: pointer; font-size: 18px; color: var(--gray-400); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.rs-modal-close:hover { background: var(--gray-100); }

/* Step indicator */
#rsStepIndicator {
  display: flex; align-items: center; gap: 0;
  padding: 14px 24px; border-bottom: 1px solid var(--gray-200);
}
.rs-step {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 500; color: var(--gray-400);
}
.rs-step.active { color: var(--green-700); }
.rs-step.done   { color: var(--green-600); }
.rs-step-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--gray-200); color: var(--gray-500);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.rs-step.active .rs-step-num { background: var(--green-700); color: white; }
.rs-step.done   .rs-step-num { background: var(--green-500); color: white; }
.rs-step-line { flex: 1; height: 1px; background: var(--gray-200); margin: 0 10px; }

/* Body scroll */
#rsBody { flex: 1; overflow-y: auto; padding: 20px 24px; min-height: 0; }

/* ── Step 1: Upload ── */
.rs-dropzone {
  border: 2px dashed var(--gray-300); border-radius: var(--radius-md);
  padding: 48px 24px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.rs-dropzone.drag-over { border-color: var(--green-500); background: var(--green-50); }
.rs-drop-label { font-size: 14px; font-weight: 500; color: var(--gray-600); margin: 12px 0 4px; }
.rs-drop-sub   { font-size: 12px; color: var(--gray-400); margin: 0 0 12px; }
.rs-drop-hint  { font-size: 11px; color: var(--gray-400); margin-top: 10px; }
.rs-file-btn   { cursor: pointer; }
.rs-img-preview {
  position: relative; display: inline-block; max-width: 100%;
  border-radius: var(--radius-md); overflow: hidden;
  border: 1px solid var(--gray-200);
}
.rs-img-preview img { display: block; max-height: 300px; margin: 0 auto; }
.rs-clear-img {
  position: absolute; top: 8px; right: 8px;
  width: 26px; height: 26px; border: none; border-radius: 50%;
  background: rgba(0,0,0,.5); color: white; cursor: pointer; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.rs-step1-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 18px;
}
.rs-hint { font-size: 12px; color: var(--gray-400); }

/* ── Step 2: Review ── */
.rs-header-grid {
  display: grid; grid-template-columns: 140px 1fr; gap: 16px; margin-bottom: 16px;
}
.rs-img-thumb img { width: 140px; border-radius: var(--radius-sm); border: 1px solid var(--gray-200); }
.rs-ocr-row { margin-bottom: 10px; }
.rs-ocr-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rs-tax-row { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 8px; }
.rs-ocr-label { display: block; font-size: 11px; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 3px; }
.rs-confidence { font-size: 12px; color: var(--gray-500); margin-top: 6px; }
.rs-ocr-notes  { margin-left: 8px; color: var(--amber-600); }
.rs-num        { text-align: right; }
.rs-section-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--gray-400);
  margin: 14px 0 8px; display: flex; align-items: center; gap: 10px;
}
.rs-items-wrap { overflow-x: auto; }
.rs-items-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
}
.rs-items-table th {
  background: var(--gray-50); padding: 6px 8px; font-weight: 600;
  color: var(--gray-500); text-align: left; border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
.rs-items-table td { padding: 5px 6px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.rs-items-table .form-control-sm { padding: 4px 6px; font-size: 12px; min-width: 0; }
.rs-del-row {
  width: 22px; height: 22px; border: none; background: none; cursor: pointer;
  color: var(--gray-400); font-size: 13px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
}
.rs-del-row:hover { background: var(--gray-100); color: var(--red-500); }
.rs-match-panel {
  background: var(--green-50); border: 1px solid var(--green-200);
  border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 14px;
}
.rs-match-row {
  display: grid; grid-template-columns: 16px 80px 1fr 80px 90px;
  align-items: center; gap: 10px; padding: 6px 4px;
  border-radius: 4px; cursor: pointer; font-size: 12px;
}
.rs-match-row.selected { background: white; border: 1px solid var(--green-400); }
.rs-match-row input  { margin: 0; cursor: pointer; }
.rs-match-date { color: var(--gray-500); }
.rs-match-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-match-amt  { font-weight: 600; text-align: right; }
.rs-match-acct { color: var(--gray-400); font-size: 11px; }
.rs-no-match-notice {
  font-size: 12px; color: var(--gray-500); font-style: italic;
  padding: 8px 12px; background: var(--gray-50); border-radius: var(--radius-sm);
  margin-bottom: 12px;
}
.rs-step2-footer { display: flex; justify-content: space-between; margin-top: 16px; }

/* ── Step 3: Confirm ── */
.rs-confirm-header {
  background: var(--green-50); border: 1px solid var(--green-200);
  border-radius: var(--radius-sm); padding: 16px 20px;
  display: flex; align-items: baseline; gap: 16px; margin-bottom: 16px;
}
.rs-confirm-vendor { font-size: 16px; font-weight: 700; color: var(--gray-900); }
.rs-confirm-date   { font-size: 13px; color: var(--gray-500); }
.rs-confirm-total  { font-size: 18px; font-weight: 700; color: var(--green-700); margin-left: auto; }
.rs-items-confirm tfoot td { padding: 6px 8px; font-size: 12px; }
.rs-subtotal-row td { border-top: 1px solid var(--gray-200); padding-top: 8px !important; }
.rs-total-row    td { border-top: 2px solid var(--gray-300); }
.rs-confirm-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--green-700); font-weight: 500;
  padding: 10px 0; margin-top: 4px;
}
.rs-step3-footer { display: flex; justify-content: space-between; margin-top: 18px; }

/* button sizes */
.btn-xs { padding: 3px 8px; font-size: 11px; }
.rs-spinner {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.3); border-top-color: white;
  animation: spin .6s linear infinite; vertical-align: -2px; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.rs-demo-notice {
  background: var(--amber-50, #fffbeb); border: 1px solid var(--amber-200, #fde68a);
  border-radius: var(--radius-sm); padding: 6px 12px;
  font-size: 11px; color: var(--amber-700, #b45309);
  margin-bottom: 12px; display: flex; align-items: center; gap: 6px;
}
.context-menu-item.danger:hover { background: var(--red-50); }

/* ============================================================
   T1163 TAX PREP PAGE
   ============================================================ */

/* Year selector in page subtitle */
.tax-year-sel {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 2px 6px;
  font-size: 13px; color: var(--text-primary); cursor: pointer;
  margin-left: 4px;
}

/* Disclaimer banner */
.tax-disclaimer {
  background: #fffbeb; border: 1px solid #fde68a;
  border-radius: var(--radius-sm); padding: 10px 16px;
  font-size: 12px; color: #92400e; margin-bottom: 16px;
}

/* Tab row */
.tax-tabs {
  display: flex; gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.tax-tab {
  background: none; border: none; cursor: pointer;
  padding: 8px 18px; font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.tax-tab:hover  { color: var(--text-primary); }
.tax-tab.active { color: var(--green-700); border-bottom-color: var(--green-700); }

/* Card */
.tax-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.tax-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.tax-card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }

/* Badges */
.tax-badge { font-size: 11px; font-weight: 600; border-radius: 999px; padding: 2px 10px; }
.tax-badge.amber { background: #fef3c7; color: #92400e; }
.tax-badge.green { background: #d1fae5; color: #065f46; }

/* T1163 line rows */
.t1163-line {
  display: grid; grid-template-columns: 64px 1fr 120px;
  align-items: center; padding: 8px 20px;
  border-bottom: 1px solid var(--border-light, #f3f4f6);
  font-size: 13px;
}
.t1163-line:last-child { border-bottom: none; }
.t1163-linenum { font-family: monospace; font-size: 11px; color: var(--text-muted); }
.t1163-desc    { color: var(--text-primary); }
.t1163-amt     { text-align: right; font-weight: 500; }
.t1163-amt.income  { color: var(--green-700); }
.t1163-amt.expense { color: var(--red-500); }

/* Total rows */
.total-row {
  font-weight: 700 !important; padding: 11px 20px !important;
}
.income-total  { background: #f0fdf4; }
.expense-total { background: #fef2f2; }
.income-total  .t1163-amt,
.expense-total .t1163-amt { font-size: 14px; }

/* Net income box */
.tax-net-box {
  border-radius: var(--radius); padding: 20px 24px;
  margin-top: 16px; text-align: center;
}
.tax-net-box.positive { background: #f0fdf4; border: 1px solid #86efac; }
.tax-net-box.negative { background: #fef2f2; border: 1px solid #fca5a5; }
.tax-net-label  { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-secondary); margin-bottom: 6px; }
.tax-net-amount { font-size: 32px; font-weight: 700; color: var(--text-primary); }
.tax-net-box.positive .tax-net-amount { color: var(--green-700); }
.tax-net-box.negative .tax-net-amount { color: var(--red-500); }
.tax-net-sub    { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* CCA table */
.cca-table-wrap { overflow-x: auto; }
.cca-table {
  width: 100%; border-collapse: collapse; font-size: 12.5px;
}
.cca-table th {
  background: var(--bg-secondary, #f9fafb); text-align: left;
  padding: 9px 14px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.cca-table td { padding: 9px 14px; border-bottom: 1px solid var(--border-light, #f3f4f6); }
.cca-table tbody tr:hover { background: var(--bg-hover, #f9fafb); }
.cca-table tfoot td { background: var(--bg-secondary); font-weight: 700; }
.cca-allowance { color: var(--green-700); font-weight: 600; }
.cca-class-pill {
  display: inline-block; background: #e0f2fe; color: #0369a1;
  font-size: 11px; font-weight: 600; border-radius: 4px;
  padding: 1px 7px;
}
.cca-total-row td { font-weight: 700 !important; background: #f0fdf4 !important; }

/* CCA class reference */
.cca-ref-grid  { display: flex; flex-direction: column; gap: 0; padding: 0 0 4px; }
.cca-ref-row   { display: grid; grid-template-columns: 140px 60px 1fr; gap: 8px; align-items: center; padding: 9px 20px; border-bottom: 1px solid var(--border-light, #f3f4f6); font-size: 13px; }
.cca-ref-rate  { font-weight: 600; color: var(--green-700); text-align: center; }
.cca-ref-desc  { color: var(--text-secondary); }

/* Stat row (GST / AgriInvest) */
.tax-stat-row  { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; margin-bottom: 4px; }
.tax-stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
}
.tax-stat-card.highlight { border-color: var(--green-400, #4ade80); }
.tax-stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 6px; }
.tax-stat-val   { font-size: 24px; font-weight: 700; color: var(--text-primary); }
.tax-stat-val.green { color: var(--green-700); }
.tax-stat-sub   { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ITC pills */
.itc-pill { font-size: 11px; border-radius: 999px; padding: 2px 9px; font-weight: 500; }
.itc-pill.taxable { background: #fef3c7; color: #92400e; }
.itc-pill.zero    { background: #d1fae5; color: #065f46; }
.itc-pill.exempt  { background: #f3f4f6; color: #6b7280; }

/* AgriInvest calc */
.agri-calc   { padding: 4px 20px 16px; }
.agri-row    { display: grid; grid-template-columns: 1fr auto 260px; gap: 12px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--border-light, #f3f4f6); font-size: 13px; }
.agri-row:last-child { border-bottom: none; font-weight: 700; }
.agri-label  { color: var(--text-primary); }
.agri-val    { font-weight: 600; color: var(--green-700); white-space: nowrap; }
.agri-note   { font-size: 11px; color: var(--text-muted); }

/* AgriStability reference grid */
.agri-ref-grid { display: flex; flex-direction: column; gap: 0; }
.agri-ref-item {
  display: grid; grid-template-columns: 200px 1fr;
  gap: 16px; padding: 9px 0;
  border-bottom: 1px solid var(--border-light, #f3f4f6);
  font-size: 13px;
}
.agri-ref-item:last-child { border-bottom: none; }
.agri-ref-item strong { color: var(--text-primary); font-weight: 600; }
.agri-ref-item span   { color: var(--text-secondary); }

/* Notes */
.tax-note { font-size: 12px; color: var(--text-muted); line-height: 1.6; }

/* ============================================================
   AGRISTABILITY PAGE
   ============================================================ */

/* Status bar */
.agri-status-bar {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 18px; margin-bottom: 20px;
}
.agri-status-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; border-radius: 999px; padding: 4px 14px;
}
.agri-status-chip.gray   { background: #f3f4f6; color: #6b7280; }
.agri-status-chip.amber  { background: #fef3c7; color: #92400e; }
.agri-status-chip.blue   { background: #dbeafe; color: #1d4ed8; }
.agri-status-chip.green  { background: #d1fae5; color: #065f46; }
.agri-status-meta {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--text-secondary);
}
.agri-status-meta strong { color: var(--text-primary); }
.deadline-pill {
  display: inline-block; font-size: 11px; font-weight: 600;
  border-radius: 999px; padding: 1px 8px; margin-left: 6px;
  background: #d1fae5; color: #065f46;
}
.deadline-pill.soon   { background: #fef3c7; color: #92400e; }
.deadline-pill.urgent { background: #fee2e2; color: #991b1b; }
.deadline-pill.past   { background: #f3f4f6; color: #9ca3af; }
.agri-admin-link { color: var(--green-700); font-weight: 600; text-decoration: none; font-size: 12.5px; }
.agri-admin-link:hover { text-decoration: underline; }

/* Metric cards row */
.agri-metric-row {
  display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 4px;
}
.agri-metric {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
}
.agri-metric.triggered { border-color: #fca5a5; background: #fff5f5; }
.agri-metric.safe      { border-color: #86efac; }
.agri-metric-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 6px; }
.agri-metric-val   { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.agri-metric-val.green { color: var(--green-700); }
.agri-metric-val.muted { color: var(--text-muted); }
.agri-metric-sub   { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Margin calculator inputs */
.agri-input-section { padding: 4px 0; }
.agri-input-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 20px; border-bottom: 1px solid var(--border-light, #f3f4f6);
  gap: 12px;
}
.agri-input-row label { font-size: 13px; color: var(--text-secondary); flex: 1; }
.agri-input-wrap { display: flex; align-items: center; gap: 2px; }
.agri-input-prefix { font-size: 13px; color: var(--text-muted); }
.agri-input {
  width: 120px; text-align: right;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 4px 8px; font-size: 13px; color: var(--text-primary);
  background: var(--bg-secondary);
}
.agri-input:focus { outline: none; border-color: var(--green-500); }
.agri-input-total {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px; font-weight: 700; font-size: 13px;
  background: var(--bg-secondary); border-top: 1px solid var(--border);
}

/* Margin result box */
.agri-margin-result {
  border-radius: var(--radius); padding: 20px 24px;
  border: 1px solid var(--border);
  background: var(--bg-card);
}
.agri-margin-result.triggered { border-color: #fca5a5; background: #fff5f5; }
.agri-margin-result.safe      { border-color: #86efac; background: #f0fdf4; }
.agri-margin-result-grid {
  display: grid; grid-template-columns: repeat(6,1fr); gap: 16px; margin-bottom: 16px;
}
.amr-item { text-align: center; }
.amr-label { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.amr-val   { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.amr-val.bold  { font-size: 18px; font-weight: 700; }
.amr-val.green { color: var(--green-700); }
.amr-item.highlight { background: rgba(255,255,255,.6); border-radius: var(--radius-sm); padding: 8px; }
.agri-triggered-msg {
  background: #fee2e2; border: 1px solid #fca5a5; border-radius: var(--radius-sm);
  padding: 12px 16px; font-size: 13px; color: #7f1d1d; line-height: 1.6;
}
.agri-safe-msg {
  background: #f0fdf4; border: 1px solid #86efac; border-radius: var(--radius-sm);
  padding: 12px 16px; font-size: 13px; color: #14532d; line-height: 1.6;
}

/* History table */
.agri-history-dropped td { color: var(--text-muted); background: #fafafa; }
.agri-role-pill {
  font-size: 11px; border-radius: 999px; padding: 2px 8px; font-weight: 500;
}
.agri-included { background: #d1fae5; color: #065f46; }
.agri-dropped  { background: #f3f4f6; color: #9ca3af; }

/* Bar chart */
.agri-bar-chart {
  display: flex; align-items: flex-end; gap: 12px; justify-content: center;
  padding: 24px 20px 12px; min-height: 200px; position: relative;
}
.agri-bar-col { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.agri-bar-wrap { position: relative; width: 48px; height: 160px; }
.agri-bar {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--green-400); border-radius: 4px 4px 0 0;
  transition: height .3s;
}
.agri-bar.current { background: var(--green-600); }
.agri-bar.low     { background: #f87171; }
.agri-bar-ref-line  { position:absolute; left:0; right:0; height:2px; background:#2d6a4f; z-index:2; }
.agri-bar-trig-line { position:absolute; left:0; right:0; height:2px; background:#ef4444; z-index:2; border-top: 2px dashed #ef4444; }
.agri-bar-label { font-size: 11px; color: var(--text-muted); }
.agri-bar-val   { font-size: 11px; font-weight: 600; color: var(--text-secondary); }
.agri-chart-legend {
  position: absolute; top: 8px; right: 20px; display: flex; gap: 16px; font-size: 11px;
}
.legend-ref  { color: #2d6a4f; }
.legend-trig { color: #ef4444; }

/* Application steps */
.agri-steps { padding: 8px 20px 16px; }
.agri-step {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border-light, #f3f4f6);
  font-size: 13px;
}
.agri-step:last-child { border-bottom: none; }
.agri-step-icon {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.agri-step.done    .agri-step-icon { background: #d1fae5; color: #065f46; }
.agri-step.pending .agri-step-icon { background: #f3f4f6; color: #9ca3af; }
.agri-step.done    .agri-step-label { color: var(--text-primary); }
.agri-step.pending .agri-step-label { color: var(--text-muted); }

/* Document checklist */
.agri-checklist { padding: 4px 20px 16px; }
.agri-doc-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--border-light, #f3f4f6);
  font-size: 13px; color: var(--text-muted);
}
.agri-doc-row.done { color: var(--text-primary); }
.agri-doc-check {
  width: 18px; height: 18px; border: 1px solid var(--border);
  border-radius: 4px; display: flex; align-items: center; justify-content: center;
  font-size: 11px; flex-shrink: 0; color: var(--green-700);
}
.agri-doc-row.done .agri-doc-check { background: #d1fae5; border-color: #86efac; }

/* Key dates */
.agri-dates-grid {
  display: flex; flex-direction: column; gap: 0;
  padding: 0 20px 16px;
}
.agri-date-item {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 12px 0; border-bottom: 1px solid var(--border-light, #f3f4f6);
}
.agri-date-item:last-child { border-bottom: none; }
.agri-date-icon {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 13px;
  background: #f3f4f6; color: #9ca3af; font-weight: 700;
}
.agri-date-item.done   .agri-date-icon { background: #d1fae5; color: #065f46; }
.agri-date-item.urgent .agri-date-icon { background: #fee2e2; color: #991b1b; }
.agri-date-label { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.agri-date-val   { font-size: 12px; color: var(--green-700); font-weight: 500; margin: 1px 0; }
.agri-date-note  { font-size: 11px; color: var(--text-muted); }

/* Guide */
.agri-guide-body { padding: 0 20px 16px; }
.agri-guide-row {
  display: grid; grid-template-columns: 160px 1fr; gap: 16px;
  padding: 10px 0; border-bottom: 1px solid var(--border-light, #f3f4f6);
  font-size: 13px;
}
.agri-guide-row:last-child { border-bottom: none; }
.agri-guide-term { font-weight: 600; color: var(--text-primary); }
.agri-guide-def  { color: var(--text-secondary); line-height: 1.55; }

/* Provincial rows */
.agri-prov-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 20px; border-bottom: 1px solid var(--border-light, #f3f4f6);
  font-size: 13px;
}
.agri-prov-row:last-child { border-bottom: none; }
.agri-prov-row.active { background: #f0fdf4; }
.agri-prov-code { font-weight: 700; font-size: 12px; width: 28px; color: var(--green-700); }
.agri-prov-info { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.agri-prov-info strong { font-weight: 600; }
.agri-prov-info span   { font-size: 11px; color: var(--text-muted); }
.agri-prov-link { font-size: 12px; color: var(--green-700); text-decoration: none; }
.agri-prov-link:hover  { text-decoration: underline; }

/* Allowable / not allowable columns */
.agri-allow-cols  { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 12px; }
.agri-allow-header { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 6px 0; margin-bottom: 4px; }
.agri-allow-header.green { color: #065f46; border-bottom: 2px solid #86efac; }
.agri-allow-header.red   { color: #991b1b; border-bottom: 2px solid #fca5a5; }
.agri-allow-item { font-size: 12.5px; color: var(--text-secondary); padding: 5px 0; border-bottom: 1px solid var(--border-light,#f3f4f6); }

/* ===== EXPORT DROPDOWN ===== */
.export-wrap { position: relative; display: inline-block; }
.export-menu {
  display: none; position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 240px; background: var(--white);
  border: 1px solid var(--gray-200); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 400; overflow: hidden;
  animation: dropIn .12s ease;
}
.export-menu.open { display: block; }
.export-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; font-size: 13px; color: var(--gray-700);
  cursor: pointer; transition: background .1s; text-decoration: none;
  white-space: nowrap;
}
.export-item:hover { background: var(--green-50); color: var(--green-700); }
.export-item + .export-item { border-top: 1px solid var(--gray-100); }
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== AUTH GATE ===== */
#authGate {
  position: fixed; inset: 0; z-index: 9999;
  background: linear-gradient(135deg, #1b4332 0%, #2d6a4f 60%, #40916c 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-gate-card {
  background: var(--white);
  border-radius: 16px;
  width: 100%; max-width: 420px;
  padding: 36px 40px;
  box-shadow: 0 24px 64px rgba(0,0,0,.28);
}
.auth-gate-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 20px;
  font-size: 22px; font-weight: 300; color: var(--gray-900);
  letter-spacing: -.02em;
}
.auth-gate-logo strong { font-weight: 700; }
.auth-gate-title {
  font-size: 20px; font-weight: 600; color: var(--gray-900);
  margin-bottom: 20px;
}
.auth-tabs {
  display: flex; border-bottom: 2px solid var(--gray-200);
  margin-bottom: 22px; gap: 0;
}
.auth-tab {
  flex: 1; background: none; border: none; cursor: pointer;
  padding: 9px 0; font-size: 14px; font-weight: 500;
  color: var(--gray-500); border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: color .15s, border-color .15s;
}
.auth-tab.active { color: var(--green-700); border-bottom-color: var(--green-700); }
.auth-tab:hover:not(.active) { color: var(--gray-700); }
.auth-submit-btn {
  width: 100%; margin-top: 6px; padding: 11px;
  font-size: 15px; font-weight: 600;
}
.auth-gate-footer {
  text-align: center; font-size: 13px; color: var(--gray-500);
  margin-top: 16px;
}
.auth-gate-footer a {
  color: var(--green-700); text-decoration: none; font-weight: 600;
}
.auth-gate-footer a:hover { text-decoration: underline; }
.auth-gate-demo {
  text-align: center; margin-top: 20px;
  padding-top: 16px; border-top: 1px solid var(--gray-100);
}

/* ===== USER DROPDOWN ===== */
.user-menu-wrap { position: relative; }
.user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 220px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 500;
  overflow: hidden;
}
.user-dropdown-info {
  padding: 12px 14px 10px;
}
.user-dropdown-name  { font-weight: 600; font-size: 13px; color: var(--gray-900); }
.user-dropdown-email { font-size: 12px; color: var(--gray-500); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-dropdown-divider { height: 1px; background: var(--gray-100); }
.user-dropdown-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; font-size: 13px; color: var(--gray-700);
  cursor: pointer; transition: background .12s;
  text-decoration: none;
}
.user-dropdown-item:hover { background: var(--gray-50); }
.user-dropdown-logout { color: var(--red-500); }
.user-dropdown-logout:hover { background: var(--red-50); }

/* ===== API / DEMO MODE PILLS ===== */
.api-mode-pill,
.demo-mode-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; letter-spacing: .03em;
  padding: 3px 9px; border-radius: 20px;
  vertical-align: middle;
}
.api-mode-pill {
  background: #d1fae5; color: #065f46;
  border: 1px solid #6ee7b7;
}
.api-mode-pill::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: #10b981;
  animation: pill-pulse 2s ease-in-out infinite;
}
.demo-mode-pill {
  background: #fef3c7; color: #92400e;
  border: 1px solid #fcd34d;
}
.demo-mode-pill::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: #f59e0b;
}
@keyframes pill-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .45; }
}

/* ===== PAGE LOADING SPINNER ===== */
.page-loading {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 14px;
  padding: 80px 24px;
  color: var(--gray-400);
  font-size: 13px;
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--green-600);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
.spinner-sm {
  width: 18px; height: 18px;
  border-width: 2px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== RADIO GROUP (used in Field modal) ===== */
.radio-group {
  display: flex; gap: 16px; flex-wrap: wrap;
  padding: 6px 0;
}
.radio-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 400; color: var(--gray-700);
  cursor: pointer;
}
.radio-label input[type="radio"] {
  accent-color: var(--green-700);
  width: 15px; height: 15px;
}

/* ===== REQUIRED FIELD MARKER ===== */
.req { color: var(--red-500); font-weight: 700; }

/* ===== LENDER PACKAGE ===== */
.lp-tabs {
  display: flex; gap: 0;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 24px;
}
.lp-tab {
  background: none; border: none; cursor: pointer;
  padding: 10px 22px; font-size: 13.5px; font-weight: 500;
  color: var(--gray-500);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.lp-tab:hover { color: var(--gray-800); }
.lp-tab.active { color: var(--green-700); border-bottom-color: var(--green-700); font-weight: 600; }

/* Ratios row */
.lp-ratios {
  display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 24px;
}
.lp-ratio-card {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius, 8px); padding: 14px 18px;
  min-width: 140px; flex: 1;
}
.lp-ratio-label { font-size: 11px; color: var(--gray-500); font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 5px; }
.lp-ratio-value { font-size: 22px; font-weight: 700; color: var(--gray-900); line-height: 1.2; }
.lp-ratio-sub   { font-size: 11px; color: var(--gray-400); margin-top: 3px; }
.lp-ratio-good  { color: var(--green-700) !important; }
.lp-ratio-warn  { color: var(--amber-600) !important; }
.lp-ratio-bad   { color: var(--red-500)   !important; }

/* Net Worth tiers */
.lp-nw-tier-wrap { margin-bottom: 16px; }
.lp-nw-tier-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--gray-600);
  padding: 6px 0 4px; border-top: 2px solid var(--gray-300);
  margin-bottom: 0;
}
.lp-nw-tier {
  display: grid; grid-template-columns: 1fr 1fr;
  border: 1px solid var(--gray-200); border-radius: 0 0 8px 8px;
  overflow: hidden;
}
.lp-nw-side { display: flex; flex-direction: column; }
.lp-nw-side + .lp-nw-side { border-left: 1px solid var(--gray-200); }
.lp-nw-tier-header {
  padding: 8px 14px; background: var(--gray-50);
  font-size: 11px; font-weight: 700; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--gray-200);
  display: flex; justify-content: space-between; align-items: center;
}
.lp-nw-row {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; font-size: 13px;
  border-bottom: 1px solid var(--gray-100);
  transition: background .1s;
}
.lp-nw-row:hover { background: var(--gray-50); }
.lp-nw-row-label { flex: 1; color: var(--gray-700); }
.lp-nw-row-value { font-variant-numeric: tabular-nums; color: var(--gray-900); font-weight: 500; white-space: nowrap; }
.lp-nw-row-actions { display: none; gap: 2px; }
.lp-nw-row:hover .lp-nw-row-actions { display: flex; }
.lp-nw-subtotal {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 14px; background: var(--green-50);
  font-size: 12.5px; font-weight: 600; color: var(--green-800);
  margin-top: auto;
}

/* Grand total bar */
.lp-nw-grand {
  border: 1px solid var(--gray-300); border-top: 2px solid var(--green-700);
  border-radius: 8px; overflow: hidden; margin-top: 4px;
}
.lp-nw-grand-row {
  display: grid; grid-template-columns: 1fr auto 1fr auto;
  align-items: center; gap: 0;
  background: var(--green-800); color: white;
  padding: 12px 20px;
}
.lp-nw-networth-row {
  background: var(--green-900);
  padding: 14px 20px;
}
.lp-nw-grand-label { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.lp-nw-grand-value { font-size: 16px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; padding-left: 24px; }
.lp-nw-nw-value    { font-size: 20px; }

/* Income table */
.lp-inc-table {
  width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 20px;
}
.lp-inc-table th {
  padding: 8px 12px; text-align: right;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--gray-500);
  border-bottom: 2px solid var(--gray-200); background: var(--gray-50);
  white-space: nowrap;
}
.lp-inc-table th:first-child { text-align: left; min-width: 220px; }
.lp-inc-table td {
  padding: 7px 12px; text-align: right;
  border-bottom: 1px solid var(--gray-100);
  font-variant-numeric: tabular-nums;
}
.lp-inc-table td:first-child { text-align: left; }
.lp-inc-table tr:hover td { background: var(--gray-50); }
.lp-inc-row-label { position: relative; }
.lp-row-btns { display: none; position: absolute; right: 0; top: 50%; transform: translateY(-50%); }
tr:hover .lp-row-btns { display: inline-flex; gap: 2px; }
.lp-inc-section-header td {
  background: var(--gray-100); font-weight: 700;
  font-size: 11px; text-transform: uppercase;
  color: var(--gray-500); letter-spacing: .05em;
  padding: 6px 12px; position: relative;
}
.lp-inc-subtotal td { font-weight: 600; background: var(--green-50); color: var(--green-800); border-top: 1px solid var(--gray-300); }
.lp-inc-total td { font-weight: 700; font-size: 13.5px; background: var(--green-700); color: white; border-top: 2px solid var(--green-800); }
.lp-yoy-head { font-style: italic; color: var(--gray-400) !important; }
.lp-yoy-cell { font-size: 11.5px; }
.lp-pos { color: var(--green-700); font-weight: 600; }
.lp-neg { color: var(--red-500);   font-weight: 600; }

/* Debt table */
.lp-debt-table {
  width: 100%; border-collapse: collapse; font-size: 12.5px;
}
.lp-debt-table th {
  padding: 7px 10px; text-align: right;
  font-size: 11px; font-weight: 700; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 2px solid var(--gray-200); background: var(--gray-50);
  white-space: nowrap;
}
.lp-debt-table th:nth-child(1),
.lp-debt-table th:nth-child(2) { text-align: left; }
.lp-debt-table td {
  padding: 7px 10px; text-align: right;
  border-bottom: 1px solid var(--gray-100);
  font-variant-numeric: tabular-nums; vertical-align: top;
}
.lp-debt-table td:nth-child(1),
.lp-debt-table td:nth-child(2) { text-align: left; }
.lp-debt-group-row td { background: var(--gray-100); font-weight: 700; font-size: 11px;
  text-transform: uppercase; color: var(--gray-500); padding: 5px 10px; }
.lp-debt-subtotal td { font-weight: 600; background: var(--green-50); color: var(--green-800); border-top: 1px solid var(--gray-300); }
.lp-debt-total td { font-weight: 700; background: var(--green-700); color: white; border-top: 2px solid var(--green-800); }
.lp-debt-sec { font-size: 11px; color: var(--gray-400); display: block; margin-top: 2px; }

/* Cash Flow grid */
.lp-cf-table {
  width: 100%; border-collapse: collapse; font-size: 12px; min-width: 980px;
}
.lp-cf-table th {
  padding: 7px 6px; text-align: right;
  font-size: 10.5px; font-weight: 700; color: var(--gray-500);
  text-transform: uppercase; background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200); white-space: nowrap;
}
.lp-cf-table th:first-child { text-align: left; min-width: 170px; }
.lp-cf-total-head { border-left: 2px solid var(--gray-300); }
.lp-cf-table td {
  padding: 5px 6px; text-align: right;
  border-bottom: 1px solid var(--gray-100);
  font-variant-numeric: tabular-nums;
}
.lp-cf-table td:first-child { text-align: left; color: var(--gray-700); }
.lp-cf-table tr:hover td { background: var(--gray-50); }
.lp-cf-table tr:hover td:first-child { background: var(--gray-50); }
.lp-cf-section-header td { background: var(--gray-100); font-weight: 700;
  font-size: 11px; text-transform: uppercase; color: var(--gray-500); }
.lp-cf-subtotal td { font-weight: 600; background: var(--green-50); color: var(--green-800); border-top: 1px solid var(--gray-300); }
.lp-cf-net td { font-weight: 700; font-size: 12.5px; background: var(--green-700); color: white; }
.lp-cf-balance td { font-weight: 600; background: var(--gray-900); color: white; font-size: 12px; }
.lp-cf-neg { color: var(--red-500) !important; font-weight: 600; }
.lp-cf-months-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 8px;
}
.lp-cf-months-grid .form-group label { font-size: 11px; }

/* Icon edit buttons */
.lp-icon-btn {
  background: none; border: none; cursor: pointer;
  padding: 2px 5px; border-radius: 4px;
  color: var(--gray-400); font-size: 12px;
  transition: color .1s, background .1s; line-height: 1;
}
.lp-icon-btn:hover { color: var(--green-700); background: var(--green-50); }
.lp-icon-btn.del:hover { color: var(--red-500); background: var(--red-50); }

/* Disclaimer */
.lp-disclaimer {
  font-size: 11px; color: var(--gray-400); margin-top: 16px;
  padding-top: 12px; border-top: 1px solid var(--gray-100);
  line-height: 1.5;
}

/* ===== PRINT — LENDER PACKAGE ===== */
@media print {
  body.lp-printing .sidebar,
  body.lp-printing .topbar,
  body.lp-printing .page-header-actions,
  body.lp-printing .lp-tabs,
  body.lp-printing #lp-body,
  body.lp-printing .lp-disclaimer,
  body.lp-printing .ai-agent-btn,
  body.lp-printing .ai-cfo-btn { display: none !important; }

  body.lp-printing #lp-print-root { display: block !important; }

  body.lp-printing .lp-print-cover {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; min-height: 100vh;
    text-align: center; padding: 60px 40px;
    page-break-after: always;
  }
  .lp-cover-logo { display: flex; align-items: center; gap: 10px; font-size: 26px; font-weight: 300; margin-bottom: 40px; }
  .lp-cover-brand { font-size: 26px; }
  .lp-cover-title { font-size: 28px; font-weight: 300; color: var(--gray-900); margin-bottom: 12px; }
  .lp-cover-farm  { font-size: 22px; font-weight: 700; color: var(--green-700); margin-bottom: 24px; }
  .lp-cover-meta  { font-size: 14px; color: var(--gray-600); line-height: 2; margin-bottom: 32px; }
  .lp-cover-summary {
    display: flex; gap: 40px; justify-content: center; margin-bottom: 40px;
    border-top: 2px solid var(--gray-200); border-bottom: 2px solid var(--gray-200);
    padding: 24px 0;
  }
  .lp-cover-kpi { text-align: center; }
  .lp-cover-kpi div { font-size: 22px; font-weight: 700; color: var(--green-700); }
  .lp-cover-kpi small { font-size: 11px; color: var(--gray-500); text-transform: uppercase; }
  .lp-cover-toc { font-size: 13px; color: var(--gray-600); line-height: 2.2; text-align: left; }
  .lp-cover-disc { font-size: 11px; color: var(--gray-400); margin-top: 32px; }

  body.lp-printing .lp-print-section { page-break-before: always; padding: 20px 0; }
  .lp-ps-title { font-size: 18px; font-weight: 700; color: var(--green-800); margin-bottom: 4px; }
  .lp-ps-sub   { font-size: 12px; color: var(--gray-500); margin-bottom: 16px; }

  .lp-nw-tier  { break-inside: avoid; }
  .lp-cf-table { font-size: 9px; }
  .lp-cf-table th, .lp-cf-table td { padding: 4px 4px; }

  /* Force colours to print */
  .lp-nw-grand, .lp-nw-grand-row, .lp-inc-total td,
  .lp-cf-net td, .lp-cf-balance td, .lp-debt-total td {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}

/* Print */
@media print {
  .sidebar, .topbar, .page-header-actions, .tax-tabs,
  .tax-disclaimer, .ai-agent-btn, .ai-cfo-btn { display: none !important; }
  .tax-panel { display: block !important; }
  .tax-card  { break-inside: avoid; }
}

/* =============================================================
   NAV BADGE (unread count)
   ============================================================= */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #f59e0b;
  color: white;
  font-size: 10px;
  font-weight: 700;
  margin-left: auto;
}

/* =============================================================
   TRANSACTIONS PAGE
   ============================================================= */

/* ── Stats bar ───────────────────────────────────────────────── */
.txn-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.txn-stat-card {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
}
.txn-stat-card.green  { border-left: 4px solid var(--green-500); }
.txn-stat-card.red    { border-left: 4px solid #ef4444; }
.txn-stat-card.amber  { border-left: 4px solid #f59e0b; }
.txn-stat-card.gray   { border-left: 4px solid #d1d5db; }
.txn-stat-label { font-size: 12px; color: var(--gray-500); margin-bottom: 4px; }
.txn-stat-value { font-size: 22px; font-weight: 700; color: var(--gray-800); }
.txn-stat-card.green .txn-stat-value { color: var(--green-700); }
.txn-stat-card.red   .txn-stat-value { color: #dc2626; }
.txn-stat-card.amber .txn-stat-value { color: #92400e; }

/* ── Action Required Bar ─────────────────────────────────────── */
.txn-action-bar {
  background: #fffbeb;
  border: 1.5px solid #fcd34d;
  border-radius: 10px;
  margin-bottom: 20px;
  overflow: hidden;
}
.txn-action-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #fef3c7;
  border-bottom: 1px solid #fcd34d;
  font-size: 13.5px;
  color: #92400e;
}
.txn-action-dismiss {
  margin-left: auto;
  padding: 4px 12px;
  border: 1.5px solid #d97706;
  border-radius: 6px;
  background: white;
  color: #92400e;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.txn-action-dismiss:hover { background: #fef3c7; }

.txn-action-list { padding: 8px 0; }
.txn-action-item {
  display: grid;
  grid-template-columns: 90px 1fr auto 200px;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid #fef3c7;
  transition: background .1s;
}
.txn-action-item:last-child { border-bottom: none; }
.txn-action-item:hover { background: #fefce8; }

.txn-ai-date   { font-size: 12px; color: var(--gray-500); white-space: nowrap; }
.txn-ai-desc   { font-size: 13.5px; color: var(--gray-800); display: flex; align-items: center; gap: 8px; }
.txn-ai-badge  { flex-shrink: 0; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 8px; text-transform: uppercase; letter-spacing: .03em; }
.badge-orange  { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.txn-ai-amount { font-size: 13.5px; font-weight: 700; white-space: nowrap; }
.txn-ai-actions { display: flex; align-items: center; gap: 6px; }
.txn-cat-sel   { padding: 5px 8px; font-size: 12px; border: 1.5px solid var(--border); border-radius: 6px; max-width: 130px; }
.txn-ai-edit, .txn-ai-approve {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
}
.txn-ai-approve { border-color: var(--green-400); color: var(--green-700); }
.txn-ai-approve:hover { background: var(--green-50); }
.txn-ai-edit:hover    { background: #f8f8f8; }

.txn-action-more {
  padding: 10px 16px;
  font-size: 12.5px;
  color: var(--gray-400);
  font-style: italic;
}

/* ── Filter Bar ──────────────────────────────────────────────── */
.txn-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 10px;
}
.txn-search-wrap { position: relative; flex: 0 0 220px; }
.txn-filter-sel, .txn-filter-date {
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--gray-700);
  background: white;
  outline: none;
}
.txn-filter-sel:focus, .txn-filter-date:focus { border-color: var(--green-500); }

/* ── Transactions Table ──────────────────────────────────────── */
.txn-table { width: 100%; border-collapse: collapse; }
.txn-table th {
  padding: 9px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .04em;
  background: #f8faf8;
  border-bottom: 1.5px solid var(--border);
}
.txn-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #f0f4f0;
  vertical-align: middle;
}
.txn-table tbody tr:last-child td { border-bottom: none; }
.txn-table tbody tr:hover { background: #f9fdf9; }

.txn-th-date    { width: 100px; }
.txn-th-account { width: 160px; }
.txn-th-cat     { width: 140px; }
.txn-th-status  { width: 110px; }
.txn-th-amount  { width: 110px; text-align: right; }
.txn-th-actions { width: 70px; }

.txn-row-pending { background: #fffbeb !important; }
.txn-row-pending:hover { background: #fef9e7 !important; }

.txn-td-date    { font-size: 13px; color: var(--gray-500); white-space: nowrap; }
.txn-td-desc    { }
.txn-desc-main  { font-size: 13.5px; color: var(--gray-800); font-weight: 500; }
.txn-desc-sub   { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
.txn-td-account { font-size: 12.5px; color: var(--gray-500); }
.txn-td-cat     { }
.txn-td-status  { }
.txn-td-amount  { text-align: right; font-weight: 700; white-space: nowrap; }
.txn-td-actions { text-align: right; white-space: nowrap; }

.txn-amt-income  { color: var(--green-700); }
.txn-amt-expense { color: #dc2626; }

.txn-cat-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 10px;
  background: #f0f4f0;
  color: var(--gray-600);
  font-size: 12px;
  font-weight: 500;
}
.txn-cat-empty { font-size: 12px; color: var(--gray-300); font-style: italic; }

.txn-btn-edit, .txn-btn-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  background: white;
  color: var(--gray-400);
  cursor: pointer;
  margin-left: 3px;
  transition: all .12s;
}
.txn-btn-edit:hover   { border-color: var(--green-400); color: var(--green-700); background: #f0faf4; }
.txn-btn-delete:hover { border-color: #fca5a5; color: #dc2626; background: #fff5f5; }
.txn-btn-edit:disabled{ opacity:.35; cursor:default; }

.txn-empty {
  padding: 40px !important;
  text-align: center;
  color: var(--gray-400);
  font-style: italic;
}

/* ── Manual Transaction Modal ────────────────────────────────── */
.mt-type-toggle {
  display: flex;
  background: #f3f4f6;
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 18px;
}
.mt-type-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--gray-500);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.mt-type-btn.active {
  background: white;
  color: var(--green-700);
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
}

/* =============================================================
   RECONCILIATION PAGE
   ============================================================= */

/* ── How it works ────────────────────────────────────────────── */
.recon-how-it-works {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 18px 20px;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  margin-bottom: 24px;
}
.rhiw-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
}
.rhiw-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--green-700);
  color: white;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}
.rhiw-step strong { font-size: 13.5px; color: var(--gray-800); display: block; }
.rhiw-step p      { font-size: 12px; color: var(--gray-400); margin: 2px 0 0; }
.rhiw-arrow       { font-size: 18px; color: var(--gray-300); padding: 0 12px; margin-top: 2px; }

/* ── Empty history ───────────────────────────────────────────── */
.recon-empty-history {
  text-align: center;
  padding: 48px;
  color: var(--gray-400);
}
.recon-empty-history p     { font-size: 14px; font-weight: 600; color: var(--gray-500); margin: 12px 0 4px; }
.recon-empty-history small { font-size: 12.5px; }

/* ── History table ───────────────────────────────────────────── */
.recon-hist-table { width: 100%; border-collapse: collapse; }
.recon-hist-table th {
  padding: 9px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .04em;
  background: #f8faf8;
  border-bottom: 1.5px solid var(--border);
}
.recon-hist-table td { padding: 12px 14px; border-bottom: 1px solid #f0f4f0; }
.recon-hist-table tbody tr:last-child td { border-bottom: none; }

/* ── Workspace ───────────────────────────────────────────────── */
.recon-workspace {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  align-items: start;
}

/* ── Summary panel ───────────────────────────────────────────── */
.recon-summary-panel { display: flex; flex-direction: column; gap: 14px; }

.recon-summary-card {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}
.recon-sum-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 14px;
}
.recon-sum-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  font-size: 13.5px;
  color: var(--gray-600);
  border-bottom: 1px solid #f5f5f5;
}
.recon-sum-row:last-child { border-bottom: none; }
.recon-sum-divider { height: 2px; background: var(--border); margin: 8px 0; }

.recon-diff {
  font-size: 15px !important;
  color: var(--gray-800) !important;
  padding: 10px 0 !important;
  margin-top: 4px;
}
.recon-diff-zero  { color: var(--green-700) !important; }
.recon-diff-val   { font-size: 16px; }
.recon-diff-zero .recon-diff-val { color: var(--green-700); }

.recon-balanced-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 12px;
  background: #f0faf4;
  border-radius: 8px;
  border: 1px solid #b7e4c7;
  font-size: 13px;
  color: var(--green-800);
  font-weight: 600;
}
.recon-diff-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--gray-400);
  text-align: center;
}

.recon-progress-card {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.recon-prog-label { font-size: 12px; color: var(--gray-500); margin-bottom: 4px; }
.recon-prog-nums  { font-size: 20px; font-weight: 700; color: var(--gray-800); margin-bottom: 10px; }
.recon-prog-bar   { height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; margin-bottom: 12px; }
.recon-prog-fill  { height: 100%; background: var(--green-500); border-radius: 4px; transition: width .3s; }
.recon-prog-actions { display: flex; gap: 8px; }

/* ── Transaction panel ───────────────────────────────────────── */
.recon-txn-panel {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.recon-txn-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #f8faf8;
  border-bottom: 1.5px solid var(--border);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--gray-700);
}
.recon-txn-scroll { max-height: 560px; overflow-y: auto; }

.recon-txn-table { width: 100%; border-collapse: collapse; }
.recon-txn-table th {
  position: sticky;
  top: 0;
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .04em;
  background: #f8faf8;
  border-bottom: 1.5px solid var(--border);
  z-index: 1;
}
.recon-txn-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f5f7f5;
  vertical-align: middle;
  font-size: 13.5px;
}
.recon-txn-table tbody tr:last-child td { border-bottom: none; }

.recon-txn-row { transition: background .1s; }
.recon-txn-row:hover  { background: #f9fdf9; }
.recon-cleared        { background: #f0faf4 !important; }
.recon-cleared:hover  { background: #e8f5e9 !important; }
.recon-cleared td     { opacity: .7; }

.recon-td-check  { width: 50px; }
.recon-td-date   { width: 95px; white-space: nowrap; color: var(--gray-500); font-size: 13px; }
.recon-td-amount { text-align: right; white-space: nowrap; }
.text-right      { text-align: right !important; }

/* Finish button disabled state */
.btn.disabled {
  opacity: .5;
  cursor: not-allowed;
  pointer-events: auto;
}

/* =============================================================
   CHART OF ACCOUNTS
   ============================================================= */

/* ── Toolbar ─────────────────────────────────────────────────── */
.coa-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.coa-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.coa-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: white;
  color: var(--gray-600);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.coa-tab:hover { border-color: var(--green-400); color: var(--green-700); }
.coa-tab.active {
  background: var(--green-700);
  border-color: var(--green-700);
  color: white;
}
.coa-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: rgba(0,0,0,.12);
  font-size: 11px;
  font-weight: 600;
}
.coa-tab.active .coa-tab-count { background: rgba(255,255,255,.25); }

.coa-search-wrap {
  position: relative;
  flex: 0 0 220px;
}
.coa-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}
.coa-search {
  width: 100%;
  padding: 7px 12px 7px 32px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}
.coa-search:focus { border-color: var(--green-500); }

/* ── Type Section ────────────────────────────────────────────── */
.coa-content { display: flex; flex-direction: column; gap: 24px; }

.coa-type-section {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: white;
}

.coa-type-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: #f8faf8;
  border-bottom: 1.5px solid var(--border);
}
.coa-type-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--coa-type-color, #888);
  flex-shrink: 0;
}
.coa-type-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--coa-type-color, var(--gray-700));
  text-transform: uppercase;
  letter-spacing: .04em;
}
.coa-type-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--gray-500);
}

/* ── Account Table ───────────────────────────────────────────── */
.coa-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.coa-table thead tr {
  background: #f8faf8;
}
.coa-table th {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .04em;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.coa-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f4f0;
  vertical-align: middle;
}
.coa-table tbody tr:last-child td { border-bottom: none; }
.coa-table tbody tr:hover { background: #f9fdf9; }

.coa-th-no      { width: 80px; }
.coa-th-sub     { width: 160px; }
.coa-th-tax     { width: 100px; }
.coa-th-active  { width: 70px; text-align: center; }
.coa-th-actions { width: 70px; }

.coa-cell-no { font-family: monospace; font-size: 13px; color: var(--gray-500); font-weight: 600; }
.coa-cell-name { font-weight: 500; color: var(--gray-800); }
.coa-cell-subtype { font-size: 12.5px; color: var(--gray-500); }
.coa-cell-taxline { }
.coa-cell-active { text-align: center; }
.coa-cell-actions { text-align: right; white-space: nowrap; }

.coa-row-inactive td { opacity: .55; }
.coa-row-inactive .coa-cell-name { text-decoration: line-through; }

.coa-sys-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  background: #e8f5e9;
  color: var(--green-700);
  letter-spacing: .02em;
  text-transform: uppercase;
}

.coa-taxline-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: #f0f4ff;
  color: #3a5bd9;
  font-size: 12px;
  font-family: monospace;
  font-weight: 600;
}

.coa-empty-row {
  padding: 20px 16px !important;
  color: var(--gray-400);
  font-style: italic;
  text-align: center;
}

.coa-no-results {
  padding: 40px;
  text-align: center;
  color: var(--gray-500);
  font-size: 14px;
}

/* ── Active Toggle ───────────────────────────────────────────── */
.coa-toggle {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 20px;
  cursor: pointer;
}
.coa-toggle input { opacity: 0; width: 0; height: 0; }
.coa-toggle-slider {
  position: absolute;
  inset: 0;
  background: #d1d5db;
  border-radius: 20px;
  transition: .2s;
}
.coa-toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  left: 3px;
  top: 3px;
  transition: .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.coa-toggle input:checked + .coa-toggle-slider { background: var(--green-500); }
.coa-toggle input:checked + .coa-toggle-slider::before { transform: translateX(14px); }

/* ── Row Action Buttons ──────────────────────────────────────── */
.coa-btn-edit, .coa-btn-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--gray-500);
  cursor: pointer;
  transition: all .15s;
  margin-left: 4px;
}
.coa-btn-edit:hover  { border-color: var(--green-500); color: var(--green-700); background: #f0faf4; }
.coa-btn-delete:hover{ border-color: #e74c3c; color: #e74c3c; background: #fff5f5; }

/* ── Footer note ─────────────────────────────────────────────── */
.coa-footer-note {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0 4px;
  font-size: 12px;
  color: var(--gray-400);
}

/* ── Import Modal — Steps ────────────────────────────────────── */
.coa-import-steps {
  display: flex;
  align-items: center;
  padding: 16px 24px 0;
  gap: 0;
}
.coa-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--gray-400);
  white-space: nowrap;
}
.coa-step span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #e5e7eb;
  color: #888;
  font-size: 12px;
  font-weight: 700;
  transition: all .2s;
}
.coa-step.active { color: var(--green-700); }
.coa-step.active span { background: var(--green-700); color: white; }
.coa-step.done { color: var(--green-600); }
.coa-step.done span { background: var(--green-100); color: var(--green-700); }
.coa-step-divider {
  flex: 1;
  height: 2px;
  background: #e5e7eb;
  margin: 0 8px;
  min-width: 20px;
}

/* ── Import Step 1 — Upload ──────────────────────────────────── */
.coa-import-upload-area {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: #fafafa;
}
.coa-import-upload-area:hover,
.coa-import-upload-area.drag-over {
  border-color: var(--green-500);
  background: #f0faf4;
}
.coa-upload-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  margin: 12px 0 6px;
}
.coa-upload-browse {
  color: var(--green-700);
  cursor: pointer;
  text-decoration: underline;
}
.coa-upload-hint { font-size: 12px; color: var(--gray-400); margin: 2px 0; }

.coa-upload-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #f8faf8;
  font-size: 13px;
  color: var(--gray-600);
}
.coa-upload-success {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #f0faf4;
  border: 1px solid #b7e4c7;
  font-size: 13px;
  color: var(--green-800);
}
.coa-upload-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #fff5f5;
  border: 1px solid #fcc;
  font-size: 13px;
  color: #c0392b;
}

.coa-import-examples {
  margin-top: 20px;
  font-size: 12.5px;
  color: var(--gray-500);
}
.coa-import-col-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.coa-import-col-chips span {
  padding: 3px 10px;
  border-radius: 12px;
  background: #f0f4f0;
  color: var(--gray-600);
  font-size: 12px;
  font-family: monospace;
}

/* ── Import Step 2 — Mapping table ──────────────────────────── */
.coa-import-info {
  font-size: 13.5px;
  color: var(--gray-600);
  margin-bottom: 16px;
}
.coa-map-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.coa-map-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .04em;
  background: #f8faf8;
  border-bottom: 1.5px solid var(--border);
}
.coa-map-table td { padding: 10px 12px; border-bottom: 1px solid #f0f4f0; }
.coa-map-label { font-weight: 600; color: var(--gray-700); white-space: nowrap; }
.coa-map-hint { font-size: 12px; color: var(--gray-400); }
.coa-map-sel { padding: 6px 10px; font-size: 13px; min-width: 160px; }

/* ── Import Step 3 — Preview ─────────────────────────────────── */
.coa-preview-scroll { overflow-x: auto; }
.coa-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 480px;
}
.coa-preview-table th {
  padding: 7px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray-500);
  background: #f8faf8;
  border-bottom: 1.5px solid var(--border);
}
.coa-preview-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #f0f4f0;
  color: var(--gray-700);
}
.coa-preview-table tbody tr:last-child td { border-bottom: none; }
.coa-missing { color: #e74c3c; font-style: italic; }

/* ── Import Step 4 — Confirm ─────────────────────────────────── */
.coa-import-confirm {
  text-align: center;
  padding: 8px 0 16px;
}
.coa-import-confirm-icon { margin-bottom: 12px; }
.coa-import-confirm h3 { font-size: 17px; font-weight: 700; color: var(--gray-800); margin-bottom: 6px; }
.coa-import-confirm p  { font-size: 13.5px; color: var(--gray-500); margin-bottom: 18px; }

.coa-import-options {
  display: flex;
  gap: 12px;
  margin-top: 4px;
  text-align: left;
}
.coa-import-opt {
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.coa-import-opt input { margin-top: 3px; flex-shrink: 0; }
.coa-import-opt.selected { border-color: var(--green-500); background: #f0faf4; }
.coa-import-opt strong { display: block; font-size: 13.5px; color: var(--gray-800); margin-bottom: 3px; }
.coa-import-opt p { font-size: 12px; color: var(--gray-500); margin: 0; text-align: left; }
.coa-import-opt em { font-style: italic; color: var(--gray-400); }

/* form-row2 (reusable 2-column layout) */
.form-row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ── Grain Sale — Unit Badges ──────────────────────────────── */
.unit-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  vertical-align: middle;
}
.unit-bu {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}
.unit-mt {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

/* ── Grain Sale — POS Deduction Button (income table) ─────── */
.pos-deduction-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.pos-zero {
  background: #f9fafb;
  color: #9ca3af;
  border-color: #e5e7eb;
}
.pos-zero:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: #6b7280;
}
.pos-has-amount {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fed7aa;
}
.pos-has-amount:hover {
  background: #ffedd5;
  border-color: #fdba74;
}
.pos-zero-label {
  font-size: 11px;
  color: #9ca3af;
  font-style: italic;
}

/* ── Grain Sale — POS Preview Banner (inside create form) ─── */
.grain-pos-preview {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  margin: 4px 0 2px;
}
.grain-pos-icon {
  flex-shrink: 0;
  margin-top: 1px;
}
.grain-pos-text {
  font-size: 13px;
  color: #166534;
  line-height: 1.5;
}
.grain-pos-text strong {
  font-weight: 700;
}
.grain-pos-hint {
  display: block;
  font-size: 11.5px;
  color: #4ade80;
  color: #16a34a;
  margin-top: 1px;
}

/* ── POS Deduction Line Editor (inside quickAdd modal) ──────── */
.pos-edit-header {
  margin-bottom: 14px;
}
.pos-edit-sale-info {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 7px;
  font-size: 13px;
  color: #166534;
  margin-bottom: 8px;
}
.pos-edit-sale-info strong { font-weight: 700; }
.pos-edit-hint {
  font-size: 12px;
  color: var(--gray-400);
  margin: 0 0 2px;
  font-style: italic;
  line-height: 1.5;
}
.pos-line-row {
  display: grid;
  grid-template-columns: 1fr 140px 28px;
  gap: 8px;
  align-items: center;
  margin-bottom: 7px;
}
.pos-line-row input {
  height: 34px;
  padding: 0 10px;
  font-size: 13px;
}
.pos-line-row.no-del {
  grid-template-columns: 1fr 140px;
}
.pos-line-del {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #fee2e2;
  color: #dc2626;
  border: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: background .15s;
}
.pos-line-del:hover { background: #fecaca; }
.pos-total-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-800);
}
.pos-total-row span:first-child {
  color: var(--gray-500);
  font-weight: 400;
  font-size: 13px;
}
.btn-add-pos-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  background: var(--gray-50);
  border: 1px dashed var(--border);
  border-radius: 7px;
  font-size: 13px;
  color: var(--gray-500);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  margin-top: 4px;
}
.btn-add-pos-line:hover {
  background: #f0fdf4;
  border-color: var(--green-500);
  color: var(--green-600);
}

/* ===== IMPORT MODAL ===== */
.import-fmt-card {
  display: block;
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  user-select: none;
}
.import-fmt-card:hover   { border-color: var(--green-400); background: var(--green-50); }
.import-fmt-card.active  { border-color: var(--green-500); background: var(--green-50); }

.imp-summary {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0 14px; font-size: 13px; color: var(--gray-700);
}
.imp-auto-pill {
  background: var(--green-100); color: var(--green-800);
  padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.imp-note { color: var(--gray-400); font-size: 12px; }
.imp-table-wrap { overflow-x: auto; max-height: 360px; overflow-y: auto; border: 1px solid var(--gray-200); border-radius: 8px; margin-bottom: 16px; }
.imp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.imp-table th { background: var(--gray-50); padding: 8px 12px; text-align: left; font-weight: 600; color: var(--gray-700); position: sticky; top: 0; border-bottom: 1px solid var(--gray-200); }
.imp-table td { padding: 7px 12px; border-bottom: 1px solid var(--gray-100); color: var(--gray-700); }
.imp-table tr:last-child td { border-bottom: none; }
.imp-table .income  { color: var(--green-600); font-weight: 600; }
.imp-table .expense { color: var(--red-500,#ef4444); font-weight: 600; }
.imp-desc { max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.imp-cat-sel { font-size: 12px; padding: 3px 6px; border: 1px solid var(--gray-200); border-radius: 6px; background: var(--white); color: var(--gray-700); cursor: pointer; }
.imp-confirm-bar { display: flex; align-items: center; gap: 12px; padding-top: 4px; }
.imp-btn-primary { padding: 10px 22px; background: var(--green-600); color: #fff; font-weight: 700; font-size: 14px; border: none; border-radius: 8px; cursor: pointer; transition: background .15s; }
.imp-btn-primary:hover { background: var(--green-800); }
.imp-btn-ghost { padding: 10px 18px; background: none; border: 1.5px solid var(--gray-200); border-radius: 8px; font-size: 14px; color: var(--gray-600); cursor: pointer; }
.imp-btn-ghost:hover { border-color: var(--gray-400); }

/* ===== ONBOARDING MODAL ===== */
#onboardingOverlay {
  display: flex; /* shown/hidden via style attr */
}
.ob-modal {
  background: var(--white); border-radius: 20px; width: 560px; max-width: 96vw;
  max-height: 92vh; overflow-y: auto;
  box-shadow: 0 32px 100px rgba(0,0,0,.28);
  animation: obSlideIn .25s ease;
}
@keyframes obSlideIn {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)  scale(1); }
}
.ob-progress { height: 5px; background: var(--gray-100); }
.ob-progress-fill { background: var(--green-500); transition: width .4s ease; height: 5px; }
.ob-header { padding: 36px 40px 0; }
.ob-body   { padding: 24px 40px 32px; }
.ob-step-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .12em; color: var(--green-600); margin-bottom: 8px;
}
.ob-title { font-size: 22px; font-weight: 800; color: var(--gray-900); margin-bottom: 6px; line-height: 1.25; }
.ob-sub   { font-size: 14px; color: var(--gray-500); margin-bottom: 0; line-height: 1.55; }
.ob-crop-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 8px;
}
.ob-crop-chip {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 12px 6px; border: 2px solid var(--gray-200); border-radius: 10px;
  cursor: pointer; transition: all .15s; font-size: 12px; font-weight: 600;
  color: var(--gray-600); background: var(--white); text-align: center;
}
.ob-crop-chip:hover  { border-color: var(--green-400); background: var(--green-50); color: var(--green-700); }
.ob-crop-chip.selected { border-color: var(--green-500); background: var(--green-50); color: var(--green-800); box-shadow: inset 0 0 0 1px var(--green-500); }
.ob-crop-chip .ob-crop-emoji { font-size: 20px; }
.ob-contract-note {
  background: var(--green-50); border: 1px solid var(--green-200);
  border-radius: 10px; padding: 12px 14px; font-size: 13px; color: var(--green-800);
  line-height: 1.5; margin-top: 4px;
}
.ob-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 40px 24px; border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
}
.ob-btn-next {
  padding: 11px 26px; background: var(--green-700); color: white;
  font-weight: 700; font-size: 14px; border: none; border-radius: 10px;
  cursor: pointer; transition: background .15s;
}
.ob-btn-next:hover  { background: var(--green-900); }
.ob-btn-next:disabled { opacity: .6; cursor: not-allowed; }
.ob-btn-skip {
  font-size: 13px; color: var(--gray-400); background: none; border: none;
  cursor: pointer; padding: 8px 0;
}
.ob-btn-skip:hover { color: var(--gray-600); }
.ob-done-icon {
  font-size: 44px; margin: 0 auto 14px; display: block; text-align: center;
}
/* Step 4 action tiles */
.ob-action-grid { display: flex; flex-direction: column; gap: 10px; }
.ob-action-tile {
  display: grid; grid-template-columns: 40px 1fr 20px;
  align-items: center; gap: 12px;
  padding: 16px 18px; border: 2px solid var(--gray-200); border-radius: 12px;
  cursor: pointer; transition: all .15s; background: var(--white); text-align: left;
}
.ob-action-tile:hover { border-color: var(--green-400); background: var(--green-50); transform: translateX(2px); }
.ob-action-icon  { font-size: 22px; text-align: center; }
.ob-action-title { font-size: 14px; font-weight: 700; color: var(--gray-900); margin-bottom: 2px; }
.ob-action-desc  { font-size: 12px; color: var(--gray-500); line-height: 1.4; }
.ob-action-arrow { font-size: 18px; color: var(--gray-400); text-align: right; }

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
  /* Sidebar becomes a drawer */
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform .25s ease, width .25s ease;
    z-index: 300; width: 260px !important; min-width: 260px !important;
    box-shadow: 4px 0 20px rgba(0,0,0,.2);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  /* Dim overlay when drawer open */
  .sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.4); z-index: 299;
  }
  .sidebar-overlay.visible { display: block; }

  .main { width: 100%; }

  /* Topbar */
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-center { display: none; } /* hide search bar on mobile */
  .market-ticker { display: none; }
  .ai-cfo-btn span:not(svg) { display: none; } /* icon only */
  .ai-agent-btn span:not(:first-child):not(#aiAgentBadge) { display: none; }

  /* Pages */
  .page { padding: 16px 14px 60px; }

  /* Stats grid — 2 columns on mobile */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px 14px; }
  .stat-card-value { font-size: 20px; }

  /* Cards */
  .card-header { padding: 14px 16px; }
  .card-body   { padding: 14px 16px; }

  /* Settings grid */
  div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Page header */
  .page-header { flex-direction: column; gap: 10px; }
  .page-header-actions { width: 100%; }
  .page-header-actions .btn { flex: 1; justify-content: center; }

  /* Pricing card in settings */
  div[style*="grid-template-columns:1fr 1fr;gap:16px"] {
    display: flex !important; flex-direction: column !important;
  }

  /* Form rows */
  .form-row { flex-direction: column; gap: 0; }

  /* Tables — horizontal scroll */
  .table-wrap, .imp-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 580px; }

  /* Modals */
  .modal { width: 95vw; max-width: 95vw; margin: 0 auto; }
  .modal.modal-wide { max-width: 95vw; }

  /* AI panels full width on mobile */
  #aiAgentPanel, #aiCFOPanel { width: 100% !important; max-width: 100%; }

  /* Import overlay */
  #importOverlay > div { margin: 16px; padding: 20px; }
  #importStep1 > div { grid-template-columns: 1fr !important; }

  /* Topbar right — tighten */
  .topbar-right { gap: 6px; }
  #upgradeNavBtn { padding: 5px 10px !important; font-size: 11px !important; }

  /* Breadcrumb */
  .breadcrumb { font-size: 13px; }

  /* Onboarding modal */
  .ob-header { padding: 24px 22px 0; }
  .ob-body   { padding: 20px 22px 24px; }
  .ob-footer { padding: 14px 22px 20px; }
  .ob-crop-grid { grid-template-columns: repeat(3, 1fr); }
  .ob-action-tile { grid-template-columns: 32px 1fr 16px; padding: 12px 14px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .ob-title { font-size: 19px; }
  .ob-crop-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== BILLING PAGE ===== */

/* AR Summary Cards */
.bill-summary-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.bill-summary-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 20px 24px;
  border-left: 4px solid var(--green-500);
}
.bill-summary-paid   { border-left-color: #10b981; }
.bill-summary-overdue { border-left-color: #ef4444; }
.bill-summary-label  { font-size: 12px; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.bill-summary-value  { font-size: 26px; font-weight: 700; color: var(--gray-900); line-height: 1; }
.bill-summary-sub    { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

/* Billing section */
.bill-section {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  margin-bottom: 24px;
  overflow: hidden;
}
.bill-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
}
.bill-section-header h2 { font-size: 15px; font-weight: 600; color: var(--gray-900); margin: 0; }

.bill-table-wrap { overflow-x: auto; }
.bill-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.bill-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .4px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-100);
}
.bill-table td {
  padding: 12px 16px;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-50);
  vertical-align: middle;
}
.bill-table tbody tr:last-child td { border-bottom: none; }
.bill-table tbody tr:hover td { background: var(--gray-50); }

.bill-doc-num { font-weight: 600; color: var(--green-700); font-size: 12px; font-family: 'Courier New', monospace; }
.bill-empty { text-align: center; color: var(--gray-400); padding: 32px 16px !important; font-size: 13px; }

/* Status badges */
.bill-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .2px;
}
.bill-badge-draft     { background: #f3f4f6; color: #6b7280; }
.bill-badge-sent      { background: #eff6ff; color: #3b82f6; }
.bill-badge-paid      { background: #f0fdf4; color: #16a34a; }
.bill-badge-overdue   { background: #fef2f2; color: #ef4444; }
.bill-badge-cancelled { background: #fafafa; color: #9ca3af; text-decoration: line-through; }

/* Action buttons */
.bill-actions { display: flex; gap: 4px; justify-content: flex-end; }
.bill-act-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: transparent;
  color: var(--gray-500);
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
}
.bill-act-btn:hover { background: var(--gray-100); color: var(--gray-800); border-color: var(--gray-300); }
.bill-act-del:hover { background: #fef2f2; color: #ef4444; border-color: #fca5a5; }

/* ── Invoice Modal: line items ── */
.modal-xl { max-width: 820px; }

.inv-items-section {
  margin: 20px 0 0;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
}
.inv-items-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.inv-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--gray-100);
}
.inv-item-row:last-child { border-bottom: none; }
.inv-item-row .form-control { height: 36px; font-size: 13px; }
.inv-remove-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--gray-400);
  cursor: pointer;
}
.inv-remove-row:hover:not(:disabled) { background: #fef2f2; color: #ef4444; border-color: #fca5a5; }
.inv-remove-row:disabled { opacity: .3; cursor: default; }
.inv-add-row-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-top: 1px dashed var(--gray-200);
  color: var(--green-600);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}
.inv-add-row-btn:hover { background: var(--gray-50); }

/* Invoice totals block */
.inv-totals {
  display: flex;
  justify-content: flex-end;
  margin: 16px 0;
}
.inv-totals-inner {
  width: 280px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 12px 16px;
}
.inv-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 13px;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-100);
}
.inv-total-row:last-child { border-bottom: none; }
.inv-total-final { font-weight: 700; font-size: 15px; color: var(--gray-900); padding-top: 8px; }
.inv-tax-input { width: 80px !important; height: 28px !important; font-size: 12px !important; text-align: right; padding: 0 8px !important; }

/* ── BOS Modal: parties ── */
.bos-parties {
  display: grid;
  gap: 0;
  margin-bottom: 16px;
}
.bos-party {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 16px;
}
.bos-party-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--green-700);
  margin-bottom: 12px;
}
.bos-asset-section {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.input-prefix-wrap { position: relative; display: flex; align-items: center; }
.input-prefix { position: absolute; left: 10px; color: var(--gray-400); font-weight: 500; pointer-events: none; z-index: 1; }
.input-with-prefix { padding-left: 22px !important; }

/* Responsive billing */
@media (max-width: 768px) {
  .bill-summary-cards { grid-template-columns: 1fr; }
  .bill-table th:nth-child(4),
  .bill-table td:nth-child(4) { display: none; }
}

