/* =====================================================================
   NR13 Inspect Pro — Design System "Industrial Dark" (Preto & Laranja)
   Responsivo: mobile (base) → tablet → desktop
   ===================================================================== */

:root {
  /* Superfícies */
  --bg:            #121212;   /* fundo da aplicação */
  --surface:       #1E1E1E;   /* cards / modais */
  --surface-2:     #242424;   /* elevação extra */
  --border:        #2A2A2A;   /* bordas e divisores */

  /* Marca / ações */
  --primary:       #FF6600;   /* laranja industrial */
  --primary-hover: #D95300;   /* laranja queimado */

  /* Texto */
  --text:          #FFFFFF;   /* títulos / destaques */
  --text-muted:    #A0A0A0;   /* corpo / legendas */

  /* Status / severidade */
  --ok:            #28A745;
  --warn:          #FFC107;
  --danger:        #DC3545;

  /* Métrica */
  --header-h:      56px;
  --nav-w:         248px;
  --radius:        10px;
  --radius-sm:     6px;

  --font-ui:   'Inter', 'Roboto', system-ui, -apple-system, Segoe UI, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden; /* o scroll acontece no .app-main */
}

h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 600; line-height: 1.25; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p  { margin: 0 0 .75rem; color: var(--text-muted); }
a  { color: var(--primary); text-decoration: none; }

/* Dados numéricos / TAGs / tabelas técnicas */
.mono, table.data, .tag, .metric__value { font-family: var(--font-mono); }

/* =====================================================================
   TOPO
   ===================================================================== */
.app-header {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 .875rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 40;
}

.app-header__menu {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 38px;
  height: 38px;
  padding: 0 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.app-header__menu span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

.app-header__brand { display: flex; align-items: baseline; gap: .4rem; }
.app-header__logo {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--primary);
  letter-spacing: .5px;
}
.app-header__title { font-weight: 600; }

.app-header__status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .8rem;
  color: var(--text-muted);
  padding: .25rem .55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
}
.app-header__status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted);
}
.app-header__status.is-online .dot  { background: var(--ok); }
.app-header__status.is-offline .dot { background: var(--danger); }

/* =====================================================================
   LAYOUT
   ===================================================================== */
.app-body {
  position: absolute;
  inset: var(--header-h) 0 0 0;
  display: flex;
}

.app-nav {
  width: var(--nav-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: .75rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  overflow-y: auto;
}

.app-nav__item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .7rem .8rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
}
.app-nav__item:hover { background: var(--surface-2); color: var(--text); }
.app-nav__item.is-active {
  background: rgba(255, 102, 0, .12);
  color: var(--primary);
}
.app-nav__icon { width: 18px; text-align: center; opacity: .9; }

.app-nav__footer { margin-top: auto; padding-top: .75rem; border-top: 1px solid var(--border); }
.app-nav__version { font-size: .72rem; color: var(--text-muted); text-align: center; margin: .5rem 0 0; }

.app-nav__backdrop {
  display: none;
  position: fixed;
  inset: var(--header-h) 0 0 0;
  background: rgba(0, 0, 0, .5);
  z-index: 30;
}

.app-main {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  -webkit-overflow-scrolling: touch;
}

.view { max-width: 960px; margin: 0 auto; }

/* =====================================================================
   COMPONENTES
   ===================================================================== */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}
.page-head__sub { color: var(--text-muted); font-size: .9rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
}
.card + .card { margin-top: 1rem; }

.grid { display: grid; gap: 1rem; }
@media (min-width: 560px)  { .grid--2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 860px)  { .grid--3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .grid--4 { grid-template-columns: repeat(4, 1fr); } }

/* KPI / métricas do dashboard */
.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: .9rem 1rem;
}
.metric__label { font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.metric__value { font-size: 1.7rem; font-weight: 700; margin-top: .2rem; }
.metric--ok     { border-left-color: var(--ok); }
.metric--warn   { border-left-color: var(--warn); }
.metric--danger { border-left-color: var(--danger); }

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .6rem 1rem;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s ease;
}
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--block { width: 100%; }
.btn--sm { padding: .4rem .7rem; font-size: .85rem; }

