/* Ajustes globais apenas para mobile/tablet */
@media (max-width: 1024px) {
  :root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --app-navbar-height: 52px;
    --app-navbar-total-height: calc(var(--app-navbar-height) + var(--safe-top));
    --app-horizontal-padding: 12px;
    --app-menu-trigger-size: 42px;
    --app-menu-trigger-offset: 6px;
    --app-menu-trigger-space: 52px;
  }

  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-x: clip;
    overscroll-behavior-x: none;
    touch-action: pan-y;
  }
  * { box-sizing: border-box; }

  body > * {
    max-width: 100%;
  }

  main.page-shell,
  main.app-main,
  .page-shell,
  .app-main {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
    overflow-x: clip;
    overscroll-behavior-x: none;
    touch-action: pan-y;
  }

  img,
  svg,
  video,
  canvas {
    max-width: 100%;
    height: auto;
  }

  input, select, textarea { font-size: 16px !important; min-height: 44px !important; }
  input[type="checkbox"] { transform: scale(1.2); margin-right: 6px; }

  /* Navbar e bot�o hamburger alinhados � esquerda */
  .navbar {
    position: sticky;
    top: 0;
    width: 100%;
    min-height: var(--app-navbar-total-height);
    padding-top: var(--safe-top);
    padding-left: calc(var(--app-horizontal-padding) + var(--safe-left));
    padding-right: calc(var(--app-horizontal-padding) + var(--safe-right));
    padding-bottom: 0;
    background: #1e398e;
    box-sizing: border-box;
    z-index: 1000;
  }
  .navbar-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: var(--app-navbar-height);
    width: 100%;
    min-width: 0;
    padding-left: var(--app-menu-trigger-space);
    box-sizing: border-box;
  }
  .menu-btn {
    order: 1;
    justify-self: start;
    display: inline-flex;
  }
  .logo-left { order: 2; height: 34px; }
  .logo-right { order: 3; height: 30px; justify-self: end; }
  .menu-center { display: none !important; }

  main,
  .page,
  .page-shell,
  .app-page,
  .app-main,
  .mobile-page,
  .page-relatorio {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding-top: 8px;
    box-sizing: border-box;
  }

  /* Menu drawer premium */
  .menu-drawer {
    width: 70vw;
    max-width: none;
  }

  /* Layout geral de inputs e bot�es */
  input:not([type="checkbox"]):not([type="radio"]), select, textarea { width: 100% !important; }
  button, .btn-primary, .btn-voltar, .btn-filtrar { min-height: none; font-size: 15px; border-radius: 10px; }
}

