/* =========================================
   법인카드 모니터링 시스템 - Design Tokens
   ========================================= */

:root {
  /* Brand Colors */
  --color-primary: #3417CE;
  --color-primary-hover: #2A12A3;
  --color-primary-active: #23108A;
  --color-secondary: #8E94F2;
  --color-background: #F8F9FE;
  --color-text-dark: #121212;
  --color-neutral-1: #E5E5E5;
  --color-neutral-2: #757575;
  --color-highlight: #D1D5DB;
  --color-surface: #F4F4F4;
  --color-white: #FFFFFF;

  /* Semantic Colors (파생) */
  --color-danger: #DC2626;
  --color-danger-bg: #FEE2E2;
  --color-warning: #D97706;
  --color-warning-bg: #FEF3C7;
  --color-success: #16A34A;
  --color-success-bg: #DCFCE7;
  --color-info: #2563EB;
  --color-info-bg: #DBEAFE;

  /* Focus Ring */
  --focus-ring: 0 0 0 3px rgba(52, 23, 206, 0.3);

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgba(18, 18, 18, 0.04);
  --shadow-md: 0 2px 8px rgba(18, 18, 18, 0.06);

  /* Layout */
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 72px;
  --header-h: 64px;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: 'Pretendard', 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--color-text-dark);
  background-color: var(--color-background);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* 영문/숫자는 Montserrat 적용 - :lang 및 숫자 전용 클래스 */
.num, time, .stat-value, .metric-value {
  font-family: 'Montserrat', 'Pretendard', sans-serif;
  font-variant-numeric: tabular-nums;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-hover); text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }

h1, h2, h3, h4 { margin: 0; color: var(--color-text-dark); font-weight: 700; }
h1 { font-size: 22px; letter-spacing: -0.2px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }

/* =========================================
   App Layout
   ========================================= */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.25s ease;
}
.app.sidebar-collapsed {
  grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}

/* Sidebar */
.sidebar {
  background: var(--color-white);
  border-right: 1px solid var(--color-neutral-1);
  padding: var(--sp-5) 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.25s ease;
}

/* ===== Collapsed state ===== */
.app.sidebar-collapsed .sidebar .brand {
  padding-left: 0;
  padding-right: 0;
  justify-content: center;
}
.app.sidebar-collapsed .sidebar .brand-text,
.app.sidebar-collapsed .sidebar .nav-section-title,
.app.sidebar-collapsed .sidebar .nav-label,
.app.sidebar-collapsed .sidebar .badge-count,
.app.sidebar-collapsed .sidebar .batch-status {
  display: none;
}
.app.sidebar-collapsed .sidebar .nav-section {
  padding: var(--sp-2) var(--sp-2);
}
.app.sidebar-collapsed .sidebar .nav-item {
  justify-content: center;
  padding: 10px 0;
  position: relative;
}
.app.sidebar-collapsed .sidebar .nav-item .fa-solid,
.app.sidebar-collapsed .sidebar .nav-item .fa-regular {
  font-size: 16px; width: auto;
}
/* Collapsed: dot indicator for items with badge */
.app.sidebar-collapsed .sidebar .nav-item.has-badge::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 14px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-danger);
  border: 2px solid var(--color-white);
}
/* Collapsed: tooltip on hover */
.app.sidebar-collapsed .sidebar .nav-item {
  overflow: visible;
}
.app.sidebar-collapsed .sidebar .nav-item::before {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--color-text-dark);
  color: var(--color-white);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 50;
  box-shadow: var(--shadow-md);
}
.app.sidebar-collapsed .sidebar .nav-item:hover::before {
  opacity: 1;
}

