/* ==========================================================================
   Media Parser Console - Enterprise Big-Tech Design System
   Modern, Minimalist, Mainstream SaaS Design (Linear / Stripe / Vercel Aesthetic)
   ========================================================================== */

:root {
  color-scheme: light;
  
  /* Brand Accent Colors (Refined Indigo & Electric Blue) */
  --brand: #4f46e5;
  --brand-hover: #4338ca;
  --brand-active: #3730a3;
  --brand-light: #eef2ff;
  --brand-light-hover: #e0e7ff;
  --brand-border: #c7d2fe;
  
  /* Neutral / Slate Palette */
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-muted: #e2e8f0;
  
  --ink: #0f172a;
  --ink-secondary: #334155;
  --ink-muted: #64748b;
  --ink-subtle: #94a3b8;
  
  --line: #e2e8f0;
  --line-subtle: #f1f5f9;
  
  /* Status Colors */
  --success: #059669;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --success-text: #065f46;
  
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --danger-text: #991b1b;
  
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --warning-text: #92400e;
  
  --info: #0284c7;
  --info-bg: #f0f9ff;
  --info-border: #bae6fd;
  --info-text: #075985;
  
  /* Layout Dimensions & Typography */
  --sidebar-width: 240px;
  --topbar-height: 60px;
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;
  
  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.05);
  
  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--ink);
  background-color: var(--bg-app);
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s ease;
}

/* Base App Layout */
.console-app {
  display: flex;
  min-height: 100vh;
}

/* ==========================================================================
   Sidebar Navigation (Left Rail)
   ========================================================================== */

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-card);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  user-select: none;
}

.sidebar-head {
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 750;
  font-size: 15px;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.brand img {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 5px rgba(0,0,0,0.06);
}

.role-badge {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 9999px;
  background: var(--brand-light);
  color: var(--brand);
  border: 1px solid var(--brand-border);
}

.sidebar-nav {
  padding: 14px 10px;
  flex: 1;
  overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.nav-group-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-subtle);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 10px 10px 4px;
}

.nav-group-title:not(:first-child) {
  margin-top: 14px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-secondary);
  transition: all 0.15s ease;
  margin-bottom: 2px;
  position: relative;
}

.nav-item:hover {
  background: var(--bg-subtle);
  color: var(--ink);
}

.nav-item.active {
  background: var(--brand-light);
  color: var(--brand);
  font-weight: 600;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--brand);
  border-radius: 0 4px 4px 0;
}

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

.app-icon {
  width: 1em;
  height: 1em;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: #fafafa;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.user-card-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13.5px;
  border: 1px solid var(--brand-border);
  flex-shrink: 0;
}

.user-meta {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 650;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role {
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 1px;
}

.sidebar-action-btn, .logout-icon-btn {
  background: transparent;
  border: none;
  color: var(--ink-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  padding: 0;
}

.sidebar-action-btn:hover {
  background: var(--brand-light);
  color: var(--brand);
}

.logout-icon-btn:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ==========================================================================
   Main Content Area & Topbar
   ========================================================================== */

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

.main-topbar {
  height: var(--topbar-height);
  padding: 0 32px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-subtle);
}

.topbar-breadcrumb a:hover {
  color: var(--ink);
}

.topbar-separator {
  color: #cbd5e1;
}

.page-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.01em;
}

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

.topbar-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--ink-secondary);
  padding: 5px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg-card);
  transition: all 0.15s ease;
}

.topbar-link:hover {
  background: var(--bg-subtle);
  border-color: #cbd5e1;
  color: var(--ink);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 550;
  padding: 4px 10px;
  border-radius: 9999px;
  background: var(--bg-subtle);
  color: var(--ink-secondary);
  border: 1px solid var(--line);
}

.status-pill.online {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-border);
}

.status-pill.offline {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: var(--danger-border);
}

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

.status-dot.pulse {
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
  100% { opacity: 1; transform: scale(1); }
}

.container {
  width: 100%;
  max-width: 1200px;
  padding: 28px 32px 60px;
  margin: 0 auto;
}

