/* ==========================================================================
   Tokens. :root é o tema escuro (padrão); [data-theme="light"] sobrescreve.
   ========================================================================== */

:root {
  --bg: #0b0d10;
  --surface: #14181d;
  --surface-2: #1c2128;
  --border: #2c333c;
  --text: #e8ecf1;
  --text-muted: #9aa5b1;
  --accent: #4da3ff;
  --focus: #ffffff;
  --ok: #2ecc71;
  --warn: #ffb020;
  --danger: #ff4d4f;
  --alarm: #c4001a;
  --alarm-expired: #7a0010;
  --transition: #6b2bd9;
  --on-color: #0b0d10;

  --c1: #4da3ff;
  --c2: #f5a623;
  --c3: #2ecc71;
  --c4: #e056fd;
  --c5: #00d2d3;
  --c6: #ffd23f;
  --c7: #ff7675;
  --c8: #a29bfe;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --fs-sm: 13px;
  --fs-base: 15px;
  --fs-md: 17px;
  --fs-lg: 20px;
  --fs-xl: 26px;
  --fs-alarm: 30px;

  --r1: 4px;
  --r2: 6px;
  --shadow-dialog: 0 8px 24px rgba(0, 0, 0, .5);

  --gutter: 16px;
  --content-max: 1440px;
  --session: var(--accent);

  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --border: #c9d0d8;
  --text: #0b0d10;
  --text-muted: #4a5561;
  --accent: #0b63c5;
  --focus: #000000;
  --ok: #137a3f;
  --warn: #9a5b00;
  --danger: #c4001a;
  --on-color: #0b0d10;

  color-scheme: light;
}

.c1 { --session: var(--c1); }
.c2 { --session: var(--c2); }
.c3 { --session: var(--c3); }
.c4 { --session: var(--c4); }
.c5 { --session: var(--c5); }
.c6 { --session: var(--c6); }
.c7 { --session: var(--c7); }
.c8 { --session: var(--c8); }

@media (min-width: 600px) {
  :root { --gutter: 24px; }
}

/* ==========================================================================
   Base
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.4;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  margin: 0 0 var(--s3);
  line-height: 1.25;
}

h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
h4 { font-size: var(--fs-base); }

p {
  margin: 0 0 var(--s2);
}

a {
  color: var(--accent);
}

pre {
  margin: 0;
  font-family: var(--mono);
  font-size: var(--fs-sm);
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

dl, dd {
  margin: 0;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

h1[tabindex="-1"]:focus:not(:focus-visible),
main[tabindex="-1"]:focus:not(:focus-visible) {
  outline: 3px solid transparent;
}

/* ==========================================================================
   Utilitários
   ========================================================================== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.offscreen {
  position: fixed;
  top: 0;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.mono { font-family: var(--mono); }
.muted { color: var(--text-muted); }
.tabular { font-variant-numeric: tabular-nums; }
.text-warn { color: var(--warn); }
.text-danger { color: var(--danger); }
.text-ok { color: var(--ok); }
.break-anywhere { overflow-wrap: anywhere; }

.no-mobile {
  display: none;
}

@media (min-width: 600px) {
  .only-mobile { display: none !important; }
  .no-mobile { display: inline-flex; align-items: center; }
}

.skip-link {
  position: absolute;
  left: var(--s2);
  top: -100px;
  z-index: 100;
  padding: var(--s2) var(--s3);
  background: var(--accent);
  color: var(--on-color);
  border-radius: var(--r1);
}

.skip-link:focus {
  top: var(--s2);
}

/* ==========================================================================
   Botões
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 44px;
  padding: var(--s2) var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  border-color: var(--text-muted);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: .5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-color);
  font-weight: 700;
}

.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.btn-warn {
  background: var(--warn);
  border-color: var(--warn);
  color: var(--on-color);
  font-weight: 700;
}

.btn-ack {
  min-height: 56px;
  background: #fff;
  border-color: #fff;
  color: #000;
  font-size: var(--fs-md);
  font-weight: 700;
}

.btn-on-dark {
  background: transparent;
  border-color: #fff;
  color: #fff;
}

.btn-link {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.btn-small {
  min-height: 44px;
  padding: var(--s1) var(--s3);
  font-size: var(--fs-sm);
}

.btn-block {
  width: 100%;
}

.btn-huge {
  min-height: 64px;
  padding: var(--s3) var(--s6);
  font-size: var(--fs-lg);
}

.btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-color);
  font-weight: 700;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
}

.copy-wrap {
  display: inline-flex;
}

/* ==========================================================================
   Badges e sessões
   ========================================================================== */

