/* ==========================================================================
   智汇财枢 FIN-TREASURY PRO — Executive Fintech Design System
   ========================================================================== */

:root {
  --bg-canvas: #F3F6FB;
  --surface: #FFFFFF;
  --surface-elevated: #FFFFFF;
  --surface-muted: #F1F5F9;
  --surface-hover: #F8FAFC;

  --sidebar-bg: #0E172A;
  --sidebar-surface: rgba(255, 255, 255, 0.06);
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-text: #CBD5E1;
  --sidebar-text-muted: #64748B;
  --sidebar-active-bg: linear-gradient(135deg, #4F46E5 0%, #3B82F6 100%);

  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #64748B;

  --border: #E2E8F0;
  --border-strong: #CBD5E1;

  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-soft: rgba(79, 70, 229, 0.1);

  --info: #0284C7;
  --info-soft: rgba(2, 132, 199, 0.11);

  --success: #059669;
  --success-soft: rgba(5, 150, 105, 0.11);

  --warning: #D97706;
  --warning-dark: #B45309;
  --warning-soft: rgba(217, 119, 6, 0.12);

  --danger: #E11D48;
  --danger-soft: rgba(225, 29, 72, 0.11);

  --purple: #7C3AED;
  --purple-soft: rgba(124, 58, 237, 0.11);

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 24px 48px rgba(15, 23, 42, 0.16);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --sidebar-w: 262px;
  --topbar-h: 72px;
  --font-sans: "PingFang SC", "Microsoft YaHei UI", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", "Consolas", ui-monospace, monospace;
}

[data-theme="dark"] {
  --bg-canvas: #090E1A;
  --surface: #111827;
  --surface-elevated: #172033;
  --surface-muted: #1E293B;
  --surface-hover: #1A2438;

  --sidebar-bg: #070B14;
  --sidebar-surface: rgba(255, 255, 255, 0.05);
  --sidebar-border: rgba(255, 255, 255, 0.07);

  --text-primary: #F1F5F9;
  --text-secondary: #CBD5E1;
  --text-muted: #94A3B8;

  --border: #1F2D45;
  --border-strong: #334155;

  --primary: #6366F1;
  --primary-hover: #818CF8;
  --primary-soft: rgba(99, 102, 241, 0.18);

  --info: #38BDF8;
  --info-soft: rgba(56, 189, 248, 0.15);

  --success: #10B981;
  --success-soft: rgba(16, 185, 129, 0.16);

  --warning: #F59E0B;
  --warning-dark: #FBBF24;
  --warning-soft: rgba(245, 158, 11, 0.16);

  --danger: #FB7185;
  --danger-soft: rgba(251, 113, 133, 0.16);

  --purple: #A78BFA;
  --purple-soft: rgba(167, 139, 250, 0.16);

  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-canvas);
  -webkit-font-smoothing: antialiased;
}

.tabular {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   App Shell Layout
   ========================================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  border-right: 1px solid var(--sidebar-border);
  transition: transform 0.25s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 10px 18px;
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: 14px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
}

.brand-logo svg {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.4px;
  color: #FFFFFF;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.6px;
  color: #60A5FA;
  margin-top: 2px;
}

.sidebar-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--sidebar-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 10px 12px 6px;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
}

.nav-item:hover {
  background: var(--sidebar-surface);
  color: #FFFFFF;
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.35);
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
}

.nav-label {
  flex: 1;
}

.nav-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(52, 211, 153, 0.18);
  color: #34D399;
}

.nav-item.active .nav-pill {
  background: rgba(255, 255, 255, 0.22);
  color: #FFFFFF;
}

.nav-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 99px;
  background: #F59E0B;
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--sidebar-border);
}

.compliance-card {
  background: linear-gradient(145deg, rgba(79, 70, 229, 0.18), rgba(16, 185, 129, 0.08));
  border: 1px solid rgba(99, 102, 241, 0.28);
  border-radius: 12px;
  padding: 11px 12px;
}

.compliance-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #E2E8F0;
  margin-bottom: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10B981;
  display: inline-block;
}

.status-dot.pulse {
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.65); }
  70% { box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.compliance-rules {
  font-size: 11px;
  color: #94A3B8;
  line-height: 1.65;
}

.sidebar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-icon-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--sidebar-border);
  background: var(--sidebar-surface);
  color: #CBD5E1;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.16s ease;
}

.btn-icon-text:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
}

