:root {
  --verde-escuro: #2E7D32;
  --verde-claro: #66BB6A;
  --azul: #1565C0;
  --turquesa: #00ACC1;
  --escuro: #263238;
  --claro: #F5F7FA;

  --bg: #0b1220;
  --bg-sidebar: #0d1526;
  --bg-card: #141b2e;
  --bg-card-hover: #182035;
  --border: rgba(255,255,255,.08);
  --text: #e8eaed;
  --text-muted: #8b95a5;
  --vermelho: #ef5350;
  --amarelo: #ffb74d;
}

* { box-sizing: border-box; }

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

.hidden { display: none !important; }
a { color: inherit; }

#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(160deg, rgba(11,18,32,.55), rgba(11,18,32,.85)),
    linear-gradient(135deg, #1b2a3d, #0b1220 60%);
  position: relative;
  overflow: hidden;
}
#login-screen::before {
  content: "";
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 300' preserveAspectRatio='none'%3E%3Cpath d='M0 300 L150 120 L280 220 L420 60 L600 220 L760 100 L900 240 L1050 140 L1200 260 L1200 300 Z' fill='%23142035' opacity='0.9'/%3E%3Cpath d='M0 300 L200 200 L380 260 L560 160 L740 260 L920 180 L1200 280 L1200 300 Z' fill='%230d1526'/%3E%3C/svg%3E");
  background-position: bottom;
  background-repeat: no-repeat;
  background-size: cover;
}
.login-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 2.5rem;
  border-radius: 16px;
  width: 340px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  text-align: center;
}
.login-logo { display: flex; justify-content: center; margin-bottom: 1rem; }
.login-logo img { background: #fff; border-radius: 12px; padding: .6rem; }
.login-card h1 { margin: .5rem 0 0; color: var(--text); font-size: 1.3rem; }
.login-card .subtitle { margin: .2rem 0 1.5rem; color: var(--text-muted); font-size: .85rem; }
.login-card label { display: block; margin-bottom: 1rem; text-align: left; }
.login-card input {
  display: block; width: 100%; margin-top: .3rem; padding: .65rem .8rem;
  border: 1px solid var(--border); border-radius: 8px; font-size: .95rem;
  background: #0e1524; color: var(--text);
}
.login-card input::placeholder { color: var(--text-muted); }
.login-card button[type=submit] {
  width: 100%; padding: .75rem; background: var(--verde-escuro); color: #fff;
  border: none; border-radius: 8px; font-size: 1rem; cursor: pointer; margin-top: .5rem;
  font-weight: 600;
}
.login-card button[type=submit]:hover { filter: brightness(1.15); }
.login-footer { margin-top: 1.5rem; font-size: .75rem; color: var(--text-muted); }

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

.sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 1.2rem 0;
}
.sidebar-logo { display: flex; align-items: center; gap: .6rem; padding: 0 1.2rem 1.2rem; }
.sidebar-logo img { background: #fff; border-radius: 6px; padding: .2rem; }
.sidebar-logo span { font-weight: 700; font-size: 1rem; }
.nav-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .7rem 1.2rem; color: var(--text-muted); cursor: pointer;
  font-size: .9rem; border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--bg-card); color: var(--text); }
.nav-item.active { background: var(--bg-card); color: var(--verde-claro); border-left-color: var(--verde-claro); font-weight: 600; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-footer {
  margin-top: auto; padding: 1rem 1.2rem 0; border-top: 1px solid var(--border);
  font-size: .75rem; color: var(--text-muted); text-align: center;
}
.sidebar-footer .brand { color: var(--verde-claro); font-weight: 600; }

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

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 1.15rem; }
.topbar .subtitle { margin: .1rem 0 0; font-size: .8rem; color: var(--text-muted); }
.topbar-right { display: flex; align-items: center; gap: 1.2rem; font-size: .85rem; color: var(--text-muted); }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--verde-claro); margin-right: .4rem; }
.user-menu { display: flex; align-items: center; gap: .5rem; }

