/* =====================================================================
   Painel Aviator · design system (dark tech · slate + status green)
   ===================================================================== */
:root {
  --bg: #0b1120;
  --bg-grid: rgba(148, 163, 184, .045);
  --surface: #131b2e;
  --surface-2: #1b2336;
  --surface-3: #272f42;
  --line: #2a3448;
  --line-strong: #3b4760;
  --text: #f1f5f9;
  --text-2: #cbd5e1;
  --muted: #94a3b8;
  --accent: #22c55e;
  --accent-hover: #4ade80;
  --accent-ink: #052e16;
  --accent-soft: rgba(34, 197, 94, .12);
  --info: #38bdf8;
  --warn: #f59e0b;
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, .12);
  --azul: #3b82f6; --roxo: #a855f7; --rosa: #ec4899;
  --radius-sm: 8px; --radius: 12px; --radius-lg: 16px;
  --font: "Fira Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Fira Code", ui-monospace, Menlo, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --t-fast: 150ms; --t: 220ms;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px -12px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--text); font: 15px/1.55 var(--font);
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 500px at 85% -10%, rgba(34,197,94,.08), transparent 60%),
    radial-gradient(900px 400px at -10% 10%, rgba(56,189,248,.06), transparent 60%),
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: auto, auto, 32px 32px, 32px 32px;
  background-attachment: fixed;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; transition: color var(--t-fast) var(--ease); }
a:hover { color: var(--accent-hover); }
h1 { font-size: 24px; font-weight: 600; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
h3 { font-size: 15px; font-weight: 600; margin: 0; }
p { margin: 0 0 12px; }
code, .mono { font-family: var(--mono); font-size: .9em; }
small, .muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 20px; height: 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 24px; border-bottom: 1px solid var(--line);
  background: rgba(11, 17, 32, .78); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; font-size: 16px; }
.brand:hover { color: var(--text); }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, #22c55e, #0ea5e9); color: #04121f; }
.brand small { font-family: var(--mono); font-size: 11px; color: var(--muted); font-weight: 400; }
.topbar nav { display: flex; align-items: center; gap: 4px; }
.nav-link { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px;
  border-radius: var(--radius-sm); color: var(--text-2); font-size: 14px; font-weight: 500;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { color: var(--text); background: var(--surface-2); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 28px 24px 72px; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; margin-bottom: 24px; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); } .crumbs a:hover { color: var(--text); }
.page-head .meta { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }

/* ---------- cards / sections ---------- */
.card { background: linear-gradient(180deg, var(--surface), rgba(19,27,46,.92));
  border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px; margin-bottom: 20px;
  box-shadow: var(--shadow); }
