/* RMI WebFactory — Panel admin (estilo sobrio RMI Estilo) */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --panel-app-max: 100%;
  --bg: #f4f6f5;
  --bg1: #ffffff;
  --bg2: #f4f6f5;
  --bg3: #e3e7e5;
  --border: #e3e7e5;
  --border2: #aeb8b5;
  --ac: #9fe870;
  --ac2: #7bc95a;
  --ac-text: #3d6516;
  --ac-dim: rgba(159, 232, 112, 0.14);
  --text: #1b2220;
  --text2: #48534f;
  --text3: #647472;
  --red: #c94c4c;
  --green: #3d6516;
  --yellow: #9a7b2e;
  --blue: #4a6a82;
  --radius: 8px;
  --sidebar: 268px;
  --font: 'Maven Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --shadow-sm: 0 1px 3px rgba(27, 34, 32, 0.06);
  --shadow-md: 0 8px 28px rgba(27, 34, 32, 0.08);
  --sidebar-bg: #1b2220;
  --sidebar-border: #3a4441;
  --sidebar-text: #aeb8b5;
  --sidebar-text-hi: #f4f6f5;
}

html {
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100%;
  min-height: 100%;
  overflow: hidden; /* solo el body del panel hace scroll */
  -webkit-font-smoothing: antialiased;
}

/* Login: la página sí puede hacer scroll si hace falta */
body:has(.login-pantalla) {
  overflow: auto;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--font); }
input, textarea, select { font-family: var(--font); }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

#raiz {
  height: 100%;
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  justify-content: stretch;
  align-items: stretch;
  padding: 0;
  margin: 0;
  background: var(--bg);
  width: 100%;
  max-width: none;
}

#raiz:has(.login-pantalla) {
  padding: 0;
  align-items: stretch;
  height: auto;
  min-height: 100dvh;
  overflow: auto;
}

#raiz > .login-pantalla {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.panel-app {
  display: flex;
  width: 100%;
  max-width: none;
  height: 100%;
  min-height: 100%;
  min-height: 100dvh;
  background: var(--bg1);
  border: none;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
}

/* ── Sidebar fijo izquierda, altura total pantalla ───────── */
.sidebar {
  width: var(--sidebar);
  min-width: var(--sidebar);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  height: 100dvh;
  flex-shrink: 0;
  z-index: 100;
  transition: transform 0.25s ease;
  overflow: hidden;
}

.sidebar-logo {
  padding: 22px 20px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo img {
  height: 22px;
  width: auto;
  filter: brightness(0) invert(1);
  opacity: 0.95;
}

.sidebar-logo .marca {
  font-size: 15px;
  font-weight: 600;
  color: var(--sidebar-text-hi);
  letter-spacing: 0.01em;
}

.sidebar-logo .sub {
  font-size: 11px;
  color: var(--sidebar-text);
  margin-top: 2px;
}

.sidebar-logo .punto {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ac);
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0 12px;
  overscroll-behavior: contain;
}

/* Secciones del menú (desplegables) */
.nav-group {
  margin: 4px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.nav-group:first-child {
  border-top: none;
}

.nav-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px 10px 18px;
  background: transparent;
  border: none;
  color: #8a9692;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.nav-group-toggle:hover {
  color: var(--sidebar-text-hi);
  background: rgba(255, 255, 255, 0.03);
}

.nav-group-toggle .nav-group-label {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}

.nav-group-chevron {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  font-size: 11px;
  color: var(--sidebar-text);
  transition: transform 0.2s ease;
  opacity: 0.75;
}

.nav-group.is-open .nav-group-chevron {
  transform: rotate(180deg);
  color: var(--ac);
}

.nav-group.has-active > .nav-group-toggle {
  color: var(--ac);
}

.nav-group-items {
  display: none;
  padding: 0 0 6px;
}

.nav-group.is-open > .nav-group-items {
  display: block;
}

/* Compat: etiquetas planas antiguas (si quedan) */
.nav-seccion {
  font-size: 10px;
  font-weight: 600;
  color: #647472;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 16px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border-left: 2px solid transparent;
  user-select: none;
}

