/* ===== Pantallas de acceso (login / configuración inicial) ===== */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; background:
  radial-gradient(900px 500px at 15% -10%, color-mix(in srgb, var(--primary) 16%, transparent), transparent 60%),
  radial-gradient(700px 500px at 100% 100%, color-mix(in srgb, var(--chart-2) 14%, transparent), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 30px 28px; box-shadow: var(--shadow); }
.auth-card.wide { max-width: 640px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 22px; text-align: center; }
.auth-brand img { width: 76px; height: 76px; border-radius: 18px; box-shadow: var(--shadow); }
.auth-brand .tag { color: var(--muted); font-size: 14px; }
.auth-foot { text-align: center; margin-top: 16px; color: var(--faint); font-size: 12.5px; }

/* ===== Estructura principal ===== */
#app { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar { width: 262px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; height: 100dvh; z-index: 40; }
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 14px; }
.brand img { width: 42px; height: 42px; border-radius: 11px; }
.brand b { display: block; font-size: 17px; letter-spacing: -.01em; } .brand span { font-size: 12px; color: var(--muted); }
.nav { flex: 1; overflow-y: auto; padding: 4px 12px 12px; }
.nav h6 { margin: 16px 10px 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); font-weight: 650; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14.5px; transition: background .12s, color .12s; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--primary-soft); color: var(--primary-ink); }
.nav a .badge { margin-left: auto; background: var(--primary); color: #fff; border-radius: 999px; font-size: 11.5px; padding: 1px 8px; min-width: 22px; text-align: center; }
.side-foot { padding: 14px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-ink); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.user-chip b { display: block; font-size: 14px; line-height: 1.2; } .user-chip span { font-size: 12px; color: var(--muted); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 30; border-bottom: 1px solid var(--border); }
.topbar h1 { font-size: 21px; letter-spacing: -.02em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#menuBtn { display: none; }
#view { padding: 24px 28px 40px; flex: 1; max-width: 1500px; width: 100%; margin: 0 auto; }
.scrim { display: none; }
.bottom-nav { display: none; }

/* ===== Tablet y celular ===== */
@media (max-width: 960px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-102%); transition: transform .22s ease, box-shadow .22s, visibility 0s linear .22s; box-shadow: none; width: 280px; visibility: hidden; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); visibility: visible; transition-delay: 0s; }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(15,18,28,.5); z-index: 35; }
  #menuBtn { display: inline-flex; }
  .topbar { padding: 10px 14px; } .topbar h1 { font-size: 18px; }
  #view { padding: 16px 14px 96px; }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--border); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 18px rgba(31,36,51,.07); }
  .bottom-nav a, .bottom-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border: 0; background: none; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600; border-radius: 10px; cursor: pointer; }
  .bottom-nav a.active { color: var(--primary); background: var(--primary-soft); }
}
@media (max-width: 640px) {
  .auth-card { padding: 24px 20px; }
  input, select, textarea { font-size: 16px; } /* evita el zoom automático en iPhone */
  .kpi .value { font-size: 22px; }
  .overlay { padding: 0; align-items: flex-end; }
  .modal { max-width: none; border-radius: 20px 20px 0 0; max-height: 94vh; max-height: 94dvh; margin: 0; }
  .modal-foot { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; }
  .filters .field { flex: 1 1 calc(50% - 10px); } .filters .field.wide { flex: 1 1 100%; }
  #toasts { left: 12px; right: 12px; bottom: 84px; max-width: none; }
  /* tablas → tarjetas */
  .table-wrap.stack { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .stack table, .stack tbody, .stack tr, .stack td { display: block; width: 100%; }
  .stack thead { display: none; }
  .stack tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 10px; box-shadow: var(--shadow-sm); }
  .stack tbody tr:hover { background: var(--surface); }
  .stack td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; border: 0; text-align: right !important; }
  .stack td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; font-weight: 600; text-align: left; flex-shrink: 0; }
  .stack td[data-label=""]::before { display: none; }
  .stack td.actions { justify-content: flex-end; padding-top: 10px; margin-top: 4px; border-top: 1px dashed var(--border); flex-wrap: wrap; }
  .stack td.main-cell { display: block; text-align: left !important; font-size: 15.5px; padding-bottom: 8px; }
  .stack td.main-cell::before { display: none; }
}
