/* ==============================================
   加盟商管理 Dashboard - Mantine 风格浅色主题
   参考: Bano Dashboard + Mantine UI 设计系统
   ============================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;600;700&display=swap');

:root {
  --bg-primary: #f8f9fa;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f3f5;

  --border-default: #dee2e6;
  --border-highlight: #ced4da;

  --text-primary: #212529;
  --text-secondary: #868e96;
  --text-muted: #adb5bd;

  --accent-primary: #228be6;
  --accent-light: #e7f5ff;
  --accent-secondary: #339af0;

  --alert-amount: #212529;
  --alert-success: #2b8a3e;
  --alert-pending: #e67700;
  --alert-negative: #c92a2a;

  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

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

  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.1);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* =============== 布局 =============== */

.app-container {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-default);
  padding: var(--space-lg) 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  font-family: 'Inter', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  padding: var(--space-xs) var(--space-lg);
  margin-bottom: var(--space-xl);
  letter-spacing: -0.5px;
}

.nav-section { margin-bottom: var(--space-sm); }

.nav-item {
  padding: 10px var(--space-lg);
  color: var(--text-secondary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
  margin: 2px 0;
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-primary);
}

.nav-item.active {
  color: var(--accent-primary);
  background: var(--accent-light);
  border-left-color: var(--accent-primary);
  font-weight: 600;
}

.nav-divider {
  height: 1px;
  background: var(--border-default);
  margin: var(--space-sm) var(--space-lg);
}

.main-content {
  flex: 1;
  padding: var(--space-xl) var(--space-2xl);
  max-width: 1200px;
  width: 100%;
}

/* =============== 页头 =============== */

.page-header {
  margin-bottom: var(--space-xl);
}

.page-title {
  font-family: 'Inter', sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--accent-primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  margin-bottom: var(--space-md);
}

.back-link:hover {
  gap: var(--space-sm);
  color: var(--accent-secondary);
}

/* =============== 卡片系统 =============== */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-card);
  transition: all 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

.card-clickable { cursor: pointer; }

.card-clickable:hover {
  background: var(--bg-card);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-hover);
}

/* =============== 总余额区域（多币种等权） =============== */

.balance-overview {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  padding: var(--space-xl);
  margin-bottom: var(--space-xl);
}

.balance-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: var(--space-lg);
}

.currency-grid {
  display: flex;
  gap: var(--space-md);
}

.currency-card {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: var(--space-lg) var(--space-md);
  text-align: center;
  transition: all 0.15s ease;
}

.currency-card:hover {
  border-color: var(--accent-primary);
  background: var(--accent-light);
}

.currency-card-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  margin-bottom: var(--space-xs);
}

.currency-card-amount {
  font-family: 'JetBrains Mono', monospace;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

/* =============== 门店卡片网格 =============== */

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.section-count {
  color: var(--text-muted);
  font-size: 14px;
}

.franchise-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-lg);
}

.franchise-card {
  position: relative;
  padding: var(--space-xl);
}

.franchise-header {
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-default);
}

.franchise-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.franchise-currencies {
  margin-bottom: var(--space-lg);
}

.franchise-currency-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f1f3f5;
}

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

.franchise-currency-code {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
}

.franchise-currency-amount {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.view-details-btn {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--accent-primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.view-details-btn:hover {
  gap: var(--space-sm);
  color: var(--accent-secondary);
}

/* =============== 筛选器 =============== */

.filters-bar {
  margin-bottom: var(--space-xl);
}

.filter-presets {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.filter-preset {
  padding: 6px var(--space-md);
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-preset:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-light);
}

.filter-preset.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #ffffff;
}

.date-range {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.date-input {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: all 0.15s ease;
}

.date-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(34, 139, 230, 0.15);
}

.date-separator {
  color: var(--text-muted);
  font-size: 13px;
}

.filter-row {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.filter-select {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  min-width: 150px;
}

.filter-select:hover { border-color: var(--border-highlight); }

.filter-select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(34, 139, 230, 0.15);
}

/* =============== 交易记录表格 =============== */

.transactions-table {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-default);
}

th {
  padding: var(--space-sm) var(--space-lg);
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid #f1f3f5;
  font-size: 14px;
}

tbody tr { transition: background 0.15s ease; }
tbody tr:hover { background: var(--bg-primary); }
tbody tr:last-child td { border-bottom: none; }

.transaction-date {
  color: var(--text-secondary);
  font-size: 13px;
}

.transaction-type {
  font-weight: 500;
  color: var(--text-primary);
}