/* Hamburger / toggle button in topbar */
.topbar .sidebar-toggle {
  background: transparent;
  border: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-dark);
  font-size: 16px;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.topbar .sidebar-toggle:hover {
  background: var(--color-surface);
}
.topbar .sidebar-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--color-neutral-1);
  margin-bottom: var(--sp-4);
}
.sidebar .brand-logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--color-primary);
  color: var(--color-white);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.sidebar .brand-name {
  font-weight: 700; font-size: 14px; line-height: 1.25;
}
.sidebar .brand-sub {
  font-size: 11px; color: var(--color-neutral-2); margin-top: 2px;
}
.sidebar .nav-section {
  padding: var(--sp-3) var(--sp-4);
}
.sidebar .nav-section-title {
  font-size: 11px; color: var(--color-neutral-2);
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 0 var(--sp-2) var(--sp-2);
  font-weight: 600;
}
.sidebar .nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3);
  border-radius: var(--r-sm);
  color: var(--color-text-dark);
  font-size: 13px; font-weight: 500;
  text-decoration: none;
  margin-bottom: 2px;
  transition: all 0.15s ease;
}
.sidebar .nav-item:hover {
  background: var(--color-surface);
  text-decoration: none;
}
.sidebar .nav-item.active {
  background: rgba(52, 23, 206, 0.08);
  color: var(--color-primary);
  font-weight: 600;
}
.sidebar .nav-item .fa-solid,
.sidebar .nav-item .fa-regular {
  width: 16px; text-align: center; font-size: 14px;
}
.sidebar .nav-item .badge-count {
  margin-left: auto;
  background: var(--color-danger);
  color: var(--color-white);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* Main content */
.main {
  display: flex; flex-direction: column;
  min-width: 0;
}

/* Top header */
.topbar {
  height: var(--header-h);
  background: var(--color-white);
  border-bottom: 1px solid var(--color-neutral-1);
  display: flex; align-items: center;
  padding: 0 var(--sp-6) 0 var(--sp-4);
  gap: var(--sp-3);
  position: sticky; top: 0; z-index: 10;
}
.topbar .page-title {
  font-size: 17px; font-weight: 700;
}
.topbar .crumb {
  color: var(--color-neutral-2); font-size: 12px; margin-left: var(--sp-3);
}
.topbar .spacer { flex: 1; }
.topbar .search {
  position: relative;
}
.topbar .search input {
  border: 1px solid var(--color-highlight);
  border-radius: var(--r-md);
  padding: 8px 12px 8px 34px;
  width: 260px;
  font-size: 13px;
  background: var(--color-background);
  outline: none;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.topbar .search input:focus {
  border-color: var(--color-primary);
  box-shadow: var(--focus-ring);
  background: var(--color-white);
}
.topbar .search .fa-solid {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--color-neutral-2); font-size: 12px;
}
.topbar .icon-btn {
  background: transparent; border: 0;
  width: 36px; height: 36px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-dark); position: relative;
}
.topbar .icon-btn:hover { background: var(--color-surface); }
.topbar .icon-btn .dot {
  position: absolute; top: 8px; right: 8px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--color-danger);
  border: 2px solid var(--color-white);
}
.topbar .user-chip {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 4px 10px 4px 4px; border-radius: 999px;
  background: var(--color-surface);
}
.topbar .user-chip .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--color-primary); color: var(--color-white);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.topbar .user-chip .user-name { font-size: 13px; font-weight: 600; }
.topbar .user-chip .user-role { font-size: 11px; color: var(--color-neutral-2); }

/* Page content */
.page {
  padding: var(--sp-8);
  max-width: 1440px;
  width: 100%;
}
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: var(--sp-6);
  gap: var(--sp-4); flex-wrap: wrap;
}
.page-header .subtitle {
  font-size: 13px; color: var(--color-neutral-2); margin-top: 4px;
}

/* =========================================
   Buttons
   ========================================= */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600;
  border: 1px solid transparent;
  background: var(--color-white);
  color: var(--color-text-dark);
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn-primary {
  background: var(--color-primary); color: var(--color-white);
}
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-primary:active { background: var(--color-primary-active); }
.btn-secondary {
  background: var(--color-white); color: var(--color-primary);
  border-color: var(--color-highlight);
}
.btn-secondary:hover {
  background: var(--color-surface);
  border-color: var(--color-primary);
}
.btn-ghost {
  background: transparent; color: var(--color-text-dark);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--color-surface); }
