/* Tranquilino — prototipo */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #1b1f1d;
  --muted: #6b716d;
  --line: #e7e3da;
  --accent: #1f3d34;
  --accent-ink: #ffffff;
  --accent-soft: #e4ece8;

  --s-pend: #5f6661;  --s-pend-bg: #eeece6;
  --s-info: #2a55c4;  --s-info-bg: #e8eefc;
  --s-ok: #1d7448;    --s-ok-bg: #e2f2e9;
  --s-bad: #b2372c;   --s-bad-bg: #fbe8e5;
  --s-warn: #8f6200;  --s-warn-bg: #fbf0d6;

  --radius: 18px;
  --radius-s: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 6px 24px rgba(20, 30, 25, .05);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121514;
    --surface: #1b1f1d;
    --ink: #eef1ef;
    --muted: #9aa29d;
    --line: #2a302d;
    --accent: #9fd6b8;
    --accent-ink: #0f1a15;
    --accent-soft: #1f2e27;
    --s-pend: #b3bab5;  --s-pend-bg: #262b28;
    --s-info: #9cb6ff;  --s-info-bg: #1d2640;
    --s-ok: #8fd8ae;    --s-ok-bg: #19301f;
    --s-bad: #ff9d92;   --s-bad-bg: #3a1e1b;
    --s-warn: #f2c66b;  --s-warn-bg: #372c12;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 0 16px calc(96px + env(safe-area-inset-bottom));
}

/* Header */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(12px + env(safe-area-inset-top)) 0 12px;
  background: var(--bg);
}
.top h1 { flex: 1; margin: 0; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .brand { font-weight: 700; letter-spacing: -.01em; }
.icon-btn {
  position: relative;
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent; color: inherit; text-decoration: none;
}
.icon-btn:hover { background: var(--line); }
.icon-btn svg { width: 22px; height: 22px; }
.dot { position: absolute; top: 8px; right: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--s-bad); border: 2px solid var(--bg); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 600; font-size: 14px;
}

/* Text */
.hello { margin: 8px 0 4px; font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.sub { margin: 0 0 20px; color: var(--muted); }
.label { margin: 28px 0 10px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }
.card-link { display: block; text-decoration: none; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-title { font-weight: 600; }
.card-meta { margin-top: 2px; font-size: 14px; color: var(--muted); }
.card-actions { display: flex; gap: 8px; margin-top: 14px; }
.card-actions .btn { flex: 1; }

/* Hero: el mes actual */
.hero { padding: 22px; }
.hero .period { font-size: 15px; color: var(--muted); }
.hero .amount { margin: 4px 0 2px; font-size: 38px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
.hero .due { color: var(--muted); }
.hero .msg { margin: 16px 0 0; padding: 12px 14px; border-radius: var(--radius-s); font-size: 15px; }
.hero .btn-block { margin-top: 18px; }
.msg.info { background: var(--s-info-bg); color: var(--s-info); }
.msg.ok { background: var(--s-ok-bg); color: var(--s-ok); }
.msg.bad { background: var(--s-bad-bg); color: var(--s-bad); }
.msg.warn { background: var(--s-warn-bg); color: var(--s-warn); }
.msg.pend { background: var(--s-pend-bg); color: var(--s-pend); }

/* Estado */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.pendiente { color: var(--s-pend); background: var(--s-pend-bg); }
.chip.informado { color: var(--s-info); background: var(--s-info-bg); }
.chip.confirmado { color: var(--s-ok); background: var(--s-ok-bg); }
.chip.no_recibido, .chip.atrasado { color: var(--s-bad); background: var(--s-bad-bg); }
.chip.sin_confirmar, .chip.parcial { color: var(--s-warn); background: var(--s-warn-bg); }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 14px;
  font-weight: 600; text-decoration: none;
  transition: transform .08s ease, opacity .15s ease;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--muted); min-height: 44px; }
.btn-danger { background: var(--surface); border-color: var(--line); color: var(--s-bad); }
.btn-block { display: flex; width: 100%; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 15px; border-radius: 12px; }
.stack > * + * { margin-top: 10px; }

/* Listas */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 14px 16px;
  border: 0; border-top: 1px solid var(--line);
  background: transparent; text-align: left; text-decoration: none;
}
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .k { color: var(--muted); font-size: 14px; }
.row .v { font-weight: 500; }
.row .chev { width: 18px; height: 18px; color: var(--muted); flex: none; }
button.row:hover, a.row:hover { background: var(--bg); }

