/* Penny — dark design: tokens first, then layout, then components. */

/* --- Tokens ---------------------------------------------------------------- */
:root {
  color-scheme: dark;
  --bg: #050506;
  --surface: #141416;          /* cards */
  --surface-2: #1c1c1f;        /* tiles, inputs */
  --surface-3: #252529;        /* hovered tiles, inner boxes */
  --border: rgb(255 255 255 / 0.07);
  --border-strong: rgb(255 255 255 / 0.13);
  --text: #f4f4f5;
  --text-2: #b9b9c2;
  --muted: #7c7c87;

  /* Accent: pastel blue in the same tint as the reference's lavender. */
  --accent: #9ec5ff;
  --on-accent: #08101f;
  --accent-soft: rgb(158 197 255 / 0.14);

  /* Green is reserved for good things, soft red for bad ones. */
  --good: #86e3a5;
  --good-ink: #0b2e18;
  --bad: #ff9d9d;
  --bad-ink: #3a0c0c;

  --radius: 26px;
  --radius-tile: 18px;
  --shadow: 0 1px 0 rgb(255 255 255 / 0.03) inset, 0 20px 40px -24px rgb(0 0 0 / 0.8);

  /* Charts (validated pair for the dark card surface) */
  --series-1: #4f93f0;
  --series-2: #c98500;
  --other: #4a4a53;
  --chart-muted: #7c7c87;
  --chart-grid: #232327;
  --chart-crosshair: #55555e;
  --tooltip-bg: #f4f4f5;
  --tooltip-text: #0a0a0b;
}

/* --- Base ------------------------------------------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
}

h1,
h2,
h3,
p {
  margin: 0;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  background: var(--surface-3);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 6px;
  word-break: break-word;
}

.icon {
  flex-shrink: 0;
}

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

.caption {
  font-size: 13px;
}

.small {
  font-size: 13px;
  margin-bottom: 14px;
}

/* --- Sidebar: icons only, expands over the page on hover ------------------- */
.sidebar {
  position: fixed;
  top: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 40;
  width: 78px;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: width 0.22s ease, box-shadow 0.22s ease;
}

.sidebar:hover,
.sidebar:focus-within {
  width: 236px;
  box-shadow: 0 24px 60px rgb(0 0 0 / 0.7);
  transition-delay: 0.08s;
}

.label {
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.sidebar:hover .label,
.sidebar:focus-within .label {
  opacity: 1;
  transition-delay: 0.14s;
}

.logo {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 48px;
  padding: 0 5px;
  color: var(--text);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.logo-mark {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 19px;
  font-weight: 600;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 36px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 48px;
  padding: 0 14px;
  border-radius: 14px;
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-link.active {
  background: var(--accent);
  color: var(--on-accent);
}

.side-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.side-add {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 48px;
  padding: 0 13px;
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s;
}

.side-add:hover {
  background: var(--surface-2);
}

.main {
  margin-left: 94px;
  padding: 32px 36px 56px;
  max-width: 1400px;
}

/* --- Page header and toolbars ---------------------------------------------- */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 28px;
}

.page-head h1 {
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-head p {
  margin-top: 4px;
  color: var(--muted);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 8px 0 18px;
}

.section-title {
  font-size: 20px;
  font-weight: 500;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  color: var(--muted);
  text-decoration: none;
}

.back:hover {
  color: var(--text);
}

.narrow {
  max-width: 600px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 20px;
  align-items: start;
}

.stack {
  display: grid;
  gap: 20px;
}

.stack-sm {
  display: grid;
  gap: 8px;
}

/* --- Cards and tiles ------------------------------------------------------- */
.card {
  min-width: 0;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

.card-head h2 {
  font-size: 17px;
  font-weight: 500;
}

/* The round ↗ button in card corners. */
.round-btn {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}

.round-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

.empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--muted);
}

.empty .btn {
  margin-top: 14px;
}

.alert {
  margin-bottom: 20px;
  padding: 14px 18px;
  border-radius: var(--radius-tile);
  background: var(--bad);
  color: var(--bad-ink);
  font-weight: 500;
}

/* --- Stat tiles ------------------------------------------------------------ */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
}

.stat-label {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-2);
}

.stat-value {
  margin: 16px 0 10px;
  font-size: clamp(28px, 2.5vw, 38px);
  font-weight: 300;
  letter-spacing: -0.02em;
  line-height: 1.1;
  white-space: nowrap;
}

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

.spark {
  display: block;
  width: calc(100% + 44px);
  height: 52px;
  margin: 14px -22px -22px;
}

.spark-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 6px rgb(158 197 255 / 0.6));
}

/* Delta badge: solid mint for good, soft red for bad, dark ink on top. */
.delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.delta.good {
  background: var(--good);
  color: var(--good-ink);
}

