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

:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: rgba(30, 30, 55, 0.7);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --border-glass: rgba(255, 255, 255, 0.08);
  --text-primary: #e8e8f0;
  --text-secondary: #9d9dba;
  --text-muted: #6b6b8a;
  --accent-primary: #6c5ce7;
  --accent-secondary: #a29bfe;
  --accent-glow: rgba(108, 92, 231, 0.3);
  --success: #00cec9;
  --danger: #fd79a8;
  --warning: #fdcb6e;
  --positive: #00b894;
  --negative: #e17055;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.4);
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== Background Animation ===== */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 20% 50%, rgba(108, 92, 231, 0.08) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 20%, rgba(162, 155, 254, 0.06) 0%, transparent 50%),
              radial-gradient(ellipse at 50% 80%, rgba(0, 206, 201, 0.04) 0%, transparent 50%);
  animation: bgFloat 20s ease-in-out infinite;
  z-index: -1;
}

@keyframes bgFloat {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(2%, -1%) rotate(1deg); }
  66% { transform: translate(-1%, 2%) rotate(-1deg); }
}

/* ===== Back Navigation ===== */
.nav-back {
  margin-bottom: 0.5rem;
}

.nav-back__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.nav-back__link:hover {
  color: var(--accent-secondary);
  background: rgba(108, 92, 231, 0.08);
}

.nav-back__link svg {
  transition: transform var(--transition-fast);
}

.nav-back__link:hover svg {
  transform: translateX(-3px);
}

/* ===== Container ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ===== Header ===== */
.header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.header__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-radius: var(--radius-lg);
  font-size: 1.8rem;
  margin-bottom: 1rem;
  box-shadow: 0 8px 32px var(--accent-glow);
  animation: iconPulse 3s ease-in-out infinite;
}

@keyframes iconPulse {
  0%, 100% { box-shadow: 0 8px 32px var(--accent-glow); transform: scale(1); }
  50% { box-shadow: 0 12px 40px rgba(108, 92, 231, 0.5); transform: scale(1.05); }
}

.header__title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
}

.header__subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 400;
}

/* ===== Drop Zone ===== */
.dropzone {
  position: relative;
  border: 2px dashed var(--border-glass);
  border-radius: var(--radius-xl);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow: hidden;
}

.dropzone::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.05), rgba(0, 206, 201, 0.03));
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--accent-primary);
  background: rgba(108, 92, 231, 0.06);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md), 0 0 60px var(--accent-glow);
}

.dropzone:hover::before,
.dropzone.drag-over::before {
  opacity: 1;
}

.dropzone__icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: block;
  animation: float 3s ease-in-out infinite;
}

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

.dropzone__text {
  font-size: 1.1rem;
  color: var(--text-primary);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.dropzone__hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.dropzone__input {
  display: none;
}

/* ===== File Info Bar ===== */
.file-info {
  display: none;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  margin-top: 1.5rem;
  animation: slideUp 0.4s var(--transition-slow);
}

.file-info.visible {
  display: flex;
}

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

.file-info__icon {
  font-size: 1.5rem;
}

.file-info__details {
  flex: 1;
}

.file-info__name {
  font-weight: 600;
  font-size: 0.95rem;
}

.file-info__meta {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 2px;
}

/* ===== Stats Bar ===== */
.stats {
  display: none;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.stats.visible {
  display: grid;
  animation: slideUp 0.4s var(--transition-slow);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-align: center;
  backdrop-filter: blur(12px);
  transition: transform var(--transition-fast);
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-card__value {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.stat-card__value--positive { color: var(--positive); }
.stat-card__value--negative { color: var(--negative); }
.stat-card__value--neutral { color: var(--accent-secondary); }

.stat-card__label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

/* ===== Toolbar ===== */
.toolbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.toolbar.visible {
  display: flex;
  animation: slideUp 0.3s ease;
}

.toolbar__search {
  position: relative;
  flex: 1;
  max-width: 320px;
}

.toolbar__search-input {
  width: 100%;
  padding: 0.6rem 1rem 0.6rem 2.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-fast);
}

.toolbar__search-input::placeholder { color: var(--text-muted); }
.toolbar__search-input:focus { border-color: var(--accent-primary); }

.toolbar__search-icon {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.toolbar__actions {
  display: flex;
  gap: 0.75rem;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn--primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(108, 92, 231, 0.5);
}

.btn--primary:active { transform: translateY(0); }

.btn--secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-glass);
}

.btn--secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent-primary);
}

/* ===== Table ===== */
.table-wrapper {
  display: none;
  overflow-x: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-md);
}

.table-wrapper.visible {
  display: block;
  animation: slideUp 0.5s var(--transition-slow);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table thead {
  background: rgba(108, 92, 231, 0.1);
  position: sticky;
  top: 0;
  z-index: 2;
}

.data-table th {
  padding: 0.9rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-secondary);
  border-bottom: 1px solid var(--border-glass);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
}

.data-table th:hover { color: var(--text-primary); }
.data-table th .sort-icon { margin-left: 0.3rem; opacity: 0.4; font-size: 0.7rem; }
.data-table th.sorted .sort-icon { opacity: 1; }

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  white-space: nowrap;
}

.data-table tbody tr { transition: background var(--transition-fast); }
.data-table tbody tr:hover { background: rgba(108, 92, 231, 0.06); }
.data-table tbody tr:last-child td { border-bottom: none; }

.value--positive { color: var(--positive); font-weight: 600; }
.value--negative { color: var(--negative); font-weight: 600; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge--credit { background: rgba(0, 184, 148, 0.15); color: var(--positive); }
.badge--debit { background: rgba(225, 112, 85, 0.15); color: var(--negative); }
.badge--other { background: rgba(162, 155, 254, 0.15); color: var(--accent-secondary); }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state__icon { font-size: 2.5rem; margin-bottom: 1rem; opacity: 0.5; }

/* ===== Loading Spinner ===== */
.spinner { display: none; text-align: center; padding: 2rem; }
.spinner.visible { display: block; }

.spinner__circle {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-glass);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.8s linear infinite;
}

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

.spinner__text { color: var(--text-muted); font-size: 0.9rem; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 0.8rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
}

.toast.visible { transform: translateY(0); opacity: 1; }
.toast--success { border-left: 3px solid var(--success); }
.toast--error { border-left: 3px solid var(--danger); }

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 2rem 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 2rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .container { padding: 1.25rem 1rem; }
  .header__title { font-size: 1.5rem; }
  .dropzone { padding: 2rem 1.5rem; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar__search { max-width: none; }
  .data-table { font-size: 0.82rem; }
  .data-table th, .data-table td { padding: 0.6rem 0.75rem; }
}
