:root {
  --accent: #27a8ff;
  --accent-dark: #1d8ae0;
  --bg: #0f1720;
  --panel: #142638;
  --panel-2: #1d3b55;
  --border: #223349;
  --text: #eaf2fb;
  --text-secondary: #6f7c8d;
  --success: #4cd787;
  --danger-fix: #e04f5f;
  --warning: #f0b429;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

#login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 32px;
  width: 320px;
  text-align: center;
}

.login-card h1 {
  color: var(--accent);
  font-size: 20px;
  margin-bottom: 4px;
}

.login-card .brand-logo {
  height: 72px;
  width: auto;
  display: block;
  margin: 0 auto 10px;
}

.login-card .brand-wordmark {
  width: 180px;
  height: auto;
  display: block;
  margin: 0 auto;
}

.login-card p {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 0;
  margin-bottom: 24px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

textarea { resize: vertical; min-height: 60px; }

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  background: var(--accent);
  color: #06131f;
  transition: background 0.15s;
}

button:hover { background: var(--accent-dark); }

button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

button.danger {
  background: var(--danger-fix);
  color: white;
}

button.small { padding: 6px 10px; font-size: 12px; }

.error-msg {
  color: var(--danger-fix);
  font-size: 13px;
  min-height: 18px;
}

#app-view { display: none; min-height: 100vh; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  flex-shrink: 0;
}

.sidebar .brand {
  padding: 0 20px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.sidebar .brand-logo-small {
  height: 32px;
  width: auto;
  display: block;
  margin-bottom: 8px;
}

.sidebar .brand-wordmark-small {
  width: 120px;
  height: auto;
  display: block;
}

.sidebar .brand small {
  display: block;
  color: var(--text-secondary);
  font-weight: 400;
  font-size: 12px;
  margin-top: 4px;
}

.nav-item {
  display: block;
  padding: 12px 20px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  border-left: 3px solid transparent;
}

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

.nav-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(39,168,255,0.08);
}

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

.sidebar-footer .who {
  font-size: 13px;
  margin-bottom: 8px;
}

.sidebar-footer .who .rol {
  color: var(--text-secondary);
  font-size: 12px;
}

.main {
  flex: 1;
  padding: 28px 32px;
  overflow-x: auto;
}

.main h2 {
  margin-top: 0;
  font-size: 20px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar .filters { display: flex; gap: 8px; }
.toolbar select { width: auto; margin-bottom: 0; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

th, td {
  text-align: left;
  padding: 10px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  background: var(--panel-2);
}

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

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.badge.abierto { background: rgba(240,180,41,0.15); color: var(--warning); }
.badge.en_progreso { background: rgba(39,168,255,0.15); color: var(--accent); }
.badge.cerrado { background: rgba(76,215,135,0.15); color: var(--success); }
.badge.admin { background: rgba(39,168,255,0.15); color: var(--accent); }
.badge.tecnico { background: rgba(111,124,141,0.2); color: var(--text-secondary); }
.badge.activo { background: rgba(76,215,135,0.15); color: var(--success); }
.badge.inactivo { background: rgba(224,79,95,0.15); color: var(--danger-fix); }
.badge.empresarial { background: rgba(39,168,255,0.15); color: var(--accent); }
.badge.normal { background: rgba(111,124,141,0.2); color: var(--text-secondary); }
.badge.laptop { background: rgba(76,215,135,0.15); color: var(--success); }
.badge.desktop { background: rgba(111,124,141,0.2); color: var(--text-secondary); }

.actions-cell { white-space: nowrap; }

.resumen-cards {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.resumen-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--panel);
}

.resumen-card .nombre { font-weight: 600; }
.resumen-card .detalle { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.actions-cell button { margin-right: 6px; }

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 380px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal.wide {
  width: 760px;
  max-width: 92vw;
}

.modal h3 { margin-top: 0; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.hidden { display: none !important; }

.empty-state {
  color: var(--text-secondary);
  font-size: 13px;
  padding: 24px;
  text-align: center;
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: 10px;
}

.muted {
  color: var(--text-secondary);
  font-style: italic;
}

.version-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0 24px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.version-form input[type="text"],
.version-form input:not([type]),
.version-form input[type="file"] {
  width: auto;
  margin-bottom: 0;
  flex: 1 1 180px;
}
.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.checkbox-inline input { width: auto; margin: 0; }

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 100;
}

.toast.error { border-color: var(--danger-fix); color: var(--danger-fix); }

/* ---------- WhatsApp ---------- */

.wa-layout {
  display: flex;
  height: calc(100vh - 100px);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel);
}

.wa-lista {
  width: 300px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.wa-conv {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.wa-conv:hover { background: rgba(255,255,255,0.03); }

.wa-conv.active { background: rgba(39,168,255,0.1); }

.wa-conv .wa-conv-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.wa-conv .wa-conv-nombre { font-weight: 600; font-size: 13px; }
.wa-conv .wa-conv-hora { font-size: 11px; color: var(--text-secondary); flex-shrink: 0; }
.wa-conv .wa-conv-preview {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.wa-conv .wa-badge-nuevo {
  display: inline-block;
  background: var(--success);
  color: #06131f;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  margin-left: 6px;
}

.wa-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.wa-thread-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
}
.wa-thread-header .wa-thread-tel {
  font-weight: 400;
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: 8px;
}

.wa-mensajes {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wa-bubble {
  max-width: 65%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.wa-bubble.entrante {
  align-self: flex-start;
  background: var(--panel-2);
  border-top-left-radius: 2px;
}

.wa-bubble.saliente {
  align-self: flex-end;
  background: rgba(39,168,255,0.18);
  border-top-right-radius: 2px;
}

.wa-bubble .wa-bubble-meta {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-secondary);
  text-align: right;
}

.wa-composer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.wa-composer textarea {
  margin-bottom: 0;
  min-height: 40px;
  max-height: 120px;
  flex: 1;
}

.wa-composer button { flex-shrink: 0; align-self: flex-end; }

.wa-sin-seleccion {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 13px;
}

/* ---------- Impresión ---------- */

.print-header {
  display: none;
}

@media print {
  body { background: white; color: #111; }

  .sidebar,
  .toast,
  .modal-overlay,
  .toolbar button,
  .toolbar select,
  .actions-cell,
  .no-print {
    display: none !important;
  }

  .layout { display: block; }
  .main { padding: 0; }

  .print-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 14px;
    margin-bottom: 18px;
    border-bottom: 2px solid #27a8ff;
  }
  .print-header-logo { height: 46px; width: auto; }
  .print-header-wordmark { width: 130px; height: auto; }
  .print-meta {
    margin-left: auto;
    font-size: 11px;
    color: #555;
    text-align: right;
  }

  table {
    background: white;
    border-color: #ccc;
    box-shadow: none;
  }
  th {
    background: #f0f0f0;
    color: #333;
  }
  th, td { color: #111; border-color: #ddd; }
  .badge { border: 1px solid #999; background: none !important; color: #111 !important; }

  h2 { color: #111; }
}
