/* ============================================
   实体行业投资回报计算模型 — 样式表 v2
   Professional Financial Dashboard Design
   ============================================ */

/* ---------- CSS Variables ---------- */
:root {
  /* Slate scale (new primary) */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  /* Gray aliases for backward compatibility with inline styles */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: rgba(37, 99, 235, 0.1);
  --indigo: #4f46e5;
  --indigo-light: rgba(79, 70, 229, 0.1);
  --cyan: #06b6d4;
  --emerald: #10b981;
  --rose: #f43f5e;
  --amber: #f59e0b;
  --violet: #8b5cf6;
  --violet-light: rgba(139, 92, 246, 0.1);

  --success: var(--emerald);
  --success-light: rgba(16, 185, 129, 0.1);
  --danger: var(--rose);
  --danger-light: rgba(244, 63, 94, 0.1);
  --warning: var(--amber);
  --warning-light: rgba(245, 158, 11, 0.1);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow: 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.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.07), 0 4px 6px -4px rgba(15, 23, 42, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
  --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.18);

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);

  --sidebar-width: 380px;
  --font-sans: 'Inter', 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
}

/* ---------- Reset & Base ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--slate-700);
  background: var(--slate-50);
  overflow-x: hidden;
}

/* ---------- Animations ---------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes pulseSoft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.25); }
  50% { box-shadow: 0 0 0 8px rgba(37, 99, 235, 0); }
}

.animate-fade-in {
  animation: fadeIn 0.4s var(--transition-base) both;
}

.animate-fade-in-up {
  animation: fadeInUp 0.5s var(--transition-base) both;
}

.animate-slide-in-right {
  animation: slideInRight 0.4s var(--transition-base) both;
}

/* Stagger children */
.stagger-children > *:nth-child(1) { animation-delay: 0.00s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.06s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.12s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.18s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.24s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.30s; }
.stagger-children > *:nth-child(7) { animation-delay: 0.36s; }
.stagger-children > *:nth-child(8) { animation-delay: 0.42s; }

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

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-width);
  background: #fff;
  border-right: 1px solid var(--slate-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 60px;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--slate-300) transparent;
}

.sidebar::-webkit-scrollbar {
  width: 5px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--slate-300);
  border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--slate-400);
  width: 6px;
}

.sidebar-header {
  padding: 22px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  background: linear-gradient(135deg, var(--slate-900) 0%, #1e1b4b 60%, #312e81 100%);
  color: white;
  position: relative;
  overflow: visible;
}

.sidebar-header::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -20%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(99,102,241,0.25) 0%, transparent 70%);
  pointer-events: none;
}

.sidebar-header h1 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 5px;
  letter-spacing: 0.3px;
  position: relative;
}

.sidebar-header p {
  font-size: 12px;
  opacity: 0.75;
  font-weight: 400;
  position: relative;
}

/* User bar in sidebar */
.sidebar .user-bar {
  padding: 10px 24px !important;
  background: linear-gradient(to right, var(--slate-50), #fff) !important;
  border-bottom: 1px solid var(--slate-200) !important;
}

.sidebar .user-bar #userStatus {
  color: var(--slate-500);
  font-weight: 500;
}

.sidebar .user-bar a {
  color: var(--primary) !important;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  transition: color var(--transition-fast);
}

.sidebar .user-bar a:hover {
  color: var(--primary-dark) !important;
  text-decoration: underline;
}

.sidebar-body {
  flex: 1;
  padding: 20px 16px;
  overflow-y: visible;
}

.sidebar-footer {
  padding: 18px 16px;
  border-top: 1px solid var(--slate-200);
  background: linear-gradient(to bottom, #fff, var(--slate-50));
  box-shadow: 0 -4px 12px rgba(15,23,42,0.03);
}

/* ---------- Main Content ---------- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 88px 32px 28px;
  min-height: 100vh;
}

/* ---------- Form Components ---------- */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 7px;
  transition: color var(--transition-fast);
}

