/* ========================================================================= 
   Design system compartilhado com os outros dois projetos
   ========================================================================= */
:root[data-theme="dark"]{
  --bg:#0A0A0A; --bg-elevated:#111110; --surface:#151513; --surface-hover:#1D1D1A;
  --border:#2A2A26; --border-soft:#1E1E1B;
  --text:#F3F2ED; --text-dim:#948F84; --text-faint:#5C584F;
  --accent:#D83831; --accent-text:#FF6156; --accent-soft:rgba(216,56,49,.16); --accent-soft-strong:rgba(216,56,49,.30);
  --success:#3FAE6B; --success-soft:rgba(63,174,107,.14);
  --warn:#D89A38; --warn-soft:rgba(216,154,56,.14);
  --danger:#FF6156; --danger-soft:rgba(216,56,49,.18);
}
:root[data-theme="light"]{
  --bg:#FBFAF8; --bg-elevated:#FFFFFF; --surface:#FFFFFF; --surface-hover:#F3F2ED;
  --border:#E4E2DB; --border-soft:#ECEAE3;
  --text:#14130F; --text-dim:#716C61; --text-faint:#A8A297;
  --accent:#D83831; --accent-text:#B72B25; --accent-soft:rgba(216,56,49,.08); --accent-soft-strong:rgba(216,56,49,.16);
  --success:#2F8F55; --success-soft:rgba(47,143,85,.10);
  --warn:#B57A1F; --warn-soft:rgba(181,122,31,.10);
  --danger:#B72B25; --danger-soft:rgba(216,56,49,.10);
}
*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }
body{ background:var(--bg); color:var(--text); font-family:'Inter',system-ui,sans-serif; -webkit-font-smoothing:antialiased; transition:background .35s ease, color .35s ease; }
.mono{ font-family:'IBM Plex Mono',ui-monospace,monospace; }
a{ color:inherit; text-decoration:none; }
button{ font-family:inherit; cursor:pointer; }
input,select,textarea{ font-family:inherit; }
:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; border-radius:4px; }

.app{ max-width:1120px; margin:0 auto; padding:24px 20px 80px; }
@keyframes riseIn{ from{ opacity:0; transform:translateY(10px);} to{ opacity:1; transform:translateY(0);} }
.rise{ animation:riseIn .5s cubic-bezier(.16,1,.3,1) both; }

