/* =========================================
   ESTILOS MAESTROS - ONESYNC V4 (FUSIÓN COMPLETA)
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

:root {
  --bg: #020617;
  --card: rgba(15,23,42,0.94);
  --accent: #22c55e;        /* Verde principal */
  --accent-alt: #38bdf8;    /* Azul claro secundario */
  --border: #1f2937;
  --text-main: #e5e7eb;
  --text-muted: #9ca3af;
  --danger: #fb7185;        /* Rojo suave */
}

* { box-sizing: border-box; font-family: "Roboto", sans-serif; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  font-size: 0.86rem;
}

/* FONDOS */
.bg-image {
  position: fixed; inset: 0;
  background: url("bosque-fondo.jpeg") center/cover no-repeat fixed;
  opacity: 0.5; z-index: -2;
  filter: saturate(0.95) blur(0.5px);
}
.bg-overlay {
  position: fixed; inset: 0;
  background: radial-gradient(circle at top, rgba(15,23,42,0.35), rgba(15,23,42,0.94));
  z-index: -1;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.8rem;
  min-height: calc(100vh - 3rem);
}

/* HEADER */
header {
  padding: 1rem;
  border-radius: 1rem;
  background: radial-gradient(circle at top, #0b1220, #020617);
  border: 1px solid rgba(148,163,184,0.3);
  backdrop-filter: blur(20px);
  margin-bottom: 0.8rem;
  box-shadow: 0 14px 32px rgba(0,0,0,0.55);
  text-align: center;
  position: relative;
}

/* Version label positioned inside the header */
.app-version {
  position: absolute;
  bottom: 0.5rem;
  right: 1rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
}
.header-logo { max-width: 250px; height: auto; margin-bottom: 0.5rem; }
h1 { margin: 0; font-size: 1.5rem; color: var(--text-main); letter-spacing: 0.05em; text-transform: uppercase; background: linear-gradient(to right, var(--text-main), var(--accent-alt)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
p.sub { margin: 0.3rem 0 0; font-size: 0.85rem; color: var(--text-muted); }


/* =========================================
   HEADER - ESTILO SOCIAL (ROL / BD / ALERTAS)
   ========================================= */
.header-actions{
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: calc(100% - 1.8rem);
}

.header-pill{
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(148,163,184,0.22);
  background: rgba(255,255,255,0.06);
  color: var(--text-main);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  backdrop-filter: blur(10px);
  user-select: none;
}

.header-version{
  border-color: rgba(56,189,248,0.24);
  background: rgba(56,189,248,0.10);
  color: rgba(224,242,254,0.95);
}

.header-logout{
  padding: 0 12px;
  background: rgba(255,255,255,0.04);
}

.header-logout:hover{
  border-color: rgba(148,163,184,0.38);
  background: rgba(255,255,255,0.08);
}

.header-dot{
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(148,163,184,0.22);
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(10px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  position: relative;
}

.header-dot:hover{
  border-color: rgba(148,163,184,0.38);
  background: rgba(255,255,255,0.08);
}

.header-icon{
  font-size: 1.05rem;
  line-height: 1;
  opacity: 0.92;
}

/* BD: círculo interno (🟢 / 🔴 / 🟡) */
#btn-check-db::after{
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  box-shadow: 0 0 0 2px rgba(2,6,23,0.55);
}

#btn-check-db[data-status="ok"]::after{
  background: rgba(34,197,94,0.95);
}

#btn-check-db[data-status="down"]::after{
  background: rgba(248,113,113,0.95);
}

#btn-check-db[data-status="checking"]::after{
  background: rgba(251,191,36,0.95);
  animation: pulseDot 0.9s ease-in-out infinite;
}

@keyframes pulseDot{
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.75; }
}

/* Rol activo: colores por rol */
.role-pill.muted{
  color: var(--text-muted);
  opacity: 0.92;
}

.role-pill[data-role="admin"]{
  border-color: rgba(34,197,94,0.35);
  background: rgba(34,197,94,0.12);
  color: #86efac;
}

.role-pill[data-role="almacen"]{
  border-color: rgba(56,189,248,0.35);
  background: rgba(56,189,248,0.12);
  color: #7dd3fc;
}

.role-pill[data-role="diseno"]{
  border-color: rgba(234,179,8,0.35);
  background: rgba(234,179,8,0.12);
  color: #fde047;
}

.role-pill[data-role="comercial"]{
  border-color: rgba(168,85,247,0.35);
  background: rgba(168,85,247,0.12);
  color: #d8b4fe;
}


