/* ===== CSS Variables ===== */
:root {
  --primary: #1a3a5c;
  --primary-dark: #0f2740;
  --primary-light: #2a5080;
  --accent: #22c55e;
  --accent-dark: #16a34a;
  --accent-light: #dcfce7;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --bg: #f0f4f8;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --sidebar-width: 240px;
  --topbar-height: 60px;
  --banner-height: 36px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
  --shadow-lg: 0 4px 24px rgba(0,0,0,.12);
  --transition: .2s ease;
}

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

[hidden] { display: none !important; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ===== Login ===== */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 20%, rgba(34,197,94,.16), transparent 32%),
    radial-gradient(circle at 85% 80%, rgba(59,130,246,.18), transparent 34%),
    var(--primary-dark);
}

.login-screen[hidden] { display: none; }

.login-card {
  width: min(440px, 100%);
  padding: 34px;
  border-radius: 18px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 24px 80px rgba(0,0,0,.3);
}

.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 30px; }
.login-brand > span { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: var(--accent); color: #fff; font-size: 20px; font-weight: 700; }
.login-brand div { display: flex; flex-direction: column; }
.login-brand strong { color: var(--primary-dark); font-size: 16px; }
.login-brand small { color: var(--text-muted); }
.login-card h1 { font-size: 26px; color: var(--primary-dark); }
.login-subtitle { color: var(--text-muted); margin: 6px 0 24px; }
.login-submit { width: 100%; justify-content: center; padding: 12px; margin-top: 4px; }
.login-error { padding: 10px 12px; margin-bottom: 10px; border-radius: 7px; color: #b91c1c; background: #fee2e2; font-size: 13px; }
.login-error.success { color: #166534; background: #dcfce7; }
.demo-accounts { display: flex; flex-wrap: wrap; gap: 7px; padding-top: 22px; margin-top: 22px; border-top: 1px solid var(--border); }
.demo-accounts span { width: 100%; color: var(--text-muted); font-size: 12px; }
.demo-accounts button { border: 1px solid var(--border); background: var(--bg); color: var(--primary); border-radius: 999px; padding: 6px 10px; cursor: pointer; font-size: 12px; }
.demo-accounts button:hover { border-color: var(--primary-light); background: #fff; }
.logout-btn { border: 1px solid var(--border); background: #fff; color: var(--text-muted); border-radius: 6px; padding: 5px 8px; cursor: pointer; font-size: 12px; }
.logout-btn:hover { color: var(--danger); border-color: #fecaca; }
.data-status { padding: 10px 14px; border: 1px solid #bbf7d0; background: #f0fdf4; color: #166534; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }

/* ===== Demo Banner ===== */
.demo-banner {
  background: linear-gradient(90deg, #f59e0b, #d97706);
  color: #fff;
  text-align: center;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  position: sticky;
  top: 0;
  z-index: 200;
}

/* ===== App Shell ===== */
.app-shell {
  display: flex;
  min-height: calc(100vh - var(--banner-height));
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--primary-dark);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: var(--banner-height);
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; }
.brand-text strong { color: #fff; font-size: 15px; }
.brand-text span { font-size: 11px; opacity: .6; }

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: rgba(255,255,255,.35);
  padding: 12px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-size: 14px;
  border: none;
  background: none;
  color: inherit;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--primary-light); color: #fff; font-weight: 500; }
.nav-item .nav-icon { font-size: 16px; width: 22px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.view-toggle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius);
  color: #e2e8f0;
  cursor: pointer;
  font-size: 13px;
  transition: background var(--transition);
}

.view-toggle-btn:hover { background: rgba(255,255,255,.12); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--banner-height);
  background: rgba(0,0,0,.5);
  z-index: 99;
}

/* ===== Main ===== */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--banner-height));
}

.topbar {
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: var(--banner-height);
  z-index: 50;
}

.menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text);
  padding: 4px;
}

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

.page-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}

.period-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.period-selector select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.current-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary-light);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 25%;
}

.user-info { display: flex; flex-direction: column; }
.user-info strong { font-size: 13px; }
.user-info span { font-size: 11px; color: var(--text-muted); }
.user-actions { display: flex; gap: 6px; }

