/* ==========================================================================
   ANALITIKA INTEGRADOR SIIGO  ·  estilo base
   ========================================================================== */
:root {
  --teal:      #0d9488;
  --teal-dark: #0f766e;
  --ink:       #0f172a;
  --slate:     #111c2e;
  --slate-2:   #1e293b;
  --bg:        #f1f5f9;
  --card:      #ffffff;
  --line:      #e2e8f0;
  --muted:     #64748b;
  --ok:        #16a34a;
  --ok-bg:     #dcfce7;
  --warn:      #d97706;
  --warn-bg:   #fef3c7;
  --err:       #dc2626;
  --err-bg:    #fee2e2;
  --radio:     12px;
  --sombra:    0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal-dark); }

/* ------------------------------------------------------------------ LOGIN */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--teal) 0%, var(--slate) 100%);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 18px;
  padding: 36px 32px 28px;
  box-shadow: 0 20px 50px rgba(2, 6, 23, .35);
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand h1 { margin: 14px 0 2px; font-size: 26px; letter-spacing: 3px; }
.login-brand p  { margin: 0; color: var(--muted); letter-spacing: 1px; font-size: 13px; }
.login-foot { text-align: center; color: var(--muted); font-size: 12px; margin: 18px 0 0; }

/* ------------------------------------------------------------------ MARCA */
.brand-logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  color: #fff; font-weight: 800; font-size: 20px;
  display: grid; place-items: center;
}
.brand-logo.big { width: 62px; height: 62px; border-radius: 16px; font-size: 30px; margin: 0 auto; }

/* --------------------------------------------------------------- APP SHELL */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--slate);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { color: #fff; letter-spacing: 2px; font-size: 15px; }
.brand-text span   { color: #94a3b8; font-size: 11px; letter-spacing: .5px; }

.menu { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.menu a {
  display: flex; align-items: center; gap: 10px;
  color: #cbd5e1; text-decoration: none;
  padding: 11px 12px; border-radius: 9px; font-size: 14px;
  transition: background .15s, color .15s;
}
.menu a:hover  { background: rgba(255,255,255,.06); color: #fff; }
.menu a.active { background: var(--teal); color: #fff; }
.menu .ico { width: 18px; text-align: center; opacity: .9; }

.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding-top: 16px; }
.user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.user-badge {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--teal); color: #fff; font-weight: 700;
  display: grid; place-items: center; font-size: 14px;
}
.user-name { font-size: 13px; color: #e2e8f0; }
.logout { display: inline-block; color: #94a3b8; font-size: 13px; text-decoration: none; }
.logout:hover { color: #fff; }

/* --------------------------------------------------------------- CONTENIDO */
.content { padding: 32px 40px; width: 100%; }

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 24px;
}
.page-head h1 { margin: 0; font-size: 24px; }
.page-head .sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

/* Tarjetas */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radio); padding: 18px 20px; box-shadow: var(--sombra);
  display: flex; flex-direction: column; gap: 6px;
}
.card-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
.card-value { font-size: 20px; }
.card-sub   { color: var(--muted); font-size: 13px; }

/* Panel */
.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radio); padding: 22px 24px; box-shadow: var(--sombra);
}
.panel h2 { margin: 0 0 14px; font-size: 17px; }
.panel.muted p { color: var(--muted); margin: 0 0 8px; }
.panel .aviso { color: var(--warn); }

/* Tabla */
.tabla { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 14px; }
.tabla th, .tabla td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tabla th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.tabla code { background: #f1f5f9; padding: 2px 6px; border-radius: 6px; font-size: 12.5px; }
.muted { color: var(--muted); }

/* Formularios */
.form, .form-panel { display: flex; flex-direction: column; gap: 16px; }
.form-panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radio); padding: 24px; box-shadow: var(--sombra); max-width: 640px;
}
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px 18px; margin: 0; }
legend { padding: 0 8px; color: var(--teal-dark); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: #334155; font-weight: 600; }
fieldset label + label { margin-top: 14px; }
input {
  border: 1px solid #cbd5e1; border-radius: 9px; padding: 11px 12px;
  font-size: 14px; font-family: inherit; color: var(--ink); background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: #94a3b8; font-weight: 400; }
input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13,148,136,.15); }
small { color: var(--muted); font-weight: 400; font-size: 12px; }

