/* ═══════════════════════════════════════════════════════════════════════════════
   METSO PWA — Professional Design System
   ═══════════════════════════════════════════════════════════════════════════════ */

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

:root {
  /* Palette: industrial slate with cyan instrumentation */
  --bg: #080d14;
  --bg-elevated: rgba(13, 20, 31, 0.9);
  --surface: #121a26;
  --surface-hover: #172233;
  --surface2: #1b2635;
  --surface2-hover: #243246;
  --border: rgba(148, 163, 184, 0.1);
  --border-strong: rgba(186, 230, 253, 0.18);

  /* Text */
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #8ca0b8;
  --text-faint: #64758c;

  /* Accent: Teal-blue */
  --primary: #22b8cf;
  --primary-light: #67e8f9;
  --primary-dim: rgba(34, 184, 207, 0.14);
  --primary-glow: rgba(34, 184, 207, 0.28);
  --primary-surface: rgba(34, 184, 207, 0.09);

  /* Status */
  --success: #10b981;
  --success-light: #34d399;
  --success-dim: rgba(16, 185, 129, 0.12);
  --success-glow: rgba(16, 185, 129, 0.2);
  --danger: #ef4444;
  --danger-dim: rgba(239, 68, 68, 0.12);
  --warning: #f59e0b;
  --warning-dim: rgba(245, 158, 11, 0.12);

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 0.75rem;
  --space-lg: 1rem;
  --space-xl: 1.5rem;
  --space-2xl: 2rem;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 100px;

  /* Shadows (tinted) */
  --shadow-sm: 0 8px 20px rgba(2, 6, 23, 0.28);
  --shadow-md: 0 18px 40px rgba(2, 6, 23, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  --shadow-lg: 0 26px 70px rgba(2, 6, 23, 0.5), 0 0 0 1px rgba(186, 230, 253, 0.06);
  --shadow-glow: 0 0 20px var(--primary-glow);

  /* Typography */
  --font: 'Inter', ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Aptos', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', 'SF Mono', 'Fira Code', ui-monospace, monospace;

  /* Layout */
  --tab-height: 76px;
  --topbar-height: 64px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;
}

html, body { height: 100%; overflow: hidden; }

body {
  background:
    radial-gradient(circle at 14% -10%, rgba(34, 184, 207, 0.18), transparent 34%),
    radial-gradient(circle at 95% 8%, rgba(16, 185, 129, 0.1), transparent 30%),
    linear-gradient(180deg, #0b1320 0%, var(--bg) 44%, #060a10 100%);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
  scrollbar-width: thin;
  scrollbar-color: rgba(34,184,207,0.3) transparent;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  opacity: 0.32;
  background-image:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, black, transparent 76%);
}

button,
input,
select,
textarea { font: inherit; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary-light);
  outline-offset: 3px;
}

/* ─── SCREENS ──────────────────────────────────────────────────────────────── */
body { visibility: hidden; }
body.ready { visibility: visible; }
.screen { display: none; height: 100vh; height: 100dvh; }
.screen.active { display: flex; flex-direction: column; }

/* ─── APP LAYOUT ───────────────────────────────────────────────────────────── */
#app-screen { display: none; flex-direction: column; height: 100vh; height: 100dvh; }
#app-screen.active { display: flex; }