.btn-danger {
  background: var(--color-danger); color: var(--color-white);
}
.btn-danger:hover { filter: brightness(0.9); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled, .btn.is-disabled { opacity: 0.4; cursor: not-allowed; }

/* =========================================
   Cards
   ========================================= */
.card {
  background: var(--color-white);
  border: 1px solid var(--color-neutral-1);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--color-neutral-1);
  gap: var(--sp-3);
}
.card-header h2 { font-size: 15px; }
.card-header .card-sub { font-size: 12px; color: var(--color-neutral-2); }
.card-body { padding: var(--sp-6); }
.card-body.no-pad { padding: 0; }

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}
.stats-grid.cols-5 {
  grid-template-columns: repeat(5, 1fr);
}
.stat-card {
  background: var(--color-white);
  border: 1px solid var(--color-neutral-1);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  position: relative;
  overflow: hidden;
}
.stat-card .stat-label {
  font-size: 12px; color: var(--color-neutral-2);
  font-weight: 500; margin-bottom: var(--sp-2);
  display: flex; align-items: center; gap: 6px;
}
.stat-card .stat-value {
  font-size: 26px; font-weight: 700; line-height: 1.1;
  color: var(--color-text-dark);
}
.stat-card .stat-unit {
  font-size: 14px; color: var(--color-neutral-2); font-weight: 500;
  margin-left: 2px;
}
.stat-card .stat-delta {
  margin-top: var(--sp-3);
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
}
.stat-delta.up { background: var(--color-danger-bg); color: var(--color-danger); }
.stat-delta.down { background: var(--color-success-bg); color: var(--color-success); }
.stat-delta.neutral { background: var(--color-surface); color: var(--color-neutral-2); }
.stat-card .stat-icon {
  position: absolute; top: var(--sp-5); right: var(--sp-5);
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(52, 23, 206, 0.08);
  color: var(--color-primary);
  font-size: 15px;
}
.stat-card.is-danger .stat-icon { background: var(--color-danger-bg); color: var(--color-danger); }
.stat-card.is-warning .stat-icon { background: var(--color-warning-bg); color: var(--color-warning); }
.stat-card.is-success .stat-icon { background: var(--color-success-bg); color: var(--color-success); }

/* =========================================
   Filters bar
   ========================================= */
.filters {
  display: flex; flex-wrap: wrap; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  background: var(--color-white);
  border: 1px solid var(--color-neutral-1);
  border-radius: var(--r-lg);
  margin-bottom: var(--sp-4);
  align-items: center;
}
.filter {
  display: flex; flex-direction: column; gap: 4px;
}
.filter-label {
  font-size: 11px; color: var(--color-neutral-2); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.form-input, .form-select {
  border: 1px solid var(--color-highlight);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--color-text-dark);
  background: var(--color-white);
  outline: none;
  min-width: 140px;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.form-input:focus, .form-select:focus {
  border-color: var(--color-primary);
  box-shadow: var(--focus-ring);
}
.form-input::placeholder { color: var(--color-neutral-2); }

.filters .spacer { flex: 1; }

/* Chip filters */
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px;
  background: var(--color-surface);
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px; font-weight: 500;
  color: var(--color-text-dark);
  cursor: pointer; transition: all 0.15s ease;
}
.chip:hover { background: var(--color-neutral-1); }
.chip.active {
  background: rgba(52, 23, 206, 0.1);
  color: var(--color-primary);
  border-color: var(--color-secondary);
  font-weight: 600;
}
.chip .count {
  background: var(--color-white);
  padding: 0 6px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
}
.chip.active .count { background: var(--color-primary); color: var(--color-white); }

