:root {
  --app-bg: #f9f9fa;
  --surface: #ffffff;
  --surface-soft: #f4f4f6;
  --text: #1a1b1d;
  --muted: #646b7a;
  --line: #e0e2e6;
  --brand: #2c42ce;
  --brand-hover: #1e32a6;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;

  --tv-bg: #060a12;
  --tv-surface: #0f1522;
  --tv-line: rgba(182, 194, 214, 0.12);
  --tv-text: #f0f3fa;
  --tv-muted: #8b99b5;
  --tv-amber: #facc15;
  --tv-blue: #38bdf8;
  --tv-green: #22c55e;
  --tv-red: #ef4444;
  --tv-teal: #2dd4bf;
}

/* Correção v1.4: garante que elementos com atributo hidden realmente fiquem invisíveis,
   mesmo quando alguma classe posterior define display:grid/flex/table. */
[hidden] {
  display: none !important;
}

*, *::before, *::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--app-bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.noscript-alert {
  padding: 16px;
  color: #fff;
  background: var(--danger);
  font-weight: 700;
  text-align: center;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.form-stack {
  display: grid;
  gap: 16px;
}

.field-group {
  display: grid;
  gap: 6px;
}

.field-group span {
  font-size: 0.94rem;
  font-weight: 700;
}

.field-group small {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="date"] {
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]::placeholder,
input[type="password"]::placeholder {
  color: #a0a6b5;
}

input:focus-visible {
  outline: 0;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(44, 66, 206, 0.15);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.96rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
  user-select: none;
}

.button:active {
  transform: scale(0.98);
}

.button:disabled {
  opacity: 0.6;
  pointer-events: none;
}

.button-full {
  width: 100%;
}

.button-compact {
  min-height: 38px;
  padding: 0 14px;
  font-size: 0.88rem;
}

.button-primary {
  color: #fff;
  background: var(--brand);
}

.button-primary:hover {
  background: var(--brand-hover);
}

.button-secondary {
  color: var(--text);
  background: #ebecf0;
}

.button-secondary:hover {
  background: #dfe0e6;
}

.button-ghost {
  color: var(--muted);
  background: transparent;
}

.button-ghost:hover {
  color: var(--text);
  background: var(--surface-soft);
}

.button-danger {
  color: #fff;
  background: var(--danger);
}

.button-danger:hover {
  background: var(--danger-hover);
}

.button-row {
  display: grid;
  gap: 10px;
}

.message {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.4;
}

.message-success,
.message:not(.message-error) {
  color: #0d5a36;
  background: #d4f3e1;
}

.message-error {
  color: #8c1616;
  background: #fde4e4;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 32px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.06);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin: 0 0 20px;
  border-radius: 14px;
  color: #fff;
  background: var(--brand);
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.login-description {
  margin: 0 0 24px;
  color: var(--muted);
  font-weight: 500;
}

.register-shell {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px;
}

.mobile-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.mobile-header h1 {
  margin: 0;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.info-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 24px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: #eef2ff;
  border: 1px solid #c7d2fe;
}

.info-banner strong {
  color: #3730a3;
  font-size: 0.94rem;
}

.info-banner span {
  flex: 1;
  min-width: 280px;
  color: #4f46e5;
  font-size: 0.9rem;
  font-weight: 500;
}

.sync-status {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sync-status[data-status="ok"] {
  color: #065f46;
  background: #d1fae5;
}

.sync-status[data-status="syncing"] {
  color: #92400e;
  background: #fef3c7;
}

.sync-status[data-status="error"] {
  color: #991b1b;
  background: #fee2e2;
}

.content-grid {
  display: grid;
  gap: 20px;
}

.panel-card {
  padding: 20px;
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
  border: 1px solid var(--line);
}

.card-heading {
  margin-bottom: 24px;
}

.card-heading h2 {
  margin: 0 0 4px;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.card-heading p {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.96rem;
}

.card-heading-inline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.size-fieldset {
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.size-fieldset legend {
  padding: 0 6px;
  font-size: 0.94rem;
  font-weight: 700;
}

.size-toolbar {
  display: grid;
  grid-template-columns: auto auto;
  gap: 8px;
  margin-bottom: 12px;
}

.size-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.size-option {
  position: relative;
  display: flex;
  cursor: pointer;
}

.size-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.size-option span {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  text-align: center;
  transition: all 0.15s ease;
  user-select: none;
}

.size-option input:checked + span {
  border-color: var(--brand);
  background: #eef2ff;
  color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand);
}

.size-option input:focus-visible + span {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.actions-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.record-summary {
  margin-top: 12px;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  text-align: center;
}

.record-summary span {
  display: block;
  font-size: 2.8rem;
  line-height: 1;
  font-weight: 950;
  letter-spacing: -0.08em;
}

.record-summary small {
  max-width: 170px;
  color: var(--muted);
  font-weight: 700;
}

.recent-card {
  margin-top: 16px;
}

.recent-records {
  display: grid;
  gap: 10px;
}

.recent-item {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.recent-title-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.recent-title-row strong {
  flex: 1;
}

.recent-item strong {
  line-height: 1.25;
}

.recent-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.recent-meta span {
  padding: 6px 8px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
}

.recent-empty {
  margin: 0;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  text-align: center;
  font-weight: 700;
}

/* Tela de TV */
.tv-body {
  min-height: 100vh;
  overflow: hidden;
  color: var(--tv-text);
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.16), transparent 40rem),
    radial-gradient(circle at bottom right, rgba(250, 204, 21, 0.08), transparent 36rem),
    var(--tv-bg);
}

.tv-dashboard {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 18px;
  padding: clamp(16px, 2vw, 32px);
}

.tv-header {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 18px;
}

.airport-label {
  margin: 0 0 8px;
  color: var(--tv-amber);
  font-size: clamp(0.9rem, 1.3vw, 1.4rem);
  font-weight: 950;
  letter-spacing: 0.18em;
}

.tv-header h1 {
  margin: 0;
  color: var(--tv-text);
  font-size: clamp(1.8rem, 4.2vw, 4.8rem);
  line-height: 0.92;
  letter-spacing: -0.07em;
  text-transform: uppercase;
}

.clock-box {
  min-width: clamp(220px, 18vw, 380px);
  display: grid;
  align-content: center;
  justify-items: end;
  padding: clamp(14px, 1.6vw, 24px);
  border: 1px solid var(--tv-line);
  border-radius: 24px;
  background: rgba(17, 24, 39, 0.92);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.clock-box span {
  color: var(--tv-muted);
  font-size: clamp(1rem, 1.4vw, 1.6rem);
  font-weight: 800;
}

.clock-box strong {
  color: var(--tv-amber);
  font-size: clamp(2rem, 3.8vw, 4.2rem);
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.tv-source {
  margin-top: 8px;
  color: var(--tv-muted);
  font-size: clamp(0.72rem, 0.9vw, 1rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.tv-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.tv-stat-card {
  padding: clamp(12px, 1.4vw, 20px);
  border: 1px solid var(--tv-line);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(22, 32, 51, 0.98), rgba(12, 18, 31, 0.98));
}

.tv-stat-card span {
  display: block;
  margin-bottom: 6px;
  color: var(--tv-muted);
  font-size: clamp(0.78rem, 1vw, 1.1rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.tv-stat-card strong {
  color: var(--tv-text);
  font-size: clamp(1.7rem, 3vw, 3.3rem);
  line-height: 1;
  font-weight: 950;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
}

.departure-board {
  min-height: 0;
  position: relative;
  border: 1px solid var(--tv-line);
  border-radius: 24px;
  background: rgba(17, 24, 39, 0.92);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.departure-board::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.02),
    rgba(255, 255, 255, 0.02) 1px,
    transparent 1px,
    transparent 8px
  );
  opacity: 0.7;
}

.table-wrapper {
  position: relative;
  height: 100%;
  max-height: calc(100vh - 260px);
  overflow: auto;
}

.tv-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  color: var(--tv-text);
}

.tv-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.tv-table th {
  padding: clamp(12px, 1vw, 18px) clamp(8px, 0.9vw, 14px);
  color: #101827;
  background: var(--tv-amber);
  font-size: clamp(0.68rem, 0.86vw, 1rem);
  font-weight: 950;
  letter-spacing: 0.07em;
  text-align: left;
  text-transform: uppercase;
}

.tv-table th:nth-child(1) {
  width: 9%;
}

.tv-table th:nth-child(2) {
  width: 25%;
}

.tv-table th:nth-child(3) {
  width: 11%;
}

.tv-table th:nth-child(4) {
  width: 12%;
}

.tv-table th:nth-child(5),
.tv-table th:nth-child(6) {
  width: 12%;
}

.tv-table th:nth-child(7) {
  width: 10%;
}

.tv-table th:nth-child(8) {
  width: 9%;
}

.tv-table td {
  padding: clamp(12px, 1vw, 20px) clamp(8px, 0.9vw, 14px);
  border-bottom: 1px solid rgba(182, 194, 214, 0.18);
  background: rgba(12, 18, 31, 0.52);
  font-size: clamp(0.92rem, 1.18vw, 1.55rem);
  font-weight: 800;
  line-height: 1.16;
  vertical-align: middle;
}

.tv-table tr:nth-child(even) td {
  background: rgba(22, 32, 51, 0.7);
}

.tv-table td:nth-child(2) {
  font-weight: 950;
}

.tv-table td:nth-child(1),
.tv-table td:nth-child(5),
.tv-table td:nth-child(6) {
  font-variant-numeric: tabular-nums;
}

.date-cell {
  display: grid;
  gap: 4px;
}

.date-cell strong {
  color: var(--tv-text);
  font-size: clamp(1rem, 1.25vw, 1.65rem);
}

.date-cell small {
  color: var(--tv-muted);
  font-size: clamp(0.66rem, 0.8vw, 0.95rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.date-cell-changed strong,
.date-cell-changed small {
  color: var(--tv-amber);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 112px;
  padding: 10px 11px;
  border-radius: 999px;
  color: #061018;
  font-size: clamp(0.72rem, 0.8vw, 1rem);
  font-weight: 950;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-waiting {
  background: var(--tv-blue);
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.18);
}

.status-today {
  background: var(--tv-green);
  box-shadow: 0 0 24px rgba(34, 197, 94, 0.2);
}

.status-late {
  color: #fff;
  background: var(--tv-red);
  box-shadow: 0 0 24px rgba(239, 68, 68, 0.2);
}

.status-arrived {
  background: var(--tv-teal);
  box-shadow: 0 0 24px rgba(45, 212, 191, 0.2);
}

.tv-action-button {
  min-height: 46px;
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 0 12px;
  color: #061018;
  background: var(--tv-amber);
  font-size: clamp(0.78rem, 0.9vw, 1rem);
  font-weight: 950;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.tv-action-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 24px rgba(250, 204, 21, 0.16);
}

.tv-action-button-disabled {
  color: var(--tv-muted);
  background: rgba(168, 179, 197, 0.14);
  border: 1px solid var(--tv-line);
  box-shadow: none;
}

.tv-action-button-disabled:hover {
  transform: none;
}

.empty-state {
  min-height: calc(100vh - 280px);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 40px;
  position: relative;
  z-index: 1;
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border-radius: 28px;
  color: var(--tv-amber);
  background: rgba(250, 204, 21, 0.12);
  font-size: 3rem;
}

.empty-state strong {
  font-size: clamp(1.8rem, 3.5vw, 4rem);
  letter-spacing: -0.04em;
}

.empty-state small {
  color: var(--tv-muted);
  font-size: clamp(1rem, 1.4vw, 1.6rem);
  font-weight: 750;
}

@media (min-width: 720px) {
  .button-row {
    grid-template-columns: 1fr 1fr;
  }

  .form-actions-row:has(#cancelEditButton:not([hidden])) {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .content-grid {
    grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.8fr);
    align-items: start;
  }

  .panel-card {
    padding: 24px;
  }

  .size-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 1080px) {
  .tv-body {
    overflow: auto;
  }

  .tv-dashboard {
    min-width: 1180px;
  }
}

@media (max-width: 520px) {
  .login-card {
    padding: 24px 18px;
    border-radius: 24px;
  }

  .register-shell {
    padding: 14px;
  }

  .mobile-header {
    align-items: center;
  }

  .mobile-header h1 {
    font-size: 2rem;
  }

  .button-ghost {
    min-height: 46px;
    padding-inline: 14px;
  }

  .size-toolbar {
    grid-template-columns: 1fr;
  }

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

  .recent-title-row {
    display: grid;
  }
}

.panel-row {
  will-change: transform, opacity, filter;
}

.panel-row-late {
  box-shadow: inset 5px 0 0 rgba(239, 68, 68, 0.95);
}

.panel-row-today {
  box-shadow: inset 5px 0 0 rgba(34, 197, 94, 0.95);
}

.panel-row-waiting {
  box-shadow: inset 5px 0 0 rgba(59, 130, 246, 0.85);
}

.panel-row-arrived {
  box-shadow: inset 5px 0 0 rgba(148, 163, 184, 0.8);
  opacity: 0.82;
}

@keyframes airportRowEnter {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
/* Ajustes v1.3: botões do card de registros próximos e organizados. */
.recent-button-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.recent-button-group .button {
  margin: 0;
}

/* Ajustes v1.3: animação tipo painel de aeroporto para reordenação. */
.panel-row-enter {
  animation: airportRowEnter 0.45s ease both;
}

.panel-row-moved-up {
  animation: airportMoveUp 0.7s ease both;
}

.panel-row-moved-down {
  animation: airportMoveDown 0.7s ease both;
}

@keyframes airportMoveUp {
  from {
    transform: translateY(26px);
    filter: brightness(1.35);
  }
  to {
    transform: translateY(0);
    filter: brightness(1);
  }
}

@keyframes airportMoveDown {
  from {
    transform: translateY(-26px);
    filter: brightness(1.2);
  }
  to {
    transform: translateY(0);
    filter: brightness(1);
  }
}

@media (max-width: 640px) {
  .recent-button-group {
    justify-content: flex-start;
  }
}
