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

:root {
  --bg-page:        #f4f5f7;
  --bg-sidebar:     #1a233a;
  --bg-topbar:      #ffffff;
  --bg-card:        #ffffff;
  --bg-card-hover:  #f8f9fc;

  --text-primary:   #1a1f36;
  --text-secondary: #6b7280;
  --text-muted:     #9ca3af;
  --text-sidebar:   #c8cfe4;
  --text-sidebar-active: #ffffff;

  --accent-primary:   #2563eb;
  --accent-hover:     #1d4ed8;
  --accent-light:     #eff6ff;
  --accent-secondary: #7c3aed;

  --success:        #16a34a;
  --success-bg:     #f0fdf4;
  --warning:        #d97706;
  --warning-bg:     #fffbeb;
  --danger:         #dc2626;
  --danger-bg:      #fef2f2;
  --info:           #0891b2;
  --info-bg:        #ecfeff;

  --border:         #e5e7eb;
  --border-focus:   #2563eb;
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:      0 10px 30px rgba(0,0,0,0.1);
  --transition:     all 0.18s ease;
  --sidebar-w:      220px;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── App Shell Layout ───────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  flex-shrink: 0;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo-title {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.sidebar-logo-sub {
  font-size: 8px;
  color: #7c8db5;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

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

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  color: #4b5e87;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 12px 20px 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-sidebar);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 450;
  border-left: 3px solid transparent;
  transition: var(--transition);
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-sidebar-active);
}

.sidebar-link.active {
  background: rgba(37, 99, 235, 0.18);
  color: var(--text-sidebar-active);
  border-left-color: var(--accent-primary);
  font-weight: 600;
}

.sidebar-link svg { opacity: 0.8; flex-shrink: 0; }
.sidebar-link.active svg { opacity: 1; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* ─── Main Content ───────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── Top Bar ────────────────────────────────────── */
.topbar {
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

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

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

/* ─── Page Content ───────────────────────────────── */
.page-content {
  padding: 24px;
  flex: 1;
}

.page-header {
  margin-bottom: 20px;
}

.page-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.page-header p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ─── Cards ──────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.card-padded { padding: 20px; }

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

.card-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body { padding: 20px; }

/* ─── KPI Stat Cards ─────────────────────────────── */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #d1d5db;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-top: 2px;
}

.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 500;
  margin-top: 4px;
}

/* ─── Grids ──────────────────────────────────────── */
.grid { display: grid; }
.gap-4 { gap: 16px; }
.gap-5 { gap: 20px; }
.gap-6 { gap: 24px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .grid-4, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .main-content { margin-left: 0; }
  .sidebar { display: none; }
}

/* ─── Form Elements ──────────────────────────────── */
.input-field {
  padding: 7px 12px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  outline: none;
  transition: var(--transition);
  height: 34px;
}

.input-field:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.input-field::placeholder { color: var(--text-muted); }

.input-field option { background: #fff; color: var(--text-primary); }

/* Search with icon */
.search-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.search-wrap svg {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-wrap .input-field { padding-left: 32px; }

/* ─── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  height: 34px;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-outline {
  background: #ffffff;
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-outline:hover { background: var(--bg-page); border-color: #d1d5db; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-page); color: var(--text-primary); }

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

/* ─── Table ──────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

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

thead tr {
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
}

th {
  text-align: left;
  padding: 10px 16px;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

td {
  padding: 11px 16px;
  border-bottom: 1px solid #f3f4f6;
  color: var(--text-primary);
}

tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: #f8f9fc; }
tbody tr:last-child td { border-bottom: none; }

/* ─── Badges ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-success { background: var(--success-bg);  color: var(--success);  }
.badge-warning { background: var(--warning-bg);  color: var(--warning);  }
.badge-danger  { background: var(--danger-bg);   color: var(--danger);   }
.badge-info    { background: var(--info-bg);     color: var(--info);     }
.badge-neutral { background: #f3f4f6; color: #4b5563; }

/* ─── Watchlist Panel ────────────────────────────── */
.watchlist-banner {
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 14px 20px;
  margin-bottom: 20px;
}

.watchlist-banner-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--danger);
  font-size: 13.5px;
  margin-bottom: 12px;
}

.watchlist-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.watchlist-chip {
  background: #ffffff;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  transition: var(--transition);
}

.watchlist-chip:hover {
  background: #fef2f2;
  box-shadow: var(--shadow-sm);
}

.watchlist-chip-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
}

.watchlist-chip-meta {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ─── Progress Bar ───────────────────────────────── */
.progress-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.progress-bar-track {
  flex: 1;
  height: 6px;
  background: #e5e7eb;
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--accent-primary);
  transition: width 0.4s ease;
}
.progress-bar-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 36px;
  text-align: right;
}

/* ─── Modal ──────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeOverlay 0.15s ease;
}
@keyframes fadeOverlay {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: #ffffff;
  border-radius: 10px;
  width: 100%;
  max-width: 640px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
  max-height: 90vh;
  overflow-y: auto;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.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: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-body { padding: 20px; }

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
}
.modal-close:hover { background: var(--bg-page); color: var(--text-primary); }

/* ─── Loading ────────────────────────────────────── */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: var(--bg-page);
  gap: 14px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-screen p {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ─── Login Page ─────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: var(--bg-page);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-width: 380px;
  padding: 36px 32px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 28px;
}

.login-logo-icon {
  width: 48px;
  height: 48px;
  background: var(--accent-light);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.login-logo-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

.login-logo-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.form-group { margin-bottom: 14px; }

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.input-full {
  width: 100%;
  padding: 9px 12px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  outline: none;
  transition: var(--transition);
}
.input-full:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.btn-login {
  width: 100%;
  padding: 10px;
  background: var(--accent-primary);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  transition: var(--transition);
}
.btn-login:hover { background: var(--accent-hover); }

.error-msg {
  font-size: 12.5px;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid #fca5a5;
  border-radius: 5px;
  padding: 8px 12px;
  margin-bottom: 10px;
}

/* ─── Utilities ──────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.mt-1 { margin-top: 4px; }
.text-sm { font-size: 12.5px; }
.text-xs { font-size: 11px; }
.font-semibold { font-weight: 600; }
.w-full { width: 100%; }
.flex-wrap { flex-wrap: wrap; }
.relative { position: relative; }

/* ─── Chart Labels ───────────────────────────────── */
.recharts-cartesian-grid-horizontal line,
.recharts-cartesian-grid-vertical line {
  stroke: #f3f4f6;
}
.recharts-text { fill: var(--text-secondary); font-size: 12px; }
.recharts-legend-item-text { color: var(--text-secondary) !important; font-size: 12px !important; }

/* ─── Divider ────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0;
}

/* ─── Animations ─────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-fade-in { animation: fadeIn 0.25s ease forwards; }

/* ─── Print styles ───────────────────────────────── */
@media print {
  .sidebar, .topbar-actions, .btn { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .card, .stat-card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* ─── Scrollbar ──────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
