:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #17202a;
  --muted: #627386;
  --line: #d8e0e8;
  --accent: #0f766e;
  --accent-soft: #d7f4ee;
  --danger: #b42318;
  --warning: #b7791f;
  --blue: #2563eb;
  --sidebar: #16212e;
  --sidebar-raised: #1e2b3a;
  --sidebar-active: #233244;
  --sidebar-line: #334458;
  --sidebar-text: #b6c4d4;
  --sidebar-muted: #9fb0c3;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button,
input,
select {
  font: inherit;
}
button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 12px;
  cursor: pointer;
}
button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
button.secondary {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--ink);
}
button.primary.compact {
  width: auto;
  min-width: 120px;
  padding: 8px 16px;
}
button.secondary.compact {
  width: auto;
  min-width: auto;
  min-height: 38px;
  padding: 8px 10px;
  white-space: nowrap;
}
input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}
label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.hidden {
  display: none !important;
}
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 20px;
}
.auth-card h1,
.auth-card h2 {
  margin: 0 0 14px;
}
.auth-switch {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.auth-switch a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--sidebar);
  padding: 18px 14px;
}
.brand {
  padding: 4px 8px 10px;
}
.brand strong {
  display: block;
  color: #fff;
  font-size: 19px;
}
.brand span {
  display: block;
  margin-top: 3px;
  color: var(--sidebar-muted);
  font-size: 12px;
}
.nav {
  display: grid;
  gap: 5px;
}
.nav button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  border-color: transparent;
  background: transparent;
  color: var(--sidebar-text);
  font-weight: 650;
}
.nav button.active {
  background: var(--sidebar-active);
  color: #fff;
}
.nav button:hover,
.settings-subnav button:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}
.nav-icon,
.subnav-dot {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: #526477;
}
.nav button.active .nav-icon,
.settings-toggle[aria-expanded="true"] .nav-icon,
.settings-subnav button.active .subnav-dot {
  background: var(--accent);
}
.settings-toggle .chevron {
  margin-left: auto;
  color: inherit;
}
.settings-subnav {
  display: none;
  gap: 4px;
  margin: -4px 0 2px 14px;
  padding-left: 14px;
  border-left: 2px solid var(--sidebar-line);
}
.settings-subnav.open {
  display: grid;
}
.settings-subnav button {
  width: 100%;
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-color: transparent;
  background: transparent;
  color: var(--sidebar-muted);
  font-size: 13px;
  font-weight: 650;
  text-align: left;
}
.settings-subnav button.active {
  background: var(--sidebar-raised);
  color: #fff;
}
.subnav-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}
.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding: 8px;
}
.sidebar-footer select,
.sidebar-footer button {
  border-color: #2d3d50;
  background: var(--sidebar-raised);
  color: #fff;
}
.main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}
.topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  padding: 14px 22px;
}
.topbar h1 {
  margin: 0;
  font-size: 22px;
}
.topbar .sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}
.content {
  padding: 20px;
}
.page {
  display: none;
}
.page.active {
  display: block;
}
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}
.panel h2,
.panel h3 {
  margin: 0 0 14px;
  font-size: 16px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
}
.span-3 {
  grid-column: span 3;
}
.span-4 {
  grid-column: span 4;
}
.span-5 {
  grid-column: span 5;
}
.span-6 {
  grid-column: span 6;
}
.span-7 {
  grid-column: span 7;
}
.span-8 {
  grid-column: span 8;
}
.span-12 {
  grid-column: span 12;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.modal-form {
  display: grid;
  gap: 12px;
}
.category-name-controls-row {
  position: relative;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: end;
  gap: 10px;
}
.category-icon-field,
.category-color-field {
  width: 38px;
}
.category-color-input {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  overflow: hidden;
}
.category-color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}
.category-color-input::-webkit-color-swatch {
  border: 0;
}
.category-color-input::-moz-color-swatch {
  border: 0;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
}
.date-input-row {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 8px;
}
.toolbar,
.row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.toolbar {
  justify-content: space-between;
  margin-bottom: 14px;
}
.wrap {
  flex-wrap: wrap;
}
.icon-button {
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
}
.icon-button svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}
.records-tools {
  display: grid;
  gap: 12px;
}
.records-filter-panel {
  display: none;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}
.records-filter-panel.open {
  display: grid;
}
.filter-field {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}
.filter-field .filter-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  border: 1px solid var(--line);
}
.filter-field svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
}
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.metric {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
}
.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}
.list {
  display: grid;
  gap: 8px;
}
.item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.item small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}
.category-icon {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  color: var(--ink);
  flex: 0 0 auto;
}
.category-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}
.category-item-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.icon-dropdown {
  position: relative;
  display: inline-block;
}
.icon-dropdown-trigger {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
}
.icon-dropdown-trigger::after {
  content: none;
}
.icon-dropdown-trigger[aria-expanded="true"]::after {
  content: none;
}
.icon-picker {
  position: absolute;
  z-index: 300;
  top: calc(100% + 8px);
  left: 0;
  width: min(520px, 100%);
  min-width: min(520px, calc(100vw - 48px));
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 44px));
  gap: 8px;
  max-height: 300px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
  scrollbar-width: thin;
}
.icon-choice {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
}
.icon-choice svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  transition: transform 120ms ease;
}
.icon-choice.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.icon-choice.active svg {
  transform: scale(1.5);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.record-group {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}
.record-group h3 {
  margin: 10px 0 2px;
  color: #344054;
  font-size: 14px;
}
.record-day {
  display: grid;
  gap: 6px;
  border-left: 2px solid var(--line);
  padding-left: 10px;
}
.record-day h4 {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}
.pill,
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.chip.todo {
  border-color: #f3d19e;
  background: #fff7e6;
  color: #8a4b0f;
  font-weight: 700;
}
.swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
}
.amount-expense {
  color: var(--danger);
}
.amount-income {
  color: var(--accent);
}
.status {
  min-height: 24px;
  color: var(--muted);
  font-size: 13px;
}
.status.error {
  color: var(--danger);
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.45);
  padding: 20px;
}
.modal {
  width: min(720px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.2);
  padding: 18px;
}
.category-modal {
  overflow: visible;
}
.modal h2 {
  margin: 0;
  font-size: 18px;
}
.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef5;
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--blue);
}
.settings-block {
  display: grid;
  gap: 12px;
}
.settings-hero {
  min-height: 150px;
  display: grid;
  align-content: center;
  gap: 8px;
}
.settings-hero p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}
.settings-targets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}
.settings-target {
  min-height: 110px;
  display: grid;
  gap: 8px;
  align-content: start;
  text-align: left;
}
.settings-target strong {
  font-size: 15px;
}
.settings-target span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}
.placeholder {
  min-height: 120px;
  display: grid;
  align-content: center;
  gap: 8px;
  color: var(--muted);
  border: 1px dashed #c8d3df;
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 16px;
}
@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .nav {
    grid-template-columns: 1fr;
  }
  .settings-subnav {
    grid-column: 1 / -1;
  }
  .sidebar-footer {
    margin-top: 0;
  }
  .records-filter-panel {
    grid-template-columns: 1fr;
  }
  .span-3,
  .span-4,
  .span-5,
  .span-6,
  .span-7,
  .span-8 {
    grid-column: span 12;
  }
}