/* ─── TOPBAR ───────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: calc(var(--space-md) + env(safe-area-inset-top, 0px)) var(--space-lg) var(--space-md);
  height: var(--topbar-height);
  background: linear-gradient(180deg, rgba(12, 19, 31, 0.94), rgba(12, 19, 31, 0.78));
  border-bottom: 1px solid rgba(186, 230, 253, 0.1);
  flex-shrink: 0;
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  box-shadow: 0 12px 30px rgba(2, 6, 23, 0.25);
}

.mode-btns {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(186, 230, 253, 0.09);
  border-radius: var(--radius-full);
}

.mode-btn {
  min-height: 36px;
  padding: 0.45rem 0.9rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--duration-normal) var(--ease-out);
}
.mode-btn:hover {
  background: var(--surface);
  color: var(--text-secondary);
  border-color: rgba(148, 163, 184, 0.2);
}
.mode-btn.active {
  background: linear-gradient(180deg, rgba(34, 184, 207, 0.22), rgba(34, 184, 207, 0.12));
  color: var(--primary-light);
  border-color: rgba(103, 232, 249, 0.28);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 8px 20px rgba(34, 184, 207, 0.12);
}

.week-select {
  margin-left: auto;
  min-height: 38px;
  padding: 0.45rem 0.7rem;
  background: rgba(18, 26, 38, 0.9);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: -0.01em;
  cursor: pointer;
  max-width: 90px;
  transition: border-color var(--duration-fast);
}
.week-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
}

/* ─── MAIN CONTENT ─────────────────────────────────────────────────────────── */
main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg) calc(var(--tab-height) + var(--space-2xl));
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* ─── TAB BAR ──────────────────────────────────────────────────────────────── */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--tab-height);
  display: flex;
  background: linear-gradient(180deg, rgba(10, 16, 25, 0.82), rgba(10, 16, 25, 0.96));
  border-top: 1px solid rgba(186, 230, 253, 0.12);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
  backdrop-filter: blur(22px) saturate(1.2);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  box-shadow: 0 -18px 45px rgba(2, 6, 23, 0.5);
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-sm);
  position: relative;
  border-radius: var(--radius-lg);
  transition: all var(--duration-normal) var(--ease-out);
}
.tab-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 24px;
  height: 2px;
  background: var(--primary-light);
  border-radius: 0 0 2px 2px;
  transition: transform var(--duration-normal) var(--ease-spring);
}
.tab-btn.active { color: var(--primary-light); background: rgba(34, 184, 207, 0.07); }
.tab-btn.active::before { transform: translateX(-50%) scaleX(1); }
.tab-btn:active { transform: scale(0.92); }

.tab-btn .tab-icon { font-size: 1.28rem; line-height: 1; filter: saturate(0.9); }
.tab-btn .tab-label { font-size: 0.65rem; font-weight: 500; letter-spacing: 0.02em; }

/* ─── TAB PANELS ───────────────────────────────────────────────────────────── */
.tab-panel { display: none; animation: fadeIn var(--duration-normal) var(--ease-out); }
.tab-panel.active { display: block; }