.form-group:focus-within .form-label {
  color: var(--primary);
}

.form-label .hint {
  font-weight: 400;
  color: var(--slate-400);
  font-size: 12px;
  margin-left: 4px;
}

.form-input,
.form-select {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--slate-800);
  background: #fff;
  transition: border-color var(--transition-base),
              box-shadow var(--transition-base),
              transform var(--transition-base);
}

.form-input:hover,
.form-select:hover {
  border-color: var(--slate-400);
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3.5px rgba(37, 99, 235, 0.1);
  transform: translateY(-1px);
}

.form-input::placeholder {
  color: var(--slate-400);
}

.input-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-group .form-input {
  flex: 1;
}

.input-suffix {
  font-size: 13px;
  color: var(--slate-500);
  white-space: nowrap;
  font-weight: 500;
}

/* ---------- Section Title ---------- */
.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--slate-800);
  margin: 26px 0 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--slate-200);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title:first-child {
  margin-top: 0;
}

.section-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--primary-light), var(--indigo-light));
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0.12), transparent);
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}

.btn:hover::after {
  opacity: 1;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--indigo) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25), 0 1px 2px rgba(37, 99, 235, 0.15);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.32), 0 2px 4px rgba(37, 99, 235, 0.15);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.2);
}

.btn-success {
  background: linear-gradient(135deg, var(--emerald) 0%, #059669 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.22);
}

.btn-success:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.3);
}

.btn-secondary {
  background: #fff;
  color: var(--slate-700);
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--slate-50);
  border-color: var(--slate-300);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-ghost {
  background: transparent;
  color: var(--slate-600);
  border: none;
}

.btn-ghost:hover {
  background: var(--slate-100);
  color: var(--slate-800);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- KPI Cards ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.kpi-card {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.03);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--indigo));
  opacity: 0.9;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
}

.kpi-card.success::before {
  background: linear-gradient(90deg, var(--emerald), #34d399);
}

.kpi-card.danger::before {
  background: linear-gradient(90deg, var(--rose), #fb7185);
}

.kpi-card.warning::before {
  background: linear-gradient(90deg, var(--amber), #fbbf24);
}

.kpi-card.cyan::before {
  background: linear-gradient(90deg, var(--cyan), #22d3ee);
}

.kpi-card.violet::before {
  background: linear-gradient(90deg, var(--violet), #a78bfa);
}

.kpi-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--slate-900);
  line-height: 1.15;
  letter-spacing: -0.5px;
}

.kpi-value.positive { color: var(--emerald); }
.kpi-value.negative { color: var(--rose); }

.kpi-sub {
  font-size: 12px;
  color: var(--slate-500);
  margin-top: 6px;
  font-weight: 500;
}

/* ---------- Chart Cards ---------- */
.chart-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  border: 1px solid var(--slate-100);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.chart-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.chart-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--slate-800);
  letter-spacing: -0.2px;
}

.chart-container {
  position: relative;
  height: 300px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.chart-container.small {
  height: 240px;
}

/* ---------- Data Table ---------- */
.data-table-wrapper {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
  border: 1px solid var(--slate-100);
}

.data-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--slate-100);
  background: linear-gradient(to right, #fff, var(--slate-50));
}

.data-table-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--slate-800);
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 11px 14px;
  text-align: right;
  border-bottom: 1px solid var(--slate-100);
  white-space: nowrap;
}

.data-table th {
  background: linear-gradient(to bottom, var(--slate-50), #f8fafc);
  font-weight: 600;
  color: var(--slate-500);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.data-table tbody tr:nth-child(even) {
  background: rgba(248, 250, 252, 0.6);
}

.data-table tbody tr:hover {
  background: var(--slate-50);
}

.data-table td:first-child,
.data-table th:first-child {
  text-align: left;
}

.data-table .negative {
  color: var(--rose);
  font-weight: 600;
}

.data-table .positive {
  color: var(--emerald);
  font-weight: 600;
}

/* ---------- Investment Table ---------- */
.investment-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--slate-200);
}

