/* ═══════════════════════════════════════════════
   Finance Analytics — Premium Design System
   ═══════════════════════════════════════════════ */

/* ─── Design Tokens ─── */
:root {
  --bg:              #f0f2f8;
  --surface:         #ffffff;
  --surface-2:       #f8f9fc;
  --surface-3:       #f3f4f9;
  --border:          #e4e7ef;
  --border-subtle:   #eef0f6;
  --text-primary:    #0f172a;
  --text-secondary:  #475569;
  --text-muted:      #94a3b8;
  --accent:          #4f46e5;
  --accent-light:    #eef2ff;
  --accent-hover:    #4338ca;
  --accent-glow:     rgba(79,70,229,.18);
  --success:         #059669;
  --success-light:   #ecfdf5;
  --danger:          #dc2626;
  --danger-light:    #fef2f2;
  --warning:         #d97706;
  --warning-light:   #fffbeb;
  --shadow-xs:       0 1px 2px rgba(0,0,0,.04);
  --shadow-sm:       0 1px 4px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  --shadow:          0 4px 20px rgba(0,0,0,.07), 0 1px 6px rgba(0,0,0,.04);
  --shadow-lg:       0 12px 40px rgba(0,0,0,.1), 0 4px 12px rgba(0,0,0,.06);
  --shadow-xl:       0 24px 60px rgba(0,0,0,.14), 0 8px 20px rgba(0,0,0,.08);
  --radius-sm:       8px;
  --radius:          12px;
  --radius-lg:       16px;
  --radius-xl:       20px;
  --nav-height:      60px;
  --font:            'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:       'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --transition:      .18s cubic-bezier(.22,1,.36,1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Custom Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ══════════════════════════════════
   NAVBAR
══════════════════════════════════ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--nav-height);
  background: #0d1117;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  box-shadow: 0 1px 24px rgba(0,0,0,.25);
}

.nav-brand {
  color: white;
  text-decoration: none;
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: -.015em;
  display: flex;
  align-items: center;
  gap: .55rem;
  transition: opacity var(--transition);
}

.nav-brand:hover { opacity: .85; }

.nav-brand-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  box-shadow: 0 0 12px rgba(99,102,241,.5);
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: .15rem;
}

.nav-links a {
  color: rgba(255,255,255,.5);
  text-decoration: none;
  font-size: .8rem;
  font-weight: 500;
  padding: .35rem .7rem;
  border-radius: 6px;
  transition: color var(--transition), background var(--transition);
  letter-spacing: .015em;
  white-space: nowrap;
}

.nav-links a:hover {
  color: rgba(255,255,255,.9);
  background: rgba(255,255,255,.07);
}

.nav-links a.active {
  color: #a5b4fc;
  background: rgba(99,102,241,.18);
  font-weight: 600;
}

/* ══════════════════════════════════
   CONTAINER
══════════════════════════════════ */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem;
}

/* ══════════════════════════════════
   PAGE ENTRY ANIMATIONS
══════════════════════════════════ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(.96); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes slideRight {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes shimmer {
  from { background-position: -200% center; }
  to   { background-position: 200% center; }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99,102,241,0); }
  50%       { box-shadow: 0 0 0 4px rgba(99,102,241,.15); }
}

.container > * {
  animation: fadeUp .5s cubic-bezier(.22,1,.36,1) both;
}
.container > *:nth-child(1) { animation-delay: .04s; }
.container > *:nth-child(2) { animation-delay: .09s; }
.container > *:nth-child(3) { animation-delay: .14s; }
.container > *:nth-child(4) { animation-delay: .19s; }
.container > *:nth-child(5) { animation-delay: .24s; }
.container > *:nth-child(6) { animation-delay: .29s; }
.container > *:nth-child(7) { animation-delay: .34s; }
.container > *:nth-child(8) { animation-delay: .39s; }

/* ══════════════════════════════════
   CARDS
══════════════════════════════════ */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255,255,255,.4) 0%, transparent 60%);
  pointer-events: none;
}

/* ─── Grids ─── */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }

/* ══════════════════════════════════
   AUTH FORM
══════════════════════════════════ */
.auth-form {
  max-width: 440px;
  margin: 5rem auto;
  background: var(--surface);
  padding: 2.75rem 2.5rem;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  animation: scaleIn .45s cubic-bezier(.22,1,.36,1) both;
  position: relative;
  overflow: hidden;
}

.auth-form::after {
  content: '';
  position: absolute;
  top: -80px;
  right: -80px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(99,102,241,.08) 0%, transparent 70%);
  pointer-events: none;
}

.auth-form h1 {
  font-size: 1.65rem;
  font-weight: 800;
  margin-bottom: 2rem;
  letter-spacing: -.03em;
  color: var(--text-primary);
}

.auth-form p {
  margin-top: 1.25rem;
  text-align: center;
  font-size: .875rem;
  color: var(--text-muted);
}

.auth-form p a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.auth-form p a:hover { text-decoration: underline; }

/* ══════════════════════════════════
   FORM ELEMENTS
══════════════════════════════════ */
.form-group { margin-bottom: 1.15rem; }

.form-group label {
  display: block;
  margin-bottom: .4rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: .025em;
  text-transform: uppercase;
}

.form-group input {
  width: 100%;
  padding: .7rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
}

