:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-soft: #f0f3f7;
  --line: #e6eaf0;
  --text: #171b22;
  --muted: #7b8492;
  --primary: #0798d6;
  --primary-strong: #0479b0;
  --primary-soft: #e7f7fd;
  --sidebar: #ffffff;
  --accent: #f5cf38;
  --accent-strong: #171b22;
  --danger: #d65137;
  --income: #d84c3f;
  --expense: #13985f;
  --transfer: var(--accent);
  --shadow: 0 18px 46px rgba(24, 34, 48, 0.08);
  --soft-shadow: 0 10px 26px rgba(24, 34, 48, 0.07);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  background: var(--sidebar);
  color: var(--text);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 6px 28px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 13px;
  background: url("./icon.svg") center / cover no-repeat;
  display: grid;
  place-items: center;
  box-shadow: 0 12px 24px rgba(7, 137, 211, 0.24);
}

.brand-title {
  font-weight: 800;
  font-size: 18px;
}

.brand-subtitle,
.mini-label {
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 7px;
}

.nav-item {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 999px;
  color: #697483;
  background: transparent;
  font-weight: 750;
}

.nav-item:hover,
.nav-item.active {
  color: white;
  background: #171b22;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-radius: 18px;
  background: #fff5bd;
  border: 1px solid #f4dc65;
}

.mini-balance {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 800;
}

.main {
  min-width: 0;
  padding: 28px 30px 34px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
}

.topbar p {
  color: var(--muted);
  margin-top: 6px;
}

.top-actions,
.panel-heading,
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.primary-button,
.icon-button,
.button-stack button,
.compact-form button,
.file-import,
.danger-button,
.toolbar input,
.toolbar select {
  border-radius: 8px;
}

.primary-button {
  background: var(--primary);
  color: white;
  padding: 11px 16px;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--primary-strong);
}

.secondary-button {
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 11px 16px;
  font-weight: 700;
}

.icon-button {
  width: 42px;
  height: 42px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 20px;
}

.icon-button.small {
  width: 32px;
  height: 32px;
  box-shadow: none;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 8px;
}