.register-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
  padding: var(--space-xl);
  background:
    linear-gradient(135deg, rgba(34, 184, 207, 0.16), rgba(18, 26, 38, 0.88) 48%, rgba(16, 185, 129, 0.08)),
    var(--surface);
  border: 1px solid rgba(186, 230, 253, 0.16);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
}
.register-hero::after {
  content: '';
  position: absolute;
  right: -48px;
  top: -60px;
  width: 150px;
  height: 150px;
  border: 1px solid rgba(103, 232, 249, 0.18);
  border-radius: 999px;
}
.eyebrow {
  display: inline-flex;
  margin-bottom: var(--space-sm);
  color: var(--primary-light);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.register-hero h1 {
  font-size: clamp(1.55rem, 8vw, 2.4rem);
  line-height: 0.95;
  letter-spacing: -0.055em;
  text-wrap: balance;
}
.register-hero p {
  max-width: 34ch;
  margin-top: var(--space-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.hero-week {
  position: relative;
  align-self: flex-start;
  min-width: 82px;
  padding: var(--space-sm) var(--space-md);
  background: rgba(8, 13, 20, 0.54);
  border: 1px solid rgba(103, 232, 249, 0.18);
  border-radius: var(--radius-lg);
  text-align: right;
}
.hero-week span {
  display: block;
  color: var(--text-faint);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.hero-week strong {
  display: block;
  margin-top: 2px;
  color: var(--primary-light);
  font-family: var(--font-mono);
  font-size: 1.1rem;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── BUTTONS ──────────────────────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  min-height: 52px;
  padding: 0.9rem var(--space-lg);
  background: linear-gradient(135deg, #0891b2, #22b8cf 54%, #67e8f9);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  box-shadow: 0 16px 30px rgba(34, 184, 207, 0.22), inset 0 1px 0 rgba(255,255,255,0.22);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #0e7490, #22b8cf 58%, #a5f3fc);
  box-shadow: 0 20px 38px rgba(34, 184, 207, 0.3), inset 0 1px 0 rgba(255,255,255,0.22);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 1px 4px rgba(14, 165, 233, 0.2);
}
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  min-height: 42px;
  padding: 0.68rem 1.2rem;
  background: rgba(186, 230, 253, 0.08);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}
.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: rgba(148, 163, 184, 0.2);
  color: var(--text);
}
.btn-secondary:active { transform: scale(0.97); }

.btn-success {
  width: calc(100% - 2rem);
  margin: var(--space-lg) var(--space-lg);
  padding: 0.85rem;
  background: var(--success);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  box-shadow: 0 2px 8px var(--success-glow);
}
.btn-success:hover {
  background: #059669;
  box-shadow: 0 4px 16px var(--success-glow);
  transform: translateY(-1px);
}
.btn-success:active { transform: translateY(0) scale(0.98); }
.btn-success:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

/* ─── FORM ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: var(--space-xl); }

.form-group label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-sm);
}

.form-group input[type="text"],
.form-group textarea {
  width: 100%;
  padding: 0.95rem 1rem;
  background: rgba(18, 26, 38, 0.86);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font);
  -webkit-appearance: none;
  transition: all var(--duration-fast) var(--ease-out);
}
.form-group input[type="text"]:focus,
.form-group textarea:focus {
  outline: none;
  border-color: rgba(103, 232, 249, 0.5);
  box-shadow: 0 0 0 4px var(--primary-dim), 0 14px 30px rgba(2, 6, 23, 0.22);
  background: var(--bg-elevated);
}
.form-group input[type="text"]::placeholder,
.form-group textarea::placeholder {
  color: var(--text-faint);
}
.form-group textarea {
  resize: vertical;
  min-height: 88px;
  line-height: 1.5;
}

.required { color: var(--danger); font-weight: 700; }

/* ─── TAG LIST ─────────────────────────────────────────────────────────────── */
.tag-list {
  max-height: 240px;
  overflow-y: auto;
  background: rgba(18, 26, 38, 0.96);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  margin-top: var(--space-sm);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.tag-item {
  padding: 0.9rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background var(--duration-fast);
}
.tag-item:last-child { border-bottom: none; }
.tag-item:hover { background: linear-gradient(90deg, var(--primary-surface), var(--surface-hover)); }
.tag-item:active { background: var(--primary-dim); }

.tag-id {
  color: var(--primary);
  font-weight: 600;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
}
.tag-desc { color: var(--text); font-size: 0.85rem; }
.tag-plant {
  color: var(--text-faint);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

.selected-tag {
  padding: 0.85rem 1rem;
  margin-top: var(--space-sm);
  background: linear-gradient(135deg, rgba(34, 184, 207, 0.16), rgba(34, 184, 207, 0.07));
  border: 1px solid rgba(103, 232, 249, 0.24);
  border-radius: var(--radius-lg);
  color: var(--primary-light);
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.selected-tag button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
  transition: color var(--duration-fast);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.selected-tag button:hover { color: var(--danger); background: var(--danger-dim); }

/* ─── TIPO BUTTONS ─────────────────────────────────────────────────────────── */
.tipo-btns { display: flex; gap: var(--space-sm); }

.tipo-btn {
  flex: 1;
  min-height: 42px;
  padding: 0.65rem var(--space-sm);
  background: rgba(18, 26, 38, 0.82);
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  text-align: center;
}
.tipo-btn:hover {
  background: var(--surface-hover);
  color: var(--text-secondary);
}
.tipo-btn.active {
  background: linear-gradient(180deg, rgba(34, 184, 207, 0.2), rgba(34, 184, 207, 0.1));
  color: var(--primary-light);
  border-color: rgba(103, 232, 249, 0.34);
  font-weight: 600;
}

/* ─── PHOTOS PREVIEW ───────────────────────────────────────────────────────── */
.photo-dropzone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md);
  background: linear-gradient(135deg, rgba(18, 26, 38, 0.88), rgba(34, 184, 207, 0.05));
  border: 1px dashed rgba(103, 232, 249, 0.24);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  font-size: 0.84rem;
  transition: all var(--duration-fast) var(--ease-out);
}
.photo-dropzone.drag-over {
  background: var(--primary-surface);
  border-color: var(--primary);
  color: var(--primary-light);
  box-shadow: 0 0 0 4px var(--primary-dim), var(--shadow-md);
}

.photos-preview {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-top: var(--space-md);
}

.photo-thumb-wrap {
  position: relative;
  width: 78px;
  height: 78px;
  flex-shrink: 0;
}
.photo-thumb {
  width: 78px;
  height: 78px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 2px solid rgba(186, 230, 253, 0.18);
  box-shadow: var(--shadow-sm);
  transition: all var(--duration-fast);
  display: block;
}
.photo-thumb-wrap:hover .photo-thumb {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}
.photo-thumb-del {
  display: none;
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  border: none;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.photo-thumb-wrap:hover .photo-thumb-del {
  display: flex;
}

@media (min-width: 820px) {
  main { max-width: 900px; }
  #tab-registrar.active {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.78fr);
    gap: var(--space-xl);
    align-items: start;
  }
  #tab-registrar .register-hero,
  #tab-registrar #reg-guardar,
  #tab-registrar #reg-msg { grid-column: 1 / -1; }
}

@media (max-width: 420px) {
  .topbar { gap: var(--space-sm); }
  .mode-btn { padding-inline: 0.7rem; font-size: 0.76rem; }
  .register-hero { padding: var(--space-lg); }
  .hero-week { display: none; }
  .photo-dropzone { align-items: stretch; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── PLAN ─────────────────────────────────────────────────────────────────── */
.plan-week {
  font-size: 0.78rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: var(--space-lg);
}

.plan-bars { display: flex; gap: var(--space-md); margin-bottom: var(--space-xl); }

.plan-bar-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: center;
  transition: all var(--duration-normal) var(--ease-out);
}
.plan-bar-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.plan-bar-pct {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.plan-bar-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: var(--space-xs) 0 var(--space-md);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

.plan-bar-track {
  background: var(--surface2);
  border-radius: var(--radius-full);
  height: 5px;
  overflow: hidden;
}

.plan-bar-fill {
  background: linear-gradient(90deg, var(--primary), #38bdf8);
  border-radius: var(--radius-full);
  height: 5px;
  transition: width var(--duration-slow) var(--ease-out);
}

.plan-stats { display: flex; flex-direction: column; gap: var(--space-sm); }

.plan-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  transition: background var(--duration-fast);
}
.plan-stat:hover { background: var(--surface-hover); }

.plan-stat-val { font-weight: 700; font-family: var(--font-mono); letter-spacing: -0.02em; }
.val-ok { color: var(--success); }
.val-pending { color: var(--warning); }

/* ─── PENDIENTES ───────────────────────────────────────────────────────────── */
.pending-header {
  font-size: 0.82rem;
  color: var(--warning);
  font-weight: 600;
  margin-bottom: var(--space-lg);
  padding: var(--space-sm) var(--space-md);
  background: var(--warning-dim);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--warning);
}

.pending-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin-bottom: var(--space-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  transition: all var(--duration-fast);
}
.pending-item:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.pending-item-info { flex: 1; min-width: 0; }
.pending-item-tag {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.pending-item-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.btn-mark-ok {
  padding: 0.4rem 0.85rem;
  white-space: nowrap;
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  min-width: 80px;
  text-align: center;
  transition: all var(--duration-normal) var(--ease-out);
}
.btn-mark-ok:hover {
  background: var(--success-dim);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.3);
}
.btn-mark-ok:active { transform: scale(0.95); }
.btn-mark-ok.done {
  background: var(--success-dim);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.3);
  font-weight: 600;
}
.btn-mark-ok:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── INFORME ──────────────────────────────────────────────────────────────── */
.informe-opciones { display: flex; flex-direction: column; gap: var(--space-md); }

.informe-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg) var(--space-xl);
  display: flex;
  gap: var(--space-lg);
  align-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: all var(--duration-normal) var(--ease-out);
}
.informe-card:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.informe-card:active {
  transform: translateY(0) scale(0.98);
  box-shadow: none;
}

.informe-icon { font-size: 2rem; flex-shrink: 0; line-height: 1; }
.informe-card div { flex: 1; }
.informe-card strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.informe-card small { font-size: 0.78rem; color: var(--text-muted); line-height: 1.3; }

.informe-badge {
  background: var(--primary-dim);
  color: var(--primary);
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

/* ─── INFO ─────────────────────────────────────────────────────────────────── */
.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border);
}
.info-row:last-child { border-bottom: none; }
.info-row span:first-child { color: var(--text-muted); font-size: 0.84rem; }
.info-row span:last-child,
.info-row strong { font-weight: 600; color: var(--text); }

/* ─── LOGIN ────────────────────────────────────────────────────────────────── */
.login-box {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  padding: var(--space-2xl) var(--space-xl);
  margin: auto;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-logo { width: 80px; height: 80px; object-fit: contain; margin: 0 auto var(--space-md); }
.login-box h1 { font-size: 1.4rem; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.login-box select,
.login-box input[type="password"] {
  width: 100%;
  padding: 0.8rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 1rem;
  transition: border-color var(--duration-fast);
}
.login-box select:focus,
.login-box input[type="password"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
}

/* ─── MISC ─────────────────────────────────────────────────────────────────── */
.error-msg { color: var(--danger); font-size: 0.82rem; min-height: 1.2em; font-weight: 500; }

.status-msg {
  font-size: 0.82rem;
  min-height: 1.2em;
  margin-top: var(--space-lg);
  text-align: center;
  font-weight: 500;
}

.loading-placeholder {
  color: var(--text-faint);
  font-size: 0.88rem;
  padding: var(--space-md) 0;
  text-align: center;
}

/* ─── SCROLLBAR ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ═══════════════════════════════════════════════════════════════════════════════
   PWA COMPONENTS (Offline, Install, Update, Toast, Sync)
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ─── OFFLINE BANNER ───────────────────────────────────────────────────────── */
#offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(90deg, #92400e, #b45309);
  color: #fef3c7;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.45rem var(--space-md);
  transform: translateY(-100%);
  transition: transform var(--duration-normal) var(--ease-out);
  z-index: 300;
  letter-spacing: 0.01em;
}
#offline-banner.visible { transform: translateY(0); }

/* ─── SYNC BADGE ───────────────────────────────────────────────────────────── */
#sync-badge {
  position: fixed;
  top: var(--space-sm);
  right: var(--space-sm);
  background: var(--warning-dim);
  color: var(--warning);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  border: 1px solid rgba(245, 158, 11, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-normal);
  z-index: 250;
}
#sync-badge.visible { opacity: 1; }

/* ─── INSTALL BANNER ───────────────────────────────────────────────────────── */
#install-banner {
  position: fixed;
  bottom: calc(var(--tab-height) + env(safe-area-inset-bottom, 0px) + var(--space-lg));
  left: var(--space-lg);
  right: var(--space-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: slideUp var(--duration-slow) var(--ease-spring);
}
#install-banner span { flex: 1; }

#install-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.45rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--duration-fast);
}
#install-btn:hover { background: #0284c7; }
#install-btn:active { transform: scale(0.95); }

