/* Bancolombia Expense Organizer - mobile-first stylesheet (no framework, no CDN). */

:root {
  --bg: #0b1220;
  --surface: #141d31;
  --surface-2: #1c2740;
  --line: #253149;
  --text: #e8eefb;
  --muted: #93a1bd;
  --accent: #fdd835;
  --accent-ink: #1a1a05;
  --expense: #f87171;
  --income: #4ade80;
  --warn: #fbbf24;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

/* The sheet/toast are hidden with the HTML `hidden` attribute; without this
 * rule their `display` class beats the UA's `[hidden] { display: none }` and a
 * full-screen backdrop silently blocks every tap. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); font-size: 0.82rem; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px;
  background: rgba(11, 18, 32, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar__title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar__title h1 { white-space: nowrap; }
.logo {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 800; font-size: 1.1rem;
}
.icon-btn {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 7px 10px; cursor: pointer;
}
.icon-btn:active { transform: scale(0.96); }

/* ---------- layout ---------- */
.view { padding: 14px 14px calc(84px + var(--safe-bottom)); max-width: 720px; margin: 0 auto; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.card--flush { padding: 0; overflow: hidden; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.section-title { margin: 18px 4px 8px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.kpi__label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.kpi__value { font-size: 1.22rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi__hint { font-size: 0.75rem; color: var(--muted); }
.kpi--expense .kpi__value { color: var(--expense); }
.kpi--income .kpi__value { color: var(--income); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px; cursor: pointer; font-weight: 600;
}
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn--danger { background: transparent; border-color: #5b2222; color: var(--expense); }
.btn--block { width: 100%; }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; font-size: 0.8rem; cursor: pointer;
}
.chip.is-active { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 650; }

/* ---------- forms ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px;
}
.field textarea { min-height: 110px; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- transaction rows ---------- */
.txn {
  display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer;
  background: var(--surface); width: 100%; text-align: left; border-left: 0; border-right: 0; border-top: 0;
}
.txn:last-child { border-bottom: 0; }
.txn__icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--surface-2); font-size: 1.1rem; }
.txn__main { min-width: 0; }
.txn__title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.txn__meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 0.76rem; }
.txn__amount { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.txn__amount.is-income { color: var(--income); }
.badge { border-radius: 6px; padding: 1px 6px; font-size: 0.7rem; border: 1px solid var(--line); background: var(--surface-2); }
.badge--warn { color: var(--warn); border-color: #6b4b09; }
.pill { border-radius: 999px; padding: 2px 8px; font-size: 0.72rem; font-weight: 600; color: #0b1220; }

/* ---------- charts ---------- */
.chart { width: 100%; display: block; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 132px; padding-top: 6px; }
.bars__col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.bars__bar { width: 100%; max-width: 26px; border-radius: 5px 5px 0 0; background: linear-gradient(180deg, var(--accent), #b58900); min-height: 2px; }
.bars__label { font-size: 0.62rem; color: var(--muted); white-space: nowrap; }
.donut { display: flex; gap: 14px; align-items: center; }
.donut__legend { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.legend__row { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; font-size: 0.82rem; }
.legend__dot { width: 10px; height: 10px; border-radius: 3px; }
.legend__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- insights ---------- */
.insight { display: flex; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 0.85rem; }
.insight:last-child { border-bottom: 0; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(20, 29, 49, 0.97); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + var(--safe-bottom));
}
.tab {
  background: none; border: 0; color: var(--muted); display: flex;
  flex-direction: column; align-items: center; gap: 2px;
  font-size: 0.68rem; padding: 4px 0; cursor: pointer;
}
.tab span { font-size: 1.15rem; }
.tab.is-active { color: var(--accent); font-weight: 650; }
.tab--primary span {
  background: var(--accent); color: var(--accent-ink);
  border-radius: 50%; width: 30px; height: 30px;
  display: grid; place-items: center; margin-top: -12px;
  box-shadow: 0 6px 16px rgba(253, 216, 53, 0.28);
}

/* ---------- sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 40; display: grid; align-items: end; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(3, 6, 12, 0.65); }
.sheet__panel {
  position: relative; background: var(--surface);
  border-radius: 18px 18px 0 0; border-top: 1px solid var(--line);
  max-height: 90vh; overflow-y: auto; padding: 6px 16px calc(20px + var(--safe-bottom));
  animation: rise 0.18s ease-out;
}
@keyframes rise { from { transform: translateY(14px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet__grabber { width: 42px; height: 4px; border-radius: 99px; background: var(--line); margin: 8px auto 12px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-bottom));
  transform: translateX(-50%); z-index: 50;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 16px; max-width: 92vw;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); font-size: 0.85rem;
}
.toast--error { border-color: #6b2b2b; }
.toast--ok { border-color: #2f6b3f; }

.empty { text-align: center; color: var(--muted); padding: 28px 16px; font-size: 0.9rem; }
.spinner { text-align: center; color: var(--muted); padding: 24px; }
.hint { font-size: 0.78rem; color: var(--muted); background: var(--surface-2); border-radius: 10px; padding: 10px; }