.metric {
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.metric strong {
  font-size: 25px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.dashboard-grid {
  align-items: start;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel-heading {
  justify-content: space-between;
  margin-bottom: 16px;
}

.inline-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.panel-heading select,
.entry-form input,
.entry-form select,
.toolbar input,
.toolbar select,
.compact-form input,
.compact-form select {
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 0;
}

.entry-form {
  display: grid;
  gap: 12px;
}

.entry-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.entry-form input,
.entry-form select {
  width: 100%;
  color: var(--text);
}

.advanced-fields {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfd;
}

.advanced-fields summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.advanced-fields .form-row {
  margin-top: 10px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  padding: 4px;
  border-radius: 8px;
  background: var(--surface-soft);
  gap: 4px;
}

.segmented label {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.segmented input {
  display: none;
}

.segmented label:has(input:checked) {
  background: white;
  color: var(--text);
  box-shadow: 0 4px 12px rgba(20, 33, 43, 0.08);
  font-weight: 700;
}

.full {
  width: 100%;
}

.form-actions {
  display: grid;
  gap: 8px;
}

.hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 32, 31, 0.36);
  z-index: 20;
}

.modal-panel {
  width: min(440px, 100%);
  display: grid;
  gap: 12px;
  padding: 18px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.modal-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.modal-panel input,
.modal-panel select {
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
}

.list,
.rank-list,
.account-list,
.chip-list {
  display: grid;
  gap: 10px;
}

.list-item,
.rank-item,
.account-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.account-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gold-rate-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  border-radius: 999px;
  background: #fff5bd;
  color: #4d4318;
  font-size: 12px;
  font-weight: 800;
}

.gold-rate-pill .edit-button {
  height: 28px;
  padding: 0 10px;
  background: #171b22;
  color: #fff;
  font-size: 12px;
}

.edit-button {
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--primary);
  font-weight: 800;
}

.ledger-actions {
  display: flex;
  gap: 6px;
}

.item-main {
  min-width: 0;
}

.item-title {
  font-weight: 750;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.amount.expense {
  color: var(--expense);
}

.amount.income {
  color: var(--income);
}

.amount.transfer {
  color: var(--transfer);
}

.toolbar {
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.toolbar input[type="search"] {
  flex: 1 1 280px;
}

.ledger-shell {
  display: grid;
  gap: 16px;
}

.ledger-hero {
  border-radius: 8px;
  background: linear-gradient(135deg, #e6f5f1 0%, #ffffff 74%);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 18px;
  box-shadow: var(--shadow);
}

.ledger-month {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ledger-month input {
  border: 0;
  background: white;
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 800;
  text-align: center;
}

.ghost-button {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: white;
  color: var(--primary);
  font-size: 24px;
  line-height: 1;
  border: 1px solid var(--line);
}

.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.ledger-totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.ledger-totals div {
  padding: 14px;
  border-radius: 8px;
  background: white;
  border: 1px solid var(--line);
}

.ledger-totals span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.ledger-totals strong {
  font-size: 24px;
}

.ledger-toolbar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 0;
}

.ledger-list {
  display: grid;
  gap: 12px;
}

.ledger-chart-inline {
  margin-top: 12px;
  padding: 10px 12px 2px;
  border: 1px solid rgba(181, 148, 30, 0.18);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.38);
}

.ledger-chart-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.ledger-chart-heading h2 {
  margin: 0;
  font-size: 13px;
}

.ledger-chart-heading span {
  color: var(--muted);
  font-size: 12px;
}

.ledger-chart-inline canvas {
  width: 100%;
  min-height: 150px;
}

.statistics-panel {
  display: grid;
  gap: 18px;
}

.statistics-heading,
.statistics-result-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.statistics-heading h2,
.statistics-heading p,
.statistics-result-heading h3 {
  margin: 0;
}

.statistics-heading p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.statistics-filters {
  display: grid;
  grid-template-columns: 100px minmax(140px, 1fr) minmax(140px, 1fr);
  gap: 8px;
}

.statistics-filters select {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 9px 11px;
}

.statistics-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.statistics-summary div {
  padding: 15px;
  border-radius: 16px;
  background: var(--surface-soft);
}

.statistics-summary span,
.statistics-result-heading span {
  color: var(--muted);
  font-size: 12px;
}

.statistics-summary span,
.statistics-summary strong {
  display: block;
}

.statistics-summary strong {
  margin-top: 6px;
  font-size: 21px;
}

.statistics-result-heading h3 {
  font-size: 16px;
}

.statistics-chart {
  padding: 12px 14px 4px;
  border-radius: 18px;
  background: var(--surface-soft);
}

.statistics-chart canvas {
  width: 100%;
  min-height: 260px;
}

.day-group {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: #fbfcfd;
  border-bottom: 1px solid var(--line);
}

.day-title {
  font-weight: 850;
}

.day-subtotal {
  display: flex;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.ledger-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.ledger-row:last-child {
  border-bottom: 0;
}

.ledger-icon {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: var(--primary-soft);
  display: grid;
  place-items: center;
  font-weight: 850;
  color: var(--primary);
}

.ledger-icon.expense {
  background: #e5f5ed;
  color: var(--expense);
}

.ledger-icon.income {
  background: #fff0eb;
  color: var(--income);
}

.ledger-icon.transfer {
  background: #edf3ff;
  color: var(--transfer);
}

.ledger-main {
  min-width: 0;
}

.ledger-title {
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ledger-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 840px;
}

canvas {
  width: 100%;
  max-width: 100%;
  display: block;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-weight: 700;
  background: #fbfcfd;
}

td.right,
th.right {
  text-align: right;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: #3d4a56;
  font-size: 12px;
  margin: 2px 4px 2px 0;
}

.delete-button {
  background: #fff2ed;
  color: var(--danger);
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.bar {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  overflow: hidden;
  margin-top: 8px;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--primary);
}

.asset-layout,
.possessions-layout,
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 16px;
}

.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.taxonomy-panel {
  grid-column: span 2;
}

.eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--primary-strong);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.taxonomy-page-head,
.settings-intro {
  margin-bottom: 18px;
  padding: 2px 2px 0;
}

.taxonomy-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.taxonomy-page-head h2,
.settings-intro h2,
.account-identity h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.035em;
}

.taxonomy-page-head p,
.settings-intro p,
.account-identity p {
  max-width: 680px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.taxonomy-summary {
  display: flex;
  gap: 10px;
}

.taxonomy-summary div {
  min-width: 92px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  text-align: center;
  box-shadow: var(--soft-shadow);
}

.taxonomy-summary strong,
.taxonomy-summary span {
  display: block;
}

.taxonomy-summary strong {
  font-size: 23px;
}

.taxonomy-summary span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.taxonomy-library-panel {
  grid-column: auto;
}

.taxonomy-panel {
  padding: 12px;
}

.taxonomy-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.taxonomy-toolbar > span {
  color: var(--muted);
  font-size: 12px;
}

.taxonomy-toolbar strong {
  color: var(--text);
}

.taxonomy-toolbar .primary-button {
  height: 32px;
  padding: 0 12px;
}

.account-page-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.account-hero {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 25px;
  border-radius: 24px;
  color: #fff;
  background: linear-gradient(125deg, #111820, #163f52 72%, #087eaf);
  box-shadow: 0 20px 48px rgba(17, 31, 42, 0.18);
}

.account-hero .eyebrow,
.account-hero p {
  color: rgba(255, 255, 255, 0.68);
}

.account-avatar {
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 22px;
  color: #11202a;
  background: linear-gradient(135deg, #fff4a8, #f4cf38);
  font-size: 27px;
  font-weight: 900;
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  color: #dffbed;
  background: rgba(24, 190, 117, 0.15);
  font-size: 13px;
  font-weight: 750;
}

.connection-pill i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #43db92;
  box-shadow: 0 0 0 4px rgba(67, 219, 146, 0.12);
}

.account-details {
  margin: 0;
}

.account-details div,
.app-info-list div {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.account-details div:last-child,
.app-info-list div:last-child {
  border-bottom: 0;
}

.account-details dt,
.app-info-list span {
  color: var(--muted);
}

.account-details dd {
  max-width: 70%;
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 750;
  text-align: right;
}

.account-sync-hint {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.account-data-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 12px;
}

.account-data-stats div {
  padding: 15px 10px;
  border-radius: 15px;
  background: var(--surface-soft);
  text-align: center;
}

.account-data-stats strong,
.account-data-stats span {
  display: block;
}

.account-data-stats strong {
  font-size: 22px;
}

.account-data-stats span,
.account-data-panel small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.account-actions-panel .danger-button,
.danger-zone-panel .danger-button,
.settings-action {
  width: 100%;
  margin-top: 14px;
}

.data-portability-panel {
  grid-row: span 2;
}

.danger-zone-panel {
  border-color: rgba(214, 81, 55, 0.22);
  background: #fffafa;
}

.app-info-list strong {
  text-align: right;
}

.panel-description {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.asset-overview {
  grid-column: 1 / -1;
}

.possession-overview {
  grid-column: 1 / -1;
}

.possession-list {
  display: grid;
  gap: 10px;
}

.possession-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.possession-costs {
  display: grid;
  justify-items: end;
  gap: 4px;
}

.possession-costs strong {
  color: var(--primary);
}

.possession-costs span {
  color: var(--muted);
  font-size: 12px;
}

.asset-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.asset-summary div {
  padding: 14px;
  border-radius: 8px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.asset-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.asset-summary strong {
  font-size: 20px;
}

.button-stack {
  display: grid;
  gap: 9px;
  margin-bottom: 10px;
}

.button-stack button,
.compact-form button,
.file-import,
.danger-button {
  padding: 10px 12px;
  background: var(--surface-soft);
  color: var(--text);
  text-align: center;
}

.file-import {
  display: block;
  margin-top: 10px;
}

.file-import input {
  display: none;
}

.csv-status {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-soft);
  margin-bottom: 12px;
}

.csv-status span {
  font-weight: 800;
}

.csv-status small {
  color: var(--muted);
  line-height: 1.45;
}

.compact-form {
  display: grid;
  grid-template-columns: 1fr 110px 54px 72px;
  gap: 8px;
  margin-bottom: 14px;
}

.tag-category-form {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) 72px;
}

.taxonomy-create-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 92px 40px auto;
  gap: 8px;
  padding: 10px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.taxonomy-create-form input:not([type="color"]),
.taxonomy-create-form select,
.taxonomy-category-editor input:not([type="color"]),
.taxonomy-category-editor select,
.taxonomy-tag-editor input,
.taxonomy-tag-editor select,
.taxonomy-add-tag input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
}

.taxonomy-create-form input:focus,
.taxonomy-create-form select:focus,
.taxonomy-category-editor input:focus,
.taxonomy-category-editor select:focus,
.taxonomy-tag-editor input:focus,
.taxonomy-tag-editor select:focus,
.taxonomy-add-tag input:focus {
  outline: 3px solid rgba(7, 152, 214, 0.12);
  border-color: rgba(7, 152, 214, 0.45);
}

.color-control,
.taxonomy-category-editor input[type="color"] {
  width: 40px;
  height: 36px;
}

.color-control {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.color-control input,
.taxonomy-category-editor input[type="color"] {
  padding: 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.taxonomy-list {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
}

.taxonomy-card {
  flex: 0 0 auto;
  width: 220px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--category-color) 12%, #fff), #f7f9fb);
  box-shadow: 0 4px 16px rgba(24, 39, 52, 0.1);
}

.taxonomy-size-small {
  width: 160px;
}

.taxonomy-size-medium {
  width: 230px;
}

.taxonomy-size-large {
  width: 310px;
}

.taxonomy-size-wide {
  width: 390px;
}

.taxonomy-size-small .taxonomy-type,
.taxonomy-size-small .taxonomy-count {
  display: none;
}

.taxonomy-card:has(.taxonomy-category-editor:not(.hidden)),
.taxonomy-card:has(.taxonomy-tag-editor:not(.hidden)),
.taxonomy-card:has(.taxonomy-add-tag:not(.hidden)) {
  width: min(620px, 100%);
  overflow: auto;
}

.taxonomy-category-summary {
  order: 1;
  min-height: 38px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
}

.taxonomy-category-summary strong {
  font-size: 14px;
}

.taxonomy-category-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--category-color, var(--primary));
}

.taxonomy-type {
  color: var(--muted);
  font-size: 11px;
}

.taxonomy-category-summary .taxonomy-count {
  margin-right: auto;
}

.taxonomy-category-editor,
.taxonomy-tag-editor {
  order: 3;
  display: grid;
  grid-template-columns: 40px minmax(120px, 1fr) 88px auto 28px;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.taxonomy-category-name {
  font-weight: 800;
}

.taxonomy-count {
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #edf1f4;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.taxonomy-tags {
  order: 2;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  padding: 6px 8px 8px;
}

.taxonomy-tag-chip {
  max-width: 100%;
  min-height: 26px;
  display: inline-flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--tag-color) 18%, #fff);
  border-radius: 999px;
  color: #3d4a56;
  background: color-mix(in srgb, var(--tag-color) 13%, #fff);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
}

.taxonomy-tag-chip > span:last-child {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.taxonomy-tag-chip:hover,
.taxonomy-tag-chip.active {
  border-color: rgba(7, 152, 214, 0.4);
  background: color-mix(in srgb, var(--tag-color) 22%, #fff);
}

.taxonomy-tag-editor {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(130px, 0.7fr) auto 28px;
}

.taxonomy-tag-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tag-color, var(--primary));
}

.taxonomy-name-input {
  font-weight: 700;
}

.taxonomy-add-tag {
  order: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  padding: 7px 9px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.taxonomy-add-tag button {
  padding: 7px 11px;
  border-radius: 8px;
  color: var(--primary-strong);
  background: var(--primary-soft);
  font-weight: 750;
}

.taxonomy-save-button,
.taxonomy-delete-button {
  height: 28px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 800;
}

.taxonomy-save-button {
  padding: 0 9px;
  color: var(--primary-strong);
  background: var(--primary-soft);
}

.taxonomy-delete-button {
  width: 28px;
  color: var(--danger);
  background: transparent;
}

.taxonomy-delete-button:hover {
  background: #fff2ed;
}

.taxonomy-text-button,
.taxonomy-icon-button {
  height: 27px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
}

.taxonomy-text-button {
  padding: 0 6px;
}

.taxonomy-icon-button {
  width: 30px;
  letter-spacing: 1px;
}

.taxonomy-text-button:hover,
.taxonomy-icon-button:hover {
  color: var(--primary-strong);
  background: var(--primary-soft);
  border-radius: 7px;
}

.taxonomy-empty,
.taxonomy-empty-state {
  padding: 15px 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.taxonomy-empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.taxonomy-unassigned {
  --category-color: #a0a7b1;
}

.taxonomy-unassigned-heading {
  justify-content: flex-start;
}

.taxonomy-unassigned-heading .taxonomy-count {
  margin-right: 0;
}

.chip-list {
  display: grid;
  gap: 8px;
}

.category-chip,
.tag-map-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--chip-color, var(--accent));
  border-radius: 8px;
  background: #fff;
}

.category-chip span,
.tag-map-row strong {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.tag-map-list {
  display: grid;
  gap: 8px;
}

.chip {
  border-radius: 999px;
  padding: 7px 10px;
  color: white;
  font-size: 12px;
  font-weight: 700;
}

.danger-button {
  background: #fff2ed;
  color: var(--danger);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #101820;
  color: white;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* App-style redesign inspired by lightweight mobile finance/product trackers. */
.primary-button {
  background: #171b22;
  border-radius: 999px;
  color: #fff;
  box-shadow: 0 12px 24px rgba(23, 27, 34, 0.14);
}

.primary-button:hover {
  background: #000;
}

.secondary-button,
.icon-button,
.button-stack button,
.compact-form button,
.file-import,
.danger-button {
  border-radius: 999px;
}

.metric-grid {
  gap: 0;
  padding: 18px;
  border-radius: 24px;
  background: linear-gradient(135deg, #11bce9 0%, #087be4 100%);
  box-shadow: 0 18px 40px rgba(7, 130, 218, 0.2);
}

.metric {
  min-height: 102px;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 10px 16px;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  color: #fff;
}

.metric + .metric {
  border-left: 1px solid rgba(255, 255, 255, 0.24);
}

.metric span {
  color: rgba(255, 255, 255, 0.78);
  margin-bottom: 9px;
}

.metric strong {
  color: #fff;
  font-size: 24px;
}

.panel,
.table-wrap,
.day-group,
.ledger-toolbar,
.ledger-hero {
  border-radius: 20px;
  border-color: transparent;
  box-shadow: var(--soft-shadow);
}

.panel {
  padding: 20px;
}

.panel-heading {
  margin-bottom: 18px;
}

.panel-heading h2 {
  font-size: 17px;
}

.entry-form input,
.entry-form select,
.toolbar input,
.toolbar select,
.compact-form input,
.compact-form select,
.modal-panel input,
.modal-panel select,
.panel-heading select {
  border-radius: 14px;
  border-color: #e3e8ef;
  background: #f9fafc;
}

.entry-form input:focus,
.entry-form select:focus,
.toolbar input:focus,
.toolbar select:focus,
.compact-form input:focus,
.compact-form select:focus {
  outline: 3px solid rgba(7, 152, 214, 0.12);
  border-color: rgba(7, 152, 214, 0.45);
  background: #fff;
}

.segmented {
  padding: 3px;
  border-radius: 999px;
  background: #eef2f6;
}

.segmented label {
  border-radius: 999px;
  height: 34px;
}

.segmented label:has(input:checked) {
  background: #171b22;
  color: #fff;
  box-shadow: none;
}

.ledger-hero {
  background: linear-gradient(135deg, #fff0a9 0%, #fff9de 58%, #ffffff 100%);
  border: 1px solid #f1de78;
}

.ledger-month input {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
}

.ledger-totals div {
  border: 0;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.74);
}

.ledger-totals strong {
  font-size: 23px;
}

.day-group {
  overflow: hidden;
}

.day-header {
  background: #fff;
  border-bottom-color: #f0f2f5;
}

.ledger-row {
  grid-template-columns: 44px minmax(0, 1fr) auto auto;
  gap: 13px;
  padding: 14px 16px;
  border-bottom-color: #f1f3f6;
  background: #fff;
}

.ledger-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #fff3bd;
  color: #3a341b;
}

.ledger-icon.expense {
  background: #e6f7ef;
  color: var(--expense);
}

.ledger-icon.income {
  background: #ffe9e5;
  color: var(--income);
}

.amount.expense {
  color: var(--expense);
}

.amount.income {
  color: var(--income);
}

.edit-button {
  border-radius: 999px;
  background: #eef7fb;
  color: var(--primary);
}

.delete-button {
  border-radius: 999px;
}

.tag {
  background: #f0f3f7;
  color: #596272;
}

.asset-overview canvas,
.possession-overview canvas {
  min-height: 260px;
}

.rank-item,
.list-item,
.account-card,
.category-chip,
.tag-map-row {
  border-radius: 16px;
  border-color: #edf0f4;
  background: #fff;
}

.rank-item {
  padding: 14px 4px 14px 0;
  border: 0;
  border-bottom: 1px solid #f0f2f5;
  border-radius: 0;
}

.rank-item:last-child {
  border-bottom: 0;
}

.bar {
  height: 7px;
  background: #f0f2f5;
}

.rank-item .bar span {
  background: #f7d746;
}

.asset-overview {
  background: linear-gradient(135deg, #ffffff 0%, #eef8f6 100%);
}

.possession-overview {
  background: linear-gradient(135deg, #10b9ea 0%, #087ce4 100%);
  color: #fff;
  border: 0;
  box-shadow: 0 18px 40px rgba(7, 130, 218, 0.2);
}

.possession-overview h2,
.possession-overview .item-title,
.possession-overview strong {
  color: #fff;
}

.possession-overview .item-sub,
.possession-overview .asset-summary span {
  color: rgba(255, 255, 255, 0.76);
}

.possession-overview .asset-summary div {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.13);
  border-radius: 18px;
}

.possession-overview .bar {
  background: rgba(255, 255, 255, 0.22);
}

.possession-overview .bar span {
  background: #fff;
}

.possession-list {
  gap: 12px;
}

.possession-card {
  position: relative;
  grid-template-columns: 48px minmax(0, 1fr) 76px auto;
  min-height: 104px;
  padding: 16px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(135deg, #70d47f 0%, #41bd72 100%);
  color: #fff;
  box-shadow: 0 10px 22px rgba(38, 155, 95, 0.18);
}

.possession-card:nth-child(2n) {
  background: linear-gradient(135deg, #b989ee 0%, #8d61d8 100%);
  box-shadow: 0 10px 22px rgba(119, 80, 192, 0.18);
}

.possession-card:nth-child(3n) {
  background: linear-gradient(135deg, #5fcfe7 0%, #20a1d8 100%);
  box-shadow: 0 10px 22px rgba(32, 161, 216, 0.18);
}

.possession-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.possession-card .item-title {
  color: #fff;
  font-size: 18px;
  line-height: 1.2;
}

.possession-card .item-sub {
  color: rgba(255, 255, 255, 0.78);
}

.possession-card .item-main {
  display: grid;
  gap: 8px;
}

.possession-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.possession-category {
  flex: 0 0 auto;
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.88);
  font-size: 12px;
  font-weight: 800;
}

.possession-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.possession-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  font-weight: 750;
}

.possession-note {
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.possession-days {
  display: flex;
  align-items: baseline;
  gap: 3px;
  min-width: 76px;
  justify-content: flex-end;
}

.possession-days strong {
  font-size: 30px;
  line-height: 1;
}

.possession-days span {
  color: rgba(255, 255, 255, 0.82);
  font-weight: 800;
}

.possession-card .ledger-actions {
  align-self: stretch;
  display: grid;
  align-content: center;
  gap: 7px;
}

.possession-card .edit-button,
.possession-card .delete-button {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.possession-card .delete-button {
  width: 32px;
  height: 32px;
}

.asset-summary div {
  border-radius: 18px;
  border-color: #edf0f4;
  background: #f8fafc;
}

.csv-status,
.advanced-fields,
.modal-panel {
  border-radius: 18px;
}

.toast {
  border-radius: 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: repeat(4, minmax(0, 1fr));
  }

  .nav-item {
    text-align: center;
    padding: 10px 6px;
  }

  .sidebar-footer {
    display: none;
  }

  .metric-grid,
  .dashboard-grid,
  .asset-layout,
  .possessions-layout,
  .account-page-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .account-hero,
  .data-portability-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .possession-overview {
    grid-column: auto;
  }

  .taxonomy-panel {
    grid-column: auto;
  }

  .metric-grid {
    gap: 1px;
  }

  .metric + .metric {
    border-left: 0;
  }
}

@media (max-width: 620px) {
  .main {
    padding: 18px;
  }

  .taxonomy-page-head,
  .account-hero {
    align-items: flex-start;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .taxonomy-summary {
    width: 100%;
  }

  .taxonomy-summary div {
    flex: 1;
  }

  .taxonomy-create-form {
    grid-template-columns: minmax(0, 1fr) 82px 40px;
  }

  .taxonomy-create-form .primary-button {
    grid-column: 1 / -1;
  }

  .statistics-heading,
  .statistics-result-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .statistics-filters,
  .statistics-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .taxonomy-list {
    gap: 8px;
  }

  .taxonomy-size-small {
    width: calc(50% - 4px);
  }

  .taxonomy-size-medium {
    width: min(210px, 100%);
  }

  .taxonomy-size-large {
    width: min(280px, 100%);
  }

  .taxonomy-size-wide {
    width: 100%;
  }

  .taxonomy-card:has(.taxonomy-category-editor:not(.hidden)),
  .taxonomy-card:has(.taxonomy-tag-editor:not(.hidden)),
  .taxonomy-card:has(.taxonomy-add-tag:not(.hidden)) {
    width: 100%;
  }

  .taxonomy-category-summary {
    gap: 6px;
  }

  .taxonomy-category-summary strong {
    max-width: 35vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .taxonomy-tags {
    padding: 8px;
  }

  .taxonomy-category-editor {
    grid-template-columns: 40px minmax(0, 1fr) 48px;
  }

  .taxonomy-category-editor [data-category-type] {
    grid-column: 2;
  }

  .taxonomy-category-editor [data-save-category] {
    grid-column: 3;
    grid-row: 2;
  }

  .taxonomy-category-editor [data-delete-category] {
    grid-column: 3;
    grid-row: 1;
  }

  .taxonomy-tag-editor {
    grid-template-columns: minmax(0, 1fr) 48px;
  }

  .taxonomy-tag-editor [data-tag-category] {
    grid-column: 1;
  }

  .taxonomy-tag-editor [data-save-tag] {
    grid-column: 2;
    grid-row: 2;
  }

  .taxonomy-tag-editor [data-delete-tag] {
    grid-column: 2;
    grid-row: 1;
  }

  .taxonomy-category-row {
    grid-template-columns: 40px minmax(0, 1fr) 48px;
  }

  .taxonomy-category-row [data-category-name] {
    grid-column: 2;
  }

  .taxonomy-category-row [data-category-type] {
    grid-column: 2;
  }

  .taxonomy-category-row .taxonomy-count {
    grid-column: 1;
    grid-row: 2;
  }

  .taxonomy-category-row [data-save-category] {
    grid-column: 3;
    grid-row: 2;
  }

  .taxonomy-category-row [data-delete-category] {
    grid-column: 3;
    grid-row: 1;
  }

  .taxonomy-tag-row {
    grid-template-columns: 10px minmax(0, 1fr) 48px;
  }

  .taxonomy-tag-row [data-tag-category] {
    grid-column: 2;
  }

  .taxonomy-tag-row [data-save-tag] {
    grid-column: 3;
    grid-row: 2;
  }

  .taxonomy-tag-row [data-delete-tag] {
    grid-column: 3;
    grid-row: 1;
  }

  .taxonomy-add-tag {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions .primary-button {
    flex: 1;
  }

  .form-row,
  .two-col,
  .ledger-totals,
  .asset-summary,
  .compact-form {
    grid-template-columns: 1fr;
  }

  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .possession-card {
    grid-template-columns: 44px minmax(0, 1fr) 68px;
    align-items: start;
  }

  .possession-icon {
    width: 44px;
    height: 44px;
  }

  .possession-title-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .possession-category {
    max-width: 100%;
  }

  .possession-card .ledger-actions {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-self: auto;
  }

  .possession-card .delete-button {
    width: 100%;
  }
}
/* Cloud edition authentication */
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 18% 14%, rgba(7, 152, 214, 0.2), transparent 34%),
    radial-gradient(circle at 84% 82%, rgba(245, 207, 56, 0.18), transparent 30%),
    #f5f7fa;
}

.auth-screen.hidden {
  display: none;
}

.auth-card {
  width: min(440px, 100%);
  display: grid;
  gap: 18px;
  padding: 40px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.14);
}

.auth-card h1,
.auth-card p {
  margin: 0;
}

.auth-card p {
  color: #64748b;
  line-height: 1.6;
}

.auth-card label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-weight: 650;
}

.auth-card label small {
  color: #8490a0;
  font-size: 12px;
  font-weight: 450;
  line-height: 1.5;
}

.auth-eyebrow {
  width: fit-content;
  padding: 5px 9px;
  border-radius: 999px;
  color: #0479b0;
  background: #e7f7fd;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-logo {
  width: 44px;
  height: 44px;
}

.auth-error {
  min-height: 20px;
  color: #b91c1c;
  font-size: 14px;
}
