:root {
  --ink: #12110f;
  --paper: #f3efe6;
  --amber: #e8a317;
  --amber-deep: #c47f00;
  --line: rgba(18, 17, 15, 0.12);
  --muted: rgba(18, 17, 15, 0.62);
  --panel: rgba(255, 252, 245, 0.78);
  --shadow: 0 24px 60px rgba(18, 17, 15, 0.14);
  --font-display: "Bebas Neue", sans-serif;
  --font-body: "Manrope", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  overflow-x: clip;
  width: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(232, 163, 23, 0.28), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(18, 17, 15, 0.18), transparent 50%),
    linear-gradient(165deg, #f7f2e8 0%, #e7e0d2 48%, #d9d1c0 100%);
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.hero, main, footer { position: relative; z-index: 1; }

.hero {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 1.25rem;
  padding: clamp(1.25rem, 3.5vw, 2.75rem);
  padding-bottom: 1rem;
  animation: rise 0.9s ease both;
}
.hero-top {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 1.25rem 2rem;
  align-items: end;
}
.hero-inner { max-width: 36rem; }

.brand {
  margin: 0 0 0.45rem;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 6.5vw, 4rem);
  letter-spacing: 0.06em;
  line-height: 0.95;
  color: var(--ink);
  animation: brandIn 1s ease both;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.15rem, 2.2vw, 1.55rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  max-width: 22ch;
  line-height: 1.25;
}