.badge {
  display: inline-block;
  padding: var(--s1) var(--s2);
  border-radius: var(--r1);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  line-height: 1.2;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.badge-ok { background: var(--ok); border-color: var(--ok); color: var(--on-color); }
.badge-warn { background: var(--warn); border-color: var(--warn); color: var(--on-color); }
.badge-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.badge-muted { background: var(--surface-2); border-color: var(--border); color: var(--text-muted); }
.badge-alarm { background: var(--alarm); border-color: var(--alarm); color: #fff; }
.badge-transition { background: var(--transition); border-color: var(--transition); color: #fff; }

/* No tema claro --accent, --ok e --warn são escuros: texto branco mantém o contraste. */
[data-theme="light"] .btn-primary { color: #fff; }
[data-theme="light"] .badge-danger { color: #fff; }
[data-theme="light"] .badge-ok { color: #fff; }
[data-theme="light"] .badge-warn { color: #fff; }

.session-tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: var(--s1) var(--s2);
  border-radius: var(--r1);
  background: var(--session);
  color: var(--on-color);
  font-weight: 700;
  vertical-align: middle;
}

.session-tag-sm { font-size: var(--fs-sm); padding: 2px var(--s2); }
.session-tag-md { font-size: var(--fs-base); }

.session-tag-name {
  max-width: 24ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: var(--session);
  flex: none;
}

/* ==========================================================================
   Formulários
   ========================================================================== */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  margin: 0 0 var(--s3);
  min-width: 0;
}

fieldset {
  margin: 0 0 var(--s4);
  padding: var(--s3) var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  min-width: 0;
}

legend {
  padding: 0 var(--s1);
}

.field-label {
  font-weight: 700;
}

.field-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.field-error {
  margin: 0;
  color: var(--danger);
  font-size: var(--fs-sm);
  font-weight: 700;
}

.form-error {
  margin: var(--s2) 0;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--danger);
  border-radius: var(--r1);
  color: var(--danger);
  font-weight: 700;
}

.input,
select.input,
textarea.input {
  width: 100%;
  min-height: 44px;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

textarea.input {
  min-height: 120px;
  resize: vertical;
}

.input.mono,
textarea.mono {
  font-family: var(--mono);
  font-size: var(--fs-sm);
}

.input[aria-invalid="true"] {
  border-color: var(--danger);
}

.check {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: 44px;
}

.check input {
  width: 20px;
  height: 20px;
  flex: none;
}

.check-list {
  display: flex;
  flex-direction: column;
}

.inline-form {
  margin: var(--s3) 0;
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  background: var(--surface-2);
}

.inline-form-title {
  font-weight: 700;
}

.caid-chips-entry {
  display: flex;
  gap: var(--s2);
}

.caid-chips-entry .input {
  flex: 1;
  min-width: 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-top: var(--s2);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  max-width: 100%;
  padding: 0 0 0 var(--s2);
  border: 1px solid var(--border);
  border-radius: var(--r1);
  background: var(--surface-2);
}

.chip-text {
  overflow-wrap: anywhere;
}

.chip-remove {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: none;
  color: var(--text);
  font-size: var(--fs-lg);
  cursor: pointer;
}

.scope-selector .scope-cdns {
  padding-left: var(--s5);
}

.event-start-inputs {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--s3);
}

.event-start-inputs .field {
  margin: 0;
}

.event-start-preview {
  margin-top: var(--s2);
}

/* ==========================================================================
   Layout da aplicação
   ========================================================================== */

.app-shell {
  min-height: 100vh;
}

.page {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--s4) var(--gutter) var(--s7);
}

.page-narrow {
  max-width: 880px;
}

.boot-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
  min-height: 100vh;
  padding: var(--gutter);
  text-align: center;
}

.view-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  margin-bottom: var(--s4);
}

.view-header h1 {
  margin: 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s3);
}

.section {
  margin-top: var(--s6);
}

.section-title {
  font-size: var(--fs-lg);
}

.card {
  min-width: 0;
  padding: var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  background: var(--surface);
}