.content {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
  width: 100%;
}

/* ===== Cards & Stats ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}

.stat-card.accent { border-left-color: var(--accent); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.info { border-left-color: var(--info); }

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.stat-card.accent .stat-value { color: var(--accent-dark); }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

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

.card-header h2, .card-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
}

.card-body { padding: 20px; }

/* ===== Metric Legend ===== */
.metric-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 16px;
  background: #f8fafc;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 12px;
}

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

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

.legend-dot.gmv { background: var(--info); }
.legend-dot.company { background: var(--warning); }
.legend-dot.cs { background: var(--accent); }

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

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

thead th {
  background: #f8fafc;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:hover { background: #f8fafc; }

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--accent-dark); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.font-mono { font-family: "SF Mono", "Fira Code", monospace; font-size: 12px; }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-success { background: var(--accent-light); color: var(--accent-dark); }
.badge-danger { background: #fee2e2; color: var(--danger); }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-info { background: #dbeafe; color: #1d4ed8; }
.badge-gray { background: #f1f5f9; color: var(--text-muted); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background var(--transition), opacity var(--transition);
  white-space: nowrap;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-light); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover:not(:disabled) { background: var(--accent-dark); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover:not(:disabled) { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(26,58,92,.1);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

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

/* ===== Filters ===== */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 16px;
}

.filter-bar .form-group { margin-bottom: 0; min-width: 140px; }

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 4px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.tab-btn {
  flex: 1;
  padding: 8px 16px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}

.tab-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow);
}

/* ===== Leaderboard ===== */
.leaderboard-list { list-style: none; }

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.leaderboard-item:hover { background: #f8fafc; }
.leaderboard-item.is-me { background: var(--accent-light); }
.leaderboard-item.rank-1 { border-left: 4px solid #fbbf24; }

.rank-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  background: var(--bg);
  color: var(--text-muted);
}

.rank-badge.gold { background: #fef3c7; color: #b45309; }
.rank-badge.silver { background: #f1f5f9; color: #64748b; }
.rank-badge.bronze { background: #fed7aa; color: #c2410c; }

.lb-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary-light);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  flex-shrink: 0;
  overflow: hidden;
}

.lb-info { flex: 1; min-width: 0; }
.lb-name { font-weight: 600; font-size: 15px; }
.lb-code { font-size: 12px; color: var(--text-muted); }

.lb-stats {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.lb-stat { text-align: right; min-width: 80px; }
.lb-stat-label { font-size: 11px; color: var(--text-muted); }
.lb-stat-value { font-size: 14px; font-weight: 600; }
.lb-stat-value.highlight { color: var(--accent-dark); }

.lb-gap {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 100px;
  text-align: right;
}

/* ===== Link Tool ===== */
.link-tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.qr-code-box {
  width: 160px;
  height: 160px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  color: var(--text-muted);
  font-size: 12px;
  gap: 8px;
  margin: 0 auto;
}

.qr-code-box img { display: block; width: 160px; height: 160px; }

.promo-link-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  word-break: break-all;
  font-size: 12px;
  font-family: monospace;
  margin: 12px 0;
  line-height: 1.6;
}

.link-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.link-history-item:last-child { border-bottom: none; }

/* ===== Admin ===== */
.rule-config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.rule-item {
  background: #f8fafc;
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
}

.rule-item label { font-size: 12px; color: var(--text-muted); display: block; margin-bottom: 4px; }

.freeze-banner {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: #92400e;
}

.freeze-banner.frozen { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 16px;
}

.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

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

.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 0 4px;
}

.modal-body { padding: 20px; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--primary-dark);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: slideIn .3s ease;
  max-width: 360px;
}

.toast.success { background: var(--accent-dark); }
.toast.warning { background: var(--warning-dark, #b45309); }
.toast.error { background: var(--danger); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: .4; }

/* ===== Progress Bar ===== */
.progress-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width .5s ease;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .main-wrapper {
    margin-left: 0;
  }

  .menu-btn {
    display: block;
  }

  .content {
    padding: 16px;
  }

  .link-tool-grid {
    grid-template-columns: 1fr;
  }

  .leaderboard-item {
    flex-wrap: wrap;
  }

  .lb-stats {
    width: 100%;
    justify-content: space-between;
  }

  .lb-gap {
    width: 100%;
    text-align: left;
  }

  .user-info { display: none; }
}

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

  .stat-value {
    font-size: 20px;
  }

  .topbar {
    padding: 0 12px;
  }

  .page-title {
    font-size: 16px;
  }

  .period-selector label {
    display: none;
  }
}

