/* =========================================================================
   EcoConstruct AI — BELLUT
   ========================================================================= */
:root {
  --bg: #0a1220;
  --bg-2: #0f1b2e;
  --panel: #122036;
  --panel-2: #16302700;
  --card: #13223a;
  --card-hover: #1a2c49;
  --line: #294064;
  --text: #eaf1fb;
  --muted: #9bb0cf;
  --faint: #6d83a3;
  --green: #4ade80;
  --green-deep: #22c55e;
  --teal: #2dd4bf;
  --gold: #fbbf24;
  --amber: #fb923c;
  --blue: #60a5fa;
  --danger: #f87171;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 40px -20px rgba(0, 0, 0, 0.7);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(74, 222, 128, 0.12), transparent 60%),
    radial-gradient(900px 500px at -10% 20%, rgba(96, 165, 250, 0.10), transparent 55%),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border-right: 1px solid var(--line);
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 22px; }
.brand .logo {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--teal));
  display: grid; place-items: center;
  box-shadow: 0 8px 22px -8px rgba(74, 222, 128, 0.7);
  border: 1.5px solid rgba(255, 255, 255, 0.18);
}
.brand .logo svg { width: 24px; height: 24px; }
.brand .title { font-weight: 700; font-size: 16px; letter-spacing: 0.2px; }
.brand .sub { font-size: 11px; color: var(--muted); letter-spacing: 2px; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px; border-radius: var(--radius-sm);
  color: var(--muted); cursor: pointer; font-size: 14px; font-weight: 500;
  border: 1px solid transparent;
  transition: background .16s, color .16s, border-color .16s;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .9; }
.nav-item:hover { background: var(--card); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(52,211,153,.16), rgba(45,212,191,.08));
  color: var(--text);
  border-color: var(--line);
}
.nav-item.active svg { color: var(--green); }

.sidebar-foot { margin-top: auto; padding: 14px 10px 0; font-size: 11px; color: var(--faint); }
.sidebar-foot .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; margin-right: 6px; box-shadow: 0 0 8px var(--green); }

/* ---------- Main ---------- */
.main { padding: 26px 34px 60px; overflow-x: hidden; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.topbar h1 { font-size: 23px; font-weight: 700; letter-spacing: .2px; }
.topbar .crumb { font-size: 12px; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 1.5px; }
.topbar .right { display: flex; align-items: center; gap: 14px; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line);
  padding: 9px 13px; border-radius: 999px; min-width: 230px;
}
.search input { background: none; border: none; color: var(--text); outline: none; font-size: 13px; width: 100%; }
.search svg { width: 16px; height: 16px; color: var(--muted); }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--amber), var(--gold));
  display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #20140a;
}

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 18px; }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.span-2 { grid-column: span 2; }

