:root {
  color-scheme: light;
  --ink: #10201b;
  --ink-soft: #243a33;
  --muted: #6c7771;
  --line: #dde5df;
  --surface: #f4f6f3;
  --paper: #ffffff;
  --paper-soft: #fbfcfa;
  --accent: #f97316;
  --accent-soft: #fff0e3;
  --blue: #2563eb;
  --blue-soft: #e8efff;
  --good: #0f9f6e;
  --good-soft: #e8f8ef;
  --bad: #dc2626;
  --bad-soft: #fff1f2;
  --shadow: 0 18px 42px rgba(16, 32, 27, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--surface);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  font: inherit;
}

button,
a,
select,
input {
  -webkit-tap-highlight-color: transparent;
}

button {
  touch-action: manipulation;
}

.shell {
  width: auto;
  max-width: 1180px;
  margin: 0 10px;
  padding: calc(14px + env(safe-area-inset-top)) 0 calc(92px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding: 10px;
  background: rgba(244, 246, 243, 0.92);
  backdrop-filter: blur(18px);
}

.brand-lockup {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.app-mark {
  display: grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--ink);
  box-shadow: 0 10px 24px rgba(16, 32, 27, 0.2);
}

.app-mark svg {
  width: 21px;
  height: 21px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1;
}

h2 {
  font-size: 20px;
  line-height: 1.1;
}

.top-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 46px;
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  color: #fff;
  background: var(--ink);
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.icon-button svg {
  width: 19px;
  height: 19px;
}

.icon-button:hover {
  transform: translateY(-1px);
  background: var(--ink-soft);
  box-shadow: 0 10px 22px rgba(16, 32, 27, 0.14);
}

.icon-button.subtle {
  color: var(--ink);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
}

.icon-button.subtle:hover {
  background: #fff;
}

.status-panel {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 156px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.status-panel > div:last-child {
  min-width: 0;
}

.status-icon {
  display: grid;
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 8px;
  color: var(--ink);
  background: var(--accent-soft);
}

.status-icon svg {
  width: 24px;
  height: 24px;
}

.status-panel p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.money-hero {
  overflow: hidden;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(145deg, #10201b 0%, #173a32 58%, #2f443d 100%);
  box-shadow: var(--shadow);
  animation: lift 360ms ease both;
}

.hero-main {
  display: flex;
  min-height: 150px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
}

.hero-main .eyebrow {
  color: rgba(255, 255, 255, 0.66);
}

.hero-balance {
  display: block;
  max-width: 100%;
  margin-top: 10px;
  font-size: 40px;
  line-height: 0.98;
  overflow-wrap: anywhere;
}

.hero-balance.is-negative {
  color: #fecaca;
}

.sync-chip {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  max-width: 132px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  padding: 0 10px;
  color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
}

.sync-chip svg {
  width: 14px;
  height: 14px;
  color: #fed7aa;
}

.sync-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: rgba(255, 255, 255, 0.12);
}

.metric {
  display: grid;
  min-height: 104px;
  align-content: start;
  gap: 7px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.08);
}

.metric svg {
  width: 18px;
  height: 18px;
  color: #fed7aa;
}

.metric span {
  color: rgba(255, 255, 255, 0.65);
  font-size: 12px;
  font-weight: 800;
}

.metric strong {
  display: block;
  font-size: 20px;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.metric.positive svg,
.metric.positive strong,
.income {
  color: #6ee7b7;
}

.metric.accent strong {
  color: #fed7aa;
}

.expense {
  color: var(--bad);
}

.period-panel {
  position: sticky;
  top: 66px;
  z-index: 15;
  display: grid;
  gap: 10px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid rgba(221, 229, 223, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
  box-shadow: 0 10px 24px rgba(16, 32, 27, 0.06);
}

.period-fields {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 10px;
}

.period-panel label {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.period-panel label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.period-panel select,
.period-panel input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--paper-soft);
  outline: 0;
}

.period-panel select:focus,
.period-panel input:focus {
  border-color: rgba(249, 115, 22, 0.72);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.12);
}

.quick-periods {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.quick-periods button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.quick-periods button svg {
  width: 16px;
  height: 16px;
}

.quick-periods button:hover {
  transform: translateY(-1px);
  border-color: rgba(249, 115, 22, 0.42);
}

.quick-periods button.is-active {
  color: #9a3412;
  border-color: #fed7aa;
  background: var(--accent-soft);
}

.workspace {
  display: grid;
  gap: 12px;
}

.chart-zone,
.transactions-zone {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 12px 32px rgba(16, 32, 27, 0.06);
  animation: lift 420ms ease both;
}

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

.chart-canvas {
  position: relative;
  width: 100%;
}

.daily-canvas {
  height: 218px;
}

.doughnut-canvas {
  height: 268px;
}

.transactions {
  display: grid;
  gap: 8px;
}

.transaction {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.transaction:last-child {
  border-bottom: 0;
  padding-bottom: 4px;
}

.transaction-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  color: #9a3412;
  background: var(--accent-soft);
}

.transaction-icon.is-income {
  color: #047857;
  background: var(--good-soft);
}

.transaction-icon svg {
  width: 20px;
  height: 20px;
}

.transaction-main {
  min-width: 0;
}

.transaction-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.transaction-actions {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

.transaction strong,
.transaction span,
.transaction p {
  display: block;
}

.transaction strong {
  margin-bottom: 5px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

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

.transaction p {
  margin: 8px 0 0;
  color: #3f4b45;
  font-size: 13px;
  line-height: 1.38;
  overflow-wrap: anywhere;
}

.transaction b {
  flex: 0 0 auto;
  font-size: 15px;
  white-space: nowrap;
}

.delete-transaction {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.delete-transaction svg {
  width: 17px;
  height: 17px;
}

.delete-transaction:hover {
  color: var(--bad);
  border-color: #fecaca;
  background: var(--bad-soft);
}

.bottom-nav {
  position: fixed;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  left: max(10px, env(safe-area-inset-left));
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  max-width: 520px;
  margin: 0 auto;
  padding: 6px;
  border: 1px solid rgba(221, 229, 223, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 48px rgba(16, 32, 27, 0.18);
  backdrop-filter: blur(18px);
}

.bottom-nav a,
.bottom-nav button {
  display: grid;
  min-height: 54px;
  place-items: center;
  gap: 4px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.bottom-nav svg {
  width: 19px;
  height: 19px;
}

.bottom-nav a:active,
.bottom-nav button:active {
  color: var(--ink);
  background: var(--accent-soft);
}

.empty {
  margin: 0;
  padding: 18px;
  border-radius: 8px;
  color: var(--muted);
  background: var(--paper-soft);
}

[hidden] {
  display: none !important;
}

@keyframes lift {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 420px) {
  .shell {
    width: auto;
    margin-right: 8px;
    margin-left: 8px;
  }

  .topbar {
    padding-right: 8px;
    padding-left: 8px;
  }

  .top-actions {
    margin-right: 14px;
  }

  .icon-button {
    width: 46px;
    padding: 0;
    overflow: hidden;
  }

  .icon-button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .hero-main {
    min-height: 142px;
    padding: 20px;
  }

  .hero-balance {
    font-size: 35px;
  }

  .period-fields {
    grid-template-columns: 1fr;
  }

  .quick-periods button {
    gap: 5px;
    font-size: 12px;
  }

  .transaction-title {
    flex-direction: column;
    gap: 6px;
  }

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

@media (min-width: 760px) {
  .shell {
    width: min(1180px, calc(100% - 40px));
    margin-right: auto;
    margin-left: auto;
    padding-top: 24px;
    padding-bottom: 42px;
  }

  .topbar {
    margin: 0 0 22px;
    padding: 0;
    background: transparent;
    backdrop-filter: none;
  }

  h1 {
    font-size: 42px;
  }

  .money-hero {
    margin-bottom: 14px;
  }

  .hero-main {
    min-height: 180px;
    padding: 30px;
  }

  .hero-balance {
    font-size: 56px;
  }

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

  .period-panel {
    position: static;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    padding: 14px;
  }

  .period-fields {
    grid-template-columns: repeat(2, minmax(190px, 240px));
  }

  .quick-periods {
    min-width: 320px;
  }

  .workspace {
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
    gap: 14px;
  }

  .transactions-zone {
    grid-row: 1 / 3;
    grid-column: 2 / 3;
  }

  .bottom-nav {
    display: none;
  }
}