header.top{ display:flex; align-items:flex-start; justify-content:space-between; gap:20px; padding-bottom:22px; border-bottom:1px solid var(--border-soft); margin-bottom:26px; flex-wrap:wrap; }
.brand{ display:flex; align-items:center; gap:14px; }
.brand-mark{ width:40px; height:40px; border-radius:10px; background:var(--accent); display:flex; align-items:center; justify-content:center; flex-shrink:0; position:relative; overflow:hidden; color:#fff; }
.brand-mark::after{ content:""; position:absolute; inset:0; background:repeating-linear-gradient(115deg, rgba(255,255,255,.16) 0 2px, transparent 2px 7px); }
.brand-mark svg{ position:relative; z-index:1; width:20px; height:20px; }
.brand-text h1{ margin:0; font-size:19px; font-weight:700; letter-spacing:.01em; }
.brand-text p{ margin:2px 0 0; font-size:12px; color:var(--text-dim); }
.top-right{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.live-pill{ display:flex; align-items:center; gap:7px; padding:7px 12px; border:1px solid var(--border); border-radius:100px; font-size:11.5px; color:var(--text-dim); }
.live-dot{ width:7px; height:7px; border-radius:50%; background:var(--accent); animation:pulse 2.2s infinite; }
@keyframes pulse{ 0%{ box-shadow:0 0 0 0 var(--accent-soft-strong); } 70%{ box-shadow:0 0 0 7px rgba(216,56,49,0); } 100%{ box-shadow:0 0 0 0 rgba(216,56,49,0); } }
.icon-btn{ width:36px; height:36px; border-radius:9px; border:1px solid var(--border); background:var(--surface); display:flex; align-items:center; justify-content:center; color:var(--text); transition:all .2s ease; flex-shrink:0; }
.icon-btn:hover{ background:var(--surface-hover); border-color:var(--text-faint); }
.icon-btn svg{ width:17px; height:17px; }

.section-label{ display:flex; align-items:center; gap:10px; margin:0 0 14px; font-size:11.5px; text-transform:uppercase; letter-spacing:.1em; color:var(--text-faint); font-weight:600; }
.section-label .num{ color:var(--accent); }
.section-label::after{ content:""; flex:1; height:1px; background:var(--border-soft); }
.panel{ background:var(--surface); border:1px solid var(--border); border-radius:16px; padding:22px; margin-bottom:26px; }

.btn-primary{ background:var(--accent); color:#fff; border:none; padding:11px 22px; font-size:13px; font-weight:600; border-radius:9px; cursor:pointer; transition:all .2s ease; display:inline-flex; align-items:center; gap:8px; }
.btn-primary:hover{ background:var(--accent-text); }
.btn-primary:disabled{ opacity:.5; cursor:not-allowed; }
.btn-secondary{ background:var(--bg-elevated); color:var(--text); border:1px solid var(--border); padding:9px 16px; font-size:12.5px; font-weight:600; border-radius:9px; cursor:pointer; display:inline-flex; align-items:center; gap:7px; transition:all .15s ease; }
.btn-secondary:hover{ border-color:var(--accent); color:var(--accent-text); }
.btn-danger{ background:none; border:none; color:var(--text-faint); font-size:12px; cursor:pointer; }
.btn-danger:hover{ color:var(--danger); }

/* ---------- Cards genericos (conexao / monitor) ---------- */
.card-grid{ display:grid; grid-template-columns:repeat(auto-fill, minmax(240px,1fr)); gap:14px; }
.entity-card{ border:1.5px solid var(--border); border-radius:14px; padding:16px; background:var(--bg-elevated); position:relative; }
.entity-card .badge-row{ display:flex; gap:6px; margin-bottom:8px; flex-wrap:wrap; }
.badge{ font-size:10px; font-weight:700; padding:3px 9px; border-radius:100px; text-transform:uppercase; letter-spacing:.03em; }
.badge.pro{ background:var(--accent-soft); color:var(--accent-text); }
.badge.fabric{ background:var(--success-soft); color:var(--success); }
.badge.manual{ background:var(--border-soft); color:var(--text-dim); }
.badge.automatico{ background:var(--success-soft); color:var(--success); }
.badge.modo-manual{ background:var(--border-soft); color:var(--text-dim); }
.entity-card .name{ font-size:14px; font-weight:600; margin-bottom:4px; }
.entity-card .meta{ font-size:11.5px; color:var(--text-faint); margin-bottom:12px; }
.entity-card .actions{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.add-card{ display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; border-style:dashed; color:var(--text-dim); min-height:130px; cursor:pointer; transition:all .15s ease; }
.add-card:hover{ border-color:var(--text-faint); }
.add-card svg{ width:20px; height:20px; margin-bottom:8px; color:var(--text-faint); }

.result-pill{ display:inline-flex; align-items:center; gap:6px; font-size:11.5px; font-weight:700; padding:4px 10px; border-radius:100px; }
.result-pill.ok{ background:var(--success-soft); color:var(--success); }
.result-pill.warn{ background:var(--warn-soft); color:var(--warn); }
.result-pill.danger{ background:var(--danger-soft); color:var(--danger); }
.result-pill.none{ background:var(--border-soft); color:var(--text-faint); }

/* ---------- Modal ---------- */
.modal-overlay{ display:none; position:fixed; inset:0; background:rgba(0,0,0,.55); align-items:center; justify-content:center; z-index:50; padding:20px; overflow-y:auto; }
.modal-overlay.active{ display:flex; }
.modal{ background:var(--surface); border:1px solid var(--border); border-radius:16px; padding:24px; max-width:560px; width:100%; max-height:88vh; overflow-y:auto; position:relative; margin:auto; }
.modal h3{ margin:0 0 6px; font-size:16px; }
.modal p.desc{ font-size:12.5px; color:var(--text-dim); margin:0 0 16px; }
.modal .field{ margin-bottom:14px; }
.modal .field-row{ display:flex; gap:10px; }
.modal .field-row .field{ flex:1; }
.modal label{ font-size:12px; font-weight:600; color:var(--text-dim); display:block; margin-bottom:6px; }
.modal input[type="text"], .modal input[type="password"], .modal input[type="email"], .modal input[type="time"], .modal input[type="number"], .modal select, .modal textarea{
  width:100%; background:var(--bg-elevated); border:1px solid var(--border); color:var(--text); font-size:13px; padding:9px 11px; border-radius:8px; font-family:inherit;
}
.modal textarea{ min-height:80px; resize:vertical; font-family:'IBM Plex Mono',monospace; font-size:12px; }
.modal-close{ position:absolute; top:16px; right:16px; }
.modal-actions{ display:flex; justify-content:flex-end; gap:10px; margin-top:18px; }
.radio-group{ display:flex; gap:8px; }
.radio-btn{ flex:1; padding:9px; border-radius:8px; border:1px solid var(--border); background:var(--bg-elevated); color:var(--text-dim); font-size:12.5px; font-weight:600; text-align:center; cursor:pointer; }
.radio-btn.active{ border-color:var(--accent); color:var(--accent-text); background:var(--accent-soft); }
.hidden{ display:none !important; }

.metric-row{ display:grid; grid-template-columns:1.2fr 0.9fr 1fr 0.7fr auto; gap:8px; margin-bottom:8px; align-items:center; }
.metric-legend{ font-size:11px; color:var(--text-faint); margin:-2px 0 8px; line-height:1.5; }
.hint{ font-size:11.5px; color:var(--text-faint); line-height:1.5; margin:0 0 14px; }
.muted{ color:var(--text-faint); font-weight:400; }
.metric-row input, .metric-row select{ width:100%; }
.metric-row-head span{ font-size:10px; text-transform:uppercase; letter-spacing:.04em; color:var(--text-faint); font-weight:600; }
.metric-row .remove-metric{ color:var(--text-faint); background:none; border:none; cursor:pointer; padding:4px; }
.metric-row .remove-metric:hover{ color:var(--danger); }
.mon-email-row{ display:flex; gap:8px; align-items:center; margin-bottom:8px; }
.mon-email-row input{ flex:1; }
.mon-email-row .remove-metric{ color:var(--text-faint); background:none; border:none; cursor:pointer; padding:4px; font-size:16px; line-height:1; }
.mon-email-row .remove-metric:hover{ color:var(--danger); }
.inspection-result{ background:var(--bg-elevated); border:1px solid var(--border); border-radius:10px; padding:12px 14px; font-size:12px; color:var(--text-dim); margin-top:10px; line-height:1.6; max-height:180px; overflow-y:auto; }
.inspection-result b{ color:var(--text); }

/* ---------- Resultado ---------- */
#resultPanel{ display:none; }
#resultPanel.active{ display:block; }
.result-periodo{ display:inline-block; font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:.04em; color:var(--text-dim); background:var(--border-soft); border-radius:100px; padding:4px 11px; margin-bottom:14px; }
.result-summary{ font-size:13.5px; color:var(--text); line-height:1.6; margin-bottom:18px; }
.anomaly-card{ background:var(--bg-elevated); border:1px solid var(--border); border-left:3px solid var(--border); border-radius:10px; padding:14px 16px; margin-bottom:12px; }
.anomaly-card.critico{ border-left-color:var(--danger); }
.anomaly-card.atencao{ border-left-color:var(--warn); }
.anomaly-card .head{ display:flex; justify-content:space-between; align-items:flex-start; gap:10px; margin-bottom:6px; flex-wrap:wrap; }
.anomaly-card .head strong{ font-size:13.5px; }
.anomaly-card .stats{ font-size:11.5px; color:var(--text-faint); font-family:'IBM Plex Mono',monospace; }
.anomaly-card .explicacao{ font-size:12.5px; color:var(--text-dim); margin:6px 0; }
.anomaly-card .recomendacao{ font-size:12px; color:var(--text-faint); font-style:italic; }

.provider-row{ display:flex; align-items:center; gap:10px; margin:14px 0; flex-wrap:wrap; }
.provider-label{ font-size:12px; color:var(--text-dim); font-weight:600; }
.provider-toggle{ display:flex; gap:8px; }
.provider-btn{ padding:7px 14px; border-radius:8px; border:1px solid var(--border); background:var(--bg-elevated); color:var(--text-dim); font-size:12.5px; font-weight:600; cursor:pointer; transition:all .15s ease; }
.provider-btn.active{ border-color:var(--accent); color:var(--accent-text); background:var(--accent-soft); }
.gemini-warning{ background:var(--warn-soft); border:1px solid var(--warn); border-radius:10px; padding:12px 14px; font-size:12px; color:var(--text); margin:10px 0; }
.gemini-warning p{ margin:0 0 10px; line-height:1.5; }
.gemini-warning strong{ color:var(--warn); }
.gemini-warning .checkbox-line{ display:flex; align-items:center; gap:8px; font-weight:600; color:var(--text); }
.gemini-warning .checkbox-line input{ width:15px; height:15px; }

#loading{ display:none; align-items:center; gap:12px; padding:22px; justify-content:center; color:var(--text-dim); font-size:13px; }
#loading.active{ display:flex; }
.spinner{ width:20px; height:20px; border:2.5px solid var(--border); border-top-color:var(--accent); border-radius:50%; animation:spin .8s linear infinite; }
@keyframes spin{ to{ transform:rotate(360deg); } }
#errorBox{ display:none; background:var(--warn-soft); border:1px solid var(--warn); color:var(--warn); padding:14px 16px; border-radius:10px; font-size:13px; margin-bottom:20px; white-space:pre-line; }
#errorBox.active{ display:block; }

footer.foot{ margin-top:50px; padding-top:18px; border-top:1px solid var(--border-soft); display:flex; justify-content:space-between; flex-wrap:wrap; gap:8px; font-size:11px; color:var(--text-faint); }

@media (max-width: 720px){
  .card-grid{ grid-template-columns:1fr 1fr; }
  .metric-row{ grid-template-columns:1fr; }
  .metric-row-head{ display:none; }
}
