/* Gestymate: el aspecto de la demo de Álvaro. Mobile first: se usa con una mano, en la barra o en el
   almacén. Sin fuentes externas (privacidad y modo sin conexión): fuentes del sistema. */
:root {
  --ink: #1C1B19;
  --muted: #8A8478;
  --paper: #FAF8F4;
  --card: #FFFFFF;
  --line: #E7E2D8;
  --soft: #F1EEE7;
  --accent: #2B3A67;
  --accent-soft: #EAF0FB;
  --warn: #B45309;
  --warn-soft: #FDF0E1;
  --ok: #2F6B47;
  --ok-soft: #EAF2EC;
  --danger: #A12C2C;
  --nav-height: 72px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
body.has-nav { padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom)); }
h1 { font-size: 24px; margin: 4px 0 10px; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 0 0 8px; }
a { color: var(--accent); }

/* ---------- Cabecera de cada pantalla ---------- */
.appbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 560px; margin: 0 auto; padding: calc(18px + env(safe-area-inset-top)) 16px 4px;
}
.appbar .hello-date { font-size: 13px; color: var(--muted); }
.appbar .hello { font-size: 22px; font-weight: 700; margin-top: 2px; letter-spacing: -0.01em; }
.brand { font-weight: 800; letter-spacing: -0.02em; color: var(--accent); text-decoration: none; font-size: 18px; }
.brand.big { font-size: 22px; margin-bottom: 18px; display: inline-block; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--line); background: var(--card);
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink); flex-shrink: 0;
}

.page { max-width: 560px; margin: 0 auto; padding: 8px 16px 32px; }
.auth { padding-top: 32px; }