/* =========================================
   Tables
   ========================================= */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--r-lg);
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--color-white);
}
table.data-table thead th {
  text-align: left;
  padding: 12px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-neutral-2);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-neutral-1);
  white-space: nowrap;
}
table.data-table tbody td {
  padding: 14px;
  border-bottom: 1px solid var(--color-neutral-1);
  vertical-align: middle;
}
table.data-table tbody tr:hover { background: var(--color-background); }
table.data-table tbody tr:last-child td { border-bottom: 0; }
table.data-table .num { text-align: right; }
table.data-table .cell-amount { font-weight: 600; }
table.data-table .cell-name {
  display: flex; align-items: center; gap: 10px;
}
.cell-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--color-secondary);
  color: var(--color-white);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}
.cell-sub { font-size: 11px; color: var(--color-neutral-2); margin-top: 1px; }

/* Status / Flag badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  font-size: 11px; font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
}
.badge i { font-size: 10px; }
.badge-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-info { background: var(--color-info-bg); color: var(--color-info); }
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-neutral { background: var(--color-surface); color: var(--color-neutral-2); }
.badge-primary { background: rgba(52, 23, 206, 0.1); color: var(--color-primary); }

.flag-stack { display: flex; flex-wrap: wrap; gap: 4px; }

/* Pagination */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--color-neutral-1);
  background: var(--color-white);
  border-bottom-left-radius: var(--r-lg);
  border-bottom-right-radius: var(--r-lg);
  font-size: 12px; color: var(--color-neutral-2);
}
.pagination .pages { display: flex; gap: 4px; }
.pagination .page-btn {
  min-width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--color-text-dark);
  font-size: 12px; font-weight: 500;
  padding: 0 8px;
}
.pagination .page-btn:hover { background: var(--color-surface); }
.pagination .page-btn.active {
  background: var(--color-primary); color: var(--color-white); font-weight: 700;
}

/* =========================================
   Charts / Grids
   ========================================= */
.grid-2 {
  display: grid; grid-template-columns: 2fr 1fr; gap: var(--sp-4);
}
.grid-3 {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4);
}
.grid-12 {
  display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--sp-4);
}
.col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

.chart-box { position: relative; width: 100%; }
.chart-box.h-260 { height: 260px; }
.chart-box.h-300 { height: 300px; }
.chart-box.h-360 { height: 360px; }

/* Legend bar */
.legend {
  display: flex; flex-wrap: wrap; gap: var(--sp-3);
  font-size: 12px; color: var(--color-neutral-2);
}
.legend-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  margin-right: 5px; vertical-align: middle;
}

/* Top list */
.top-list { display: flex; flex-direction: column; }
.top-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 10px 0;
  border-bottom: 1px solid var(--color-neutral-1);
}
.top-item:last-child { border-bottom: 0; }
.top-rank {
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--color-surface); color: var(--color-neutral-2);
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.top-rank.r1 { background: var(--color-primary); color: var(--color-white); }
.top-rank.r2 { background: var(--color-secondary); color: var(--color-white); }
.top-rank.r3 { background: #b8bcf5; color: var(--color-white); }
.top-item .top-name { font-size: 13px; font-weight: 600; flex: 1; }
.top-item .top-meta { font-size: 11px; color: var(--color-neutral-2); }
.top-item .top-value { font-size: 13px; font-weight: 700; font-family: 'Montserrat', sans-serif; }

/* =========================================
   Drawer / Modal
   ========================================= */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(18, 18, 18, 0.35);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 100;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0;
  width: 480px; max-width: 95vw; height: 100vh;
  background: var(--color-white);
  border-left: 1px solid var(--color-neutral-1);
  box-shadow: -8px 0 24px rgba(18,18,18,0.08);
  z-index: 101;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--color-neutral-1);
}
.drawer-body {
  flex: 1; overflow-y: auto; padding: var(--sp-6);
}
.drawer-footer {
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--color-neutral-1);
  display: flex; justify-content: flex-end; gap: var(--sp-2);
}
.close-btn {
  background: transparent; border: 0; width: 32px; height: 32px;
  border-radius: var(--r-sm); color: var(--color-neutral-2);
  display: inline-flex; align-items: center; justify-content: center;
}
.close-btn:hover { background: var(--color-surface); color: var(--color-text-dark); }

