:root {
  --ios-bg: #f2f5fa;
  --ios-surface: #ffffff;
  --ios-text: #17202e;
  --ios-muted: #66707f;
  --ios-brand: #0f5cc0;
  --ios-brand-dark: #0e2646;
  --ios-border: #dde4ef;
  --ios-ok: #1f8a4c;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, "SF Pro Text", "Segoe UI", Tahoma, sans-serif;
  background: var(--ios-bg);
  color: var(--ios-text);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.ios-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--ios-brand-dark);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 0.7rem) 1rem 0.7rem;
  box-shadow: 0 1px 4px rgba(14, 38, 70, 0.25);
}

.ios-title {
  font-size: 1.15rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.ios-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  background: var(--ios-surface);
  border-top: 1px solid var(--ios-border);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -1px 4px rgba(14, 38, 70, 0.08);
}

.ios-tabbar a {
  flex: 1;
  text-align: center;
  padding: 0.8rem 0.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ios-muted);
  text-decoration: none;
  border-bottom: 3px solid transparent;
}

.ios-tabbar a.active {
  color: var(--ios-brand);
  border-bottom-color: var(--ios-brand);
}

.ios-main {
  padding: 0.9rem 0.8rem calc(env(safe-area-inset-bottom) + 5.2rem);
}

.ios-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.ios-kpi {
  background: var(--ios-surface);
  border: 1px solid var(--ios-border);
  border-radius: 12px;
  padding: 0.7rem 0.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.ios-kpi-num { font-size: 1.35rem; font-weight: 800; }
.ios-kpi-label { font-size: 0.75rem; color: var(--ios-muted); }

.ios-card {
  display: block;
  background: var(--ios-surface);
  border: 1px solid var(--ios-border);
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  margin-bottom: 0.6rem;
  color: inherit;
  text-decoration: none;
}

.ios-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-color: var(--ios-brand);
}

.ios-total-label { color: var(--ios-muted); font-size: 0.9rem; }
.ios-total-num { font-size: 1.3rem; font-weight: 800; color: var(--ios-brand); }

.ios-section h2 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ios-muted);
  margin: 1rem 0.2rem 0.5rem;
}

.ios-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
}

.ios-row-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.ios-row-title {
  font-weight: 700;
  font-size: 0.98rem;
  overflow-wrap: anywhere;
}

.ios-row-sub {
  font-size: 0.8rem;
  color: var(--ios-muted);
  overflow-wrap: anywhere;
}

.ios-row-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  flex-shrink: 0;
}

.ios-row-price { font-weight: 800; font-size: 0.95rem; white-space: nowrap; }
.ios-row-date { font-size: 0.75rem; color: var(--ios-muted); }

.ios-badge {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ios-muted);
  border: 1px solid var(--ios-border);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
}

.ios-badge.ok { color: var(--ios-ok); border-color: var(--ios-ok); }

.ios-kv {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.3rem 0;
  font-size: 0.92rem;
}

.ios-kv > span:first-child { color: var(--ios-muted); }
.ios-kv b { text-align: right; overflow-wrap: anywhere; }

.ios-link { color: var(--ios-brand); }
.ios-empty { color: var(--ios-muted); text-align: center; padding: 1.5rem 0; }

.ios-doc-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem;
}

.ios-doc-stats {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  margin-top: 0.45rem;
}

.ios-words {
  font-weight: 800;
  font-size: 1rem;
  color: var(--ios-brand);
  white-space: nowrap;
}

.ios-doc-price { font-weight: 700; font-size: 0.92rem; }

/* ---------- Boton de accion ---------- */

.ios-btn {
  display: block;
  text-align: center;
  background: var(--ios-brand);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 0.7rem;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  margin-bottom: 0.6rem;
}

.ios-btn:active { opacity: 0.85; }

/* ---------- Nombres de documento: max 2 lineas ---------- */

.ios-doc-head .ios-row-title {
  font-weight: 600;
  font-size: 0.92rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Login ---------- */

.ios-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  padding-left: calc(1.5rem + env(safe-area-inset-left));
  padding-right: calc(1.5rem + env(safe-area-inset-right));
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
}

.ios-login-card {
  width: 100%;
  max-width: 22rem;
  background: var(--ios-surface);
  border: 1px solid var(--ios-border);
  border-radius: 16px;
  padding: 1.6rem 1.4rem;
  text-align: center;
}

.ios-login-icon {
  width: 72px;
  height: 72px;
  border-radius: 16px;
}

.ios-login-card h1 {
  margin: 0.6rem 0 0.1rem;
  font-size: 1.25rem;
}

.ios-login-sub {
  margin: 0 0 1.1rem;
  color: var(--ios-muted);
  font-size: 0.85rem;
}

.ios-login-error {
  background: #fdecec;
  border: 1px solid #f4caca;
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  font-size: 0.85rem;
  margin-bottom: 0.8rem;
}

.ios-login-input {
  width: 100%;
  font-size: 1rem;
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--ios-border);
  border-radius: 10px;
  margin-bottom: 0.7rem;
}

.ios-login-btn {
  width: 100%;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--ios-brand);
  border: 0;
  border-radius: 10px;
  padding: 0.7rem;
}

.ios-logout {
  margin-left: auto;
}

.ios-logout button {
  background: transparent;
  color: #9db8dd;
  border: 1px solid #2c4a75;
  border-radius: 8px;
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
}