/* ==========================================================================
   Page Headers & Metric KPI Cards
   ========================================================================== */

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}

.page-head h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 22px 24px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  scroll-margin-top: 80px;
}

.card + .card {
  margin-top: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.card h2 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.title {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.subtitle, .muted {
  color: var(--ink-muted);
}

.subtitle {
  margin: 0 0 24px;
  font-size: 13.5px;
  line-height: 1.6;
}

/* KPI Statistics Grid */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
  align-items: stretch;
}

.stats > .card, .grid-2 > .card, .dashboard-charts-grid > .card {
  margin-top: 0;
}

.stat {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xs);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  height: 100%;
}

.stat:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-label {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--ink-muted);
}

.stat-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--ink-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat strong {
  display: block;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-top: 10px;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.stat-foot {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--ink-subtle);
}

/* Two-column responsive grid */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: stretch;
}

.grid-2 > .card {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  height: 100%;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.between {
  justify-content: space-between;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ==========================================================================
   Interactive Controls & Forms
   ========================================================================== */

.field {
  margin: 16px 0;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-secondary);
  margin-bottom: 6px;
}

input, select, textarea {
  width: 100%;
  height: 42px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 0 14px;
  background: var(--bg-card);
  color: var(--ink);
  font-size: 14px;
  font-family: inherit;
  transition: all 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

input::placeholder {
  color: #64748b;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: var(--bg-subtle);
  color: var(--ink-secondary);
  transition: all 0.15s ease;
  user-select: none;
  white-space: nowrap;
}

.btn:hover {
  background: #e2e8f0;
  color: var(--ink);
}

.btn-primary {
  background: var(--brand);
  color: #ffffff;
  border-color: var(--brand);
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.25);
}

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid #cbd5e1;
  color: var(--ink-secondary);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: #94a3b8;
  color: var(--ink);
}

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

.btn-danger:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: var(--danger-hover);
}

.btn-small {
  height: 28px;
  padding: 0 9px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-block {
  width: 100%;
}

/* Badges & Tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.badge.off {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: var(--danger-border);
}

.badge.brand {
  background: var(--brand-light);
  color: var(--brand);
  border-color: var(--brand-border);
}

.badge.neutral {
  background: var(--bg-subtle);
  color: var(--ink-secondary);
  border-color: var(--line);
}

.key {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 12px;
  color: var(--ink-secondary);
  display: inline-block;
  letter-spacing: 0.02em;
}

.secret {
  background: #0f172a;
  color: #f8fafc;
  padding: 16px;
  border-radius: var(--radius-lg);
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid #1e293b;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.notice {
  padding: 14px 18px;
  border: 1px solid var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning-text);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.code {
  margin: 12px 0 0;
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  overflow: auto;
  font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  border: 1px solid #1e293b;
}

/* ==========================================================================
   Modern Enterprise Data Tables
   ========================================================================== */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: var(--shadow-xs);
}

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

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

th {
  color: var(--ink-secondary);
  font-weight: 650;
  font-size: 12px;
  padding: 11px 16px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-subtle);
  color: var(--ink);
  vertical-align: middle;
}

tbody tr {
  transition: background-color 0.12s ease;
}

tbody tr:hover {
  background-color: #f8fafc;
}

tbody tr:last-child td {
  border-bottom: none;
}

/* Table Inline Controls */
table input[type="date"],
table input[type="number"],
table select {
  height: 30px;
  padding: 0 8px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
  border: 1px solid #cbd5e1;
  background: #ffffff;
}

table input[type="number"] {
  text-align: right;
}

/* iOS Style Smooth Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 22px;
  flex-shrink: 0;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 9999px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

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

.switch input:focus-visible + .slider {
  box-shadow: 0 0 0 2px var(--brand-light), 0 0 0 4px var(--brand);
}

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

.switch-sm {
  width: 36px;
  height: 19px;
}

.switch-sm .slider:before {
  height: 13px;
  width: 13px;
  left: 3px;
  bottom: 3px;
}

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

/* ==========================================================================
   Segmented Controls & Modern Charts
   ========================================================================== */