.panel {
  padding: var(--s4);
  border-radius: var(--r2);
  background: var(--surface-2);
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
  gap: var(--s4);
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s5);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s5);
}

@media (min-width: 1024px) {
  .two-col { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

.empty-state {
  padding: var(--s5);
  border-radius: var(--r2);
  background: var(--surface-2);
  text-align: center;
}

.empty-state-title {
  font-size: var(--fs-md);
  font-weight: 700;
}

.loading {
  padding: var(--s4) 0;
  color: var(--text-muted);
}

.error-block,
.danger-block {
  padding: var(--s3) var(--s4);
  border: 1px solid var(--danger);
  border-left-width: 6px;
  border-radius: var(--r2);
  background: var(--surface);
  color: var(--text);
}

.warn-block {
  padding: var(--s3) var(--s4);
  border: 1px solid var(--warn);
  border-left-width: 6px;
  border-radius: var(--r2);
  background: var(--surface);
}

.info-block {
  padding: var(--s3) var(--s4);
  border-radius: var(--r2);
  background: var(--surface-2);
}

.dl-grid {
  display: grid;
  grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
  gap: var(--s1) var(--s4);
}

.dl-grid dt {
  color: var(--text-muted);
}

.dl-grid dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

.dl-compact {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s2) var(--s3);
  margin: var(--s3) 0;
  font-size: var(--fs-sm);
}

.dl-compact dt {
  color: var(--text-muted);
}

.dl-compact dd {
  overflow-wrap: anywhere;
}

.counters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s2) var(--s4);
  font-variant-numeric: tabular-nums;
}