.investment-table th,
.investment-table td {
  padding: 8px;
  border-bottom: 1px solid var(--slate-200);
  text-align: center;
}

.investment-table th {
  background: linear-gradient(to bottom, var(--slate-50), #f8fafc);
  font-weight: 600;
  font-size: 12px;
  color: var(--slate-600);
}

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

.investment-table .form-input {
  border: none;
  padding: 6px;
  text-align: right;
  background: transparent;
}

.investment-table .form-input:focus {
  box-shadow: none;
  background: #fff;
  border-radius: 4px;
}

/* ---------- Capacity Grid ---------- */
.capacity-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.capacity-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.capacity-item label {
  font-size: 11px;
  color: var(--slate-500);
  text-align: center;
  font-weight: 500;
}

.capacity-item input {
  width: 100%;
  min-width: 0;
  padding: 7px 6px;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 13px;
  background: #fff;
  transition: all var(--transition-base);
}

.capacity-item input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ---------- Tooltip ---------- */
.tooltip-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--slate-400);
  color: white;
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  margin-left: 6px;
  position: relative;
  vertical-align: middle;
  flex-shrink: 0;
  transition: background var(--transition-fast);
}

.tooltip-trigger:hover {
  background: var(--primary);
}

.tooltip-trigger::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 260px;
  padding: 10px 14px;
  background: var(--slate-800);
  color: white;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.6;
  border-radius: 8px;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  transform: translateX(-50%) translateY(4px);
}

.tooltip-trigger::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--slate-800);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.tooltip-trigger:hover::after,
.tooltip-trigger:hover::before {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.tooltip-trigger:hover::before {
  transform: translateX(-50%);
}

/* ---------- Cost Mode Toggle ---------- */
.cost-mode-toggle {
  display: flex;
  gap: 4px;
}

.cost-mode-btn {
  flex: 1;
  padding: 7px 8px;
  font-size: 12px;
  font-weight: 600;
  background: var(--slate-100);
  color: var(--slate-500);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-base);
}

.cost-mode-btn:hover {
  background: var(--slate-200);
  color: var(--slate-700);
}

.cost-mode-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--indigo));
  color: white;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

/* ---------- Tags ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.tag-blue { background: var(--primary-light); color: var(--primary); }
.tag-green { background: var(--success-light); color: #047857; }
.tag-red { background: var(--danger-light); color: #be123c; }
.tag-orange { background: var(--warning-light); color: #b45309; }
.tag-purple { background: var(--violet-light); color: var(--violet); }

/* ---------- Alerts ---------- */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid transparent;
}