.nav-group-items .nav-item {
  padding-left: 22px;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--sidebar-text-hi);
}

.nav-item.activo {
  background: var(--ac-dim);
  color: var(--ac);
  border-left-color: var(--ac);
}

.nav-item .icono {
  font-size: 14px;
  width: 18px;
  text-align: center;
  opacity: 0.85;
}

/* Ítems sueltos (sin grupo), p.ej. Panel */
.nav-item.nav-item-root {
  margin: 4px 0 8px;
}

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-usuario { display: flex; align-items: center; gap: 10px; }

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ac);
  color: var(--ac-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-nombre { font-size: 12px; font-weight: 600; color: var(--sidebar-text-hi); }
.sidebar-rol { font-size: 10px; color: var(--sidebar-text); margin-top: 1px; }

.sidebar .btn-ghost { color: var(--sidebar-text); }
.sidebar .btn-ghost:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }

/* ── Main: ocupa el resto y solo este área hace scroll ── */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 100%;
  min-height: 100dvh;
  margin-left: var(--sidebar);
  width: calc(100% - var(--sidebar));
  max-width: calc(100% - var(--sidebar));
  background: var(--bg);
  overflow: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  width: 100%;
}

.topbar-inner {
  width: 100%;
  max-width: none;
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-titulo {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.topbar-acciones { display: flex; align-items: center; gap: 10px; }

.topbar-menu-btn {
  display: none;
  margin-right: 4px;
  font-size: 18px;
  line-height: 1;
  padding: 6px 10px;
}

@media (max-width: 768px) {
  .topbar-menu-btn {
    display: inline-flex !important;
  }
  .topbar-menu-btn[hidden] {
    display: none !important;
  }
}

.contenido {
  padding: 28px;
  flex: 1;
  width: 100%;
  max-width: none;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* ── Cards ──────────────────────────────────────── */
.card {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg1);
}

.card-titulo { font-size: 14px; font-weight: 600; color: var(--text); }
.card-body { padding: 22px; }

/* ── Stats ──────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  border-color: var(--border2);
  box-shadow: var(--shadow-md);
}

.stat-num {
  font-size: 28px;
  font-weight: 700;
  color: var(--ac-text);
  letter-spacing: -0.02em;
}

.stat-lbl {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.stat-sub { font-size: 12px; color: var(--text2); }
.stat-icon { font-size: 20px; margin-bottom: 4px; opacity: 0.7; }

/* ── Botones ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  border: 1.5px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--ac);
  color: var(--ac-text);
  border-color: var(--ac);
}

.btn-primary:hover {
  background: var(--ac2);
  border-color: var(--ac2);
}

.btn-secondary {
  background: var(--bg1);
  color: var(--text);
  border-color: var(--border2);
}

.btn-secondary:hover {
  background: var(--bg2);
  border-color: var(--text3);
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: rgba(201, 76, 76, 0.45);
}

.btn-danger:hover { background: rgba(201, 76, 76, 0.06); }

.btn-ghost {
  background: transparent;
  color: var(--text2);
  border-color: transparent;
}

.btn-ghost:hover { background: var(--bg2); color: var(--text); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 11px; }

/* ── Formularios ────────────────────────────────── */
.form-grupo { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  margin-bottom: 6px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg1);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: var(--ac2);
  box-shadow: 0 0 0 3px var(--ac-dim);
}

.form-input::placeholder { color: #aeb8b5; }
.form-textarea { resize: vertical; min-height: 96px; }

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23647472' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.form-hint { font-size: 12px; color: var(--text3); margin-top: 5px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Toggle ─────────────────────────────────────── */
.toggle { position: relative; display: inline-block; width: 38px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg3);
  border-radius: 11px;
  cursor: pointer;
  transition: 0.2s;
  border: 1.5px solid var(--border2);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  left: 2px;
  bottom: 2px;
  transition: 0.2s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

input:checked + .toggle-slider { background: var(--ac); border-color: var(--ac2); }
input:checked + .toggle-slider::before { transform: translateX(16px); }

/* ── Tabla ──────────────────────────────────────── */
.tabla { width: 100%; border-collapse: collapse; }

.tabla th {
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}

.tabla td {
  padding: 13px 14px;
  font-size: 13px;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
}

.tabla tr:last-child td { border-bottom: none; }
.tabla tr:hover td { background: var(--bg2); }
.tabla td strong { color: var(--text); font-weight: 600; }

/* ── Badges ─────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-green { background: var(--ac-dim); color: var(--green); }
.badge-red { background: rgba(201, 76, 76, 0.1); color: var(--red); }
.badge-yellow { background: rgba(154, 123, 46, 0.12); color: var(--yellow); }
.badge-blue { background: rgba(74, 106, 130, 0.1); color: var(--blue); }
.badge-grey { background: var(--bg3); color: var(--text3); }

/* ── Modal ──────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 19, 17, 0.45);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-titulo { font-size: 15px; font-weight: 600; }
.modal-body { padding: 22px; }
.modal-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg2);
}

.modal-ancho { max-width: 900px; }

.color-input-wrap { display: flex; align-items: center; gap: 8px; }
.color-preview { width: 28px; height: 28px; border-radius: 4px; border: 1.5px solid var(--border); flex-shrink: 0; }
input[type=color] { width: 0; height: 0; opacity: 0; position: absolute; }

/* ── Tabs ───────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 22px; }

.tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  margin-bottom: -1px;
}

.tab:hover { color: var(--text); }
.tab.activo { color: var(--ac-text); border-bottom-color: var(--ac); }

/* ── Hero editor ────────────────────────────────── */
.hero-tipo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }

.hero-tipo-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg1);
}

