/* ══════════════════════════════════════════════════════════════
   ASTRO-DOSE — Sistema de Consumos Mínimos
   Paleta exacta del sistema Excel original
   ══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@400;500;600;700&family=Inter:wght@300;400;500;600&display=swap');

:root {
  /* Paleta exacta del VBA */
  --enc-bg:     rgb(31, 56, 100);     /* azul oscuro encabezados */
  --enc-txt:    rgb(255, 255, 255);
  --sep-bg:     rgb(46, 117, 182);    /* azul medio separadores */
  --kpi-bg:     rgb(235, 243, 251);   /* azul muy claro KPIs */
  --azul-txt:   rgb(31, 56, 100);
  --verde-bg:   rgb(226, 239, 218);
  --verde-txt:  rgb(55, 86, 35);
  --amar-bg:    rgb(255, 242, 204);
  --amar-txt:   rgb(31, 56, 100);
  --naran-bg:   rgb(255, 199, 170);
  --naran-txt:  rgb(132, 60, 12);
  --rojo-bg:    rgb(252, 228, 214);
  --rojo-txt:   rgb(156, 0, 6);
  --azul-claro: rgb(214, 228, 240);
  --gris-bg:    rgb(242, 242, 242);
  --gris-txt:   rgb(85, 85, 85);

  /* Variables de UI */
  --sidebar-w:  260px;
  --header-h:   60px;
  --radius:     6px;
  --shadow-sm:  0 1px 4px rgba(31,56,100,.12);
  --shadow-md:  0 4px 16px rgba(31,56,100,.16);
  --transition: 0.2s ease;

  /* Tipografía */
  --font-display: 'Rajdhani', sans-serif;
  --font-body:    'Inter', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: var(--font-body);
  background: var(--gris-bg);
  color: #1a2233;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── LAYOUT ─────────────────────────────────────────────────── */

.layout {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  background: var(--enc-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width var(--transition);
  overflow: hidden;
}

.sidebar__brand {
  padding: 0 20px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}

.sidebar__brand-icon {
  width: 32px; height: 32px;
  background: var(--sep-bg);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: white; flex-shrink: 0;
}

.sidebar__brand-text {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: white;
  letter-spacing: .5px;
  white-space: nowrap;
}

.sidebar__brand-sub {
  font-size: .65rem;
  color: rgba(255,255,255,.5);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}

.nav-section {
  margin-bottom: 4px;
}

.nav-section__label {
  padding: 8px 20px 4px;
  font-size: .62rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,.72);
  text-decoration: none;
  font-size: .85rem;
  font-weight: 500;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(255,255,255,.07);
  color: white;
  border-left-color: rgba(255,255,255,.3);
}

.nav-item.active {
  background: rgba(46,117,182,.35);
  color: white;
  border-left-color: var(--sep-bg);
}

.nav-item__icon {
  width: 18px; text-align: center;
  font-size: .95rem;
  flex-shrink: 0;
}

.nav-item__badge {
  margin-left: auto;
  background: var(--sep-bg);
  color: white;
  font-size: .6rem;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
}

/* ── TOPBAR ──────────────────────────────────────────────────── */

.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--header-h);
  background: white;
  border-bottom: 1px solid rgba(31,56,100,.1);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 90;
  box-shadow: var(--shadow-sm);
}

.topbar__page-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--enc-bg);
  letter-spacing: .3px;
}

.topbar__spacer { flex: 1; }

.topbar__user {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.topbar__avatar {
  width: 34px; height: 34px;
  background: var(--sep-bg);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-weight: 700;
  font-size: .85rem;
  font-family: var(--font-display);
}

.topbar__user-info { line-height: 1.2; }
.topbar__user-name { font-size: .85rem; font-weight: 600; color: var(--enc-bg); }
.topbar__user-role { font-size: .7rem; color: var(--gris-txt); }

/* ── MAIN CONTENT ────────────────────────────────────────────── */

.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--header-h);
  padding: 28px;
  min-height: calc(100vh - var(--header-h));
  flex: 1;
  overflow-x: hidden;
}

/* ── PAGE HEADER ─────────────────────────────────────────────── */

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--enc-bg);
}

.page-header__title {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--enc-bg);
  line-height: 1;
}

.page-header__subtitle {
  font-size: .78rem;
  color: var(--gris-txt);
  margin-top: 4px;
}

/* ── KPI CARDS ───────────────────────────────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: white;
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  border-top: 3px solid var(--sep-bg);
  transition: box-shadow var(--transition);
}

.kpi-card:hover { box-shadow: var(--shadow-md); }

.kpi-card__label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--gris-txt);
  margin-bottom: 8px;
}

.kpi-card__value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--enc-bg);
  line-height: 1;
}

.kpi-card__sub {
  font-size: .72rem;
  color: var(--gris-txt);
  margin-top: 4px;
}

.kpi-card--verde  { border-top-color: var(--verde-txt); }
.kpi-card--rojo   { border-top-color: rgb(156,0,6); }
.kpi-card--naranja { border-top-color: var(--naran-txt); }

/* ── TABLA ESTÁNDAR ──────────────────────────────────────────── */

.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card__header {
  background: var(--enc-bg);
  color: white;
  padding: 13px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: .3px;
}

.card__body { padding: 20px; }

.table-wrap { overflow-x: auto; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}

table.data-table th {
  background: var(--enc-bg);
  color: white;
  padding: 9px 12px;
  text-align: left;
  font-weight: 600;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
}

