:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #0f131b;
  --panel: #171d27;
  --panel-soft: #202735;
  --surface: #111722;
  --surface-soft: #141b27;
  --text: #f6f7fb;
  --muted: #9ca7ba;
  --line: #2e3849;
  --line-soft: rgba(255, 255, 255, 0.06);
  --green: #58d68d;
  --red: #ff7a7a;
  --blue: #75b7ff;
  --gold: #f5c86a;
  --accent: #7cc7a2;
  --focus: #d9f99d;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: linear-gradient(180deg, #111722 0%, var(--bg) 42%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

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

.lock-panel {
  width: min(100%, 420px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 29, 40, 0.96);
  box-shadow: var(--shadow);
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  margin-bottom: 22px;
  color: #0f151d;
  background: var(--accent);
  font-weight: 800;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 6vw, 3.4rem);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

.stack,
.form-grid,
.dialog-body {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #0d121a;
  padding: 10px 12px;
}

.primary,
.secondary,
.small-button,
.icon-button,
.top-action-button,
.tab {
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 800;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.primary {
  min-height: 46px;
  color: #07110d;
  background: var(--accent);
}

.secondary,
.small-button,
.icon-button,
.tab {
  color: var(--text);
  background: var(--panel-soft);
  border-color: var(--line);
}

button:hover {
  border-color: rgba(124, 199, 162, 0.55);
}

button:active {
  transform: translateY(1px);
}

.small-button {
  min-height: 34px;
  padding: 0 12px;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
}

.top-action-button {
  min-height: 42px;
  padding: 0 12px;
  color: var(--text);
  background: var(--panel-soft);
  border-color: var(--line);
}

.top-action-button.icon-button {
  width: 42px;
  padding: 0;
}

.ui-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

#save-button .ui-icon {
  color: var(--accent);
}

#lock-button .ui-icon {
  color: var(--gold);
}

#allocation-view-button .ui-icon {
  color: var(--blue);
}

.status-text,
.hint {
  min-height: 1.2rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0 14px;
}

.topbar h1 {
  margin: 0;
}

.eyebrow {
  margin-bottom: 2px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 8px 0 18px;
  background: rgba(16, 19, 26, 0.92);
  backdrop-filter: blur(14px);
}

.tab {
  min-height: 42px;
  color: var(--muted);
}

.tab.active {
  color: #07110d;
  background: var(--accent);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 29, 40, 0.96);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.9fr);
  gap: 14px;
  margin-bottom: 14px;
}

.panel {
  padding: 16px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-heading span {
  color: var(--muted);
  font-size: 0.85rem;
}

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.span-panel {
  grid-column: 1 / -1;
}

.bar-list,
.account-list,
.transaction-list,
.compact-list,
.security-list {
  display: grid;
  gap: 10px;
}

.category-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.category-tile,
.account-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.category-tile {
  display: grid;
  gap: 10px;
  min-height: 116px;
  padding: 16px;
}

.category-tile span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.category-tile strong {
  font-size: clamp(1.25rem, 2vw, 1.8rem);
}

.account-section {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.account-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.account-section-heading h3 {
  margin: 0;
  font-size: 0.95rem;
}

.category-savings {
  border-color: rgba(88, 214, 141, 0.42);
}

.category-investments {
  border-color: rgba(245, 166, 35, 0.52);
}

.category-current {
  border-color: rgba(245, 200, 106, 0.48);
}

.category-total {
  border-color: rgba(117, 183, 255, 0.55);
  background: linear-gradient(180deg, rgba(117, 183, 255, 0.16), var(--surface) 62%);
}

.bar-row {
  display: grid;
  gap: 7px;
}

.bar-top,
.account-row,
.transaction-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #0e131b;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--gold));
}

.allocation-fill {
  background: linear-gradient(90deg, var(--blue), var(--accent));
}

.goal-fill {
  background: linear-gradient(90deg, var(--gold), var(--green));
}

.allocation-visual {
  min-height: 176px;
}

.allocation-donut-layout {
  display: grid;
  grid-template-columns: minmax(170px, 240px) minmax(0, 1fr);
  align-items: center;
  gap: 18px;
}

.donut-chart {
  position: relative;
  display: grid;
  width: min(240px, 64vw);
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  margin: 0 auto;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.24);
}

