/* ═══════════════════════════════════════════════════════════════════════════
   KitTrack — Stylesheet
   Lojit Medical · Estilo industrial/técnico oscuro · Mobile-first
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@300;400;500;600&display=swap');

/* ─── Variables ──────────────────────────────────────────────────────────── */

:root {
  --bg:           #0a0f1a;
  --surface:      #111827;
  --surface-2:    #1a2236;
  --surface-3:    #223049;
  --border:       #1e2d45;
  --border-light: #2a3f5f;

  --cyan:         #00c2ff;
  --cyan-dim:     rgba(0, 194, 255, 0.12);
  --cyan-glow:    rgba(0, 194, 255, 0.25);
  --green:        #00ff9d;
  --green-dim:    rgba(0, 255, 157, 0.12);
  --orange:       #ff6b35;
  --orange-dim:   rgba(255, 107, 53, 0.12);
  --purple:       #b48cff;
  --purple-dim:   rgba(180, 140, 255, 0.12);
  --red:          #ff4d6a;
  --red-dim:      rgba(255, 77, 106, 0.12);
  --yellow:       #ffd166;

  --text-primary:   #e8edf5;
  --text-secondary: #7b93b8;
  --text-muted:     #4a6080;
  --text-code:      #a8c7e8;

  --font-sans: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 20px var(--cyan-glow);

  --transition: 0.18s ease;
  --nav-height: 56px;
  --header-height: 60px;
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

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

ul, ol { list-style: none; }

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

/* ─── Scrollbar ──────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Login screen ───────────────────────────────────────────────────────── */

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(0,194,255,0.08) 0%, transparent 70%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 32px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.login-logo .logo-icon {
  width: 40px;
  height: 40px;
  background: var(--cyan-dim);
  border: 1.5px solid var(--cyan);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.login-logo h1 {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--cyan);
  letter-spacing: 0.04em;
}

.login-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: 32px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.login-card .form-group { margin-bottom: 16px; }

.login-card .form-label {
  display: block;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.login-card .form-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 15px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

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

.login-error {
  font-size: 13px;
  color: var(--red);
  margin-top: 8px;
  min-height: 20px;
  font-family: var(--font-mono);
}

.btn-login {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  background: var(--cyan);
  color: #000;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: opacity var(--transition), transform var(--transition);
}

.btn-login:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-login:active { transform: translateY(0); }

/* ─── App shell ──────────────────────────────────────────────────────────── */

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.header-logo-icon {
  width: 32px;
  height: 32px;
  background: var(--cyan-dim);
  border: 1px solid var(--cyan);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.header-brand h2 {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  color: var(--cyan);
  letter-spacing: 0.06em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 6px;
  border-radius: 20px;
  border: 1px solid;
  font-size: 12px;
  font-family: var(--font-mono);
  font-weight: 500;
}

.user-badge .user-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Role colors applied via JS */
.user-badge[data-role="lojit"]        { border-color: var(--cyan);   color: var(--cyan);   background: var(--cyan-dim); }
.user-badge[data-role="lojit"] .user-dot { background: var(--cyan); }
.user-badge[data-role="fabricante"]   { border-color: var(--green);  color: var(--green);  background: var(--green-dim); }
.user-badge[data-role="fabricante"] .user-dot { background: var(--green); }
.user-badge[data-role="hospital"]     { border-color: var(--purple); color: var(--purple); background: var(--purple-dim); }
.user-badge[data-role="hospital"] .user-dot { background: var(--purple); }
.user-badge[data-role="distribuidor"] { border-color: var(--orange); color: var(--orange); background: var(--orange-dim); }
.user-badge[data-role="distribuidor"] .user-dot { background: var(--orange); }

.btn-logout {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font-mono);
  transition: border-color var(--transition), color var(--transition);
}

.btn-logout:hover { border-color: var(--red); color: var(--red); }

/* ─── Bottom nav (mobile) ────────────────────────────────────────────────── */

.app-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 10px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color var(--transition), background var(--transition);
  padding: 0 4px;
}

.nav-item .nav-icon { font-size: 18px; line-height: 1; }

.nav-item.active {
  color: var(--cyan);
  background: var(--cyan-dim);
}

.nav-item:hover:not(.active) { color: var(--text-primary); }

/* ─── Main content ───────────────────────────────────────────────────────── */

.app-main {
  flex: 1;
  padding: 16px 16px calc(var(--nav-height) + 16px);
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

/* Sections */
.section { display: none; }
.section.active { display: block; }

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

.section-title {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 16px;
  background: var(--cyan);
  border-radius: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   COMPONENTS
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Cards ──────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.card + .card { margin-top: 12px; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ─── Stat cards (panel) ─────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
}

.stat-card.cyan::after  { background: var(--cyan); }
.stat-card.green::after { background: var(--green); }
.stat-card.orange::after { background: var(--orange); }
.stat-card.purple::after { background: var(--purple); }

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

.stat-value {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 600;
  line-height: 1;
  color: var(--text-primary);
}

.stat-card.cyan .stat-value  { color: var(--cyan); }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.orange .stat-value { color: var(--orange); }
.stat-card.purple .stat-value { color: var(--purple); }

.stat-label {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ─── Refresh indicator ──────────────────────────────────────────────────── */

.refresh-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-bottom: 16px;
}

.refresh-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.8); }
}