.counters dt {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.counters dd {
  font-size: var(--fs-md);
  font-weight: 700;
}

@media (min-width: 1024px) {
  .counters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s5);
  }
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.table th,
.table td {
  padding: var(--s2);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.table th {
  color: var(--text-muted);
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

.sticky-footer {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  margin: var(--s5) calc(-1 * var(--gutter)) 0;
  padding: var(--s3) var(--gutter);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.sticky-footer .btn-primary {
  min-height: 56px;
}

/* ==========================================================================
   Barra global
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s3);
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--s2) var(--gutter);
}

.topbar-brand {
  color: var(--text);
  font-size: var(--fs-lg);
  font-weight: 800;
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.topbar-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  font-size: var(--fs-sm);
}

.alarm-pill {
  background: var(--alarm);
  border-color: var(--alarm);
  color: #fff;
  font-weight: 800;
}

.topbar-counters {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: var(--s1);
  font-size: var(--fs-sm);
  white-space: nowrap;
}

.topbar-clock {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  white-space: nowrap;
}

.topbar-time {
  font-weight: 700;
}

.topbar-sound,
.topbar-user {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
}

.mute-options {
  display: inline-flex;
  gap: var(--s1);
}

.main-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1);
}

.main-nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--s2);
  border-bottom: 3px solid transparent;
  color: var(--text);
  text-decoration: none;
}

.main-nav-link[aria-current="page"] {
  border-bottom-color: var(--accent);
  font-weight: 700;
}

.main-nav-vertical ul {
  flex-direction: column;
}

.main-nav-vertical .main-nav-link {
  width: 100%;
}

.tb-menu {
  margin-left: auto;
}

.tb-break {
  display: none;
}

.mobile-menu {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding: var(--s3) var(--gutter);
  border-top: 1px solid var(--border);
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s1) var(--gutter);
  overflow-x: auto;
  white-space: nowrap;
  font-size: var(--fs-sm);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

/* Tablet: linha 1 com marca, indicador, pílula, relógio, som e usuário; linha 2 com nav e contadores. */
@media (min-width: 600px) and (max-width: 1023px) {
  .tb-indicator { order: 1; }
  .tb-pill { order: 2; }
  .tb-clock { order: 3; margin-left: auto; }
  .tb-sound { order: 4; }
  .tb-user { order: 5; }
  .tb-break { display: block; order: 6; flex-basis: 100%; height: 0; }
  .tb-nav { order: 7; font-size: var(--fs-sm); }
  .tb-tcounters { order: 8; margin-left: auto; }
  .tb-dcounters { display: none; }
}

@media (min-width: 1024px) {
  .tb-tcounters { display: none; }
  .tb-clock { margin-left: auto; }
}

/* ==========================================================================
   Faixas
   ========================================================================== */

.banners {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  margin-top: var(--s2);
  padding: var(--s3) var(--s4);
  border-radius: var(--r2);
  font-weight: 700;
}

.banner p {
  margin: 0;
}

.banner-button {
  width: 100%;
  min-height: 56px;
  border: 0;
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.banner-danger { background: var(--danger); color: #fff; }
.banner-danger a { color: #fff; }
.banner-warn { background: var(--warn); color: var(--on-color); }
.banner-warn a { color: var(--on-color); }
.banner-info { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.banner-muted { background: var(--surface-2); color: var(--text); font-weight: 400; }

[data-theme="light"] .banner-warn { color: #fff; }
[data-theme="light"] .banner-warn a { color: #fff; }

.banner-list {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
}

/* ==========================================================================
   Pilha de alarmes
   ========================================================================== */

.alarm-stack {
  max-width: var(--content-max);
  margin: var(--s3) auto 0;
  padding: 0 var(--gutter);
}

.alarm-stack-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  margin-bottom: var(--s2);
}

.alarm-stack-title {
  margin: 0;
}

.alarm-list {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  max-height: 60vh;
  overflow-y: auto;
}

@media (min-width: 600px) {
  .alarm-list { max-height: 50vh; }
}

.alarm-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s3);
  padding: var(--s4);
  border-radius: var(--r2);
}

@media (min-width: 600px) {
  .alarm-card { grid-template-columns: minmax(0, 1fr) auto; }
}

.alarm-card p {
  margin: 0 0 var(--s1);
}

.alarm-caid {
  background: var(--alarm);
  color: #fff;
  border-left: 8px solid var(--session);
}

.alarm-expired {
  background: var(--alarm-expired);
  color: #fff;
  border-left: 8px solid var(--session);
}

.alarm-expired::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 4px solid #fff;
  border-radius: var(--r2);
  pointer-events: none;
}

.alarm-ended {
  background: var(--surface-2);
  color: var(--text);
  border: 2px solid var(--danger);
}

.alarm-ended .alarm-card-label {
  color: var(--danger);
}

.alarm-ended .btn-on-dark {
  border-color: var(--border);
  color: var(--text);
}

.alarm-transition {
  background: var(--transition);
  color: #fff;
  border-left: 8px solid var(--session);
}

.alarm-card-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
}

.alarm-card-label {
  font-size: var(--fs-lg);
  font-weight: 800;
}

.alarm-card-caid {
  font-size: var(--fs-alarm);
  font-weight: 700;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.alarm-card-error {
  padding: var(--s2);
  border-radius: var(--r1);
  background: #fff;
  color: #000;
  font-weight: 700;
}

.alarm-card-actions {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.alarm-card-actions .btn,
.alarm-card-actions .copy-wrap,
.alarm-card-actions .copy-wrap .btn {
  width: 100%;
}

@media (min-width: 600px) {
  .alarm-card-actions { min-width: 220px; }
}

.acked-recent {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  margin-top: var(--s2);
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.ack-all-list {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

/* ==========================================================================
   Diálogos, overlay de som, login
   ========================================================================== */

.dialog {
  width: min(560px, calc(100vw - 2 * var(--gutter)));
  max-height: calc(100vh - 2 * var(--gutter));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r2);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-dialog);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, .6);
}

.dialog-body {
  padding: var(--s5);
}

.dialog-title {
  font-size: var(--fs-lg);
}

.dialog-content {
  margin-bottom: var(--s3);
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--s2);
}

.sound-overlay {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  padding: var(--gutter);
  border: 0;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.sound-overlay::backdrop {
  background: var(--bg);
}

.sound-overlay-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
  min-height: 100%;
  max-width: 560px;
  margin: 0 auto;
  text-align: center;
}

.sound-overlay-title {
  font-size: var(--fs-xl);
}

.sound-overlay-pending {
  font-weight: 700;
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--gutter);
}

.login-box {
  width: 100%;
  max-width: 400px;
}

.login-title {
  text-align: center;
}

.login-expired-head {
  padding: var(--s4) var(--s5);
  background: var(--danger);
  color: #fff;
}

.login-expired-head .dialog-title {
  margin: 0;
}

/* ==========================================================================
   Toasts
   ========================================================================== */

.toasts {
  position: fixed;
  right: var(--s2);
  bottom: var(--s2);
  left: var(--s2);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  pointer-events: none;
}

@media (min-width: 600px) {
  .toasts {
    left: auto;
    width: 380px;
    right: var(--s4);
    bottom: var(--s4);
  }
}

.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  background: var(--surface-2);
  pointer-events: auto;
}

.toast-text {
  margin: 0;
}

.toast-warn { border-color: var(--warn); border-left-width: 6px; }
.toast-error { border-color: var(--danger); border-left-width: 6px; }

/* ==========================================================================
   Componentes compartilhados
   ========================================================================== */

.cdn-card-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--s2);
}