.lead {
  margin: 0.75rem 0 1.2rem;
  color: var(--muted);
  font-size: 1rem;
  max-width: 40ch;
  line-height: 1.5;
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

.hero-live {
  margin: 0;
  align-self: end;
  padding: 0.95rem 1.05rem;
  border-radius: 1rem;
  border: 1px solid rgba(18, 17, 15, 0.1);
  background: rgba(255, 253, 248, 0.72);
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.45;
  animation: fadeUp 0.9s ease 0.1s both;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.75rem 1.25rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary {
  background: var(--ink);
  color: var(--paper);
}
.btn.primary:hover { background: #000; }
.btn.ghost {
  background: transparent;
  border-color: rgba(18, 17, 15, 0.28);
  color: var(--ink);
}

.tower {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  min-height: 0;
  animation: fadeUp 0.85s ease 0.12s both;
}
.tower-filters {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(8rem, 12rem) minmax(8rem, 12rem) 1fr;
  gap: 0.75rem 1rem;
  align-items: end;
}
.tower-filters label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.tower-filters select {
  width: 100%;
  border: 1px solid rgba(18, 17, 15, 0.18);
  border-radius: 0.7rem;
  padding: 0.65rem 0.75rem;
  font: inherit;
  background: #fffdf8;
  color: var(--ink);
}
.tower-unit {
  margin: 0;
  align-self: end;
  color: var(--muted);
  font-size: 0.86rem;
  padding-bottom: 0.35rem;
}
.tower-unit b { color: var(--ink); }
.tower-uni {
  margin: -0.35rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.tower-trio {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  padding: 0.75rem 0.8rem;
  border-radius: 0.85rem;
  border: 1px solid var(--line);
  background: rgba(232, 163, 23, 0.08);
}
.tower-trio b {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  letter-spacing: 0.03em;
  line-height: 0.95;
}
.tower-trio em {
  display: block;
  margin-top: 0.15rem;
  font-style: normal;
  font-size: 0.75rem;
  color: var(--muted);
}
#tw-saldo-wrap.is-up b { color: #1f6b3a; }
#tw-saldo-wrap.is-down b { color: #9a3412; }
.tower-card {
  background: rgba(255, 253, 248, 0.86);
  border: 1px solid rgba(18, 17, 15, 0.1);
  border-radius: 1.15rem;
  padding: 1rem 1.1rem 1.05rem;
  box-shadow: var(--shadow);
  display: grid;
  gap: 0.85rem;
  align-content: start;
}
.tower-card header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}
.tower-card header strong {
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.04em;
}
.tower-big {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.tower-big b {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  letter-spacing: 0.03em;
  line-height: 0.95;
}
.tower-mini {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1rem;
  color: var(--muted);
  font-size: 0.86rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--line);
}
.tower-mini b { color: var(--ink); font-weight: 700; }
.tower-spark {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: end;
  gap: 0.28rem;
  height: 3.4rem;
  padding-top: 0.2rem;
}
.tower-spark i {
  display: block;
  width: 100%;
  border-radius: 0.35rem 0.35rem 0.15rem 0.15rem;
  background: linear-gradient(180deg, #e8a317, #9a6a00);
  min-height: 0.25rem;
  opacity: 0.9;
}
.tower-spark i.is-peak {
  background: linear-gradient(180deg, #12110f, #3a3428);
}

.hero-foot {
  display: grid;
  gap: 0.75rem;
}
.hero-strip {
  margin: 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
  font-size: 0.92rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: baseline;
}
.hero-strip span:not(.dot) {
  font-family: var(--font-display);
  font-size: 1.45rem;
  color: var(--amber-deep);
  letter-spacing: 0.03em;
}

.scroll-cue {
  appearance: none;
  border: 1px dashed rgba(18, 17, 15, 0.28);
  background: rgba(255, 253, 248, 0.55);
  border-radius: 999px;
  padding: 0.7rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  animation: cuePulse 1.8s ease-in-out infinite;
}
.scroll-cue:hover { background: rgba(255, 253, 248, 0.9); }
.scroll-arrow {
  width: 0.7rem;
  height: 0.7rem;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: rotate(45deg);
  animation: arrowBounce 1.4s ease-in-out infinite;
}
@keyframes cuePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232, 163, 23, 0); }
  50% { box-shadow: 0 0 0 6px rgba(232, 163, 23, 0.12); }
}
@keyframes arrowBounce {
  0%, 100% { transform: translateY(0) rotate(45deg); }
  50% { transform: translateY(4px) rotate(45deg); }
}

@media (max-width: 900px) {
  .hero-top,
  .tower { grid-template-columns: 1fr; }
  .tower-filters { grid-template-columns: 1fr 1fr; }
  .tower-unit { grid-column: 1 / -1; }
  .tower-trio { grid-template-columns: 1fr; }
  .hero { min-height: auto; }
}

main {
  padding: 0 clamp(1.5rem, 4vw, 3.5rem) 4rem;
  display: grid;
  gap: 2.5rem;
  min-width: 0;
  max-width: 100%;
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(18, 17, 15, 0.08);
  border-radius: 1.25rem;
  padding: clamp(1.2rem, 2.5vw, 2rem);
  box-shadow: var(--shadow);
  animation: fadeUp 0.7s ease both;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.1rem);
  letter-spacing: 0.04em;
  line-height: 1;
}
.panel-head p {
  margin: 0.35rem 0 1.25rem;
  color: var(--muted);
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem 1rem;
  margin-bottom: 1.1rem;
  align-items: end;
}
.filters label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.filters input,
.filters select {
  width: 100%;
  border: 1px solid rgba(18, 17, 15, 0.18);
  border-radius: 0.7rem;
  padding: 0.7rem 0.8rem;
  font: inherit;
  background: #fffdf8;
  color: var(--ink);
}

.pulse {
  margin: 0 0 1.1rem;
  padding: 1rem 1.1rem 1.05rem;
  border-radius: 1rem;
  border: 1px solid rgba(18, 17, 15, 0.1);
  background:
    linear-gradient(135deg, rgba(232, 163, 23, 0.12), transparent 42%),
    rgba(255, 253, 248, 0.92);
  animation: fadeUp 0.55s ease both;
}
.pulse-hero {
  display: grid;
  grid-template-columns: auto auto minmax(12rem, 1fr);
  gap: 1.25rem 1.75rem;
  align-items: end;
  margin-bottom: 1rem;
}
.pulse-block strong {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.7rem);
  letter-spacing: 0.03em;
  line-height: 0.95;
}
.pulse-block em {
  font-style: normal;
  color: var(--muted);
  font-size: 0.85rem;
}
.pulse-k {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.pulse-saldo.is-up strong { color: #1f6b3a; }
.pulse-saldo.is-down strong { color: #9a3412; }
.pulse-saldo.is-flat strong { color: var(--ink); }

.pulse-meter-wrap { min-width: 0; }
.pulse-track {
  display: flex;
  height: 0.85rem;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(18, 17, 15, 0.08);
  margin: 0.45rem 0 0.55rem;
}
.pulse-fill { height: 100%; transition: width 0.45s ease; }
.pulse-fill.above { background: #2f7d4a; }
.pulse-fill.alvo { background: var(--amber); }
.pulse-fill.below { background: #b45309; }
.pulse-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.1rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.pulse-legend .dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  margin-right: 0.25rem;
  vertical-align: middle;
}
.pulse-legend .dot.above { background: #2f7d4a; }
.pulse-legend .dot.alvo { background: var(--amber); }
.pulse-legend .dot.below { background: #b45309; }
.pulse-legend b { color: var(--ink); font-weight: 700; }

.pulse-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}
.pulse-stats strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.55rem;
  letter-spacing: 0.03em;
  line-height: 1;
  margin-top: 0.15rem;
}
.pulse-atest .pulse-stats { border-top: 0; padding-top: 0; }
.pulse-atest {
  display: grid;
  gap: 1rem;
}
.spark-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}
.spark-note {
  font-size: 0.82rem;
  color: var(--muted);
}
.spark-note b { color: var(--ink); font-weight: 700; }
.spark-chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(2.2rem, 1fr);
  align-items: end;
  gap: 0.45rem;
  min-height: 7.5rem;
  padding: 0.35rem 0.15rem 0;
  border-top: 1px dashed rgba(18, 17, 15, 0.12);
  position: relative;
}
.spark-avg-line {
  position: absolute;
  left: 2%;
  right: 2%;
  height: 0;
  border-top: 1.5px dashed rgba(196, 127, 0, 0.85);
  pointer-events: none;
  z-index: 1;
}
.spark-col {
  display: grid;
  grid-template-rows: 1fr auto auto;
  align-items: end;
  justify-items: center;
  gap: 0.25rem;
  height: 100%;
  min-height: 7rem;
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: inherit;
}
.spark-col:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
  border-radius: 0.4rem;
}
.spark-bar-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: end;
  justify-content: center;
  position: relative;
}
.spark-bar {
  width: 68%;
  max-width: 2rem;
  border-radius: 0.55rem 0.55rem 0.2rem 0.2rem;
  background: linear-gradient(180deg, #e8a317 0%, #9a6a00 100%);
  min-height: 0.35rem;
  transition: height 0.45s ease, transform 0.2s ease, filter 0.2s ease;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35);
}
.spark-col:hover .spark-bar,
.spark-col.is-hot .spark-bar {
  transform: translateY(-2px);
  filter: brightness(1.08);
}
.spark-col.is-dim .spark-bar {
  background: linear-gradient(180deg, rgba(18,17,15,0.22), rgba(18,17,15,0.12));
  filter: none;
  transform: none;
}
.spark-col.is-active .spark-bar {
  background: linear-gradient(180deg, #12110f 0%, #3a3428 100%);
}
.spark-val {
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  line-height: 1;
  color: var(--ink);
}
.spark-col.is-dim .spark-val { color: var(--muted); }
.spark-lab {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.spark-empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 1rem 0;
}

@media (max-width: 900px) {
  .pulse-hero { grid-template-columns: 1fr 1fr; }
  .pulse-meter-wrap { grid-column: 1 / -1; }
  .pulse-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  border-radius: 0.85rem;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.9);
  max-width: 100%;
  width: 100%;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  table-layout: auto;
}
th, td {
  padding: 0.55rem 0.55rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  white-space: nowrap;
}
td.nome {
  white-space: normal;
  min-width: 8rem;
  max-width: 14rem;
  line-height: 1.35;
  word-break: break-word;
}
/* Foco = motoristas: função some na UI de jornadas para caber as horas */
#table-horas th:nth-child(4),
#table-horas td:nth-child(4) {
  display: none;
}
th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: rgba(18, 17, 15, 0.03);
  position: sticky;
  top: 0;
  white-space: nowrap;
}
tbody tr:hover { background: rgba(232, 163, 23, 0.08); }
.hint { margin: 0.75rem 0 0; color: var(--muted); font-size: 0.9rem; }