.hero-tipo-card:hover { border-color: var(--border2); }
.hero-tipo-card.sel { border-color: var(--ac2); background: var(--ac-dim); }
.hero-tipo-icon { font-size: 22px; margin-bottom: 6px; }
.hero-tipo-nom { font-size: 12px; font-weight: 600; color: var(--text2); }

.paleta { display: flex; gap: 6px; flex-wrap: wrap; }

.paleta-item {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
}

.paleta-item:hover,
.paleta-item.sel { border-color: var(--text); transform: scale(1.08); }

/* ── Toast ──────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.25s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: none; }
}

.toast.ok { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--blue); }

/* ── Charts ─────────────────────────────────────── */
.chart-bar-wrap { display: flex; flex-direction: column; gap: 10px; }
.chart-bar-row { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.chart-bar-lbl { width: 100px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-shrink: 0; }
.chart-bar-bg { flex: 1; height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.chart-bar-fill { height: 100%; background: var(--ac); border-radius: 3px; transition: width 0.6s ease; }
.chart-bar-val { width: 40px; text-align: right; color: var(--text3); font-size: 11px; }

/* ── Login ──────────────────────────────────────── */
.login-pantalla {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 36px;
  box-shadow: var(--shadow-md);
}

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

.login-logo img {
  height: 28px;
  width: auto;
  margin-bottom: 12px;
}

.login-logo .rmi {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.login-logo .sub {
  font-size: 12px;
  color: var(--text3);
  margin-top: 6px;
}

.login-error {
  background: rgba(201, 76, 76, 0.08);
  border: 1px solid rgba(201, 76, 76, 0.25);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--red);
  margin-bottom: 16px;
}

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 768px) {
  #raiz { padding: 0; height: 100dvh; }
  .panel-app {
    max-width: none;
    width: 100%;
    min-height: 100dvh;
    height: 100dvh;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    transform: translateX(-100%);
    box-shadow: 8px 0 28px rgba(0, 0, 0, 0.35);
  }
  .sidebar.abierto { transform: none; }
  .main {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
  }
  .contenido { padding: 20px 16px; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .topbar-inner { padding: 0 16px; }
}

/* ── Misc ───────────────────────────────────────── */
.sep-v { width: 1px; height: 16px; background: var(--border); margin: 0 4px; }
.truncar { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cargando { display: flex; align-items: center; justify-content: center; padding: 48px; color: var(--text3); font-size: 14px; gap: 10px; }
.spin { animation: girar 0.7s linear infinite; display: inline-block; }
@keyframes girar { to { transform: rotate(360deg); } }
.vacio { padding: 48px; text-align: center; color: var(--text3); font-size: 14px; }