.cdn-card-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cdn-card-name {
  font-weight: 700;
  font-size: var(--fs-md);
  overflow-wrap: anywhere;
}

.cdn-card-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s1);
}

.cdn-card-error {
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}

.cdn-card-subtitle {
  margin: var(--s2) 0 var(--s1);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.caid-now-list {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.caid-now {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s1) var(--s2);
}

.caid-now-value {
  overflow-wrap: anywhere;
}

.caid-now-match {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s1);
}

.caid-now .inline-form {
  flex-basis: 100%;
}

.cdn-card-actions {
  margin-top: var(--s3);
}

.event-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s1) var(--s3);
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.event-row:hover {
  border-color: var(--accent);
}

.event-row-when {
  font-weight: 700;
}

.event-row-caid,
.event-row-cdns {
  overflow-wrap: anywhere;
}

.event-row-badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--s1);
  margin-left: auto;
}

.event-list {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.test-result {
  margin-top: var(--s2);
  padding: var(--s3);
  border-radius: var(--r2);
  background: var(--surface-2);
}

.test-result-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
}

.test-result-caids {
  margin-top: var(--s2);
}

.schedule-preview {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.schedule-block {
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  background: var(--surface);
}

.schedule-block-error {
  border-color: var(--danger);
  border-left-width: 6px;
}

.schedule-block-title {
  font-size: var(--fs-base);
}

.schedule-formatted,
.schedule-block pre {
  margin: var(--s2) 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.schedule-errors {
  color: var(--danger);
}

/* ==========================================================================
   Telas (classes de layout usadas pelos Blocos B e C)
   ========================================================================== */

/* Abas de sessão no monitoramento */
.tabs {
  display: flex;
  gap: var(--s1);
  margin-bottom: var(--s4);
  overflow-x: auto;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-height: 44px;
  padding: 0 var(--s3);
  border-bottom: 3px solid transparent;
  color: var(--text);
  text-decoration: none;
  flex: none;
}

.tab[aria-current="page"] {
  border-bottom-color: var(--session);
  font-weight: 700;
}

.tab-new {
  color: var(--accent);
}

/* Linhas de sessões ativas */
.session-rows {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.session-row {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  padding: var(--s3);
  border: 1px solid var(--border);
  border-left: 6px solid var(--session);
  border-radius: var(--r2);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

@media (min-width: 1024px) {
  .session-row {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, .6fr) minmax(0, 1.4fr) minmax(0, .7fr) minmax(0, 1.4fr);
    align-items: center;
    gap: var(--s3);
  }
}

/* Cabeçalho e blocos do painel da sessão */
.session-header {
  padding: var(--s4);
  border: 1px solid var(--border);
  border-left: 6px solid var(--session);
  border-radius: var(--r2);
  background: var(--surface);
}

.session-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-top: var(--s3);
}

.session-header-actions .btn-danger {
  width: 100%;
}

@media (min-width: 1024px) {
  .session-header-actions .btn-danger {
    width: auto;
    margin-left: auto;
  }
}

.transition-block {
  padding: var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  background: var(--surface);
}

.transition-time {
  font-size: var(--fs-xl);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.transition-ringing {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-radius: var(--r2);
  background: var(--transition);
  color: #fff;
  font-weight: 800;
}

/* Lista de CAIDs esperados */
.item-list {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.item-row {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  background: var(--surface);
}

.item-row.is-removed {
  opacity: .6;
}

.item-row-caid {
  font-family: var(--mono);
  font-size: var(--fs-md);
  overflow-wrap: anywhere;
}

.item-row-program,
.item-row-cdns {
  min-width: 0;
  overflow-wrap: anywhere;
}

.item-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}

.item-row-actions-inline {
  display: none;
}

@media (min-width: 600px) {
  .item-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
  }
  .item-row-program,
  .item-row-cdns,
  .item-row-actions {
    grid-column: 1 / -1;
  }
  .item-row-actions-menu { display: none; }
  .item-row-actions-inline { display: flex; }
}

@media (min-width: 1024px) {
  .item-row {
    grid-template-columns: 140px minmax(0, 1.2fr) minmax(0, 1.5fr) minmax(0, 1fr) auto;
  }
  .item-row-program,
  .item-row-cdns,
  .item-row-actions {
    grid-column: auto;
  }
}

.items-toggle {
  display: inline-flex;
  gap: var(--s1);
}

.add-forms {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s4);
  margin-top: var(--s4);
}

@media (min-width: 1024px) {
  .add-forms { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* Detalhe do evento */
.slack {
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: var(--fs-sm);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.raw {
  max-height: 60vh;
  overflow: auto;
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  background: var(--surface-2);
  white-space: pre;
  overflow-wrap: normal;
}

.raw-response {
  max-height: 70vh;
}

.raw-hit {
  background: var(--warn);
  color: var(--on-color);
  font-weight: 700;
}

.response-list {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.response-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) 0;
  border-bottom: 1px solid var(--border);
}

.response-panel {
  flex-basis: 100%;
  min-width: 0;
}

.response-actions {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  width: 100%;
}

.response-actions .btn,
.response-actions .copy-wrap {
  width: 100%;
}

@media (min-width: 600px) {
  .response-actions {
    flex-direction: row;
    flex-wrap: wrap;
    width: auto;
  }
  .response-actions .btn,
  .response-actions .copy-wrap {
    width: auto;
  }
}

/* Histórico */
.subnav {
  display: flex;
  gap: var(--s1);
  margin-bottom: var(--s4);
  border-bottom: 1px solid var(--border);
}

.subnav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--s3);
  border-bottom: 3px solid transparent;
  color: var(--text);
  text-decoration: none;
}

.subnav a[aria-current="page"] {
  border-bottom-color: var(--accent);
  font-weight: 700;
}

.filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s3);
}

