:root {
  --ink: #0F1A17;
  --ink-2: #2B3632;
  --muted: #4A5752;
  --muted-2: #5B6863;
  --bg: #F2F4F3;
  --card: #FFFFFF;
  --line: #DCE2DF;
  --line-2: #EDF0EE;
  --green: #0B6B4F;
  --green-dark: #08513C;
  --green-soft: #E3F4EC;
  --amber: #B45309;
  --amber-ink: #8A3F05;
  --amber-soft: #FFF4E5;
  --amber-line: #F5C77E;
  --red: #B42318;
  --red-soft: #FDECEA;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Manrope, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--green); }
button, input, select { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#screen {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 24px) 20px calc(110px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 18px;
  outline: none;
}

/* Barra inferior */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(76px + var(--safe-b));
  padding: 0 8px var(--safe-b);
  background: #fff;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-around;
  z-index: 10;
}
.tabbar a {
  min-width: 60px; min-height: 48px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--muted-2);
  font-size: 11px; font-weight: 700;
}
.tabbar a[aria-current="page"] { color: var(--green); font-weight: 800; }
.tabbar .fab { min-width: 52px; width: 52px; height: 52px; border-radius: 18px; background: var(--green); color: #fff; }
.tabbar .fab svg { width: 24px; height: 24px; stroke-width: 2.4; }
.hide-tabbar .tabbar { display: none; }

/* Encabezados */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top .hello { font-size: 13px; color: var(--muted); font-weight: 500; }
.top h1 { margin: 2px 0 0; font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; }
.section-title h2 { margin: 0; font-size: 16px; font-weight: 800; }
.section-title a { font-size: 13px; font-weight: 700; text-decoration: none; }

.icon-btn {
  position: relative; width: 44px; height: 44px; border-radius: 22px;
  background: #fff; border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink); text-decoration: none; cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }
.dot-count {
  position: absolute; top: 5px; right: 5px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: var(--red); color: #fff; font-size: 10px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}

.avatars { display: flex; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; color: #fff; font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; border: 2px solid var(--bg); flex-shrink: 0;
}
.avatars .avatar + .avatar { margin-left: -8px; }

/* Bloques */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 18px; }
.list > * + * { border-top: 1px solid var(--line-2); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row .t { font-size: 14px; font-weight: 700; }
.row .s { font-size: 12px; color: var(--muted); }
.mono { font-family: var(--mono); font-weight: 700; }
.amt { font-family: var(--mono); font-size: 14px; font-weight: 700; white-space: nowrap; }
.pos { color: var(--green); }
.neg { color: var(--red); }

.hero { background: var(--ink); color: #fff; border-radius: 22px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.hero .label { font-size: 13px; color: #B9C7C1; font-weight: 600; }
.hero .big { font-family: var(--mono); font-size: 34px; font-weight: 700; letter-spacing: -0.03em; }
.hero .big small { font-size: 20px; color: #B9C7C1; }
.hero .meta { display: flex; justify-content: space-between; font-size: 12px; color: #B9C7C1; gap: 8px; }
.bar { height: 8px; border-radius: 4px; background: #2A3934; overflow: hidden; }
.bar > div { height: 100%; background: #3DD68C; border-radius: 4px; }
.bar.light { background: var(--line-2); height: 6px; }
.bar.light > div { background: var(--green); }
.bar.light.warn > div { background: var(--amber); }

.alert {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 16px;
  background: var(--amber-soft); border: 1px solid var(--amber-line); color: var(--ink); text-decoration: none;
}
.alert .ic { width: 36px; height: 36px; border-radius: 10px; background: var(--amber); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.alert .ic svg { width: 18px; height: 18px; }
.alert .t { font-size: 14px; font-weight: 700; }
.alert .s { font-size: 12px; color: #6B3A06; }
.alert .go { font-size: 13px; font-weight: 800; color: var(--amber-ink); margin-left: auto; }

.datechip { width: 44px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; background: var(--line-2); border-radius: 10px; padding: 4px 0; }
.datechip b { font-size: 17px; font-weight: 800; line-height: 1.1; }
.datechip span { font-size: 10px; font-weight: 800; color: var(--muted); text-transform: uppercase; }
.datechip.soon { background: var(--amber-soft); }
.datechip.soon b, .datechip.soon span { color: var(--amber-ink); }

/* Tarjeta de crédito */
.cc { overflow: hidden; }
.cc.soon { border: 2px solid var(--amber-line); }
.cc-face { background: #1E2B27; color: #fff; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.cc-face .num { font-family: var(--mono); font-size: 15px; letter-spacing: 0.12em; color: #B9C7C1; }
.cc-face .bal { font-family: var(--mono); font-size: 22px; font-weight: 700; }
.pill { font-size: 11px; font-weight: 800; padding: 4px 8px; border-radius: 8px; background: var(--amber-line); color: #4A2603; }
.pill.ok { background: #3DD68C; color: #062E21; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 14px 16px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.kv { display: flex; flex-direction: column; gap: 2px; }
.kv span { font-size: 11px; color: var(--muted-2); font-weight: 600; }
.kv b { font-size: 14px; font-weight: 700; }
.pad { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 8px; }

/* Botones */
.btns { display: flex; gap: 8px; }
.btn {
  flex: 1; min-height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff;
  font-size: 14px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; color: var(--ink);
}
.btn.primary { background: var(--green); color: #fff; border-color: var(--green); font-weight: 800; }
.btn.ghost { border-color: var(--green); color: var(--green); font-weight: 800; }
.btn.danger { color: var(--red); border-color: #F3B8B2; }
.btn.small { flex: 0 0 auto; min-height: 40px; border-radius: 20px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: 0.5; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid #C9D1CD; background: #fff;
  font-size: 13px; font-weight: 700; color: var(--ink-2); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .lbl { font-size: 12px; color: var(--muted); font-weight: 700; }
.field input, .field select {
  min-height: 48px; border-radius: 12px; border: 1px solid #C9D1CD; padding: 0 14px; font-size: 15px; background: #fff; width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid var(--green); outline-offset: 1px; }
.amount-input { border: none !important; text-align: center; font-family: var(--mono); font-size: 40px !important; font-weight: 700; background: transparent !important; }
.switch-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.switch-row .grow { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.switch {
  width: 50px; height: 30px; border-radius: 15px; border: none; padding: 3px; background: #9AA6A1; cursor: pointer; display: flex; flex-shrink: 0;
}
.switch::after { content: ''; width: 24px; height: 24px; border-radius: 12px; background: #fff; transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--green); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* Actividad */
.feed-item { display: flex; gap: 12px; padding: 14px; }
.feed-item .grow { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.feed-item .detail { font-size: 13px; color: var(--ink-2); }
.feed-item .when { font-size: 11px; color: var(--muted-2); }
.unread { width: 10px; height: 10px; border-radius: 5px; background: var(--green); margin-top: 4px; flex-shrink: 0; }
.day-label { font-size: 12px; font-weight: 800; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }

.summary { border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.empty { text-align: center; color: var(--muted); font-size: 14px; padding: 28px 16px; }
.hint { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.hint svg { width: 16px; height: 16px; }

/* Hoja (formularios emergentes) */
dialog#sheet {
  border: none; padding: 0; width: 100%; max-width: 560px; margin: auto auto 0; border-radius: 24px 24px 0 0;
  max-height: 92vh; background: #fff; color: var(--ink);
}
dialog#sheet::backdrop { background: rgba(15, 26, 23, 0.45); }
#sheetForm { padding: 20px 20px calc(20px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; }
#sheetForm h2 { margin: 0; font-size: 18px; font-weight: 800; }

#toast {
  position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; max-width: calc(100% - 40px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.offline-banner { background: var(--amber-soft); color: var(--amber-ink); font-size: 13px; font-weight: 700; padding: 10px 14px; border-radius: 12px; }