/* =========================================
   Modal (center)
   ========================================= */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(18, 18, 18, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: var(--sp-4);
}
.modal.open {
  opacity: 1;
  pointer-events: auto;
}
.modal-dialog {
  background: var(--color-white);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 48px rgba(18, 18, 18, 0.18);
  transform: translateY(10px);
  transition: transform 0.2s ease;
}
.modal.open .modal-dialog {
  transform: translateY(0);
}
.modal-dialog.modal-lg { max-width: 720px; }
.modal-dialog.modal-sm { max-width: 420px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--color-neutral-1);
}
.modal-body {
  padding: var(--sp-6);
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--color-neutral-1);
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
}

/* Form grid (for CRUD forms) */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-4);
}
.form-grid .form-field.full {
  grid-column: 1 / -1;
}
.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-dark);
}
.form-field label .required {
  color: var(--color-danger);
  margin-left: 2px;
}
.form-field .form-input,
.form-field .form-select {
  width: 100%;
  min-width: 0;
}
.form-field .form-hint {
  font-size: 11px;
  color: var(--color-neutral-2);
}
.form-field .form-error {
  font-size: 11px;
  color: var(--color-danger);
  display: none;
}
.form-field.has-error .form-input,
.form-field.has-error .form-select {
  border-color: var(--color-danger);
}
.form-field.has-error .form-error { display: block; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* Row actions (table icon buttons) */
.row-actions {
  display: inline-flex; gap: 2px;
}
.row-actions .btn {
  padding: 5px 8px;
  font-size: 12px;
}

/* Confirm dialog body */
.confirm-text {
  font-size: 14px;
  color: var(--color-text-dark);
  line-height: 1.6;
}
.confirm-text strong {
  color: var(--color-danger);
}

/* Detail list (key-value) */
.kv-list { display: grid; grid-template-columns: 110px 1fr; row-gap: 10px; column-gap: var(--sp-4); }
.kv-list dt { font-size: 12px; color: var(--color-neutral-2); font-weight: 500; }
.kv-list dd { margin: 0; font-size: 13px; font-weight: 500; color: var(--color-text-dark); }

.section-title {
  font-size: 12px; font-weight: 600; color: var(--color-neutral-2);
  text-transform: uppercase; letter-spacing: 0.3px;
  margin: var(--sp-5) 0 var(--sp-3);
}

/* Timeline */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
  position: relative; padding: 0 0 14px 22px;
  border-left: 2px solid var(--color-neutral-1);
}
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before {
  content: ""; position: absolute; left: -6px; top: 2px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--color-primary);
  border: 2px solid var(--color-white);
  box-shadow: 0 0 0 1px var(--color-primary);
}
.timeline .t-title { font-size: 13px; font-weight: 600; }
.timeline .t-meta { font-size: 11px; color: var(--color-neutral-2); margin-top: 2px; }

/* =========================================
   Config page
   ========================================= */
.config-grid {
  display: grid; grid-template-columns: 260px 1fr; gap: var(--sp-4);
}
.config-nav {
  background: var(--color-white);
  border: 1px solid var(--color-neutral-1);
  border-radius: var(--r-lg);
  padding: var(--sp-3);
  height: fit-content;
  position: sticky; top: calc(var(--header-h) + var(--sp-4));
}
.config-nav .nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 10px 12px; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 500; color: var(--color-text-dark);
  cursor: pointer;
}
.config-nav .nav-item:hover { background: var(--color-surface); }
.config-nav .nav-item.active {
  background: rgba(52, 23, 206, 0.08); color: var(--color-primary); font-weight: 600;
}
.config-nav .nav-item i { width: 16px; font-size: 13px; }

/* Tag list */
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-neutral-1);
  border-radius: 999px;
  font-size: 12px; font-weight: 500;
}
.tag button {
  background: transparent; border: 0;
  color: var(--color-neutral-2);
  font-size: 11px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px;
}
.tag button:hover { color: var(--color-danger); }

