:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --bg-2: #e9f1ed;
  --ink: #17201b;
  --muted: #66736c;
  --line: #d8ded7;
  --panel: #fffdf8;
  --panel-2: #f7faf8;
  --accent: #176a5b;
  --accent-2: #b84a35;
  --accent-3: #325d99;
  --accent-4: #836326;
  --good: #207a43;
  --bad: #b9382d;
  --warn: #ad721d;
  --shadow: 0 16px 42px rgba(26, 36, 31, 0.10);
  --radius: 8px;
  --focus: 0 0 0 3px rgba(23, 106, 91, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(244, 241, 234, 0.96), rgba(233, 241, 237, 0.96)),
    radial-gradient(circle at 16% 4%, rgba(23, 106, 91, 0.12), transparent 28%),
    radial-gradient(circle at 82% 2%, rgba(184, 74, 53, 0.10), transparent 24%);
  color: var(--ink);
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
  gap: 14px;
  align-content: center;
  color: var(--muted);
}

.boot-mark {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 4px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.brand-line {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.brand-title {
  font-size: 20px;
  font-weight: 750;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 13px;
}

.login-panel label,
.field label,
.inline-field label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  margin-bottom: 6px;
}

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

.textarea {
  min-height: 84px;
  resize: vertical;
}

.button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  min-height: 38px;
  padding: 9px 12px;
  border-radius: 8px;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover {
  border-color: rgba(23, 106, 91, 0.45);
}

.button.primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.button.danger {
  color: #fff;
  background: var(--bad);
  border-color: var(--bad);
}

.button.ghost {
  background: transparent;
}

.button.icon {
  width: 38px;
  padding: 8px;
}

.button svg,
.icon-inline {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.login-panel .button {
  width: 100%;
  margin-top: 14px;
}

.error {
  color: var(--bad);
  font-size: 13px;
  min-height: 18px;
  margin-top: 10px;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-width: 0;
}

.sidebar {
  background: rgba(255, 253, 248, 0.76);
  border-right: 1px solid var(--line);
  padding: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  backdrop-filter: blur(16px);
  min-width: 0;
}

.nav {
  display: grid;
  gap: 8px;
  margin: 24px 0;
  min-width: 0;
}

.nav button {
  width: 100%;
  justify-content: flex-start;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.nav button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}

.side-note {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0 0 4px;
  font-size: clamp(25px, 4vw, 38px);
  letter-spacing: 0;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.grid {
  display: grid;
  gap: 14px;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.two-grid {
  grid-template-columns: minmax(0, 1.08fr) minmax(330px, 0.92fr);
}

.three-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel,
.stat,
.modal-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel,
.stat {
  padding: 16px;
  min-width: 0;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.stat-value {
  font-size: 26px;
  line-height: 1.08;
  font-weight: 800;
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.stat-context {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.positive {
  color: var(--good);
}

.negative {
  color: var(--bad);
}

.warning {
  color: var(--warn);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin: 0;
  font-size: 18px;
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}

.segmented button {
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  min-height: 36px;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

td.amount,
th.amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.pill.good {
  color: var(--good);
  border-color: rgba(32, 122, 67, 0.28);
  background: rgba(32, 122, 67, 0.08);
}

.pill.bad {
  color: var(--bad);
  border-color: rgba(185, 56, 45, 0.28);
  background: rgba(185, 56, 45, 0.08);
}

.pill.warn {
  color: var(--warn);
  border-color: rgba(173, 114, 29, 0.28);
  background: rgba(173, 114, 29, 0.09);
}

.list {
  display: grid;
  gap: 10px;
}

.list-row {
  display: grid;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.list-row:last-child {
  border-bottom: 0;
}

.row-main {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.row-title {
  font-weight: 720;
}

.row-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.progress {
  height: 9px;
  border-radius: 999px;
  background: var(--panel-2);
  overflow: hidden;
  border: 1px solid var(--line);
}

.progress span {
  display: block;
  height: 100%;
  width: min(100%, var(--value, 0%));
  background: var(--accent);
}

.progress.warn span {
  background: var(--warn);
}

.progress.bad span {
  background: var(--bad);
}

.chart {
  min-height: 260px;
}

.chart-bars {
  display: grid;
  align-items: end;
  grid-template-columns: repeat(12, minmax(22px, 1fr));
  gap: 8px;
  height: 210px;
  padding: 8px 0 0;
}

.month-bar {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 6px;
  min-width: 0;
}

.bar-stack {
  height: 168px;
  display: flex;
  align-items: end;
  gap: 3px;
  justify-content: center;
}

.bar {
  width: 42%;
  min-width: 7px;
  border-radius: 5px 5px 0 0;
  min-height: 2px;
}

.bar.income {
  background: var(--good);
}

.bar.expense {
  background: var(--accent-2);
}

.bar-label {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
}

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
}

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

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--accent);
}

.swatch.income {
  background: var(--good);
}

.swatch.expense {
  background: var(--accent-2);
}

.tax-grid {
  grid-template-columns: 330px minmax(0, 1fr);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid.one {
  grid-template-columns: 1fr;
}

.field.inline-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 23px;
}

.field.inline-check input {
  width: 18px;
  height: 18px;
}

.field.inline-check label {
  margin: 0;
  font-size: 14px;
  color: var(--ink);
}

.tax-result {
  display: grid;
  gap: 12px;
}

.tax-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.tax-line strong {
  font-size: 18px;
}

.calendar-list {
  display: grid;
  gap: 10px;
}

.calendar-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.calendar-date {
  width: 64px;
  height: 56px;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  text-align: center;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.calendar-date span {
  display: block;
  color: var(--ink);
  font-size: 19px;
}

.empty {
  color: var(--muted);
  padding: 20px 0;
  line-height: 1.5;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 26, 23, 0.38);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 20;
}

.modal-panel {
  width: min(760px, 100%);
  max-height: min(86vh, 900px);
  overflow: auto;
  padding: 18px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.modal-head h2 {
  margin: 0;
  font-size: 20px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-top: 16px;
}

.mobile-menu {
  display: none;
}

.hidden {
  display: none !important;
}

@media (max-width: 1100px) {
  .stats-grid,
  .three-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-grid,
  .tax-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar .brand-line {
    margin-bottom: 0;
  }

  .nav {
    display: flex;
    overflow-x: auto;
    margin: 12px 0 0;
    padding-bottom: 4px;
  }

  .nav button {
    width: auto;
  }

  .side-note {
    display: none;
  }

  .main {
    padding: 14px;
  }

  .topbar {
    display: grid;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .stats-grid,
  .three-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .chart-bars {
    gap: 5px;
  }

  .calendar-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .calendar-item > .pill {
    grid-column: 2;
    justify-self: start;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #101512;
    --bg-2: #17211d;
    --ink: #eef4ef;
    --muted: #a3b0a8;
    --line: #31413a;
    --panel: #17211d;
    --panel-2: #121a17;
    --accent: #5ac6a9;
    --accent-2: #e47b61;
    --accent-3: #89aef0;
    --accent-4: #d4af58;
    --good: #6fce8d;
    --bad: #f06f63;
    --warn: #e4b458;
    --shadow: 0 18px 46px rgba(0, 0, 0, 0.28);
  }

  body {
    background:
      linear-gradient(135deg, rgba(16, 21, 18, 0.96), rgba(23, 33, 29, 0.96)),
      radial-gradient(circle at 16% 4%, rgba(90, 198, 169, 0.10), transparent 28%),
      radial-gradient(circle at 82% 2%, rgba(228, 123, 97, 0.10), transparent 24%);
  }

  .input,
  .select,
  .textarea {
    background: #121a17;
  }

  .brand-mark,
  .button.primary,
  .nav button[aria-pressed="true"],
  .segmented button[aria-pressed="true"] {
    color: #0d1411;
  }
}
