:root {
  --bg-deep: #0a0c10;
  --bg-panel: #10141c;
  --bg-card: #111827;
  --bg-card-hover: #172033;
  --bg-soft: #0f172a;
  --border: #1e2840;
  --border-bright: #2d3f66;
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --accent-yellow: #f59e0b;
  --accent-red: #ef4444;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-dim: #64748b;
  --text-mono: #a5f3fc;
  --glow-blue: 0 0 20px rgba(59, 130, 246, 0.18);
  --glow-green: 0 0 18px rgba(16, 185, 129, 0.18);
  --glow-red: 0 0 18px rgba(239, 68, 68, 0.18);
  --radius: 14px;
  --font-display: "Rajdhani", sans-serif;
  --font-body: "Exo 2", sans-serif;
  --font-mono: "Share Tech Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-body);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(59, 130, 246, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59, 130, 246, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* =========================
   TOPBAR
========================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 12, 16, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-bright);
  padding: 0 24px;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  color: white;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  box-shadow: var(--glow-blue);
}

.brand-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 2px;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 2.2px;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

.clock-block {
  text-align: right;
}

.clock-display {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--text-mono);
}

.date-display {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.turno-badge {
  padding: 7px 14px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  border: 1px solid rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-yellow);
  white-space: nowrap;
}

.turno-badge.ok {
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(16, 185, 129, 0.35);
  color: var(--accent-green);
}

.turno-badge.error {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--accent-red);
}

.turno-badge.loading {
  background: rgba(6, 182, 212, 0.12);
  border-color: rgba(6, 182, 212, 0.32);
  color: var(--accent-cyan);
}

/* =========================
   KPIS
========================= */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  padding: 0;
  background: var(--border);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 1;
}

.stat-item {
  background: var(--bg-panel);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.stat-icon {
  font-size: 22px;
}

.stat-val {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}

.stat-val.small {
  font-size: 15px;
  line-height: 1.2;
}

.stat-val.green { color: var(--accent-green); }
.stat-val.yellow { color: var(--accent-yellow); }
.stat-val.red { color: var(--accent-red); }
.stat-val.blue { color: var(--accent-blue); }
.stat-val.mono { color: var(--text-mono); font-family: var(--font-mono); }

.stat-lbl {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* =========================
   MAIN
========================= */
.main-wrap {
  position: relative;
  z-index: 1;
  padding: 24px;
}

.panel-shell {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(16, 20, 28, 0.96), rgba(10, 12, 16, 0.98));
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.28);
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.section-title::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 18px;
  background: var(--accent-cyan);
  border-radius: 2px;
  box-shadow: var(--glow-blue);
}

/* =========================
   FILTROS
========================= */
.filter-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.control-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-wrap.search-wrap {
  min-width: 360px;
}

.control-wrap.narrow {
  min-width: 140px;
}

.control-wrap label {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  min-height: 42px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 0 14px;
  outline: none;
}

input::placeholder {
  color: var(--text-dim);
}

input:focus,
select:focus {
  border-color: rgba(6, 182, 212, 0.5);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1);
}

.action-btn {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: white;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.88), rgba(6, 182, 212, 0.88));
  padding: 0 18px;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: transform 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease;
  box-shadow: var(--glow-blue);
}

.action-btn:hover {
  opacity: 0.96;
}

.action-btn:active {
  transform: translateY(1px);
}

/* =========================
   GRID
========================= */
.machines-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 16px;
  align-items: stretch;
}

/* =========================
   CARD
========================= */
.machine-card-horizontal {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(180deg, #0f172a, #0a1222);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  transition: 0.2s;
  min-height: 200px;
  height: 100%;
  overflow: hidden;
  align-self: stretch;
}

.machine-card-horizontal:hover {
  border-color: #3b82f6;
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

.machine-card-horizontal.activa {
  border-left: 4px solid var(--accent-green);
}

.machine-card-horizontal.inactiva {
  border-left: 4px solid var(--accent-red);
}

.machine-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 14px;
  min-height: 0;
}

.machine-head-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 14px;
  align-items: start;
}

.machine-bottom-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 14px;
  align-items: start;
  flex: 1;
}

.machine-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.machine-name {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 700;
  line-height: 0.95;
  color: #f8fafc;
}

.machine-operario {
  color: #ef4444;
  font-weight: 700;
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1.05;
  letter-spacing: 0.2px;
}

.machine-center {
  display: grid;
  grid-template-columns: repeat(4, minmax(54px, 1fr));
  gap: 10px;
  align-items: start;
  min-width: 0;
}

.kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #94a3b8;
  min-width: 0;
}

.kpi span {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1;
}

.kpi strong {
  font-size: 28px;
  color: white;
  font-family: var(--font-display);
  line-height: 1;
}

.rendimiento {
  min-width: 0;
}

.rendimiento .barra {
  width: 100%;
  height: 8px;
  background: #1e293b;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
}