.card {
  background: linear-gradient(180deg, var(--card), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card h3 { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.card .card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card .card-head .hint { font-size: 12px; color: var(--muted); }

/* KPI */
.kpi { position: relative; overflow: hidden; }
.kpi .kpi-ico {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; margin-bottom: 14px;
  background: rgba(52,211,153,.14); color: var(--green);
}
.kpi .kpi-ico svg { width: 20px; height: 20px; }
.kpi .val { font-size: 28px; font-weight: 700; letter-spacing: .3px; }
.kpi .unit { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.kpi .lbl { font-size: 13px; color: var(--muted); margin-top: 4px; }
.kpi .trend { font-size: 12px; margin-top: 10px; display: inline-flex; align-items: center; gap: 5px; color: var(--green); }
.kpi .trend svg { width: 12px; height: 12px; flex-shrink: 0; }
.kpi .trend.down { color: var(--blue); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--faint); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .6px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 11px 10px; border-bottom: 1px solid rgba(35,68,56,.5); }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .14s; }
tbody tr:hover { background: rgba(52,211,153,.05); }
.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; color: var(--teal); }

/* ---------- Badges / tags ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 999px; border: 1px solid transparent; }
.badge svg { width: 11px; height: 11px; flex-shrink: 0; }
.badge.green { background: rgba(52,211,153,.14); color: var(--green); border-color: rgba(52,211,153,.3); }
.badge.amber { background: rgba(244,183,64,.14); color: var(--gold); border-color: rgba(244,183,64,.3); }
.badge.blue { background: rgba(56,189,248,.14); color: var(--blue); border-color: rgba(56,189,248,.3); }
.badge.gray { background: rgba(154,166,178,.12); color: var(--muted); border-color: rgba(154,166,178,.25); }
.badge.red { background: rgba(248,113,113,.14); color: var(--danger); border-color: rgba(248,113,113,.3); }

.tag { font-size: 11px; padding: 3px 9px; border-radius: 7px; background: var(--bg-2); border: 1px solid var(--line); color: var(--muted); }

/* ---------- Project cards ---------- */
.proj-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.proj {
  background: linear-gradient(180deg, var(--card), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  cursor: pointer; transition: transform .16s, border-color .16s, box-shadow .16s;
  display: flex; flex-direction: column; gap: 12px;
}
.proj:hover { transform: translateY(-3px); border-color: var(--green); box-shadow: 0 22px 44px -24px rgba(52,211,153,.5); }
.proj .pid { font-size: 11px; color: var(--faint); font-family: monospace; }
.proj .pname { font-size: 16px; font-weight: 700; }
.ploc { display: flex; align-items: center; gap: 5px; }
.ploc svg { width: 13px; height: 13px; flex-shrink: 0; }
.proj .ploc { font-size: 12px; color: var(--muted); }
.proj .pmeta { display: flex; gap: 16px; margin-top: 4px; }
.proj .pmeta .m .v { font-size: 18px; font-weight: 700; color: var(--green); }
.proj .pmeta .m .k { font-size: 11px; color: var(--muted); }
.proj .pbar { height: 7px; background: var(--bg-2); border-radius: 999px; overflow: hidden; }
.proj .pbar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--teal)); border-radius: 999px; }

/* ---------- Progress / efficiency ring ---------- */
.ring { position: relative; width: 96px; height: 96px; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-val { position: absolute; inset: 0; display: grid; place-items: center; font-size: 20px; font-weight: 700; }

.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.bar-row .bl { width: 150px; font-size: 13px; color: var(--muted); flex-shrink: 0; }
.bar-row .bt { flex: 1; height: 9px; background: var(--bg-2); border-radius: 999px; overflow: hidden; }
.bar-row .bt > span { display: block; height: 100%; border-radius: 999px; }
.bar-row .bv { width: 44px; text-align: right; font-size: 13px; font-weight: 600; }

/* legend */
.legend { display: flex; flex-direction: column; gap: 10px; }
.legend .li { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.legend .li .sw { width: 11px; height: 11px; border-radius: 3px; }
.legend .li .lv { margin-left: auto; font-weight: 600; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  background: linear-gradient(135deg, var(--green-deep), var(--teal));
  color: #04221a; font-weight: 700; font-size: 13px;
  border: none; padding: 10px 16px; border-radius: 10px;
  transition: transform .12s, filter .12s;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn.ghost { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--green); }
.btn:disabled { opacity: .55; cursor: progress; transform: none; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 7px 13px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--card); border: 1px solid var(--line); color: var(--muted); cursor: pointer;
  transition: all .14s;
}
.chip:hover { color: var(--text); border-color: var(--green); }
.chip.active { background: rgba(52,211,153,.16); color: var(--green); border-color: var(--green); }

/* ---------- AI panel ---------- */
.ai-rec { display: flex; flex-direction: column; gap: 12px; }
.rec {
  display: flex; align-items: center; gap: 14px;
  padding: 14px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--line);
}
.rec .ri { width: 38px; height: 38px; border-radius: 10px; background: rgba(56,189,248,.14); color: var(--blue); display: grid; place-items: center; flex-shrink: 0; }
.rec .rt { font-weight: 600; font-size: 14px; }
.rec .rm { font-size: 12px; color: var(--muted); }
.rec .rc { margin-left: auto; text-align: right; }
.rec .rc .pct { font-size: 18px; font-weight: 700; color: var(--green); }
.rec .rc .pl { font-size: 10px; color: var(--faint); text-transform: uppercase; letter-spacing: .5px; }