/* ---------- Menú inferior fijo ---------- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center; background: var(--card); border-top: 1px solid var(--line);
  padding: 10px 8px calc(12px + env(safe-area-inset-bottom));
}
.bottomnav-inner { display: flex; width: 100%; max-width: 560px; }
.navitem {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 11px; color: var(--muted); text-decoration: none; padding: 2px 0;
}
.navitem.active { color: var(--ink); font-weight: 600; }
.navitem .icon-wrap { position: relative; display: flex; }
.navitem .badge {
  position: absolute; top: -5px; right: -8px; background: var(--warn); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 999px; min-width: 16px; height: 16px; padding: 0 4px; display: flex; align-items: center; justify-content: center;
}

/* ---------- Inicio ---------- */
.cta {
  display: flex; align-items: center; justify-content: center; gap: 10px; border-radius: 18px; padding: 20px;
  font-weight: 700; font-size: 17px; background: var(--accent); color: #fff; text-decoration: none; margin: 12px 0 14px;
}
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat {
  flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px;
  text-decoration: none; color: inherit; min-width: 0;
}
.stat.attention { border-color: var(--warn); }
.stat.attention .stat-num { color: var(--warn); }
.stat-num { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-label { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.section-title {
  font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 18px 0 8px;
}

/* ---------- Listas ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; margin: 12px 0; }
.card.rows { padding: 2px 16px; }
.card.soon { background: var(--soft); border-style: dashed; }
.list-row {
  display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit;
}
.list-row:last-child { border-bottom: none; }
.thumb {
  width: 42px; height: 42px; border-radius: 10px; background: #EFEAE0; flex-shrink: 0; object-fit: cover;
  display: flex; align-items: center; justify-content: center; color: var(--muted);
}
.row-main { min-width: 0; flex: 1; }
.row-title { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.row-amount { font-weight: 800; font-size: 15px; margin-left: auto; white-space: nowrap; text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 18px 8px; }
.list { margin: 0; padding-left: 18px; }

/* ---------- Pestañas, resumen, gráfico ---------- */
.tabs { display: flex; gap: 8px; margin: 8px 0; }
.tab {
  flex: 1; text-align: center; padding: 9px 0; border-radius: 999px; font-weight: 600; font-size: 13.5px;
  border: 1px solid var(--line); color: var(--ink); text-decoration: none; background: var(--card);
}
.tab.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.tabs.small .tab { font-size: 12px; padding: 7px 0; }
.summary { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; margin: 10px 0; }
.summary-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.summary-num { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; margin-top: 4px; }
.donut-wrap { display: flex; justify-content: center; padding: 8px 0 10px; }
.donut { width: 196px; height: 196px; border-radius: 999px; position: relative; display: flex; align-items: center; justify-content: center; }
.donut-hole {
  position: absolute; width: 124px; height: 124px; border-radius: 999px; background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
.donut-total { font-size: 19px; font-weight: 800; }
.donut-range { font-size: 11px; color: var(--muted); margin-top: 3px; padding: 0 10px; }
.dot { width: 10px; height: 10px; border-radius: 999px; flex-shrink: 0; }
.note { font-size: 12px; color: var(--muted); text-align: center; margin: 10px 0; }
.search {
  display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; margin: 10px 0;
}
.search input { border: none; background: none; font: inherit; font-size: 14px; flex: 1; outline: none; padding: 0; }
.art-row {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
  display: flex; align-items: center; gap: 12px; margin-bottom: 8px;
}

/* ---------- Interruptor ---------- */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toggle {
  width: 46px; height: 28px; border-radius: 999px; position: relative; flex-shrink: 0; background: var(--line);
  border: none; cursor: pointer; padding: 0;
}
.toggle.on { background: var(--accent); }
.toggle-thumb {
  position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 999px; background: #fff;
  transition: left .15s ease; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.toggle.on .toggle-thumb { left: 21px; }

/* ---------- Configuración ---------- */
.company-head { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 52px; height: 52px; border-radius: 14px; background: var(--accent); color: #fff; font-weight: 800; font-size: 22px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.settings-row:last-child { border-bottom: none; }
.settings-row .chev { color: var(--muted); }
.legal { text-align: center; font-size: 12px; color: var(--muted); margin-top: 18px; }

/* ---------- Formularios y botones ---------- */
.muted { color: var(--muted); }
.small { font-size: 14px; }
.back { display: inline-block; margin-bottom: 8px; text-decoration: none; font-size: 15px; }
.form { display: flex; flex-direction: column; gap: 14px; margin: 14px 0; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
input[type=text], input[type=email], input[type=password], input[type=date], select, textarea {
  font: inherit; padding: 13px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card);
  width: 100%; color: var(--ink);
}
input[readonly] { background: var(--soft); }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 84px; }
.password-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); min-height: 36px; padding: 0 12px;
  border: 0; border-radius: 9px; background: var(--soft); color: var(--accent); font: inherit; font-size: 14px;
  font-weight: 600; cursor: pointer;
}
.password-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px 12px; margin: 0; background: var(--card); }
legend { font-weight: 600; font-size: 14px; padding: 0 4px; }
.form label.choice { flex-direction: row; align-items: center; gap: 10px; font-weight: 400; font-size: 16px; padding: 6px 0; }
.btn {
  display: inline-block; text-align: center; text-decoration: none; font: inherit; font-weight: 700;
  padding: 14px 18px; border: none; border-radius: 14px; background: var(--accent); color: #fff; cursor: pointer; margin: 6px 0;
}
.btn.secondary { background: var(--soft); color: var(--ink); }
.btn.danger { background: var(--danger); }
.btn.big-action { display: block; font-size: 18px; padding: 18px; margin: 18px 0 8px; }
.btn:disabled { opacity: .6; }
.link-btn {
  background: none; border: none; padding: 6px 0; font: inherit; font-size: 14px; font-weight: 600;
  color: var(--accent); cursor: pointer; text-decoration: none;
}
.link-btn.warn { color: var(--warn); }
.link-btn.danger { color: var(--danger); }
.duplicate { background: var(--warn-soft); border: 1px solid var(--warn); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.duplicate p { margin: 0; }
.alert { background: var(--warn-soft); color: var(--warn); padding: 10px 12px; border-radius: 12px; font-weight: 600; }
.ok-note { background: var(--soft); padding: 10px 12px; border-radius: 12px; }
.ok-box { background: var(--ok-soft); color: var(--ok); padding: 10px 12px; border-radius: 12px; font-weight: 600; }
.offline-banner { background: var(--warn-soft); color: var(--warn); font-size: 14px; font-weight: 600; padding: 8px 16px; text-align: center; }
.tag {
  display: inline-block; background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.tag.amber { background: var(--warn-soft); color: var(--warn); }

/* ---------- Usuarios ---------- */
.people { list-style: none; padding: 0; margin: 14px 0; }
.person {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px;
}
.person-name { font-weight: 700; }
.person .small { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; }
.actions { display: flex; gap: 14px; align-items: center; }
.status { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.status-active { background: var(--ok-soft); color: var(--ok); }
.status-invited { background: var(--soft); color: var(--muted); }
.status-revoked { background: var(--warn-soft); color: var(--warn); }
.linkbox { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }

/* ---------- Documentos ---------- */
.photo-pick { background: var(--card); border: 1px dashed var(--line); border-radius: 12px; padding: 12px; margin-bottom: 8px; }
.pages { display: flex; gap: 10px; overflow-x: auto; margin: 12px 0; }

img.logo { object-fit: contain; background: #fff; }
.logo-preview { display: block; max-width: 160px; max-height: 80px; margin: 8px 0; object-fit: contain; }
.issue-card { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.issue-card .table { margin: 0; }
.settle { display: flex; flex-wrap: wrap; gap: 8px; }
.settle form { flex: 1; min-width: 140px; }
.settle .btn { width: 100%; }
.tag.green { background: var(--ok-soft); color: var(--ok); }
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0 12px; }
.month-title { font-size: 18px; font-weight: 700; }
.pager { display: flex; gap: 8px; margin-top: 12px; }
.pager .btn { flex: 1; text-align: center; }
.rise { color: var(--warn); font-weight: 700; }
.fall { color: var(--ok); font-weight: 600; }
.falls summary { cursor: pointer; list-style: revert; }
.section-title a { float: right; font-weight: 600; }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; background: var(--accent-soft); border-radius: 12px; padding: 10px 12px; }
.suggest p { margin: 0 0 2px; width: 100%; }

/* Review: the photo stays in sight while the data below it is checked. */
.viewer { position: sticky; top: 0; z-index: 5; background: var(--paper); margin: 8px -16px 12px; padding: 6px 16px 8px; border-bottom: 1px solid var(--line); }
.viewer-frame { height: 36vh; height: 36dvh; overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; touch-action: pan-x pan-y; overscroll-behavior: contain; }
.viewer-frame img { display: block; width: 100%; max-width: none; height: auto; user-select: none; -webkit-user-drag: none; }
.viewer-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.viewer-pages { display: flex; gap: 6px; margin-right: auto; }
.viewer.collapsed .viewer-frame { display: none; }
.chip { font: inherit; font-size: 14px; font-weight: 600; min-width: 40px; min-height: 36px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.viewer-bar .chip[data-viewer-toggle] { margin-left: auto; }
@media (min-width: 900px) {
  .page.page-wide { max-width: 1180px; }
  .review { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(360px, 1fr); gap: 24px; align-items: start; }
  .viewer { top: 12px; margin: 0; padding: 0; border-bottom: 0; }
  .viewer-frame { height: calc(100vh - 150px); }
  .viewer-bar .chip[data-viewer-toggle] { display: none; }
}
.pages img { height: 220px; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.critical { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.critical.has-warning { border-color: var(--warn); background: var(--warn-soft); }
.warn { color: var(--warn); font-weight: 600; margin: 0; }
.form label.confirm { font-size: 15px; padding: 2px 0; }
.lines { display: flex; flex-direction: column; gap: 8px; }
.line { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.line input[name$="-description"] { grid-column: 1 / -1; }
.line input { padding: 10px 8px; }
.line label.choice { grid-column: 1 / -1; font-size: 14px; padding: 0; }
.line.handwritten { border-color: var(--warn); background: var(--warn-soft); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.facts div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 12px 0; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table .num { text-align: right; white-space: nowrap; }
.table tr.discount td { color: var(--ok); }
.vat-grid { display: grid; grid-template-columns: 54px 1fr 1fr; gap: 6px 8px; align-items: center; margin-top: 6px; }
.vat-grid input { padding: 10px 8px; }
.surcharge-grid { grid-template-columns: 54px 1fr; }

.settings-row.stack { flex-direction: column; align-items: stretch; gap: 6px; }

/* Doble verificación */
.steps { padding-left: 20px; line-height: 1.5; }
.steps li { margin-bottom: 10px; }
.secret-key { font-family: ui-monospace, Consolas, monospace; font-size: 17px; letter-spacing: .04em; background: var(--soft); padding: 10px 12px; border-radius: 12px; word-break: break-all; }
.qr { margin: 10px 0; } .qr svg { display: block; width: 200px; height: 200px; border-radius: 12px; }
.recovery-codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.recovery-codes code { display: block; font-size: 16px; background: var(--soft); padding: 8px 10px; border-radius: 10px; text-align: center; }

/* Gasto entre fechas */
.range-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin: 6px 0 12px; }
.range-form label { display: flex; flex-direction: column; font-size: 12.5px; color: var(--muted); gap: 2px; }
.range-form input[type="date"] { font: inherit; font-size: 15px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: inherit; }
.list-row a.row-main, .list-row a.chev { color: inherit; text-decoration: none; }

/* Ver la app como el cliente (nuestro equipo, solo lectura) */
.view-as-banner { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 14px; background: #7a2e0e; color: #fff; font-size: 13.5px; }
.view-as-banner .btn { background: #fff; color: #7a2e0e; padding: 6px 12px; min-height: 0; }
.viewing-as img[src*="/paginas/"] { visibility: hidden; }
