/* Status dos Sistemas - Anglo | Mobile-first */
:root {
  --blue: #0066CC;
  --blue-dark: #004C99;
  --green: #10B981;
  --red: #EF4444;
  --amber: #F59E0B;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-400: #9CA3AF;
  --gray-600: #4B5563;
  --gray-800: #1F2937;
  --gray-900: #111827;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
}

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

html, body { max-width: 100%; overflow-x: hidden; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
  color: #fff;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}
.brand-logo { height: 52px; width: 52px; display: block; justify-self: start; }
.brand-name {
  font-weight: 600;
  font-size: 18px;
  letter-spacing: .3px;
  text-align: center;
  justify-self: center;
}
.last-update { font-size: 12px; opacity: .9; justify-self: end; text-align: right; }

/* Container */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
  flex: 1;
}

/* Alert */
.alert {
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #FDE68A;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 14px;
  margin-bottom: 16px;
}

/* Overall banner */
.overall {
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  color: #fff;
  font-weight: 600;
  font-size: 18px;
  box-shadow: var(--shadow);
  background: var(--gray-400);
}
.overall.online { background: var(--green); }
.overall.offline { background: var(--red); }
.overall.unknown { background: var(--gray-400); }
.overall-icon {
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.overall-icon::after {
  content: ''; width: 8px; height: 8px; border-radius: 50%; background: #fff;
}

/* Status dot */
.dot {
  width: 11px; height: 11px; border-radius: 50%;
  flex-shrink: 0; display: inline-block; margin-right: 8px;
}
.dot.online { background: var(--green); }
.dot.offline { background: var(--red); }
.dot.unknown { background: var(--gray-400); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* Components card (rows) */
.components { margin-bottom: 20px; }
.components-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px 20px;
}
.comp-row { padding: 18px 0; border-bottom: 1px solid var(--gray-100); }
.comp-row:last-child { border-bottom: none; }
.comp-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 10px;
}
.comp-name { font-weight: 600; font-size: 15px; display: flex; align-items: center; }
.comp-status { font-size: 14px; font-weight: 600; white-space: nowrap; }
.comp-status.online { color: var(--green); }
.comp-status.offline { color: var(--red); }
.comp-status.unknown { color: var(--gray-400); }

/* 90-day uptime bars */
.uptime { }
.bars { display: flex; gap: 1px; align-items: flex-end; width: 100%; overflow: hidden; }
.bar {
  flex: 1 1 0;
  height: 30px;
  min-width: 0;
  border-radius: 2px;
  background: var(--gray-200);
  transition: transform .1s;
}
.bar.up { background: var(--green); }
.bar.partial { background: var(--amber); }
.bar.down { background: var(--red); }
.bar.nodata { background: var(--gray-200); }
.bar:hover { transform: scaleY(1.15); }
.uptime-legend {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 6px; font-size: 12px; color: var(--gray-400);
}
.uptime-legend .pct { color: var(--gray-600); font-weight: 600; }

/* Panel (ramais) */
.panel {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.panel-head {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-head h2 { font-size: 17px; }
.counts { display: flex; gap: 8px; flex-wrap: wrap; }
.count {
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--gray-100);
  color: var(--gray-600);
}
.count b { color: var(--gray-900); }
.count-online { background: #ECFDF5; }
.count-online b { color: var(--green); }
.count-offline { background: #FEF2F2; }
.count-offline b { color: var(--red); }
.count-total { background: #EFF6FF; }
.count-total b { color: var(--blue); }

/* Filter row */
.filter-row { display: flex; gap: 8px; margin-bottom: 12px; }
#searchInput {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  font-size: 16px; /* 16px evita o zoom automatico do iOS ao focar */
  font-family: inherit;
}
#searchInput:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,102,204,.1); }
.toggle {
  padding: 11px 14px;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  color: var(--gray-600);
}
.toggle.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* Ramais list */
.ramais-list { list-style: none; }
.ramal {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--gray-100);
}
.ramal:last-child { border-bottom: none; }
.ramal-num {
  font-weight: 700;
  font-size: 15px;
  color: var(--blue);
  min-width: 56px;
}
.ramal-body { flex: 1; min-width: 0; }
.ramal-name {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ramal-meta { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.online { background: #ECFDF5; color: var(--green); }
.badge.offline { background: #FEF2F2; color: var(--red); }
.empty { text-align: center; color: var(--gray-400); padding: 32px 0; }

/* Footer */
.footer {
  text-align: center;
  padding: 16px;
  color: var(--gray-400);
  font-size: 13px;
}

/* Colunas (mobile-first: empilhado) */
.columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}
.col-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-600);
  margin: 0 0 10px 2px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.components { margin-bottom: 0; }

/* Tablet / Desktop */
@media (min-width: 640px) {
  .panel-head { flex-direction: row; align-items: center; justify-content: space-between; }
}
@media (min-width: 900px) {
  /* Serviços à esquerda, ramais à direita */
  .columns { grid-template-columns: 1fr 1fr; }
}

/* Refino para celulares (iPhone e menores) */
@media (max-width: 480px) {
  .topbar { padding: 12px 14px; gap: 8px; }
  .brand-logo { height: 42px; width: 42px; }
  .brand-name { font-size: 15px; }
  .last-update { font-size: 11px; }
  .container { padding: 14px; }
  .overall { padding: 12px 14px; font-size: 14px; gap: 10px; margin-bottom: 14px; }
  .overall-icon { width: 18px; height: 18px; }
  .overall-icon::after { width: 6px; height: 6px; }
  /* Seção "Serviços e Sistemas" mais compacta no celular */
  .col-title { font-size: 13px; margin-bottom: 8px; }
  .components-card { padding: 0 14px; }
  .comp-row { padding: 12px 0; }
  .comp-head { margin-bottom: 7px; }
  .comp-name { font-size: 13.5px; }
  .comp-status { font-size: 12.5px; }
  .bar { height: 22px; }
  .uptime-legend { font-size: 10.5px; margin-top: 4px; }
  .counts { width: 100%; }
  .filter-row { flex-wrap: nowrap; }
  .toggle { padding: 11px 12px; }
  /* garante que nada estoure a largura da tela */
  .container, .overall, .components-card, .panel, .service-card { max-width: 100%; }
}