.btn-icon-text svg {
  width: 14px;
  height: 14px;
}

/* Main Area */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.mobile-menu-btn {
  display: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: 9px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.mobile-menu-btn svg {
  width: 18px;
  height: 18px;
}

.page-title {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.2px;
  color: var(--text-primary);
}

.page-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.rule-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 99px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
  transition: transform 0.15s ease;
}

.rule-pill:hover {
  transform: translateY(-1px);
}

.rule-pill.secondary {
  background: var(--success-soft);
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 24%, transparent);
}

.pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.view-container {
  padding: 24px 28px 40px;
  max-width: 1520px;
  width: 100%;
  margin: 0 auto;
  animation: fadeSlideIn 0.22s ease;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Buttons & Inputs
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
  border-radius: 8px;
}

.btn-sm svg {
  width: 14px;
  height: 14px;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 11.5px;
  border-radius: 7px;
}

.btn-primary {
  background: linear-gradient(135deg, #4F46E5 0%, #3B82F6 100%);
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.28);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 7px 18px rgba(79, 70, 229, 0.36);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-success {
  background: linear-gradient(135deg, #059669 0%, #10B981 100%);
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}

.btn-success:hover {
  transform: translateY(-1px);
}

.btn-outline {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-outline:hover {
  background: var(--surface-muted);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--surface-muted);
  color: var(--text-primary);
}

.btn-danger-soft {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-danger-soft:hover {
  background: var(--danger);
  color: #FFFFFF;
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13.5px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.input-money {
  font-family: var(--font-mono);
  font-weight: 700;
  text-align: right;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ==========================================================================
   Cards, Grids & KPI Bento
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title svg {
  width: 17px;
  height: 17px;
  color: var(--primary);
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.card-body {
  padding: 20px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3.5px;
  background: var(--kpi-accent, var(--primary));
}

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.kpi-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-icon-box {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--kpi-bg, var(--primary-soft));
  color: var(--kpi-accent, var(--primary));
}

.kpi-icon-box svg {
  width: 17px;
  height: 17px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  line-height: 1.2;
}

.kpi-meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.grid-transfer {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.98fr);
  gap: 20px;
  align-items: start;
}

.mb-18 { margin-bottom: 18px; }
.mt-16 { margin-top: 16px; }
.mt-12 { margin-top: 12px; }

/* ==========================================================================
   Badges, Tags & Progress Bars
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.4;
}

.badge-success { background: var(--success-soft); color: var(--success); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-warning { background: var(--warning-soft); color: var(--warning-dark); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-muted { background: var(--surface-muted); color: var(--text-secondary); }

.company-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
}

.company-letter {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: #FFFFFF;
  flex-shrink: 0;
}

.company-letter.lg {
  width: 34px;
  height: 34px;
  font-size: 16px;
  border-radius: 10px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-muted);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.tag-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--surface-muted);
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--primary);
  transition: width 0.35s ease;
}

.progress-fill.projected {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0.35;
}

/* ==========================================================================
   SVG Topology & Charts
   ========================================================================== */
.topology-wrap {
  padding: 14px 18px 18px;
  background: radial-gradient(circle at 20% 20%, var(--primary-soft), transparent 50%),
              radial-gradient(circle at 80% 80%, var(--success-soft), transparent 45%),
              var(--surface);
  overflow-x: auto;
}

.topology-svg {
  display: block;
  min-width: 720px;
}

.topo-node rect:first-child {
  transition: stroke 0.2s ease, transform 0.2s ease;
}

.topo-node:hover rect:first-child {
  stroke: var(--primary);
  stroke-width: 2;
}

.flow-pulse {
  animation: flowDash 1.6s linear infinite;
}

@keyframes flowDash {
  from { stroke-dashoffset: 20; }
  to { stroke-dashoffset: 0; }
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--text-secondary);
}

.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.donut-legend {
  flex: 1;
  min-width: 185px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.donut-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-name {
  flex: 1;
  color: var(--text-primary);
  font-weight: 500;
}

.legend-pct {
  font-size: 11.5px;
  color: var(--text-muted);
  width: 44px;
  text-align: right;
}

.legend-val {
  font-weight: 700;
  color: var(--text-primary);
  min-width: 76px;
  text-align: right;
}

.empty-chart {
  padding: 36px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-chart-ring {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 12px solid var(--surface-muted);
  margin: 0 auto 12px;
}

/* ==========================================================================
   Smart Transfer Workbench
   ========================================================================== */
.direction-stage {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: end;
  background: var(--surface-muted);
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.direction-arrow-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-bottom: 6px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
}

.direction-arrow-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  margin-bottom: 3px;
}

.direction-arrow-circle svg {
  width: 16px;
  height: 16px;
}

.validation-banner {
  margin-top: 10px;
  padding: 10px 13px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.validation-banner svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.validation-banner.ok {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid color-mix(in srgb, var(--success) 25%, transparent);
}

.validation-banner.error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
}

.line-items-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.line-item-row {
  display: grid;
  grid-template-columns: 148px 140px 1fr 34px;
  gap: 8px;
  align-items: center;
}

.fixed-value-box {
  background: linear-gradient(135deg, var(--primary-soft), var(--success-soft));
  border: 1.5px solid color-mix(in srgb, var(--primary) 30%, transparent);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.fixed-value-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.fixed-value-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-btn {
  padding: 5px 10px;
  border-radius: 99px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.gap-assistant-box {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
}

.gap-assistant-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.gap-assistant-title svg {
  width: 14px;
  height: 14px;
  color: var(--primary);
}

.options-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

/* Mechanism Preview Panel */
.mechanism-hero {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.mechanism-hero.success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.mechanism-hero.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.mechanism-hero.purple { background: var(--purple-soft); border-color: color-mix(in srgb, var(--purple) 35%, transparent); }
.mechanism-hero.warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.mechanism-hero.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }

.mechanism-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.mechanism-reasons {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.summary-tile {
  background: var(--surface-muted);
  border-radius: 10px;
  padding: 11px 12px;
}

.summary-tile-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.summary-tile-val {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 2px;
}

.bank-quota-card {
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  background: var(--surface);
}

.bank-quota-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 6px;
}

.bank-quota-sub {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 5px;
}

.impact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.impact-card {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 12px;
}

.impact-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 3px 0;
}

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table.fin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.fin-table th {
  text-align: left;
  padding: 11px 14px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.fin-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-primary);
}

.fin-table tbody tr:hover {
  background: var(--surface-hover);
}

.fin-table .num,
.fin-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning-dark) !important; }
.text-primary { color: var(--primary) !important; }
.text-muted { color: var(--text-muted) !important; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }

/* ==========================================================================
   Tabs & Pills
   ========================================================================== */
.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.tab-btn {
  padding: 8px 15px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.16s ease;
}

.tab-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.tab-btn.active {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.tag-bar-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tag-bar-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.tag-bar-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

/* ==========================================================================
   Filters, Switch, Modals & Toasts
   ========================================================================== */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.filter-bar .input,
.filter-bar .select {
  width: auto;
  min-width: 150px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}

.switch-row:last-child {
  border-bottom: none;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border-strong);
  border-radius: 99px;
  transition: 0.2s;
}

.slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #FFFFFF;
  border-radius: 50%;
  transition: 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.switch input:checked + .slider {
  background: var(--primary);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-backdrop.open {
  display: flex;
}

.modal-dialog {
  width: 100%;
  max-width: 680px;
  max-height: 88vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalPop 0.2s ease;
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.modal-close {
  border: none;
  background: var(--surface-muted);
  color: var(--text-secondary);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Toast */
.toast-container {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--sidebar-bg);
  color: #FFFFFF;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 4px solid var(--primary);
  animation: toastIn 0.22s ease;
  max-width: 380px;
}

.toast.success { border-left-color: #10B981; }
.toast.error { border-left-color: #F43F5E; }
.toast.warning { border-left-color: #F59E0B; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.empty-state {
  text-align: center;
  padding: 42px 20px;
  color: var(--text-muted);
}

.empty-state-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* Voucher Box */
.voucher-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: var(--surface-muted);
  padding: 14px;
  border-radius: 12px;
  margin-bottom: 16px;
}

.voucher-field-label {
  font-size: 11px;
  color: var(--text-muted);
}

.voucher-field-val {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1240px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-transfer { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .mobile-menu-btn {
    display: inline-flex;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .rule-pill {
    display: none;
  }
  .view-container {
    padding: 18px 16px 32px;
  }
  .topbar {
    padding: 0 16px;
  }
  .line-item-row {
    grid-template-columns: 1fr 1fr;
  }
  .options-bar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .direction-stage { grid-template-columns: 1fr; }
  .impact-grid { grid-template-columns: 1fr; }
}
