:root {
  --background: #f4f9fc;
  --background-alt: #eef6fb;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --text: #12263a;
  --muted: #4d6275;
  --subtle: #7b8a98;
  --border: rgba(52, 101, 164, 0.16);
  --brand: #3465a4;
  --brand-deep: #0f3a55;
  --brand-action: #2f80ed;
  --clinical: #20b8bd;
  --success: #2dbe7e;
  --warning: #f4b942;
  --danger: #d84a4a;
  --shadow: 0 22px 60px rgba(15, 58, 85, 0.14);
  --glass-blur: blur(18px) saturate(135%);
  --ouro-azul-a: #eefaff;
  --ouro-azul-b: #76c9ee;
  --ouro-azul-c: #0072a9;
  --ouro-azul-d: #00427e;
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  color: var(--text);
  background:
    radial-gradient(circle at 12% 12%, rgba(32, 184, 189, 0.22), transparent 34%),
    radial-gradient(circle at 82% 18%, rgba(52, 101, 164, 0.22), transparent 32%),
    linear-gradient(135deg, var(--background) 0%, #fbfdff 48%, var(--background-alt) 100%);
  overflow: hidden;
}

button,
a {
  font: inherit;
}

.app-shell {
  width: 100dvw;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: clamp(8px, 1.2dvh, 16px);
  padding: clamp(10px, 1.6dvw, 24px);
  overflow: hidden;
}

.topbar,
.wait-card,
.notice-bar {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.62);
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass-blur);
}

.topbar {
  min-height: 76px;
  border-radius: 22px;
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(280px, 1.4fr) minmax(250px, 0.8fr);
  align-items: center;
  gap: clamp(12px, 2dvw, 26px);
  padding: clamp(10px, 1.2dvw, 16px) clamp(14px, 1.8dvw, 24px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand.has-logo {
  width: 100%;
  min-height: clamp(70px, 9dvh, 92px);
  height: auto;
  gap: 0;
  overflow: visible;
}

.brand-logo-frame {
  width: clamp(52px, 6dvw, 74px);
  height: clamp(52px, 6dvw, 74px);
  border-radius: 18px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  color: #fff;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--border);
  box-shadow: 0 14px 28px rgba(52, 101, 164, 0.24);
}

.brand-logo-frame.has-logo {
  width: min(100%, 380px);
  height: clamp(68px, 8.5dvh, 90px);
  max-height: none;
  overflow: visible;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  background: transparent;
  border-color: transparent;
  border-radius: 0;
  box-shadow: none;
}

.brand-logo,
.brand-logo-fallback {
  width: 100%;
  height: 100%;
}

.brand-logo {
  object-fit: contain;
  padding: 6px;
}

.brand-logo-frame.has-logo .brand-logo {
  display: block;
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  padding: 0;
  object-fit: contain;
  object-position: left center;
}

.brand-logo-fallback {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--clinical));
  font-size: clamp(24px, 3dvw, 34px);
}

.brand-logo-fallback[hidden],
.brand.has-logo .brand-logo-fallback {
  display: none;
}

.brand-text {
  min-width: 0;
}

.brand.has-logo .brand-text {
  display: none;
}

.brand-text strong,
.brand-text span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-text strong {
  font-size: 15px;
  color: var(--brand-deep);
}

.brand-text span {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.status-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 42px;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--brand-deep);
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  min-width: 0;
}

.status-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
}

.status-update {
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.05;
}

.status-update span {
  color: var(--subtle);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

.status-update strong {
  color: var(--brand-deep);
  font-size: 12px;
  font-weight: 700;
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 7px rgba(45, 190, 126, 0.14);
  animation: pulse 1.8s ease-in-out infinite;
}

.tts-widget {
  position: fixed;
  right: clamp(12px, 2dvw, 24px);
  top: 50%;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: calc(100dvw - 24px);
  border-radius: 999px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 12px 34px rgba(15, 58, 85, 0.18);
  backdrop-filter: var(--glass-blur);
  transform: translateY(-50%);
  touch-action: none;
}

.tts-widget[hidden] {
  display: none;
}

.tts-widget.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.tts-button {
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-action), var(--clinical));
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.tts-button[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--brand-deep), var(--clinical));
}