.transaction-amount {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

.transaction-amount .positive { color: var(--alert-success); }
.transaction-amount .negative { color: var(--alert-negative); }

.transaction-amount .exchange-arrow {
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  margin: 0 4px;
}

.transaction-amount .receive {
  color: var(--alert-success);
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.status-badge.completed {
  background: #ebfbee;
  color: var(--alert-success);
  border: 1px solid #b2f2bb;
}

.status-badge.pending {
  background: #fff9db;
  color: var(--alert-pending);
  border: 1px solid #ffec99;
}

/* =============== Accounts Carousel =============== */

.accounts-carousel {
  display: flex;
  align-items: center;
  gap: 8px;
}

.carousel-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-default);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

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

.accounts-track {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  scroll-behavior: smooth;
  padding: 8px 0;
  scrollbar-width: none;
}

.accounts-track::-webkit-scrollbar { display: none; }

.account-card {
  min-width: 170px;
  padding: 24px 20px;
  text-align: center;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
  transition: all 0.15s;
}

.account-card:hover { border-color: var(--accent-primary); }

.account-flag { font-size: 36px; margin-bottom: 10px; }

.account-amount {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.account-currency-name {
  font-size: 12px;
  color: var(--text-secondary);
}

/* =============== Transaction List =============== */

.view-all-link {
  color: var(--accent-primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.view-all-link:hover { text-decoration: underline; }

.tx-list {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.tx-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #f1f3f5;
  cursor: pointer;
  transition: background 0.15s;
}

.tx-item:last-child { border-bottom: none; }
.tx-item:hover { background: var(--bg-primary); }

.tx-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.tx-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}

.tx-info { min-width: 0; }

.tx-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

.tx-time {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.tx-right {
  text-align: right;
  flex-shrink: 0;
  margin-left: 16px;
}

.tx-amount {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.tx-fee {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.tx-status {
  font-size: 12px;
  font-weight: 500;
  margin-top: 2px;
}

.tx-status.completed { color: var(--alert-success); }
.tx-status.pending { color: var(--alert-pending); }

/* =============== Account List (scrollable) =============== */

.account-list-scroll {
  max-height: 520px;
  overflow-y: auto;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
}

.account-list-scroll thead th {
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  z-index: 1;
}

/* =============== Currency Summary (scrollable table) =============== */

.currency-summary-scroll {
  max-height: 260px;
  overflow-y: auto;
}

.currency-summary-scroll thead th {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}

/* =============== Balance Hero =============== */

.balance-hero {
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border-default);
}

.balance-hero-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-xs);
}

.currency-select {
  padding: 6px 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.currency-select:hover { border-color: var(--border-highlight); }

.currency-select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(34, 139, 230, 0.15);
}

.balance-total {
  font-family: 'JetBrains Mono', monospace;
  font-size: 36px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -1px;
  margin: var(--space-xs) 0;
}

.balance-note {
  font-size: 12px;
  color: var(--text-muted);
}

/* =============== Account List Table =============== */

.account-row { cursor: pointer; }
.account-name-cell { font-weight: 500; }
.text-right { text-align: right; }

.mono {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
}

.cell-muted { color: var(--text-muted); }

/* =============== 子账号状态 Badge =============== */

.status-active {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  background: #ebfbee;
  color: #2b8a3e;
  border: 1px solid #b2f2bb;
}

.status-not-registered {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  background: #f1f3f5;
  color: #868e96;
  border: 1px solid #dee2e6;
}

.account-row.disabled {
  opacity: 0.55;
  cursor: default;
}

.account-row.disabled .view-details-btn {
  color: var(--text-muted);
  pointer-events: none;
}

/* =============== Toast 提示 =============== */

.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #212529;
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =============== 配置页面 =============== */

.config-form {
  display: flex;
  gap: var(--space-md);
  align-items: flex-end;
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 200px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-select {
  padding: 10px 14px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.form-select:hover { border-color: var(--border-highlight); }

.form-select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(34, 139, 230, 0.15);
}

.btn-primary {
  padding: 10px 24px;
  background: var(--accent-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary:hover { background: #1c7ed6; }

.btn-danger {
  padding: 6px 14px;
  background: transparent;
  color: #c92a2a;
  border: 1px solid #ffc9c9;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-danger:hover {
  background: #fff5f5;
  border-color: #c92a2a;
}

/* =============== 响应式 =============== */

@media (max-width: 1024px) {
  .sidebar { width: 220px; }
  .main-content { padding: var(--space-lg); }
  .franchise-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .currency-card-amount { font-size: 20px; }
}

@media (max-width: 768px) {
  .app-container { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }

  .main-content { padding: var(--space-md); }
  .currency-grid { flex-direction: column; }
  .currency-card-amount { font-size: 20px; }
  .franchise-grid { grid-template-columns: 1fr; }
  .account-card { min-width: 140px; }
  .tx-name { max-width: 180px; }
  .tx-left { gap: 8px; }
}
