/* V2.1 — layout fluido para celular, tablet, computador e TV. */
:root {
  --layout-gutter: clamp(8px, 2vw, 40px);
  --panel-gutter: clamp(10px, 1.4vw, 26px);
}

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

body {
  width: 100%;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: clip;
  font-size: clamp(13px, .5vw, 18px);
}

.app-shell {
  width: 100%;
  max-width: 2400px;
  margin-inline: auto;
  padding: var(--panel-gutter) var(--layout-gutter) max(18px, env(safe-area-inset-bottom));
}

.app-shell,
.app-shell main,
.topbar,
.top-user,
.top-links,
.page-head,
.agenda-hero,
.config-layout,
.config-panel,
.config-side,
.form-page,
.painel,
.panel,
.notice,
.barra,
.titulo,
.cards,
.report-section,
.table-card {
  min-width: 0;
  max-width: 100%;
}

img,
svg,
video,
canvas {
  max-width: 100%;
}

h1,
.page-head h1,
.agenda-hero h1 {
  font-size: clamp(23px, 1.8vw, 42px);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

p,
label,
th,
td,
.notice,
.help,
.top-user b {
  overflow-wrap: anywhere;
}

input,
select,
textarea,
button {
  max-width: 100%;
  min-width: 0;
}

input[type="checkbox"],
input[type="radio"] {
  min-width: 16px;
  flex: 0 0 auto;
}

.page-head,
.titulo,
.agenda-hero,
.hero-acoes {
  flex-wrap: wrap;
}

.agenda-hero {
  gap: clamp(12px, 2vw, 24px);
}

.cards {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
}

.cards article,
.cards.compact article {
  min-width: 0;
}

.form-grid.cols,
.config-panel .form-grid,
.form-two,
.permission-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
}

.form-grid > *,
.form-two > *,
.permission-grid > *,
.config-panel .form-grid > * {
  min-width: 0;
}

.form-grid .wide,
.form-grid label.wide,
.config-panel .wide {
  grid-column: 1 / -1;
}

.form-grid input,
.form-grid select,
.form-two input,
.form-two select,
.config-panel textarea {
  width: 100%;
}

.barra {
  width: 100%;
  flex-wrap: wrap;
}

.barra label {
  min-width: min(150px, 100%);
}

