:root{
  color-scheme: dark;
  /* -- Surfaces / plane -- */
  --page-plane:      #060f1e;
  --surface-1:       #0f2340;
  --surface-2:       #122a4c;
  --surface-glow:     radial-gradient(circle at 15% 10%, rgba(41,89,153,0.35), transparent 55%),
                      radial-gradient(circle at 85% 90%, rgba(217,44,34,0.07), transparent 45%);
  --border-hairline: rgba(255,255,255,0.09);
  --border-brand:    rgba(101,147,226,0.35);

  /* -- Ink -- */
  --text-primary:    #ffffff;
  --text-secondary:  #b9c4d6;
  --text-muted:      #6f83a3;
  --gridline:        #1c3355;
  --baseline:        #2a4570;

  /* -- Brand accents (from the GOBMINAS emblem: navy blue, white, red, silver) -- */
  --brand:           #5b8def;   /* institutional blue — borders, icons, structure */
  --brand-bright:    #8fb8f2;   /* lighter tint — headline numbers, clock */
  --red-accent:      #e5382c;   /* emblem red — used sparingly */
  --silver:          #c7cdd6;

  /* -- Graus (ordinal blue ramp — the emblem's compass/square blue, validated: dark, surface #0f2340) -- */
  --grau-aprendiz:   #1f4fa3;
  --grau-companheiro:#316ed8;
  --grau-mestre:     #6593e2;
  --grau-instalado:  #98b7eb;

  /* -- Ritos (ordinal silver ramp — the emblem's flag silver, validated: dark, surface #0f2340) -- */
  --rito-1: #4b5363;
  --rito-2: #636e83;
  --rito-3: #7c889c;
  --rito-4: #99a2b2;
  --rito-5: #b3bac6;
  --rito-6: #cbcfd8;
  --rito-7: #e5e7eb;

  /* -- Status (fixed, reserved meaning — never reused as series identity) -- */
  --status-good:        #2fbb72;
  --status-good-bright: #5fd694;
  --status-bad:         var(--red-accent);
  --status-bad-bright:  #ff6259;
}

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

html, body{
  width:100%; height:100%;
  overflow:hidden;
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body{
  background-image: var(--surface-glow);
  background-color: var(--page-plane);
}

.app{
  height:100vh;
  width:100vw;
  display:grid;
  grid-template-rows: auto 1fr 1fr auto;
  gap: 14px;
  padding: 16px 30px 10px;
}

/* ================= HEADER ================= */
.header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 24px;
  background: linear-gradient(180deg, var(--surface-1), var(--surface-2));
  border: 1px solid var(--border-hairline);
  border-top: 3px solid var(--brand);
  border-radius: 14px;
  padding: 11px 28px;
  position: relative;
  overflow:hidden;
}
.header::after{
  content:"";
  position:absolute; inset:0;
  background: linear-gradient(90deg, transparent, rgba(91,141,239,0.08), transparent);
  pointer-events:none;
}

