@font-face {
  font-family: "Space Grotesk";
  src: url("/static/fonts/space-grotesk.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "Onest";
  src: url("/static/fonts/onest.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --grafite: #181a1b;
  --grafite-2: #232627;
  --branco: #ffffff;
  --lima: #dff53d;
  --lima-forte: #d3ea2b;
  --papel: #f9f8f3;
  --superficie: #edebe2;
  --linha: rgba(24, 26, 27, 0.12);
  --texto: #181a1b;
  --texto-2: rgba(24, 26, 27, 0.62);
  --ok: #1d7f48;
  --atencao: #a86a0a;
  --erro: #b93226;

  --titulo: "Space Grotesk", system-ui, sans-serif;
  --corpo: "Onest", system-ui, sans-serif;
  --codigo: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --raio: 8px;
  --trilho: 224px;
  --rapido: 140ms;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--corpo);
  font-size: 15px;
  line-height: 1.45;
  color: var(--texto);
  background: var(--papel);
}

h1,
h2,
h3 {
  font-family: var(--titulo);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.1;
}

h2 {
  font-size: 19px;
}

p {
  margin: 0;
}

a {
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--grafite);
  outline-offset: 2px;
}

.ic {
  width: 18px;
  height: 18px;
  flex: none;
}

[hidden] {
  display: none !important;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Estrutura: trilho escuro à esquerda, conteúdo no papel */

.app {
  display: grid;
  grid-template-columns: var(--trilho) minmax(0, 1fr);
  min-height: 100vh;
}

.trilho {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 26px 14px 18px;
  background: var(--grafite);
  color: var(--branco);
}

.trilho :focus-visible {
  outline-color: var(--lima);
}

.trilho-logo {
  display: block;
  padding: 0 10px;
  margin-bottom: 34px;
}

.trilho-logo img {
  display: block;
  width: 96px;
  height: auto;
}

.trilho nav {
  display: grid;
  gap: 2px;
}

.trilho nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.66);
  transition: color var(--rapido), background-color var(--rapido);
}

.trilho nav a:hover {
  color: var(--branco);
  background: var(--grafite-2);
}

.trilho nav a[aria-current="page"] {
  color: var(--branco);
  background: var(--grafite-2);
}

.trilho nav a[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--lima);
}

.trilho-pe {
  margin-top: auto;
  padding: 14px 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.trilho-pe span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trilho-pe button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: rgba(255, 255, 255, 0.66);
}

.trilho-pe button:hover {
  color: var(--branco);
  background: var(--grafite-2);
}

.conteudo {
  padding: 40px clamp(20px, 4vw, 56px) 120px;
  max-width: 1180px;
  width: 100%;
}

.cabeca {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin-bottom: 24px;
}

.cabeca p {
  color: var(--texto-2);
}

/* Medidores da máquina: um painel só, três colunas separadas por linha */

.medidores {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  background: var(--branco);
  border: 1px solid var(--linha);
  border-radius: var(--raio);
}

.medidor {
  padding: 20px 22px 22px;
}

.medidor + .medidor {
  border-left: 1px solid var(--linha);
}

.medidor-nome {
  color: var(--texto-2);
}

.medidor-valor {
  font-family: var(--titulo);
  font-size: 34px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 4px 0 2px;
  font-variant-numeric: tabular-nums;
}

.medidor-detalhe {
  color: var(--texto-2);
  font-variant-numeric: tabular-nums;
}

.barra {
  height: 6px;
  margin-top: 14px;
  background: var(--superficie);
  border-radius: 3px;
  overflow: hidden;
}

.barra i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--grafite);
  transform-origin: left;
  transform: scaleX(var(--parte, 0));
  transition: transform 400ms ease-out;
}

.barra[data-nivel="alto"] i {
  background: var(--atencao);
}

.barra[data-nivel="critico"] i {
  background: var(--erro);
}

/* Apps */

.secao-titulo {
  margin: 40px 0 14px;
}

.apps {
  display: grid;
  gap: 12px;
}

.app-item {
  background: var(--branco);
  border: 1px solid var(--linha);
  border-radius: var(--raio);
}

.app-topo {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding: 16px 18px 16px 22px;
}

.app-nome {
  min-width: 180px;
  flex: 1 1 220px;
}