.rendimiento .fill {
  height: 100%;
  background: linear-gradient(90deg, #fb7185, var(--accent-red));
  border-radius: 999px;
}

.machine-status-col {
  display: flex;
  align-items: flex-start;
  min-height: 100%;
}

.estado-box {
  display: inline-flex;
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 8px;
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: #1e293b;
  min-height: 32px;
}

.estado-box.ok {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.24);
  color: #34d399;
}

.estado-box.warn {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.24);
  color: #fbbf24;
}

.estado-box.danger {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.24);
  color: #f87171;
}

.machine-right {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
  min-height: 74px;
}

.opr-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.opr-num {
  font-weight: 800;
  font-size: 28px;
  color: #f8fafc;
  font-family: var(--font-display);
  line-height: 1;
}

.opr-desc {
  font-size: 13px;
  line-height: 1.35;
  color: #94a3b8;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  line-clamp: 3;
  overflow: hidden;
  min-height: 52px;
}



/* =========================
   NOTIFICACIONES
========================= */
.notif-stack {
  position: relative;
}

.notif-popover {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.notif-item {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  min-width: 0;
}

.notif-item.inicio {
  border-color: rgba(59, 130, 246, 0.26);
  background: rgba(59, 130, 246, 0.12);
}

.notif-item.calidad {
  border-color: rgba(245, 158, 11, 0.26);
  background: rgba(245, 158, 11, 0.12);
}

.notif-item-label {
  font-size: 11px;
  font-weight: 800;
  color: #e2e8f0;
}

.notif-item-opr {
  font-size: 11px;
  color: #94a3b8;
}

/* =========================
   DETALLE
========================= */
.detalle {
  display: block;
  width: 100%;
  margin-top: 4px;
}

.detalle summary {
  cursor: pointer;
  color: #60a5fa;
  font-size: 14px;
  font-weight: 700;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.detalle summary::-webkit-details-marker {
  display: none;
}

.detalle-body {
  margin-top: 12px;
  width: 100%;
}

.detalle-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  width: 100%;
}

.detalle-clip {
  width: 100%;
  max-width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(96, 165, 250, 0.18);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  overflow: hidden;
}

.detalle-clip-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.clip-opr {
  font-size: 14px;
  font-weight: 800;
  color: #f8fafc;
  background: rgba(59, 130, 246, 0.16);
  border: 1px solid rgba(59, 130, 246, 0.28);
  padding: 4px 10px;
  border-radius: 999px;
}

.clip-proceso {
  font-size: 12px;
  font-weight: 700;
  color: #93c5fd;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.clip-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.clip-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.clip-badge.inicio {
  background: rgba(59, 130, 246, 0.16);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #93c5fd;
}

.clip-badge.calidad {
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.28);
  color: #fbbf24;
}

.clip-desc {
  font-size: 14px;
  line-height: 1.45;
  color: #e5e7eb;
  margin-bottom: 10px;
  word-break: break-word;
}

.detalle-clip-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 8px;
}

.detalle-clip-meta span {
  font-size: 12px;
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  padding: 6px 8px;
}

.detalle-vacio {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(148, 163, 184, 0.24);
  color: #94a3b8;
  font-size: 13px;
}

/* =========================
   EMPTY STATE
========================= */
.empty-state {
  border: 1px dashed var(--border-bright);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  padding: 28px;
  text-align: center;
  color: var(--text-secondary);
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 1200px) {
  .stats-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .topbar,
  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-right {
    width: 100%;
    justify-content: space-between;
  }

  .filter-row {
    width: 100%;
    justify-content: flex-start;
  }

  .control-wrap.search-wrap {
    min-width: min(100%, 420px);
  }

  .machines-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  }
}

@media (max-width: 700px) {
  .topbar,
  .main-wrap {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar {
    min-height: auto;
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .stats-bar {
    grid-template-columns: 1fr 1fr;
  }

  .panel-shell {
    padding: 14px;
  }

  .control-wrap,
  .control-wrap.search-wrap,
  .control-wrap.narrow {
    min-width: 100%;
    width: 100%;
  }

  .action-btn {
    width: 100%;
  }

  .machines-grid {
    grid-template-columns: 1fr;
  }

.machine-head-row,
  .machine-bottom-row {
    grid-template-columns: 1fr;
  }

  .machine-center {
    grid-template-columns: 1fr 1fr;
  }

  .machine-card-horizontal {
    min-height: 220px;
  }

  .machine-name {
    font-size: 30px;
  }

  .machine-operario {
    font-size: 16px;
  }

  .kpi strong {
    font-size: 24px;
  }

  .opr-num {
    font-size: 24px;
  }

  .opr-desc {
    min-height: auto;
    -webkit-line-clamp: 3;
    line-clamp: 3;
  }
}

  .detalle-clip-meta {
    grid-template-columns: 1fr 1fr;
  }

.badges-front {
  margin-top: 4px;
  margin-bottom: 2px;
  min-height: 24px;
  align-items: center;
}