.ai-console {
  background: #0a1813; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 16px; font-family: "SFMono-Regular", Consolas, monospace; font-size: 12.5px;
  min-height: 180px; max-height: 260px; overflow-y: auto; color: var(--muted);
}
.ai-console .ln { padding: 2px 0; }
.ai-console .ln .t { color: var(--faint); }
.ai-console .ok { color: var(--green); }
.ai-console .hl { color: var(--teal); }
.ai-console .wn { color: var(--gold); }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(4,10,8,.72); backdrop-filter: blur(4px); display: none; place-items: center; z-index: 50; padding: 20px; }
.modal-bg.show { display: grid; }
.modal {
  width: min(720px, 100%); background: linear-gradient(180deg, var(--card), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 26px;
  box-shadow: 0 40px 80px -30px rgba(0,0,0,.8); animation: pop .2s ease;
  max-height: calc(100vh - 40px); overflow-y: auto;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal .mh { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.modal .mclose { cursor: pointer; color: var(--muted); background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; width: 32px; height: 32px; display: grid; place-items: center; }
.modal .mclose:hover { color: var(--text); }

/* ---------- Utilities ---------- */
.section { display: none; animation: fade .25s ease; }
.section.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.muted { color: var(--muted); }
.intro { font-size: 13.5px; color: var(--muted); max-width: 720px; margin-bottom: 22px; }
.flex { display: flex; }
.between { justify-content: space-between; }
.center { align-items: center; }
.gap8 { gap: 8px; } .gap12 { gap: 12px; } .gap16 { gap: 16px; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt22 { margin-top: 22px; }
.right-txt { text-align: right; }
.stars { color: var(--gold); letter-spacing: 1px; }

.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 200px; padding-top: 10px; }
.bar-chart .bc { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bar-chart .bc .bcb { width: 100%; max-width: 34px; background: linear-gradient(180deg, var(--green), var(--green-deep)); border-radius: 7px 7px 0 0; transition: height .6s cubic-bezier(.2,.8,.2,1); position: relative; }
.bar-chart .bc .bcb:hover { filter: brightness(1.15); }
.bar-chart .bc .bcl { font-size: 11px; color: var(--faint); }

.lab-card { display: flex; flex-direction: column; gap: 14px; }
.lab-exp { padding: 16px; border-radius: var(--radius-sm); background: var(--bg-2); border: 1px solid var(--line); }
.lab-exp .leh { display: flex; align-items: center; justify-content: space-between; }
.lab-exp .meter { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; margin-top: 12px; }
.lab-exp .meter > span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--amber)); }

/* ---------- Pesquisa global ---------- */
.search { position: relative; }
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 60;
  background: linear-gradient(180deg, var(--card), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); overflow: hidden; display: none;
}
.search-results.show { display: block; }
.sr-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; cursor: pointer; border-bottom: 1px solid rgba(41,64,100,.4);
}
.sr-item:last-child { border-bottom: none; }
.sr-item:hover { background: rgba(52,211,153,.08); }
.sr-item .sr-l { font-size: 13px; font-weight: 600; }
.sr-item .sr-s { font-size: 11.5px; color: var(--muted); }
.sr-empty { padding: 12px 14px; font-size: 12.5px; color: var(--muted); }

/* ---------- Atividade recente ---------- */
.act-feed { display: flex; flex-direction: column; gap: 4px; }
.act-item { display: flex; gap: 12px; padding: 9px 2px; border-bottom: 1px solid rgba(41,64,100,.35); }
.act-item:last-child { border-bottom: none; }
.act-item .act-ico {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  background: rgba(52,211,153,.12); color: var(--green);
  display: grid; place-items: center;
}
.act-item .act-ico svg { width: 15px; height: 15px; }
.act-item .act-txt { font-size: 12.5px; line-height: 1.45; }
.act-item .act-time { font-size: 11px; color: var(--faint); margin-top: 2px; }

/* ---------- Telemetria do laboratório ---------- */
.spark { display: block; width: 100%; opacity: .9; }

/* ---------- Metadados de fornecedor ---------- */
.sup-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; font-size: 11.5px; padding-top: 4px; }
.sup-meta > div { display: flex; flex-direction: column; gap: 2px; }
.sup-meta strong { font-size: 12.5px; }