/* Formulários */
.field { margin-bottom: .9rem; }
.field label { display: block; font-size: .82rem; color: var(--text-muted); margin-bottom: .3rem; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: .6rem .7rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* Tabelas técnicas */
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
table.data th, table.data td {
  padding: .55rem .6rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
table.data th { color: var(--primary); font-weight: 600; text-transform: uppercase; font-size: .74rem; letter-spacing: .5px; }
.table-scroll { overflow-x: auto; }

/* Badges de status */
.badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  border: 1px solid currentColor;
}
.badge--ok     { color: var(--ok); }
.badge--warn   { color: var(--warn); }
.badge--danger { color: var(--danger); }

/* Estado vazio */
.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty__icon { font-size: 2rem; opacity: .5; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
  z-index: 50;
}
.modal {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.modal__head h2 { margin: 0; }
.modal__close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: .25rem .5rem;
}
.modal__close:hover { color: var(--text); }
.modal__body { padding: 1.1rem; }

/* Linha de formulário em colunas */
.form-row { display: grid; gap: 0 1rem; }
@media (min-width: 560px) {
  .form-row--2 { grid-template-columns: 1fr 1fr; }
  .form-row--3 { grid-template-columns: 1fr 1fr 1fr; }
  .form-row--21 { grid-template-columns: 2fr 1fr; }
}
.form-actions {
  display: flex;
  gap: .6rem;
  justify-content: flex-end;
  margin-top: .5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
fieldset.group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .9rem 1rem .4rem;
  margin: 0 0 1rem;
}
fieldset.group > legend {
  padding: 0 .4rem;
  font-size: .82rem;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* Caixa de resultado do enquadramento */
.enquadramento {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: .8rem .9rem;
  margin-bottom: 1rem;
  font-size: .88rem;
}
.enquadramento b { color: var(--text); }
.enquadramento .categoria {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
}

/* Lista de itens (cards clicáveis) */
.list { display: flex; flex-direction: column; gap: .6rem; }
.list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.list__item:hover { border-color: var(--primary); }
.list__main { min-width: 0; }
.list__title { font-weight: 600; }
.list__sub { font-size: .82rem; color: var(--text-muted); }
.list__actions { display: flex; gap: .4rem; flex-shrink: 0; }
.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: .35rem .55rem;
  cursor: pointer;
  font-size: .8rem;
}
.icon-btn:hover { color: var(--text); border-color: var(--primary); }
.icon-btn--danger:hover { color: var(--danger); border-color: var(--danger); }

.toolbar {
  display: flex;
  gap: .6rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.toolbar input[type="search"] {
  flex: 1;
  min-width: 180px;
  padding: .55rem .7rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
}

/* Abas (editor de inspeção) */
.tabs {
  display: flex;
  gap: .25rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
  -webkit-overflow-scrolling: touch;
}
.tab {
  flex-shrink: 0;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 500;
  padding: .6rem .9rem;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }

/* Cartão de foto */
.foto-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .5rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.foto-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.foto-card input, .foto-card select {
  width: 100%;
  padding: .4rem .5rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: .82rem;
}

/* Inputs dentro de tabelas técnicas */
table.data input, table.data select {
  padding: .35rem .45rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
  font-size: .85rem;
  max-width: 100%;
}
table.data td { vertical-align: middle; }

textarea {
  resize: vertical;
  font-family: var(--font-ui);
}

/* Toasts */
.toast-stack {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: .5rem;
  z-index: 60;
  width: min(92vw, 420px);
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: .7rem .9rem;
  font-size: .88rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}
.toast--ok     { border-left-color: var(--ok); }
.toast--warn   { border-left-color: var(--warn); }
.toast--danger { border-left-color: var(--danger); }

/* =====================================================================
   RESPONSIVO
   ===================================================================== */

/* Mobile / tablet estreito: menu vira gaveta */
@media (max-width: 900px) {
  .app-nav {
    position: fixed;
    inset: var(--header-h) auto 0 0;
    transform: translateX(-100%);
    transition: transform .2s ease;
    z-index: 35;
    width: min(80vw, var(--nav-w));
  }
  .app-nav.is-open { transform: translateX(0); }
  .app-nav__backdrop.is-open { display: block; }
  .app-main { padding: 1rem; }
}

/* Desktop: menu sempre visível, esconde o botão hambúrguer */
@media (min-width: 901px) {
  .app-header__menu { display: none; }
}