table.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid rgba(31,56,100,.07);
  vertical-align: middle;
}

table.data-table tr:hover td { background: var(--kpi-bg); }

table.data-table tr:last-child td { border-bottom: none; }

/* ── BADGES ──────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .3px;
}

.badge--verde   { background: var(--verde-bg); color: var(--verde-txt); }
.badge--rojo    { background: var(--rojo-bg); color: var(--rojo-txt); }
.badge--amarillo { background: var(--amar-bg); color: var(--amar-txt); }
.badge--naranja { background: var(--naran-bg); color: var(--naran-txt); }
.badge--azul    { background: var(--azul-claro); color: var(--enc-bg); }
.badge--gris    { background: var(--gris-bg); color: var(--gris-txt); }

/* ── BOTONES ─────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn--primary {
  background: var(--enc-bg);
  color: white;
}
.btn--primary:hover { background: var(--sep-bg); color: white; }

.btn--secondary {
  background: var(--kpi-bg);
  color: var(--enc-bg);
  border: 1px solid var(--azul-claro);
}
.btn--secondary:hover { background: var(--azul-claro); }

.btn--danger {
  background: var(--rojo-bg);
  color: var(--rojo-txt);
  border: 1px solid rgba(156,0,6,.2);
}
.btn--danger:hover { background: rgb(252,200,180); }

.btn--sm { padding: 5px 10px; font-size: .75rem; }

/* ── FORMULARIOS ─────────────────────────────────────────────── */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gris-txt);
}

.form-control {
  padding: 8px 12px;
  border: 1px solid rgba(31,56,100,.2);
  border-radius: var(--radius);
  font-size: .85rem;
  font-family: var(--font-body);
  color: #1a2233;
  background: white;
  transition: border-color var(--transition);
  width: 100%;
}

.form-control:focus {
  outline: none;
  border-color: var(--sep-bg);
  box-shadow: 0 0 0 3px rgba(46,117,182,.12);
}

select.form-control { cursor: pointer; }

/* ── ALERTAS / FLASH ─────────────────────────────────────────── */

.alert {
  padding: 11px 16px;
  border-radius: var(--radius);
  font-size: .83rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.alert--success { background: var(--verde-bg); color: var(--verde-txt); }
.alert--danger  { background: var(--rojo-bg); color: var(--rojo-txt); }
.alert--warning { background: var(--amar-bg); color: var(--amar-txt); }
.alert--info    { background: var(--kpi-bg); color: var(--enc-bg); }

/* ── PAGINACIÓN ──────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
  padding-top: 16px;
}

.page-link {
  padding: 5px 11px;
  border: 1px solid var(--azul-claro);
  border-radius: var(--radius);
  font-size: .78rem;
  color: var(--enc-bg);
  text-decoration: none;
  font-weight: 500;
  transition: all var(--transition);
}

.page-link:hover, .page-link.active {
  background: var(--enc-bg);
  color: white;
  border-color: var(--enc-bg);
}

/* ── LOGIN PAGE ──────────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--enc-bg);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(46,117,182,.4) 0%, transparent 70%);
  top: -200px; right: -200px;
  pointer-events: none;
}

.login-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(46,117,182,.25) 0%, transparent 70%);
  bottom: -150px; left: -100px;
  pointer-events: none;
}

.login-box {
  background: white;
  border-radius: 12px;
  padding: 44px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 24px 64px rgba(0,0,0,.3);
  position: relative;
  z-index: 1;
}

.login-box__brand {
  text-align: center;
  margin-bottom: 32px;
}

.login-box__logo {
  width: 56px; height: 56px;
  background: var(--enc-bg);
  border-radius: 12px;
  display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 26px;
  margin-bottom: 14px;
}

.login-box__title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--enc-bg);
  line-height: 1.1;
}

.login-box__sub {
  font-size: .75rem;
  color: var(--gris-txt);
  letter-spacing: .5px;
  margin-top: 4px;
}

/* ── UTILITIES ───────────────────────────────────────────────── */

.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mt-8 { margin-top: 32px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.w-full { width: 100%; }
.font-display { font-family: var(--font-display); }

/* ── SEPARATOR ───────────────────────────────────────────────── */

.section-sep {
  background: var(--sep-bg);
  color: white;
  padding: 6px 16px;
  font-family: var(--font-display);
  font-size: .9rem;
  font-weight: 600;
  letter-spacing: .5px;
  border-radius: var(--radius);
  margin: 20px 0 12px;
}

/* ── RESPONSIVE ──────────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .topbar, .main-content { left: 0; margin-left: 0; }
  .main-content { padding: 16px; }
}

/* ── LOGO EUROCHEM ───────────────────────────────────────────── */

.sidebar__brand-logo {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar__logo-img {
  width: 36px;
  height: 36px;
  object-fit: contain;

}

.login-box__logo {
  width: 72px;
  height: 72px;
  background: var(--enc-bg);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  padding: 10px;
}

.login-box__logo img {

}

/* ── VISITAS / FIXES ─────────────────────────────────────────── */

.main-content {
  margin-left: var(--sidebar-w) !important;
  overflow-x: hidden;
}

.topbar {
  left: var(--sidebar-w) !important;
}

.btn--xs { padding: 3px 7px; font-size: .68rem; }

.badge--amar  { background: var(--amar-bg);  color: var(--amar-txt); }
.badge--naran { background: var(--naran-bg); color: var(--naran-txt); }