:root {
  --ink: #17241e;
  --muted: #6c7b72;
  --line: #e2e7e3;
  --green: #1f6749;
  --lime: #dff18a;
  --rev: #1f6749;
  --exp: #d98c22;
  --page: #f7f8f4;
  --surface: #ffffff;
  --donut-c1: #1f6046;
  --donut-c2: #4f9c6d;
  --donut-c3: #93b86a;
  --donut-c4: #d2df8e;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  height: 72px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 34px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; }
.brand a { display: flex; }
.logo { height: 34px; width: auto; display: block; }
.period { border: 1px solid var(--line); background: var(--surface); padding: 10px 13px; border-radius: 9px; color: #46534c; }
.avatar { border: 0; background: #dfeadd; width: 38px; height: 38px; border-radius: 50%; color: #28513b; font-weight: 700; margin-left: 4px; }
.topbarRight { display: flex; align-items: center; gap: 14px; }
.inlineForm { display: flex; margin: 0; }
.navLink { color: #46534c; text-decoration: none; font-size: 13px; font-weight: 700; padding: 8px 4px; }
.navLink:hover { color: var(--ink); }
.userName { font-size: 13px; color: #46534c; }

.layout { min-height: calc(100vh - 72px); }
.eyebrow { font-size: 10px; letter-spacing: 1.5px; color: #668071; font-weight: 800; }

.content { padding: 38px clamp(24px, 4vw, 58px) 60px; max-width: 1480px; width: 100%; margin: auto; }
.pageHead { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 28px; gap: 16px; }
.pageHead h1 { font: 500 38px Georgia, serif; margin: 0 0 8px; }
.pageHead > div > p:last-child, .panelHead p { color: var(--muted); font-size: 13px; margin: 0; }
.primary { border: 0; border-radius: 9px; background: var(--ink); color: #fff; padding: 12px 17px; font-weight: 700; box-shadow: 0 4px 12px #17241e18; white-space: nowrap; }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 14px; }
.metrics article, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 21px; box-shadow: 0 2px 8px #24352c08; }
.metricTop, .panelHead { display: flex; justify-content: space-between; align-items: flex-start; color: #6a766f; font-size: 12px; }
.metricTop i { font-style: normal; padding: 5px 7px; border-radius: 20px; background: #e8f5ea; color: #2c7348; font-weight: 700; }
.metricTop i.down { background: #f6ece0; color: #a35a12; }
.metrics strong { font: 500 29px Georgia, serif; }
.metrics article > p { font-size: 11px; color: #87928b; }
.profit { background: var(--ink) !important; color: #fff; }
.profit .metricTop, .profit > p { color: #bac6bf; }
.profit .metricTop i { background: #23392f; color: #b9e6c9; }

.grid { display: grid; grid-template-columns: 1.7fr 1fr; gap: 14px; margin-bottom: 14px; }
.panelHead h2 { font: 600 18px Georgia, serif; margin: 0 0 5px; color: var(--ink); }
.tableHead h2 b { font: 700 11px system-ui, sans-serif; color: #668071; background: #ecf0e7; padding: 2px 8px; border-radius: 20px; margin-left: 6px; vertical-align: middle; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; }
.legend i, .spendList i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.rev { background: var(--rev); }
.exp { background: var(--exp); }

/* Cash flow chart (SVG) */
.chartWrap { position: relative; margin-top: 18px; }
.chart { width: 100%; aspect-ratio: 640 / 220; display: block; overflow: visible; }
.chart .gridline { stroke: #e1e0d9; stroke-width: 1; }
.chart .axisLabel { fill: #898781; font-size: 10px; font-family: system-ui, sans-serif; }
.chart .monthLabel { fill: #6a766f; font-size: 11px; font-family: system-ui, sans-serif; text-anchor: middle; }
.chart .bar { cursor: pointer; }
.chart .revenueBar { fill: var(--rev); }
.chart .expenseBar { fill: var(--exp); }
.chart .valueLabel { font-size: 10px; font-weight: 700; fill: var(--ink); text-anchor: middle; }
.chartTip {
  position: absolute; pointer-events: none; background: var(--ink); color: #fff;
  font-size: 11px; padding: 7px 10px; border-radius: 8px; white-space: nowrap;
  transform: translate(-50%, -100%); opacity: 0; transition: opacity .1s ease;
  z-index: 5;
}
.chartTip.show { opacity: 1; }
.chartTip b { font-weight: 700; }

.donut {
  margin: 16px auto; width: 135px; height: 135px; border-radius: 50%;
  display: grid; place-items: center; position: relative;
}
.donut:before { content: ""; position: absolute; background: var(--surface); width: 83px; height: 83px; border-radius: 50%; }
.donut div { z-index: 1; text-align: center; }
.donut strong { display: block; font: 19px Georgia, serif; }
.donut span { font-size: 9px; color: #8c968f; }
.spendList p { display: flex; justify-content: space-between; font-size: 11px; color: #637068; margin: 9px 0; }
.c1 { background: var(--donut-c1); }
.c2 { background: var(--donut-c2); }
.c3 { background: var(--donut-c3); }
.c4 { background: var(--donut-c4); }

.transactions { padding: 0; overflow: hidden; }
.tableHead { padding: 20px 21px 16px; }
.tools { display: flex; gap: 8px; }
.tools input, .tools select { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--surface); font-size: 11px; }
table { width: 100%; border-collapse: collapse; min-width: 650px; }
th { text-align: left; background: #f8f9f6; color: #8a948e; font-size: 9px; letter-spacing: 1px; text-transform: uppercase; padding: 10px 21px; border-block: 1px solid var(--line); }
td { padding: 12px 21px; border-bottom: 1px solid #edf0ed; color: #6f7b73; font-size: 11px; font-variant-numeric: tabular-nums; }
.tag { background: #f0f2ed; padding: 5px 8px; border-radius: 6px; }
.roleSelect { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 11px; background: var(--surface); color: #6f7b73; }
.rowIconBtn { border: 0; background: transparent; color: #92a097; font-size: 13px; padding: 6px; border-radius: 6px; line-height: 1; }
.rowIconBtn:hover { background: #f0f2ed; color: var(--ink); }
.rowIconBtn-danger:hover { background: #fbeaea; color: #a33; }
.positive { color: #2b704b; font-weight: 700; }
.negative { color: #8a4a12; font-weight: 700; }
.empty { padding: 30px 21px; text-align: center; color: #92a097; }

.modalWrap { position: fixed; inset: 0; background: #0d1b1499; display: none; place-items: center; z-index: 30; padding: 20px; }
.modalWrap.open { display: grid; }
.modal { background: var(--surface); width: min(440px, 100%); border-radius: 16px; padding: 25px; }
.modalHead { display: flex; justify-content: space-between; }
.modalHead h2 { font: 25px Georgia, serif; margin: 0; }
.close { border: 0; border-radius: 50%; width: 30px; height: 30px; background: #f0f2ed; }
.modal label { display: flex; flex-direction: column; gap: 7px; font-size: 11px; font-weight: 700; margin: 15px 0; }
.modal input, .modal select { border: 1px solid var(--line); border-radius: 9px; padding: 11px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.categoryRow { display: flex; gap: 8px; }
.categoryRow select { flex: 1; min-width: 0; }
.iconBtn {
  flex: none; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 9px;
  background: #f0f2ed; color: var(--ink); font-size: 15px; font-weight: 700;
  display: grid; place-items: center; padding: 0;
}
.iconBtn:hover { background: #e6e9e2; }
.newCategoryRow { display: flex; gap: 8px; margin-top: 8px; }
.newCategoryRow input { flex: 1; min-width: 0; }
.full { width: 100%; }
.toast { position: fixed; right: 24px; bottom: 24px; background: var(--ink); color: #fff; padding: 13px 17px; border-radius: 10px; display: none; }
.toast.show { display: block; }

@media (max-width: 800px) {
  .content { padding: 25px 15px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .profit { grid-column: 1/-1; }
  .grid { grid-template-columns: 1fr; }
  .pageHead h1 { font-size: 30px; }
}
@media (max-width: 520px) {
  .period { display: none; }
  .pageHead { display: block; }
  .pageHead button { margin-top: 16px; width: 100%; }
  .metrics { grid-template-columns: 1fr; }
  .profit { grid-column: auto; }
  .tableHead { display: block; }
  .tools { margin-top: 14px; }
  .row { grid-template-columns: 1fr; }
}

.authBody { display: grid; place-items: center; min-height: 100vh; }
.authWrap { padding: 20px; width: 100%; }
.authCard {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 40px; max-width: 380px; margin: auto; box-shadow: 0 2px 8px #24352c08;
}
.authLogo { height: 30px; margin-bottom: 24px; }
.authCard h1 { font: 500 28px Georgia, serif; margin: 0 0 6px; }
.authSub { color: var(--muted); font-size: 13px; margin: 0 0 24px; }
.authCard label { display: flex; flex-direction: column; gap: 7px; font-size: 11px; font-weight: 700; margin: 0 0 15px; }
.authCard input[type="email"], .authCard input[type="password"] { border: 1px solid var(--line); border-radius: 9px; padding: 11px; font-size: 14px; font-weight: 400; }
.checkboxRow { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 400 !important; }
.checkboxRow input { width: auto; }
.authError { background: #fbeaea; border: 1px solid #f0c9c9; color: #a33; border-radius: 9px; padding: 10px 14px; font-size: 12px; margin-bottom: 18px; }
.authError p { margin: 0; }
