* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: #f5f7fa;
  color: #1f2937;
  line-height: 1.5;
}

.hero {
  background: linear-gradient(120deg, #0f172a 0%, #1e293b 100%);
  color: #fff;
  padding: 72px 0 64px;
}

.hero h1 {
  margin: 0 0 16px;
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 1.1;
}

.hero p {
  margin: 0;
  max-width: 860px;
  color: #e2e8f0;
  font-size: 1.1rem;
}

.container {
  width: min(1100px, 92%);
  margin: 0 auto;
}

main.container {
  margin-top: 36px;
  margin-bottom: 48px;
}

.status-section {
  background: #fff;
  border: 1px solid #dbe1ea;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.chart-section {
  margin-top: 20px;
}

.chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.chart-subtitle {
  display: block;
  margin-top: 4px;
  font-size: 0.9rem;
  color: #64748b;
  font-weight: 500;
}

.chart-updated {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: #64748b;
}

.chart-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.chart-filters label {
  font-size: 0.9rem;
  color: #334155;
}

.chart-filters input,
.chart-filters button {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.9rem;
}

.chart-filters button {
  background: #0ea5e9;
  color: #fff;
  border-color: #0284c7;
  cursor: pointer;
}

.filter-error {
  margin: 0 0 10px;
  font-size: 0.85rem;
  color: #b91c1c;
}

.chart-wrapper {
  width: 100%;
  overflow-x: auto;
  position: relative;
}

.chart-wrapper-incidents {
  min-height: 280px;
}

.chart-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  z-index: 3;
  background: rgba(255, 255, 255, 0.88);
  color: #991b1b;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.2px;
}

#incidents-chart {
  display: block;
  width: 100%;
  min-width: 680px;
  height: 260px;
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  padding: 6px 8px;
  font-size: 0.75rem;
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.94);
  border-radius: 6px;
  pointer-events: none;
  white-space: nowrap;
}

.chart-instruction {
  margin: 12px 0 6px;
  font-size: 1.15rem;
  font-weight: 800;
  color: #b91c1c;
}

h2 {
  margin-top: 0;
  margin-bottom: 18px;
  font-size: 1.5rem;
}

.status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.history-btn {
  padding: 7px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #1e293b;
  font-size: 0.9rem;
  cursor: pointer;
}

.history-btn-mobile-wrap {
  display: none;
}

.history-section {
  margin-top: 16px;
  border-top: 1px solid #e5e7eb;
  padding-top: 14px;
}

#history-chart {
  display: block;
  width: 100%;
  min-width: 980px;
}

.history-note {
  margin-top: 8px;
  font-size: 0.9rem;
  color: #64748b;
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

thead th {
  background: #f8fafc;
  color: #111827;
  font-weight: 700;
}

tbody tr:hover {
  background: #f9fafb;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.92rem;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.badge-critico {
  background: #fee2e2;
  color: #991b1b;
}

.badge-critico .dot {
  background: #dc2626;
}

.badge-medio {
  background: #fef3c7;
  color: #92400e;
}

.badge-medio .dot {
  background: #f59e0b;
}

.badge-informativo {
  background: #dcfce7;
  color: #166534;
}

.badge-informativo .dot {
  background: #16a34a;
}

.badge-sin_estado {
  background: #e5e7eb;
  color: #374151;
}

.badge-sin_estado .dot {
  background: #6b7280;
}

.updated-meta {
  margin-left: 10px;
  font-size: 0.8rem;
  color: #6b7280;
}

.detail-btn {
  margin-left: 10px;
  padding: 3px 8px;
  font-size: 0.78rem;
  color: #334155;
  background: #eef2f7;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
}

.detail-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.detail-panel {
  margin-top: 8px;
  margin-bottom: 0;
  padding: 10px;
  max-width: 100%;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.75rem;
  color: #475569;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.hidden {
  display: none;
}

.incidents-table-section {
  margin-top: 16px;
}

.incidents-table-pager {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.incidents-table-pager button {
  padding: 4px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  cursor: pointer;
}

.incidents-table-pager button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.incidents-table-pager span {
  font-size: 0.85rem;
  color: #475569;
}

.incidents-table {
  width: 100%;
  border-collapse: collapse;
}

.incidents-table th,
.incidents-table td {
  padding: 10px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  vertical-align: top;
}

.incidents-table th {
  background: #f8fafc;
}

.incident-detail {
  display: inline;
  color: #334155;
}

.incident-detail.truncated {
  display: inline-block;
  max-width: 640px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.incident-detail-btn {
  margin-left: 8px;
  padding: 3px 8px;
  font-size: 0.75rem;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  cursor: pointer;
}

.empty-row {
  color: #64748b;
}

.disclaimer-section {
  margin-top: 20px;
  background: #f8fafc;
  border-color: #e2e8f0;
  opacity: 0.9;
}

.disclaimer-section h2 {
  font-size: 1.05rem;
  margin-bottom: 10px;
  color: #475569;
}

.disclaimer-section p {
  margin: 0 0 12px;
  color: #64748b;
  font-size: 0.9rem;
  line-height: 1.45;
}

.visitor-section {
  margin-top: 20px;
  background: #f8fafc;
  border-color: #e2e8f0;
}

.visitor-counter {
  margin: 0;
  color: #475569;
  font-size: 0.95rem;
}

.status-mobile-list {
  display: none;
}

.status-mobile-item {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: 10px;
  overflow: hidden;
}

.status-mobile-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 0;
  background: #f8fafc;
  color: #0f172a;
  text-align: left;
  cursor: pointer;
}

.status-mobile-title {
  font-weight: 600;
}

.status-mobile-env {
  color: #64748b;
  font-size: 0.88rem;
}

.status-mobile-body {
  padding: 10px 12px 12px;
}

@media (max-width: 768px) {
  .status-desktop-table {
    display: none;
  }

  .status-mobile-list {
    display: block;
  }

  .history-btn-desktop {
    display: none;
  }

  .history-btn-mobile-wrap {
    display: block;
    margin-top: 10px;
  }

  table {
    table-layout: fixed;
  }

  .incidents-table {
    table-layout: auto;
  }

  .incidents-table th:nth-child(1),
  .incidents-table td:nth-child(1) {
    width: 68px;
    white-space: nowrap;
  }

  .incidents-table th:nth-child(2),
  .incidents-table td:nth-child(2) {
    width: 118px;
    white-space: nowrap;
  }

  .incidents-table th:nth-child(3),
  .incidents-table td:nth-child(3) {
    width: auto;
  }

  th,
  td {
    word-break: break-word;
  }

  .hero {
    padding: 44px 0 36px;
  }

  .hero p {
    font-size: 1rem;
  }

  .status-section {
    padding: 16px;
  }

  .chart-filters {
    gap: 8px;
  }

  .chart-filters label {
    width: 100%;
    margin-top: 4px;
  }

  .chart-filters input,
  .chart-filters button {
    width: 100%;
  }

  #incidents-chart {
    min-width: 520px;
  }

  #history-chart {
    min-width: 720px;
  }

  .chart-instruction {
    font-size: 1rem;
  }

  .updated-meta {
    display: block;
    margin-left: 0;
    margin-top: 6px;
  }

  .detail-btn {
    margin-left: 0;
    margin-top: 6px;
  }

  .badge {
    max-width: 100%;
    white-space: normal;
    align-items: flex-start;
    line-height: 1.2;
  }

  .badge .dot {
    margin-top: 3px;
    flex: 0 0 auto;
  }

  .incident-detail.truncated {
    max-width: 220px;
  }
}
