.dashboard-shell {
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: 2rem clamp(1rem, 3vw, 2.5rem) 4rem;
  position: relative;
  z-index: 1;
}

.dashboard-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1.4rem;
}

.eyebrow,
.panel-kicker {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.dashboard-head h1 {
  margin-top: 0.2rem;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.12;
}

.dashboard-copy {
  margin-top: 0.6rem;
  color: var(--muted);
  max-width: 680px;
}

.dashboard-session {
  min-width: 260px;
  display: grid;
  justify-items: end;
  gap: 0.45rem;
}

.live-clock {
  color: var(--accent-2);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
}

.auth-state {
  color: var(--muted);
  font-size: 0.82rem;
}

.session-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.dash-button,
.icon-button,
.text-button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

.dash-button {
  min-height: 38px;
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
}

.dash-button.primary {
  color: #111827;
  background: var(--accent);
}

.dash-button.subtle {
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(21, 26, 44, 0.78);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.summary-card {
  position: relative;
  min-height: 126px;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(155deg, rgba(24, 29, 47, 0.98), rgba(13, 16, 27, 0.96));
  overflow: hidden;
}

.summary-card::after {
  content: "";
  position: absolute;
  width: 110px;
  height: 110px;
  right: -45px;
  top: -50px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.09;
}

.summary-card span,
.summary-card small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.summary-card strong {
  display: block;
  margin: 0.35rem 0 0.45rem;
  font-size: clamp(1.25rem, 2.2vw, 1.75rem);
  line-height: 1.15;
}

.summary-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.summary-trend {
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 700;
  color: var(--muted);
  text-align: right;
}

.summary-trend.is-good { color: #86efac; }
.summary-trend.is-bad { color: #fca5a5; }
.summary-trend.is-flat { color: #cbd5e1; }

.asset-card { color: #22c55e; }
.debt-card { color: #ef4444; }
.net-card { color: #f59e0b; border-color: rgba(245, 158, 11, 0.42); }
.expense-card { color: #60a5fa; }

.insight-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.insight-card {
  min-height: 112px;
  padding: 0.95rem 1rem;
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 0.75rem;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(15, 19, 32, 0.72);
}

.insight-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--accent);
  background: rgba(245, 158, 11, 0.13);
}

.insight-card small,
.insight-card strong,
.insight-card p { display: block; }
.insight-card small { color: var(--muted); font-size: 0.68rem; }
.insight-card strong { margin-top: 0.1rem; font-size: 0.92rem; }
.insight-card p { margin-top: 0.22rem; color: var(--muted); font-size: 0.76rem; line-height: 1.4; }

.chart-panel {
  margin-bottom: 1rem;
}

.chart-head {
  min-height: 84px;
}

.chart-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.28rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(8, 11, 19, 0.62);
}

.chart-tab {
  min-height: 36px;
  padding: 0.45rem 0.9rem;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.chart-tab.is-active {
  color: #111827;
  background: var(--accent);
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.2);
}

.chart-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chart-view {
  padding: 1rem 1.1rem 1.2rem;
}

.chart-view[hidden],
.chart-message[hidden],
.history-chart[hidden],
.compare-chart[hidden],
.month-chart[hidden] {
  display: none;
}

.chart-legend {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-bottom: 0.7rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-dot {
  width: 9px;
  height: 9px;
  display: inline-block;
  border-radius: 3px;
}

.legend-dot.asset { background: #22c55e; }
.legend-dot.debt { background: #ef4444; }
.legend-dot.expense { background: #60a5fa; }

.history-chart-scroll {
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
}

.history-chart {
  min-width: 840px;
  height: 290px;
  padding: 0.8rem 0.35rem 0;
  display: grid;
  grid-template-columns: repeat(12, minmax(52px, 1fr));
  gap: 0.45rem;
  border: 1px solid rgba(148, 163, 184, 0.13);
  border-radius: 14px;
  background:
    repeating-linear-gradient(to top, rgba(148, 163, 184, 0.11) 0 1px, transparent 1px 58px),
    rgba(8, 11, 19, 0.42);
}

.history-month {
  min-width: 0;
  display: grid;
  grid-template-rows: 1fr 30px;
  gap: 0.45rem;
}

.history-bars {
  min-height: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
}

.history-bar {
  width: min(13px, 28%);
  height: max(3px, var(--bar-height, 0%));
  display: block;
  border-radius: 5px 5px 2px 2px;
  transition: height 0.25s ease;
}

.history-bar.asset { background: linear-gradient(180deg, #4ade80, #15803d); }
.history-bar.debt { background: linear-gradient(180deg, #fb7185, #b91c1c); }
.history-bar.expense { background: linear-gradient(180deg, #93c5fd, #2563eb); }
.history-bar.is-zero { opacity: 0.18; }

.history-label {
  color: var(--muted);
  font-size: 0.67rem;
  text-align: center;
  white-space: nowrap;
}

.compare-periods {
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.compare-chart {
  display: grid;
  gap: 1.1rem;
}

.compare-metric {
  --metric-color: #f59e0b;
  padding: 0.9rem;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 13px;
  background: rgba(8, 11, 19, 0.34);
}

.compare-metric.asset { --metric-color: #22c55e; }
.compare-metric.debt { --metric-color: #ef4444; }
.compare-metric.expense { --metric-color: #60a5fa; }

.compare-metric-head {
  margin-bottom: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.compare-metric-head strong { font-size: 0.86rem; }
.compare-metric-head span { color: var(--muted); font-size: 0.7rem; }

.compare-line {
  display: grid;
  grid-template-columns: 52px minmax(100px, 1fr) 125px;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.5rem;
}

.compare-line-label {
  color: var(--muted);
  font-size: 0.7rem;
}

.compare-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.12);
}

.compare-bar {
  width: var(--bar-width, 0%);
  height: 100%;
  display: block;
  min-width: 2px;
  border-radius: inherit;
}

.compare-line.previous .compare-bar { background: rgba(148, 163, 184, 0.58); }
.compare-line.current .compare-bar { background: var(--metric-color); }
.compare-amount { font-size: 0.76rem; font-weight: 700; text-align: right; }

.month-chart-period {
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.month-chart {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(330px, 0.95fr);
  gap: 1rem;
}

.month-overview,
.month-expense-breakdown {
  padding: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 14px;
  background: rgba(8, 11, 19, 0.34);
}

.month-net {
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-radius: 12px;
  background: rgba(34, 197, 94, 0.1);
}

.month-net.is-negative { background: rgba(239, 68, 68, 0.1); }
.month-net span { color: var(--muted); font-size: 0.76rem; }
.month-net strong { color: #86efac; font-size: 1.05rem; }
.month-net.is-negative strong { color: #fca5a5; }

.month-metrics {
  margin-top: 1rem;
  display: grid;
  gap: 0.85rem;
}

.month-metric { --metric-color: #f59e0b; }
.month-metric.asset { --metric-color: #22c55e; }
.month-metric.debt { --metric-color: #ef4444; }
.month-metric.expense { --metric-color: #60a5fa; }

.month-metric-head {
  margin-bottom: 0.38rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.month-metric-head span { color: var(--muted); font-size: 0.72rem; }
.month-metric-head strong { font-size: 0.78rem; }
.month-metric-track { height: 11px; overflow: hidden; border-radius: 999px; background: rgba(148, 163, 184, 0.12); }
.month-metric-bar { width: var(--bar-width, 0%); height: 100%; display: block; min-width: 2px; border-radius: inherit; background: var(--metric-color); }

.month-expense-head {
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.month-expense-head strong { font-size: 0.86rem; }
.month-expense-head span { color: var(--muted); font-size: 0.7rem; }
.month-expense-body { display: grid; grid-template-columns: 135px minmax(0, 1fr); align-items: center; gap: 1.1rem; }

.month-expense-donut {
  width: 135px;
  aspect-ratio: 1;
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 50%;
}

.month-expense-donut::after {
  content: '';
  width: 62%;
  aspect-ratio: 1;
  position: absolute;
  border-radius: 50%;
  background: #0c101b;
}

.month-expense-donut span { position: relative; z-index: 1; color: var(--muted); font-size: 0.72rem; }
.month-expense-legend { min-width: 0; display: grid; gap: 0.52rem; }
.month-expense-item { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; }
.month-expense-item span { min-width: 0; display: flex; align-items: center; gap: 0.4rem; }
.month-expense-item i { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; }
.month-expense-item b { overflow: hidden; color: var(--muted); font-size: 0.7rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.month-expense-item strong { flex: 0 0 auto; font-size: 0.68rem; }
.month-expense-empty { min-height: 160px; display: grid; place-items: center; color: var(--muted); font-size: 0.78rem; text-align: center; }

.chart-message {
  min-height: 245px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(12, 16, 27, 0.92);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
  overflow: hidden;
}

.ledger-panel.is-loading .ledger-section,
.ledger-panel.is-loading .ledger-status-row {
  opacity: 0.55;
  pointer-events: none;
}

.ledger-panel.is-locked .ledger-section,
.ledger-panel.is-locked .ledger-status-row {
  opacity: 0.48;
}

.ledger-auth-callout {
  margin: 0.85rem 1.1rem 0;
  padding: 0.8rem 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid rgba(245, 158, 11, 0.38);
  border-radius: 13px;
  background: rgba(120, 74, 12, 0.17);
}

.ledger-auth-callout[hidden] { display: none; }
.ledger-auth-callout strong,
.ledger-auth-callout span { display: block; }
.ledger-auth-callout strong { font-size: 0.83rem; }
.ledger-auth-callout span { margin-top: 0.15rem; color: var(--muted); font-size: 0.7rem; }

.panel-head {
  min-height: 78px;
  padding: 1rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  font-size: 1.2rem;
  line-height: 1.2;
}

.month-control {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.month-control input {
  width: 145px;
  min-height: 38px;
  padding: 0.4rem 0.55rem;
  font-size: 0.82rem;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px solid var(--line);
  background: #0f1320;
}

.ledger-status-row {
  padding: 0.65rem 1.1rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.76rem;
  border-bottom: 1px solid var(--line);
}

.ledger-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.text-button {
  padding: 0.2rem;
  color: var(--accent);
  background: transparent;
  font-size: 0.78rem;
  font-weight: 700;
}

.text-button:disabled,
.dash-button:disabled,
.icon-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.text-button i { margin-right: 0.25rem; }
.text-button[hidden] { display: none; }
.danger-text { color: #f87171; }

.ledger-section {
  padding: 0.95rem 1.1rem 0.25rem;
}

.ledger-section + .ledger-section {
  border-top: 1px solid rgba(35, 42, 61, 0.8);
}

.ledger-section:last-child { padding-bottom: 1.1rem; }

.ledger-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.55rem;
}

.ledger-section-head h3 {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9rem;
}

.section-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.asset-dot { background: #22c55e; }
.debt-dot { background: #ef4444; }
.expense-dot { background: #60a5fa; }

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

.ledger-table {
  width: 100%;
  min-width: 610px;
  border-collapse: collapse;
}

.ledger-table th {
  padding: 0.35rem 0.3rem;
  color: #7f8a9c;
  font-size: 0.67rem;
  text-align: left;
  font-weight: 600;
}

.ledger-table th:nth-child(1) { width: 23%; }
.ledger-table th:nth-child(2) { width: 20%; }
.ledger-table th:nth-child(3) { width: 21%; }
.ledger-table th:nth-child(4) { width: 29%; }
.ledger-table th:nth-child(5) { width: 7%; }

.ledger-table td { padding: 0.25rem 0.2rem; }

.ledger-table input,
.ledger-table select {
  min-height: 34px;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  font-size: 0.76rem;
}

.money-field {
  position: relative;
  display: flex;
  align-items: center;
}

.ledger-table .money-input {
  width: 100%;
  padding-right: 1.65rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.money-suffix {
  position: absolute;
  right: 0.48rem;
  color: #7f8a9c;
  font-size: 0.7rem;
  pointer-events: none;
}

.row-delete {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #7f8a9c;
  background: transparent;
  cursor: pointer;
}

.row-delete:hover { color: #f87171; background: rgba(239, 68, 68, 0.12); }

.auth-dialog {
  width: min(430px, calc(100% - 2rem));
  max-width: none;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--text);
  background: #111625;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.62);
}

.auth-dialog::backdrop {
  background: rgba(5, 7, 12, 0.75);
  backdrop-filter: blur(7px);
}

.auth-dialog-card {
  position: relative;
  padding: 1.5rem;
  display: grid;
  gap: 0.65rem;
}

.auth-dialog h2 { font-size: 1.65rem; }
.auth-description { color: var(--muted); font-size: 0.84rem; margin-bottom: 0.4rem; }
.auth-dialog label { margin-bottom: -0.4rem; }

.dialog-close {
  position: absolute;
  right: 1rem;
  top: 1rem;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: #0f1320;
  cursor: pointer;
}

.challenge-box {
  padding: 0.75rem;
  display: grid;
  grid-template-columns: 1fr 120px;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

.challenge-box[hidden],
.website-trap { display: none; }
.form-error { min-height: 1.2rem; color: #fca5a5; font-size: 0.78rem; }
.auth-submit { width: 100%; margin-top: 0.2rem; }

@media (max-width: 1220px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .insight-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .month-chart { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .dashboard-shell { padding-top: 1.25rem; }
  .dashboard-head { align-items: flex-start; flex-direction: column; }
  .dashboard-session { min-width: 0; justify-items: start; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .insight-grid { grid-template-columns: 1fr; }
  .summary-card { min-height: 112px; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .month-control { width: 100%; }
  .month-control input { flex: 1; }
  .ledger-status-row { align-items: flex-start; flex-direction: column; }
  .ledger-actions { justify-content: flex-start; }
  .ledger-auth-callout { align-items: flex-start; flex-direction: column; }
  .chart-head { align-items: flex-start; }
  .chart-tabs { width: 100%; }
  .chart-tab { flex: 1; }
  .compare-line { grid-template-columns: 46px minmax(80px, 1fr); }
  .compare-amount { grid-column: 2; text-align: left; }
  .month-expense-body { grid-template-columns: 110px minmax(0, 1fr); }
  .month-expense-donut { width: 110px; }
}

@media (max-width: 430px) {
  .summary-grid { grid-template-columns: 1fr; }
  .challenge-box { grid-template-columns: 1fr; }
  .chart-tab { padding-inline: 0.55rem; font-size: 0.7rem; }
  .month-expense-body { grid-template-columns: 1fr; justify-items: center; }
  .month-expense-legend { width: 100%; }
}