.alert-info {
  background: linear-gradient(to right, #eff6ff, #dbeafe);
  color: #1e40af;
  border-color: #bfdbfe;
}

.alert-success {
  background: linear-gradient(to right, #ecfdf5, #d1fae5);
  color: #065f46;
  border-color: #a7f3d0;
}

.alert-warning {
  background: linear-gradient(to right, #fffbeb, #fef3c7);
  color: #92400e;
  border-color: #fde68a;
}

.alert-danger {
  background: linear-gradient(to right, #fff1f2, #ffe4e6);
  color: #9f1239;
  border-color: #fecdd3;
}

/* ---------- Template Selector ---------- */
.template-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ---------- PDF Report ---------- */
.pdf-report {
  background: #fff;
  padding: 28px 32px;
  max-width: 1100px;
  margin: 0 auto;
  font-family: var(--font-sans);
  color: var(--slate-800);
}

.pdf-report h1 {
  font-size: 22px;
  text-align: center;
  margin-bottom: 8px;
  color: var(--slate-900);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.pdf-report .report-meta {
  text-align: center;
  color: var(--slate-500);
  font-size: 12px;
  margin-bottom: 24px;
}

.pdf-report tr {
  page-break-inside: avoid;
}

.pdf-report table {
  page-break-inside: auto;
}

/* ---------- Global Scrollbar ---------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--slate-300);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--slate-400);
}

/* ---------- AI Loading ---------- */
.ai-loader {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px;
}

.ai-loader-ring {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--violet-light);
  border-top-color: var(--violet);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.ai-loader-text {
  color: var(--violet);
  font-weight: 600;
  font-size: 14px;
  animation: pulseSoft 2s ease-in-out infinite;
}

/* ---------- Result Area Entrance Animations ---------- */
#result-area:not(.hidden) .kpi-card {
  opacity: 0;
  animation: fadeInUp 0.5s var(--transition-base) forwards;
}
#result-area:not(.hidden) .kpi-card:nth-child(1) { animation-delay: 0.00s; }
#result-area:not(.hidden) .kpi-card:nth-child(2) { animation-delay: 0.06s; }
#result-area:not(.hidden) .kpi-card:nth-child(3) { animation-delay: 0.12s; }
#result-area:not(.hidden) .kpi-card:nth-child(4) { animation-delay: 0.18s; }
#result-area:not(.hidden) .kpi-card:nth-child(5) { animation-delay: 0.24s; }
#result-area:not(.hidden) .kpi-card:nth-child(6) { animation-delay: 0.30s; }

#result-area:not(.hidden) .chart-card {
  opacity: 0;
  animation: fadeInUp 0.55s var(--transition-base) forwards;
  animation-delay: 0.20s;
}

#result-area:not(.hidden) .data-table-wrapper {
  opacity: 0;
  animation: fadeInUp 0.6s var(--transition-base) forwards;
  animation-delay: 0.35s;
}

/* ---------- Glass Utility ---------- */
.glass {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

/* ---------- Hidden ---------- */
.hidden {
  display: none !important;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 320px;
  }
  .main-content {
    padding: 22px 24px;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: relative;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--slate-200);
    max-height: 60vh;
    overflow-y: auto;
    margin-top: 60px;
  }
  .main-content {
    margin-left: 0;
    padding: 78px 16px 18px;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .app-container {
    flex-direction: column;
  }
  .capacity-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .chart-container {
    height: 240px;
  }
  .chart-container.small {
    height: 200px;
  }
}

@media (max-width: 480px) {
  .btn-group {
    gap: 6px;
  }
  .btn {
    padding: 8px 12px;
    font-size: 13px;
  }
  .kpi-value {
    font-size: 22px;
  }
}


/* ============================================
   UI/UX Enhancement v2.1
   ============================================ */

/* ---------- Glass & Gradient Utilities ---------- */
.glass-effect {
  background: rgba(255, 255, 255, 0.65);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.45);
}

.gradient-card {
  background: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(241,245,249,0.8) 100%);
  border: 1px solid rgba(255,255,255,0.6);
}

.glow-border {
  position: relative;
}
.glow-border::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  opacity: 0;
  z-index: -1;
  transition: opacity 0.3s ease;
  filter: blur(6px);
}
.glow-border:focus-within::after {
  opacity: 0.4;
}

/* ---------- Sidebar Header Enhancement ---------- */
.sidebar-header {
  background: linear-gradient(145deg, #0f172a 0%, #1e1b4b 50%, #312e81 100%);
  position: relative;
  overflow: visible;
}
.sidebar-header::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 150px;
  height: 150px;
  background: radial-gradient(circle, rgba(6,182,212,0.15) 0%, transparent 70%);
  pointer-events: none;
}

.sidebar-header h1 {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-header h1::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--primary));
  box-shadow: 0 0 8px rgba(6,182,212,0.5);
  animation: pulseDot 2s ease-in-out infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.3); }
}

/* ---------- User Bar Enhancement ---------- */
.user-bar-enhanced {
  padding: 12px 24px;
  background: linear-gradient(to right, #f8fafc, #ffffff);
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--slate-500);
}

.user-status-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--slate-400);
}