/* ===== 2026 Blue Console Refresh ===== */
:root {
  --primary: #1268d8;
  --primary-dark: #10233f;
  --primary-light: #2f82ef;
  --accent: #28b978;
  --accent-dark: #15925b;
  --accent-light: #eaf9f1;
  --warning: #f59a23;
  --danger: #f0525e;
  --info: #2f82ef;
  --bg: #f4f8fd;
  --surface: #fff;
  --border: #dce6f2;
  --text: #172b49;
  --text-muted: #73849d;
  --sidebar-width: 216px;
  --topbar-height: 84px;
  --banner-height: 32px;
  --radius: 12px;
  --shadow: 0 7px 24px rgba(32, 78, 125, .07), 0 1px 3px rgba(32, 78, 125, .06);
  --shadow-lg: 0 24px 70px rgba(25, 57, 96, .18);
}

body {
  background:
    radial-gradient(circle at 84% 0, rgba(47,130,239,.06), transparent 30%),
    linear-gradient(180deg, #f8fbff 0, var(--bg) 320px);
  letter-spacing: .01em;
}

/* Login */
.login-screen {
  grid-template-columns: minmax(380px, 620px) minmax(360px, 440px);
  gap: clamp(32px, 6vw, 92px);
  padding: 48px clamp(28px, 7vw, 120px);
  background:
    radial-gradient(circle at 18% 16%, rgba(72,157,255,.22), transparent 30%),
    radial-gradient(circle at 75% 82%, rgba(43,191,139,.13), transparent 28%),
    linear-gradient(135deg, #f6fbff 0%, #eaf4ff 52%, #f7fbff 100%);
}

.login-visual {
  position: relative;
  min-height: 590px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.login-visual::before {
  content: "";
  position: absolute;
  width: 470px;
  height: 470px;
  right: 0;
  bottom: 10px;
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(255,255,255,.96), rgba(219,237,255,.72));
  box-shadow: inset 0 0 0 1px rgba(77,151,232,.12), 0 30px 80px rgba(50,114,184,.12);
}

.login-visual-copy { position: relative; z-index: 3; max-width: 520px; margin-bottom: 245px; }
.login-visual .eyebrow { display: inline-flex; color: var(--primary); font-size: 12px; font-weight: 800; letter-spacing: .16em; margin-bottom: 16px; }
.login-visual h2 { color: #102b50; font-size: clamp(38px, 4.2vw, 62px); line-height: 1.1; letter-spacing: -.045em; }
.login-visual p { color: #6d829f; font-size: 16px; margin-top: 18px; }

.mascot-stage { position: absolute; right: 28px; bottom: 12px; width: 410px; height: 410px; z-index: 2; }
.mascot-stage > img { position: absolute; width: 300px; height: 330px; right: 48px; bottom: 28px; z-index: 2; object-fit: contain; object-position: center bottom; mix-blend-mode: multiply; filter: drop-shadow(0 22px 22px rgba(25,91,165,.14)); }
.orbit { position: absolute; border: 1px dashed rgba(47,130,239,.28); border-radius: 50%; }
.orbit-one { inset: 20px; }
.orbit-two { inset: 72px; border-style: solid; border-color: rgba(47,130,239,.1); }
.mascot-chip { position: absolute; z-index: 3; padding: 11px 15px; min-width: 124px; border-radius: 13px; background: rgba(255,255,255,.93); border: 1px solid rgba(204,224,246,.9); box-shadow: 0 12px 28px rgba(34,85,143,.12); backdrop-filter: blur(12px); }
.mascot-chip strong, .mascot-chip span { display: block; }
.mascot-chip strong { color: #1a365d; font-size: 13px; }
.mascot-chip span { color: var(--text-muted); font-size: 11px; margin-top: 2px; }
.chip-orders { left: -4px; top: 118px; }
.chip-settle { right: -5px; bottom: 72px; }

.login-card {
  position: relative;
  width: 100%;
  padding: 38px 40px 34px;
  border: 1px solid rgba(205,222,241,.9);
  border-radius: 22px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 30px 90px rgba(31,76,126,.18);
  backdrop-filter: blur(20px);
}
.login-brand { margin-bottom: 34px; gap: 13px; }
.login-brand > img { width: 52px; height: 52px; border-radius: 16px; background: #eaf4ff; object-fit: cover; object-position: 50% 25%; }
.login-brand strong { color: #125fc5; font-size: 18px; letter-spacing: -.02em; }
.login-brand small { margin-top: 1px; font-size: 11px; }
.login-card h1 { color: #122947; font-size: 29px; letter-spacing: -.035em; }
.login-subtitle { margin: 8px 0 27px; }
.login-card .form-group label { font-size: 12px; color: #4c607a; }
.login-card .form-group input { height: 46px; border-color: #d6e2ef; background: #fbfdff; }
.login-card .form-group input:focus { background: #fff; border-color: #3f8df1; box-shadow: 0 0 0 4px rgba(47,130,239,.11); }
.login-card .btn { min-height: 44px; border-radius: 9px; font-weight: 650; }

/* Service banner */
.demo-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--banner-height);
  padding: 5px 16px;
  background: #edf6ff;
  border-bottom: 1px solid #dceafd;
  color: #3373bd;
  font-size: 12px;
  font-weight: 500;
}
.demo-banner::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #2dbe78; margin-right: 8px; box-shadow: 0 0 0 4px rgba(45,190,120,.12); }

/* Sidebar */
.sidebar {
  color: #60728b;
  background: rgba(255,255,255,.97);
  border-right: 1px solid var(--border);
  box-shadow: 6px 0 24px rgba(39,81,128,.035);
}
.sidebar-brand { min-height: 78px; padding: 15px 17px; border-bottom: 1px solid #edf2f8; }
.brand-icon { width: 48px; height: 48px; border-radius: 15px; background: linear-gradient(145deg,#e7f3ff,#f8fbff); overflow: hidden; }
.brand-icon img { width: 52px; height: 52px; object-fit: cover; object-position: 50% 25%; transform: translate(-2px,-2px); }
.brand-text strong { color: #1465ca; font-size: 16px; letter-spacing: -.02em; }
.brand-text span { color: #8795a9; font-size: 10px; opacity: 1; margin-top: 1px; }
.sidebar-nav { padding: 14px 10px; }
.nav-section-label { color: #a2adbc; font-size: 10px; font-weight: 700; letter-spacing: .12em; padding: 10px 13px 7px; }
.nav-item { position: relative; min-height: 44px; gap: 11px; padding: 10px 12px; border-radius: 10px; color: #53677f; font-weight: 500; }
.nav-item:hover { color: var(--primary); background: #f3f8ff; }
.nav-item.active { color: #176bd2; background: linear-gradient(90deg,#eaf3ff,#f3f8ff); font-weight: 700; }
.nav-item.active::before { content: ""; position: absolute; left: 0; top: 11px; bottom: 11px; width: 3px; border-radius: 4px; background: #287ee8; }
.nav-item .nav-icon { display: grid; place-items: center; width: 26px; height: 26px; color: currentColor; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 18px; font-weight: 700; }
.sidebar-footer { padding: 12px; border-top: 1px solid #edf2f8; }
.view-toggle-btn { min-height: 42px; color: #33679f; background: #f3f8fe; border-color: #dce9f7; border-radius: 10px; }
.view-toggle-btn:hover { background: #eaf3ff; }

/* Top bar */
.topbar { height: var(--topbar-height); padding: 0 26px; background: rgba(248,251,255,.93); border-bottom: 1px solid rgba(220,230,242,.8); backdrop-filter: blur(16px); }
.topbar-left { gap: 26px; }
.page-heading { min-width: 220px; }
.page-title { color: #152b48; font-size: 21px; font-weight: 750; letter-spacing: -.03em; line-height: 1.2; }
.page-heading p { color: #8795a8; font-size: 11px; margin-top: 5px; white-space: nowrap; }
.period-selector { margin-left: auto; }
.period-selector label { font-size: 11px; }
.period-selector select { height: 38px; padding: 0 34px 0 12px; border-color: #d8e3ef; border-radius: 9px; background-color: #fff; box-shadow: 0 2px 8px rgba(32,78,125,.04); }
.current-user { padding-left: 18px; border-left: 1px solid #dee7f1; }
.user-avatar { width: 38px; height: 38px; background: linear-gradient(145deg,#3b92f4,#176ad2); box-shadow: 0 5px 12px rgba(31,119,220,.2); }
.user-info strong { color: #223a59; }
.logout-btn { border-color: #d8e3ef; border-radius: 8px; color: #708198; }
.logout-btn:hover { background: #fff5f5; }

/* Main content and cards */
.content { max-width: 1500px; padding: 22px 26px 42px; }
.data-status { position: relative; padding: 9px 14px 9px 35px; margin-bottom: 18px; border: 1px solid #ccebdc; border-radius: 10px; color: #24835a; background: linear-gradient(90deg,#effbf5,#f8fffb); box-shadow: none; }
.data-status::before { content: "✓"; position: absolute; left: 13px; top: 8px; display: grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; color: #fff; background: #31b776; font-size: 10px; font-weight: 800; }
.metric-legend { gap: 9px 22px; padding: 11px 15px; margin-bottom: 18px; border: 1px solid #e0e9f3; border-radius: 10px; color: #667991; background: rgba(255,255,255,.72); }
.legend-dot { width: 8px; height: 8px; }

.stats-grid { grid-template-columns: repeat(3,minmax(210px,1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { display: flex; align-items: center; gap: 15px; min-height: 126px; padding: 19px; border: 1px solid #dfe8f2; border-left: 1px solid #dfe8f2; border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; transition: transform .18s ease, box-shadow .18s ease; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 13px 30px rgba(32,78,125,.1); }
.stat-icon { display: grid; place-items: center; flex: 0 0 49px; width: 49px; height: 49px; border-radius: 12px; color: #fff; background: linear-gradient(145deg,#4b99f5,#1c72de); box-shadow: 0 8px 16px rgba(36,119,218,.2); font-size: 22px; font-weight: 700; }
.stat-card.accent .stat-icon { background: linear-gradient(145deg,#4bce8d,#20aa6a); box-shadow-color: rgba(32,170,106,.2); }
.stat-card.warning .stat-icon { background: linear-gradient(145deg,#ffbb57,#f28b13); box-shadow-color: rgba(242,139,19,.2); }
.stat-content { min-width: 0; }
.stat-label { color: #667990; font-size: 12px; margin-bottom: 7px; }
.stat-value, .stat-card.accent .stat-value { color: #162c4a; font-size: 26px; letter-spacing: -.035em; }
.stat-sub { color: #8a98ab; font-size: 11px; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.card { border: 1px solid #dfe8f2; border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.card-header { min-height: 57px; padding: 14px 18px; border-bottom-color: #e4ebf3; background: linear-gradient(180deg,#fff,#fcfdff); }
.card-header h2, .card-header h3 { color: #203956; font-size: 15px; font-weight: 700; }
.card-body { padding: 18px; }

/* Inputs and actions */
.btn { min-height: 36px; padding: 8px 15px; border-radius: 8px; font-weight: 650; box-shadow: none; }
.btn-primary, .btn-accent { background: linear-gradient(135deg,#348bf1,#1267d4); box-shadow: 0 5px 12px rgba(36,119,218,.16); }
.btn-primary:hover:not(:disabled), .btn-accent:hover:not(:disabled) { background: linear-gradient(135deg,#287fE9,#0c5bc1); transform: translateY(-1px); }
.btn-outline { border-color: #d4e0ec; background: #fff; color: #4b627d; }
.btn-outline:hover:not(:disabled) { border-color: #9fc4ef; color: #176bd2; background: #f7fbff; }
.form-group label { color: #4c6079; font-size: 12px; }
.form-group input, .form-group select, .form-group textarea, .rule-item input { min-height: 39px; border-color: #d7e2ee; border-radius: 8px; background: #fbfdff; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: #4a94ee; box-shadow: 0 0 0 3px rgba(47,130,239,.1); background: #fff; }
.filter-bar { padding: 14px; border: 1px solid #e1eaf3; border-radius: 10px; background: #f8fbff; }

/* Tables */
.table-wrap { border: 1px solid #e0e8f1; border-radius: 9px; }
table { color: #425875; }
thead th { padding: 11px 12px; color: #60738c; background: #f4f8fc; border-bottom: 1px solid #dbe5ef; font-size: 11px; letter-spacing: .015em; }
tbody td { padding: 11px 12px; border-bottom-color: #e7edf4; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f5f9fe; }
.badge { padding: 3px 9px; border-radius: 999px; font-weight: 650; }
.badge-info { background: #e9f3ff; color: #1a6dcc; }
.badge-success { background: #e9f8f0; color: #188555; }
.badge-warning { background: #fff4df; color: #b56a0a; }
.badge-danger { background: #fff0f1; color: #cf3e49; }

/* Feature components */
.progress-bar { height: 9px; background: #e8eef5; border-radius: 999px; }
.progress-fill { background: linear-gradient(90deg,#3b92f4,#176bd2); border-radius: 999px; box-shadow: 0 0 8px rgba(47,130,239,.2); }
.tabs { padding: 5px; border: 1px solid #e0e8f1; background: #edf3f9; border-radius: 10px; }
.tab-btn { border-radius: 7px; }
.tab-btn.active { color: #176bd2; box-shadow: 0 3px 10px rgba(34,75,121,.08); }
.leaderboard-item { min-height: 84px; }
.leaderboard-item.is-me { background: #edf8f4; }
.leaderboard-item.rank-1 { border-left-color: #f4a01f; }
.lb-avatar { background: linear-gradient(145deg,#4b99f5,#176bd2); }
.rule-item { border-color: #dfe8f2; background: #f8fbff; }
.qr-code-box, .promo-link-box { border-color: #d7e3ef; background: #f7fbff; }
.modal-overlay { background: rgba(15,36,65,.48); backdrop-filter: blur(3px); }
.modal { border: 1px solid rgba(255,255,255,.7); border-radius: 15px; box-shadow: var(--shadow-lg); }
.modal-header { background: #f8fbff; }

@media (max-width: 1120px) {
  .login-screen { grid-template-columns: minmax(310px, 1fr) 400px; gap: 32px; padding: 36px; }
  .login-visual h2 { font-size: 43px; }
  .mascot-stage { right: -28px; transform: scale(.86); transform-origin: right bottom; }
  .stats-grid { grid-template-columns: repeat(2,minmax(210px,1fr)); }
}

@media (max-width: 900px) {
  :root { --topbar-height: 76px; }
  .login-screen { display: flex; justify-content: center; padding: 24px; }
  .login-visual { display: none; }
  .login-card { width: min(440px,100%); }
  .sidebar { box-shadow: 18px 0 50px rgba(17,46,82,.16); }
  .topbar { padding: 0 16px; }
  .page-heading { min-width: 0; }
  .page-heading p { display: none; }
  .period-selector { margin-left: 0; }
  .content { padding: 17px 16px 36px; }
}

@media (max-width: 600px) {
  :root { --banner-height: 38px; --topbar-height: auto; }
  .demo-banner { min-height: var(--banner-height); font-size: 10px; }
  .topbar { min-height: 68px; flex-wrap: wrap; padding: 10px 12px; gap: 8px; }
  .topbar-left { gap: 9px; }
  .period-selector { margin-left: auto; }
  .period-selector select { width: 138px; font-size: 11px; }
  .topbar-right { width: 100%; display: none; }
  .stats-grid { grid-template-columns: 1fr; gap: 11px; }
  .stat-card { min-height: 104px; padding: 15px; }
  .stat-value { font-size: 23px; }
  .metric-legend { display: grid; }
  .login-card { padding: 29px 24px 24px; }
  .login-brand { margin-bottom: 27px; }
}
