/* ============ RESET & BASE ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: #f8fafc;
  color: #0f172a;
  line-height: 1.5;
}
a { text-decoration: none; }

/* ============ LAYOUT ============ */
.layout { display: flex; min-height: 100vh; }

/* ============ SIDEBAR ============ */
.sidebar {
  width: 240px;
  background: #1e293b;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.sidebar-logo h1 {
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-logo p { color: #64748b; font-size: 12px; margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 12px 10px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: all 0.15s;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #e2e8f0; }
.nav-item.active { background: rgba(14,165,233,0.15); color: #38bdf8; }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.sidebar-user { color: #475569; font-size: 12px; margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-btn { background: none; border: none; color: #475569; font-size: 13px; cursor: pointer; padding: 0; transition: color 0.15s; }
.logout-btn:hover { color: #e2e8f0; }

/* ============ MAIN ============ */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.page-header {
  padding: 28px 32px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}
.page-header h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
.page-header p { color: #64748b; font-size: 13px; margin-top: 3px; }
.page-content { padding: 24px 32px 48px; flex: 1; }

/* ============ CARDS ============ */
.card { background: white; border-radius: 12px; border: 1px solid #e2e8f0; padding: 20px; }
.card-title { font-size: 11px; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.7px; margin-bottom: 14px; }

/* ============ STAT CARDS ============ */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: white; border-radius: 12px; border: 1px solid #e2e8f0; padding: 18px 20px; }
.stat-label { font-size: 11px; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.6px; }
.stat-value { font-size: 24px; font-weight: 800; margin-top: 6px; letter-spacing: -0.5px; line-height: 1.2; }
.stat-sub { font-size: 12px; color: #94a3b8; margin-top: 4px; }
.text-green { color: #10b981; }
.text-red { color: #ef4444; }
.text-blue { color: #0ea5e9; }
.text-amber { color: #f59e0b; }
.text-muted { color: #64748b; }

/* ============ GRID LAYOUTS ============ */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.grid-equal { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ============ TABLES ============ */
.table-wrap { overflow-x: auto; background: white; border-radius: 12px; border: 1px solid #e2e8f0; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 11px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
tbody td { padding: 11px 16px; font-size: 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafafa; }
.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ============ BADGES ============ */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: 0.3px; }
.badge-asset { background: #dcfce7; color: #166534; }
.badge-liability { background: #fee2e2; color: #991b1b; }
.badge-income { background: #dbeafe; color: #1e40af; }
.badge-expense { background: #fef9c3; color: #854d0e; }

/* ============ COLOR DOT ============ */
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; display: inline-block; }

/* ============ FORMS ============ */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { margin-bottom: 14px; }
label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 5px; }
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  background: white;
  color: #0f172a;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14,165,233,0.1);
}
.input-with-prefix { display: flex; align-items: stretch; }
.input-prefix {
  padding: 9px 11px;
  background: #f8fafc;
  border: 1px solid #d1d5db;
  border-right: none;
  border-radius: 8px 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  display: flex;
  align-items: center;
  white-space: nowrap;
}
.input-with-prefix input { border-radius: 0 8px 8px 0; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary { background: #0ea5e9; color: white; }
.btn-primary:hover { background: #0284c7; }
.btn-success { background: #10b981; color: white; }
.btn-success:hover { background: #059669; }
.btn-secondary { background: #f1f5f9; color: #374151; border: 1px solid #e2e8f0; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 6px 13px; font-size: 13px; }
.btn-icon {
  width: 30px; height: 30px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; border: none; cursor: pointer;
  background: none; color: #94a3b8; transition: all 0.15s;
}
.btn-icon:hover { background: #f1f5f9; color: #374151; }
.btn-icon svg { width: 14px; height: 14px; }

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 20px;
}
.modal { background: white; border-radius: 16px; padding: 24px; width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; color: #94a3b8; padding: 4px; border-radius: 4px; display: flex; }
.modal-close:hover { color: #0f172a; background: #f1f5f9; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid #f1f5f9; }

/* ============ ALERTS ============ */
.alert { padding: 11px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-info { background: #dbeafe; color: #1e40af; }

/* ============ LOGIN PAGE ============ */
.login-page {
  min-height: 100vh;
  background: #1e293b;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card { background: white; border-radius: 20px; padding: 40px; width: 100%; max-width: 380px; }
.login-logo { text-align: center; margin-bottom: 30px; }
.login-logo-icon {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, #0ea5e9 0%, #6366f1 100%);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
  font-size: 28px;
}
.login-logo h1 { font-size: 22px; font-weight: 800; }
.login-logo p { color: #64748b; font-size: 13px; margin-top: 4px; }

/* ============ ENTRY PAGE ============ */
.entry-rates-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 24px;
}
.entry-rates-title { font-size: 12px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.entry-rates-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.entry-section { margin-bottom: 20px; }
.entry-section-header {
  display: flex; align-items: center; gap: 8px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 10px;
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: #64748b;
}
.entry-item-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: 7px;
  background: white;
  transition: border-color 0.15s;
}
.entry-item-row:hover { border-color: #cbd5e1; }
.entry-item-info { flex: 1; min-width: 0; }
.entry-item-name { font-size: 14px; font-weight: 600; }
.entry-item-cat { font-size: 11px; color: #94a3b8; }
.entry-item-value { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.currency-tag { font-size: 12px; font-weight: 700; color: #94a3b8; min-width: 26px; text-align: right; }
.entry-item-value input { width: 140px; text-align: right; font-weight: 600; }

/* ============ COLOR PICKER ============ */
.color-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.color-swatch {
  width: 26px; height: 26px; border-radius: 50%;
  cursor: pointer; border: 3px solid transparent;
  transition: transform 0.1s;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: #1e293b; transform: scale(1.15); }

/* ============ CHART ============ */
.chart-wrap { position: relative; height: 280px; }

/* ============ TREND CONTROLS ============ */
.trend-header { display: flex; align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-bottom: 20px; }
.range-tabs { display: flex; gap: 3px; background: #f1f5f9; padding: 3px; border-radius: 9px; }
.range-tab {
  padding: 5px 14px; border-radius: 6px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; background: none; color: #64748b; transition: all 0.15s;
}
.range-tab.active { background: white; color: #0f172a; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.item-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.item-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 20px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: 2px solid #e2e8f0; background: white;
  transition: all 0.15s; user-select: none;
}
.item-chip:hover { border-color: #94a3b8; }
.item-chip.active { border-color: transparent !important; color: white; }
.item-chip.active .chip-dot { opacity: 0.8; }
.chip-dot { width: 8px; height: 8px; border-radius: 50%; }

/* ============ ENTRY HISTORY ============ */
.history-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border: 1px solid #e2e8f0; border-radius: 10px; margin-bottom: 8px;
  background: white; transition: all 0.15s; cursor: pointer;
}
.history-item:hover { border-color: #0ea5e9; background: #f0f9ff; }
.history-date { font-weight: 700; font-size: 14px; }
.history-sub { font-size: 12px; color: #94a3b8; margin-top: 2px; }
.history-net { font-weight: 700; font-size: 16px; }

/* ============ EMPTY STATE ============ */
.empty-state { text-align: center; padding: 48px 24px; color: #94a3b8; }
.empty-state-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; margin-bottom: 16px; }

/* ============ DIVIDER ============ */
.section-gap { margin-bottom: 24px; }

/* ============ CURRENCY SWITCHER ============ */
.cur-switcher {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 10px;
}
.cur-btn {
  flex: 1;
  padding: 5px 4px;
  border: none;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  background: none;
  color: #64748b;
  transition: all 0.15s;
  letter-spacing: 0.3px;
}
.cur-btn:hover { color: #94a3b8; background: rgba(255,255,255,0.06); }
.cur-btn.active { background: #0ea5e9; color: white; }

.rate-badge {
  font-size: 11px;
  color: #475569;
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .page-header, .page-content { padding-left: 20px; padding-right: 20px; }
}
@media (max-width: 700px) {
  .sidebar { display: none; }
  .page-header { padding-top: 20px; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .entry-rates-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
}
