/* Camada visual da IHM alinhada ao site institucional TRL7.
   Escopo deliberado: apresentação. Não altera contratos, modelos de dados,
   navegação, semântica de estados nem lógica operacional. */

:root {
  --bg: #f3f6f8;
  --card: #ffffff;
  --soft: #f6f8f9;
  --fg: #12202b;
  --mut: #5e6c77;
  --line: #d8e0e5;
  --line-strong: #bac6ce;
  --navy: #0b1b27;
  --navy-2: #122c3d;
  --orange: #d9682b;
  --orange-dark: #a94817;
  --acc: #d9682b;
  --ok: #237a57;
  --warn: #9b5a18;
  --err: #a43b36;
  --grid: #e3e8eb;
  --shadow: 0 8px 24px rgba(11, 27, 39, .055);
  --display: "Space Grotesk", Inter, system-ui, sans-serif;
}

html, body { background: var(--bg); }
body {
  color: var(--fg);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: -.005em;
}

.app {
  max-width: 1440px;
  padding: 0 22px 52px;
}

/* -------------------------------------------------------------------------
   Cabeçalho — barra de instrumento, sem transformar a tela em landing page.
   ------------------------------------------------------------------------- */
.top {
  margin: 0 -22px;
  padding: 12px 22px;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, .97);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 12px rgba(11, 27, 39, .035);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
}

.top__brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 330px;
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--fg);
  text-decoration: none;
}

.portal-brand__logo {
  width: 44px;
  height: 44px;
  border-radius: 7px;
  object-fit: cover;
  flex: 0 0 auto;
  box-shadow: 0 0 0 1px rgba(11, 27, 39, .08);
}

.portal-brand__copy {
  display: flex;
  flex-direction: column;
  line-height: 1.04;
}

.portal-brand__copy strong {
  font-family: var(--display);
  font-size: 18px;
  letter-spacing: -.02em;
}