/* ─── Movement list ──────────────────────────────────────────────────────── */

.movement-list { display: flex; flex-direction: column; gap: 8px; }

.movement-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: border-color var(--transition);
}

.movement-item:hover { border-color: var(--border-light); }

.movement-type-badge {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.movement-type-badge.salida     { background: var(--orange-dim); }
.movement-type-badge.recepcion  { background: var(--green-dim); }
.movement-type-badge.entrada    { background: var(--cyan-dim); }

.movement-info { flex: 1; min-width: 0; }

.movement-kit {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--cyan);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.movement-route {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.movement-meta {
  text-align: right;
  flex-shrink: 0;
}

.movement-time {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.movement-user {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ─── Status badges ──────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.badge.en_lojit    { background: var(--cyan-dim);   color: var(--cyan);   border: 1px solid rgba(0,194,255,0.3); }
.badge.en_lojit::before { background: var(--cyan); }
.badge.en_transito { background: var(--orange-dim); color: var(--orange); border: 1px solid rgba(255,107,53,0.3); }
.badge.en_transito::before { background: var(--orange); animation: pulse 1.5s infinite; }
.badge.en_destino  { background: var(--green-dim);  color: var(--green);  border: 1px solid rgba(0,255,157,0.3); }
.badge.en_destino::before { background: var(--green); }

/* Reception status */
.badge.correcto    { background: var(--green-dim);  color: var(--green);  border: 1px solid rgba(0,255,157,0.3); }
.badge.incompleto  { background: var(--orange-dim); color: var(--orange); border: 1px solid rgba(255,107,53,0.3); }
.badge.con_danos   { background: var(--red-dim);    color: var(--red);    border: 1px solid rgba(255,77,106,0.3); }

/* ─── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: var(--font-mono);
  font-weight: 500;
  border: none;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}

.btn:hover { opacity: 0.88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.btn-primary   { background: var(--cyan);   color: #000; }
.btn-success   { background: var(--green);  color: #000; }
.btn-warning   { background: var(--orange); color: #000; }
.btn-ghost     { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-light); }
.btn-ghost:hover { color: var(--text-primary); border-color: var(--text-muted); }
.btn-danger    { background: var(--red-dim); color: var(--red); border: 1px solid rgba(255,77,106,0.3); }

.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-lg { padding: 13px 24px; font-size: 14px; font-weight: 600; }
.btn-full { width: 100%; justify-content: center; }

.btn-scan {
  background: var(--surface-3);
  border: 1px dashed var(--cyan);
  color: var(--cyan);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-family: var(--font-mono);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition);
}

.btn-scan:hover { background: var(--cyan-dim); }

/* ─── Forms ──────────────────────────────────────────────────────────────── */

.form-group { margin-bottom: 16px; }

.form-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.form-label .required {
  color: var(--orange);
  font-size: 13px;
  line-height: 1;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px var(--cyan-dim);
}

.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-muted); }

.form-input[readonly],
.form-input:disabled {
  background: var(--surface-3);
  color: var(--text-muted);
  cursor: not-allowed;
  border-style: dashed;
}

.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='%237b93b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; cursor: pointer; }

.form-select option { background: var(--surface-2); color: var(--text-primary); }

.form-textarea { min-height: 80px; resize: vertical; }

.form-hint {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.input-group {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.input-group .form-input { flex: 1; }

/* ─── Form card (Salida / Recepción) ─────────────────────────────────────── */

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
}

.form-card-title {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-card-title .accent { color: var(--cyan); }

.form-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ─── Kit search result ──────────────────────────────────────────────────── */

.kit-found-card {
  background: var(--surface-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 16px;
  display: none;
}

.kit-found-card.visible { display: block; }

.kit-found-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.kit-found-code {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--cyan);
}

.kit-found-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.kit-found-location {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

/* ─── Kit list (Kits section) ────────────────────────────────────────────── */

.kit-filters {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-light);
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all var(--transition);
}

.filter-btn.active { background: var(--cyan-dim); border-color: var(--cyan); color: var(--cyan); }
.filter-btn:hover:not(.active) { border-color: var(--text-muted); color: var(--text-primary); }

.search-box {
  position: relative;
  margin-bottom: 12px;
}

.search-box .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
  pointer-events: none;
}

.search-box .form-input { padding-left: 38px; }

.kit-grid { display: flex; flex-direction: column; gap: 8px; }

.kit-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}

.kit-card:hover {
  border-color: var(--cyan);
  background: var(--surface-2);
  transform: translateX(2px);
}

.kit-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.kit-code {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--cyan);
}

.kit-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  line-height: 1.4;
}