.app-nome h3 {
  font-size: 18px;
}

.app-links {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  margin-top: 2px;
  color: var(--texto-2);
  font-size: 14px;
}

.app-links a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration-color: var(--linha);
  text-underline-offset: 3px;
}

.app-links a:hover {
  color: var(--texto);
  text-decoration-color: currentColor;
}

.app-links .ic {
  width: 14px;
  height: 14px;
}

.estado {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 150px;
}

.estado::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(24, 26, 27, 0.3);
}

.estado[data-estado="rodando"]::before {
  background: var(--ok);
}

.estado[data-estado="parcial"]::before {
  background: var(--atencao);
}

.estado[data-estado="parado"]::before {
  background: var(--erro);
}

.consumo {
  min-width: 150px;
  color: var(--texto-2);
  font-variant-numeric: tabular-nums;
}

.acoes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.botao {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--linha);
  border-radius: 6px;
  background: var(--branco);
  transition: background-color var(--rapido), border-color var(--rapido);
}

.botao:hover:not(:disabled) {
  background: var(--papel);
  border-color: rgba(24, 26, 27, 0.3);
}

.botao:active:not(:disabled) {
  background: var(--superficie);
}

.botao:disabled {
  opacity: 0.45;
  cursor: default;
}

.botao-escuro {
  background: var(--grafite);
  border-color: var(--grafite);
  color: var(--branco);
}

.botao-escuro:hover:not(:disabled) {
  background: #2c3031;
  border-color: #2c3031;
}

.botao-perigo {
  background: var(--erro);
  border-color: var(--erro);
  color: var(--branco);
}

.botao-perigo:hover:not(:disabled) {
  background: #a02a20;
  border-color: #a02a20;
}

.app-nota {
  padding: 0 22px 14px;
  margin-top: -6px;
  color: var(--texto-2);
  font-size: 14px;
}

.tabela {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.tabela th {
  text-align: left;
  font-weight: 400;
  color: var(--texto-2);
}

.tabela th,
.tabela td {
  padding: 9px 12px;
  border-top: 1px solid var(--linha);
  vertical-align: middle;
}

.tabela th:first-child,
.tabela td:first-child {
  padding-left: 22px;
}

.tabela th:last-child,
.tabela td:last-child {
  padding-right: 18px;
}

.tabela-containers {
  table-layout: fixed;
}

.tabela-containers th:nth-child(1) {
  width: 26%;
}

.tabela-containers th:nth-child(3) {
  width: 24%;
}

.tabela-containers th:nth-child(4) {
  width: 9%;
}

.tabela-containers th:nth-child(5) {
  width: 11%;
}

.tabela-containers th:nth-child(6) {
  width: 116px;
}

.tabela-containers td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabela-containers td:last-child {
  overflow: visible;
}

.tabela-containers .quebra {
  word-break: normal;
}

.tabela .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tabela .fim {
  text-align: right;
  white-space: nowrap;
}

.tabela .quebra {
  word-break: break-all;
  color: var(--texto-2);
}

.botao-linha {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  text-decoration: underline;
  text-decoration-color: var(--linha);
  text-underline-offset: 3px;
}

.botao-linha:hover {
  background: var(--papel);
  text-decoration-color: currentColor;
}

.certificados {
  padding: 10px 22px 14px;
  border-top: 1px solid var(--linha);
  color: var(--texto-2);
  font-size: 14px;
}

.certificados .ruim {
  color: var(--erro);
}

.vazio {
  padding: 28px 22px;
  background: var(--branco);
  border: 1px solid var(--linha);
  border-radius: var(--raio);
  color: var(--texto-2);
}

/* Histórico */

.painel {
  background: var(--branco);
  border: 1px solid var(--linha);
  border-radius: var(--raio);
  overflow-x: auto;
}

.painel .tabela tr:first-child th {
  border-top: 0;
}

.falhou {
  color: var(--erro);
}

.detalhe {
  display: block;
  margin-top: 4px;
  max-width: 70ch;
  white-space: pre-wrap;
  font-family: var(--codigo);
  font-size: 12px;
  color: var(--texto-2);
}

/* Logs: gaveta escura presa ao pé da tela */

.gaveta {
  position: fixed;
  left: var(--trilho);
  right: 0;
  bottom: 0;
  height: min(46vh, 520px);
  display: flex;
  flex-direction: column;
  background: var(--grafite);
  color: var(--branco);
  border-top: 3px solid var(--lima);
  z-index: 5;
}

.gaveta :focus-visible {
  outline-color: var(--lima);
}

.gaveta-topo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px 10px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.gaveta-topo h2 {
  font-size: 15px;
  font-family: var(--corpo);
  font-weight: 500;
  letter-spacing: 0;
}

.gaveta-topo span {
  color: rgba(255, 255, 255, 0.6);
  font-weight: 400;
}

.gaveta-topo button {
  display: inline-flex;
  padding: 6px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: rgba(255, 255, 255, 0.7);
}

.gaveta-topo button:hover {
  color: var(--branco);
  background: var(--grafite-2);
}

.gaveta pre {
  flex: 1;
  margin: 0;
  padding: 12px 20px 18px;
  overflow: auto;
  font-family: var(--codigo);
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: rgba(255, 255, 255, 0.86);
}

/* Diálogo de confirmação e resultado */

dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 24px;
  border: 0;
  border-radius: 10px;
  background: var(--branco);
  color: var(--texto);
  box-shadow: 0 24px 60px rgba(24, 26, 27, 0.28);
}