.user-status-badge.online::before {
  background: var(--emerald);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* ---------- Section Title Accent ---------- */
.section-title {
  position: relative;
  padding-left: 14px;
  border-bottom: none;
}
.section-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 2px;
  bottom: 2px;
  width: 4px;
  border-radius: 2px;
  background: linear-gradient(to bottom, var(--primary), var(--indigo));
}
.section-title:first-child {
  margin-top: 0;
}

/* ---------- Tooltip Enhancement ---------- */
.tooltip-trigger {
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, var(--slate-400), var(--slate-500));
  font-size: 11px;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.tooltip-trigger:hover {
  background: linear-gradient(135deg, var(--primary), var(--indigo));
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}
.tooltip-trigger::after {
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.7;
  padding: 10px 14px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.15);
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid rgba(255,255,255,0.08);
}
.tooltip-trigger::before {
  border-top-color: #1e293b;
}

/* ---------- Input Reference Hint ---------- */
.input-reference {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--slate-400);
  font-weight: 500;
  background: linear-gradient(to right, var(--slate-50), transparent);
  padding: 3px 8px;
  border-radius: 4px;
  border-left: 2px solid var(--slate-300);
}

/* ---------- KPI Card v2 Enhancement ---------- */
.kpi-card {
  background: linear-gradient(145deg, rgba(255,255,255,0.9) 0%, rgba(248,250,252,0.85) 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.7);
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  padding: 22px;
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.kpi-card::before {
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--indigo));
}
.kpi-card.success {
  background: linear-gradient(145deg, rgba(236,253,245,0.9) 0%, rgba(255,255,255,0.85) 100%);
  border-color: rgba(16, 185, 129, 0.15);
}
.kpi-card.success::before {
  background: linear-gradient(90deg, var(--emerald), #34d399);
}
.kpi-card.danger {
  background: linear-gradient(145deg, rgba(255,241,242,0.9) 0%, rgba(255,255,255,0.85) 100%);
  border-color: rgba(244, 63, 94, 0.12);
}
.kpi-card.danger::before {
  background: linear-gradient(90deg, var(--rose), #fb7185);
}
.kpi-card.warning {
  background: linear-gradient(145deg, rgba(255,251,235,0.9) 0%, rgba(255,255,255,0.85) 100%);
  border-color: rgba(245, 158, 11, 0.15);
}
.kpi-card.warning::before {
  background: linear-gradient(90deg, var(--amber), #fbbf24);
}
.kpi-card.neutral {
  background: linear-gradient(145deg, rgba(241,245,249,0.9) 0%, rgba(255,255,255,0.85) 100%);
  border-color: rgba(148, 163, 184, 0.2);
}
.kpi-card.neutral::before {
  background: linear-gradient(90deg, var(--slate-400), var(--slate-300));
}
.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.1), 0 4px 8px rgba(15, 23, 42, 0.05);
}
.kpi-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kpi-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--slate-200), transparent);
  margin-left: 4px;
}
.kpi-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.8px;
  background: linear-gradient(135deg, var(--slate-900), var(--slate-700));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.kpi-value.positive {
  background: linear-gradient(135deg, #059669, #10b981);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.kpi-value.negative {
  background: linear-gradient(135deg, #e11d48, #f43f5e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.kpi-sub {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--slate-400);
}

/* ---------- Risk Rating Card ---------- */
.risk-card {
  background: linear-gradient(145deg, rgba(255,255,255,0.9) 0%, rgba(248,250,252,0.85) 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  padding: 22px;
  border: 1px solid rgba(255,255,255,0.7);
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
  position: relative;
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.risk-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--slate-400), var(--slate-300));
  opacity: 0.9;
}
.risk-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.1);
}
.risk-card .risk-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--slate-400);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.risk-card .risk-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--slate-200), transparent);
  margin-left: 4px;
}
.risk-card .risk-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.8px;
  background: linear-gradient(135deg, var(--slate-900), var(--slate-700));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.risk-card .risk-sub {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--slate-400);
}
.risk-card .risk-meter {
  margin-top: 12px;
  height: 6px;
  border-radius: 3px;
  background: var(--slate-200);
  overflow: hidden;
  position: relative;
}
.risk-card .risk-meter-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease, background 0.3s ease;
}
.risk-level-low::before { background: linear-gradient(90deg, var(--emerald), #34d399); }
.risk-level-low .risk-value {
  background: linear-gradient(135deg, #059669, #10b981);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.risk-level-low .risk-meter-fill { background: linear-gradient(90deg, var(--emerald), #34d399); }
.risk-level-medium::before { background: linear-gradient(90deg, var(--amber), #fbbf24); }
.risk-level-medium .risk-value {
  background: linear-gradient(135deg, #b45309, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.risk-level-medium .risk-meter-fill { background: linear-gradient(90deg, var(--amber), #fbbf24); }
.risk-level-high::before { background: linear-gradient(90deg, var(--rose), #fb7185); }
.risk-level-high .risk-value {
  background: linear-gradient(135deg, #be123c, #f43f5e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.risk-level-high .risk-meter-fill { background: linear-gradient(90deg, var(--rose), #fb7185); }

/* ---------- Chart Card Enhancement ---------- */
.chart-card {
  background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid rgba(226, 232, 240, 0.6);
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.03);
}
.chart-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.07), 0 2px 6px rgba(15, 23, 42, 0.04);
}
.chart-header {
  position: relative;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--slate-100);
}
.chart-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.chart-title::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--indigo));
}

/* ---------- Industry Params Transition ---------- */
.industry-params {
  transition: opacity 0.25s ease, transform 0.25s ease, max-height 0.3s ease;
  transform-origin: top;
}
.industry-params.hidden {
  opacity: 0;
  transform: translateY(-8px);
  max-height: 0;
  overflow: hidden;
  pointer-events: none;
}
.industry-params:not(.hidden) {
  opacity: 1;
  transform: translateY(0);
  animation: fadeInUp 0.3s ease both;
}

/* ---------- Button Enhancements ---------- */
.btn-primary.btn-block {
  font-size: 15px;
  letter-spacing: 0.5px;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.3);
}
.btn-primary.btn-block:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.38);
}
.btn-group .btn-secondary {
  transition: all 0.2s ease;
}
.btn-group .btn-secondary:hover {
  transform: translateY(-1px);
  border-color: var(--slate-300);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

/* ---------- Data Table Enhancement ---------- */
.data-table-wrapper {
  background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid rgba(226, 232, 240, 0.6);
}

/* ---------- Empty State Enhancement ---------- */
#empty-state {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid rgba(186, 230, 253, 0.5);
  border-radius: var(--radius-lg);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .risk-card {
    margin-top: 12px;
  }
}


/* ============================================
   calc.html Enhancement
   ============================================ */

/* ---------- Sidebar User Bar ---------- */
.sidebar .sidebar-user-bar {
  padding: 12px 24px !important;
  background: rgba(255, 255, 255, 0.85) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border-bottom: 1px solid rgba(226, 232, 240, 0.6) !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.user-action-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--slate-500);
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  transition: color var(--transition-fast);
}

.user-action-link:hover {
  color: var(--slate-700);
}

.user-action-login {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  transition: color var(--transition-fast);
}

.user-action-login:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

/* ---------- Form Select Custom Arrow ---------- */
.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ---------- Template Selector Pill Buttons ---------- */
.template-selector .template-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  background: var(--slate-100);
  color: var(--slate-600);
  border: 1px solid var(--slate-200);
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--transition-base);
}

