:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #0f172a;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warn: #854d0e;
  --warn-soft: #fef3c7;
  --success: #16a34a;
}

* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
  min-height: 100vh;
}

/* Removido o efeito de grid de pontos no fundo para maior discrição */
body::before {
  display: none;
}

.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 23, 42, 0.96);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: white;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.55rem;
  align-items: center;
  padding: 0.55rem clamp(0.45rem, 1vw, 0.85rem);
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
}

.brand {
  display: inline-flex;
  gap: 0.55rem;
  align-items: center;
  color: inherit;
  text-decoration: none;
  min-width: 10rem;
}
.brand-badge {
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border-radius: 0.5rem;
  background: var(--accent);
  font-weight: 700;
  box-shadow: none;
}
.brand strong {
  display: block;
  line-height: 1;
  font-size: 1.02rem;
}
.brand small {
  display: block;
  color: #94a3b8;
  font-size: 0.68rem;
  margin-top: 0.15rem;
}

.routes {
  display: flex;
  align-items: center;
  gap: 0.32rem;
  justify-content: center;
  flex-wrap: wrap;
}
.routes a {
  color: #cbd5e1;
  text-decoration: none;
  border: 1px solid transparent;
  padding: 0.46rem 0.68rem;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.82rem;
  transition:
    background 0.2s ease,
    color 0.2s ease;
}
.routes a:hover,
.routes a.active {
  color: white;
  background: rgba(255, 255, 255, 0.1);
  border-color: transparent;
  transform: none;
  box-shadow: none;
}

.menu-toggle {
  display: none;
}
.toolbar {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 0.7fr 1.6fr 0.9fr minmax(13rem, 1.25fr) auto;
  gap: 0.5rem;
  align-items: end;
  animation: slideDown 0.2s ease both;
}
.toolbar label,
.modal-grid label {
  display: grid;
  gap: 0.22rem;
}
.toolbar span,
.modal-grid span {
  color: #94a3b8;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
select,
input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 0.5rem;
  background: rgba(30, 41, 59, 0.95);
  color: white;
  outline: none;
  padding: 0.6rem 0.68rem;
  font-size: 0.86rem;
  transition: border-color 0.2s ease;
}
select:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: none;
}
input::placeholder {
  color: #64748b;
}
.btn {
  border: 0;
  border-radius: 0.5rem;
  padding: 0.68rem 0.92rem;
  cursor: pointer;
  font-weight: 600;
  transition:
    background 0.2s ease,
    filter 0.2s ease;
  white-space: nowrap;
}
.btn:hover {
  filter: brightness(1.05);
  box-shadow: none;
}
.btn:active {
  transform: scale(0.98);
}
.btn.primary {
  background: var(--accent);
  color: white;
}
.btn.ghost {
  background: var(--card);
  color: var(--primary);
  border: 1px solid var(--line);
}

.page {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0.55rem clamp(0.28rem, 0.65vw, 0.58rem) 4.25rem;
}
.hero,
.stats article,
.route-panel {
  position: relative;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  animation: softIn 0.25s ease both;
}

/* Ocultadas as marcas d'água gigantes de fundo para um visual mais limpo */
.hero::after,
.stats article::after,
.route-panel::after,
.mes-card::after,
.notes article::after,
.city-card::after,
.hero::before,
.stats article::before,
.route-panel::before,
.mes-card::before,
.notes article::before,
.city-card::before {
  display: none !important;
}

.hero {
  border-radius: 0.75rem;
  padding: 0.85rem;
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}
.eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 700;
  margin: 0 0 0.2rem;
}
.hero h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2.4vw, 2.1rem);
  font-weight: 700;
}
.hero p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}
.hero-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin: 0.55rem 0;
}
.stats article {
  border-radius: 0.75rem;
  padding: 0.75rem 0.85rem;
}
.stats strong {
  display: block;
  font-size: 1.42rem;
  font-weight: 700;
}
.stats span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.route-panel {
  border-radius: 0.75rem;
  padding: 0.65rem;
  min-height: 18rem;
}
.route-panel:not(.hidden) {
  animation: routeIn 0.2s ease both;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 0.8rem;
  margin-bottom: 0.65rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.58rem;
}
.section-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}
.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  max-width: 52rem;
}

