* { box-sizing: border-box; }
html, body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f3f4f6;
  color: #111827;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

header {
  background: #0f172a;
  color: white;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
header h1 { margin: 0; font-size: 18px; font-weight: 600; }

.tdv-logo {
  display: flex;
  align-items: baseline;
  gap: 10px;
  text-decoration: none;
}
.tdv-logo-mark {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -1px;
  color: #ffffff;
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1;
}
.tdv-logo-mark .d { font-weight: 400; font-size: 22px; }
.tdv-logo-divider {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.3);
}
.tdv-logo-sub {
  font-size: 13px;
  font-weight: 500;
  color: #cbd5e1;
  letter-spacing: 0.2px;
}
header nav a { color: #cbd5e1; margin-left: 18px; font-weight: 500; }
header nav a.active { color: white; }
.user-pill {
  background: #1e293b;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  margin-left: 12px;
}

main {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 24px 60px;
}

h2 { font-size: 20px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 18px 0 10px; color: #374151; text-transform: uppercase; letter-spacing: 0.5px; }

.card {
  background: white;
  border-radius: 12px;
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.grid-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi {
  background: white;
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.kpi .label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: #6b7280; }
.kpi .value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.kpi.rojo .value { color: #dc2626; }
.kpi.amarillo .value { color: #d97706; }
.kpi.verde .value { color: #059669; }
.kpi.azul .value { color: #2563eb; }
.kpi.morado .value { color: #7c3aed; }

table { width: 100%; border-collapse: collapse; }
table th, table td { padding: 10px 12px; text-align: left; font-size: 14px; border-bottom: 1px solid #e5e7eb; }
table th { background: #f9fafb; color: #6b7280; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
table tr:hover td { background: #f9fafb; }

.semaforo {
  display: inline-block;
  width: 10px; height: 10px; border-radius: 50%;
  margin-right: 6px;
}
.semaforo.verde { background: #10b981; }
.semaforo.amarillo { background: #f59e0b; }
.semaforo.rojo { background: #ef4444; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.pendiente { background: #fee2e2; color: #b91c1c; }
.badge.en_progreso { background: #fef3c7; color: #92400e; }
.badge.resuelto { background: #d1fae5; color: #065f46; }
.badge.escalado { background: #fce7f3; color: #9d174d; }

.prioridad-alta { color: #b91c1c; font-weight: 700; }
.prioridad-media { color: #d97706; font-weight: 600; }
.prioridad-baja { color: #2563eb; }

form .row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
form .col { flex: 1; min-width: 240px; }
form label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; color: #374151; }
form input[type=text], form input[type=number], form select, form textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
form textarea { min-height: 90px; resize: vertical; }
form input:focus, form select:focus, form textarea:focus { outline: 2px solid #2563eb; border-color: #2563eb; }

.checkbox-group {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 6px 14px;
  background: #f9fafb;
  padding: 10px 12px;
  border-radius: 8px;
}
.checkbox-group label {
  display: flex; align-items: center; gap: 6px;
  font-weight: normal; margin-bottom: 0; font-size: 14px;
}
.checkbox-group input { margin: 0; }

.btn {
  display: inline-block;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: #1d4ed8; }
.btn.secondary { background: #e5e7eb; color: #1f2937; }
.btn.secondary:hover { background: #d1d5db; }
.btn.success { background: #059669; }
.btn.success:hover { background: #047857; }
.btn.warn { background: #d97706; }
.btn.danger { background: #dc2626; }

.notif-bell {
  position: relative;
  margin-left: 12px;
  cursor: pointer;
  font-size: 18px;
}
.notif-bell .count {
  position: absolute;
  top: -6px; right: -8px;
  background: #ef4444;
  color: white;
  border-radius: 999px;
  font-size: 11px;
  padding: 1px 6px;
  font-weight: 700;
}
.notif-panel {
  position: absolute;
  top: 60px;
  right: 28px;
  width: 360px;
  background: white;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  max-height: 500px;
  overflow-y: auto;
  z-index: 10;
  display: none;
}
.notif-panel.open { display: block; }
.notif-panel .item {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
  display: flex; gap: 8px;
}
.notif-panel .item.unread { background: #eff6ff; }
.notif-panel .item .dot {
  width: 8px; height: 8px; border-radius: 50%; margin-top: 6px;
  flex-shrink: 0;
}
.notif-panel .item .dot.asignacion { background: #2563eb; }
.notif-panel .item .dot.recordatorio_50 { background: #f59e0b; }
.notif-panel .item .dot.recordatorio_80 { background: #f97316; }
.notif-panel .item .dot.vencido { background: #dc2626; }
.notif-panel .item .dot.respuesta { background: #10b981; }
.notif-panel .item .meta { color: #6b7280; font-size: 11px; margin-top: 2px; }

.dept-card {
  background: #f9fafb;
  border-left: 4px solid #93c5fd;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.dept-card.respondido { border-left-color: #10b981; }
.dept-card .head { display: flex; justify-content: space-between; align-items: center; }
.dept-card .nombre { font-weight: 600; }

.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: #111827;
  color: white;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  opacity: 0;
  transition: opacity 0.25s;
  z-index: 100;
}
.toast.show { opacity: 1; }

.email-row {
  border-left: 3px solid #2563eb;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: #f9fafb;
  border-radius: 4px;
  font-size: 13px;
}
.email-row .asunto { font-weight: 600; }
.email-row .meta { color: #6b7280; font-size: 11px; }
.email-row pre { white-space: pre-wrap; margin: 6px 0 0; font-family: inherit; }

.tab-bar { display: flex; gap: 6px; margin-bottom: 12px; }
.tab-bar .tab {
  padding: 8px 14px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  background: #e5e7eb;
  color: #4b5563;
  font-size: 13px;
  font-weight: 500;
}
.tab-bar .tab.active { background: white; color: #111827; }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: #6b7280;
  font-size: 14px;
}

/* ---- Admin panel ---- */
.admin-tabs { display: flex; gap: 4px; border-bottom: 2px solid #e5e7eb; margin-bottom: 20px; }
.admin-tabs .atab {
  padding: 10px 20px; cursor: pointer; font-size: 14px; font-weight: 500;
  border-radius: 8px 8px 0 0; color: #6b7280; background: none; border: none;
}
.admin-tabs .atab.active { background: white; color: #111827; border: 2px solid #e5e7eb; border-bottom: 2px solid white; margin-bottom: -2px; }
.admin-tabs .atab:hover:not(.active) { background: #f9fafb; }

.admin-section { display: none; }
.admin-section.active { display: block; }

.admin-toolbar {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px;
}

.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.45); z-index: 200; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: white; border-radius: 12px; padding: 24px 28px;
  width: 480px; max-width: 95vw; box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal-box h3 { margin: 0 0 18px; font-size: 17px; }
.modal-box .modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  background: #f9fafb; padding: 12px 14px; border-radius: 8px; margin-bottom: 14px;
}
.filter-bar label { font-size: 12px; font-weight: 500; color: #374151; display: block; margin-bottom: 3px; }
.filter-bar select, .filter-bar input { padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  background: #eff6ff; color: #1d4ed8; padding: 3px 10px;
  border-radius: 999px; font-size: 13px; font-weight: 500;
}
.tag .del { cursor: pointer; color: #6b7280; font-size: 15px; line-height: 1; }
.tag .del:hover { color: #dc2626; }

.config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 640px) { .config-grid { grid-template-columns: 1fr; } }

.btn.sm { padding: 5px 12px; font-size: 12px; }
table .btn.sm { border-radius: 6px; }
