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

body {
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  transition: background 0.3s, color 0.3s;
}

/* ── THEME VARIABLES ── */
body.dark {
  --bg:      #0d0f14;
  --surface: #13161d;
  --card:    #1a1e28;
  --border:  #252a38;
  --text:    #e8ecf5;
  --muted:   #5a6380;
  --accent:  #34d399;
}

body.light {
  --bg:      #f0f4fa;
  --surface: #e4eaf5;
  --card:    #ffffff;
  --border:  #d0d8ea;
  --text:    #1a1e28;
  --muted:   #7a85a0;
  --accent:  #059669;
}

/* ── LAYOUT ── */
.app {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

/* ── UTILITY ── */
.hidden {
  display: none !important;
}

/* SIDEBAR*/
.sidebar {
  width: 220px;
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 36px;
  padding-left: 4px;
}

.logo-icon {
  font-size: 22px;
  color: var(--accent);
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

/* Nav */
.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--card);
  color: var(--text);
}

.nav-item.active {
  background: rgba(52, 211, 153, 0.08);
  color: var(--accent);
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

/* Sidebar bottom controls */
.sidebar-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.role-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.role-label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.role-select {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  transition: all 0.2s;
  text-align: left;
}

.theme-toggle:hover {
  color: var(--text);
}

/* MAIN AREA*/
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px 20px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
  border-bottom: 1px solid var(--border);
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.page-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #34d399, #60a5fa);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #0d0f14;
}

/* Page content wrapper */
.content {
  padding: 24px 32px;
  flex: 1;
  overflow-y: auto;
  animation: fadeIn 0.35s ease;
}

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

/* CARDS*/
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}

/* Summary cards grid */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.summary-card {
  position: relative;
  overflow: hidden;
}

/* Left color accent bar */
.summary-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--accent);
  border-radius: 3px 0 0 3px;
}

.card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.card-icon {
  font-size: 16px;
  color: var(--accent);
}

.card-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.card-value {
  font-size: 26px;
  font-weight: 700;
  font-family: 'DM Mono', monospace;
  letter-spacing: -1px;
}

.card-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

/*  CHARTS */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.chart-card {
  padding: 20px;
}

.chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}

/* TRANSACTIONS PAGE*/

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

.search-input,
.filter-select {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.search-input {
  flex: 1;
  min-width: 160px;
}

.search-input:focus,
.filter-select:focus {
  border-color: var(--accent);
}

.sort-dir-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.sort-dir-btn:hover {
  border-color: var(--accent);
}

/* Table */
.tx-table-wrap {
  padding: 0;
  overflow: hidden;
}

.tx-table {
  width: 100%;
  border-collapse: collapse;
}

.tx-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.tx-row {
  transition: background 0.15s;
}

.tx-row:hover {
  background: var(--surface);
}

.tx-row td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(37, 42, 56, 0.5);
  vertical-align: middle;
}

.tx-row:last-child td {
  border-bottom: none;
}

.tx-date {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--muted);
}

.tx-note {
  color: var(--muted);
  max-width: 200px;
}

.tx-amount {
  font-family: 'DM Mono', monospace;
  font-weight: 600;
}

.tx-amount.income  { color: #34d399; }
.tx-amount.expense { color: #f87171; }

/* Category pill */
.cat-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

/* Type pill */
.type-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}

.type-pill.income  { background: rgba(52,211,153,0.13); color: #34d399; }
.type-pill.expense { background: rgba(248,113,113,0.13); color: #f87171; }

/* Action buttons */
.tx-actions {
  display: flex;
  gap: 6px;
}

.action-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.action-btn.edit { color: #60a5fa; }
.action-btn.edit:hover { background: rgba(96,165,250,0.13); border-color: #60a5fa; }

.action-btn.del  { color: #f87171; }
.action-btn.del:hover  { background: rgba(248,113,113,0.13); border-color: #f87171; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.empty-icon {
  font-size: 40px;
  margin-bottom: 8px;
  opacity: 0.4;
}

.empty-sub {
  font-size: 12px;
}

/* INSIGHTS PAGE*/
.insights-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.insight-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.insight-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.insight-title {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 4px;
}

.insight-value {
  font-size: 22px;
  font-weight: 700;
  font-family: 'DM Mono', monospace;
  letter-spacing: -0.5px;
}

.insight-desc {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* BUTTONS*/
.btn-primary {
  background: var(--accent);
  color: #0d0f14;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-primary:hover {
  opacity: 0.85;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--text);
}

/* MODAL*/
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.modal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  width: 480px;
  max-width: 95vw;
  position: relative;
  animation: fadeIn 0.2s ease;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
}

/* Form grid inside modal */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full-span {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.form-input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--accent);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

/* RESPONSIVE*/
@media (max-width: 900px) {
  .sidebar {
    width: 64px;
    padding: 16px 8px;
  }

  .logo-text,
  .nav-label,
  .role-label,
  .role-box .role-select,
  .theme-toggle {
    display: none;
  }

  .logo        { justify-content: center; }
  .nav-item    { justify-content: center; padding: 10px; }
  .charts-row  { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1fr; }
  .insights-grid { grid-template-columns: 1fr; }
  .content     { padding: 16px; }
  .topbar      { padding: 16px; }
}

@media (max-width: 600px) {
  .filters-bar   { flex-direction: column; }
  .search-input,
  .filter-select { width: 100%; }
}
