:root {
  --bg: #eef6ff;
  --bg-strong: #d9ecff;
  --ink: #0b2545;
  --muted: #55708e;
  --line: #c7dcf2;
  --panel: #ffffff;
  --primary: #1266f1;
  --primary-dark: #0849ad;
  --primary-soft: #e6f0ff;
  --accent: #38bdf8;
  --good: #0f7b6c;
  --bad: #c7354b;
  --shadow: 0 18px 45px rgba(16, 89, 166, 0.11);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(18, 102, 241, 0.10), rgba(238, 246, 255, 0.2) 280px),
    var(--bg);
  font-family: Arial, Helvetica, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  min-height: 86px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(16, 89, 166, 0.08);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
}

.menu-details {
  position: relative;
}

.menu-details summary {
  list-style: none;
}

.menu-details summary::-webkit-details-marker {
  display: none;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 22px;
  width: 100%;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  color: #073b7a;
  font-size: 28px;
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 10px 22px rgba(18, 102, 241, 0.24);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-pill {
  margin-left: auto;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--primary-dark);
  background: rgba(255, 255, 255, 0.82);
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(16, 89, 166, 0.07);
}

.menu-panel {
  position: fixed;
  top: 86px;
  left: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(320px, calc(100vw - 28px));
  height: calc(100vh - 86px);
  padding: 22px;
  background:
    linear-gradient(180deg, #f7fbff, #ffffff),
    #fff;
  border-right: 1px solid var(--line);
  box-shadow: 18px 0 38px rgba(16, 89, 166, 0.16);
  transform: translateX(-105%);
  transition: transform 190ms ease;
}

.menu-details[open] .menu-panel {
  transform: translateX(0);
}

.menu-panel a,
.logout button,
.filters button,
button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  color: #0b4f9c;
  min-height: 38px;
  padding: 8px 14px;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.menu-panel a {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 48px;
}

.menu-panel a:hover,
.logout button:hover,
.filters button:hover,
button:hover {
  border-color: #9cc6f5;
  background: var(--primary-soft);
  transform: translateY(-1px);
}

.menu-panel a.active,
.primary {
  color: #fff;
  border-color: var(--primary);
  background: linear-gradient(135deg, var(--primary), #0ea5e9);
  box-shadow: 0 12px 22px rgba(18, 102, 241, 0.20);
}

.primary:hover { background: var(--primary-dark); }

.menu-toggle {
  display: inline-flex;
  width: 58px;
  height: 58px;
  padding: 12px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  position: relative;
  z-index: 50;
}

.menu-toggle span {
  display: block;
  width: 21px;
  height: 3px;
  border-radius: 999px;
  background: #0b4f9c;
  transition: transform 180ms ease, opacity 180ms ease;
}

.menu-details[open] .menu-toggle span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.menu-details[open] .menu-toggle span:nth-child(2) {
  opacity: 0;
}

.menu-details[open] .menu-toggle span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.logout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 32px auto 52px;
}

.login-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 48px;
  align-items: center;
  min-height: calc(100vh - 160px);
}

h1, h2 { margin: 0; line-height: 1.15; }
h1 { font-size: clamp(32px, 4vw, 52px); }
h2 { font-size: 20px; margin-bottom: 18px; }
.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}
.muted { color: var(--muted); font-size: 18px; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 22px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.metrics,
.grid {
  display: grid;
  gap: 18px;
}

.metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.metrics article,
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metrics article {
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(230, 240, 255, 0.86), rgba(255, 255, 255, 0.94)),
    var(--panel);
}
.metrics span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}
.metrics strong { font-size: 26px; }
.good { color: var(--good); }
.bad { color: var(--bad); }

.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { padding: 20px; overflow-x: auto; }

.chart-legend {
  display: flex;
  gap: 14px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin: -6px 0 10px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend i {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.legend-budget { background: var(--primary); }
.legend-expenses { background: var(--accent); }

.table-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--primary-dark);
  background: rgba(255, 255, 255, 0.86);
  text-decoration: none;
  font-weight: 800;
}

.table-action:hover,
.secondary-action:hover {
  border-color: #9cc6f5;
  background: var(--primary-soft);
}

.form-stack {
  display: grid;
  gap: 14px;
  align-content: start;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 650;
}

input, select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafdff;
  color: var(--ink);
  padding: 8px 10px;
  font: inherit;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
}
.check input { width: 18px; min-height: 18px; }

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

th, td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: #376896;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
}
.num { text-align: right; white-space: nowrap; }
.empty { color: var(--muted); text-align: center; }

.flash {
  margin-bottom: 18px;
  border-radius: 8px;
  padding: 12px 14px;
  background: #e7f1ff;
  color: #0b4f9c;
  border: 1px solid #b8d7fb;
}
.flash.error {
  background: #fff1ef;
  color: #9d2f22;
  border-color: #f3c4bd;
}

canvas {
  width: 100%;
  display: block;
}

@media (max-width: 820px) {
  .topbar {
    align-items: center;
    flex-direction: row;
    min-height: 76px;
    padding: 10px 16px;
  }
  .brand { font-size: 22px; }
  .brand-row { gap: 14px; }
  .brand-mark {
    width: 34px;
    height: 34px;
  }
  .user-pill {
    min-height: 38px;
    padding: 6px 12px;
    font-size: 15px;
  }
  .menu-toggle {
    width: 50px;
    height: 50px;
  }
  .menu-panel {
    top: 76px;
    height: calc(100vh - 76px);
  }
  .login-panel,
  .grid.two,
  .metrics { grid-template-columns: 1fr; }
  .section-head { align-items: stretch; flex-direction: column; }
}
