* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", sans-serif;
  background: #0f1117;
  color: #e1e4e8;
  min-height: 100vh;
}

/* ---- PAGES ---- */
.page { display: none; }
.page.active { display: flex; }

/* ---- LOGIN ---- */
#login-page {
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f1117 0%, #1a1d29 100%);
}

.login-container {
  background: #1c1f2e;
  padding: 40px;
  border-radius: 16px;
  width: 400px;
  text-align: center;
  border: 1px solid #2a2d3a;
}

.login-container h1 {
  font-size: 28px;
  margin-bottom: 6px;
}

.subtitle {
  color: #8b8fa3;
  margin-bottom: 28px;
  font-size: 14px;
}

form input, form select, form textarea {
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 14px;
  border-radius: 10px;
  border: 1px solid #2a2d3a;
  background: #12141f;
  color: #e1e4e8;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

form input:focus, form select:focus, form textarea:focus {
  border-color: #6c5ce7;
}

form button[type="submit"], .btn-primary {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #6c5ce7, #a855f7);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

form button[type="submit"]:hover, .btn-primary:hover {
  opacity: 0.9;
}

.error {
  color: #ff6b6b;
  font-size: 13px;
  margin-top: 8px;
}

.success {
  color: #00b894;
  font-size: 13px;
  margin-top: 8px;
}

.switch-text {
  margin-top: 16px;
  font-size: 13px;
  color: #8b8fa3;
}

.switch-text a {
  color: #a78bfa;
  text-decoration: none;
  font-weight: 600;
}

.switch-text a:hover {
  text-decoration: underline;
}

.test-accounts {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #2a2d3a;
}

.test-accounts p {
  font-size: 13px;
  color: #8b8fa3;
  margin-bottom: 10px;
}

.quick-login {
  padding: 8px 18px;
  margin: 4px;
  border: 1px solid #2a2d3a;
  background: #12141f;
  color: #a78bfa;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: background 0.2s;
}

.quick-login:hover {
  background: #1e2035;
}

/* ---- DASHBOARD LAYOUT ---- */
#dashboard-page {
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: #1c1f2e;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #2a2d3a;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.sidebar-header h2 {
  font-size: 18px;
}

.role-badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
  text-transform: uppercase;
}