.grid-calendario {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.48rem;
}
.mes-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0.52rem;
  background: var(--card);
  transition: border-color 0.2s ease;
}
.mes-card:hover {
  border-color: #cbd5e1;
  box-shadow: none;
  transform: none;
}
.mes-card h3 {
  margin: 0 0 0.45rem;
  background: #f1f5f9;
  color: var(--ink);
  border-radius: 0.5rem;
  padding: 0.42rem;
  text-align: center;
  text-transform: uppercase;
  font-size: 0.76rem;
  font-weight: 700;
}
.dias-semana,
.dias-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.15rem;
  text-align: center;
}
.dias-semana b {
  color: #94a3b8;
  font-size: 0.66rem;
  padding-bottom: 0.14rem;
}
.dia {
  min-height: 1.72rem;
  padding: 0.19rem 0.05rem;
  display: grid;
  place-items: center;
  border-radius: 0.37rem;
  position: relative;
  font-weight: 600;
  font-size: 0.74rem;
  transition: background 0.15s ease;
}
.dia:hover:not(.vazio) {
  background: #f1f5f9;
  transform: none;
  z-index: auto;
}
.dia small {
  position: absolute;
  right: 0.08rem;
  bottom: 0.03rem;
  font-size: 0.49rem;
  min-width: 0.75rem;
  height: 0.75rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
}
.feriado-dia {
  background: var(--danger-soft);
  color: var(--danger);
}
.ponto-dia {
  background: var(--warn-soft);
  color: var(--warn);
}
.vazio {
  visibility: hidden;
}

.tabela-wrapper {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  background: white;
}
th {
  background: #f8fafc;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.68rem;
  text-align: left;
  padding: 0.72rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td {
  padding: 0.7rem 0.72rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
}
tr {
  transition: background 0.15s ease;
}
tr:hover td {
  background: #f8fafc;
}
.event-name {
  font-weight: 600;
}
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.24rem 0.5rem;
  font-weight: 700;
  font-size: 0.72rem;
  white-space: nowrap;
}
.badge-feriado {
  background: var(--danger-soft);
  color: var(--danger);
}
.badge-ponto {
  background: var(--warn-soft);
  color: var(--warn);
}
.empty {
  margin-top: 0.8rem;
  padding: 1rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 0.75rem;
}

.city-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.5rem;
}
.city-card {
  position: relative;
  overflow: hidden;
  text-align: left;
  background: white;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0.7rem;
  display: grid;
  gap: 0.18rem;
  cursor: pointer;
  transition: border-color 0.2s ease;
}
.city-card:hover,
.city-card.active {
  border-color: var(--accent);
  box-shadow: none;
  transform: none;
}
.city-card strong {
  font-size: 0.9rem;
  font-weight: 600;
}
.city-card span {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.74rem;
}
.city-card small {
  color: var(--muted);
}
.notes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.55rem;
}
.notes article {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0.8rem;
  background: #fff;
}
.notes h3 {
  margin: 0 0 0.35rem;
  font-weight: 700;
}
.notes p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}
code {
  background: #f1f5f9;
  border-radius: 0.25rem;
  padding: 0.08rem 0.28rem;
  color: var(--primary);
}
.hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.4);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease both;
}
.modal-card {
  width: min(720px, 100%);
  border-radius: 0.75rem;
  background: white;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  padding: 1rem;
  animation: modalIn 0.2s ease both;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.7rem;
}
.modal-head h2 {
  margin: 0;
  font-weight: 700;
}
.modal-head p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}
.modal-close {
  border: 0;
  background: #f1f5f9;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
}
.modal-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
  margin-top: 0.85rem;
}
.modal-grid span {
  color: var(--muted);
}
.modal-grid select,
.modal-grid input {
  background: #f8fafc;
  color: var(--ink);
  border-color: var(--line);
}
.modal-preview {
  margin-top: 0.85rem;
  border: 1px solid #bfdbfe;
  border-radius: 0.5rem;
  padding: 0.75rem;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}
.modal-preview strong {
  font-size: 1.5rem;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-top: 0.85rem;
}

.assinatura-fixa {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0.45rem;
  z-index: 30;
  display: flex;
  justify-content: center;
  pointer-events: none;
  padding: 0 0.6rem;
}
.assinatura-pill {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  max-width: min(94vw, 760px);
  padding: 0.42rem 0.55rem 0.42rem 0.42rem;
  border-radius: 0.5rem;
  color: var(--muted);
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  transition:
    color 0.2s ease,
    border-color 0.2s ease;
  animation: footerFloat 0.3s ease both;
}
.assinatura-pill:hover {
  transform: none;
  background: var(--card);
  border-color: #cbd5e1;
  color: var(--ink);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}
