:root {
  --teal: #0f8f6f;
  --teal-deep: #0a5c4a;
  --teal-soft: #e6f6f0;
  --ink: #12201c;
  --muted: #5a6f68;
  --paper: #f2f7f5;
  --white: #fff;
  --danger: #c0392b;
  --line: rgba(15, 143, 111, 0.16);
  --shadow: 0 18px 50px rgba(10, 60, 48, 0.14);
  --radius: 20px;
  --font: Manrope, system-ui, sans-serif;
  --display: Sora, Manrope, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 480px at 100% -10%, rgba(15, 143, 111, 0.16), transparent 55%),
    radial-gradient(700px 400px at -5% 30%, rgba(15, 143, 111, 0.08), transparent 50%),
    linear-gradient(180deg, #f7fbf9, var(--paper));
  line-height: 1.45;
}

[hidden] { display: none !important; }
a { color: var(--teal-deep); font-weight: 700; text-decoration: none; }
a:hover { text-decoration: underline; }

.boot-error {
  margin: 1rem;
  padding: 1rem 1.15rem;
  border-radius: 14px;
  background: #fdecea;
  border: 1px solid #f5c6cb;
  color: #7a1f1a;
  font-size: 0.95rem;
}
.boot-error strong { display: block; margin-bottom: 0.35rem; }

.view { min-height: 100%; }
.muted { color: var(--muted); }
.fine { font-size: 0.88rem; color: var(--muted); margin-top: 1.25rem; }
.error { color: var(--danger); font-size: 0.92rem; font-weight: 600; margin: 0; }

.brand-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.brand-row img { object-fit: contain; }
.brand-row strong {
  display: block;
  font-family: var(--display);
  letter-spacing: -0.02em;
}
.brand-row span {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal-deep);
  font-weight: 800;
}
.brand-row.compact strong { font-size: 0.98rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  padding: 0.85rem 1.25rem;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.6; cursor: wait; transform: none; }
.btn-primary {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 12px 28px rgba(15, 143, 111, 0.28);
  width: 100%;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}
.btn.small { padding: 0.4rem 0.8rem; font-size: 0.82rem; width: auto; }
.btn-icon { white-space: nowrap; font-size: 0.82rem; padding: 0.45rem 0.85rem; }

/* —— Login —— */
.login-view {
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  width: min(420px, 100%);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  padding: 1.75rem 1.5rem;
  box-shadow: var(--shadow);
  animation: rise 0.55s ease both;
}
.login-card h1 {
  font-family: var(--display);
  font-size: 1.55rem;
  letter-spacing: -0.03em;
  margin: 1.25rem 0 0.4rem;
}
.login-card form {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.25rem;
}
.login-card label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.88rem;
  font-weight: 700;
}
.login-card input {
  font: inherit;
  padding: 0.8rem 0.95rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}
.login-card input:focus {
  outline: 2px solid rgba(15, 143, 111, 0.35);
  border-color: var(--teal);
}

/* —— Dash —— */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  background: rgba(247, 251, 249, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.user-chip {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-main {
  width: min(1500px, calc(100% - 2rem));
  margin: 1.25rem auto 2.5rem;
  display: grid;
  gap: 1rem;
}
.dash-layout {
  display: grid;
  gap: 1.25rem;
  align-items: stretch;
}
.dash-primary {
  display: grid;
  gap: 1rem;
  min-width: 0;
  align-content: start;
}
.dash-history {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}
.history-filter {
  font: inherit;
  width: 100%;
  margin-bottom: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}
.history-filter:focus {
  outline: 2px solid rgba(15, 143, 111, 0.35);
  border-color: var(--teal);
}
.card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem 1.25rem;
  box-shadow: 0 10px 28px rgba(10, 60, 48, 0.06);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.card-head h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.05rem;
}
.hero-status,
.monitor-card {
  display: grid;
  gap: 0.85rem;
}
.monitor-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.monitor-card h2 {
  margin: 0.15rem 0 0;
  font-family: var(--display);
  font-size: 1.45rem;
  letter-spacing: -0.02em;
}
.monitor-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: #fff3cd;
  color: #7a5b00;
}
.monitor-badge .badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.monitor-card[data-state="live"] .monitor-badge {
  background: var(--teal-soft);
  color: var(--teal-deep);
}
.monitor-card[data-state="live"] .badge-dot {
  animation: live-pulse 1.4s ease-in-out infinite;
  background: var(--teal);
  box-shadow: 0 0 0 0 rgba(15, 143, 111, 0.5);
}
.monitor-card[data-state="wait"] .monitor-badge {
  background: #fff3cd;
  color: #7a5b00;
}
.monitor-card[data-state="off"] .monitor-badge,
.monitor-card[data-state="error"] .monitor-badge {
  background: #fdecea;
  color: #9b1c1c;
}
.monitor-card[data-state="live"] {
  border-color: rgba(15, 143, 111, 0.35);
  box-shadow: 0 14px 36px rgba(15, 143, 111, 0.12);
}
.device-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.device-strip .chip {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f4f4f4;
  color: #777;
}
.device-strip .chip[data-on="1"] {
  background: var(--teal-soft);
  color: var(--teal-deep);
  border-color: rgba(15, 143, 111, 0.28);
}
.stat.highlight strong {
  color: var(--teal-deep);
}
.eyebrow {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal-deep);
}
.hero-status h2 {
  margin: 0.15rem 0 0.25rem;
  font-family: var(--display);
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}
.status-pulse {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #9aa;
}
.sound-toggle {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: 700;
  margin-top: 0.45rem;
}
.sound-toggle .muted {
  font-weight: 600;
  font-size: 0.78rem;
}
.sound-unlock {
  margin-top: 0.55rem;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  background: #fff8e6;
  border: 1px solid rgba(201, 133, 42, 0.35);
  display: grid;
  gap: 0.55rem;
}
.sound-unlock p {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 600;
  color: #7a5b00;
}
.principal-line {
  margin: 0.35rem 0 0.15rem;
  font-size: 0.86rem;
  font-weight: 600;
}