button.link-nome {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(196, 127, 0, 0.55);
  text-underline-offset: 0.18em;
}
button.link-nome:hover {
  color: var(--amber-deep);
  text-decoration-color: var(--amber-deep);
}

.sheet[hidden] { display: none !important; }
.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  justify-items: end;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 17, 15, 0.42);
  backdrop-filter: blur(2px);
  animation: fadeUp 0.25s ease both;
}
.sheet-panel {
  position: relative;
  z-index: 1;
  width: min(42rem, 100vw);
  height: 100%;
  background: #fffdf8;
  border-left: 1px solid rgba(18, 17, 15, 0.12);
  box-shadow: -24px 0 60px rgba(18, 17, 15, 0.22);
  padding: 1.25rem 1.25rem 1.5rem;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 0.85rem;
  animation: sheetIn 0.28s ease both;
  overflow: hidden;
}
@keyframes sheetIn {
  from { transform: translateX(24px); opacity: 0.6; }
  to { transform: none; opacity: 1; }
}
.sheet-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}
.sheet-kicker {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.sheet-head h3 {
  margin: 0.2rem 0 0.25rem;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  letter-spacing: 0.03em;
  line-height: 1;
}
.sheet-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.sheet-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  padding: 0.75rem 0.85rem;
  border-radius: 0.85rem;
  border: 1px solid var(--line);
  background: rgba(232, 163, 23, 0.08);
}
@media (min-width: 520px) {
  .sheet-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.sheet-summary span {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.sheet-summary strong {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.03em;
}
.sheet-table {
  min-height: 0;
  overflow: auto;
}
.sheet-close { flex-shrink: 0; }

footer {
  padding: 1.5rem clamp(1.5rem, 4vw, 3.5rem) 2.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@keyframes brandIn {
  from { opacity: 0; transform: translateY(28px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 1100px) {
  #table-horas th:nth-child(6),
  #table-horas td:nth-child(6),
  #table-horas th:nth-child(9),
  #table-horas td:nth-child(9) {
    display: none;
  }
  #table-atestados th:nth-child(7),
  #table-atestados td:nth-child(7),
  #table-atestados th:nth-child(8),
  #table-atestados td:nth-child(8),
  #table-atestados th:nth-child(9),
  #table-atestados td:nth-child(9) {
    display: none;
  }
  td.nome { max-width: 11rem; }
}

@media (max-width: 700px) {
  #table-horas th:nth-child(5),
  #table-horas td:nth-child(5),
  #table-horas th:nth-child(7),
  #table-horas td:nth-child(7) {
    display: none;
  }
  td.nome { max-width: 9rem; }
}