.portal-brand__copy small {
  margin-top: 5px;
  color: var(--mut);
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.top__context {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.top__context strong {
  font-family: var(--display);
  font-size: 13px;
  font-weight: 700;
  color: var(--fg);
}

.top__env {
  font-size: 10px;
  color: var(--mut);
  font-weight: 700;
  letter-spacing: .08em;
}

.top__integration {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
}

.top .device { margin-left: 0; }
.top .device__source { max-width: 34ch; }

/* -------------------------------------------------------------------------
   Controles — linguagem de equipamento, não de sistema administrativo.
   ------------------------------------------------------------------------- */
.btn {
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 5px;
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
  font-weight: 750;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.btn:hover {
  filter: none;
  background: var(--navy-2);
  border-color: var(--navy-2);
}

.btn:active { transform: translateY(1px); }

.btn--ghost {
  background: #fff;
  color: var(--fg);
  border-color: var(--line);
}

.btn--ghost:hover {
  background: var(--soft);
  color: var(--fg);
  border-color: var(--line-strong);
}

.top__integration .btn--ghost {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12px;
}

.device__select,
.device__input,
.cred__input,
.filters__select,
.acquisition__input {
  min-height: 38px;
  border-radius: 5px;
  border-color: var(--line-strong);
  background: #fff;
}

.device__select:focus,
.device__input:focus,
.cred__input:focus,
.filters__select:focus,
.acquisition__input:focus {
  outline: 3px solid rgba(217, 104, 43, .14);
  border-color: var(--orange);
}

/* -------------------------------------------------------------------------
   Navegação — console lateral compacta.
   ------------------------------------------------------------------------- */
.layout {
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 28px;
  padding-top: 26px;
}

.nav {
  padding: 4px 0 16px;
}

.nav__group + .nav__group { margin-top: 19px; }

.nav__title {
  margin-bottom: 6px;
  color: #7a8790;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .11em;
}

.nav__link {
  min-height: 38px;
  padding: 9px 11px;
  border-radius: 5px;
  color: #2b3b47;
  font-size: 13px;
}

.nav__link:hover {
  background: #eef2f4;
  color: var(--orange-dark);
}

.nav__link--active {
  background: var(--navy);
  color: #fff;
  font-weight: 750;
  box-shadow: inset 4px 0 0 var(--orange);
}

.nav__link--active:hover {
  background: var(--navy-2);
  color: #fff;
}

.content { padding-bottom: 18px; }

/* -------------------------------------------------------------------------
   Superfícies — os dados passam a morar em módulos de instrumento.
   ------------------------------------------------------------------------- */
.card,
.state,
.spectrum,
.tablewrap {
  border-radius: 7px;
  border-color: var(--line);
  box-shadow: var(--shadow);
}

.card {
  padding: 20px 22px;
  background: #fff;
}

.card__head {
  min-height: 30px;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #edf1f3;
}

.card h3,
.acquisition__panel h3 {
  font-family: var(--display);
  font-size: 17px;
  letter-spacing: -.02em;
}

.card h4,
.quantity h4 {
  color: #5a6872;
  font-size: 10.5px;
  font-weight: 850;
  letter-spacing: .08em;
}

.badge {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .01em;
}

.badge--ok { background: #e6f2ec; color: #176640; }
.badge--warn { background: #fbf0df; color: #8a561d; }
.badge--error { background: #f8e8e7; color: #963630; }

.meta {
  color: #697680;
  gap: 15px;
  margin-bottom: 14px;
}

/* Estado do equipamento: ficha técnica em duas colunas de pares. */
.overview > .card:first-child {
  border-top: 3px solid var(--navy);
}

.overview > .card:first-child .facts {
  grid-template-columns: max-content minmax(120px, 1fr) max-content minmax(120px, 1fr);
  gap: 8px 18px;
  padding: 13px 15px;
  margin: 0;
  background: #f7f9fa;
  border: 1px solid #e7ecef;
  border-radius: 6px;
}

.overview > .card:first-child .facts dt {
  color: #7a8790;
  font-size: 11px;
  font-weight: 700;
}

.overview > .card:first-child .facts dd {
  font-size: 12.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

/* Último PQ: leitura central da tela. */
.overview > .card:nth-child(2) {
  border-top: 3px solid var(--orange);
}

.frequency {
  width: fit-content;
  min-width: 182px;
  display: grid;
  gap: 2px;
  margin: 4px 0 16px;
  padding: 11px 15px 12px;
  background: var(--navy);
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(11, 27, 39, .11);
}

.frequency__label {
  color: #9fb1bc;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .11em;
}

.frequency__value {
  color: #fff;
  font-family: var(--display);
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -.025em;
}

.quantities {
  grid-template-columns: repeat(3, minmax(190px, 1fr));
  gap: 10px;
}

.quantity {
  position: relative;
  overflow: hidden;
  min-height: 88px;
  padding: 12px 13px 13px;
  background: #fff;
  border: 1px solid #e1e7ea;
  border-radius: 6px;
}

.quantity::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #c7d0d6;
}

.quantity:hover { border-color: #cbd5db; }

.phases {
  gap: 12px;
  margin-top: 9px;
}

.phase {
  min-width: 58px;
}

.phase__label {
  font-size: 9.5px;
  letter-spacing: .04em;
}

.phase__value {
  margin-top: 1px;
  color: #0c1821;
  font-family: var(--display);
  font-size: 15px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.unavailable {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px dashed #cbd4da;
  border-radius: 5px;
  background: #fafbfb;
}

.unavailable h4 { color: #71808a; }

.times {
  margin-top: 15px;
  padding: 12px 14px 0;
  border-top: 1px solid var(--line);
}

.times__label {
  color: #71808a;
  font-weight: 650;
}

/* -------------------------------------------------------------------------
   Aquisição — console de ensaio, não formulário administrativo.
   ------------------------------------------------------------------------- */
.acquisition {
  gap: 18px;
}

.acquisition__panel {
  padding: 20px 22px 22px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
}

.acquisition__panel:first-child {
  padding-top: 20px;
  border-top: 3px solid var(--orange);
}

.acquisition__panel + .acquisition__panel {
  border-top: 1px solid var(--line);
}

.acquisition__panel .card__head {
  margin-bottom: 18px;
}

.acquisition__form {
  max-width: none;
  gap: 15px 16px;
  padding: 16px;
  background: #f7f9fa;
  border: 1px solid #e5eaed;
  border-radius: 6px;
}

.acquisition__label {
  color: #687680;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .09em;
}

.acquisition__input {
  padding: 8px 10px;
}

.segmented {
  min-height: 40px;
  border-color: var(--line-strong);
  border-radius: 5px;
  background: #fff;
}

.segmented__option span {
  min-height: 39px;
  display: grid;
  place-items: center;
  padding: 7px 15px;
  background: #fff;
  font-family: var(--display);
  font-weight: 700;
}

.segmented__option input:checked + span {
  background: var(--orange);
  color: #fff;
  font-weight: 750;
}

.acquisition__actions {
  min-height: 40px;
}

.acquisition__actions .btn {
  min-width: 200px;
  min-height: 40px;
  background: var(--navy);
  border-color: var(--navy);
}

.acquisition__actions .btn:disabled {
  opacity: 1;
  background: #7b878f;
  border-color: #7b878f;
  color: #fff;
}

/* Histórico de comandos: necessário, porém deliberadamente secundário. */
.acquisition__panel:nth-child(2) .tablewrap {
  box-shadow: none;
}

.tablewrap {
  overflow-x: auto;
  background: #fff;
}

.table {
  font-size: 11.5px;
}

.table th {
  padding: 8px 10px;
  background: #f0f4f6;
  color: #65737d;
  border-bottom: 1px solid #cfd8de;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .035em;
  text-transform: uppercase;
}

.table td {
  padding: 8px 10px;
  border-bottom-color: #e6ebee;
}

.table tbody tr:hover {
  background: #f7f9fa;
}

.command-id {
  max-width: 19ch;
  color: #6b7881;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 10.5px;
}

.pager .btn {
  background: #fff;
  color: var(--fg);
  border-color: var(--line);
}

/* Filtros e gráficos seguem a mesma linguagem de instrumento. */
.filters {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 13px;
  margin-bottom: 14px;
  box-shadow: 0 4px 16px rgba(11, 27, 39, .03);
}

.chip { border-radius: 999px; }
.chip--on { background: var(--navy); border-color: var(--navy); color: #fff; }

.chart__svg {
  border-radius: 6px;
  border-color: var(--line);
  background: #fff;
}

.qcard {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(11, 27, 39, .03);
}

.qcard__value {
  font-family: var(--display);
  font-size: 22px;
}

/* -------------------------------------------------------------------------
   Responsivo.
   ------------------------------------------------------------------------- */
@media (max-width: 1180px) {
  .top__brand { min-width: 0; }
  .top__integration { order: 4; margin-left: 0; }
  .top .device { margin-left: auto; }
  .layout { grid-template-columns: 190px minmax(0, 1fr); }
  .quantities { grid-template-columns: repeat(2, minmax(190px, 1fr)); }
}

@media (max-width: 900px) {
  .app { padding: 0 14px 40px; }
  .top { margin: 0 -14px; padding: 11px 14px; position: static; }
  .top__brand { width: 100%; }
  .top .device { margin-left: 0; }
  .top__integration { width: 100%; }
  .layout { grid-template-columns: 1fr; padding-top: 16px; }
  .nav { border-bottom: 1px solid var(--line); padding-bottom: 10px; }
  .overview > .card:first-child .facts {
    grid-template-columns: max-content minmax(120px, 1fr);
  }
}

@media (max-width: 760px) {
  .acquisition__panel { padding: 16px; }
  .acquisition__form { padding: 13px; }
  .acquisition__actions .btn { width: 100%; }
  .quantities { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .portal-brand__copy small { display: none; }
  .top__context { flex: 1; }
  .top__integration .btn { flex: 1; }
  .top .device { width: 100%; }
  .device__select, .device__row { width: 100%; }
  .card { padding: 16px 14px; }
  .frequency { width: 100%; }
}
