:root {
  --bg0: #070a10;
  --bg1: #0d121c;
  --card: rgba(18, 24, 36, 0.72);
  --stroke: rgba(255, 255, 255, 0.09);
  --text: #e9eef7;
  --muted: #8b98ad;
  --accent: #3ee0b3;
  --accent2: #8b7bff;
  --danger: #ff6b8a;
  --income: #5cf0c4;
  --expense: #ff8da1;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: "Outfit", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background: radial-gradient(1200px 800px at 20% -10%, rgba(62, 224, 179, 0.12), transparent),
    radial-gradient(900px 600px at 100% 0%, rgba(139, 123, 255, 0.14), transparent),
    linear-gradient(165deg, var(--bg0), var(--bg1) 55%, #06080d);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
}

.hidden {
  display: none !important;
}

.glass {
  background: var(--card);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

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

.no-tg__card {
  max-width: 420px;
  padding: 28px;
  border-radius: var(--radius);
  text-align: center;
}

.no-tg__card h1 {
  margin: 0 0 12px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.root {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  margin: 12px 12px 0;
  padding: 14px 16px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.brand__logo {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(62, 224, 179, 0.25), rgba(139, 123, 255, 0.35));
  border: 1px solid var(--stroke);
  font-size: 18px;
  color: var(--accent);
}

.brand__name {
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: 1.15rem;
}

.brand__sub {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rate-pill {
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  flex-shrink: 0;
}

.main {
  flex: 1;
  padding: 16px 12px 96px;
}

.panel {
  animation: fade 0.28s ease;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.segment {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.segment--period .seg-btn {
  flex: 1 1 auto;
  min-width: 72px;
}

.seg-btn {
  flex: 1;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.seg-btn.is-active {
  border-color: rgba(62, 224, 179, 0.45);
  background: linear-gradient(135deg, rgba(62, 224, 179, 0.18), rgba(139, 123, 255, 0.12));
  box-shadow: 0 0 0 1px rgba(62, 224, 179, 0.15) inset;
}

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

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.stat-card {
  padding: 14px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.03);
}

.stat-card__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat-card__value {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  word-break: break-all;
}

.stat-card__unit {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 4px;
}

.stat-card--in .stat-card__value {
  color: var(--income);
}
.stat-card--out .stat-card__value {
  color: var(--expense);
}
.stat-card--bal .stat-card__value {
  color: var(--accent);
}

.block {
  margin-bottom: 18px;
}

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

.block__head h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #dfe7f5;
}

.chart-sub {
  font-size: 0.72rem;
  color: var(--muted);
  max-width: 55%;
  text-align: right;
  line-height: 1.35;
}

.chart-wrap {
  position: relative;
  height: min(280px, 52vh);
  padding: 8px 4px 4px;
  border-radius: var(--radius-sm);
}

.chart-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.tag-cloud {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tag-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.02);
}

.tag-row__name {
  color: var(--text);
  font-weight: 500;
}

.tag-row__amt {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--expense);
}

.tx-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tx-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.02);
}

.tx-item__badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 1rem;
  border: 1px solid var(--stroke);
}

.tx-item--in .tx-item__badge {
  background: rgba(92, 240, 196, 0.12);
  color: var(--income);
}

.tx-item--out .tx-item__badge {
  background: rgba(255, 141, 161, 0.12);
  color: var(--expense);
}

.tx-item__mid {
  min-width: 0;
}

.tx-item__title {
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-item__meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}

.tx-item__amt {
  text-align: right;
  font-family: var(--mono);
  font-size: 0.88rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 0.8rem;
  color: var(--muted);
}

.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font);
  outline: none;
}

.input:focus {
  border-color: rgba(62, 224, 179, 0.45);
  box-shadow: 0 0 0 3px rgba(62, 224, 179, 0.12);
}

.row2 {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 10px;
}

.preview {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--accent);
}

.tag-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-chip {
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.tag-chip.is-on {
  border-color: rgba(139, 123, 255, 0.55);
  background: rgba(139, 123, 255, 0.15);
}

.btn-primary,
.btn-secondary,
.btn-ghost {
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 600;
  border-radius: 14px;
  padding: 14px 16px;
  width: 100%;
  transition: transform 0.1s, filter 0.15s;
}

.btn-primary {
  background: linear-gradient(135deg, #3ee0b3, #48c7ff);
  color: #041018;
  box-shadow: 0 12px 30px rgba(62, 224, 179, 0.25);
}

.btn-primary:active {
  transform: scale(0.99);
}

.btn-secondary {
  width: auto;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--stroke);
}

.btn-ghost {
  width: auto;
  padding: 6px 10px;
  font-size: 0.8rem;
  background: transparent;
  color: var(--muted);
}

.hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 10px;
  min-height: 1.2em;
}

.lead {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
  margin: 0 0 12px;
}

.inline-add {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.inline-add .input {
  margin-bottom: 0;
}

.settings-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.02);
  font-size: 0.92rem;
}

.settings-line__name {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.settings-line__actions {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
  align-items: center;
}

.btn-mini {
  border: none;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  white-space: nowrap;
}

.btn-mini--neutral {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--stroke);
}

.btn-mini--danger {
  background: rgba(255, 107, 138, 0.15);
  color: var(--danger);
}

.bottom {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 12px;
  width: calc(100% - 24px);
  max-width: 500px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  border-radius: 20px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  z-index: 20;
}

.nav-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 8px 4px;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.65rem;
  font-weight: 600;
}

.nav-btn__i {
  font-size: 1.1rem;
  opacity: 0.85;
}

.nav-btn.is-active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

@media (min-width: 540px) {
  .bottom {
    bottom: 20px;
  }
}
