:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef3ef;
  --ink: #1e2824;
  --muted: #66736d;
  --line: #dce3df;
  --accent: #2f7a58;
  --accent-2: #c85d2d;
  --danger: #a83a32;
  --warning: #9b6b12;
  --radius: 8px;
  --shadow: 0 8px 24px rgba(30, 40, 36, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Outfit", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0.02em;
  line-height: 1.45;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  align-items: center;
  background: #222;
  color: #fff;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  padding: 14px clamp(18px, 4vw, 44px);
}

.brand-mark {
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0;
}

.nav {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.nav a,
.nav button {
  align-items: center;
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.86);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 10px;
  transition: all 0.3s;
}

.nav a:hover,
.nav button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  text-decoration: none;
  transition: all 0.3s;
}

.account-menu {
  position: relative;
}

.nav-icon {
  flex: 0 0 auto;
  font-size: 18px;
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  line-height: 1;
}

.account-toggle {
  align-items: center;
  background: rgba(255, 255, 255, 0.15) !important;
  border-radius: 10px;
  display: inline-flex;
  gap: 6px;
}

.account-toggle:hover {
  background: rgba(255, 255, 255, 0.15) !important;
}

.account-menu-content {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: none;
  min-width: 180px;
  padding: 6px;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
}

.account-menu:focus-within .account-menu-content {
  display: block;
}

.account-menu-content a,
.account-menu-content button {
  border-radius: 10px;
  color: var(--ink);
  display: block;
  padding: 9px 10px;
  text-align: left;
  width: 100%;
}

.account-menu-content a:hover,
.account-menu-content button:hover {
  background: var(--surface-2);
  color: var(--ink);
  text-decoration: none;
}

.account-menu-content form {
  margin: 0;
}

.page {
  margin: 0 auto;
  max-width: 1640px;
  padding: 26px clamp(16px, 4vw, 40px) 48px;
}

.page-expenses {
  max-width: 1920px;
}

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

h1,
h2,
h3 {
  line-height: 1.15;
  margin: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
}

.muted {
  color: var(--muted);
}

.panel,
.auth-panel,
.metric,
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel,
.auth-panel {
  padding: 20px;
}

.panel h2 {
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
  padding-bottom: 12px;
}

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

.auth-panel {
  max-width: 420px;
  width: 100%;
}

.auth-panel h1 {
  margin-bottom: 6px;
}

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

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

.metric {
  padding: 16px;
}

.dashboard-metrics {
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
}

.metric-large {
  min-height: 118px;
  padding: 22px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  font-size: 28px;
  margin-top: 4px;
}

.metric-large strong {
  font-size: 38px;
  margin-top: 10px;
}

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.form-grid .full {
  grid-column: 1 / -1;
}

@media (min-width: 1081px) {
  .expense-form {
    grid-template-columns: repeat(10, minmax(0, 1fr));
  }

  .expense-form .field-item,
  .expense-form .field-notes,
  .expense-form .field-actions {
    grid-column: 1 / -1;
  }

  .expense-form .field-vendor,
  .expense-form .field-category {
    grid-column: span 3;
  }

  .expense-form .field-brand {
    grid-column: 1 / -1;
  }

  .expense-form .field-amount,
  .expense-form .field-status {
    grid-column: span 2;
  }

  .expense-form .field-date,
  .expense-form .field-payee,
  .expense-form .field-repayment,
  .expense-form .field-payment-method,
  .expense-form .field-frequency {
    grid-column: span 2;
  }
}

label {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

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

textarea {
  min-height: 92px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 122, 88, 0.16);
  outline: none;
}

.check-row,
.inline-actions,
.filters,
.button-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.check-row label {
  align-items: center;
  background: var(--surface-2);
  border-radius: 6px;
  color: var(--ink);
  display: inline-flex;
  font-weight: 600;
  gap: 8px;
  margin: 0;
  padding: 8px 10px;
}

.check-row input {
  min-height: auto;
  width: auto;
}

.btn,
button.btn {
  align-items: center;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 600;
  gap: 6px;
  letter-spacing: 0.02em;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  text-decoration: none;
  transition: all 0.3s;
}

.btn-icon {
  flex: 0 0 auto;
  font-size: 18px;
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  line-height: 1;
}

.btn:hover {
  background: #266348;
  text-decoration: none;
  transition: all 0.3s;
}

.btn.secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.btn.secondary:hover {
  background: var(--surface-2);
}

.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
}

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

th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tfoot td {
  background: #f8faf7;
  border-top: 2px solid var(--line);
  color: var(--ink);
  font-weight: 600;
}

.sort-link {
  align-items: center;
  color: inherit;
  display: inline-flex;
  gap: 4px;
  text-decoration: none;
}

.sort-link:hover {
  color: var(--ink);
  text-decoration: none;
}

th.amount .sort-link {
  justify-content: flex-end;
  width: 100%;
}

tr:last-child td {
  border-bottom: 0;
}

.amount {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.pill {
  background: var(--surface-2);
  border-radius: 999px;
  color: var(--ink);
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
}

.status-pill {
  align-items: center;
  display: inline-flex;
  gap: 5px;
}

.status-pill svg {
  fill: none;
  height: 13px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.5;
  width: 13px;
}

.pill.warn {
  background: #fff2d8;
  color: var(--warning);
}

.pill.good {
  background: #dff3e8;
  color: #226444;
}

.pill.danger {
  background: #f8dfdc;
  color: var(--danger);
}

.flash {
  border-radius: 6px;
  margin-bottom: 16px;
  padding: 12px 14px;
}

.flash.success {
  background: #dff3e8;
  color: #174a33;
}

.flash.error {
  background: #f8dfdc;
  color: var(--danger);
}

.errors {
  color: var(--danger);
  margin: 0 0 16px;
}

.filters {
  align-items: end;
}

.filters > div {
  min-width: 150px;
}

.filters .wide {
  min-width: 220px;
}

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

.chart-list {
  display: grid;
  gap: 10px;
  margin-top: 0;
}

.chart-list-scroll {
  max-height: 150px;
  overflow-y: auto;
  padding-right: 6px;
}

.bar-row {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(110px, 2fr) minmax(160px, 3fr) minmax(90px, auto);
  min-height: 28px;
}

.bar-track {
  background: var(--surface-2);
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
}

.bar-fill {
  background: var(--accent-2);
  height: 100%;
}

@media (max-width: 860px) {
  .topbar,
  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .metrics,
  .two-col,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .filters > div {
    width: 100%;
  }
}