.template-selector .template-btn:hover {
  background: var(--slate-200);
  color: var(--slate-800);
}

.template-selector .template-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--indigo));
  color: white;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

/* ---------- Page Header ---------- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 14px;
}

.page-header-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--slate-900);
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-header-title::before {
  content: '';
  width: 3px;
  height: 24px;
  border-radius: 2px;
  background: linear-gradient(to bottom, var(--primary), var(--indigo));
  flex-shrink: 0;
}

.page-header-subtitle {
  font-size: 13px;
  color: var(--slate-500);
  margin-top: 4px;
}

.page-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- Chart Grid ---------- */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.chart-grid-1col {
  grid-template-columns: 1fr;
}

.chart-card-full {
  margin-top: 20px;
}

/* ---------- Model Explanation Card ---------- */
.model-explanation-card {
  margin-bottom: 20px;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-left: 4px solid #0284c7;
  animation: fadeInUp 0.5s ease both;
}

.model-explanation-card .chart-header {
  border-bottom-color: rgba(186, 230, 253, 0.5);
}

.model-explanation-content {
  font-size: 13px;
  line-height: 1.8;
  color: #334155;
}

/* ---------- AI Analysis Card ---------- */
.ai-analysis-card {
  margin-top: 20px;
  background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
  border-left: 4px solid var(--violet);
  position: relative;
}

