@font-face {
  font-family: "IBM Plex Sans";
  src: url("./fonts/ibm-plex-sans-latin-variable.woff2") format("woff2");
  font-weight: 100 700;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("./fonts/ibm-plex-mono-latin-400.woff2") format("woff2");
  font-display: swap;
}

:root {
  color-scheme: dark;
  --void: #070b0e;
  --panel: #0d1418;
  --panel-up: #131c21;
  --line: #1f2d33;
  --line-up: #33464e;
  --ink: #e8f0f1;
  --ink-soft: #a3b6bc;
  --ink-faint: #7f949b;
  --signal: #4fd6c8;
  --signal-ink: #04201d;
  --danger: #ff9d8a;
  --ease: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(1100px 520px at 72% -12%, rgb(79 214 200 / 7%), transparent 70%),
    var(--void);
  color: var(--ink);
  font: 14px/1.45 "IBM Plex Sans", "Segoe UI", sans-serif;
}
::selection { background: rgb(79 214 200 / 32%); }
* { scrollbar-color: var(--line-up) transparent; scrollbar-width: thin; }
.defs { position: absolute; }
h1, h2, h3, p { margin: 0; }
.muted { color: var(--ink-soft); }
.grow { flex: 1; }

.icon {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentcolor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

.shell { display: grid; grid-template-columns: 88px minmax(0, 1fr); height: 100%; }

.rail {
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
  padding: 18px 8px;
  border-right: 1px solid var(--line);
  background: rgb(7 11 14 / 70%);
}
.mark { display: block; width: 32px; height: auto; object-fit: contain; filter: drop-shadow(0 2px 10px rgb(48 160 255 / 45%)); }
.nav { display: grid; gap: 4px; width: 100%; }
.nav button {
  display: grid;
  justify-items: center;
  gap: 3px;
  width: 100%;
  padding: 9px 2px 7px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-faint);
  font: 500 10.5px/1.1 inherit;
  font-family: inherit;
  cursor: pointer;
  transition: color .2s, background-color .2s;
}
.nav button:hover { background: var(--panel); color: var(--ink); }
.nav button[aria-current="page"] { background: var(--panel-up); color: var(--signal); }

.stage { display: flex; flex-direction: column; min-width: 0; height: 100%; }

.bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: flex-end;
  justify-content: space-between;
  padding: 16px 24px 14px;
}
.brand h1 { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.brand p { color: var(--ink-soft); font-size: 13px; font-variant-numeric: tabular-nums; }
.tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.field { display: grid; gap: 3px; color: var(--ink-faint); font-size: 11.5px; }
select, input {
  min-height: 34px;
  padding: 4px 8px;
  border: 1px solid var(--line-up);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font: 13px/1.3 inherit;
  font-family: inherit;
}
select:hover, input:hover { border-color: var(--ink-faint); }
input::placeholder { color: var(--ink-faint); }

button { font-family: inherit; }
.primary, .quiet {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 4px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color .2s, border-color .2s, transform .2s var(--ease);
}
.primary { border: 1px solid var(--signal); background: var(--signal); color: var(--signal-ink); }
.primary:hover { background: #7be6da; }
.primary:active, .quiet:active { transform: translateY(1px); }
.primary.running { background: transparent; color: var(--signal); font-variant-numeric: tabular-nums; }
.quiet { border: 1px solid var(--line-up); background: transparent; color: var(--ink); text-decoration: none; }
.quiet:hover { border-color: var(--ink-faint); background: var(--panel-up); }
.quiet[aria-disabled="true"] { opacity: .45; pointer-events: none; }
button:disabled { opacity: .45; cursor: not-allowed; }
.link { padding: 2px 0; border: 0; background: none; color: var(--ink-soft); font-size: 12.5px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link:hover { color: var(--ink); }
.icon-button { display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-soft); cursor: pointer; }
.icon-button:hover { background: var(--panel-up); color: var(--ink); }

.scan { position: relative; flex: none; height: 2px; overflow: hidden; background: var(--line); }
.scan::after {
  position: absolute;
  inset: 0;
  width: 34%;
  background: linear-gradient(90deg, transparent, var(--signal), transparent);
  content: "";
  animation: sweep 1.5s var(--ease) infinite;
}
@keyframes sweep { from { transform: translateX(-110%); } to { transform: translateX(310%); } }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 0 24px 10px; color: var(--ink-faint); font-size: 12px; }
.chip {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 26px;
  padding: 2px 6px 2px 10px;
  border: 1px solid var(--signal);
  border-radius: 13px;
  background: rgb(79 214 200 / 9%);
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
}
.chip .icon { width: 13px; height: 13px; }
.alert { margin: 0 24px 10px; padding: 8px 12px; border: 1px solid var(--danger); border-radius: 6px; color: var(--danger); font-size: 13px; }

main { flex: 1; min-height: 0; padding: 4px 24px 24px; overflow-y: auto; outline: none; }
.entering { animation: rise .45s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.band {
  display: grid;
  grid-template-columns: minmax(200px, 1.5fr) repeat(auto-fit, minmax(130px, 1fr));
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 12px 34px rgb(0 0 0 / 28%);
}
.metric { min-width: 0; padding: 14px 18px; border-left: 1px solid var(--line); }
.metric:first-child { border-left: 0; }
.metric strong { display: block; font-size: 30px; font-weight: 600; line-height: 1.15; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.metric:first-child strong { font-size: 46px; color: var(--signal); text-shadow: 0 3px 22px rgb(79 214 200 / 32%); }
.metric span { color: var(--ink-soft); font-size: 12.5px; }
.metric small { display: block; color: var(--ink-faint); font-size: 11.5px; font-variant-numeric: tabular-nums; }
button.metric { width: 100%; border-top: 0; border-right: 0; border-bottom: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
button.metric:hover { background: var(--panel-up); }

.board { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.panel {
  grid-column: span 6;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.panel.w4 { grid-column: span 4; }
.panel.w5 { grid-column: span 5; }
.panel.w7 { grid-column: span 7; }
.panel.w8 { grid-column: span 8; }
.panel.w12 { grid-column: span 12; }
.panel h2 { margin-bottom: 8px; font-size: 13.5px; font-weight: 600; }
.panel .hint { margin: -4px 0 8px; color: var(--ink-faint); font-size: 12px; }
.chart { width: 100%; height: 280px; }
.chart.tall { height: 420px; }
.chart.short { height: 200px; }

.empty {
  display: grid;
  gap: 14px;
  justify-items: start;
  max-width: 520px;
  margin: 12vh auto 0;
}
.empty h2 { font-size: 26px; font-weight: 600; letter-spacing: -.01em; }
.empty p { color: var(--ink-soft); }
.none { padding: 40px 12px; color: var(--ink-faint); font-size: 13px; text-align: center; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 12px; }
.toolbar .note { margin-left: auto; color: var(--ink-soft); font-size: 12.5px; font-variant-numeric: tabular-nums; }
input[type="search"] { width: min(320px, 100%); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; background: var(--panel); color: var(--ink-faint); font-weight: 500; }
tbody tr:hover { background: var(--panel-up); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono { font-family: "IBM Plex Mono", monospace; font-size: 12px; }
td.wide { max-width: 340px; overflow: hidden; text-overflow: ellipsis; }

.drawer {
  position: fixed;
  z-index: 20;
  inset: 0 0 0 auto;
  width: min(400px, 100%);
  padding: 18px 20px;
  overflow-y: auto;
  border-left: 1px solid var(--line-up);
  background: var(--panel);
  box-shadow: -18px 0 50px rgb(0 0 0 / 50%);
  animation: slide .35s var(--ease);
}
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer h2 { font-size: 16px; font-weight: 600; }
.drawer-head + p { margin: 4px 0 14px; font-size: 12.5px; }
.report { display: grid; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); }
.report h3 { font-size: 13.5px; font-weight: 600; }
.report p { color: var(--ink-faint); font-size: 12.5px; }
.report div { display: flex; gap: 6px; }

.login { width: min(420px, calc(100% - 32px)); padding: 22px; border: 1px solid var(--line-up); border-radius: 12px; background: var(--panel); color: var(--ink); box-shadow: 0 24px 70px rgb(0 0 0 / 60%); }
.login::backdrop { background: rgb(4 7 9 / 72%); backdrop-filter: blur(3px); }
.login-logo { justify-self: center; width: 96px; height: auto; }
.login h2 { font-size: 17px; font-weight: 600; }
.login form { display: grid; gap: 12px; }
.stack { display: grid; gap: 4px; color: var(--ink-soft); font-size: 12.5px; }
.stack input { width: 100%; }
#login-code { font-family: "IBM Plex Mono", monospace; font-size: 22px; letter-spacing: .2em; text-align: center; }
.check { display: flex; gap: 8px; align-items: center; margin-top: 8px; color: var(--ink-soft); font-size: 12.5px; }
.check input { min-height: 0; }
.form-error { color: var(--danger); font-size: 13px; }
.login-actions { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }

@media (max-width: 1100px) {
  .panel, .panel.w4, .panel.w5, .panel.w7, .panel.w8 { grid-column: span 12; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Widget: abas no topo no lugar da barra lateral, e painéis que cabem em áreas estreitas. */
.shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
.rail { flex-direction: row; gap: 10px; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.nav { display: flex; gap: 4px; width: auto; }
.nav button { flex: none; grid-auto-flow: column; width: auto; padding: 6px 12px; }
.mark { width: 24px; flex: none; }
.bar { padding: 12px 16px 10px; }
.stage { overflow-y: auto; }
.tenant-tag { color: var(--ink-soft); font-size: 12.5px; }
.history { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12.5px; }
.history button { margin-top: 8px; }
.preview { position: fixed; inset: 0; z-index: 30; display: grid; grid-template-rows: auto minmax(0, 1fr); background: var(--void); }
.preview[hidden] { display: none; }
.preview-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.preview-bar h2 { font-size: 15px; font-weight: 600; }
.preview iframe { width: 100%; height: 100%; border: 0; background: #fff; }
@media (max-width: 640px) {
  .panel, .panel.w4, .panel.w5, .panel.w7, .panel.w8 { grid-column: span 12; }
  .chart { height: 240px; }
  .tools { width: 100%; }
}

/* Tema claro: troca as variáveis e os poucos valores fixos do tema escuro. */
:root[data-theme="light"] {
  color-scheme: light;
  --void: #eef3f5;
  --panel: #ffffff;
  --panel-up: #f3f7f8;
  --line: #dfe7ea;
  --line-up: #b8c7cc;
  --ink: #16262b;
  --ink-soft: #4b6169;
  --ink-faint: #5f747b;
  --signal: #0b7f76;
  --signal-ink: #ffffff;
  --danger: #b3321b;
}
:root[data-theme="light"] body { background: var(--void); }
:root[data-theme="light"] ::selection { background: rgb(11 127 118 / 25%); }
:root[data-theme="light"] .rail { background: rgb(255 255 255 / 85%); }
:root[data-theme="light"] .primary:hover { background: #0a6e66; }
:root[data-theme="light"] .metric:first-child strong { text-shadow: none; }
:root[data-theme="light"] .band, :root[data-theme="light"] .panel { box-shadow: 0 2px 10px rgb(22 38 43 / 8%); }
:root[data-theme="light"] .drawer { box-shadow: -10px 0 30px rgb(22 38 43 / 18%); }