.header-brand{ display:flex; align-items:center; gap:16px; min-width: 340px; }
.logo-wrap{
  width:64px; height:64px;
  border-radius:50%;
  background: radial-gradient(circle at 35% 30%, #1a3a66, #0a1830);
  border: 2px solid var(--brand);
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0;
  box-shadow: 0 0 18px rgba(91,141,239,0.3);
  overflow:hidden;
}
.logo-wrap img{ width:100%; height:100%; object-fit:cover; border-radius:50%; }
.logo-wrap i{ font-size:26px; color: var(--brand); }

.brand-text .brand-title{
  font-size: 26px; font-weight:800; letter-spacing:1.5px; line-height:1;
  color: var(--text-primary);
}
.brand-text .brand-title span{ color: var(--brand); }
.brand-text .brand-sub{
  margin-top:6px; font-size:12.5px; font-weight:600; letter-spacing:0.6px;
  color: var(--text-secondary); text-transform:uppercase;
}

.header-center{
  flex:1;
  text-align:center;
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:4px;
}
.greeting{
  font-size: 22px; font-weight:700; color: var(--text-primary);
}
.greeting .name{ color: var(--brand-bright); }
.header-center .period{
  font-size: 12.5px; font-weight:600; letter-spacing:0.8px; text-transform:uppercase;
  color: var(--text-muted);
  display:flex; align-items:center; gap:8px;
}
.live-dot{
  width:8px; height:8px; border-radius:50%;
  background: var(--red-accent);
  box-shadow: 0 0 8px rgba(194,59,50,0.9);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse{
  0%,100%{ opacity:1; transform:scale(1); }
  50%{ opacity:0.4; transform:scale(0.75); }
}

.header-clock{
  min-width: 260px;
  text-align:right;
}
.clock-time{
  font-size: 34px; font-weight:800; letter-spacing:1px;
  font-variant-numeric: tabular-nums;
  color: var(--brand-bright);
  line-height:1;
}
.clock-date{
  margin-top:6px;
  font-size: 13px; font-weight:600; color: var(--text-secondary);
}

/* ================= MAIN GRID ================= */
.main{
  display:grid;
  grid-template-columns: 300px 1fr 1.15fr;
  gap: 14px;
  min-height:0;
}

.panel{
  background: linear-gradient(160deg, var(--surface-1), var(--surface-2));
  border: 1px solid var(--border-hairline);
  border-radius: 16px;
  padding: 14px 20px;
  display:flex; flex-direction:column;
  min-height:0;
  position:relative;
}
.panel-title{
  display:flex; align-items:center; gap:10px;
  font-size: 14px; font-weight:700; letter-spacing:0.6px; text-transform:uppercase;
  color: var(--text-secondary);
  margin-bottom: 14px;
}
.panel-title i{ color: var(--brand); font-size:15px; }

/* ---- KPI column ---- */
.kpi-col{ display:flex; flex-direction:column; gap:14px; min-height:0; }
.kpi-card{
  flex:1;
  display:flex; flex-direction:column; justify-content:center;
  background: linear-gradient(160deg, var(--surface-1), var(--surface-2));
  border: 1px solid var(--border-hairline);
  border-left: 4px solid var(--brand);
  border-radius: 16px;
  padding: 16px 22px;
  position:relative;
  overflow:hidden;
}
.kpi-card.secondary{ border-left-color: var(--silver); }
.kpi-icon{
  position:absolute; right:16px; top:16px;
  font-size:34px; color: rgba(91,141,239,0.18);
}
.kpi-card.secondary .kpi-icon{ color: rgba(199,205,214,0.16); }
.kpi-label{
  font-size: 13px; font-weight:700; letter-spacing:0.6px; text-transform:uppercase;
  color: var(--text-muted);
}
.kpi-value{
  margin-top:8px;
  font-size: 58px; font-weight:800; line-height:1;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}
.kpi-card.hero .kpi-value{ color: var(--brand-bright); font-size:64px; }
.kpi-foot{
  margin-top:10px; font-size:12px; font-weight:600; color: var(--text-secondary);
  display:flex; align-items:center; gap:6px;
}
.kpi-foot i{ color:#4caf7d; font-size:11px; }

/* ---- Graus panel ---- */
.graus-body{
  flex:1; display:grid; grid-template-columns: 280px 1fr; gap:26px; min-height:0; align-items:stretch;
}
.donut-wrap{ position:relative; height:100%; display:flex; align-items:center; justify-content:center; }
.donut-wrap canvas{ max-height: 100%; }
.donut-center{
  position:absolute; left:50%; top:50%; transform:translate(-50%,-50%);
  text-align:center; pointer-events:none;
}
.donut-center .num{ font-size:38px; font-weight:800; color:var(--text-primary); line-height:1; }
.donut-center .lbl{ font-size:12px; font-weight:700; letter-spacing:0.5px; text-transform:uppercase; color:var(--text-muted); margin-top:6px; }

.grau-list{ display:flex; flex-direction:column; gap:14px; justify-content:space-evenly; height:100%; }
.grau-row{ display:flex; flex-direction:column; gap:8px; }
.grau-row-top{ display:flex; align-items:baseline; justify-content:space-between; gap:10px; }
.grau-name{ display:flex; align-items:center; gap:10px; font-size:16.5px; font-weight:600; color:var(--text-primary); }
.grau-dot{ width:13px; height:13px; border-radius:3px; flex-shrink:0; }
.grau-nums{ display:flex; align-items:baseline; gap:9px; white-space:nowrap; }
.grau-count{ font-size:22px; font-weight:800; color:var(--text-primary); font-variant-numeric:tabular-nums; }
.grau-pct{ font-size:13.5px; font-weight:600; color:var(--text-muted); font-variant-numeric:tabular-nums; }
.grau-track{ height:10px; border-radius:5px; background: rgba(255,255,255,0.06); overflow:hidden; }
.grau-fill{ height:100%; border-radius:5px; width:0%; transition: width 1.1s cubic-bezier(.2,.8,.2,1); }

/* ---- Ritos panel ---- */
.ritos-body{ flex:1; display:flex; flex-direction:column; min-height:0; }
.ritos-chart-wrap{ flex:1; position:relative; min-height:0; }

/* ================= FLUXO DE PROTOCOLOS ================= (métrica crítica — hierarquia elevada) */
/* Alturas em clamp(min, vh, max): escalam com a altura real da viewport (1080p, 4K, ou uma
   janela menor durante o desenvolvimento) em vez de estourar o cartão quando a viewport
   não é exatamente 1080px de altura. */
.flow-panel{
  background: linear-gradient(160deg, var(--surface-1), var(--surface-2));
  border: 1px solid var(--border-hairline);
  border-top: 3px solid var(--status-good);
  border-radius: 16px;
  padding: clamp(12px, 2vh, 20px) 32px clamp(14px, 2.4vh, 24px);
  display:flex; flex-direction:column; gap: clamp(8px, 1.3vh, 14px);
  min-height:0;
}
.flow-head{ display:flex; align-items:center; justify-content:space-between; position:relative; }
.flow-head .panel-title{ margin-bottom:0; font-size:19px; letter-spacing:0.8px; }
.flow-head .panel-title i{ font-size:19px; }
.flow-period{
  position:absolute; left:50%; top:50%; transform:translate(-50%,-50%);
  display:flex; align-items:center; gap:9px;
  font-size: 15px; font-weight:700; color: var(--text-secondary);
  white-space:nowrap;
}
.flow-period i{ color: var(--brand); font-size:14px; }

.flow-body{
  flex:1; display:grid; grid-template-columns: 1fr 300px 1fr; gap:28px; align-items:stretch; min-height:0;
}

.flow-card{
  display:flex; flex-direction:column; gap: clamp(8px, 1.6vh, 16px);
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border-hairline);
  border-left: 5px solid var(--status-good);
  border-radius: 12px;
  padding: clamp(12px, 2.5vh, 22px) 28px;
  min-height:0;
  overflow:hidden;
}
.flow-card.out{ border-left-color: var(--status-bad); }

.flow-card-head{
  display:flex; align-items:baseline; gap:12px;
  font-size: 16px; font-weight:700; letter-spacing:0.5px; text-transform:uppercase;
  color: var(--text-muted);
  flex-shrink:0;
}
.flow-card-head strong{ font-size: clamp(32px, 5vh, 50px); font-weight:800; font-variant-numeric:tabular-nums; letter-spacing:-1px; }
.flow-card.in .flow-card-head strong{ color: var(--status-good-bright); }
.flow-card.out .flow-card-head strong{ color: var(--status-bad-bright); }

.flow-list{ display:flex; flex-direction:column; gap: clamp(8px, 1.8vh, 18px); justify-content:space-evenly; flex:1; min-height:0; }
.flow-item{ display:flex; flex-direction:column; gap: clamp(3px, 0.8vh, 8px); }
.flow-item-top{ display:flex; align-items:center; gap:14px; }
.flow-badge{
  width: clamp(22px, 3.2vh, 34px); height: clamp(22px, 3.2vh, 34px); border-radius:50%; flex-shrink:0;
  display:flex; align-items:center; justify-content:center; font-size: clamp(10px, 1.4vh, 15px);
}
.flow-badge.up{ background: rgba(47,187,114,0.18); color: var(--status-good-bright); }
.flow-badge.down{ background: rgba(229,56,44,0.18); color: var(--status-bad-bright); }
.flow-name{ flex:1; font-size: clamp(13px, 1.8vh, 19px); font-weight:600; color: var(--text-primary); }
.flow-value{ font-size: clamp(15px, 2vh, 22px); font-weight:800; color: var(--text-primary); font-variant-numeric:tabular-nums; }
.flow-track{ height: clamp(6px, 1.1vh, 12px); border-radius:6px; background: rgba(255,255,255,0.07); overflow:hidden; }
.flow-fill{ height:100%; border-radius:6px; width:0%; transition: width 1.1s cubic-bezier(.2,.8,.2,1); }
.flow-fill.up{ background: linear-gradient(90deg, var(--status-good), var(--status-good-bright)); }
.flow-fill.down{ background: linear-gradient(90deg, var(--status-bad), var(--status-bad-bright)); }

.flow-balance{
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap: clamp(3px, 0.7vh, 6px);
  text-align:center; padding: clamp(8px, 1.5vh, 14px) 18px;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  overflow:hidden;
}
.flow-balance i{ font-size: clamp(22px, 3.6vh, 38px); color: var(--status-good-bright); }
.flow-balance-label{
  font-size: clamp(11px, 1.4vh, 14.5px); font-weight:700; letter-spacing:0.6px; text-transform:uppercase;
  color: var(--text-muted); margin-top:2px;
}
.flow-balance-value{ font-size: clamp(40px, 7vh, 74px); font-weight:800; color: var(--status-good-bright); line-height:1; letter-spacing:-1.5px; }
.flow-balance.negative i,
.flow-balance.negative .flow-balance-value{ color: var(--status-bad-bright); }
.flow-compare{
  width:100%; height: clamp(8px, 1.4vh, 15px); border-radius:7.5px; overflow:hidden; display:flex; margin-top: clamp(5px, 1vh, 10px);
}
.flow-compare .seg{ height:100%; width:0%; transition: width 1.1s cubic-bezier(.2,.8,.2,1); }
.flow-compare .seg.in{ background: var(--status-good); }
.flow-compare .seg.out{ background: var(--status-bad); }
.flow-balance-caption{ font-size: clamp(11px, 1.3vh, 14px); font-weight:600; color: var(--text-secondary); margin-top: clamp(4px, 0.8vh, 8px); }

/* ================= FOOTER ================= */
.footer{
  display:flex; align-items:center; justify-content:space-between;
  padding: 6px 8px 0;
  font-size: 11.5px; font-weight:600; color: var(--text-muted); letter-spacing:0.4px;
}
.footer .seal{ display:flex; align-items:center; gap:8px; }
.footer .seal i{ color: var(--brand); }