.assinatura-dot {
  width: 1.5rem;
  height: 1.5rem;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 0.25rem;
  background: #e2e8f0;
  color: var(--primary);
  font-weight: 700;
  font-size: 0.78rem;
}
.assinatura-pill span:not(.assinatura-dot) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
}
.assinatura-pill strong {
  color: var(--ink);
  font-weight: 600;
}
.assinatura-pill em {
  flex: 0 0 auto;
  font-style: normal;
  font-weight: 700;
  font-size: 0.76rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 0.25rem;
  padding: 0.15rem 0.4rem;
}

/* Animações simplificadas e menos espalhafatosas */
@keyframes softIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes routeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
@keyframes footerFloat {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1280px) {
  .grid-calendario {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
@media (max-width: 980px) {
  .appbar {
    grid-template-columns: 1fr auto;
  }
  .routes {
    grid-column: 1 / -1;
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.1rem;
  }
  .toolbar {
    grid-template-columns: 1fr 1fr;
  }
  .toolbar .search-box {
    grid-column: 1 / -1;
  }
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .hero {
    align-items: flex-start;
    flex-direction: column;
  }
  .grid-calendario {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 760px) {
  .grid-calendario {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dia {
    min-height: 1.62rem;
    font-size: 0.68rem;
  }
}
@media (max-width: 680px) {
  .appbar {
    grid-template-columns: 1fr auto;
    padding: 0.5rem;
    gap: 0.45rem;
    align-items: center;
  }
  .brand {
    min-width: 0;
  }
  .brand-badge {
    width: 2rem;
    height: 2rem;
    border-radius: 0.37rem;
  }
  .brand strong {
    font-size: 0.95rem;
  }
  .brand small {
    display: none;
  }
  .menu-toggle {
    display: inline-grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.08);
    color: white;
    font-size: 1.05rem;
  }
  .routes {
    grid-column: 1 / -1;
    order: 3;
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding: 0.08rem 0.02rem 0.12rem;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }
  .routes::-webkit-scrollbar {
    display: none;
  }
  .routes a {
    flex: 0 0 auto;
    scroll-snap-align: start;
    padding: 0.42rem 0.58rem;
    font-size: 0.76rem;
    border-radius: 0.37rem;
  }
  .toolbar {
    display: none;
    grid-template-columns: 1fr;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 0.45rem;
  }
  .toolbar.open {
    display: grid;
  }
  .page {
    padding: 0.42rem 0.28rem 4.4rem;
  }
  .hero {
    border-radius: 0.5rem;
    padding: 0.72rem;
  }
  .stats {
    grid-template-columns: 1fr 1fr;
    gap: 0.36rem;
  }
  .stats article {
    padding: 0.62rem;
    border-radius: 0.5rem;
  }
  .section-head {
    display: block;
  }
  .section-head p {
    margin-top: 0.3rem;
  }
  .hero-actions {
    width: 100%;
  }
  .hero-actions .btn {
    flex: 1;
  }
  .grid-calendario {
    display: flex;
    grid-template-columns: none;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.1rem 0.12rem 0.75rem;
    margin: 0 -0.12rem;
    scroll-snap-type: x mandatory;
    scroll-padding-left: 0.12rem;
    -webkit-overflow-scrolling: touch;
  }
  .grid-calendario::after {
    content: "";
    flex: 0 0 0.1rem;
  }
  .mes-card {
    flex: 0 0 min(88vw, 360px);
    scroll-snap-align: center;
    padding: 0.5rem;
    border-radius: 0.5rem;
  }
  .dia {
    min-height: 1.76rem;
  }
  table {
    font-size: 0.78rem;
  }
  th,
  td {
    padding: 0.6rem;
  }
  .modal-grid {
    grid-template-columns: 1fr;
  }
  .modal-actions .btn {
    width: 100%;
  }
  .assinatura-pill {
    max-width: calc(100vw - 0.7rem);
    padding: 0.36rem 0.45rem 0.36rem 0.36rem;
    border-radius: 0.5rem;
  }
  .assinatura-pill span:not(.assinatura-dot) {
    font-size: 0.72rem;
  }
  .assinatura-pill em {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