.section-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.section-head .ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: var(--surface-3); color: var(--accent); flex: none; border: 1px solid var(--line-strong); }
.section-head p { color: var(--muted); font-size: 13.5px; margin: 2px 0 0; }
.section-head .grow { flex: 1; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.fields { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fields .full { grid-column: 1 / -1; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.stack { display: grid; gap: 10px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* ---------- forms ---------- */
label, .label { display: block; font-weight: 500; font-size: 13.5px; color: var(--text-2); margin: 0 0 6px; }
.field { min-width: 0; }
input[type=text], input[type=password], input[type=number], input[type=time], textarea, select {
  width: 100%; min-height: 42px; padding: 10px 12px; background: var(--bg); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font: inherit; font-size: 15px;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
input::placeholder, textarea::placeholder { color: #64748b; }
input:hover, textarea:hover, select:hover { border-color: #52617d; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
input:disabled, textarea:disabled { opacity: .5; cursor: not-allowed; }
input[type=time] { font-family: var(--mono); color-scheme: dark; }
textarea { min-height: 170px; font-family: var(--mono); font-size: 13.5px; line-height: 1.6; resize: vertical; }
select { appearance: none; cursor: pointer; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.input-group { position: relative; display: flex; }
.input-group input { padding-right: 46px; font-family: var(--mono); font-size: 14px; }
.input-group .icon-btn { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); }
.check { display: inline-flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; margin: 0; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; margin: 0; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 42px; height: 24px; border-radius: 99px; background: var(--surface-3);
  border: 1px solid var(--line-strong); position: relative; transition: background var(--t) var(--ease); flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--muted); transition: transform var(--t) var(--ease), background var(--t) var(--ease); }
.switch input:checked + .track { background: var(--accent-soft); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); background: var(--accent); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch .txt b { display: block; font-weight: 500; color: var(--text); font-size: 14px; }
.switch .txt small { font-size: 12.5px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px;
  padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.btn:hover { background: var(--surface-3); border-color: #52617d; color: var(--text); }
.btn:active { background: #313b52; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.dashed { background: transparent; border-style: dashed; color: var(--text-2); }
.btn.dashed:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid transparent; color: var(--muted); cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
form.inline { display: inline; }

/* ---------- feedback ---------- */
.flash { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius);
  margin-bottom: 18px; border: 1px solid; font-size: 14px; }
.flash.ok { background: rgba(34,197,94,.08); border-color: rgba(34,197,94,.45); color: #bbf7d0; }
.flash.erro { background: var(--danger-soft); border-color: rgba(248,113,113,.5); color: #fecaca; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px;
  font-size: 12px; font-weight: 500; border: 1px solid var(--line-strong); color: var(--text-2);
  background: var(--surface-2); white-space: nowrap; }
.badge.on, .badge.green { color: #86efac; border-color: rgba(34,197,94,.45); background: var(--accent-soft); }
.badge.off { color: var(--muted); }
.badge.red { color: #fca5a5; border-color: rgba(248,113,113,.45); background: var(--danger-soft); }
.badge.open { color: #fcd34d; border-color: rgba(245,158,11,.45); background: rgba(245,158,11,.1); }
.badge.mono { font-family: var(--mono); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); flex: none; }
.dot.on { background: var(--accent); box-shadow: 0 0 0 3px rgba(34,197,94,.2); animation: pulse 2s infinite; }
.dot.off { background: var(--danger); }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(34,197,94,0); } }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 3px 9px; border-radius: 6px; font: 600 13px var(--mono); }
.chip.azul { background: rgba(59,130,246,.16); color: #93c5fd; }
.chip.roxo { background: rgba(168,85,247,.16); color: #d8b4fe; }
.chip.rosa { background: rgba(236,72,153,.18); color: #f9a8d4; }

/* ---------- dashboard ---------- */
.room-card { display: block; color: inherit; transition: border-color var(--t) var(--ease), transform var(--t) var(--ease); }
.room-card:hover { border-color: var(--line-strong); color: inherit; }
.score { display: flex; gap: 16px; font: 600 22px var(--mono); margin: 14px 0 6px; }
.score .g { color: #4ade80; } .score .r { color: #f87171; }
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
tbody tr { transition: background var(--t-fast) var(--ease); }
tbody tr:hover { background: rgba(39,47,66,.4); }
td.mono { font-family: var(--mono); font-size: 13px; }

/* ---------- settings layout ---------- */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start; }
.settings > * { min-width: 0; }
.section-head .grow { min-width: 0; }
.side-nav { position: sticky; top: 84px; display: grid; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 12px;
  border-radius: var(--radius-sm); color: var(--text-2); font-size: 14px; font-weight: 500;
  border-left: 2px solid transparent; transition: all var(--t-fast) var(--ease); }
.side-nav a:hover { background: var(--surface); color: var(--text); }
.side-nav a.active { background: var(--surface); color: var(--text); border-left-color: var(--accent); }
.side-nav .side-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #64748b;
  padding: 14px 12px 6px; }
section[id] { scroll-margin-top: 84px; }
.save-bar { position: sticky; bottom: 16px; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--line-strong);
  background: rgba(19,27,46,.9); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 12px 32px -12px rgba(0,0,0,.7); margin-top: 8px; }
.save-bar .state { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); }
.save-bar.dirty .state { color: #fcd34d; }

/* sessões */
.sessions { display: grid; gap: 10px; }
.session-row { display: grid; grid-template-columns: 34px 1fr auto 1fr 40px; gap: 10px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.session-row .idx { font: 600 12px var(--mono); color: var(--muted); text-align: center;
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); }
.session-row .arrow { color: var(--muted); }
.session-row .sub { grid-column: 2 / 5; font-size: 12px; color: var(--muted); margin-top: -4px; }
.session-row.invalid { border-color: rgba(248,113,113,.6); }
.session-row.invalid .sub { color: var(--danger); }
.sessions-empty { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius);
  border: 1px dashed var(--line-strong); color: var(--text-2); font-size: 14px; }
.sessions-empty .icon { color: var(--accent); }

/* copys */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 16px; overflow-x: auto; }
.tab { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 14px; border-radius: 8px;
  border: 0; background: transparent; color: var(--muted); font: 500 14px var(--font); cursor: pointer; white-space: nowrap;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.tab:hover { color: var(--text); }
.tab[aria-selected=true] { background: var(--surface-3); color: var(--text); }
.tab .tdot { width: 7px; height: 7px; border-radius: 50%; }
.copy-pane { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 340px); gap: 18px; }
.copy-pane[hidden] { display: none; }
.ph-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ph-chip { font: 500 12px var(--mono); padding: 5px 9px; border-radius: 6px; cursor: pointer;
  background: var(--surface-2); color: #fcd34d; border: 1px solid var(--line-strong);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease); }
.ph-chip:hover { border-color: #fcd34d; background: rgba(245,158,11,.1); }
.fmt-bar { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.fmt-bar .icon-btn { width: 34px; height: 34px; border: 1px solid var(--line); font: 600 13px var(--mono); }
.tg-preview { background: #0e1621; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  align-self: start; position: sticky; top: 84px; }
.tg-preview .tg-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted);
  margin-bottom: 10px; text-transform: uppercase; letter-spacing: .06em; }
.tg-bubble { background: #182533; color: #e9eef3; border-radius: 12px 12px 12px 4px; padding: 10px 12px;
  font: 14px/1.45 var(--font); white-space: pre-wrap; word-wrap: break-word; }
.tg-bubble code { background: rgba(255,255,255,.08); padding: 1px 4px; border-radius: 4px; }
.tg-bubble a { color: #6ab3f3; text-decoration: underline; }
.tg-bubble .spoiler { background: #3a4a5c; color: transparent; border-radius: 4px; }
.tg-bubble .spoiler:hover { color: inherit; background: transparent; }
.tg-time { text-align: right; font-size: 11px; color: #6d7f8f; margin-top: 4px; }
.tg-empty { color: var(--muted); font-style: italic; }

/* tokens de cor dos multiplicadores */
.ctoks { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; vertical-align: middle; }
.ctok { --c: var(--muted); display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 7px;
  border-radius: 8px; font: 600 12px/1 var(--mono); letter-spacing: -.02em; color: #fff;
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 92%, #fff 8%), color-mix(in srgb, var(--c) 70%, #000 30%));
  border: 1px solid color-mix(in srgb, var(--c) 60%, #fff 40%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent), 0 4px 12px -4px color-mix(in srgb, var(--c) 70%, transparent);
  text-shadow: 0 1px 1px rgba(0,0,0,.35); }
.ctok.azul { --c: var(--azul); }
.ctok.roxo { --c: var(--roxo); }
.ctok.rosa { --c: var(--rosa); }
.ctok.qualquer { --c: #64748b; background: transparent; border-style: dashed; border-color: #94a3b8; color: #cbd5e1;
  box-shadow: none; text-shadow: none; }
.ctok.sm { min-width: 24px; height: 24px; padding: 0 5px; font-size: 10.5px; border-radius: 6px;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 15%, transparent); }
.ctok.lg { min-width: 40px; height: 40px; padding: 0 9px; font-size: 14px; border-radius: 10px; }
.ctok-sep { color: #475569; font-size: 13px; margin: 0 1px; }

/* construtor de padrão */
.builder { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--bg); }
.builder .colors { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.color-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px; min-height: 84px;
  border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--text); cursor: pointer; font: inherit;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease); }
.color-btn:hover { background: var(--surface-2); }
.color-btn[data-color=azul]:hover { border-color: var(--azul); }
.color-btn[data-color=roxo]:hover { border-color: var(--roxo); }
.color-btn[data-color=rosa]:hover { border-color: var(--rosa); }
.color-btn[data-color=qualquer]:hover { border-color: var(--muted); }
.color-btn .ctok { margin-bottom: 6px; }
.color-btn b { font-size: 13px; font-weight: 600; }
.color-btn small { font: 11px var(--mono); }
.seq-preview { min-height: 64px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 8px 14px; border: 1px dashed var(--line-strong); border-radius: var(--radius); margin: 12px 0; }
.seq-preview .empty { font-size: 14px; color: var(--muted); }
.seq-preview .sep { color: #475569; font-size: 14px; }
.pattern-list { display: grid; gap: 8px; margin-bottom: 16px; }
.pattern-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.pattern-row .seq { display: inline-flex; }
.pattern-row .target { font: 600 14px var(--mono); color: var(--accent); }
.pattern-row.disabled { opacity: .5; }

.danger-zone { border-color: rgba(248,113,113,.35); }
.danger-zone .section-head .ico { color: var(--danger); background: var(--danger-soft); border-color: rgba(248,113,113,.35); }

.login-box { max-width: 400px; margin: 9vh auto; }
.login-box .brand { justify-content: center; margin-bottom: 20px; font-size: 18px; }

@media (max-width: 960px) {
  .settings { grid-template-columns: 1fr; }
  .side-nav { position: static; display: flex; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
  .side-nav .side-title { display: none; }
  .side-nav a { border-left: 0; white-space: nowrap; background: var(--surface); }
  .copy-pane { grid-template-columns: 1fr; }
  .tg-preview { position: static; }
}
@media (max-width: 640px) {
  .topbar { padding: 8px 16px; }
  .wrap { padding: 20px 16px 56px; }
  .card { padding: 16px; border-radius: var(--radius); }
  .grid, .fields { grid-template-columns: 1fr; }
  .hide-sm { display: none !important; }
  .builder .colors { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .session-row { grid-template-columns: minmax(0,1fr) auto minmax(0,1fr) 40px; padding: 10px; gap: 8px; }
  .section-head { flex-wrap: wrap; }
  .side-nav { margin: 0 -16px; padding: 0 16px 4px; }
  .session-row .idx { display: none; }
  .session-row .sub { grid-column: 1 / -1; }
  .save-bar { bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