.ai-analysis-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--violet), #a78bfa);
  opacity: 0.9;
}

.ai-analysis-card .chart-header {
  border-bottom-color: rgba(233, 213, 255, 0.5);
}

.ai-analysis-content {
  font-size: 13px;
  line-height: 1.7;
  color: #4b5563;
}

.ai-login-hint {
  margin-bottom: 16px;
  font-size: 13px;
}

.ai-loading-wrapper {
  padding: 20px;
  text-align: center;
}

/* ---------- AI Result Box ---------- */
.ai-result-box {
  background: #fff;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid #e9d5ff;
  margin-top: 14px;
  box-shadow: var(--shadow-sm);
}

.ai-result-title {
  font-weight: 700;
  color: #581c87;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-result-text {
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.7;
  color: #4b5563;
}

.ai-prompt-box {
  margin-top: 8px;
  padding: 10px;
  background: var(--slate-50);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--slate-600);
  white-space: pre-wrap;
  border: 1px solid var(--slate-200);
  max-height: 300px;
  overflow-y: auto;
}

/* ---------- Empty State ---------- */
.empty-state {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid rgba(186, 230, 253, 0.5);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 12px;
}

.empty-state-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-light), var(--indigo-light));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.empty-state-text {
  font-size: 14px;
  color: #1e40af;
  line-height: 1.6;
}

/* ---------- Section Spacer ---------- */
.section-spacer {
  margin-top: 20px;
}

/* ---------- Data Table Scroll ---------- */
.data-table-scroll {
  overflow-x: auto;
}

/* ---------- Data Table Dark Header Override ---------- */
.data-table-wrapper .data-table thead th {
  background: linear-gradient(to bottom, var(--slate-900), var(--slate-800));
  color: #fff;
  font-weight: 600;
}

/* ---------- Export Button Group ---------- */
.btn-export-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- Sidebar Toggle (Mobile) ---------- */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: linear-gradient(145deg, #0f172a 0%, #1e1b4b 50%, #312e81 100%);
  color: white;
  cursor: pointer;
  border: none;
  width: 100%;
  font-size: 14px;
  font-weight: 600;
}

.sidebar-toggle svg {
  transition: transform 0.25s ease;
  transform: rotate(180deg);
}

.sidebar.collapsed .sidebar-toggle svg {
  transform: rotate(0deg);
}