.delta.bad {
  background: var(--bad);
  color: var(--bad-ink);
}

/* --- Dashboard grid and charts --------------------------------------------- */
.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.chart-box {
  position: relative;
  height: 300px;
}

.legend-pills {
  display: flex;
  gap: 8px;
}

.legend-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 13px;
}

.legend-pill i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.donut-box {
  position: relative;
  height: 210px;
}

.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.donut-center strong {
  font-size: 24px;
  font-weight: 300;
  letter-spacing: -0.02em;
}

.donut-center span {
  font-size: 13px;
  color: var(--muted);
}

.legend {
  display: grid;
  gap: 6px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.legend li {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto 3em;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.legend .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend .pct {
  text-align: right;
  color: var(--muted);
}

details summary {
  margin-top: 14px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

table {
  width: 100%;
  margin-top: 10px;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

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

/* --- Lists: rows are tiles ------------------------------------------------- */
.tx-list {
  display: grid;
  gap: 8px;
}

.tx-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 8px 8px 8px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-tile);
  background: var(--surface-2);
  color: inherit;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.tx-row:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

.tx-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.tx-title {
  display: block;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tx-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}

/* The amount sits in its own small box, like the counts in the reference. */
.amount {
  padding: 9px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-3);
  font-size: 15px;
  font-weight: 400;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.amount.pos {
  color: var(--good);
}

.pill {
  display: inline-block;
  flex-shrink: 0;
  max-width: 60%;
  padding: 1px 8px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--c) 55%, #ffffff);
  color: #101012;
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.day-label {
  margin: 22px 0 10px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.day-label:first-child {
  margin-top: 0;
}

.cat-avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--c) 26%, var(--surface-2));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 50%, transparent);
  color: var(--text);
  font-weight: 600;
}

.cat-avatar.sm {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 11px;
}

.account-icon,
.stat-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.summary-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.summary-value {
  font-size: 28px;
  font-weight: 300;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.account-card {
  display: flex;
  flex-direction: column;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}

.account-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.account-card .stat-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-card .stat-value {
  margin: 22px 0 12px;
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  color: var(--accent);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 5px 14px 5px 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.chip:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
}

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

.settings-grid .btn + .small {
  margin: 16px 0 0;
}

.link-tile {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-tile);
  background: var(--surface-2);
  color: inherit;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.link-tile .icon:last-child {
  color: var(--muted);
}

a.link-tile:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

.link-tile.static {
  grid-template-columns: 44px minmax(0, 1fr);
}

.link-tile.static .tx-meta {
  white-space: normal;
  display: block;
}

/* --- Buttons --------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-ghost {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-danger {
  background: transparent;
  border-color: color-mix(in srgb, var(--bad) 40%, transparent);
  color: var(--bad);
}

.btn-danger:hover {
  background: color-mix(in srgb, var(--bad) 12%, transparent);
}

.btn-lg {
  height: 52px;
  font-size: 15px;
}

.btn-block {
  width: 100%;
}

/* The big "Add transaction" button on the dashboard. */
.btn-add {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  height: 60px;
  padding: 0 28px 0 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 16px;
  font-weight: 500;
  text-decoration: none;
  box-shadow: 0 0 0 6px rgb(158 197 255 / 0.08), 0 16px 40px -14px rgb(158 197 255 / 0.55);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-add:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 0 8px rgb(158 197 255 / 0.12), 0 18px 44px -14px rgb(158 197 255 / 0.65);
}

.btn-add .plus {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--on-accent);
  color: var(--accent);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface-3);
}

/* Month picker: a pill with round arrow buttons. */
.month-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
}

.month-switch span {
  min-width: 140px;
  text-align: center;
  font-weight: 500;
}

.month-switch a {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--text-2);
}

.month-switch a:hover {
  background: var(--surface-3);
  color: var(--text);
}

.filter select {
  width: auto;
  min-width: 200px;
  border-radius: 999px;
  background-color: var(--surface);
}

.danger-zone {
  margin-top: 10px;
}

/* --- Forms ----------------------------------------------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  min-width: 0;
}

.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.optional {
  font-weight: 400;
  color: var(--muted);
}

.field-hint {
  font-size: 12px;
  color: var(--muted);
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

input,
select {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input::placeholder {
  color: var(--muted);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

select {
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237c7c87' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

input[type="color"] {
  padding: 5px;
  cursor: pointer;
}

.amount-wrap {
  position: relative;
  display: block;
}

.amount-wrap .currency {
  position: absolute;
  top: 50%;
  left: 20px;
  transform: translateY(-50%);
  font-size: 26px;
  font-weight: 300;
  color: var(--muted);
}

.amount-wrap input {
  height: 70px;
  padding-left: 50px;
  font-size: 34px;
  font-weight: 300;
  letter-spacing: -0.02em;
}

/* Segmented control: radio buttons styled as pill tabs, active one in white. */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 18px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-2);
}