.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: #fafbff;
}

.form-group input:hover:not(:focus) {
  border-color: #c7d0e8;
}

/* ══════════════════════════════════
   BUTTONS
══════════════════════════════════ */
.btn {
  padding: .7rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .9rem;
  font-family: var(--font);
  font-weight: 600;
  letter-spacing: .015em;
  transition: all var(--transition);
  outline: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
}

.btn-primary {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: white;
  width: 100%;
  margin-top: .5rem;
  box-shadow: 0 4px 14px rgba(79,70,229,.35);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4338ca, #6d28d9);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(79,70,229,.45);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(79,70,229,.3);
}

/* ══════════════════════════════════
   ALERTS / BANNERS
══════════════════════════════════ */
.alert {
  padding: .9rem 1.15rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.15rem;
  font-size: .88rem;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: .55rem;
  animation: slideRight .3s cubic-bezier(.22,1,.36,1) both;
}

.alert-error {
  background: var(--danger-light);
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.alert-success {
  background: var(--success-light);
  color: #065f46;
  border: 1px solid #a7f3d0;
}

/* ══════════════════════════════════
   TABLES
══════════════════════════════════ */
table { width: 100%; border-collapse: collapse; }

th, td {
  padding: .8rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  font-size: .875rem;
}

thead tr {
  position: relative;
}

th {
  font-weight: 700;
  font-size: .72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  background: var(--surface-2);
  white-space: nowrap;
}

th:first-child { border-radius: var(--radius-sm) 0 0 0; }
th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }

tbody tr {
  transition: background var(--transition);
}

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

tbody tr:hover td {
  background: #f8f9ff;
}

/* ══════════════════════════════════
   BADGES
══════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .22rem .65rem;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .025em;
}

.badge-blue   { background: #eff6ff; color: #2563eb; }
.badge-green  { background: #ecfdf5; color: #059669; }
.badge-orange { background: #fffbeb; color: #b45309; }

/* ══════════════════════════════════
   TYPOGRAPHY
══════════════════════════════════ */
h1 {
  font-size: 1.55rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
  letter-spacing: -.03em;
  color: var(--text-primary);
  line-height: 1.25;
}

h2 {
  font-size: .95rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-secondary);
  letter-spacing: -.01em;
}

/* ══════════════════════════════════
   PAGE PROGRESS BAR
══════════════════════════════════ */
#nprogress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, #4f46e5, #8b5cf6, #ec4899);
  z-index: 9999;
  transition: width .3s ease;
  border-radius: 0 2px 2px 0;
}

/* ══════════════════════════════════
   STAT CARD ENHANCEMENTS
══════════════════════════════════ */
.stat-number {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

/* ══════════════════════════════════
   SELECT / INPUT OVERRIDES
══════════════════════════════════ */
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2.25rem !important;
  cursor: pointer;
  font-family: var(--font);
  color: var(--text-primary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  font-size: .875rem;
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

select:hover:not(:focus) { border-color: #c7d0e8; }

input[type="text"]:not(.form-group input),
input[type="search"]:not(.form-group input) {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .45rem .75rem;
  font-family: var(--font);
  font-size: .875rem;
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

input[type="text"]:not(.form-group input):focus,
input[type="search"]:not(.form-group input):focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ══════════════════════════════════
   TOOLTIPS / HOVER EFFECTS
══════════════════════════════════ */
[title] { cursor: help; }

/* ══════════════════════════════════
   LINK STYLES
══════════════════════════════════ */
a:not(.nav-brand):not(.nav-links a):not(.btn) {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:not(.nav-brand):not(.nav-links a):not(.btn):hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* ══════════════════════════════════
   LOADING SKELETON
══════════════════════════════════ */
@keyframes skeleton-wave {
  from { background-position: -200% 0; }
  to   { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, #f0f2f5 25%, #e8eaf0 50%, #f0f2f5 75%);
  background-size: 200% 100%;
  animation: skeleton-wave 1.5s infinite;
  border-radius: 6px;
}

/* ══════════════════════════════════
   CHART CONTAINER
══════════════════════════════════ */
[id$="-chart"],
[id$="-pie"],
[id$="-bar"] {
  transition: opacity .3s;
}

/* ══════════════════════════════════
   RESPONSIVE
══════════════════════════════════ */
@media (max-width: 1024px) {
  .container { padding: 1.5rem; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .container { padding: 1rem; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .navbar { padding: 0 1rem; }
  .nav-links a { padding: .3rem .5rem; font-size: .75rem; }
}

/* ══════════════════════════════════
   IMPORT PAGE OVERRIDES
══════════════════════════════════ */
.ea-submit-btn {
  background: linear-gradient(135deg, #0f172a, #1e293b) !important;
  transition: all var(--transition) !important;
}
.ea-submit-btn:hover {
  background: linear-gradient(135deg, #1e293b, #334155) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(15,23,42,.25) !important;
}

.ea-btn-sm {
  border-radius: var(--radius-sm) !important;
  font-family: var(--font) !important;
  transition: all var(--transition) !important;
}

/* ══════════════════════════════════
   SMOOTH FOCUS RING
══════════════════════════════════ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ══════════════════════════════════
   SELECTION
══════════════════════════════════ */
::selection {
  background: rgba(79,70,229,.15);
  color: var(--text-primary);
}