.content { padding: 1.5rem; overflow-y: auto; flex: 1; }
.page { display: none; }
.page.active { display: block; }

.cards-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 1.1rem 1.3rem;
}
.card-label { font-size: .78rem; color: var(--text-muted); margin-bottom: .5rem; display: flex; align-items: center; gap: .4rem; }
.card-value { font-size: 1.6rem; font-weight: 700; display: flex; align-items: baseline; gap: .4rem; }
.card-value .unit { font-size: 1rem; color: var(--text-muted); font-weight: 400; }
.card-sub { font-size: .78rem; color: var(--verde-claro); margin-top: .3rem; }

.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 1rem; margin-bottom: 1.2rem; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

.panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 1.1rem 1.3rem; }
.panel h3 { margin: 0 0 .8rem; font-size: .95rem; }
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; }

#map, #map-full { border-radius: 8px; overflow: hidden; }
#map { height: 320px; }
#map-full { height: 600px; }

canvas { max-width: 100%; }

.table-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { padding: .65rem .9rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-muted); font-weight: 600; font-size: .75rem; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-card-hover); }

.empty-state { padding: 2rem; text-align: center; color: var(--text-muted); font-size: .9rem; }

button {
  background: var(--verde-escuro); color: #fff; border: none; border-radius: 6px;
  padding: .5rem .9rem; font-size: .85rem; cursor: pointer;
}
button.ghost { background: none; color: var(--text); border: 1px solid var(--border); }
button.ghost:hover { background: var(--bg-card-hover); }
button.danger { background: var(--vermelho); }

.badge { padding: .15rem .55rem; border-radius: 20px; font-size: .78rem; white-space: nowrap; }
.badge.critico { background: rgba(239,83,80,.15); color: var(--vermelho); }
.badge.aviso { background: rgba(255,183,77,.15); color: var(--amarelo); }
.badge.ok { background: rgba(102,187,106,.15); color: var(--verde-claro); }

.alert-row {
  display: flex; align-items: center; gap: 1rem; padding: .9rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.alert-row:last-child { border-bottom: none; }
.alert-icon { font-size: 1.3rem; }
.alert-body { flex: 1; }
.alert-title { font-weight: 600; font-size: .9rem; }
.alert-meta { font-size: .78rem; color: var(--text-muted); }

.gauge-row { display: flex; align-items: center; gap: .8rem; margin-bottom: .9rem; }
.gauge-label { width: 70px; font-size: .82rem; color: var(--text-muted); }
.gauge-bar { flex: 1; height: 8px; background: rgba(255,255,255,.08); border-radius: 4px; overflow: hidden; }
.gauge-fill { height: 100%; background: var(--verde-claro); border-radius: 4px; }
.gauge-fill.warn { background: var(--amarelo); }
.gauge-fill.crit { background: var(--vermelho); }
.gauge-value { width: 45px; text-align: right; font-size: .82rem; font-weight: 600; }

.service-row { display: flex; align-items: center; justify-content: space-between; padding: .6rem 0; border-bottom: 1px solid var(--border); font-size: .85rem; }
.service-row:last-child { border-bottom: none; }

.report-form { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.report-form label { font-size: .8rem; color: var(--text-muted); }
.report-form input, .report-form select {
  display: block; margin-top: .3rem; padding: .5rem .6rem; border-radius: 6px;
  border: 1px solid var(--border); background: #0e1524; color: var(--text); font-size: .85rem;
}

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 1.5rem; width: 340px;
}
.modal-card h3 { margin: 0 0 1rem; font-size: 1.05rem; }
.modal-card label { display: block; font-size: .8rem; color: var(--text-muted); margin-bottom: .8rem; }
.modal-card input, .modal-card select {
  display: block; width: 100%; margin-top: .3rem; padding: .5rem .6rem;
  border: 1px solid var(--border); border-radius: 6px; font-size: .9rem;
  background: #0e1524; color: var(--text);
}
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: .5rem; }
.error { color: var(--vermelho); font-size: .85rem; min-height: 1.2em; margin: .3rem 0 0; }