.role-badge.admin { background: #ff6b6b22; color: #ff6b6b; }
.role-badge.analyst { background: #feca5722; color: #feca57; }
.role-badge.viewer { background: #48dbfb22; color: #48dbfb; }

.sidebar-user {
  display: flex;
  flex-direction: column;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid #2a2d3a;
  font-size: 14px;
}

.text-muted {
  color: #8b8fa3;
  font-size: 12px;
  margin-top: 2px;
}

.nav-links {
  list-style: none;
  flex: 1;
}

.nav-link {
  display: block;
  padding: 10px 14px;
  color: #8b8fa3;
  text-decoration: none;
  border-radius: 8px;
  margin-bottom: 4px;
  font-size: 14px;
  transition: all 0.2s;
}

.nav-link:hover, .nav-link.active {
  background: #6c5ce722;
  color: #a78bfa;
}

.logout-btn {
  padding: 10px;
  border: 1px solid #ff6b6b44;
  background: transparent;
  color: #ff6b6b;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  transition: background 0.2s;
}

.logout-btn:hover {
  background: #ff6b6b11;
}

/* ---- MAIN CONTENT ---- */
.main-content {
  margin-left: 240px;
  padding: 32px;
  flex: 1;
  min-height: 100vh;
}

.tab { display: none; }
.tab.active { display: block; }

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

.tab h2 {
  margin-bottom: 20px;
}

/* ---- STATS CARDS ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: #1c1f2e;
  padding: 24px;
  border-radius: 14px;
  border: 1px solid #2a2d3a;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-label {
  font-size: 13px;
  color: #8b8fa3;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
}

.stat-card.income .stat-value { color: #00b894; }
.stat-card.expense .stat-value { color: #ff6b6b; }
.stat-card.balance .stat-value { color: #a78bfa; }
.stat-card.count .stat-value { color: #feca57; }

.chart-container {
  max-width: 220px;
  margin: 0 auto 16px;
}

.chart-container.chart-bar {
  max-width: 100%;
  height: 220px;
}

/* ---- DASHBOARD GRID ---- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.card {
  background: #1c1f2e;
  padding: 24px;
  border-radius: 14px;
  border: 1px solid #2a2d3a;
}

.card h3 {
  margin-bottom: 16px;
  font-size: 16px;
}

/* Category breakdown */
.category-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #2a2d3a;
  font-size: 14px;
}

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

.category-bar {
  height: 6px;
  background: #6c5ce7;
  border-radius: 3px;
  margin-top: 4px;
  transition: width 0.5s ease;
}

.category-name {
  flex: 1;
}

.category-amount {
  font-weight: 600;
  margin-right: 12px;
}

.category-pct {
  color: #8b8fa3;
  font-size: 12px;
  width: 50px;
  text-align: right;
}

/* Trends */
.trend-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #2a2d3a;
  font-size: 14px;
}

.trend-item:last-child { border-bottom: none; }
.trend-income { color: #00b894; }
.trend-expense { color: #ff6b6b; }

/* Recent activity */
.recent-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #2a2d3a;
  font-size: 14px;
}

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

.recent-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.recent-desc {
  color: #8b8fa3;
  font-size: 12px;
}

.recent-amount.income { color: #00b894; }
.recent-amount.expense { color: #ff6b6b; }

/* ---- FILTERS ---- */
.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.filters select, .filters input {
  padding: 10px 14px;
  border: 1px solid #2a2d3a;
  background: #12141f;
  color: #e1e4e8;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
}

.btn-secondary {
  padding: 10px 20px;
  background: #6c5ce7;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}

.btn-ghost {
  padding: 10px 20px;
  background: transparent;
  color: #8b8fa3;
  border: 1px solid #2a2d3a;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}

/* ---- TABLE ---- */
.records-table {
  width: 100%;
  border-collapse: collapse;
}

.records-table th {
  text-align: left;
  padding: 12px 16px;
  background: #1c1f2e;
  color: #8b8fa3;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #2a2d3a;
}

.records-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #1c1f2e;
  font-size: 14px;
}

.records-table tr:hover {
  background: #1c1f2e44;
}

.type-badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 600;
}

.type-badge.income { background: #00b89422; color: #00b894; }
.type-badge.expense { background: #ff6b6b22; color: #ff6b6b; }

.status-active { color: #00b894; }
.status-inactive { color: #ff6b6b; }

.btn-sm {
  padding: 6px 12px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  margin-right: 4px;
}

.btn-edit {
  background: #feca5733;
  color: #feca57;
}

.btn-delete {
  background: #ff6b6b22;
  color: #ff6b6b;
}

.btn-role {
  background: #6c5ce722;
  color: #a78bfa;
}

/* ---- PAGINATION ---- */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

.pagination button {
  padding: 8px 14px;
  background: #1c1f2e;
  border: 1px solid #2a2d3a;
  color: #e1e4e8;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}

.pagination button.active {
  background: #6c5ce7;
  border-color: #6c5ce7;
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ---- MODAL ---- */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: #1c1f2e;
  padding: 32px;
  border-radius: 16px;
  width: 440px;
  border: 1px solid #2a2d3a;
}

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

.modal-close {
  background: none;
  border: none;
  color: #8b8fa3;
  font-size: 24px;
  cursor: pointer;
}

/* ---- TOAST ---- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 24px;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  z-index: 200;
  animation: slideIn 0.3s ease;
}

.toast.success { background: #00b894; color: white; }
.toast.error { background: #ff6b6b; color: white; }

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

/* ---- LOADING OVERLAY ---- */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 17, 23, 0.85);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 300;
  gap: 16px;
  color: #a78bfa;
  font-size: 14px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #2a2d3a;
  border-top: 3px solid #a78bfa;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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