:root {
  --bg: #09090b;
  --surface: #121215;
  --surface-2: #18181c;
  --surface-hover: #202026;
  --border: #27272a;
  --border-strong: #3f3f46;
  --text: #fafafa;
  --text-soft: #d4d4d8;
  --text-muted: #8e8e98;
  --accent: #fafafa;
  --accent-ink: #09090b;
  --positive: #22c55e;
  --positive-bg: rgba(34, 197, 94, 0.12);
  --negative: #f43f5e;
  --negative-bg: rgba(244, 63, 94, 0.12);
  --warning: #eab308;
  --warning-bg: rgba(234, 179, 8, 0.12);
  --neutral-bg: rgba(255, 255, 255, 0.06);
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Inter, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.app-shell {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  background: var(--bg);
}

.boot-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.boot-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--text);
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Header */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(9, 9, 11, 0.94);
  border-bottom: 1px solid var(--border);
}

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

.brand-badge {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  flex-shrink: 0;
}

.brand-titles {
  min-width: 0;
}

.brand-titles h1 {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--positive);
}

.sync-dot.offline {
  background: var(--warning);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-soft);
  display: grid;
  place-items: center;
  transition: background 0.15s ease;
}

.icon-btn:active {
  background: var(--surface-hover);
}

.offline-banner {
  margin: 10px 16px 0;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--warning-bg);
  border: 1px solid rgba(234, 179, 8, 0.3);
  color: #fde047;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Main */
.main-content {
  flex: 1;
  padding: 14px 16px calc(86px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

/* Hero Balance */
.hero-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
}

.hero-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hero-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.hero-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.74rem;
}

.hero-amount {
  margin: 8px 0 2px;
  font-size: clamp(2.15rem, 8.5vw, 2.65rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.08;
}

.hero-amount.negative {
  color: #fda4af;
}

.hero-breakdown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.breakdown-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.breakdown-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.breakdown-val {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-soft);
}

.alert-pill {
  margin-top: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-pill.warn {
  background: var(--warning-bg);
  color: #fde047;
  border: 1px solid rgba(234, 179, 8, 0.28);
}

.alert-pill.danger {
  background: var(--negative-bg);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, 0.28);
}

/* Progress Bar */
.progress-wrap {
  margin-top: 14px;
}

.progress-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: #27272a;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease, background-color 0.3s ease;
}

.progress-fill.level-green {
  background: var(--positive);
}

.progress-fill.level-amber {
  background: var(--warning);
}

.progress-fill.level-red {
  background: var(--negative);
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* 3 Action Buttons */
.action-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 76px;
  padding: 12px 8px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--text-soft);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.action-btn:active {
  background: var(--surface-2);
}

.action-btn .action-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.action-btn.expense .action-icon {
  background: var(--negative-bg);
  color: #fb7185;
}

.action-btn.topup .action-icon {
  background: var(--positive-bg);
  color: #4ade80;
}

.action-btn.adjust .action-icon {
  background: var(--neutral-bg);
  color: var(--text);
}

/* Month stats strip */
.stats-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
}

.stat-tile-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.stat-tile-value {
  margin-top: 3px;
  font-size: 1.04rem;
  font-weight: 600;
}

.val-expense {
  color: #fda4af;
}

.val-topup {
  color: #86efac;
}

.val-neutral {
  color: var(--text-soft);
}

/* Sections */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-title {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.link-btn {
  color: var(--text-soft);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 4px 2px;
}

/* Movements */
.movement-list {
  display: flex;
  flex-direction: column;
}

.movement-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.movement-item:last-child {
  border-bottom: none;
  padding-bottom: 2px;
}

.movement-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-soft);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.movement-info {
  flex: 1;
  min-width: 0;
}

.movement-title {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.movement-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.movement-right {
  text-align: right;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.movement-amount {
  font-weight: 600;
  font-size: 0.9rem;
}

.movement-balance-after {
  font-size: 0.71rem;
  color: var(--text-muted);
}

.delete-mini-btn {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: grid;
  place-items: center;
}

.delete-mini-btn:active {
  background: var(--negative-bg);
  color: #fda4af;
}

.day-group-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 12px 0 2px;
}

/* Buttons */
.primary-btn {
  width: 100%;
  min-height: 46px;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.primary-btn:active {
  opacity: 0.88;
}

.secondary-btn {
  min-height: 42px;
  padding: 9px 13px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-weight: 500;
  font-size: 0.86rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.secondary-btn:active {
  background: var(--surface-hover);
}

.danger-btn {
  min-height: 42px;
  padding: 9px 13px;
  border-radius: var(--radius-md);
  background: var(--negative-bg);
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: #fda4af;
  font-weight: 600;
  font-size: 0.86rem;
}

/* Huchas */
.pot-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.pot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pot-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.pot-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-soft);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.pot-name {
  font-weight: 600;
  font-size: 0.94rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pot-amount {
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text);
}

.pot-goal-text {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.pot-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 6px;
}

.pot-mini-btn {
  min-height: 36px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.79rem;
  font-weight: 500;
  color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.pot-mini-btn:active {
  background: var(--surface-hover);
}

/* History & Export */
.export-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.export-grid .full-span {
  grid-column: 1 / -1;
}

.filter-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.filter-chips::-webkit-scrollbar {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.input,
.select {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--text);
  outline: none;
}

.input:focus,
.select:focus {
  border-color: var(--text);
}

.input-euro-big {
  font-size: 1.9rem;
  font-weight: 700;
  text-align: center;
  min-height: 60px;
  letter-spacing: -0.02em;
}

.quick-amounts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.quick-chip {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-soft);
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 460px;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 6px 10px calc(8px + var(--safe-bottom));
  background: rgba(9, 9, 11, 0.96);
  border-top: 1px solid var(--border);
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 4px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 500;
}

.nav-tab.active {
  color: var(--text);
  font-weight: 600;
}

/* Modal Sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-panel {
  width: 100%;
  max-width: 460px;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--surface);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  border: 1px solid var(--border-strong);
  border-bottom: none;
  padding: 12px 18px calc(22px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
  margin: 0 auto 2px;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sheet-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-soft);
}

.helper-text {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.84rem;
  color: var(--text-soft);
}

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

.icon-picker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.icon-pick-btn {
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: grid;
  place-items: center;
}

.icon-pick-btn.selected {
  border-color: var(--text);
  color: var(--text);
  background: var(--surface-hover);
}

/* Auth / Setup */
.auth-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 16px;
  gap: 16px;
}

.auth-hero {
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.auth-hero h1 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.auth-hero p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.empty-state {
  text-align: center;
  padding: 24px 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Toasts */
.toast-region {
  position: fixed;
  top: calc(12px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  width: min(420px, calc(100% - 28px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 500;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
}

.toast.ok {
  border-color: rgba(34, 197, 94, 0.45);
}

.toast.err {
  border-color: rgba(244, 63, 94, 0.55);
  color: #fda4af;
}