/* Modo TV — fonte grande, menos chrome */
body.tv-mode .dash-main {
  font-size: 1.15rem;
}
body.tv-mode .stat strong {
  font-size: clamp(2.2rem, 6vw, 3.2rem);
}
body.tv-mode .last-pix strong {
  font-size: clamp(2.6rem, 7vw, 3.8rem);
}
body.tv-mode .alert-value {
  font-size: clamp(3.5rem, 12vw, 6rem) !important;
}
body.tv-mode .history .val {
  font-size: 1.25rem;
}
body.tv-mode .topbar .user-chip,
body.tv-mode .hint {
  display: none;
}
body.tv-mode .card-head h3,
body.tv-mode .label {
  font-size: 1rem;
}
.grid-2.single-stat {
  grid-template-columns: 1fr;
}
.stat .label {
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat strong {
  display: block;
  font-family: var(--display);
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  letter-spacing: -0.03em;
  margin: 0.25rem 0;
}
.last-pix {
  border: 1.5px solid #A5D6A7;
  background: #E8F5E9;
  box-shadow: 0 10px 28px rgba(15, 143, 111, 0.1);
}
.last-pix strong {
  font-size: clamp(1.95rem, 4.8vw, 2.6rem);
  color: var(--teal-deep);
}
.last-pix.pulse-in {
  animation: last-pix-flash 1.1s ease;
}
.history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
  max-height: 320px;
  overflow: auto;
  flex: 1;
  min-height: 0;
}
.history li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 1rem;
  padding: 0.75rem 0.85rem;
  border-radius: 14px;
  background: var(--teal-soft);
  border: 1px solid var(--line);
}
.history li.empty {
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 0.92rem;
  display: block;
}
.history .val { font-family: var(--display); font-weight: 800; }
.history .sub { grid-column: 1 / -1; font-size: 0.82rem; color: var(--muted); }
.hint {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0.25rem 0 0;
}

/* —— Alert overlay —— */
.alert-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background:
    radial-gradient(circle at 50% 30%, rgba(15, 143, 111, 0.35), transparent 55%),
    rgba(8, 28, 22, 0.88);
  animation: fade-in 0.25s ease both;
}
.alert-panel {
  width: min(520px, 100%);
  text-align: center;
  color: #fff;
  padding: 2rem 1.5rem;
  border-radius: 28px;
  background: linear-gradient(165deg, #0c6b54, #12a37d 60%, #0f8f6f);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  animation: pop 0.45s cubic-bezier(0.2, 0.9, 0.2, 1.2) both;
}
.alert-eyebrow {
  margin: 0;
  letter-spacing: 0.18em;
  font-size: 0.8rem;
  font-weight: 800;
  opacity: 0.9;
}
.alert-value {
  margin: 0.5rem 0 0.75rem;
  font-family: var(--display);
  font-size: clamp(2.8rem, 12vw, 4.2rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  text-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}
.alert-payer, .alert-bank, .alert-time {
  margin: 0.2rem 0;
  font-size: 1.05rem;
  opacity: 0.95;
}
.alert-panel .btn-primary {
  margin-top: 1.5rem;
  background: #fff;
  color: var(--teal-deep);
  box-shadow: none;
  width: auto;
  min-width: 160px;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes pop {
  from { opacity: 0; transform: scale(0.92) translateY(16px); }
  to { opacity: 1; transform: none; }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(15, 143, 111, 0.55); }
  50% { box-shadow: 0 0 0 12px rgba(15, 143, 111, 0); }
}
@keyframes live-pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(15, 143, 111, 0.45);
  }
  50% {
    transform: scale(1.15);
    box-shadow: 0 0 0 6px rgba(15, 143, 111, 0);
  }
}
@keyframes last-pix-flash {
  0% {
    box-shadow: 0 0 0 0 rgba(15, 143, 111, 0.45);
    border-color: var(--teal);
  }
  40% {
    box-shadow: 0 0 0 10px rgba(15, 143, 111, 0);
  }
  100% {
    box-shadow: 0 10px 28px rgba(10, 60, 48, 0.06);
  }
}

@media (min-width: 960px) {
  .dash-layout {
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.9fr);
    align-items: stretch;
  }
  .dash-history {
    position: sticky;
    top: 4.5rem;
    max-height: calc(100vh - 5.5rem);
    height: auto;
    align-self: stretch;
  }
  .dash-history .history {
    max-height: none;
    overflow-y: auto;
    flex: 1;
  }
  .grid-2 {
    grid-template-columns: 0.9fr 1.25fr;
  }
}

@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  .user-chip { display: none; }
  .btn-icon { font-size: 0.75rem; padding: 0.4rem 0.65rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