@media (min-width: 600px) {
  .filters { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); align-items: end; }
}

.export-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s3);
  margin: var(--s3) 0;
}

/* Configuração */
.config-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s5);
}

.config-index ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1) var(--s3);
}

.config-index a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

@media (min-width: 1024px) {
  .config-layout { grid-template-columns: 200px minmax(0, 1fr); }
  .config-index { position: sticky; top: 80px; align-self: start; }
  .config-index ul { flex-direction: column; }
}

.cdn-list {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.cdn-row {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  background: var(--surface);
}

.cdn-row-url {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 1024px) {
  .cdn-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto auto;
    align-items: center;
  }
}

.headers-editor {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.header-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s2);
}

@media (min-width: 600px) {
  .header-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) auto; align-items: end; }
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
}

.result-ok { color: var(--ok); }
.result-error { color: var(--danger); }

/* ==========================================================================
   Painel do mock (só em desenvolvimento)
   ========================================================================== */

.mock-panel {
  position: fixed;
  left: var(--s2);
  bottom: var(--s2);
  z-index: 30;
  max-width: calc(100vw - 2 * var(--s2));
  padding: var(--s2);
  border: 2px dashed var(--warn);
  border-radius: var(--r2);
  background: var(--surface);
  font-size: var(--fs-sm);
}

.mock-panel-title {
  margin: 0 0 var(--s1);
  color: var(--warn);
  font-weight: 800;
}

.mock-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1);
  max-width: 420px;
}

/* ==========================================================================
   Motion: só a moldura de alarme e o pisca de EXPIRED / SOM BLOQUEADO.
   ========================================================================== */

body.has-ringing::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 50;
  border: 6px solid var(--alarm);
  pointer-events: none;
  animation: alarm-frame 1000ms ease-in-out infinite alternate;
}

@keyframes alarm-frame {
  from { opacity: 1; }
  to { opacity: .35; }
}

.blink {
  position: relative;
}

.blink::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 4px solid #fff;
  border-radius: var(--r2);
  pointer-events: none;
  animation: blink 800ms steps(2, jump-none) infinite;
}

@keyframes blink {
  from { opacity: 1; }
  to { opacity: .4; }
}