.tts-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.tts-close {
  width: 26px;
  height: 26px;
  min-height: 0;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.main-stage {
  min-height: 0;
  display: grid;
  grid-template-rows: 1fr;
  gap: clamp(8px, 1.1dvh, 14px);
}

.topbar > *,
.card-heading > div {
  min-width: 0;
}

.caption {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: var(--brand-deep);
  font-size: clamp(22px, 2.4dvw, 34px);
  line-height: 1.02;
  overflow-wrap: anywhere;
}

.intro-text {
  max-width: 780px;
  margin-top: 4px;
  color: var(--muted);
  font-size: clamp(12px, 1.1dvw, 14px);
  line-height: 1.3;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(128px, 1fr));
  gap: 10px;
}

.meta-grid div {
  min-height: 74px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid var(--border);
}

.meta-grid span,
.unit-metrics dt {
  display: block;
  color: var(--subtle);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.meta-grid strong {
  display: block;
  margin-top: 7px;
  color: var(--brand-deep);
  font-size: 14px;
}

.content-area {
  min-height: 0;
  display: grid;
  grid-template-rows: 1fr;
  gap: 8px;
}

.unit-tabs {
  display: none;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.unit-tab {
  min-height: 40px;
  white-space: nowrap;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 14px;
  color: var(--brand-deep);
  background: rgba(255, 255, 255, 0.64);
  font-size: 13px;
  font-weight: 700;
}

.unit-tab[aria-selected="true"] {
  color: #fff;
  background: var(--brand);
}

.cards-grid {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: clamp(12px, 1.6dvw, 20px);
  overflow: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
  align-items: stretch;
}

.wait-card {
  --level: var(--brand);
  min-width: 0;
  min-height: 0;
  border-radius: 28px;
  padding: clamp(12px, 1.4dvw, 18px);
  display: grid;
  grid-template-rows: auto minmax(193px, 1fr) auto auto;
  gap: clamp(8px, 1dvh, 12px);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.wait-card::before {
  content: "";
  position: absolute;
  inset: -120px -90px auto auto;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--level) 22%, transparent);
  opacity: 0.8;
}

.wait-card.is-active {
  border-color: color-mix(in srgb, var(--level) 42%, rgba(255, 255, 255, 0.62));
  box-shadow: 0 22px 58px rgba(15, 58, 85, 0.18);
}

.wait-card:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--level) 48%, #ffffff);
  outline-offset: 3px;
}