/* ---------- Param Group (Optional) ---------- */
.param-group {
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.param-group-header {
  padding: 12px 16px;
  background: linear-gradient(to right, var(--slate-50), #fff);
  font-size: 13px;
  font-weight: 700;
  color: var(--slate-700);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.param-group-body {
  padding: 16px;
  background: #fff;
}

.param-group-body.collapsed {
  display: none;
}

/* ---------- Utility Classes ---------- */
.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-18 { margin-top: 18px; }
.mt-20 { margin-top: 20px; }
.mb-10 { margin-bottom: 10px; }
.mb-12 { margin-bottom: 12px; }
.w-full { width: 100%; }
.cursor-pointer { cursor: pointer; }

/* ---------- Risk Meter Height (P0) ---------- */
.risk-card .risk-meter {
  height: 12px;
  border-radius: 6px;
}

.risk-card .risk-meter-fill {
  border-radius: 6px;
}

/* ---------- Icon Alignment Helpers ---------- */
.chart-title svg,
.page-header-title svg,
.empty-state-icon svg,
.ai-result-title svg,
.section-icon svg,
.risk-title svg,
.data-table-title svg,
.btn svg {
  flex-shrink: 0;
}

.section-icon svg {
  color: var(--primary);
}

.input-reference svg {
  flex-shrink: 0;
  color: var(--slate-400);
}

/* ---------- Responsive Enhancements ---------- */
@media (max-width: 768px) {
  .chart-grid {
    grid-template-columns: 1fr;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .page-header-actions {
    width: 100%;
  }
  .sidebar-toggle {
    display: flex;
  }
  .sidebar.collapsed .sidebar-body,
  .sidebar.collapsed .sidebar-footer {
    display: none;
  }
  .data-table-wrapper {
    overflow-x: auto;
  }
}

@media (max-width: 480px) {
  .page-header-actions .btn {
    flex: 1;
    min-width: 120px;
  }
  .kpi-value {
    font-size: 22px;
  }
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Sidebar Header with User Info (Fixed Top) ---------- */
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
}

.sidebar-header-left {
  position: relative;
  z-index: 1;
}

.sidebar-header-left h1 {
  margin-bottom: 3px;
  font-size: 17px;
}

.sidebar-header-left p {
  font-size: 11px;
  opacity: 0.7;
  margin: 0;
}

.sidebar-header-right {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.sidebar-header-right .user-status-badge {
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.sidebar-header-right .user-status-badge::before {
  background: rgba(255, 255, 255, 0.5);
}

.sidebar-header-right .user-status-badge.online::before {
  background: var(--emerald);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3);
}

.sidebar-header-right .user-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.sidebar-header-right .user-action-link {
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  transition: color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sidebar-header-right .user-action-link:hover {
  color: #fff;
}

.sidebar-header-right .user-action-login {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  transition: all var(--transition-fast);
}

.sidebar-header-right .user-action-login:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

/* ---------- App Header (Global Fixed Top Bar) ---------- */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  z-index: 200;
  overflow: visible;
}

/* 强制覆盖 sidebar-header 的 overflow: hidden */
.app-header.sidebar-header {
  overflow: visible;
}

@media (max-width: 768px) {
  .app-header {
    height: 56px;
  }
  .app-header .sidebar-header-left h1 {
    font-size: 15px;
  }
  .app-header .sidebar-header-left p {
    display: none;
  }
  .sidebar {
    margin-top: 56px;
    top: 0;
  }
  .main-content {
    padding: 74px 16px 18px;
  }
}

/* ---------- User Dropdown Menu ---------- */
.user-dropdown {
  position: relative;
}

.user-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  padding: 5px 12px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast);
  font-family: inherit;
  line-height: 1.4;
}

.user-dropdown-toggle:hover {
  background: rgba(255, 255, 255, 0.18);
}

.user-dropdown-toggle svg {
  flex-shrink: 0;
}

.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 170px;
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  display: none;
  overflow: visible;
}

.user-dropdown-menu.show {
  display: block;
  animation: fadeInUp 0.2s ease both;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  color: var(--slate-700);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--transition-fast);
  white-space: nowrap;
}

.user-dropdown-item:hover {
  background: var(--slate-50);
}

.user-dropdown-item-danger {
  color: var(--rose);
}

.user-dropdown-item-danger:hover {
  background: var(--danger-light);
}

.user-dropdown-divider {
  height: 1px;
  background: var(--slate-200);
  margin: 4px 0;
}