/* =========================================
   Help page
   ========================================= */
.help-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: var(--sp-6);
  align-items: flex-start;
}
.help-toc {
  background: var(--color-white);
  border: 1px solid var(--color-neutral-1);
  border-radius: var(--r-lg);
  padding: var(--sp-3);
  position: sticky;
  top: calc(var(--header-h) + var(--sp-4));
  max-height: calc(100vh - var(--header-h) - var(--sp-8));
  overflow-y: auto;
}
.help-toc .toc-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-neutral-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: var(--sp-2) var(--sp-3) var(--sp-3);
}
.help-toc a {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  color: var(--color-text-dark);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s ease;
  margin-bottom: 2px;
}
.help-toc a:hover {
  background: var(--color-surface);
  text-decoration: none;
}
.help-toc a.active {
  background: rgba(52, 23, 206, 0.08);
  color: var(--color-primary);
  font-weight: 600;
}
.help-toc a i {
  width: 14px;
  text-align: center;
  font-size: 12px;
  color: var(--color-neutral-2);
}
.help-toc a.active i { color: var(--color-primary); }

.help-content {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}

.help-section {
  background: var(--color-white);
  border: 1px solid var(--color-neutral-1);
  border-radius: var(--r-lg);
  padding: var(--sp-6) var(--sp-8);
  scroll-margin-top: calc(var(--header-h) + var(--sp-4));
}
.help-section h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: var(--sp-2);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.help-section h2 .section-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: rgba(52, 23, 206, 0.08);
  color: var(--color-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.help-section > .section-desc {
  font-size: 13px;
  color: var(--color-neutral-2);
  margin-bottom: var(--sp-5);
}
.help-section h3 {
  font-size: 15px;
  font-weight: 700;
  margin: var(--sp-5) 0 var(--sp-3);
  color: var(--color-text-dark);
}
.help-section p {
  font-size: 13px;
  line-height: 1.7;
  color: var(--color-text-dark);
  margin-bottom: var(--sp-3);
}
.help-section ul, .help-section ol {
  font-size: 13px;
  line-height: 1.8;
  color: var(--color-text-dark);
  padding-left: 20px;
  margin: 0 0 var(--sp-3);
}
.help-section li { margin-bottom: 4px; }
.help-section code {
  font-family: 'Montserrat', monospace;
  background: var(--color-surface);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--color-primary);
}
.help-section a { color: var(--color-primary); font-weight: 500; }

/* Flag reference card grid */
.flag-ref-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
  margin-top: var(--sp-3);
}
.flag-ref {
  border: 1px solid var(--color-neutral-1);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
}
.flag-ref .flag-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.flag-ref .flag-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}
.flag-ref .flag-desc {
  font-size: 12px;
  color: var(--color-neutral-2);
  line-height: 1.5;
}

/* Info callout box */
.callout {
  border-left: 3px solid var(--color-primary);
  background: rgba(52, 23, 206, 0.05);
  padding: var(--sp-4) var(--sp-5);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  font-size: 13px;
  line-height: 1.6;
  margin: var(--sp-4) 0;
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
}
.callout i { color: var(--color-primary); font-size: 14px; padding-top: 2px; }
.callout.warn { border-left-color: var(--color-warning); background: var(--color-warning-bg); }
.callout.warn i { color: var(--color-warning); }
.callout.danger { border-left-color: var(--color-danger); background: var(--color-danger-bg); }
.callout.danger i { color: var(--color-danger); }

/* FAQ accordion */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.faq-item {
  border: 1px solid var(--color-neutral-1);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: border-color 0.15s ease;
}
.faq-item.open {
  border-color: var(--color-secondary);
  box-shadow: var(--shadow-sm);
}
.faq-question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  background: var(--color-white);
  border: 0;
  width: 100%;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-dark);
  cursor: pointer;
  font-family: inherit;
}
.faq-question:hover { background: var(--color-surface); }
.faq-question .q-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  background: var(--color-primary);
  color: var(--color-white);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.faq-question .q-text { flex: 1; }
