/* ── Reset & Base ─────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg:          #0b0f1a;
  --surface:     #131825;
  --surface-2:   #1a2035;
  --border:      rgba(255, 255, 255, 0.08);
  --text:        #e8ecf4;
  --text-dim:    #7a839b;
  --sale:        #00c896;
  --expense:     #f45b69;
  --accent:      #6c5ce7;
  --radius:      16px;
  --radius-sm:   10px;
  --radius-xs:   6px;
  --shadow:      0 4px 24px rgba(0,0,0,0.35);
  --transition:  0.25s cubic-bezier(.4,0,.2,1);
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100dvh; overflow-x: hidden;
}

/* ── App Shell ───────────────────────────────────── */
.app-shell {
  position: relative; max-width: 520px; margin: 0 auto;
  min-height: 100dvh; display: flex; flex-direction: column; overflow: hidden;
}

.glow {
  position: absolute; border-radius: 50%; filter: blur(100px);
  opacity: 0.15; pointer-events: none; z-index: 0;
  animation: pulse 8s ease-in-out infinite alternate;
}
.glow-1 { width: 300px; height: 300px; background: var(--accent); top: -40px; right: -40px; }

/* ── Top Bar ─────────────────────────────────────── */
.top-bar {
  position: relative; z-index: 2; padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; }
.back-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  text-decoration: none; transition: background var(--transition);
}
.back-btn:hover { background: var(--surface-2); }
.top-bar h1 { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; }

.save-top-btn {
  padding: 8px 16px; font-family: inherit; font-size: 0.85rem; font-weight: 700;
  color: #fff; background: var(--accent); border: none; border-radius: var(--radius-xs);
  cursor: pointer; transition: all var(--transition); box-shadow: 0 2px 10px rgba(108, 92, 231, 0.3);
}
.save-top-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(108, 92, 231, 0.4); }

/* ── Body ────────────────────────────────────────── */
.settings-body {
  position: relative; z-index: 2; flex: 1;
  padding: 4px 20px 32px; display: flex; flex-direction: column; gap: 28px; overflow-y: auto;
}

.settings-section { display: flex; flex-direction: column; gap: 14px; }
.section-head h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: 4px; }
.section-head p { font-size: 0.82rem; color: var(--text-dim); }

.settings-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px;
}
.settings-card.flush { padding: 0; overflow: hidden; }

/* ── Thresholds Form ─────────────────────────────── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; color: var(--text-dim); }
.field input {
  width: 100%; padding: 10px 12px; font-family: inherit; font-size: 0.95rem; font-weight: 600;
  color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-xs); outline: none; transition: border-color var(--transition);
}
.field input:focus { border-color: var(--accent); }
.help-text { font-size: 0.72rem; color: var(--text-dim); margin-top: 12px; line-height: 1.5; font-style: italic; }

/* ── Dynamic Lists ───────────────────────────────── */
.list-group { list-style: none; display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.item-text { flex: 1; font-size: 0.9rem; font-weight: 500; }
.del-btn {
  background: transparent; border: none; color: var(--text-dim);
  cursor: pointer; display: grid; place-items: center; width: 28px; height: 28px;
  border-radius: 4px; transition: all var(--transition);
}
.del-btn:hover { color: var(--expense); background: rgba(244, 91, 105, 0.1); }

.add-row {
  display: flex; padding: 10px; gap: 10px; background: rgba(0,0,0,0.15);
}
.add-row input {
  flex: 1; padding: 10px 12px; font-family: inherit; font-size: 0.9rem;
  color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-xs); outline: none; transition: border-color var(--transition);
}
.add-row input:focus { border-color: var(--accent); }
.add-btn {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  width: 40px; display: grid; place-items: center; border-radius: var(--radius-xs);
  cursor: pointer; transition: all var(--transition);
}
.add-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Tabs ────────────────────────────────────────── */
.tab-bar { display: flex; gap: 6px; }
.tab {
  flex: 1; padding: 10px; background: transparent; border: 1px solid var(--border);
  color: var(--text-dim); font-family: inherit; font-size: 0.82rem; font-weight: 600;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0; cursor: pointer; transition: all var(--transition);
  border-bottom: none;
}
.tab.active { background: var(--surface); color: var(--text); }
.tab-content { border-top-left-radius: 0; border-top-right-radius: 0; border-top: none; }

/* ── Toast ───────────────────────────────────────── */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(120px);
  display: flex; align-items: center; gap: 10px; padding: 14px 24px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 600; color: var(--text); box-shadow: var(--shadow);
  z-index: 100; opacity: 0; transition: transform 0.4s cubic-bezier(.22,1,.36,1), opacity 0.4s ease; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-icon { color: var(--sale); flex-shrink: 0; }

/* ── Responsive ──────────────────────────────────── */
@media (min-width: 560px) {
  .app-shell {
    margin-top: 24px; margin-bottom: 24px; min-height: calc(100dvh - 48px);
    border: 1px solid var(--border); border-radius: 24px;
    background: rgba(19, 24, 37, 0.6); backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px); box-shadow: 0 12px 48px rgba(0,0,0,0.5);
  }
}
.settings-body::-webkit-scrollbar { width: 4px; }
.settings-body::-webkit-scrollbar-track { background: transparent; }
.settings-body::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 4px; }