/* Copiar alias */
.copy {
  display: flex; align-items: center; gap: 10px;
  margin-top: 14px; padding: 12px 14px;
  border: 1px dashed var(--line); border-radius: var(--radius-s);
  background: var(--bg);
}
.copy .grow { flex: 1; min-width: 0; }
.copy .v { font-weight: 600; overflow-wrap: anywhere; }

/* Formularios */
.field { display: block; margin-bottom: 18px; }
.field > span { display: block; margin-bottom: 8px; font-size: 15px; font-weight: 500; }
.field small { display: block; margin-top: 6px; color: var(--muted); font-size: 13px; }
.input {
  width: 100%; min-height: 52px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { min-height: 220px; padding: 14px; line-height: 1.5; resize: vertical; display: block; }
.input-money { display: flex; gap: 8px; }
.input-money .input { flex: 1; font-size: 22px; font-weight: 600; }
.code-input { text-align: center; font-size: 26px; font-weight: 700; letter-spacing: .25em; text-transform: uppercase; }

.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button {
  min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); font-weight: 500;
}
.seg button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 4px 0 18px; }
.toggle input { appearance: none; width: 48px; height: 28px; flex: none; border-radius: 999px; background: var(--line); position: relative; transition: background .15s; cursor: pointer; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(20px); }

.file {
  display: flex; align-items: center; gap: 10px;
  min-height: 52px; padding: 0 14px;
  border: 1px dashed var(--line); border-radius: 14px;
  color: var(--muted); cursor: pointer;
}
.file input { display: none; }
.file svg { width: 20px; height: 20px; }
.thumb { display: block; max-width: 100%; max-height: 260px; margin-top: 10px; border-radius: var(--radius-s); border: 1px solid var(--line); }

/* Asistente por pasos */
.steps { display: flex; gap: 6px; margin: 4px 0 22px; }
.steps i { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.steps i.on { background: var(--accent); }
.step-title { margin: 0 0 20px; font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.footer-actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.footer-actions .inner { max-width: 520px; margin: 0 auto; display: flex; gap: 8px; }
.footer-actions .btn { flex: 1; }

/* Pestañas */
.tabs { display: flex; gap: 4px; margin: 24px 0 14px; padding: 4px; border-radius: 14px; background: var(--line); }
.tabs button { flex: 1; min-height: 38px; border: 0; border-radius: 10px; background: transparent; font-weight: 500; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* Bienvenida */
.welcome { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 32px 0; }
.welcome .logo { width: 64px; height: 64px; border-radius: 18px; margin-bottom: 24px; }
.welcome h1 { margin: 0 0 8px; font-size: 34px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
.welcome p { margin: 0 0 32px; color: var(--muted); font-size: 17px; }

/* Vacío */
.empty { padding: 36px 20px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }
.empty .btn { margin-top: 16px; }

/* Línea de tiempo */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; font-size: 15px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.timeline li::after { content: ""; position: absolute; left: 7px; top: 19px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline time { display: block; font-size: 13px; color: var(--muted); }

/* Cálculo de ajuste */
.calc { font-size: 15px; }
.calc .line { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.calc .line:last-child { border-bottom: 0; }
.calc .total { font-weight: 700; }

/* Avisos */
.notif { display: flex; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--line); }
.notif:first-child { border-top: 0; }
.notif .bullet { width: 8px; height: 8px; margin-top: 8px; border-radius: 50%; background: transparent; flex: none; }
.notif.unread .bullet { background: var(--s-info); }
.notif time { display: block; font-size: 13px; color: var(--muted); }

/* Publicidad (solo propietario, plan gratis) */
.ad { margin-top: 28px; padding: 14px 16px; border-radius: var(--radius-s); background: var(--line); color: var(--muted); font-size: 13px; display: flex; justify-content: space-between; gap: 12px; }

/* Hoja inferior */
.sheet-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(10, 15, 12, .4); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet {
  width: 100%; max-width: 520px; max-height: 92dvh; overflow: auto;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0; background: var(--bg);
  animation: up .2s ease;
}
.sheet .grab { width: 40px; height: 5px; margin: 0 auto 16px; border-radius: 5px; background: var(--line); }
.sheet h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.02em; }
.sheet p.lead { margin: 0 0 20px; color: var(--muted); }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 30;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  width: max-content; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px; text-align: center;
  background: var(--ink); color: var(--bg); font-weight: 500; font-size: 15px;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Panel de demo (solo prototipo) */
.demo-fab {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 10;
  min-height: 36px; padding: 0 14px; border: 1px dashed var(--muted); border-radius: 999px;
  background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 600;
}
.has-footer .demo-fab { bottom: calc(84px + env(safe-area-inset-bottom)); }
.date-ctl { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.date-ctl strong { flex: 1 1 100%; font-size: 20px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