.kit-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.kit-tag {
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 2px 7px;
  border-radius: 3px;
  background: var(--surface-3);
  color: var(--text-muted);
  border: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kit-location {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
}

/* ─── Empty state ────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state h3 { font-family: var(--font-mono); font-size: 14px; margin-bottom: 6px; color: var(--text-secondary); }
.empty-state p  { font-size: 13px; }

/* ─── Spinner ────────────────────────────────────────────────────────────── */

.spinner-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(10, 15, 26, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  backdrop-filter: blur(2px);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.spinner-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Inline spinner */
.spinner-inline {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

/* ─── Modal ──────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(10, 15, 26, 0.8);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(40px);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  padding: 0 0 env(safe-area-inset-bottom, 16px);
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--border-light);
  border-radius: 2px;
  margin: 12px auto 0;
}

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

.modal-title {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-title .modal-title-code { color: var(--cyan); }

.btn-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  padding: 4px;
  transition: color var(--transition);
}

.btn-modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 20px; }
.modal-footer {
  padding: 0 20px 20px;
  display: flex;
  gap: 10px;
  flex-direction: column;
}

/* ─── Kit detail modal ───────────────────────────────────────────────────── */

.kit-detail-section {
  margin-bottom: 24px;
}

.kit-detail-section-title {
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kit-detail-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Timeline */
.timeline { position: relative; padding-left: 24px; }

.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 20px;
}

.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot {
  position: absolute;
  left: -20px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--surface);
}

.timeline-item.salida    .timeline-dot { background: var(--orange); }
.timeline-item.recepcion .timeline-dot { background: var(--green); }
.timeline-item.entrada   .timeline-dot { background: var(--cyan); }

.timeline-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.timeline-event {
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.timeline-detail {
  font-size: 12px;
  color: var(--text-secondary);
}

.timeline-user {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* Content table */
.content-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.content-table th {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}

.content-table td {
  padding: 8px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

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

.content-table td.ref-code {
  font-family: var(--font-mono);
  color: var(--text-code);
  white-space: nowrap;
}

.content-table td.ref-qty {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
}

/* Editable content rows */
.content-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.content-row .form-input { flex: 1; }
.content-row .qty-input { width: 64px; flex: none; }
.btn-remove-row { background: transparent; border: none; color: var(--text-muted); font-size: 18px; padding: 4px; transition: color var(--transition); }
.btn-remove-row:hover { color: var(--red); }

/* ─── Scanner overlay ────────────────────────────────────────────────────── */

.scanner-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: #000;
  display: flex;
  flex-direction: column;
}

.scanner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: rgba(0,0,0,0.8);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1;
}

.scanner-title {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-primary);
}

.btn-scanner-close {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 24px;
  line-height: 1;
}

#scanner-video { width: 100%; height: 100%; object-fit: cover; }

.scanner-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 240px;
  height: 120px;
  pointer-events: none;
}

.scanner-frame::before,
.scanner-frame::after,
.scanner-frame > span::before,
.scanner-frame > span::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--cyan);
  border-style: solid;
}