.faq-question .q-chevron {
  color: var(--color-neutral-2);
  transition: transform 0.2s ease;
  font-size: 12px;
}
.faq-item.open .q-chevron { transform: rotate(180deg); color: var(--color-primary); }
.faq-answer {
  display: none;
  padding: 0 var(--sp-5) var(--sp-4) 55px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--color-text-dark);
}
.faq-item.open .faq-answer { display: block; }
.faq-answer p { margin-bottom: 8px; }
.faq-answer p:last-child { margin-bottom: 0; }

/* Shortcut keys (kbd) */
kbd {
  display: inline-block;
  font-family: 'Montserrat', monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-dark);
  background: var(--color-white);
  border: 1px solid var(--color-highlight);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 2px 6px;
  line-height: 1;
}

/* Contact card */
.contact-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-4);
  margin-top: var(--sp-4);
}
.contact-card {
  border: 1px solid var(--color-neutral-1);
  border-radius: var(--r-md);
  padding: var(--sp-5);
  text-align: center;
}
.contact-card .contact-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(52, 23, 206, 0.08);
  color: var(--color-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  margin-bottom: var(--sp-3);
}
.contact-card .contact-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}
.contact-card .contact-info {
  font-size: 12px;
  color: var(--color-neutral-2);
  line-height: 1.6;
}
.contact-card .contact-value {
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  color: var(--color-text-dark);
  display: block;
  margin-top: 6px;
}

/* Help search bar */
.help-search {
  background: var(--color-white);
  border: 1px solid var(--color-neutral-1);
  border-radius: var(--r-lg);
  padding: var(--sp-5) var(--sp-6);
  margin-bottom: var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.help-search .search-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: rgba(52, 23, 206, 0.08);
  color: var(--color-primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.help-search input {
  flex: 1;
  border: 0;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  background: transparent;
  color: var(--color-text-dark);
}
.help-search input::placeholder { color: var(--color-neutral-2); }

@media (max-width: 1024px) {
  .help-grid { grid-template-columns: 1fr; }
  .help-toc { position: relative; top: 0; max-height: none; }
  .flag-ref-grid { grid-template-columns: 1fr; }
  .contact-grid { grid-template-columns: 1fr; }
  .help-section { padding: var(--sp-5); }
}

/* Empty state */
.empty {
  padding: var(--sp-10) var(--sp-6);
  text-align: center; color: var(--color-neutral-2);
}
.empty i { font-size: 32px; color: var(--color-highlight); margin-bottom: var(--sp-3); }

/* Toggle switch */
.switch {
  position: relative; display: inline-block;
  width: 36px; height: 20px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0;
  background: var(--color-highlight);
  border-radius: 999px; cursor: pointer; transition: 0.2s;
}
.switch .slider::before {
  content: ""; position: absolute; left: 2px; top: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--color-white);
  transition: 0.2s;
  box-shadow: var(--shadow-sm);
}
.switch input:checked + .slider { background: var(--color-primary); }
.switch input:checked + .slider::before { transform: translateX(16px); }
.switch input:focus-visible + .slider { box-shadow: var(--focus-ring); }

/* Utility */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.mt-4 { margin-top: var(--sp-4); }
.text-muted { color: var(--color-neutral-2); }
.text-sm { font-size: 12px; }
.text-bold { font-weight: 700; }

/* Responsive */
@media (max-width: 1400px) {
  .stats-grid.cols-5 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1200px) {
  .stats-grid,
  .stats-grid.cols-5 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .col-6, .col-4, .col-8 { grid-column: span 12; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .page { padding: var(--sp-4); }
  .topbar { padding: 0 var(--sp-4); }
  .topbar .search input { width: 160px; }
  .stats-grid { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .config-grid { grid-template-columns: 1fr; }
}
