:root {
  --paper: #EEF0EA;
  --card: #FFFFFF;
  --ink: #1B1D1E;
  --ink-soft: #5B655F;
  --line: #D9DCCF;

  --live: #E5342A;
  --live-soft: #FBE6E4;
  --done: #2F6B4F;
  --done-soft: #E5EFE9;
  --mod: #2B4C7E;
  --mod-soft: #E7ECF4;

  --font-display: "Archivo Black", sans-serif;
  --font-body: "Work Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100vh;
}

button {
  font-family: var(--font-body);
  font-weight: 600;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
button:active { transform: scale(0.97); }
button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid var(--mod);
  outline-offset: 2px;
}
button.btn-primary { background: var(--live); color: #fff; }
button.btn-primary:hover { opacity: 0.9; }
button.btn-secondary { background: var(--mod-soft); color: var(--mod); }
button.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
button.btn-danger { background: #fff; color: var(--live); border: 1px solid var(--live); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input {
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 64px;
}

/* --------------------------- tela de login --------------------------- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 28px;
  width: 100%;
  max-width: 360px;
}

.login-card h1 {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}

.login-card p.sub {
  color: var(--ink-soft);
  font-size: 13px;
  margin: 0 0 22px;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.error-msg {
  background: var(--live-soft);
  color: var(--live);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* ------------------------------ header --------------------------------- */

header.top {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tally {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--line);
  flex-shrink: 0;
}

.tally.live {
  background: var(--live);
  animation: pulse 1.6s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .tally.live { animation: none; }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229, 52, 42, 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(229, 52, 42, 0); }
}

.status-text {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.03em;
}
.status-text.live { color: var(--live); }
.status-text.offline { color: var(--ink-soft); }

.header-right { display: flex; align-items: center; gap: 8px; }
.username-pill {
  font-size: 12px;
  color: var(--ink-soft);
  font-family: var(--font-mono);
}

/* ------------------------------- tabs ----------------------------------- */

.tabs {
  display: flex;
  gap: 4px;
  margin: 18px 0 14px;
  border-bottom: 1px solid var(--line);
}
.tab {
  background: none;
  border: none;
  padding: 10px 4px;
  margin-right: 18px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-soft);
  border-bottom: 2px solid transparent;
  border-radius: 0;
}
.tab.active { color: var(--ink); border-bottom-color: var(--live); }
.tab .count {
  display: inline-block;
  background: var(--live);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 6px;
}

/* ------------------------------ ticket card ------------------------------ */

.ticket {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px dashed var(--live);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.ticket.done { border-left-color: var(--done); opacity: 0.75; }
.ticket.leaving { opacity: 0; transform: scale(0.96); }

.ticket-info { min-width: 0; flex: 1; }

.ticket-id {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
}

.ticket-link {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
  text-decoration: none;
  display: block;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 320px;
}
.ticket-link:hover { color: var(--mod); }

.ticket-meta {
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 4px;
}

.ticket-actions { display: flex; gap: 8px; flex-shrink: 0; }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--ink-soft);
}
.empty-state .big {
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--ink);
  margin-bottom: 6px;
}

/* --------------------------- painel de moderadores ------------------------ */

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.panel h2 {
  font-family: var(--font-display);
  font-size: 14px;
  margin: 0 0 12px;
}

.mod-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 13px;
}
.mod-row:last-child { border-bottom: none; }

.inline-form { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 120px; }

.session-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.hint {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 8px;
}

/* --------------------------------- toast ---------------------------------- */

#toast-host {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 999px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { background: var(--live); }

/* ------------------------------- comissão ---------------------------------- */

.ticket-commission {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--done);
  margin-top: 2px;
}

/* -------------------------------- histórico --------------------------------- */

.history-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
  background: var(--card);
}
.history-row-header {
  width: 100%;
  background: none;
  border: none;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  border-radius: 0;
}
.history-row-header .chevron { color: var(--ink-soft); font-size: 11px; }
.history-row-detail { padding: 0 16px 16px; }

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.history-table th {
  text-align: left;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
.history-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
.history-table td.mono, .history-table th.mono { font-family: var(--font-mono); }
