/* =========================================================================
   CZM · Panel de Control — Estilos base
   Verde CZM #02B150 · Carbón CZM #343C41
   (Mismo sistema visual del panel interno panel-czm, reutilizado aquí)
   ========================================================================= */

:root {
  --czm-green: #02b150;
  --czm-green-dark: #018f41;
  --czm-green-light: #e6f8ee;
  --czm-charcoal: #343c41;
  --czm-charcoal-soft: #4c565c;
  --czm-bg: #f5f7f7;
  --czm-card: #ffffff;
  --czm-border: #e2e6e8;
  --czm-text: #20262a;
  --czm-text-muted: #6b747a;
  --czm-amber: #e0a52c;
  --czm-red: #d64545;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-card: 0 1px 2px rgba(24, 30, 33, 0.04), 0 8px 24px -12px rgba(24, 30, 33, 0.14);
  --font-display: "Poppins", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--czm-bg);
  color: var(--czm-text);
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  margin: 0;
  color: var(--czm-charcoal);
  font-weight: 600;
}

button, input, select {
  font-family: inherit;
}

/* --- Navegación ---------------------------------------------------------- */

.czm-nav {
  background: var(--czm-charcoal);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #fff;
  flex-shrink: 0;
}

.nav-logo {
  height: 34px;
  width: auto;
}

.nav-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.nav-brand-text strong {
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.2px;
}

.nav-brand-text small {
  font-size: 11.5px;
  color: #b7bec2;
}

.nav-links {
  display: flex;
  gap: 4px;
  align-items: center;
}

.nav-links a, .nav-links button.nav-logout {
  text-decoration: none;
  color: #cdd3d6;
  font-size: 14.5px;
  font-weight: 500;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.nav-links a:hover, .nav-links button.nav-logout:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-links a.active {
  background: var(--czm-green);
  color: #fff;
}

.nav-user {
  color: #8f979b;
  font-size: 12.5px;
  padding: 0 8px;
  white-space: nowrap;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}

.nav-toggle span {
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
}

/* --- Layout general -------------------------------------------------------- */

.czm-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 26px;
}

.page-header p {
  margin: 6px 0 0;
  color: var(--czm-text-muted);
  font-size: 14.5px;
  max-width: 60ch;
}

.modo-badge {
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.modo-mock {
  background: #fdf2de;
  color: #9c6b0d;
}

.modo-live {
  background: var(--czm-green-light);
  color: var(--czm-green-dark);
}

/* --- Tarjetas / grillas ----------------------------------------------------- */

.card {
  background: var(--czm-card);
  border: 1px solid var(--czm-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 22px;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 980px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .grid-4, .grid-3, .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* --- KPI cards --------------------------------------------------------------- */

.kpi-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--kpi-accent, var(--czm-green));
}

.kpi-label {
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--czm-text-muted);
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--czm-charcoal);
  line-height: 1.1;
}

.kpi-sub {
  font-size: 13px;
  color: var(--czm-text-muted);
}

.kpi-sub.positive { color: var(--czm-green-dark); font-weight: 600; }
.kpi-sub.negative { color: var(--czm-red); font-weight: 600; }

/* --- Secciones ------------------------------------------------------------------ */

.section {
  margin-top: 32px;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}

.section-title h2 {
  font-size: 18px;
}

.section-title .hint {
  font-size: 12.5px;
  color: var(--czm-text-muted);
}

/* --- Barras por familia (mini) ------------------------------------------------- */

.familia-row {
  display: grid;
  grid-template-columns: 190px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--czm-border);
}

.familia-row:last-child {
  border-bottom: none;
}

.familia-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--czm-charcoal);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.familia-values {
  text-align: right;
  font-size: 13px;
  color: var(--czm-text-muted);
  white-space: nowrap;
}

.familia-values strong {
  color: var(--czm-charcoal);
  font-weight: 700;
}

/* --- Botones / inputs genéricos -------------------------------------------------- */

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease;
}

.btn-primary {
  background: var(--czm-green);
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(0.94);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--czm-border);
  color: var(--czm-charcoal);
}

.btn-ghost:hover {
  background: var(--czm-bg);
}

.btn-danger {
  background: #fbe6e6;
  color: #b23030;
}

.btn-danger:hover {
  background: #f7d3d3;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* --- Tabla inventario -------------------------------------------------------------- */

.table-toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.table-toolbar input,
.table-toolbar select {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--czm-border);
  font-size: 13.5px;
  background: #fff;
}

.table-toolbar input {
  flex: 1;
  min-width: 200px;
}

table.czm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.czm-table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--czm-text-muted);
  padding: 10px 12px;
  border-bottom: 2px solid var(--czm-border);
}

.czm-table td {
  padding: 12px;
  border-bottom: 1px solid var(--czm-border);
}

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

.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
}