dialog::backdrop {
  background: rgba(24, 26, 27, 0.5);
}

dialog h2 {
  margin-bottom: 8px;
}

dialog p {
  color: var(--texto-2);
}

dialog pre {
  max-height: 260px;
  margin: 14px 0 0;
  padding: 12px;
  overflow: auto;
  background: var(--papel);
  border: 1px solid var(--linha);
  border-radius: 6px;
  font-family: var(--codigo);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.dialogo-acoes {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
}

.aviso {
  position: fixed;
  left: calc(var(--trilho) + 24px);
  bottom: 24px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 6px;
  background: var(--grafite);
  color: var(--branco);
  box-shadow: 0 10px 30px rgba(24, 26, 27, 0.25);
}

.aviso .ic {
  color: var(--lima);
}

/* Telas de entrada: fundo grafite, cartão claro */

.porta {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--grafite);
}

.porta-caixa {
  width: min(400px, 100%);
}

.porta-caixa > img {
  display: block;
  width: 118px;
  height: auto;
  margin-bottom: 44px;
}

.porta-caixa h1 {
  color: var(--branco);
  font-size: 34px;
  margin-bottom: 10px;
}

.porta-caixa p {
  color: rgba(255, 255, 255, 0.66);
  margin-bottom: 30px;
}

.porta :focus-visible {
  outline-color: var(--branco);
}

.botao-lima {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 50px;
  border: 0;
  border-radius: 8px;
  background: var(--lima);
  color: var(--grafite);
  font-family: var(--titulo);
  font-size: 17px;
  font-weight: 500;
  transition: background-color var(--rapido);
}

.botao-lima:hover:not(:disabled) {
  background: var(--lima-forte);
}

.botao-lima:disabled {
  opacity: 0.6;
  cursor: default;
}

.botao-lima .ic {
  width: 22px;
  height: 22px;
}

.porta-erro {
  margin: 18px 0 0 !important;
  color: #ffb4a8 !important;
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
  }

  .trilho {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
  }

  .trilho-logo {
    margin: 0;
    padding: 0 4px;
  }

  .trilho nav {
    display: flex;
    flex: 1;
  }

  .trilho nav a[aria-current="page"]::before {
    left: 10px;
    right: 10px;
    top: auto;
    bottom: 2px;
    width: auto;
    height: 3px;
  }

  .trilho-pe {
    margin: 0;
    padding: 0;
    border: 0;
  }

  .trilho-pe span {
    display: none;
  }

  .conteudo {
    padding-top: 26px;
  }

  .medidores {
    grid-template-columns: 1fr;
  }

  .medidor + .medidor {
    border-left: 0;
    border-top: 1px solid var(--linha);
  }

  .gaveta {
    left: 0;
  }

  .aviso {
    left: 16px;
  }

  .acoes {
    margin-left: 0;
  }

  .tabela .some {
    display: none;
  }

  .tabela-containers {
    table-layout: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