.segmented input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  border-radius: 999px;
  color: var(--text-2);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.segmented input:checked + span {
  background: var(--text);
  color: #0a0a0b;
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Dialog (add transaction) --------------------------------------------- */
.dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 40px 100px rgb(0 0 0 / 0.7);
}

.dialog::backdrop {
  background: rgb(0 0 0 / 0.6);
  backdrop-filter: blur(6px);
}

.dialog[open] {
  animation: pop 0.18s ease-out;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
}

.dialog-body {
  padding: 24px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.dialog-head h2 {
  font-size: 22px;
  font-weight: 500;
}

/* --- Toast ----------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 100;
  max-width: calc(100vw - 32px);
  padding: 12px 22px;
  border-radius: 999px;
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  font-weight: 500;
  box-shadow: 0 16px 40px rgb(0 0 0 / 0.5);
  transform: translateX(-50%);
  animation: toast-in 0.2s ease-out;
  transition: opacity 0.3s, transform 0.3s;
}

.toast.leaving {
  opacity: 0;
  transform: translate(-50%, 8px);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
}

/* --- Phone tab bar (hidden on laptops) ------------------------------------- */
.tabbar {
  display: none;
}

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

@media (max-width: 1100px) {
  .dash-grid,
  .split,
  .settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .sidebar {
    display: none;
  }

  /* The tab bar's + button is the way to add on phones, so no second one in the page header. */
  .page-head [data-open-add] {
    display: none;
  }

  .main {
    margin-left: 0;
    padding: 24px 16px 120px;
  }

  .page-head h1 {
    font-size: 26px;
  }

  .tabbar {
    position: fixed;
    inset: auto 0 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: end;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: rgb(20 20 22 / 0.88);
    backdrop-filter: blur(14px);
  }

  .tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 4px 0;
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
    text-decoration: none;
  }

  .tab.active {
    color: var(--accent);
  }

  .tab-add {
    justify-self: center;
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    margin-top: -26px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--on-accent);
    box-shadow: 0 0 0 6px var(--bg), 0 12px 28px -8px rgb(158 197 255 / 0.6);
  }

  .toast {
    bottom: 100px;
  }

  .dialog {
    width: 100%;
    max-width: 100%;
    margin: auto 0 0;
    border-radius: var(--radius) var(--radius) 0 0;
  }

  .dialog-body {
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 600px) {
  .stats,
  .summary {
    grid-template-columns: minmax(0, 1fr);
  }

  .field-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .toolbar,
  .month-switch,
  .filter,
  .filter select {
    width: 100%;
  }

  .month-switch span {
    flex: 1;
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* --- Login ----------------------------------------------------------------- */
.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px 16px;
}

.login-card {
  width: min(420px, 100%);
  padding: 32px;
}

.login-card .logo {
  padding: 0;
  margin-bottom: 28px;
}

.login-card h1 {
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.login-card > .muted {
  margin: 4px 0 24px;
}

.alert.spaced {
  margin: 16px 0 0;
}

.password-form {
  margin-top: 20px;
}

.button-row {
  margin-top: 14px;
}

/* Log-out button in the sidebar looks like the other menu items. */
button.nav-link {
  width: 100%;
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  text-align: left;
}

/* --- In-page confirmation and form errors (instead of browser popups) ------ */
@media (min-width: 901px) {
  .dialog-sm {
    width: min(400px, calc(100vw - 32px));
  }
}

.confirm-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--bad) 16%, transparent);
  color: var(--bad);
}

#confirm-title {
  font-size: 20px;
  font-weight: 500;
}

#confirm-text {
  margin: 6px 0 24px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-danger-solid {
  background: var(--bad);
  color: var(--bad-ink);
}

.btn-danger-solid:hover {
  filter: brightness(1.06);
}

.field-error {
  font-size: 12px;
  color: var(--bad);
}

input[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: var(--bad);
}

.field-hint.center {
  margin-top: 10px;
  text-align: center;
}

/* --- Net worth hero at the top of the dashboard ---------------------------- */
.hero-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 32px;
  align-items: stretch;
  margin-bottom: 16px;
  padding: 26px 28px;
}

.hero-value {
  margin: 14px 0 14px;
  font-size: clamp(40px, 4.4vw, 60px);
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1.05;
  white-space: nowrap;
}

.hero-trend {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.hero-trend-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hero-spark {
  display: block;
  flex: 1;
  width: 100%;
  min-height: 90px;
  margin-top: 8px;
}

@media (max-width: 900px) {
  .hero-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 22px;
  }

  .hero-trend-head .round-btn {
    display: none; /* the Accounts tab is one tap away on phones */
  }
}

.delta.neutral {
  background: var(--surface-3);
  color: var(--text-2);
}