/* ---------- Última simulação no modal ---------- */
.sim-last {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--green);
  background: rgba(52,211,153,.08); border: 1px solid rgba(52,211,153,.25);
  border-radius: var(--radius-sm); padding: 9px 12px;
}
.sim-last svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ---------- Visualizador 3D ---------- */
.v3d-wrap {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  overflow: hidden; margin: 14px 0 6px;
}
.v3d-sky { position: relative; height: 250px; background: linear-gradient(180deg, #16304f, #0e1d33); }
.v3d-canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.v3d-hud {
  position: absolute; top: 10px; right: 12px;
  font-size: 11.5px; font-weight: 600; color: var(--text);
  background: rgba(10, 18, 32, .72); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 12px; pointer-events: none;
}
.v3d-hint {
  position: absolute; bottom: 8px; left: 12px;
  font-size: 10.5px; color: var(--faint); pointer-events: none;
}
.v3d-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 14px; background: var(--bg-2); border-top: 1px solid var(--line);
}
.v3d-bar .v3d-lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; flex-shrink: 0; }
.v3d-bar input[type="range"] { flex: 1; accent-color: var(--green); cursor: pointer; }
.v3d-bar .v3d-time { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12.5px; color: var(--teal); width: 42px; text-align: right; }
.v3d-fallback { padding: 22px; font-size: 13px; color: var(--muted); text-align: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 26px; right: 26px; z-index: 80;
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(180deg, var(--card), var(--bg-2));
  border: 1px solid rgba(52,211,153,.4); border-radius: var(--radius-sm);
  color: var(--text); font-size: 13px; font-weight: 600;
  padding: 12px 18px; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(12px); pointer-events: none;
  transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: none; }
.toast svg { width: 16px; height: 16px; color: var(--green); }

@media (max-width: 1100px) {
  .cols-4 { grid-template-columns: repeat(2, 1fr); }
  .cols-3, .proj-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-item span { display: none; }
  .cols-4, .cols-3, .cols-2, .proj-grid, .span-2 { grid-template-columns: 1fr; grid-column: auto; }
  .main { padding: 18px; }
}

/* Extensões da plataforma: mantêm a paleta e os componentes da referência. */
[hidden] { display: none !important; }
.login-screen { min-height:100vh; display:grid; place-items:center; padding:24px; background:radial-gradient(ellipse at 20% 15%,#123a37 0,transparent 48%); }
.login-card { width:min(440px,100%); padding:42px; background:var(--card); border:1px solid var(--line); border-radius:18px; box-shadow:var(--shadow); }
.login-mark { width:54px; height:54px; border-radius:50%; display:grid; place-items:center; background:var(--green); color:#04221a; font-size:34px; margin-bottom:28px; }
.login-card label { display:block; margin:22px 0 8px; color:var(--muted); }
input,select { font:inherit; }
.login-card input,.access-form input,.access-row input[type=datetime-local],select { color:var(--text); background:var(--bg-2); border:1px solid var(--line); border-radius:8px; padding:10px; min-width:0; }
.login-card input { width:100%; box-sizing:border-box; }
.login-card button { width:100%; justify-content:center; margin-top:24px; }
#loginError { color:#fca5a5; font-size:13px; }
#sessionName { width:auto; border-radius:12px; padding:8px; }
.telemetry-controls { display:flex; gap:20px; flex-wrap:wrap; }
.telemetry-controls label { display:flex; gap:10px; align-items:center; color:var(--muted); font-size:13px; }
#telemetrySummary { font-size:12px; margin-top:16px; }
#telemetryChart svg { display:block; width:100%; max-height:180px; }
dialog { width:min(880px,92vw); max-height:85vh; overflow:auto; background:var(--card); color:var(--text); border:1px solid var(--line); border-radius:14px; padding:26px; }
dialog::backdrop { background:#020812bb; backdrop-filter:blur(5px); }
.access-form { display:grid; grid-template-columns:1fr 1fr 1fr; gap:16px; margin:24px 0; }
.access-form label { display:grid; gap:8px; font-size:13px; }
.access-row { display:flex; align-items:center; gap:14px; border-top:1px solid var(--line); padding:14px 0; flex-wrap:wrap; }
:focus-visible { outline:2px solid var(--green); outline-offset:3px; }
@media(max-width:820px){.topbar,.topbar .right{flex-wrap:wrap;gap:12px}.search{min-width:0!important;max-width:100%}.access-form{grid-template-columns:1fr}.card{overflow-x:auto}.telemetry-controls select{max-width:70vw}.login-card{padding:28px}.nav-item{min-height:42px}.nav-item span{display:inline;font-size:11px}}
.nav-item { font:inherit; text-align:left; width:100%; background:transparent; }
@media(max-width:820px){.nav-item{width:auto}}