#install-dismiss {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.3rem;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast);
}
#install-dismiss:hover { color: var(--text); background: var(--surface); }

/* ─── UPDATE BANNER ────────────────────────────────────────────────────────── */
#update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(90deg, var(--primary), #0284c7);
  color: #fff;
  padding: 0.65rem var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: 0.82rem;
  font-weight: 500;
  z-index: 310;
  animation: slideDown var(--duration-normal) var(--ease-out);
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}
#update-banner span { flex: 1; }

#update-btn {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--duration-fast);
  backdrop-filter: blur(4px);
}
#update-btn:hover { background: rgba(255, 255, 255, 0.3); }

/* ─── TOAST ────────────────────────────────────────────────────────────────── */
#pwa-toast {
  position: fixed;
  bottom: calc(var(--tab-height) + env(safe-area-inset-bottom, 0px) + var(--space-lg));
  left: 50%;
  transform: translateX(-50%) translateY(0.75rem);
  background: var(--surface);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 0.55rem 1.5rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all var(--duration-normal) var(--ease-out);
  z-index: 400;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}
#pwa-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── ANIMATIONS ───────────────────────────────────────────────────────────── */
@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ─── FOCUS VISIBLE ────────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
button:focus-visible { outline-offset: 3px; }

/* ─── SKELETON LOADERS ─────────────────────────────────────────────────────── */
.skeleton-group { padding: var(--space-sm) 0; }