@media (max-width: 768px) {
  /* Cabe�alho do checklist mais compacto */

  /* Cards dos itens mais leves */
  .checklist-cards { gap: 8px; }
  .mobile-card {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    padding: 10px 12px;
    margin-bottom: 10px;
    border: 1px solid #d7dbe7;
    background: linear-gradient(180deg, #ffffff 0%, #f7f9ff 100%);
    box-shadow: 0 6px 14px rgba(21, 34, 77, 0.08);
  }
  .mobile-item-header { margin-bottom: 6px; line-height: 1.2; }
  .item-number { font-size: 12px; font-weight: 700; color: #243881; }
  .mobile-item-title { font-size: 16px; margin: 2px 0 4px 0; color: #243881; font-weight: 800; }

  /* Bloco Unidade / Min / M�x numa linha */
  .mobile-info-block {
    margin-bottom: 8px;
    border-top: 1px solid #e8e8e8;
    padding-top: 6px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .mobile-info-row { display: flex; flex-direction: column; gap: 2px; margin: 0; }
  .mobile-info-label { font-size: 12px; font-weight: 600; color: #666; }
  .mobile-info-value { font-size: 14px; font-weight: 700; color: #000; }

  /* Valor e OK/NOK lado a lado */
  .mobile-value-row {
    display: grid;
    grid-template-columns: 1.2fr 0.9fr 0.9fr;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
  }
  .mobile-input-block { margin: 0; }
  .mobile-input { width: 100%; height: 32px; padding: 6px 8px; font-size: 14px; border-radius: 8px; border: 1px solid #d1d5db; box-sizing: border-box; }

  .mobile-oknok { display: flex; gap: 6px; flex-wrap: nowrap; margin: 0; justify-content: center; align-items: center; }
  .mobile-oknok label {
    background: #f5f5f5;
    border-radius: 10px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 700;
    color: #1f2937;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #d1d5db;
    min-width: 60px;
    justify-content: center;
  }
  .mobile-oknok label.ok-btn { background: #e6f5ea; border: 1px solid #b9e2c7; color: #0f5132; }
  .mobile-oknok label.nok-btn { background: #fde8e8; border: 1px solid #f5c2c7; color: #842029; }

  .mobile-comments-block { margin-top: 4px; }
  .mobile-textarea { width: 100%; min-height: 60px; padding: 8px; font-size: 14px; border: 1px solid #d1d5db; border-radius: 8px; box-sizing: border-box; }

  /* Detalhes checklist - cards só no mobile */
  .detalhes-cards .detalhes-card { padding: 8px 10px; margin-bottom: 8px; }
  .readonly-box { background: #f7f9fc; border: 1px solid #d7dbe7; border-radius: 8px; padding: 6px 8px; font-size: 13px; min-height: 32px; display: flex; align-items: center; }
  .readonly-oknok { display: flex; gap: 6px; justify-content: flex-end; }
  .readonly-oknok .pill { padding: 4px 8px; border-radius: 10px; font-size: 12px; border: 1px solid #d1d5db; min-width: 52px; text-align: center; }
}

@media (max-width: 600px) {
  /* Mais compacto para caber mais cards na tela */
  .navbar {
    padding-left: calc(10px + var(--safe-left));
    padding-right: calc(10px + var(--safe-right));
  }
  .mobile-card { padding: 6px 8px; margin-bottom: 6px;  box-shadow: 0 4px 10px rgba(0,0,0,0.06); }
  .mobile-item-header { margin-bottom: 4px; }
  .item-number { font-size: 11px; }
  .mobile-item-title { font-size: 14px; margin: 0 0 4px 0; }

  .mobile-info-block { gap: 4px; padding-top: 4px; margin-bottom: 6px; }
  .mobile-info-label { font-size: 11px; }
  .mobile-info-value { font-size: 12px; }

  .mobile-value-row { grid-template-columns: 1fr 0.8fr 0.8fr; gap: 6px; margin-bottom: 6px; }
  .mobile-input { height: 28px; padding: 4px 6px; font-size: 12px; }

  .mobile-oknok label { padding: 4px 8px; font-size: 12px; min-width: 58px; }
  .mobile-textarea { min-height: 50px; padding: 6px; font-size: 12px; }

  /* Não empilhar tabelas específicas (historico/detalhes) */
  .no-stack-mobile {
    display: table;
    width: 100%;
  }
  .no-stack-mobile thead { display: table-header-group; }
  .no-stack-mobile tbody { display: table-row-group; }
  .no-stack-mobile tr { display: table-row; }
  .no-stack-mobile th,
  .no-stack-mobile td {
    display: table-cell;
    padding: 6px 8px;
    font-size: 12px;
    border-bottom: 1px solid #e5e7eb;
  }
  .no-stack-mobile td::before { content: none !important; }

  /* Cards de histórico de checklist */
  .registros-cards { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
  .registro-card {
    background: #fff;
    border: 1px solid #e4e7ef;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.06);
    padding: 10px 12px;
    width: 100%;
  }
  .registro-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
  }
  .registro-id { font-size: 12px; color: #4b5563; }
  .registro-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .badge-ok.small { padding: 4px 8px; font-size: 12px; }
  .badge-nok.small { padding: 4px 8px; font-size: 12px; }
  .view-link.compact {
    padding: 6px 10px;
    font-size: 12px;
    white-space: nowrap;
  }

  /* Detalhes checklist: empilhar linhas da tabela no mobile para caber na tela */
  .detalhes-page-wrap .no-stack-mobile {
    display: block;
    width: 100%;
  }
  .detalhes-page-wrap .no-stack-mobile thead { display: none; }
  .detalhes-page-wrap .no-stack-mobile tbody { display: block; }
  .detalhes-page-wrap .no-stack-mobile tr {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-template-areas:
      "desc desc desc desc desc desc"
      "unid min max valor ok nok"
      "coment coment coment coment coment coment";
    margin-bottom: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    overflow: hidden;
  }
  .detalhes-page-wrap .no-stack-mobile td {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    font-size: 12px;
    border-bottom: 1px solid #eef1f6;
  }
  .detalhes-page-wrap .no-stack-mobile td:last-child { border-bottom: 0; }
  .detalhes-page-wrap .no-stack-mobile td::before {
    content: attr(data-label);
    font-weight: 700;
    color: #243881;
    font-size: 12px;
  }
  .detalhes-page-wrap .no-stack-mobile td[data-label="Descricao"] {
    grid-area: desc;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .detalhes-page-wrap .no-stack-mobile td[data-label="Unidade"] { grid-area: unid; }
  .detalhes-page-wrap .no-stack-mobile td[data-label="Min"] { grid-area: min; }
  .detalhes-page-wrap .no-stack-mobile td[data-label="Max"] { grid-area: max; }
  .detalhes-page-wrap .no-stack-mobile td[data-label="Valor"] { grid-area: valor; }
  .detalhes-page-wrap .no-stack-mobile td[data-label="OK"] { grid-area: ok; justify-content: center; }
  .detalhes-page-wrap .no-stack-mobile td[data-label="NOK"] { grid-area: nok; justify-content: center; }
  .detalhes-page-wrap .no-stack-mobile td[data-label="Comentarios"] {
    grid-area: coment;
    align-items: flex-start;
  }
  .detalhes-page-wrap .no-stack-mobile td[data-label="Descricao"]::before { margin-bottom: 2px; }
  .detalhes-page-wrap .no-stack-mobile td[data-label="Comentarios"]::before { margin-top: 2px; }
  .detalhes-page-wrap .no-stack-mobile td[data-label="Item"] { display: none; }

  /* Manter tabela de equipamentos operando como tabela (não empilhar) */

  /* Equipamentos em operação (cards mobile) */
  .desktop-only { display: none !important; }
}