.acciones { display: flex; gap: 12px; align-items: center; margin-top: 4px; }
.sello { color: var(--muted); font-size: 12px; margin-top: 14px; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: 9px;
  padding: 11px 18px; font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s;
}
.btn.primary { background: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-dark); }
.btn.ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn.ghost:hover { background: #f8fafc; color: var(--ink); }
.btn.full { width: 100%; }

/* Pills / etiquetas de estado */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #e2e8f0; color: #475569; }
.pill.ok   { background: var(--ok-bg);   color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }

/* Alertas */
.alert { padding: 12px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; }
.alert.ok    { background: var(--ok-bg);   color: #166534; }
.alert.warn  { background: var(--warn-bg); color: #92400e; }
.alert.error { background: var(--err-bg);  color: #991b1b; }

/* Seccion de menu (Datos SIIGO) */
.menu-sec {
  color: #64748b; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; padding: 16px 12px 6px;
}

/* Badge total de registros */
.badge-total {
  background: #e2e8f0; color: #334155; font-size: 13px; font-weight: 700;
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
}

/* Tabla con scroll horizontal si es ancha */
.tabla-wrap { overflow-x: auto; }
.col-accion { text-align: right; white-space: nowrap; }
.link-ver { color: var(--teal-dark); font-weight: 600; text-decoration: none; font-size: 13px; }
.link-ver:hover { text-decoration: underline; }

/* Paginacion */
.paginacion {
  display: flex; align-items: center; gap: 16px; margin-top: 18px;
  justify-content: center;
}

/* JSON crudo */
pre.json {
  background: #0f172a; color: #e2e8f0; border-radius: 10px;
  padding: 18px 20px; font-size: 12.5px; line-height: 1.5; margin: 0;
  font-family: "Cascadia Code", "Consolas", ui-monospace, monospace;
  white-space: pre; overflow-x: auto;
}

/* Título de sección (separador dentro de Configuración) */
.titulo-seccion {
  font-size: 18px; margin: 34px 0 4px; padding-top: 26px;
  border-top: 1px solid var(--line);
}
.etq {
  background: var(--teal); color: #fff; font-size: 11px; font-weight: 700;
  padding: 2px 9px; border-radius: 999px; vertical-align: middle; margin-left: 8px;
}

/* Panel diario / ETL */
.selector-fecha { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.inline { flex-direction: row; align-items: center; gap: 8px; }
.inline select {
  padding: 8px 10px; border-radius: 8px; border: 1px solid #cbd5e1;
  font-family: inherit; font-size: 14px; background: #fff;
}
.fila-fechas { display: flex; gap: 16px; }
.fila-fechas label { flex: 1; }
.barra-acciones {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 16px 0; flex-wrap: wrap;
}
.btn-sm { padding: 7px 12px; font-size: 13px; }
.tabla td.num, .tabla th.num { text-align: right; font-variant-numeric: tabular-nums; }
.fila-sel { background: #f0fdfa; }
.chk { width: 17px; height: 17px; accent-color: var(--teal); cursor: pointer; }

/* --------------------------------------------------- MÓVIL (app-like) */
.bottom-nav { display: none; }
.mobile-top { display: none; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }                 /* móvil: sin menú lateral */

  .mobile-top {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; padding: 10px 14px calc(10px + env(safe-area-inset-top));
    background: var(--slate); color: #fff; position: sticky; top: 0; z-index: 40;
  }
  .mobile-top .mt-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: 1px; font-size: 15px; }
  .mobile-top .mt-logo {
    width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--teal), var(--teal-dark)); font-size: 16px;
  }
  .mobile-top .mt-salir { color: #cbd5e1; text-decoration: none; font-size: 12.5px; font-weight: 600; }

  .content { padding: 16px 14px 86px; }        /* espacio para la barra inferior */

  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: var(--slate); border-top: 1px solid rgba(255,255,255,.08);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 16px rgba(2,6,23,.25);
  }
  .bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    color: #94a3b8; text-decoration: none; font-size: 10.5px; font-weight: 700;
    padding: 6px 2px; border-radius: 12px; text-align: center; line-height: 1.05;
  }
  .bottom-nav a span { font-size: 21px; }
  .bottom-nav a.on { color: #fff; background: var(--teal); }

  /* páginas con grillas anchas: aseguran scroll propio, no del body */
  .page-head { flex-wrap: wrap; }
  .cards { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 420px) {
  .cards { grid-template-columns: 1fr; }
}
