:root {
  --bg: #f3f6f4;
  --surface: #ffffff;
  --ink: #161616;
  --muted: #6f7782;
  --line: #dde2e8;
  --green: #1f7a5c;
  --red: #bc4b51;
  --blue: #2563eb;
  --amber: #d88c28;
  --charcoal: #202124;
  --teal: #0f8b8d;
  --shadow: 0 20px 60px rgba(26, 32, 44, 0.09);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background:
    radial-gradient(circle at top right, rgba(31, 122, 92, 0.10), transparent 26rem),
    linear-gradient(180deg, #f8faf8 0%, var(--bg) 48%, #eef3f0 100%);
  color: var(--ink);
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
svg { width: 18px; height: 18px; fill: currentColor; flex: 0 0 auto; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 252px;
  background: var(--charcoal);
  color: #f7f8fa;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand > span:last-child { min-width: 0; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #d6f46c;
  color: #121212;
  font-weight: 800;
}
.brand strong, .brand small { display: block; }
.brand small { color: #aeb4bd; font-size: 12px; margin-top: 2px; }
.nav { display: grid; gap: 6px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  color: #cfd4dc;
  border-radius: 8px;
}
.nav a.active, .nav a:hover { background: #303235; color: #ffffff; }
.nav-emoji { margin-left: auto; font-size: 14px; }
.sidebar-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid #3d4045;
  border-radius: 8px;
  color: #cfd4dc;
}
.sidebar-note span, .sidebar-note strong { display: block; }
.sidebar-note span { font-size: 12px; color: #9aa1aa; }

.shell { margin-left: 252px; padding: 34px; max-width: 1320px; }
.page-head {
  min-height: 76px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 22px;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 800;
}
h1, h2 { margin: 0; letter-spacing: -0.03em; }
h1 { font-size: clamp(30px, 4vw, 46px); line-height: 1.05; }
h2 { font-size: 18px; }

.status-pill, .period-select {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 9px 13px;
  color: var(--muted);
  box-shadow: var(--shadow);
}
.status-pill { display: flex; gap: 9px; align-items: center; }
.status-pill span { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }

.metrics-grid, .analytics-grid, .overview-grid, .categories-grid {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}
.metrics-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.overview-grid, .analytics-grid, .categories-grid { grid-template-columns: minmax(0, 1fr) minmax(360px, 0.85fr); }

.metric, .panel, .empty-state, .hero-panel, .snapshot-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.hero-panel {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 150px;
  padding: 24px;
  margin-bottom: 18px;
  color: #f8faf8;
  background:
    linear-gradient(135deg, rgba(22, 22, 22, 0.97), rgba(28, 68, 64, 0.94)),
    radial-gradient(circle at 85% 20%, rgba(214, 244, 108, 0.35), transparent 19rem);
  border-color: #2e3c37;
}
.hero-panel::after {
  content: "💸";
  position: absolute;
  right: 24px;
  bottom: -18px;
  font-size: 90px;
  opacity: 0.12;
  pointer-events: none;
}
.hero-panel.compact { min-height: 118px; }
.hero-panel h2 { font-size: 28px; max-width: 720px; }
.hero-panel p:not(.eyebrow) { margin: 8px 0 0; color: #d2dbd7; max-width: 740px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; position: relative; z-index: 1; }
.hero-panel .button { border-color: rgba(255, 255, 255, 0.2); }
.hero-panel .button:not(.primary) { background: rgba(255, 255, 255, 0.09); color: #ffffff; }
.hero-panel .button.primary { background: #d6f46c; color: #151515; border-color: #d6f46c; }

.metric {
  position: relative;
  overflow: hidden;
  padding: 22px;
  display: grid;
  gap: 8px;
}
.metric::after {
  content: "";
  position: absolute;
  inset: auto 16px 16px auto;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  opacity: 0.12;
}
.metric.income::after { background: var(--green); }
.metric.expense::after { background: var(--red); }
.metric.net::after { background: var(--blue); }
.metric > * { position: relative; z-index: 1; }
.metric span, .panel-head span, label { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.metric strong { font-size: 31px; letter-spacing: -0.04em; }
.metric small { color: var(--muted); }
.metric.income { border-top: 4px solid var(--green); }
.metric.expense { border-top: 4px solid var(--red); }
.metric.net { border-top: 4px solid var(--blue); }

.panel { padding: 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.panel-head a { color: var(--blue); font-weight: 700; }
.empty-state {
  padding: 24px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 18px;
  border-left: 5px solid var(--green);
}
.empty-state p:last-child { color: var(--muted); max-width: 620px; }
.hidden { display: none !important; }

.snapshot-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}
.snapshot-card {
  padding: 17px;
  display: grid;
  gap: 6px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
}
.snapshot-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.snapshot-card strong { font-size: 17px; }
.snapshot-card small { color: var(--muted); }

form { display: grid; gap: 14px; }
.field-row, .filters { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.filters { grid-template-columns: 1.4fr 0.8fr 1fr 0.9fr 0.9fr auto; align-items: end; }
label { display: grid; gap: 7px; }
input, select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--ink);
  background: #fbfcfd;
  font: inherit;
}
input:focus, select:focus { outline: 2px solid rgba(37, 99, 235, 0.18); border-color: var(--blue); }
.button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 9px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  cursor: pointer;
}
.button.primary { background: var(--ink); color: #ffffff; border-color: var(--ink); }
.button.danger { color: var(--red); }
.button.small { min-height: 34px; padding: 6px 10px; font-size: 12px; }
.button:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(26, 32, 44, 0.10); }

.activity-list, .budget-list, .category-list, .bar-list { display: grid; gap: 10px; }
.activity-item, .budget-item, .category-item, .bar-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}
.activity-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}
.activity-item strong, .category-item strong { display: block; }
.activity-item small, .category-item small { color: var(--muted); }
.activity-emoji, .type-badge {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #eef5f1;
}
.type-badge {
  width: auto;
  min-width: 84px;
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 900;
}
.type-badge.income { color: var(--green); background: #e8f5ee; }
.type-badge.expense { color: var(--red); background: #fff0ef; }
.color-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: 1px;
}
.amount-income { color: var(--green); font-weight: 900; }
.amount-expense { color: var(--red); font-weight: 900; }
.budget-bar, .bar-track, .cash-track { height: 9px; background: #e8edf2; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.budget-bar span, .bar-track span, .cash-track span { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.budget-item.over .budget-bar span { background: var(--red); }
.budget-item.warn .budget-bar span { background: var(--amber); }
.budget-item header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.budget-item small { color: var(--muted); display: block; margin-top: 8px; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 860px; }
th, td { padding: 14px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
tbody tr:hover { background: #fbfcfd; }
.num { text-align: right; }
.row-actions { display: flex; justify-content: flex-end; gap: 8px; }
.inline-empty { padding: 24px; color: var(--muted); text-align: center; }
.filter-hints {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding-top: 12px;
  color: var(--muted);
}

.bar-row header, .category-item header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.bar-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 6px; }
.cashflow-chart { display: grid; gap: 10px; }
.cash-row { display: grid; grid-template-columns: 92px 1fr 1fr 110px; gap: 10px; align-items: center; }
.cash-track.income span { background: var(--green); }
.cash-track.expense span { background: var(--red); }
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 32px));
  padding: 13px 16px;
  border-radius: 8px;
  color: #ffffff;
  background: #161616;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.20);
  font-weight: 800;
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.toast.info { background: var(--charcoal); }

@media (max-width: 980px) {
  .sidebar { position: static; width: auto; border-radius: 0; }
  .shell { margin-left: 0; padding: 22px; }
  .metrics-grid, .overview-grid, .analytics-grid, .categories-grid, .filters, .snapshot-grid { grid-template-columns: 1fr; }
  .hero-panel { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 620px) {
  .shell { padding: 18px; }
  .page-head, .empty-state { flex-direction: column; align-items: stretch; }
  .field-row { grid-template-columns: 1fr; }
  .metric strong { font-size: 25px; }
  .filter-hints { align-items: stretch; flex-direction: column; }
  .activity-item { grid-template-columns: auto 1fr; }
  .activity-item > span:last-child { grid-column: 2; }
  .cash-row { grid-template-columns: 64px 1fr; }
  .cash-row .cash-track.expense, .cash-row span:last-child { grid-column: 2; }
}