.scanner-frame::before { top: 0; left: 0; border-width: 3px 0 0 3px; }
.scanner-frame::after  { top: 0; right: 0; border-width: 3px 3px 0 0; }
.scanner-frame > span::before { bottom: 0; left: 0; border-width: 0 0 3px 3px; }
.scanner-frame > span::after  { bottom: 0; right: 0; border-width: 0 3px 3px 0; }

.scanner-laser {
  position: absolute;
  top: 50%;
  left: 10px;
  right: 10px;
  height: 2px;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
  animation: scan-laser 1.5s ease-in-out infinite;
}

@keyframes scan-laser {
  0%   { top: 10%; }
  100% { top: 90%; }
}

.scanner-hint {
  position: absolute;
  bottom: 40px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 13px;
  color: rgba(255,255,255,0.7);
}

/* ─── Toast ──────────────────────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  top: calc(var(--header-height) + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 32px);
  max-width: 420px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: var(--font-mono);
  box-shadow: var(--shadow-md);
  animation: toast-in 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: all;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.toast.success { background: var(--green-dim);  border: 1px solid rgba(0,255,157,0.3); color: var(--green); }
.toast.error   { background: var(--red-dim);    border: 1px solid rgba(255,77,106,0.3); color: var(--red); }
.toast.info    { background: var(--cyan-dim);   border: 1px solid rgba(0,194,255,0.3); color: var(--cyan); }
.toast.warning { background: var(--orange-dim); border: 1px solid rgba(255,107,53,0.3); color: var(--orange); }

.toast-icon { font-size: 16px; }
.toast-msg  { flex: 1; }

/* ─── Utility classes ────────────────────────────────────────────────────── */