.card-heading {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.unit-code {
  display: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.card-heading h2 {
  margin-top: 5px;
  color: var(--brand-deep);
  font-size: clamp(18px, 2dvw, 25px);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.level-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 8px 11px;
  color: var(--level);
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
}

.orbital-wrap {
  position: relative;
  z-index: 1;
  width: min(315px, 47dvh, 98%);
  aspect-ratio: 1;
  margin-top: 2px;
  place-self: center;
  display: grid;
  place-items: center;
  isolation: isolate;
}

.orbital,
.ring,
.tick-field {
  position: absolute;
  border-radius: 50%;
}

.orbital {
  inset: 0;
  border: 1px solid transparent;
  background:
    linear-gradient(rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.08)) padding-box,
    conic-gradient(from 0deg, transparent, color-mix(in srgb, var(--level) 45%, transparent), rgba(255,255,255,0.24), transparent 72%) border-box;
  box-shadow: inset 0 0 54px rgba(255, 255, 255, 0.28), 0 24px 56px rgba(15, 58, 85, 0.12);
  animation: rotate var(--speed, 7s) linear infinite;
  filter: blur(4px) saturate(125%);
}

.ring {
  border: 1px solid rgba(255, 255, 255, 0.38);
  background: conic-gradient(from 90deg, transparent 0 56%, color-mix(in srgb, var(--level) 26%, transparent) 65%, transparent 82%);
  mask: radial-gradient(circle, transparent 58%, rgba(0,0,0,0.72) 59% 62%, transparent 64%);
  -webkit-mask: radial-gradient(circle, transparent 58%, rgba(0,0,0,0.72) 59% 62%, transparent 64%);
  animation: rotate calc(var(--speed, 7s) * 1.45) linear infinite reverse;
}

.ring-one {
  inset: 10%;
}

.ring-two {
  inset: 22%;
  opacity: 0.56;
}

.tick-field {
  inset: 5%;
  background: repeating-conic-gradient(from 0deg, rgba(15, 58, 85, 0.13) 0deg 1.2deg, transparent 1.2deg 12deg);
  mask: radial-gradient(circle, transparent 70%, #000 71% 72.5%, transparent 73.5%);
  -webkit-mask: radial-gradient(circle, transparent 70%, #000 71% 72.5%, transparent 73.5%);
  opacity: 0.34;
}

.center-glass {
  position: relative;
  z-index: 2;
  width: 90%;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  padding: 5px;
  background:
    radial-gradient(circle at 32% 18%, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.38) 36%, transparent 58%),
    radial-gradient(circle, rgba(255,255,255,0.90), color-mix(in srgb, var(--level) 14%, #ffffff) 100%);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.76), 0 28px 54px rgba(0, 42, 82, 0.12);
}

.center-glass > * {
  max-width: 100%;
  min-width: 0;
}

.center-glass span {
  color: var(--subtle);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.time-value {
  display: block;
  margin-top: 6px;
  /* color: var(--brand-deep); */
  font-size: clamp(61px, 8.5dvw, 95px);
  line-height: 0.95;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: transparent;
  background: linear-gradient(145deg, var(--ouro-azul-a) 0%, var(--ouro-azul-b) 24%, var(--ouro-azul-c) 52%, var(--ouro-azul-d) 78%, #d9f5ff 100%);
  background-clip: text;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.82), 0 2px 0 rgba(255, 255, 255, 0.34), 0 8px 18px rgba(0, 66, 126, 0.7), 0 18px 36px rgba(0, 114, 169, 0.16);
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.72)) drop-shadow(0 10px 16px rgba(0, 66, 126, 0.18));
}

.time-description {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.15;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.flow-block,
.maps-link {
  position: relative;
  z-index: 1;
}

.flow-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.flow-value {
  color: var(--brand-deep);
}

.flow-track {
  height: 10px;
  margin-top: 9px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(52, 101, 164, 0.12);
}

.flow-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--clinical));
  transition: width 500ms ease;
}

.flow-description {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.maps-link {
  min-height: 40px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  color: #fff;
  background: var(--brand-deep);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  padding: 0 14px;
}

.maps-logo {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 8px;
  object-fit: contain;
  padding: 3px;
  background: rgba(255, 255, 255, 0.86);
}

.maps-icon {
  flex: 0 0 auto;
}

.maps-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: anywhere;
}

@media (min-width: 641px) {
  .maps-text {
    white-space: nowrap;
  }
}

.maps-link[aria-disabled="true"] {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.48);
  pointer-events: none;
}

.notice-bar {
  min-height: 44px;
  border-radius: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--muted);
  font-size: 12px;
}

.public-credit {
  justify-self: end;
  color: rgba(77, 98, 117, 0.62);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: right;
  white-space: nowrap;
  mix-blend-mode: multiply;
}

.empty-state,
.maintenance-state {
  grid-column: 1 / -1;
  align-self: stretch;
  border-radius: 28px;
  display: grid;
  place-items: center;
  padding: 28px;
  text-align: center;
  color: var(--muted);
  background: var(--surface-strong);
  border: 1px solid var(--border);
}

.empty-state strong,
.maintenance-state strong {
  display: block;
  margin-bottom: 8px;
  color: var(--brand-deep);
  font-size: 22px;
}

@keyframes rotate {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.76; }
  50% { transform: scale(1.18); opacity: 1; }
}