.period-tabs {
  display: inline-flex;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
}

.period-tab {
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--ink-muted);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
  background: transparent;
  user-select: none;
}

.period-tab:hover {
  color: var(--ink);
}

.period-tab.active {
  background: #ffffff;
  color: var(--brand);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  font-weight: 650;
}

.dashboard-charts-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 20px;
  margin-top: 20px;
  align-items: start;
}

.chart-container {
  position: relative;
  width: 100%;
}

.chart-tooltip {
  position: absolute;
  display: none;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 12px;
  line-height: 1.5;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  z-index: 20;
  white-space: nowrap;
  transition: left 0.06s ease, top 0.06s ease, opacity 0.15s ease, transform 0.15s ease;
  opacity: 0;
  transform: translateY(4px);
}

.chart-tooltip.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.chart-tooltip .tt-title {
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--ink-secondary);
  border-bottom: 1px solid var(--line-subtle);
  padding-bottom: 4px;
  font-size: 12px;
}

.chart-tooltip .tt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 3px;
  color: var(--ink-secondary);
}

.chart-tooltip .tt-row strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.chart-tooltip .tt-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.chart-hover-dot {
  transition: cx 0.06s ease, cy 0.06s ease;
  filter: drop-shadow(0 2px 4px rgba(15, 23, 42, 0.22));
}

/* Donut & Ranking Components */
.pie-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
  padding: 6px 0;
}

.pie-svg-box {
  position: relative;
  width: 210px;
  height: 210px;
  flex-shrink: 0;
}

.pie-center-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  width: 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.pie-center-lbl {
  font-size: 12.5px;
  color: var(--ink-muted);
  white-space: nowrap;
  line-height: 1;
  transition: all 0.15s ease;
}

.pie-center-val {
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  word-break: keep-all;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.pie-slice {
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
  transform-origin: 100px 100px;
}

.pie-slice:hover, .pie-slice.active {
  opacity: 0.95;
  transform: scale(1.05);
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

/* 50+ 平台紧凑居中图例 (完全对齐图片设计：圆点 + 平台名称) */
.pie-pill-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 5px 10px;
  margin-top: 12px;
  width: 100%;
  max-height: 220px;
  overflow-y: auto;
  padding: 2px 4px;
}

.pie-pill-grid::-webkit-scrollbar {
  width: 4px;
}
.pie-pill-grid::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.pie-pill-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--ink-secondary);
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  user-select: none;
}

.pie-pill-item:hover, .pie-pill-item.active {
  color: var(--ink);
  background: var(--bg-subtle);
  transform: translateY(-1px);
}

.pie-pill-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pie-pill-name {
  font-weight: 500;
  color: inherit;
  white-space: nowrap;
}

/* Ranking Bars */
.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.ranking-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
}

.ranking-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ranking-name {
  font-weight: 600;
  color: var(--ink-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ranking-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 700;
  background: var(--bg-subtle);
  color: var(--ink-muted);
}

.ranking-item:nth-child(1) .ranking-badge {
  background: #fef3c7;
  color: #b45309;
}
.ranking-item:nth-child(2) .ranking-badge {
  background: #f1f5f9;
  color: #475569;
}
.ranking-item:nth-child(3) .ranking-badge {
  background: #ffedd5;
  color: #c2410c;
}

.ranking-val {
  font-weight: 700;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.ranking-bar-bg {
  width: 100%;
  height: 8px;
  background: var(--bg-subtle);
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
}

.ranking-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #4f46e5);
  border-radius: 9999px;
  transition: width 0.4s ease;
}

/* ==========================================================================
   Settings Page Specifics
   ========================================================================== */

.settings-list {
  display: flex;
  flex-direction: column;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--line-subtle);
  gap: 20px;
}

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

.setting-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.setting-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.setting-desc {
  font-size: 12.5px;
  color: var(--ink-muted);
  line-height: 1.45;
}

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

