/* =========================================================================
   SysÁgua · Centro de Operações — estética "control room / telemetria"
   Chakra Petch (display) · Archivo (corpo) · IBM Plex Mono (dados)
   ========================================================================= */
:root {
  --bg: #04090e;
  --bg2: #07121b;
  --surface: rgba(12, 26, 36, 0.66);
  --surface-2: rgba(16, 34, 46, 0.85);
  --line: rgba(86, 178, 200, 0.16);
  --line-strong: rgba(86, 198, 222, 0.4);
  --text: #d6ecf2;
  --muted: #6f93a3;
  --cyan: #29d3e6;
  --aqua: #38e6c4;
  --amber: #ffb43b;
  --coral: #ff5e6c;
  --lime: #b6f24a;
  --glow: 0 0 18px rgba(41, 211, 230, 0.45);
  --font-display: 'Chakra Petch', sans-serif;
  --font-body: 'Archivo', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

/* variável animável p/ o efeito spotlight que segue o mouse */
@property --spot { syntax: '<number>'; inherits: false; initial-value: 0; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(120% 80% at 50% -10%, #0a1a26 0%, var(--bg) 60%);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  min-height: 100vh;
  overflow-x: hidden;
}

/* fundo: grade blueprint + brilho + scanlines */
.bg-grid, .bg-glow, .bg-scan { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.bg-grid {
  background-image:
    linear-gradient(rgba(41, 211, 230, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(41, 211, 230, 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(120% 90% at 50% 0%, #000 40%, transparent 90%);
}
.bg-glow { background: radial-gradient(60% 40% at 80% 0%, rgba(56, 230, 196, 0.12), transparent 70%), radial-gradient(50% 40% at 10% 10%, rgba(41, 211, 230, 0.1), transparent 70%); }
.bg-scan { background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px); opacity: 0.35; mix-blend-mode: overlay; }
body > *:not(.bg-grid):not(.bg-glow):not(.bg-scan) { position: relative; z-index: 1; }

/* ---- topbar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(8, 20, 28, 0.9), rgba(8, 20, 28, 0.35));
  backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 600;
}
.brand { display: flex; align-items: center; gap: 14px; }
.droplet { color: var(--cyan); font-size: 22px; filter: drop-shadow(var(--glow)); animation: pulse 2.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.55; transform: scale(0.9); } }
.brand h1 { margin: 0; font-family: var(--font-display); font-size: 19px; font-weight: 700; letter-spacing: 0.06em; }
.brand h1 span { color: var(--cyan); }
.brand h1 i { color: var(--muted); font-style: normal; font-weight: 500; font-size: 13px; letter-spacing: 0.1em; }
.brand small { color: var(--muted); font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.04em; }
.status { display: flex; align-items: center; gap: 12px; font-family: var(--font-mono); font-size: 11px; color: var(--aqua); border: 1px solid var(--line); padding: 7px 13px; border-radius: 2px; background: var(--surface); }
.dotlive { width: 8px; height: 8px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 10px var(--lime); animation: pulse 1.6s infinite; }
.clock { color: var(--muted); }

/* ---- filtros ---- */
.filtros { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; padding: 16px 24px; border-bottom: 1px solid var(--line); background: rgba(7, 16, 22, 0.5); }
.filtro { display: flex; flex-direction: column; gap: 5px; }
.filtro label { font-family: var(--font-mono); font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; }
.filtros select, .filtros input {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 2px; padding: 8px 10px; min-width: 120px; font-size: 13px; font-family: var(--font-body);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.filtros input[type="date"] { min-width: 132px; color-scheme: dark; }
.filtros select:focus, .filtros input:focus { outline: none; border-color: var(--cyan); box-shadow: var(--glow); }
.btn {
  font-family: var(--font-display); font-weight: 600; letter-spacing: 0.05em;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 2px; padding: 9px 16px; cursor: pointer; font-size: 12.5px; text-decoration: none;
  transition: all 0.18s; text-transform: uppercase;
}
.btn:hover { border-color: var(--cyan); color: var(--cyan); box-shadow: var(--glow); }
.btn.primary { background: linear-gradient(180deg, var(--cyan), #14a4c0); color: #032029; border-color: var(--cyan); box-shadow: var(--glow); }
.btn.ghost { color: var(--muted); }
.btn.featured { background: linear-gradient(180deg, var(--amber), #d98a17); color: #2a1700; border-color: var(--amber); box-shadow: 0 0 16px rgba(255, 180, 59, 0.4); }
.btn.featured:hover { color: #2a1700; filter: brightness(1.1); }
.sel-info { align-self: center; color: var(--amber); font-family: var(--font-mono); font-size: 11px; }

/* ---- KPIs (módulos de telemetria) ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(186px, 1fr)); gap: 14px; padding: 20px 24px; }
.kpi {
  position: relative; border: 1px solid var(--line);
  padding: 14px 16px 13px; backdrop-filter: blur(6px);
  --mx: 50%; --my: 50%; --spot: 0;
  background-color: var(--surface);
  background-image: radial-gradient(200px circle at var(--mx) var(--my), rgb(56 230 196 / calc(0.2 * var(--spot))), transparent 55%);
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%);
  transition: --spot 0.35s ease, transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}
.kpi:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: 0 12px 26px rgba(0, 0, 0, 0.45); --spot: 1; }
.kpi:hover::before { box-shadow: 0 0 16px var(--cyan); opacity: 1; }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; width: 3px; height: 100%; background: var(--cyan); box-shadow: var(--glow); opacity: 0.7; }
.kpi .label { font-family: var(--font-mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.kpi .value { font-family: var(--font-mono); font-size: 25px; font-weight: 600; margin-top: 7px; color: var(--text); letter-spacing: -0.01em; text-shadow: 0 0 14px rgba(41, 211, 230, 0.25); }
.kpi .sub { font-size: 11px; margin-top: 5px; color: var(--muted); }
.kpi .value.good { color: var(--lime); } .kpi .value.good { text-shadow: 0 0 14px rgba(182, 242, 74, 0.3); }
.kpi .value.warn { color: var(--amber); }
.kpi .value.bad { color: var(--coral); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.kpis .kpi:nth-child(1) { animation-delay: 0.02s; } .kpis .kpi:nth-child(2) { animation-delay: 0.06s; }
.kpis .kpi:nth-child(3) { animation-delay: 0.1s; } .kpis .kpi:nth-child(4) { animation-delay: 0.14s; }
.kpis .kpi:nth-child(5) { animation-delay: 0.18s; } .kpis .kpi:nth-child(6) { animation-delay: 0.22s; }
.kpis .kpi:nth-child(7) { animation-delay: 0.26s; } .kpis .kpi:nth-child(8) { animation-delay: 0.3s; }
.kpis .kpi:nth-child(n+9) { animation-delay: 0.34s; }

/* ---- abas ---- */
.tabs { display: flex; gap: 4px; padding: 6px 24px 0; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tab {
  font-family: var(--font-display); font-weight: 600; letter-spacing: 0.04em;
  background: transparent; color: var(--muted); border: 1px solid transparent; border-bottom: none;
  padding: 11px 18px; cursor: pointer; font-size: 13px; text-transform: uppercase;
  position: relative; transition: color 0.18s;
}
.tab b { font-family: var(--font-mono); color: var(--line-strong); margin-right: 6px; font-weight: 500; font-size: 11px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--cyan); }
.tab.active b { color: var(--cyan); }
.tab.active::after { content: ''; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; background: var(--cyan); box-shadow: var(--glow); }

.panel { display: none; padding: 6px 0; }
.panel.active { display: block; }
.hint { color: var(--muted); font-family: var(--font-mono); font-size: 11px; padding: 10px 26px 0; letter-spacing: 0.03em; }

.grid-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(370px, 1fr)); gap: 16px; padding: 16px 24px 96px; }
.grid-charts canvas { height: 262px !important; max-height: 262px; }
.card.wide { grid-column: 1 / -1; }

/* ---- cards com cantos em colchete ---- */
.card {
  position: relative; border: 1px solid var(--line);
  padding: 15px 17px; backdrop-filter: blur(7px);
  --mx: 50%; --my: 50%; --spot: 0;
  background-color: var(--surface);
  background-image: radial-gradient(260px circle at var(--mx) var(--my), rgb(41 211 230 / calc(0.16 * var(--spot))), transparent 55%);
  transition: --spot 0.35s ease, transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}
.card:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45), 0 0 22px rgba(41, 211, 230, 0.1); --spot: 1; }
.card::before, .card::after { content: ''; position: absolute; width: 12px; height: 12px; pointer-events: none; }
.card::before { left: -1px; top: -1px; border-left: 2px solid var(--cyan); border-top: 2px solid var(--cyan); }
.card::after { right: -1px; bottom: -1px; border-right: 2px solid var(--cyan); border-bottom: 2px solid var(--cyan); }
.grid-charts .card:nth-child(2) { animation-delay: 0.05s; } .grid-charts .card:nth-child(3) { animation-delay: 0.1s; }
.grid-charts .card:nth-child(4) { animation-delay: 0.15s; } .grid-charts .card:nth-child(5) { animation-delay: 0.2s; }
.grid-charts .card:nth-child(6) { animation-delay: 0.25s; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; gap: 12px; }
.card-head h2 { font-family: var(--font-display); font-size: 13px; font-weight: 600; margin: 0; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text); }
.card-head h2::before { content: '▸ '; color: var(--cyan); }
.card-head small { color: var(--muted); font-family: var(--font-mono); font-size: 10.5px; }

.map-card { margin: 16px 24px; }
#map { height: 520px; width: 100%; border: 1px solid var(--line); }
.map-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.exports { font-family: var(--font-mono); font-size: 10px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; letter-spacing: 0.08em; }
.btn.sm { padding: 5px 9px; font-size: 10px; color: var(--cyan); }

/* ---- tabelas ---- */
.tbl, .comp-table { overflow-x: auto; }
.tbl table, .comp-table table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-family: var(--font-mono); }
.tbl th, .tbl td, .comp-table th, .comp-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl th, .comp-table th { color: var(--cyan); font-weight: 600; text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.06em; }
.tbl tr:hover { background: rgba(41, 211, 230, 0.06); }
.muted { color: var(--muted); font-size: 11px; }
.abc-A { color: var(--coral); font-weight: 700; } .abc-B { color: var(--amber); font-weight: 700; } .abc-C { color: var(--lime); font-weight: 700; }

/* ---- popup leaflet ---- */
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface-2); color: var(--text); border-radius: 2px; border: 1px solid var(--line-strong); }
.uc-popup { font-family: var(--font-mono); font-size: 11.5px; }
.uc-popup b { color: var(--cyan); font-family: var(--font-display); }
.uc-popup .row { display: flex; justify-content: space-between; gap: 16px; }
.leaflet-container { background: #061019; }

/* ---- chat flutuante ---- */
.chat-toggle {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 1000;
  white-space: nowrap; max-width: calc(100vw - 40px);
  display: inline-flex; align-items: center; gap: 9px;
  padding: 12px 18px; border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 40px;
  background: linear-gradient(135deg, var(--aqua), var(--cyan) 55%, #0d8aa0);
  color: #042027; cursor: pointer;
  font-family: var(--font-display); font-weight: 700; font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase;
  box-shadow: 0 8px 28px rgba(41, 211, 230, 0.5), 0 0 0 4px rgba(41, 211, 230, 0.12);
  transition: transform 0.18s, box-shadow 0.18s;
}
.chat-toggle .ic { font-size: 17px; line-height: 1; filter: saturate(0.6); }
.chat-toggle { animation: floaty 3.6s ease-in-out infinite; }
.chat-toggle:hover { transform: translateX(-50%) translateY(-3px); box-shadow: 0 14px 38px rgba(41, 211, 230, 0.7), 0 0 0 5px rgba(41, 211, 230, 0.2); animation-play-state: paused; }
@keyframes floaty { 0%, 100% { bottom: 24px; } 50% { bottom: 31px; } }
.chat-toggle.hidden { display: none; }
@media (max-width: 480px) { .chat-toggle .lbl { display: none; } .chat-toggle { padding: 14px; border-radius: 50%; } }
.chat-panel {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 92px;
  width: 390px; max-width: calc(100vw - 32px);
  height: 560px; max-height: calc(100vh - 130px); background: var(--surface-2); backdrop-filter: blur(12px);
  border: 1px solid var(--line-strong); display: flex; flex-direction: column; z-index: 1000; overflow: hidden;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.6); animation: riseC 0.25s ease;
}
@keyframes riseC { from { opacity: 0; transform: translateX(-50%) translateY(14px); } to { opacity: 1; transform: translateX(-50%); } }
.chat-panel.hidden { display: none; }
.chat-header { display: flex; justify-content: space-between; align-items: center; padding: 13px 15px; background: linear-gradient(90deg, rgba(41, 211, 230, 0.12), transparent); border-bottom: 1px solid var(--line); font-family: var(--font-display); font-weight: 600; letter-spacing: 0.06em; font-size: 13px; }
.chat-header small { color: var(--aqua); font-family: var(--font-mono); font-weight: 400; font-size: 10px; }
.chat-header button { background: none; border: none; color: var(--muted); font-size: 15px; cursor: pointer; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 10px 13px; border-radius: 2px; max-width: 90%; white-space: pre-wrap; line-height: 1.5; font-size: 13px; }
.msg.user { background: linear-gradient(180deg, var(--cyan), #16a8c4); color: #042027; align-self: flex-end; font-weight: 500; }
.msg.bot { background: var(--surface); border: 1px solid var(--line); border-left: 2px solid var(--cyan); align-self: flex-start; }
.msg.bot.refuse { border-left-color: var(--amber); }
.msg.typing { color: var(--muted); font-style: italic; }
.msg b { color: var(--cyan); font-family: var(--font-mono); }
.chat-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 13px 8px; }
.chat-suggest button { font-family: var(--font-mono); background: var(--surface); color: var(--muted); border: 1px solid var(--line); border-radius: 2px; padding: 5px 9px; font-size: 10.5px; cursor: pointer; }
.chat-suggest button:hover { color: var(--cyan); border-color: var(--cyan); }
.chat-input { display: flex; gap: 8px; padding: 11px; border-top: 1px solid var(--line); }
.chat-input input { flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: 2px; padding: 10px 12px; color: var(--text); font-size: 13px; font-family: var(--font-body); }
.chat-input input:focus { outline: none; border-color: var(--cyan); box-shadow: var(--glow); }
.chat-input button { background: var(--cyan); color: #042027; border: none; border-radius: 2px; width: 44px; cursor: pointer; font-size: 16px; }

@media (max-width: 560px) { .brand small, .clock { display: none; } }
