/* InfraMINA · camada final compartilhada
   Organiza ritmo, enquadramento e responsividade sem alterar os fluxos. */

@media screen {
  :root {
    --ui-page-gutter: clamp(1rem, 2.2vw, 2rem);
    --ui-section-gap: clamp(1rem, 1.8vw, 1.5rem);
    --ui-control-height: 44px;
    --ui-content-max: 1500px;
  }

  body {
    font-family: var(--font-body, Archivo), system-ui, sans-serif;
    text-rendering: optimizeLegibility;
  }

  :where(button, input, select, textarea) { font: inherit; }
  :where(p, td, th, label, button, input, select, textarea) { overflow-wrap: anywhere; }
  :where(.content, .tc-content, .section-inner, .container) > * { min-width: 0; }

  /* Site público */
  .landing-page .header-inner,
  .landing-page .hero-inner,
  .landing-page .section-inner,
  .landing-page .banner-inner,
  .landing-page .footer-inner {
    width: min(100% - 2rem, 1240px);
    margin-inline: auto;
  }
  .landing-page .header { border-bottom-color: var(--console-line, #34495b); }
  .landing-page .header-inner { min-height: 72px; }
  .landing-page .nav { gap: clamp(.9rem, 2vw, 1.8rem); }
  .landing-page .nav a { line-height: 1.25; }
  .landing-page .hero-content { max-width: 760px; }
  .landing-page .hero h1 { max-width: 18ch; text-wrap: balance; }
  .landing-page .hero p { max-width: 62ch; line-height: 1.7; }
  .landing-page .section { padding-block: clamp(4rem, 8vw, 7rem); }
  .landing-page .section-head { max-width: 760px; margin-bottom: clamp(2rem, 4vw, 3.5rem); }
  .landing-page .section-head h2 { text-wrap: balance; }
  .landing-page :where(.pillar-card, .principle, .gallery-item) {
    min-width: 0;
    border-color: var(--console-line, #34495b);
  }
  .landing-page :where(.pillar-card, .principle) p { line-height: 1.65; }
  .landing-page :where(.btn-primary, .btn-outline, .btn-white) {
    min-height: var(--ui-control-height);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-inline: 1.15rem;
  }

  /* Autenticação */
  .auth-gate { padding: clamp(1rem, 4vw, 2rem); }
  .auth-card {
    width: min(100%, 460px);
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
  }
  .auth-card-head { gap: 1rem; }
  .auth-card-head img { flex: 0 0 auto; }
  .auth-form { gap: .8rem; }
  .auth-field { gap: .4rem; }
  .auth-form .btn { width: 100%; min-height: var(--ui-control-height); }

  /* Estrutura dos dois sistemas */
  .app .content,
  .tc-content { padding: var(--ui-page-gutter); }
  .app .view,
  .tc-content > * { width: min(100%, var(--ui-content-max)); margin-inline: auto; }
  .app .topbar { gap: 1rem; }
  .app .topbar-title { min-width: 0; }
  .app .topbar-title h1 { text-wrap: balance; }
  .app .toolbar,
  .card-head,
  .modal-head,
  .modal-foot,
  .tc-actions { gap: .65rem; }

  /* Seções, cartões e hierarquia */
  .app .view > :where(.card, .stats, .layout-split, .daily-block, .technical-section, .empty-state) + *,
  #tcFormSections > * + * { margin-top: var(--ui-section-gap); }
  :where(.app, .terceirizada-page) :where(.card-head, .modal-head, .daily-block-head) {
    min-height: 58px;
    padding: .9rem 1rem;
  }
  :where(.app, .terceirizada-page) :where(.card-head, .modal-head) > div { min-width: 0; }
  :where(.app, .terceirizada-page) :where(.card-head, .modal-head) h3 {
    line-height: 1.25;
    text-wrap: balance;
  }
  :where(.app, .terceirizada-page) :where(.card-head, .modal-head) p {
    margin-top: .25rem;
    max-width: 70ch;
    line-height: 1.45;
  }
  :where(.app, .terceirizada-page) :where(.card-body, .modal-body) { padding: clamp(1rem, 2vw, 1.35rem); }

  /* Formulários */
  :where(.app, .terceirizada-page) :where(.form-row, .form-grid, .tc-fields-grid) {
    align-items: start;
  }
  :where(.app, .terceirizada-page) :where(.form-group, .tc-field, label) { min-width: 0; }
  :where(.app, .terceirizada-page) :where(.form-group, .tc-field) > label {
    display: block;
    margin-bottom: .42rem;
    line-height: 1.25;
  }
  :where(.app, .terceirizada-page) :where(.form-control, .cell-in) {
    width: 100%;
    min-width: 0;
    min-height: var(--ui-control-height);
    padding: .68rem .75rem;
    line-height: 1.3;
  }
  :where(.app, .terceirizada-page) textarea.form-control { min-height: 96px; resize: vertical; }
  :where(.app, .terceirizada-page) .form-hint {
    display: block;
    margin-top: .42rem;
    color: var(--console-muted);
    font-size: var(--t-sm);
    line-height: 1.45;
  }
  :where(.app, .terceirizada-page) .qe-mobilization-field {
    padding: .85rem;
    border: 1px solid var(--console-line);
    background: var(--console-panel-2);
  }
  :where(.app, .terceirizada-page) .qe-mobilization-field[hidden] { display: none; }
  :where(.app, .terceirizada-page) .number-stepper { grid-template-columns: 44px minmax(0, 1fr) 44px; }
  :where(.app, .terceirizada-page) .number-stepper button { min-width: 44px; min-height: 44px; }

  /* Botões e ações */
  :where(.app, .terceirizada-page) .btn {
    min-height: 40px;
    padding: .62rem .9rem;
    line-height: 1.15;
    text-align: center;
  }
  :where(.app, .terceirizada-page) .btn-icon { width: 40px; padding-inline: 0; flex: 0 0 40px; }
  :where(.app, .terceirizada-page) .modal-close { flex: 0 0 40px; width: 40px; height: 40px; }

  /* Tabelas */
  :where(.app, .terceirizada-page) .table-wrap {
    max-width: 100%;
    overscroll-behavior-inline: contain;
  }
  :where(.app, .terceirizada-page) table { width: 100%; border-collapse: collapse; }
  :where(.app, .terceirizada-page) th {
    padding: .72rem .75rem;
    line-height: 1.25;
    text-align: left;
    vertical-align: bottom;
  }
  :where(.app, .terceirizada-page) td {
    padding: .68rem .75rem;
    line-height: 1.4;
    vertical-align: middle;
  }
  :where(.app, .terceirizada-page) .actions-cell { width: 1%; white-space: nowrap; }

  /* Modais */
  .modal-overlay { padding: clamp(.75rem, 3vw, 2rem); }
  .modal { width: min(100%, 640px); }
  .modal.lg { width: min(100%, 860px); }
  .modal.xl { width: min(100%, 1120px); }
  .modal-foot { flex-wrap: wrap; }

  /* Estados vazios e feedback */
  :where(.empty, .empty-state, .empty-inline) {
    min-height: 120px;
    display: grid;
    place-content: center;
    gap: .65rem;
    padding: clamp(1.25rem, 3vw, 2.25rem);
    text-align: center;
    line-height: 1.55;
  }
  .toast { max-width: min(420px, calc(100vw - 2rem)); line-height: 1.45; }

  /* Terceirizada */
  .tc-intro { display: grid; gap: .3rem; }
  .tc-intro h1 { text-wrap: balance; }
  .tc-team-card { min-width: 0; }
  .tc-team-numbers { align-items: start; }
  .tc-actions { flex-wrap: wrap; }

  /* Mapas e áreas densas */
  .map3d-head,
  .map3d-toolbar { flex-wrap: wrap; }
  .map3d-head-actions { flex-wrap: wrap; justify-content: flex-end; }
  .map3d-toolbar > * { min-width: 0; }
  .kanban-board { align-items: start; }
  .kanban-col { min-width: min(280px, 85vw); }

  @media (max-width: 900px) {
    .landing-page .nav { display: none; }
    .app .topbar { align-items: flex-start; }
    .app .toolbar { width: 100%; overflow-x: auto; padding-bottom: .2rem; }
    :where(.app, .terceirizada-page) :where(.form-row, .form-grid) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }

  @media (max-width: 640px) {
    :root { --ui-page-gutter: .8rem; --ui-section-gap: .8rem; }
    .landing-page .header-inner,
    .landing-page .hero-inner,
    .landing-page .section-inner,
    .landing-page .banner-inner,
    .landing-page .footer-inner { width: min(100% - 1.25rem, 1240px); }
    .landing-page .section { padding-block: 3.5rem; }
    .auth-gate { padding: .65rem; }
    .auth-card { max-height: calc(100dvh - 1.3rem); }
    :where(.app, .terceirizada-page) :where(.form-row, .form-grid, .tc-fields-grid) { grid-template-columns: 1fr; }
    :where(.app, .terceirizada-page) :where(.card-head, .modal-head, .daily-block-head) { align-items: flex-start; }
    :where(.app, .terceirizada-page) .modal-foot > .btn { flex: 1 1 140px; }
    .tc-actions .btn { flex: 1 1 100%; }
    .map3d-head-actions { width: 100%; justify-content: stretch; }
    .map3d-head-actions .btn { flex: 1; }
  }
}