.donut-chart::before {
  content: "";
  position: absolute;
  inset: 28px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.25);
}

.donut-chart > div {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 2px;
  text-align: center;
}

.donut-chart strong {
  color: var(--text);
  font-size: 1.45rem;
}

.donut-chart span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.allocation-legend {
  display: grid;
  gap: 8px;
}

.legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(15, 20, 29, 0.62);
}

.legend-row span {
  display: flex;
  align-items: center;
  min-width: 0;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 800;
}

.legend-row i {
  display: inline-block;
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-right: 8px;
}

.legend-row strong {
  flex: 0 0 auto;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-right: 8px;
}

.professional-bars {
  gap: 12px;
}

.professional-bars .bar-row {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 12px;
  background: rgba(15, 20, 29, 0.58);
}

.professional-bars .bar-track {
  height: 14px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  background: #0b1018;
}

.professional-bars .bar-fill {
  box-shadow: 0 0 18px rgba(124, 199, 162, 0.16);
}

.allocation-block-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.allocation-block-card {
  display: grid;
  align-content: space-between;
  gap: 12px;
  min-height: 112px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 12px;
  background:
    linear-gradient(180deg, rgba(124, 199, 162, 0.16), transparent 80%),
    #101722;
}

.allocation-block-card::before {
  content: "";
  width: 34px;
  height: 5px;
  border-radius: 999px;
  background: var(--block-color);
}

.allocation-block-card span {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.allocation-block-card strong {
  color: var(--block-color);
  font-size: 1.2rem;
}

.list-toggle {
  width: 100%;
  min-height: 40px;
}

.account-row,
.transaction-row,
.compact-row {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface);
}

.historical-row {
  opacity: 0.68;
  background: #0f141d;
}

.account-row strong,
.transaction-row strong,
.compact-row strong {
  display: block;
}

.account-row span,
.transaction-row span,
.compact-row span {
  color: var(--muted);
  font-size: 0.82rem;
}

.compact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 150px;
}

.amount-income {
  color: var(--green);
}

.amount-expense {
  color: var(--red);
}

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

.span-2 {
  grid-column: 1 / -1;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d121a;
}

.checkbox-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.warning-text {
  color: var(--gold) !important;
}

.import-box {
  display: grid;
  gap: 12px;
}

.sync-actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.sync-actions button {
  min-height: 42px;
}

.filters {
  display: flex;
  gap: 8px;
  width: min(100%, 430px);
}

.filters input,
.filters select {
  min-height: 38px;
}

.security-panel {
  border-color: rgba(117, 183, 255, 0.35);
}

.security-list p {
  margin: 0;
  color: var(--muted);
}

dialog {
  width: min(92vw, 380px);
  max-height: 88vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: auto;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.64);
}

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

.empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  text-align: center;
}

@media (max-width: 780px) {
  .app-shell {
    padding: 14px;
  }

  .category-summary,
  .content-grid,
  .form-grid,
  .sync-actions {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .panel-heading.wrap {
    align-items: stretch;
    flex-direction: column;
  }

  .allocation-donut-layout {
    grid-template-columns: 1fr;
  }

  .filters {
    width: 100%;
  }
}

@media (max-width: 430px) {
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-actions {
    justify-content: space-between;
    width: 100%;
  }

  .panel-actions .small-button {
    flex: 0 0 auto;
  }

  .tabs {
    grid-template-columns: repeat(5, minmax(96px, 1fr));
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 12px;
  }

  .tab {
    font-size: 0.82rem;
  }

  .transaction-row,
  .account-row,
  .compact-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .row-actions {
    justify-content: space-between;
    width: 100%;
  }
}