@media (prefers-reduced-motion: reduce) {
  body.has-ringing::after { animation: none; opacity: 1; }
  .blink::before { animation: none; opacity: 1; }
}

/* ==========================================================================
   Bloco C: histórico, configuração, parser e detalhe da CDN
   ========================================================================== */

.filters-summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  font-weight: 700;
  cursor: pointer;
}

.filters-details[open] .filters-summary {
  margin-bottom: var(--s3);
}

.filters-actions {
  grid-column: 1 / -1;
}

.history-new {
  margin: var(--s3) 0;
}

.history-more {
  margin-top: var(--s4);
}

.history-session p {
  margin: var(--s1) 0;
}

.history-session-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  max-width: 100%;
  text-decoration: none;
}

.result-list ul {
  padding-left: var(--s4);
}

.config-section {
  scroll-margin-top: calc(2 * var(--s7));
}

.cdn-row-name {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-wrap: anywhere;
}

.cdn-row-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s1) var(--s2);
}

.cdn-row-extra {
  grid-column: 1 / -1;
  min-width: 0;
}

.header-masked {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
  min-height: 44px;
}

.cdn-form-interval,
.settings-number {
  max-width: 160px;
}

.settings-form {
  max-width: 640px;
}

.settings-duration {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s4);
}

.settings-duration .field {
  margin: 0;
}

.settings-volume {
  display: flex;
  align-items: center;
  gap: var(--s3);
}

.settings-range {
  flex: 1;
  min-width: 0;
  max-width: 320px;
  min-height: 44px;
}

.cdn-detail-title {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  min-width: 0;
}

.cdn-errors-table {
  display: none;
}

.cdn-errors-list {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.cdn-errors-item {
  padding: var(--s2) 0;
  border-bottom: 1px solid var(--border);
}

@media (min-width: 600px) {
  .cdn-errors-table { display: block; }
  .cdn-errors-list { display: none; }
}

/* ==========================================================================
   Bloco B: monitoramento, sessão, nova sessão e evento
   ========================================================================== */

.tab-name {
  max-width: 24ch;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cdn-card-actions .cdn-test-output {
  flex-basis: 100%;
  min-width: 0;
}

.session-panel > .section:first-of-type {
  margin-top: var(--s4);
}

.session-header-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s3);
  margin-bottom: var(--s2);
}

.session-header-name {
  margin: 0;
  overflow-wrap: anywhere;
}

.session-header .counters {
  margin-top: var(--s3);
}

.item-row-form {
  grid-column: 1 / -1;
  margin: 0;
}

.item-row-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1);
}

.item-row .badge,
.event-alarm-acked .badge {
  white-space: normal;
  overflow-wrap: anywhere;
}

.item-row-actions-menu summary {
  list-style: none;
}

.item-row-actions-menu[open] > .btn-row {
  margin-top: var(--s2);
}

.cdn-item-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
  min-width: 0;
}

.cdn-item-row .inline-form,
.cdn-item-row .form-error {
  flex-basis: 100%;
}

.nested-checks {
  padding-left: var(--s6);
}

.ns-cdn-text {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s1) var(--s2);
  min-width: 0;
  overflow-wrap: anywhere;
}

.ns-subtitle {
  font-size: var(--fs-base);
  color: var(--text-muted);
}

.ns-extra {
  padding: var(--s2) 0;
  border-top: 1px solid var(--border);
}

.ns-summary {
  margin: 0;
  font-weight: 700;
}

.ns-submit {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--s2);
  width: 100%;
}

@media (min-width: 600px) {
  .ns-submit {
    align-items: flex-end;
    width: auto;
  }
}

.btn-slack {
  min-height: 56px;
}

.event-header {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  margin-bottom: var(--s5);
}

.event-header h1 {
  margin: 0;
}

.detection-card h3 {
  overflow-wrap: anywhere;
}

.detection-card h4,
.event-responses h4 {
  margin-top: var(--s4);
}

.detection-details {
  margin-top: var(--s3);
}

.detection-details summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  cursor: pointer;
}

.detection-details .raw {
  max-height: 30vh;
}

.association-actions {
  margin-top: var(--s4);
}

/* ==========================================================================
   Revisão 2: parser por bloco e responses sem body
   ========================================================================== */

.parser-blocks {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.parser-block-add {
  margin-top: var(--s2);
}

.parser-block-add .inline-form {
  margin-top: var(--s2);
}
