/* OBRA · Estilos de la aplicación (mobile-first, responsive a escritorio) */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  background: var(--arena);
  color: var(--noche);
  -webkit-font-smoothing: antialiased;
}

input, select, textarea, button { font-family: inherit; }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
select { -webkit-appearance: none; -moz-appearance: none; appearance: none; }
a { text-decoration: none; color: inherit; }
[x-cloak] { display: none !important; }

@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* ====== Shell ====== */
.app { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }

/* ---- Sidebar (oculta en móvil) ---- */
.sidebar { display: none; }

/* ---- Topbar móvil (oscura, con logo) ---- */
.topbar { flex-shrink: 0; }
.topbar-mobile {
  background: var(--noche); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; position: sticky; top: 0; z-index: 40;
}
.topbar-desktop { display: none; }
.tb-brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.logo-mark {
  width: 36px; height: 36px; background: var(--ambar); border-radius: 10px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.logo-mark.sm { width: 32px; height: 32px; }
.tb-icon {
  width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: center; position: relative; cursor: pointer;
}
.tb-icon.light { background: var(--arena); border: 1px solid var(--borde); }
.dot-badge {
  position: absolute; top: 9px; right: 9px; width: 7px; height: 7px;
  background: var(--ambar); border-radius: 50%; border: 1.5px solid var(--noche);
}
.tb-icon.light .dot-badge { border-color: var(--arena); }

/* ---- Contenido ---- */
.content { flex: 1; min-height: 0; padding: 16px 0 96px; }
.content-inner { width: 100%; }

/* ---- Bottom nav (móvil) ---- */
.bottomnav {
  position: sticky; bottom: 0; z-index: 40;
  background: #fff; border-top: 1px solid var(--linea);
  display: flex; align-items: center; justify-content: space-around;
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 12px; color: #c4bcb4;
}
.bottomnav .lbl { font-size: 10px; font-weight: 600; }
.bottomnav a.active { color: var(--ambar); }

/* ====== Escritorio ====== */
@media (min-width: 900px) {
  .sidebar {
    display: flex; flex-direction: column; width: 232px; flex-shrink: 0;
    background: var(--noche); position: sticky; top: 0; height: 100vh; color: #fff;
  }
  .sidebar-logo {
    display: flex; align-items: center; gap: 10px; color: #fff;
    padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,0.07);
  }
  .logo-word { font-size: 20px; font-weight: 700; letter-spacing: -0.04em; }
  .sidebar-nav { padding: 14px 12px; flex: 1; display: flex; flex-direction: column; gap: 2px; }
  .snav {
    display: flex; align-items: center; gap: 11px; padding: 10px 12px;
    border-radius: 10px; font-size: 13px; font-weight: 500;
    color: rgba(255,255,255,0.45);
  }
  .snav:hover { background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.75); }
  .snav.active { background: var(--ambar); color: #fff; font-weight: 700; }
  .sidebar-user {
    display: flex; align-items: center; gap: 10px; margin: 12px;
    padding: 9px 12px; border-radius: 10px; border-top: 1px solid rgba(255,255,255,0.07);
  }
  .sidebar-user:hover { background: rgba(255,255,255,0.05); }
  .su-name { display: block; font-size: 12px; font-weight: 700; color: rgba(255,255,255,0.8); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .su-sub  { display: block; font-size: 10px; color: rgba(255,255,255,0.35); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .topbar-mobile { display: none; }
  .topbar-desktop {
    display: flex; align-items: center; justify-content: space-between;
    background: #fff; border-bottom: 1px solid var(--linea);
    padding: 16px 32px; position: sticky; top: 0; z-index: 30;
  }
  .td-title h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.03em; }
  .td-title .sub { font-size: 12px; color: var(--texto-tenue); margin-top: 2px; }

  .bottomnav { display: none; }
  .content { padding: 28px 32px 48px; }
  .content-inner { max-width: 1120px; margin: 0 auto; }
  .content-inner.narrow { max-width: 720px; }
}

/* Utilidades de visibilidad por breakpoint */
.only-desktop { display: none; }
@media (min-width: 900px) {
  .only-mobile { display: none !important; }
  .only-desktop { display: block; }
}

/* ====== Componentes ====== */
.card { background: #fff; border-radius: var(--r-card); padding: 16px; }
.section-label { font-size: 9px; font-weight: 700; color: var(--etiqueta); letter-spacing: 0.12em; text-transform: uppercase; }
.h-title { font-size: 22px; font-weight: 700; letter-spacing: -0.03em; color: var(--noche); }

/* Rejillas responsive reutilizables */
.grid { display: grid; gap: 12px; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 900px) {
  .lg-cols-2 { grid-template-columns: repeat(2, 1fr); }
  .lg-cols-3 { grid-template-columns: repeat(3, 1fr); }
  .lg-cols-4 { grid-template-columns: repeat(4, 1fr); }
}

/* Chips de estado */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--r-pill); font-size: 11px; font-weight: 600; white-space: nowrap; }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.chip.borrador  { background: var(--linea); color: #999; }
.chip.borrador  .dot { background: #ccc; }
.chip.pendiente { background: oklch(0.74 0.15 65 / 0.12); color: var(--ambar-fuerte); }
.chip.pendiente .dot { background: var(--ambar); }
.chip.revision  { background: oklch(0.62 0.12 245 / 0.12); color: var(--cielo-texto); }
.chip.revision  .dot { background: var(--cielo); }
.chip.aprobado  { background: oklch(0.60 0.13 152 / 0.12); color: var(--oliva-texto); }
.chip.aprobado  .dot { background: var(--oliva); }
.chip.rechazado { background: oklch(0.58 0.16 35 / 0.12); color: var(--terracota-texto); }
.chip.rechazado .dot { background: var(--terracota); }

/* Avatar */
.avatar { border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: #fff; font-weight: 700; width: 44px; height: 44px; font-size: 14px; }
.avatar.sm { width: 38px; height: 38px; font-size: 13px; border-radius: 10px; }

/* Lista en 2 columnas en escritorio */
@media (min-width: 900px) {
  .list-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-content: start; }
  .list-grid .row-item { margin-bottom: 0; }
}

/* Fila de lista */
.row-item { background: #fff; border-radius: 14px; padding: 13px 15px; margin-bottom: 8px; display: flex; align-items: center; gap: 11px; transition: box-shadow .15s; }
.row-item:hover { box-shadow: var(--sombra-card); }
.row-item .titulo { font-size: 13px; font-weight: 600; color: var(--noche); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item .meta { font-size: 11px; color: var(--texto-tenue); margin-top: 1px; }
.row-item .monto { font-size: 13px; font-weight: 700; color: var(--noche); }

/* Botones */
.btn { border: none; border-radius: 12px; font-size: 14px; font-weight: 700; cursor: pointer; padding: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.btn-primary { background: var(--ambar); color: #fff; box-shadow: var(--sombra-ambar); }
.btn-dark { background: var(--noche); color: #fff; }
.btn-ghost { background: transparent; color: var(--noche); border: 1.5px solid var(--noche); }
.btn-soft { background: oklch(0.16 0.02 255 / 0.07); color: var(--noche); }
.btn-block { width: 100%; }

/* Inputs */
.field-label { font-size: 10px; font-weight: 700; color: var(--texto-tenue); letter-spacing: 0.08em; text-transform: uppercase; display: block; margin-bottom: 7px; }
.input, .select, .textarea { width: 100%; padding: 12px 14px; border: 1.5px solid var(--borde); border-radius: var(--r-input); font-size: 14px; color: var(--noche); background: var(--arena); outline: none; }
.textarea { resize: none; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--ambar); }

/* FAB (solo móvil) */
.fab { position: fixed; bottom: 88px; right: 18px; z-index: 45; width: 54px; height: 54px; background: var(--ambar); border-radius: 50%; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 20px oklch(0.74 0.15 65 / 0.52); }
@media (min-width: 900px) { .fab { display: none; } }

/* Bottom sheet (móvil) → modal centrado (escritorio) */
.sheet-overlay { position: fixed; inset: 0; background: rgba(10,10,20,0.6); z-index: 100; display: flex; align-items: flex-end; animation: fadeIn 0.2s ease; }
.sheet { width: 100%; background: #fff; border-radius: 26px 26px 0 0; animation: slideUp 0.32s cubic-bezier(0.32,0.72,0,1); }
.sheet .handle { width: 36px; height: 4px; background: var(--lienzo); border-radius: 2px; margin: 12px auto 0; }
.sheet-close { width: 32px; height: 32px; border-radius: 50%; background: var(--linea); border: none; color: var(--texto-suave); font-size: 16px; cursor: pointer; }
@media (min-width: 900px) {
  .sheet-overlay { align-items: center; justify-content: center; }
  .sheet { max-width: 460px; border-radius: 22px; animation: fadeIn 0.2s ease; }
  .sheet .handle { display: none; }
}

/* Filtros */
.filtros { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.filtros::-webkit-scrollbar { display: none; }
.filtro { flex-shrink: 0; padding: 7px 15px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; cursor: pointer; background: #fff; color: var(--texto-suave); border: 1.5px solid var(--borde); }
.filtro.active { background: var(--noche); color: #fff; border-color: var(--noche); }