.role-pill[data-role="supervisor"]{
  border-color: rgba(244,114,182,0.35);
  background: rgba(244,114,182,0.12);
  color: #f9a8d4;
}
@media (max-width: 780px){
  .header-actions{
    left: 0.9rem;
    right: 0.9rem;
    justify-content: center;
  }
}
/* TABS */
.tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.85rem; justify-content: center; }
.tab { border: 1px solid rgba(148,163,184,0.3); background: rgba(15,23,42,0.9); padding: 0.45rem 1rem; font-size: 0.8rem; cursor: pointer; border-radius: 999px; color: var(--text-muted); display: inline-flex; align-items: center; gap: 0.35rem; transition: all 0.2s ease; }
.tab span.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border); }
.tab:hover { transform: translateY(-1px); border-color: var(--accent-alt); color: var(--text-main); }
.tab.active { background: radial-gradient(circle at top left, var(--accent), var(--accent-alt)); border-color: transparent; color: #020617; font-weight: 600; box-shadow: 0 4px 12px rgba(34,197,94,0.3); }
.tab.active span.dot { background: #020617; }

/* CONTENIDO TABS */
.tab-content { display: none; border-radius: 1rem; background: rgba(15,23,42,0.95); border: 1px solid rgba(30,41,59,0.8); padding: 1rem; margin-bottom: 1rem; box-shadow: 0 16px 36px rgba(0,0,0,0.5); backdrop-filter: blur(12px); animation: fadeIn 0.3s ease-out; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

h2 { margin: 0 0 0.8rem; font-size: 1.1rem; font-weight: 500; color: var(--text-main); border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; }
h3 { margin: 1rem 0 0.5rem; font-size: 0.95rem; color: var(--text-main); font-weight: 500; }

/* GRIDS Y FORMULARIOS */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0.6rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
@media (max-width: 700px) { .grid-3 { grid-template-columns: 1fr; } }

label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.78rem; color: var(--text-muted); }
input, select, textarea { border-radius: 0.5rem; border: 1px solid rgba(255,255,255,0.1); padding: 0.45rem; font-size: 0.85rem; background: rgba(2,6,23,0.6); color: var(--text-main); outline: none; transition: border 0.2s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent-alt); background: rgba(2,6,23,0.9); }
input[readonly] { background: rgba(255,255,255,0.03); color: var(--text-muted); cursor: default; }
textarea { min-height: 70px; resize: vertical; }

/* BOTONES */
button { margin-top: 0.3rem; padding: 0.45rem 1.1rem; border-radius: 999px; border: 0; cursor: pointer; font-weight: 600; font-size: 0.8rem; background: linear-gradient(135deg, var(--accent), var(--accent-alt)); color: #020617; transition: filter 0.2s, transform 0.1s; }
button:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-small { padding: 0.3rem 0.8rem; font-size: 0.75rem; margin-top: 0; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.btn-ghost:hover { background: rgba(255,255,255,0.05); color: var(--text-main); }
.btn-danger { background: linear-gradient(135deg, #ef4444, #b91c1c); color: white; }
.btn-secondary { background: #334155; color: white; }
.btn-recibir { background: linear-gradient(135deg, var(--accent-alt), #0ea5e9); color: #020617; font-weight: bold; } /* ESTILO RECUPERADO */

/* TABLAS ESTANDAR */
.table { margin-top: 0.5rem; border-radius: 0.75rem; border: 1px solid var(--border); background: rgba(2,6,23,0.5); overflow: hidden; }
.table-header, .table-row { display: grid; grid-template-columns: 1.2fr 1fr 1.5fr 0.8fr 1.5fr; gap: 0.5rem; padding: 0.5rem 0.8rem; align-items: center; }
.table.table-inv .table-header, .table.table-inv .table-row { grid-template-columns: 0.9fr 1.1fr 1.4fr 0.7fr 0.9fr 0.8fr 0.7fr 0.6fr; } /* GRID INVENTARIO + ACCION */

/* =========================================
   COSTOS (Comercial)
========================================= */
.sub-label { color: var(--text-muted); font-size: 0.85rem; }

/* Movimientos: grids compactos */
.mov-grid-2{ display:grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
@media (max-width: 720px){ .mov-grid-2{ grid-template-columns: 1fr; } }

.costos-resumen {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

@media (max-width: 900px) {
  .costos-resumen { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
}

@media (max-width: 520px) {
  .costos-resumen { grid-template-columns: 1fr; }
}

.costos-card {
  background: rgba(15,23,42,0.65);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 0.75rem;
  padding: 0.75rem;
  backdrop-filter: blur(8px);
}

.costos-card-title {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.costos-card-value {
  font-weight: 800;
  margin-top: 0.25rem;
  font-size: 1.0rem;
}

.costos-card-value.big { font-size: 1.25rem; }

.costos-card-sub {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-inv-costos { width: 100%; }
.table-header { background: rgba(30,41,59,0.5); font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
.table-row { font-size: 0.8rem; border-top: 1px solid rgba(255,255,255,0.05); cursor: pointer; transition: background 0.15s; }
.table-row:hover { background: rgba(56,189,248,0.1); }
.table.table-destr .table-header, .table.table-destr .table-row { grid-template-columns: 0.8fr 0.8fr 1.5fr 0.8fr 1.2fr 1.2fr 0.6fr; font-size: 0.75rem; } /* GRID DESTRUCCION RECUPERADO */

/* TABLAS HTML CLASICAS (Para Historial y Recepciones) */
.tabla-wrapper { overflow-x: auto; margin-top: 0.5rem; border-radius: 0.5rem; border: 1px solid var(--border); background: rgba(2,6,23,0.3); }
.tabla-wrapper table thead th{ position: sticky; top: 0; background: rgba(10,14,26,0.95); z-index: 2; }
.tabla-wrapper table thead th:first-child { border-top-left-radius: 8px; }
.tabla-wrapper table thead th:last-child { border-top-right-radius: 8px; }
.tabla-wrapper table tbody tr:nth-child(odd){ background: rgba(255,255,255,0.02); }
.tabla-wrapper { max-height: 65vh; overflow-y: auto; overflow-x: auto; }

/* Historial: compactar columnas */
#tabla-historial th, #tabla-historial td{
  padding: 6px 8px;
  font-size: 0.85rem;
  line-height: 1.25;
}
#tabla-historial th:nth-child(1),
#tabla-historial td:nth-child(1),
#tabla-historial th:nth-child(2),
#tabla-historial td:nth-child(2),
#tabla-historial th:nth-child(5),
#tabla-historial td:nth-child(5),
#tabla-historial th:nth-child(6),
#tabla-historial td:nth-child(6),
#tabla-historial th:nth-child(10),
#tabla-historial td:nth-child(10),
#tabla-historial th:nth-child(11),
#tabla-historial td:nth-child(11),
#tabla-historial th:nth-child(12),
#tabla-historial td:nth-child(12) {
  white-space: nowrap;
}
#tabla-historial th:nth-child(3),
#tabla-historial td:nth-child(3) {
  width: 90px;
}
#tabla-historial th:nth-child(4),
#tabla-historial td:nth-child(4) {
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#tabla-historial th:nth-child(7),
#tabla-historial td:nth-child(7),
#tabla-historial th:nth-child(8),
#tabla-historial td:nth-child(8),
#tabla-historial th:nth-child(9),
#tabla-historial td:nth-child(9) {
  width: 90px;
  text-align: right;
}
table { width: 100%; border-collapse: collapse; font-size: 0.8rem; text-align: left; }
th, td { padding: 0.7rem 0.8rem; border-bottom: 1px solid rgba(255,255,255,0.05); vertical-align: middle; }
th { background: rgba(30,41,59,0.6); color: var(--text-muted); font-weight: 600; text-transform: uppercase; font-size: 0.7rem; }
tr:hover td { background: rgba(255,255,255,0.02); }

/* BADGES */
.badge { padding: 0.15rem 0.5rem; border-radius: 99px; font-size: 0.7rem; font-weight: 600; border: 1px solid transparent; }
.almacen { background: rgba(34,197,94,0.15); color: #86efac; border-color: rgba(34,197,94,0.3); }
.planta { background: rgba(56,189,248,0.15); color: #7dd3fc; border-color: rgba(56,189,248,0.3); }
.pendiente { background: rgba(234,179,8,0.15); color: #fde047; border-color: rgba(234,179,8,0.3); }
.destruido { background: rgba(239,68,68,0.15); color: #fca5a5; border-color: rgba(239,68,68,0.3); }
.transito { background: rgba(217,70,239,0.15); color: #f0abfc; }
.reposicion { background: rgba(168,85,247,0.15); color: #d8b4fe; }
.baja { background: rgba(148,163,184,0.2); color: #cbd5e1; }
.solicitado { background: rgba(59, 130, 246, 0.15); color: #93c5fd; border-color: rgba(59, 130, 246, 0.3); }

/* CHIPS RESUMEN (RECUPERADO) */
.resumen { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-bottom: 1.2rem; align-items: stretch; }
.chip { position: relative; display: flex; flex-direction: column; justify-content: center; min-width: 100px; background: linear-gradient(145deg, rgba(30,41,59,0.7), rgba(15,23,42,0.9)); backdrop-filter: blur(5px); border: 1px solid rgba(255,255,255,0.08); border-radius: 0.75rem; padding: 0.6rem 1rem; box-shadow: 0 4px 10px rgba(0,0,0,0.3); transition: all 0.2s ease; cursor: default; overflow: hidden; font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; }
.chip:hover { transform: translateY(-2px); border-color: var(--accent-alt); background: linear-gradient(145deg, rgba(30,41,59,0.9), rgba(15,23,42,1)); box-shadow: 0 8px 20px rgba(0,0,0,0.4); }
.chip strong { font-size: 1.4rem; font-weight: 700; color: var(--text-main); line-height: 1.1; margin-bottom: 0.2rem; background: linear-gradient(to right, #fff, #cbd5e1); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.chip::before { content: ''; position: absolute; left: 0; top: 15%; bottom: 15%; width: 3px; background: var(--border); border-radius: 0 4px 4px 0; transition: background 0.2s; }
.chip:hover::before { background: var(--accent-alt); }

/* COLORES Y MENU CONTEXTUAL */
.color-selection-container { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.3rem; margin-bottom: 0.5rem; padding: 0.5rem; background: rgba(0,0,0,0.2); border-radius: 0.5rem; }
.color-chip { padding: 0.35rem 0.75rem; border-radius: 6px; background: rgba(30, 41, 59, 0.5); border: 1px solid rgba(148, 163, 184, 0.2); color: var(--text-muted); font-size: 0.75rem; cursor: pointer; transition: all 0.2s ease; user-select: none; }
.color-chip:hover { background: rgba(30, 41, 59, 0.8); border-color: var(--accent-alt); color: var(--text-main); }
.color-chip.selected { background: rgba(34, 197, 94, 0.2); border-color: var(--accent); color: #bbf7d0; font-weight: 600; box-shadow: 0 0 10px rgba(34, 197, 94, 0.1); }
.context-menu { position: fixed; z-index: 9999; width: 200px; background: #0f172a; border: 1px solid var(--border); border-radius: 0.5rem; box-shadow: 0 10px 25px rgba(0,0,0,0.7); padding: 0.3rem; display: none; }
.context-menu button { width: 100%; text-align: left; background: transparent; padding: 0.5rem; font-size: 0.8rem; font-weight: normal; color: var(--text-main); border-radius: 0.3rem; margin: 0; display: block; box-shadow: none; }
.context-menu button:hover { background: rgba(56,189,248,0.1); color: var(--accent-alt); }

.footer { text-align: center; font-size: 0.7rem; color: var(--text-muted); margin-top: 2rem; padding-bottom: 1rem; }
.footer span { background: rgba(15,23,42,0.8); padding: 0.3rem 0.8rem; border-radius: 99px; border: 1px solid var(--border); }
.empty { text-align: center; color: var(--text-muted); padding: 1rem; font-style: italic; }
.seleccionado { font-size: 0.85rem; color: var(--accent-alt); margin-bottom: 0.5rem; padding: 0.5rem; background: rgba(56,189,248,0.1); border-radius: 0.4rem; }
#mov-fp-detalle { display: flex; justify-content: space-between; align-items: center; background: rgba(0,0,0,0.2); padding: 0.5rem; border-radius: 0.5rem; border: 1px solid var(--border); }
.mov-label { font-size: 0.7rem; text-transform: uppercase; color: var(--text-muted); }
.mov-main { font-weight: bold; color: var(--text-main); font-size: 0.9rem; text-align: right; }
.grid-6-colores { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.4rem; margin-top: 0.5rem; }
.grid-6-colores label { font-size: 0.65rem; text-align: center; color: var(--text-muted); font-weight: bold; }
.grid-6-colores input { width: 100%; padding: 0.35rem 0.2rem; text-align: center; font-size: 0.8rem; }
.table-row.active-row { background: rgba(34, 197, 94, 0.2) !important; border-left: 3px solid var(--accent); box-shadow: inset 0 0 10px rgba(0,0,0,0.3); }

/* =========================================
   DASHBOARD KPI Y GRAFICOS (ESTILOS ORIGINALES)
   ========================================= */
.dash-grid-v2 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.kpi-card { background: linear-gradient(145deg, rgba(30,41,59,0.7), rgba(15,23,42,0.9)); border: 1px solid rgba(255,255,255,0.05); border-radius: 1rem; padding: 1rem; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.kpi-card h3 { margin: 0; font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-card .number { font-size: 1.8rem; font-weight: 700; color: var(--text-main); margin: 0.3rem 0; line-height: 1; }
.kpi-card .desc { font-size: 0.7rem; color: var(--text-muted); }
.kpi-icon { position: absolute; right: -10px; bottom: -10px; font-size: 4rem; opacity: 0.05; color: white; pointer-events: none; }

/* KPI/Panel clicable (Dashboard) */
.kpi-card.dash-click, .dash-panel.dash-click, .life-item.dash-click, .legend-item.dash-click, .rank-row.dash-click { cursor: pointer; }
.kpi-card.dash-click { transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease; }
.kpi-card.dash-click:hover { transform: translateY(-2px); box-shadow: 0 10px 25px rgba(0,0,0,0.35); }
.kpi-link { font-size: 0.65rem; color: rgba(148,163,184,0.9); margin-top: 0.25rem; }
.kpi-card.dash-click:hover .kpi-link { color: var(--accent-alt); }
.legend-item.dash-click:hover { color: var(--text-main); }
.life-item.dash-click:hover { background: rgba(56,189,248,0.06); border-radius: 0.6rem; }
.rank-row.dash-click:hover { background: rgba(56,189,248,0.06); border-radius: 0.6rem; }
.dash-panel.dash-click:hover { border-color: rgba(56,189,248,0.35); }

.dash-middle-section { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.dash-panel { background: rgba(15,23,42,0.6); border: 1px solid var(--border); border-radius: 1rem; padding: 1.2rem; backdrop-filter: blur(10px); }
.panel-head { margin-bottom: 1rem; border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 0.5rem; }
.panel-head h4 { margin: 0; font-size: 0.95rem; color: var(--text-main); }

.gauge-wrapper { display: flex; align-items: center; justify-content: center; gap: 1.5rem; }
.gauge-chart { position: relative; width: 120px; height: 120px; border-radius: 50%; background: conic-gradient(var(--accent) 0%, var(--bg) 0%); display: flex; align-items: center; justify-content: center; box-shadow: 0 0 15px rgba(0,0,0,0.3); }
.gauge-chart::before { content: ''; position: absolute; width: 90px; height: 90px; background: #0f172a; border-radius: 50%; }
.gauge-value { position: relative; font-size: 1.5rem; font-weight: bold; color: var(--text-main); z-index: 2; }
.gauge-legend { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.8rem; }
.legend-item { display: flex; align-items: center; gap: 0.4rem; color: var(--text-muted); }
.dot-ok { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.dot-bad { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }

.life-bar-group { display: flex; flex-direction: column; gap: 1rem; }
.life-item { display: flex; flex-direction: column; gap: 0.3rem; }
.life-label { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-muted); }
.life-track { width: 100%; height: 8px; background: rgba(255,255,255,0.05); border-radius: 10px; overflow: hidden; }
.life-fill { height: 100%; border-radius: 10px; }

.machine-rank { display: flex; flex-direction: column; gap: 0.6rem; }
.rank-row { display: grid; grid-template-columns: 20px 1fr 40px; align-items: center; gap: 0.5rem; font-size: 0.8rem; }
.rank-bar-bg { height: 6px; background: rgba(255,255,255,0.05); border-radius: 4px; grid-column: 2 / -1; margin-top: 2px; overflow: hidden; }
.rank-bar-fill { height: 100%; background: var(--accent-alt); border-radius: 4px; }

@media (max-width: 900px) { .dash-grid-v2 { grid-template-columns: 1fr 1fr; } .dash-middle-section { grid-template-columns: 1fr; } }
@media (max-width: 500px) { .dash-grid-v2 { grid-template-columns: 1fr; } .gauge-wrapper { flex-direction: column; text-align: center; } }

/* =========================================
   HOJA DE VIDA (ESTILOS ORIGINALES)
   ========================================= */
.hv-dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 0.5rem; }
@media (max-width: 768px) { .hv-dashboard-grid { grid-template-columns: 1fr; } }
.hv-card { background: rgba(15, 23, 42, 0.6); border: 1px solid rgba(148, 163, 184, 0.15); border-radius: 1rem; padding: 1.5rem; box-shadow: 0 10px 30px rgba(0,0,0,0.25); backdrop-filter: blur(10px); display: flex; flex-direction: column; }
.hv-title { font-size: 1.2rem; color: var(--accent); margin: 0 0 0.2rem 0; letter-spacing: 0.02em; }
.hv-subtitle { font-size: 0.9rem; color: var(--text-muted); margin: 0 0 1.5rem 0; font-weight: 400; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 0.5rem; }
.hv-data-row { display: flex; justify-content: space-between; padding: 0.4rem 0; border-bottom: 1px solid rgba(255,255,255,0.03); font-size: 0.85rem; }
.hv-data-row strong { color: var(--text-main); }
.hv-data-row span { color: var(--text-muted); text-align: right; }
.hv-qr-section { display: flex; justify-content: center; margin-bottom: 1.5rem; padding: 1rem; background: rgba(255,255,255,0.03); border-radius: 0.5rem; }
.hv-qr-img { width: 140px; height: 140px; background: white; padding: 5px; border-radius: 5px; }
.hv-progress-container { display: flex; flex-direction: column; gap: 0.8rem; max-height: 250px; overflow-y: auto; padding-right: 5px; }
.hv-prog-item { font-size: 0.75rem; }
.hv-prog-header { display: flex; justify-content: space-between; margin-bottom: 0.2rem; }
.hv-prog-bar-bg { height: 6px; background: rgba(255,255,255,0.1); border-radius: 10px; overflow: hidden; }
.hv-prog-bar-fill { height: 100%; border-radius: 10px; transition: width 0.5s ease; }
.fill-green { background: var(--accent); box-shadow: 0 0 8px rgba(34,197,94,0.4); }
.fill-yellow { background: #facc15; box-shadow: 0 0 8px rgba(250,204,21,0.4); }
.fill-red { background: var(--danger); box-shadow: 0 0 8px rgba(251,113,133,0.4); }
.hv-timeline-card { grid-column: 1 / -1; margin-top: 1rem; max-height: 400px; overflow-y: auto; }
.timeline { position: relative; padding-left: 20px; margin-top: 0.5rem; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.t-item { position: relative; margin-bottom: 1.2rem; padding-left: 1.5rem; }
.t-dot { position: absolute; left: -20px; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--bg); border: 2px solid var(--text-muted); }
.t-dot.salida { border-color: var(--accent-alt); box-shadow: 0 0 5px var(--accent-alt); background: rgba(56,189,248,0.2); }
.t-dot.baja { border-color: var(--danger); box-shadow: 0 0 5px var(--danger); background: rgba(251,113,133,0.2); }
.t-content { background: rgba(255,255,255,0.03); padding: 0.6rem 1rem; border-radius: 0.5rem; border: 1px solid rgba(255,255,255,0.05); }
.t-date { font-size: 0.7rem; color: var(--text-muted); opacity: 0.8; }
.t-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.2rem; }
.t-type { font-weight: bold; color: var(--text-main); font-size: 0.85rem; }
.t-user { font-size: 0.75rem; color: var(--accent); }
.t-body { font-size: 0.8rem; color: var(--text-muted); }
.hv-pdf-viewer { grid-column: 1 / -1; margin-top: 1rem; height: 600px; display: flex; flex-direction: column; }
.hv-pdf-frame { flex: 1; width: 100%; border: none; background: #fff; border-radius: 0.5rem; margin-top: 0.5rem; }

/* =========================================
   NUEVO: VENTANAS PLEGADIZAS (ALERTAS)
   ========================================= */
details.dash-details {
  background: rgba(15,23,42,0.6);
  border: 1px solid var(--accent);
  border-radius: 0.8rem;
  margin-bottom: 1rem;
  overflow: hidden;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}
details.dash-details.repo-style { border-color: var(--accent-alt); }
details.dash-details.alert-style { border-color: var(--danger); }

details.dash-details summary {
  padding: 0.8rem 1rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-main);
  background: rgba(255,255,255,0.05);
  list-style: none; 
  display: flex;
  justify-content: space-between; /* Flecha a la derecha */
  align-items: center;
  font-size: 0.9rem;
}

/* El contenedor del texto y el badge juntos a la izquierda */
.summary-title {
  display: flex;
  align-items: center;
  gap: 10px; /* Separacion texto y numero */
}

.count-badge {
  background: var(--text-main);
  color: var(--bg);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 800;
  display: inline-block;
}

details.dash-details summary::after { content: '▼'; font-size: 0.8rem; color: var(--text-muted); transition: transform 0.2s; }
details.dash-details[open] summary::after { transform: rotate(180deg); }
details.dash-details[open] summary { border-bottom: 1px solid rgba(255,255,255,0.1); background: rgba(255,255,255,0.08); }
.details-content { padding: 0.5rem; max-height: 300px; overflow-y: auto; background: rgba(0,0,0,0.2); }

/* TABLA DENTRO DE ALERTAS */
.mini-table-row {
  display: grid;
  grid-template-columns: 0.8fr 1.5fr 1fr 0.8fr 0.8fr; 
  gap: 0.5rem;
  padding: 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 0.8rem;
  align-items: center;
}
.mini-table-row:last-child { border-bottom: none; }
.mini-header { font-weight: bold; color: var(--text-muted); background: rgba(0,0,0,0.2); font-size: 0.75rem; text-transform: uppercase; }

/* LOGIN SCREEN */
#login-screen { position: fixed; inset: 0; z-index: 10000; background: url("bosque-fondo.jpeg") center/cover no-repeat; display: flex; align-items: center; justify-content: center; }
#login-screen::before { content: ''; position: absolute; inset: 0; background: rgba(2,6,23,0.7); backdrop-filter: blur(8px); }
.login-card { position: relative; width: 90%; max-width: 350px; background: rgba(15, 23, 42, 0.9); border: 1px solid rgba(255,255,255,0.1); border-radius: 1rem; padding: 2rem; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,0.5); animation: fadeInDown 0.5s ease; }
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
.login-logo { max-width: 150px; height: auto; margin-bottom: 1rem; }
.login-card h2 { color: var(--text-main); margin-bottom: 0.2rem; font-size: 1.4rem; border:0; }
.login-card p { color: var(--text-muted); font-size: 0.8rem; margin-bottom: 1.5rem; }
.login-card input { width: 100%; margin-bottom: 0.8rem; padding: 0.6rem; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.1); text-align: center; color: white; }
.login-card input:focus { border-color: var(--accent); }
.btn-login { width: 100%; margin-top: 0.5rem; padding: 0.7rem; background: linear-gradient(135deg, var(--accent), #16a34a); color: #0f172a; font-weight: bold; letter-spacing: 0.05em; }@charset "utf-8";
/* CSS Document */



/* =========================================
   MODAL (Edición Admin)
========================================= */
.modal-backdrop{
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(2,6,23,0.72);
  z-index: 9999;
}
.modal-backdrop.open{ display:flex; }

.modal-card{
  width: min(920px, 100%);
  border-radius: 1rem;
  background: var(--card);
  border: 1px solid rgba(148,163,184,0.35);
  box-shadow: 0 24px 70px rgba(0,0,0,0.55);
  overflow: hidden;
}

.modal-header{
  display:flex;
  align-items:center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(148,163,184,0.25);
}
.modal-header h3{
  margin:0;
  font-size: 1rem;
}

.modal-body{
  padding: 1rem;
}

.modal-grid{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
}
@media (max-width: 820px){
  .modal-grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px){
  .modal-grid{ grid-template-columns: 1fr; }
}

.modal-section{
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px dashed rgba(148,163,184,0.25);
}

.modal-footer{
  display:flex;
  gap: 0.6rem;
  justify-content: flex-end;
  padding: 0.9rem 1rem;
  border-top: 1px solid rgba(148,163,184,0.25);
}



/* =========================================
   COSTOS/REPORTES - Avisos y Toast
   ========================================= */
.notice{
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  padding: 0.75rem 0.9rem;
  background: rgba(2,6,23,0.45);
  font-weight: 800;
}
.notice.success{
  border-color: rgba(34,197,94,0.35);
  background: rgba(34,197,94,0.08);
}

.toast-container{
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast{
  min-width: 260px;
  max-width: 360px;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: 0.75rem 2.2rem 0.75rem 0.9rem;
  background: rgba(2,6,23,0.88);
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 28px rgba(0,0,0,0.45);
  font-weight: 900;
  transition: opacity 0.3s ease, transform 0.3s ease;
  position: relative;
}
.toast.success{ border-color: rgba(34,197,94,0.35); }
.toast small{
  display:block;
  margin-top: 0.25rem;
  font-weight: 700;
  opacity: 0.85;
}

.toast.sticky{ box-shadow: 0 16px 36px rgba(0,0,0,0.55); }

.toast-close{
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: inherit;
  cursor: pointer;
  font-weight: 900;
  line-height: 1;
}
.toast-close:hover{ background: rgba(255,255,255,0.10); }

.pill{
  display:inline-flex;
  align-items:center;
  gap: 0.35rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
}
.pill.ok{
  border-color: rgba(34,197,94,0.35);
  background: rgba(34,197,94,0.10);
}


/* =========================================
   ALERTAS / NOTIFICACIONES (LOCAL)
   (solo este módulo funciona sin backend)
   ========================================= */

.btn-alertas{
  position: relative;
}

.badge-count{
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255, 70, 70, .95);
  color: #0b0b0b;
}

.hidden{ display:none !important; }

.modal-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 18px;
}

.alertas-modal{
  width: min(920px, 96vw);
  max-height: min(78vh, 820px);
  overflow: hidden;
}

.modal-toolbar{
  display:flex;
  gap: 10px;
  align-items:center;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(148,163,184,0.25);
}

.alerts-list{
  padding: 14px 16px;
  overflow: auto;
  display: grid;
  gap: 10px;
}

.alert-card{
  border: 1px solid var(--border);
  background: rgba(2,6,23,0.45);
  border-radius: 0.95rem;
  padding: 12px 12px;
}

.alert-card.unread{
  border-color: rgba(255, 215, 80, .30);
  background: rgba(255, 215, 80, .08);
}

.alert-top{
  display:flex;
  align-items:flex-start;
  justify-content: space-between;
  gap: 10px;
}

.alert-title{
  font-weight: 900;
  font-size: 0.92rem;
  margin: 0;
}

.alert-meta{
  opacity: .78;
  font-size: 0.72rem;
  margin-top: 2px;
}

.alert-msg{
  margin: 10px 0 10px;
  opacity: .92;
  line-height: 1.25rem;
  font-size: 0.86rem;
}

.alert-actions{
  display:flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* =========================================
   Hoja de vida: Resumen por color (tarjetas)
   ========================================= */
.color-cards{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.color-card{
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  border-radius: 14px;
  padding: 10px 10px;
}

.color-card .cc-title{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 900;
  font-size: 0.88rem;
  margin-bottom: 6px;
}

.cc-pill{
  font-size: 0.72rem;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.18);
  color: var(--text-muted);
}

.cc-rows{ display:grid; gap: 4px; }
.cc-row{ display:flex; justify-content: space-between; gap: 10px; font-size: 0.78rem; }
.cc-row span{ color: var(--text-muted); }
.cc-row strong{ color: var(--text-main); }


/* Barra de progreso dentro de la tarjeta de color */
.cc-bar{
  margin-top: 10px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.10);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.10);
}
.cc-bar-fill{
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width .25s ease;
  background: rgba(34,197,94,0.85);
}
.color-card.ok .cc-bar-fill{ background: rgba(34,197,94,0.85); }
.color-card.warn .cc-bar-fill{ background: rgba(250,204,21,0.90); }
.color-card.crit .cc-bar-fill{ background: rgba(239,68,68,0.90); }
.cc-bar-fill.ok{ background: rgba(34,197,94,0.85); }
.cc-bar-fill.warn{ background: rgba(250,204,21,0.90); }
.cc-bar-fill.crit{ background: rgba(239,68,68,0.90); }

.cc-pill.ok{
  border-color: rgba(34,197,94,0.35);
  background: rgba(34,197,94,0.12);
  color: #4ade80;
}
.cc-pill.warn{
  border-color: rgba(250,204,21,0.35);
  background: rgba(250,204,21,0.12);
  color: #facc15;
}
.cc-pill.crit{
  border-color: rgba(239,68,68,0.35);
  background: rgba(239,68,68,0.12);
  color: #fca5a5;
}
.inv-vida{ margin-top: 2px; }

.color-card.ok{ border-color: rgba(34,197,94,0.22); background: rgba(34,197,94,0.06); }
.color-card.warn{ border-color: rgba(250,204,21,0.25); background: rgba(250,204,21,0.06); }
.color-card.crit{ border-color: rgba(239,68,68,0.25); background: rgba(239,68,68,0.06); }

/* Historial: Delta plan vs real */
.delta-pos{ color: #fca5a5; font-weight: 900; }
.delta-neg{ color: #86efac; font-weight: 900; }
.delta-zero{ color: var(--text-muted); font-weight: 900; }