.skeleton-line {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
  height: 16px;
  width: 100%;
}

.skeleton-card {
  flex: 1;
  height: 100px;
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-lg);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── EMPTY STATES ─────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl) var(--space-lg);
  text-align: center;
}
.empty-state .empty-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 1.3rem;
  color: var(--text-faint);
  margin-bottom: var(--space-lg);
}
.empty-state.success .empty-icon {
  background: var(--success-dim);
  border-color: rgba(16, 185, 129, 0.2);
  color: var(--success);
}
.empty-state .empty-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}
.empty-state .empty-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 240px;
}

/* ─── SELECTION ────────────────────────────────────────────────────────────── */
::selection {
  background: var(--primary-dim);
  color: var(--primary);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   TAB: BOT WHATSAPP
   ═══════════════════════════════════════════════════════════════════════════════ */

.bot-status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  display: flex; align-items: center; gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.bot-dot {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 0 0 3px transparent;
  transition: all 0.4s;
}
.bot-dot.offline  { background: var(--text-faint); }
.bot-dot.starting { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-dim); animation: bot-pulse 1.2s infinite; }
.bot-dot.qr       { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); animation: bot-pulse 1.2s infinite; }
.bot-dot.online   { background: var(--success); box-shadow: 0 0 0 3px var(--success-glow); }
.bot-dot.error    { background: var(--danger); }