.hidden   { display: none !important; }
.mono     { font-family: var(--font-mono); }
.text-muted  { color: var(--text-muted); }
.text-cyan   { color: var(--cyan); }
.text-green  { color: var(--green); }
.text-orange { color: var(--orange); }
.text-sm  { font-size: 12px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex  { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Tablet / Desktop
   ═══════════════════════════════════════════════════════════════════════════ */

@media (min-width: 640px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .modal { border-radius: var(--radius-xl); align-self: center; }
  .modal-overlay { align-items: center; }
  .app-main { padding: 24px 24px calc(var(--nav-height) + 24px); }
  .modal-footer { flex-direction: row; }
  .modal-footer .btn { flex: 1; }
}

@media (min-width: 768px) {
  .app-nav { display: none; }
  .app-main { padding: 28px 32px 32px; }

  /* Side nav for desktop */
  .app-shell-desktop {
    display: flex;
  }

  .side-nav {
    display: flex;
    flex-direction: column;
    width: 200px;
    min-height: calc(100vh - var(--header-height));
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 16px 12px;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    flex-shrink: 0;
  }

  .side-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    font-family: var(--font-mono);
    text-align: left;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    width: 100%;
    margin-bottom: 2px;
  }

  .side-nav-item .nav-icon { font-size: 16px; }
  .side-nav-item.active { background: var(--cyan-dim); color: var(--cyan); }
  .side-nav-item:hover:not(.active) { background: var(--surface-2); color: var(--text-primary); }

  .side-nav-label {
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 16px 12px 6px;
    font-family: var(--font-mono);
  }
}

@media (min-width: 900px) {
  .side-nav { width: 220px; }
  .stats-grid { gap: 14px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   MÓDULO ROTACIONES
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Barra de filtros ───────────────────────────────────────────────────── */

.rot-filtros {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}

/* ─── Tabla resumen ──────────────────────────────────────────────────────── */

.rot-table { width: 100%; }

.rot-th-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: color var(--transition);
  position: relative;
  padding-right: 18px !important;
}

.rot-th-sortable:hover { color: var(--cyan); }

.rot-th-sortable.sort-active { color: var(--cyan); }

.rot-th-sortable::after {
  content: '⇅';
  position: absolute;
  right: 4px;
  opacity: 0.3;
  font-size: 10px;
}

.rot-th-sortable.sort-active[data-sort-dir="desc"]::after { content: '↓'; opacity: 1; color: var(--cyan); }
.rot-th-sortable.sort-active[data-sort-dir="asc"]::after  { content: '↑'; opacity: 1; color: var(--cyan); }

.rot-row {
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.rot-row:hover { background: var(--surface-2); }

.rot-row-selected {
  background: var(--cyan-dim) !important;
  outline: 1px solid rgba(0,194,255,0.25);
}

.rot-row-selected .rot-rk-code { color: var(--cyan); }

.rot-cell-rk { white-space: nowrap; }

.rot-rk-code {
  display: block;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.rot-lotes-count {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.rot-num {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 13px;
}

.rot-highlight { color: var(--cyan); font-weight: 600; }

.rot-code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}

.rot-dim { color: var(--text-muted); }

/* ─── Panel de detalle ───────────────────────────────────────────────────── */

.rot-detalle-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
  animation: rot-slide-in 0.2s ease;
}

@keyframes rot-slide-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.rot-detalle-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.rot-detalle-rk {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--cyan);
}

.rot-detalle-oem {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 2px;
}

/* ─── Métricas ───────────────────────────────────────────────────────────── */

.rot-metricas {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.rot-metrica {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  flex: 1;
  min-width: 90px;
  text-align: center;
}

.rot-metrica-val {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.rot-metrica-lbl {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: center;
}

/* ─── Tabla de lotes ─────────────────────────────────────────────────────── */

.rot-lotes-table { width: 100%; }

.rot-lote-row {
  cursor: pointer;
  transition: background var(--transition);
}

.rot-lote-row:hover { background: var(--surface-2); }

.rot-lote-selected { background: var(--surface-3) !important; }

/* ─── Barra de progreso de rotación ──────────────────────────────────────── */

.rot-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.rot-bar-val {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 20px;
  text-align: right;
}

.rot-bar-track {
  width: 80px;
  height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}

.rot-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

@media (min-width: 640px) {
  .rot-bar-track { width: 120px; }
  .rot-metricas  { gap: 12px; }
  .rot-metrica   { padding: 12px 20px; }
  .rot-metrica-val { font-size: 24px; }
}

@media (max-width: 480px) {
  .rot-filtros { gap: 8px; }
  .rot-bar-track { width: 60px; }
}