/* ==========================================================================
   Toasts & Modal Windows
   ========================================================================== */

.toast-container {
  position: fixed;
  top: 20px;
  left: calc(50% + var(--sidebar-width) / 2);
  transform: translateX(-50%);
  z-index: 11000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  width: auto;
  max-width: min(520px, calc(100vw - 32px));
}

.toast-bubble {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: 100%;
  padding: 12px 18px;
  border-radius: var(--radius-lg);
  font-size: 13.5px;
  font-weight: 550;
  line-height: 1.45;
  background: #ffffff;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--line);
  transition: opacity 0.22s ease, transform 0.22s var(--ease-out);
  animation: toastSlideIn 0.3s var(--ease-out) forwards;
}

.toast-bubble.toast-hiding {
  opacity: 0;
  transform: translateY(-16px) scale(0.95);
  pointer-events: none;
}

@keyframes toastSlideIn {
  0% { opacity: 0; transform: translateY(-20px) scale(0.96); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.toast-bubble.toast-success {
  background: #ffffff;
  border-color: var(--success-border);
  color: var(--success-text);
}
.toast-bubble.toast-success .toast-icon { color: var(--success); }

.toast-bubble.toast-error {
  background: #ffffff;
  border-color: var(--danger-border);
  color: var(--danger-text);
}
.toast-bubble.toast-error .toast-icon { color: var(--danger); }

.toast-bubble.toast-warning {
  background: #ffffff;
  border-color: var(--warning-border);
  color: var(--warning-text);
}
.toast-bubble.toast-warning .toast-icon { color: var(--warning); }

.toast-bubble.toast-info {
  background: #ffffff;
  border-color: var(--brand-border);
  color: var(--brand-active);
}
.toast-bubble.toast-info .toast-icon { color: var(--brand); }

.toast-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-content {
  flex: 1;
  word-break: break-word;
}

.toast-close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  font-size: 18px;
  line-height: 1;
  width: 22px;
  height: 22px;
  cursor: pointer;
  color: currentColor;
  opacity: 0.5;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s, background 0.15s;
}

.toast-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.05);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal-backdrop.modal-open {
  opacity: 1;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 460px;
  padding: 24px;
  transform: scale(0.96) translateY(6px);
  transition: transform 0.22s var(--ease-out);
}

.modal-backdrop.modal-open .modal-card {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.modal-icon-wrap {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-lg);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-icon-wrap.danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.modal-icon-wrap.warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.modal-icon-wrap.primary {
  background: var(--brand-light);
  color: var(--brand);
  border: 1px solid var(--brand-border);
}

.modal-title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.modal-desc {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-muted);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* ==========================================================================
   Auth Pages (Login / Register / Setup)
   ========================================================================== */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: radial-gradient(circle at 50% 20%, rgba(79, 70, 229, 0.05) 0%, transparent 70%), var(--bg-app);
}

.auth-card {
  width: min(420px, 100%);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
  text-align: center;
}

.auth-brand img {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.04);
  border: 1px solid rgba(226, 232, 240, 0.8);
  background: #ffffff;
  margin-bottom: 12px;
  object-fit: contain;
}

.auth-brand h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
}

/* Password Input Group with Toggle Button */
.password-group {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.password-group input {
  padding-right: 42px !important;
}

.password-toggle-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background 0.15s ease;
  line-height: 1;
  user-select: none;
}

.password-toggle-btn:hover {
  color: var(--ink);
  background: rgba(0, 0, 0, 0.05);
}

.password-toggle-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.password-toggle-btn svg {
  width: 16px;
  height: 16px;
  display: block;
}

.flash {
  margin-bottom: 16px;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.flash.error {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: var(--danger-border);
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

@media (max-width: 860px) {
  .console-app {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .main-topbar {
    padding: 0 16px;
  }
  .toast-container {
    left: 50%;
  }
  .stats, .grid-2, .dashboard-charts-grid {
    grid-template-columns: 1fr;
  }
  .container {
    padding: 20px 16px;
  }
}