@media (max-width: 1023px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }

  .status-strip {
    width: 100%;
    justify-content: space-between;
  }

  .unit-tabs {
    display: flex;
  }

  .content-area {
    grid-template-rows: auto 1fr;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }

  .wait-card {
    display: none;
    cursor: default;
  }

  .wait-card.is-active {
    display: grid;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 10px;
    gap: 6px;
  }

  .topbar {
    min-height: 0;
    border-radius: 18px;
    gap: 8px;
    grid-template-columns: minmax(0, 1fr);
    padding: 10px;
  }

  .brand-logo-frame {
    width: 42px;
    height: 42px;
    border-radius: 14px;
  }

  .brand-text strong {
    max-width: 206px;
    font-size: 13px;
  }

  .brand-text span {
    max-width: 206px;
    font-size: 11px;
  }

  .tts-widget {
    right: 10px;
  }

  .tts-label {
    display: none;
  }

  .tts-button {
    min-height: 32px;
    padding: 0 9px;
    font-size: 12px;
  }

  .status-strip {
    grid-column: 1 / -1;
    min-height: 30px;
    padding: 4px 10px;
    font-size: 11px;
    gap: 7px;
    border-radius: 16px;
    flex-wrap: wrap;
  }

  .status-update strong {
    font-size: 11px;
  }

  .main-stage,
  .content-area {
    gap: 6px;
  }

  h1 {
    font-size: 18px;
    line-height: 1.08;
  }

  .intro-text {
    font-size: 11px;
  }

  .meta-grid {
    grid-template-columns: 1fr 1fr;
  }

  .meta-grid div {
    min-height: 48px;
    padding: 8px 10px;
  }

  .meta-grid span {
    font-size: 9px;
  }

  .meta-grid strong {
    margin-top: 5px;
    font-size: 12px;
  }

  .unit-tab {
    min-height: 32px;
    padding: 0 12px;
    font-size: 12px;
  }

  .wait-card {
    border-radius: 22px;
    padding: 12px;
    grid-template-rows: auto auto auto auto;
    gap: 7px;
  }

  .card-heading h2 {
    font-size: 18px;
  }

  .unit-code {
    font-size: 10px;
  }

  .level-pill {
    padding: 6px 9px;
    font-size: 11px;
  }

  .orbital-wrap {
    width: min(222px, 39dvh, 79%);
    margin-top: 0;
  }

  .time-value {
    margin-top: 3px;
    font-size: 51px;
  }

  .center-glass {
    padding: 14px;
  }

  .center-glass span {
    font-size: 10px;
  }

  .time-description {
    margin-top: 5px;
    font-size: 16px;
  }

  .flow-header,
  .maps-link,
  .flow-description {
    font-size: 11px;
  }

  .flow-track {
    height: 8px;
    margin-top: 6px;
  }

  .maps-link {
    min-height: 36px;
    padding: 0 10px;
    border-radius: 20px;
    line-height: 1.25;
    text-align: center;
  }

  .maps-text {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .notice-bar {
    min-height: 30px;
    border-radius: 16px;
    padding: 6px 10px;
    grid-template-columns: 1fr;
    font-size: 10px;
    line-height: 1.35;
  }

  .public-credit {
    justify-self: start;
    white-space: normal;
  }
}

@media (max-height: 760px) and (min-width: 1024px) {
  .intro-text {
    display: none;
  }

  .wait-card {
    grid-template-rows: auto minmax(156px, 1fr) auto auto;
    gap: 7px;
  }

  .orbital-wrap {
    width: min(232px, 39dvh, 82%);
  }

}

@media (max-height: 920px) and (min-width: 1024px) {
  .app-shell {
    gap: 8px;
    padding-block: 14px;
  }

  .wait-card {
    grid-template-rows: auto auto auto auto;
    gap: 7px;
  }

  .maps-link {
    min-height: 38px;
  }
}

@media (max-height: 860px) and (max-width: 1023px) {
  .topbar {
    padding-block: 8px;
  }

  .intro-text,
  .caption {
    display: none;
  }

  h1 {
    font-size: 28px;
    line-height: 1.05;
  }

  .wait-card {
    gap: 6px;
  }

  .orbital-wrap {
    width: min(199px, 35dvh, 71%);
  }

  .time-value {
    font-size: 47px;
  }

  .maps-link {
    min-height: 34px;
  }
}

@media (max-height: 860px) and (min-width: 641px) and (max-width: 1023px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .status-strip {
    width: auto;
  }

  .intro-copy {
    grid-column: 1 / -1;
  }

  .meta-grid div {
    min-height: 56px;
    padding: 10px 12px;
  }

  .orbital-wrap {
    width: min(175px, 32dvh, 63%);
  }
}

@media (max-height: 860px) and (max-width: 640px) {
  h1 {
    font-size: 20px;
    width: min(18ch, 100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