@keyframes bot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.bot-status-info { flex: 1; min-width: 0; }
.bot-status-label { font-size: 1rem; font-weight: 600; }
.bot-status-detail { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; font-family: var(--font-mono); }
.bot-status-pid { font-size: 0.72rem; color: var(--text-faint); margin-top: 2px; }

.bot-metrics-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-md);
  margin-bottom: var(--space-lg);
}
.bot-metric-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  text-align: center;
}
.bot-metric-val { font-size: 1.3rem; font-weight: 700; font-family: var(--font-mono); letter-spacing: -0.02em; color: var(--text); }
.bot-metric-lbl { font-size: 0.68rem; color: var(--text-muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.04em; }

.bot-actions { display: flex; flex-direction: column; gap: var(--space-md); margin-bottom: var(--space-lg); }

.btn-bot-success, .btn-bot-secondary, .btn-bot-danger {
  width: 100%; padding: 0.8rem var(--space-lg);
  border: none; border-radius: var(--radius-md);
  font-size: 0.9rem; font-weight: 600; letter-spacing: -0.01em;
  cursor: pointer; transition: all var(--duration-normal) var(--ease-out);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font);
}
.btn-bot-success:disabled, .btn-bot-secondary:disabled, .btn-bot-danger:disabled {
  cursor: not-allowed;
}
.btn-bot-success:active:not(:disabled), .btn-bot-secondary:active:not(:disabled), .btn-bot-danger:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-bot-success  { background: var(--success); color: #fff; box-shadow: 0 2px 8px rgba(16,185,129,0.25); }
.btn-bot-success:hover:not(:disabled)  { background: #059669; box-shadow: 0 4px 16px rgba(16,185,129,0.35); transform: translateY(-1px); }

.btn-bot-secondary { background: var(--surface); color: var(--text-secondary); border: 1px solid var(--border-strong); }
.btn-bot-secondary:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }

.btn-bot-danger { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(239,68,68,0.25); }
.btn-bot-danger:hover:not(:disabled) { background: rgba(239,68,68,0.2); }

.bot-btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }

.bot-qr-section {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl);
  overflow: hidden; display: none; margin-bottom: var(--space-lg);
}
.bot-qr-section.visible { display: block; }
.bot-qr-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--border);
}
.bot-qr-title { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.bot-qr-badge {
  font-size: 0.7rem; font-weight: 600; padding: 0.2rem 0.5rem;
  background: var(--primary-dim); color: var(--primary);
  border-radius: var(--radius-full); animation: bot-pulse 1.4s infinite;
}
.bot-qr-frame {
  padding: var(--space-xl); display: flex; justify-content: center;
}
.bot-qr-frame iframe {
  width: 240px; height: 300px; border: none; border-radius: var(--radius-md); background: #fff;
}
.bot-qr-hint {
  padding: 0 var(--space-xl) var(--space-xl);
  font-size: 0.78rem; color: var(--text-muted); text-align: center; line-height: 1.5;
}

.bot-log-section {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl);
  margin-bottom: var(--space-lg);
}
.bot-log-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--border);
}
.bot-log-title { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.bot-log-clear { font-size: 0.72rem; color: var(--text-faint); cursor: pointer; padding: 0.2rem 0.5rem; border-radius: var(--radius-sm); transition: color var(--duration-fast); }
.bot-log-clear:hover { color: var(--text-muted); }
#bot-log-list { padding: var(--space-md) var(--space-lg); max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.bot-log-entry { font-size: 0.75rem; font-family: var(--font-mono); line-height: 1.4; }
.bot-log-ts { color: var(--text-faint); margin-right: 6px; }
.bot-log-entry.ok .bot-log-msg  { color: var(--success); }
.bot-log-entry.err .bot-log-msg { color: var(--danger); }
.bot-log-entry.warn .bot-log-msg { color: var(--warning); }
.bot-log-entry.info .bot-log-msg { color: var(--primary); }
.bot-log-entry .bot-log-msg { color: var(--text-muted); }