.badge-ok { background: var(--czm-green-light); color: var(--czm-green-dark); }
.badge-low { background: #fdf2de; color: #9c6b0d; }
.badge-role-admin { background: #ece6fb; color: #6b3fd6; }
.badge-role-produccion { background: #e6f2fb; color: #1a68a8; }
.badge-role-cliente { background: var(--czm-green-light); color: var(--czm-green-dark); }

/* --- Home hero ---------------------------------------------------------------------- */

.home-hero {
  background: var(--czm-charcoal);
  border-radius: var(--radius-lg);
  padding: 44px 36px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
  position: relative;
  overflow: hidden;
}

.home-hero::after {
  content: "";
  position: absolute;
  right: -40px;
  bottom: -60px;
  width: 260px;
  height: 260px;
  background: radial-gradient(circle, rgba(2, 177, 80, 0.3), transparent 70%);
}

.home-hero-logo {
  height: 88px;
  width: auto;
  position: relative;
  z-index: 1;
  background: #fff;
  padding: 14px;
  border-radius: var(--radius-md);
}

.home-hero-text {
  position: relative;
  z-index: 1;
  max-width: 56ch;
}

.home-hero-text h1 {
  color: #fff;
  font-size: 28px;
  margin-bottom: 8px;
}

.home-hero-text p {
  color: #c3cacd;
  font-size: 15px;
  margin: 0;
}

.home-links {
  margin-top: 32px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

@media (max-width: 700px) {
  .home-links {
    grid-template-columns: 1fr;
  }
}

.home-link-card {
  text-decoration: none;
  display: block;
  padding: 24px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.home-link-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px -14px rgba(24, 30, 33, 0.28);
}

.home-link-card .icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--czm-green-light);
  color: var(--czm-green-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 14px;
}

.home-link-card h3 {
  font-size: 16px;
  margin-bottom: 6px;
}

.home-link-card p {
  font-size: 13.5px;
  color: var(--czm-text-muted);
  margin: 0;
}

/* --- Footer --------------------------------------------------------------------------- */

.czm-footer {
  text-align: center;
  padding: 24px;
  font-size: 12.5px;
  color: var(--czm-text-muted);
}

/* --- Responsive nav --------------------------------------------------------------------- */

@media (max-width: 760px) {
  .nav-toggle {
    display: flex;
  }
  .nav-links {
    position: absolute;
    top: 68px;
    left: 0;
    right: 0;
    background: var(--czm-charcoal);
    flex-direction: column;
    align-items: stretch;
    padding: 8px 16px 16px;
    display: none;
  }
  .nav-links.open {
    display: flex;
  }
  .nav-brand-text small {
    display: none;
  }
}

/* =========================================================================
   Extensiones nuevas para el dashboard de inventario (login + admin)
   ========================================================================= */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--czm-charcoal);
  background-image: radial-gradient(circle at 20% 20%, rgba(2,177,80,0.18), transparent 55%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px -20px rgba(0,0,0,0.5);
  padding: 36px 32px;
}

.login-card .login-logo-link {
  display: block;
  width: fit-content;
  margin: 0 auto 18px;
}

.login-card .login-logo {
  height: 46px;
  width: auto;
  margin: 0;
}

.login-card h1 {
  font-size: 19px;
  text-align: center;
}

.login-card .login-sub {
  text-align: center;
  font-size: 13px;
  color: var(--czm-text-muted);
  margin: 6px 0 24px;
}

.login-field {
  margin-bottom: 16px;
}

.login-field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--czm-text-muted);
  margin-bottom: 6px;
}

.login-field input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--czm-border);
  border-radius: var(--radius-sm);
  font-size: 14.5px;
}

.login-field input:focus {
  outline: 2px solid var(--czm-green);
  outline-offset: 1px;
  border-color: var(--czm-green);
}

.login-error {
  background: #fbe6e6;
  color: #b23030;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  display: none;
}

.login-error.show { display: block; }

.login-submit {
  width: 100%;
  padding: 11px;
  font-size: 14.5px;
}

.login-footer-link {
  text-align: center;
  margin-top: 18px;
  font-size: 12.5px;
  color: var(--czm-text-muted);
}

.login-footer-link a {
  color: var(--czm-green-dark);
  font-weight: 600;
  text-decoration: none;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
}

.form-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--czm-text-muted);
  margin-bottom: 5px;
}

.form-field input, .form-field select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--czm-border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}

.chip-select {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 2px;
}

.chip-option {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--czm-border);
  border-radius: 999px;
  padding: 6px 12px 6px 8px;
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
  background: #fff;
}

.chip-option input {
  margin: 0;
}

.chip-option.checked {
  border-color: var(--czm-green);
  background: var(--czm-green-light);
  color: var(--czm-green-dark);
  font-weight: 600;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--czm-border);
  margin-bottom: 22px;
  overflow-x: auto;
}

.tab-btn {
  background: none;
  border: none;
  padding: 11px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--czm-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tab-btn.active {
  color: var(--czm-green-dark);
  border-bottom-color: var(--czm-green);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--czm-charcoal);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  box-shadow: 0 12px 30px -10px rgba(0,0,0,0.4);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  z-index: 100;
  max-width: 320px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: #b23030;
}

.empty-state {
  text-align: center;
  color: var(--czm-text-muted);
  padding: 30px 0;
  font-size: 13.5px;
}
