:root {
  --nlb-green: #007A3D;
  --nlb-deep: #004F2D;
  --nlb-soft: #E7F4ED;
  --nlb-bg: #F8FAFC;
  --dark: #111827;
  --muted: #6B7280;
  --border: #E5E7EB;
  --warning: #F59E0B;
  --risk: #DC2626;
  --positive: #16A34A;
  --white: #FFFFFF;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.08);
  --radius: 10px;
  --radius-sm: 6px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

html { scroll-behavior: smooth; font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--nlb-bg);
  color: var(--dark);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Sticky Header ── */
.dashboard-header {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(135deg, var(--nlb-deep) 0%, var(--nlb-green) 100%);
  color: var(--white);
  padding: 14px 32px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 12px rgba(0,79,45,0.25);
}
.header-left { display: flex; align-items: center; gap: 16px; }
.header-logo {
  width: 42px; height: 42px; background: var(--white);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: var(--nlb-green); font-size: 16px;
}
.header-title { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; }
.header-subtitle { font-size: 0.8rem; opacity: 0.85; font-weight: 400; }
.header-right { display: flex; align-items: center; gap: 12px; }
.header-badge {
  background: rgba(255,255,255,0.18); padding: 5px 14px;
  border-radius: 20px; font-size: 0.78rem; font-weight: 500;
}

/* ── Nav Bar ── */
.nav-bar {
  position: sticky; top: 70px; z-index: 99;
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: 0 32px; display: flex; align-items: center;
  gap: 4px; overflow-x: auto; box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.nav-bar::-webkit-scrollbar { height: 0; }
.nav-link {
  padding: 12px 16px; font-size: 0.78rem; font-weight: 500;
  color: var(--muted); text-decoration: none; white-space: nowrap;
  border-bottom: 2px solid transparent; transition: all 0.2s;
}
.nav-link:hover { color: var(--nlb-green); }
.nav-link.active { color: var(--nlb-green); border-bottom-color: var(--nlb-green); font-weight: 600; }

/* ── Filter Bar ── */
.filter-bar {
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: 14px 32px; display: flex; align-items: center;
  gap: 14px; flex-wrap: wrap;
}
.filter-group { display: flex; align-items: center; gap: 6px; }
.filter-label { font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.filter-select, .filter-input {
  padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.82rem; font-family: var(--font); color: var(--dark);
  background: var(--white); outline: none; transition: border-color 0.2s;
}
.filter-select:focus, .filter-input:focus { border-color: var(--nlb-green); }
.filter-input { width: 200px; }
.filter-reset {
  padding: 6px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--white); font-size: 0.78rem; font-family: var(--font);
  color: var(--muted); cursor: pointer; transition: all 0.2s;
}
.filter-reset:hover { border-color: var(--risk); color: var(--risk); }

/* ── Layout ── */
.dashboard-container { max-width: 1440px; margin: 0 auto; padding: 24px 32px 64px; }
.section { margin-bottom: 40px; scroll-margin-top: 140px; }
.section-header { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.section-number {
  font-size: 0.7rem; font-weight: 700; color: var(--nlb-green);
  background: var(--nlb-soft); padding: 3px 8px; border-radius: 4px;
  font-family: var(--mono);
}
.section-title { font-size: 1.15rem; font-weight: 700; color: var(--dark); letter-spacing: -0.01em; }
.section-subtitle { font-size: 0.82rem; color: var(--muted); }

/* ── Grid ── */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }

/* ── Cards ── */
.card {
  background: var(--white); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 20px;
  box-shadow: var(--card-shadow); transition: box-shadow 0.25s;
}
.card:hover { box-shadow: var(--card-shadow-hover); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-title { font-size: 0.82rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.card-value { font-size: 2rem; font-weight: 800; color: var(--dark); letter-spacing: -0.02em; line-height: 1.1; }
.card-change { font-size: 0.78rem; font-weight: 500; margin-top: 4px; }
.card-change.positive { color: var(--positive); }
.card-change.negative { color: var(--risk); }
.card-change.neutral { color: var(--warning); }
.card-icon {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.card-icon.green { background: var(--nlb-soft); color: var(--nlb-green); }
.card-icon.amber { background: #FEF3C7; color: var(--warning); }
.card-icon.red { background: #FEE2E2; color: var(--risk); }
.card-icon.blue { background: #DBEAFE; color: #2563EB; }

/* ── KPI Cards (compact) ── */
.kpi-card { text-align: center; padding: 18px 14px; }
.kpi-card .card-value { font-size: 1.6rem; }
.kpi-card .card-title { margin-bottom: 8px; }

/* ── Stat Row ── */
.stat-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.stat-row:last-child { border-bottom: none; }
.stat-label { font-size: 0.82rem; color: var(--muted); }
.stat-value { font-size: 0.88rem; font-weight: 600; font-family: var(--mono); }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 12px;
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
}
.badge-strong { background: #DCFCE7; color: #166534; }
.badge-watch { background: #FEF3C7; color: #92400E; }
.badge-weak { background: #FEE2E2; color: #991B1B; }
.badge-size {
  padding: 2px 8px; border-radius: 4px;
  font-size: 0.68rem; font-weight: 700; font-family: var(--mono);
  background: var(--nlb-soft); color: var(--nlb-green);
}

/* ── Tables ── */
.table-container { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.data-table thead { background: var(--nlb-soft); position: sticky; top: 0; }
.data-table th {
  padding: 10px 14px; text-align: left; font-weight: 600;
  color: var(--nlb-deep); font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.04em; border-bottom: 2px solid var(--nlb-green);
  white-space: nowrap; cursor: pointer; user-select: none;
}
.data-table th:hover { background: rgba(0,122,61,0.08); }
.data-table th .sort-icon { font-size: 0.65rem; margin-left: 4px; opacity: 0.4; }
.data-table th.sorted .sort-icon { opacity: 1; }
.data-table td {
  padding: 9px 14px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody tr { transition: background 0.15s; }
.data-table tbody tr:hover { background: var(--nlb-soft); }
.data-table tbody tr.highlight { background: #FFFBEB; }
.data-table .num { text-align: right; font-family: var(--mono); font-size: 0.8rem; }
.data-table .branch-name { font-weight: 600; color: var(--dark); max-width: 200px; overflow: hidden; text-overflow: ellipsis; }

/* ── Bar (inline) ── */
.bar-container { width: 100%; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.bar-fill.green { background: var(--nlb-green); }
.bar-fill.amber { background: var(--warning); }
.bar-fill.red { background: var(--risk); }

/* ── Chart containers ── */
.chart-box { min-height: 300px; position: relative; }
.chart-box-sm { min-height: 220px; }
.chart-box-lg { min-height: 380px; }

/* ── Insight Box ── */
.insight-box {
  background: linear-gradient(135deg, var(--nlb-soft) 0%, #F0FFF4 100%);
  border-left: 3px solid var(--nlb-green);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 18px; margin-top: 12px;
}
.insight-box .insight-title { font-size: 0.72rem; font-weight: 700; color: var(--nlb-green); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.insight-box p { font-size: 0.82rem; color: var(--dark); line-height: 1.55; }

/* ── Opportunity Matrix ── */
.matrix-card {
  border-radius: var(--radius); padding: 18px; border: 1px solid var(--border);
  background: var(--white);
}
.matrix-card.growth { border-left: 4px solid var(--positive); }
.matrix-card.recovery { border-left: 4px solid var(--risk); }
.matrix-card.digital { border-left: 4px solid #2563EB; }
.matrix-card.lending { border-left: 4px solid var(--warning); }
.matrix-card.cost { border-left: 4px solid #8B5CF6; }
.matrix-tag {
  display: inline-block; padding: 2px 10px; border-radius: 4px;
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; margin-bottom: 8px;
}
.matrix-tag.growth { background: #DCFCE7; color: #166534; }
.matrix-tag.recovery { background: #FEE2E2; color: #991B1B; }
.matrix-tag.digital { background: #DBEAFE; color: #1E40AF; }
.matrix-tag.lending { background: #FEF3C7; color: #92400E; }
.matrix-tag.cost { background: #EDE9FE; color: #5B21B6; }
.matrix-branches { font-size: 0.8rem; color: var(--muted); line-height: 1.6; }

/* ── Accordion ── */
.accordion { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.accordion-item { border-bottom: 1px solid var(--border); }
.accordion-item:last-child { border-bottom: none; }
.accordion-trigger {
  width: 100%; padding: 14px 18px; background: var(--white);
  border: none; cursor: pointer; display: flex;
  align-items: center; justify-content: space-between;
  font-family: var(--font); font-size: 0.85rem; font-weight: 600; color: var(--dark);
  transition: background 0.15s;
}
.accordion-trigger:hover { background: var(--nlb-soft); }
.accordion-trigger .icon { transition: transform 0.25s; font-size: 0.75rem; }
.accordion-trigger.open .icon { transform: rotate(180deg); }
.accordion-content {
  max-height: 0; overflow: hidden; transition: max-height 0.35s ease;
  background: #FAFBFC;
}
.accordion-content.open { max-height: 800px; }
.accordion-inner { padding: 14px 18px; font-size: 0.82rem; color: var(--muted); line-height: 1.6; }
.accordion-inner code { font-family: var(--mono); background: var(--nlb-soft); padding: 1px 6px; border-radius: 3px; font-size: 0.78rem; color: var(--nlb-deep); }

/* ── Branch Detail Modal ── */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.45); backdrop-filter: blur(4px);
  align-items: flex-start; justify-content: center; padding: 40px 20px;
  overflow-y: auto;
}
.modal-overlay.active { display: flex; }
.modal-content {
  background: var(--white); border-radius: 14px;
  width: 100%; max-width: 960px; padding: 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15); position: relative;
}
.modal-close {
  position: absolute; top: 16px; right: 16px;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--white);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: var(--muted); transition: all 0.2s;
}
.modal-close:hover { background: #FEE2E2; color: var(--risk); border-color: var(--risk); }
.modal-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.modal-subtitle { font-size: 0.82rem; color: var(--muted); margin-bottom: 20px; }
.modal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.modal-stat { text-align: center; padding: 12px; background: var(--nlb-bg); border-radius: var(--radius-sm); }
.modal-stat .val { font-size: 1.2rem; font-weight: 700; font-family: var(--mono); }
.modal-stat .lbl { font-size: 0.7rem; color: var(--muted); margin-top: 2px; }

/* ── Reshuffle ── */
.move-card {
  padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--white); margin-bottom: 10px; transition: box-shadow 0.2s;
}
.move-card:hover { box-shadow: var(--card-shadow-hover); }
.move-card .move-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.move-card .move-branch { font-weight: 600; font-size: 0.85rem; }
.move-card .move-detail { font-size: 0.78rem; color: var(--muted); }
.move-card .move-arrow { color: var(--nlb-green); font-weight: 700; margin: 0 6px; }
.priority-high { border-left: 3px solid var(--risk); }
.priority-medium { border-left: 3px solid var(--warning); }
.priority-low { border-left: 3px solid var(--positive); }

/* ── Footer ── */
.dashboard-footer {
  text-align: center; padding: 24px 32px; border-top: 1px solid var(--border);
  background: var(--white); color: var(--muted); font-size: 0.75rem;
}

/* ── Tooltip ── */
.tooltip {
  position: relative; cursor: help;
}
.tooltip::after {
  content: attr(data-tip); position: absolute; bottom: 100%; left: 50%;
  transform: translateX(-50%); padding: 6px 10px; background: var(--dark);
  color: var(--white); border-radius: 4px; font-size: 0.7rem;
  white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity 0.2s;
  z-index: 10;
}
.tooltip:hover::after { opacity: 1; }

/* ── Tabs ── */
.tab-bar { display: flex; gap: 2px; margin-bottom: 16px; background: #F1F5F9; border-radius: var(--radius-sm); padding: 3px; }
.tab-btn {
  padding: 8px 16px; border: none; background: transparent;
  border-radius: 4px; font-family: var(--font); font-size: 0.78rem;
  font-weight: 500; color: var(--muted); cursor: pointer; transition: all 0.2s;
}
.tab-btn.active { background: var(--white); color: var(--nlb-green); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

/* ── Loading ── */
.loading-skeleton {
  background: linear-gradient(90deg, #F1F5F9 25%, #E2E8F0 50%, #F1F5F9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Print ── */
@media print {
  .dashboard-header, .nav-bar, .filter-bar, .modal-overlay { display: none !important; }
  .card { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
  body { background: white; }
}

/* ── Responsive ── */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .span-3 { grid-column: span 2; }
  .span-4 { grid-column: span 2; }
}
@media (max-width: 768px) {
  .dashboard-header { padding: 12px 16px; }
  .nav-bar { padding: 0 12px; }
  .filter-bar { padding: 10px 16px; }
  .dashboard-container { padding: 16px; }
  .grid-4, .grid-3, .grid-2, .grid-1-2, .grid-2-1 { grid-template-columns: 1fr; }
  .span-2, .span-3, .span-4 { grid-column: span 1; }
  .card { padding: 16px; }
  .card-value { font-size: 1.5rem; }
  .modal-content { padding: 20px; }
  .modal-grid { grid-template-columns: repeat(2, 1fr); }
  .header-subtitle { display: none; }
}
@media (max-width: 480px) {
  html { font-size: 14px; }
  .header-badge { display: none; }
  .filter-input { width: 140px; }
  .modal-grid { grid-template-columns: 1fr; }
}