.tabela {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.tabela table {
  width: 100%;
  min-width: 640px;
  table-layout: auto;
}

.tabela th,
.tabela td {
  white-space: normal;
  overflow-wrap: anywhere;
  vertical-align: top;
}

.schedule-table {
  min-width: 720px;
}

.schedule-table input {
  width: 100%;
  min-width: 70px;
}

.calendario,
.semana {
  width: 100%;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendario > .dia,
.semana > * {
  min-width: 0;
}

.semana-tempo {
  max-width: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.topbar {
  width: 100%;
  height: auto;
  min-height: 58px;
  grid-template-columns: minmax(150px, 1fr) minmax(180px, .9fr) minmax(0, 2fr);
}

.top-user,
.top-links {
  flex-wrap: wrap;
}

.top-links a,
.top-links button {
  min-height: 40px;
}

.detalhe-overlay {
  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (min-width: 1800px) {
  body {
    font-size: clamp(15px, .65vw, 20px);
  }

  .app-shell {
    max-width: 2800px;
    padding-inline: clamp(36px, 2.4vw, 72px);
  }

  .topbar {
    grid-template-columns: minmax(200px, 1fr) minmax(320px, 1.2fr) minmax(0, 2.6fr);
  }

  .top-user b {
    font-size: clamp(14px, .85vw, 20px);
  }

  .top-user small,
  .top-brand small {
    font-size: clamp(10px, .55vw, 14px);
  }

  button,
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    min-height: 46px;
    font-size: clamp(14px, .68vw, 18px);
  }

  h1,
  .page-head h1,
  .agenda-hero h1 {
    font-size: clamp(32px, 2vw, 50px);
  }

  .agenda-hero {
    padding: clamp(28px, 2vw, 52px);
  }

  .painel,
  .panel {
    padding: clamp(16px, 1.1vw, 28px);
  }

  .top-links a,
  .top-links button {
    font-size: clamp(13px, .7vw, 17px);
    padding-inline: clamp(9px, .8vw, 16px);
  }
}

@media (max-width: 1024px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "user menu" "links links";
    position: relative;
    padding: 8px 10px;
  }

  .top-user {
    grid-area: user;
  }

  .top-brand {
    display: none;
  }

  .menu-toggle {
    display: inline-flex;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    grid-area: menu;
    justify-self: end;
  }

  .top-links {
    display: none;
    grid-column: 1 / -1;
    grid-area: links;
    position: static;
    width: 100%;
    justify-content: stretch;
    align-items: stretch;
    max-height: min(68dvh, 560px);
    overflow-y: auto;
    padding-top: 6px;
  }

  .top-links.aberto {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  }

  .top-links a,
  .top-links button {
    min-height: 44px;
    white-space: normal;
    text-align: center;
  }

  .top-links form {
    display: grid;
    grid-column: 1 / -1;
  }

  .top-links form button {
    width: 100%;
  }

  .config-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 700px) {
  :root {
    --layout-gutter: max(8px, env(safe-area-inset-left));
    --panel-gutter: 10px;
  }

  .app-shell {
    padding-right: max(8px, env(safe-area-inset-right));
  }

  .topbar {
    margin-bottom: 12px;
  }

  .top-user {
    gap: 5px 8px;
  }

  .top-user b {
    max-width: min(64vw, 320px);
  }

  .top-links.aberto {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .top-links a,
  .top-links button {
    padding: 9px 6px;
    font-size: 12px;
  }

  .agenda-hero {
    display: block;
    padding: 16px;
    margin-bottom: 12px;
  }

  .agenda-hero p {
    font-size: 13px;
  }

  .hero-acoes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 14px;
  }

  .hero-acoes > * {
    min-width: 0;
    white-space: normal;
    text-align: center;
  }

  .cards {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 155px), 1fr));
    gap: 8px;
  }

  .cards article {
    padding: 12px;
  }

  .cards strong {
    font-size: clamp(18px, 5.5vw, 24px);
    overflow-wrap: anywhere;
  }

  .painel,
  .panel {
    padding: 12px;
  }

  .form-grid.cols,
  .config-panel .form-grid,
  .form-two,
  .permission-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-grid .wide,
  .form-grid label.wide,
  .config-panel .wide {
    grid-column: 1;
  }

  .actions {
    align-items: stretch;
  }

  .actions > *,
  .actions form,
  .actions form button {
    max-width: 100%;
  }

  .big-button {
    width: 100%;
    height: auto;
    min-height: 54px;
    padding: 10px 14px;
    white-space: normal;
  }

  .punch-panel {
    padding: 16px 12px;
  }

  .punch-chips span {
    max-width: 100%;
    font-size: 15px;
  }

  .calendario,
  .semana {
    gap: 3px;
  }

  .calendario > .dia {
    padding: 5px 3px;
  }

  .calendario .contador {
    max-width: 100%;
    padding-inline: 3px;
    font-size: 9px;
  }

  .account {
    gap: 8px;
  }

  .account form,
  .account button {
    max-width: 100%;
  }

  .login-shell {
    padding: 14px 10px max(72px, env(safe-area-inset-bottom));
  }

  .login-shell .app-footer {
    left: 10px;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 380px) {
  :root {
    --layout-gutter: max(6px, env(safe-area-inset-left));
    --panel-gutter: 8px;
  }

  .app-shell {
    padding-right: max(6px, env(safe-area-inset-right));
  }

  .top-links.aberto {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-acoes {
    grid-template-columns: minmax(0, 1fr);
  }

  .auth-card,
  .login-card {
    padding: 16px;
  }

  .semana b {
    padding-inline: 1px;
    font-size: 9px;
  }
}

/* Landscape phones have little vertical room; keep the page scrollable and
   reduce chrome without forcing a desktop-width layout. */
@media (max-width: 1024px) and (orientation: landscape) and (max-height: 520px) {
  .app-shell {
    padding-top: 8px;
  }

  .topbar {
    margin-bottom: 8px;
  }

  .agenda-hero {
    padding: 12px 16px;
  }

  .cards {
    gap: 6px;
  }

  .cards article {
    padding: 9px;
  }

  .login-shell {
    align-items: start;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .login-shell .app-footer {
    position: static;
    margin: 18px 0 0;
  }
}

@media (pointer: coarse) {
  button,
  .btn,
  .button-link,
  .small-link,
  .top-links a,
  .top-links button {
    min-height: 44px;
  }

  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea,
  label.check {
    min-height: 44px;
  }
}

@media print {
  .app-shell {
    width: auto;
    max-width: none;
    padding: 0;
  }
}
