/* app.css — NeuroData: dashboard EEG (tema escuro moderno) */
:root {
  --bg: #0b1120;
  --bg-2: #0f172a;
  --panel: #131c31;
  --panel-2: #1a2540;
  --border: #24314f;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #38bdf8;
  --primary-ink: #072033;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 15% -10%, #14203c 0, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
.boot { padding: 3rem; color: var(--muted); }

/* ---- layout ---- */
#app-root { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex-shrink: 0; background: var(--bg-2);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 16px; }
.brand-mark { font-size: 26px; }
.brand-name { font-weight: 700; letter-spacing: .3px; }
.brand-sub { font-size: 12px; color: var(--muted); }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--panel-2); color: #fff; box-shadow: inset 0 0 0 1px var(--border); }
.nav-icon { width: 22px; text-align: center; }
.sidebar-foot { margin-top: auto; padding: 16px 20px; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; border-bottom: 1px solid var(--border);
  background: rgba(11, 17, 32, 0.6); backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 20px; margin: 0; }
.content { padding: 24px 28px 60px; }

.status-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px;
  border-radius: 999px; background: var(--panel); border: 1px solid var(--border);
  font-size: 13px; color: var(--muted);
}
.status-pill.is-rec { border-color: #7f1d1d; color: #fecaca; }
.pill-dot, .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---- grid & cards ---- */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-sidebar { grid-template-columns: 320px 1fr; }
.grid + .grid { margin-top: 20px; }
@media (max-width: 900px) {
  .grid-2, .grid-sidebar { grid-template-columns: 1fr; }
  .sidebar { width: 68px; }
  .brand-name, .brand-sub, .nav-item span:not(.nav-icon), .sidebar-foot { display: none; }
}

.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.card h2 { font-size: 15px; margin: 0 0 14px; letter-spacing: .3px; }
.card h3 { margin: 4px 0 12px; font-size: 17px; }
.card h4 { margin: 20px 0 10px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h2 { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.warn { color: #fca5a5; }

/* ---- forms & buttons ---- */
.field {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 9px 12px; font-size: 14px; width: 100%;
}
.field:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.field-sm { max-width: 130px; }
.form-row { display: flex; gap: 10px; margin: 10px 0; flex-wrap: wrap; align-items: center; }
.form-row .field { flex: 1; min-width: 120px; }
.form-row label { color: var(--muted); font-size: 13px; }

.btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: transform .05s, background .15s, opacity .15s; white-space: nowrap;
}
.btn:hover { background: #223052; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn-primary:hover { background: #7dd3fc; }
.btn-danger { background: #3a1420; color: #fecaca; border-color: #7f1d1d; }
.btn-danger:hover { background: #4c1626; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* ---- status box ---- */
.status-line { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.kv-k { color: var(--muted); font-size: 13px; }
.kv-v { font-weight: 600; }
.signal-bar { height: 8px; border-radius: 6px; background: var(--bg); margin-top: 14px; overflow: hidden; }
.signal-fill { height: 100%; transition: width .4s, background .4s; }

/* ---- log ---- */
.loglist { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow: auto; font-family: ui-monospace, monospace; font-size: 12.5px; }
.logitem { display: flex; gap: 10px; padding: 4px 6px; border-radius: 6px; }
.logtime { color: var(--muted); flex-shrink: 0; }
.log-error { background: rgba(239, 68, 68, 0.09); color: #fca5a5; }
.log-info span:last-child { color: var(--text); }

/* ---- scope / charts ---- */
.card-scope .scope-wrap { height: 260px; }
.scope-wrap, .ts-wrap { position: relative; width: 100%; }
.scope-canvas { width: 100%; height: 100%; display: block; background: #060c18; border-radius: 10px; }
.ts-wrap { height: 150px; margin-top: 14px; }
.ts-canvas { width: 100%; height: 100%; display: block; background: #060c18; border-radius: 10px; }
.rec-info { font-family: ui-monospace, monospace; font-size: 13px; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tile { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 14px; text-align: center; }
.tile-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.tile-val { font-size: 30px; font-weight: 800; margin-top: 6px; }
.legend { display: flex; gap: 18px; margin-top: 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.legend-dot { width: 12px; height: 4px; border-radius: 2px; }

/* band bars */
.bandbars { display: flex; flex-direction: column; gap: 9px; }
.bandbars-row { display: grid; grid-template-columns: 96px 1fr 88px; align-items: center; gap: 12px; }
.bandbars-label { font-size: 13px; color: var(--muted); }
.bandbars-track { background: var(--bg); border-radius: 6px; height: 14px; overflow: hidden; }
.bandbars-fill { height: 100%; width: 0; border-radius: 6px; transition: width .5s ease; }
.bandbars-val { text-align: right; font-family: ui-monospace, monospace; font-size: 12.5px; color: var(--text); }

/* patterns */
.pattern-list, .session-list { display: flex; flex-direction: column; gap: 8px; }
.pattern-item { display: flex; align-items: center; gap: 14px; padding: 12px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; }
.pattern-main { flex: 1; min-width: 0; }
.pattern-name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.tag { font-size: 11px; color: var(--primary); background: rgba(56, 189, 248, 0.12); padding: 2px 8px; border-radius: 999px; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 40px; width: 120px; }
.spark-bar { flex: 1; border-radius: 2px 2px 0 0; min-height: 4px; }

/* sessions & ranking */
.session-item { text-align: left; width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; cursor: pointer; color: var(--text); }
.session-item:hover { border-color: var(--primary); }
.session-name { font-weight: 600; }
.rank { display: flex; flex-direction: column; gap: 8px; }
.rank-item { display: grid; grid-template-columns: 150px 1fr 48px; align-items: center; gap: 12px; }
.rank-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-bar { background: var(--bg); height: 12px; border-radius: 6px; overflow: hidden; }
.rank-fill { height: 100%; background: linear-gradient(90deg, #38bdf8, #22c55e); transition: width .5s; }
.rank-score { text-align: right; font-family: ui-monospace, monospace; font-size: 13px; }

/* ---- colapso da barra lateral ---- */
.collapse-btn {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 16px; line-height: 1;
}
.collapse-btn:hover { color: var(--text); background: var(--panel); }
.topbar-title { display: flex; align-items: center; gap: 14px; }
.nav-collapsed .sidebar { width: 0; min-width: 0; border-right: none; overflow: hidden; }

/* ---- análise gráfica (study) ---- */
.study-toolbar {
  display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center;
  padding: 12px 14px; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 16px; position: sticky; top: 74px; z-index: 4;
}
.tgroup { display: flex; align-items: center; gap: 8px; }
.tlabel { color: var(--muted); font-size: 12.5px; }
.study-review { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 200px; }
.scrub { flex: 1; min-width: 120px; accent-color: var(--primary); }

.chart-stack { display: flex; flex-direction: column; gap: 16px; }
.chart-card { padding: 12px 14px 14px; }
.chart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; gap: 10px; flex-wrap: wrap; }
.chart-head h3 { margin: 0; font-size: 14px; }
.chart-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chart-body { position: relative; height: 240px; }
.sig-canvas { width: 100%; height: 100%; display: block; background: #060c18; border-radius: 8px; cursor: grab; }
.resize-handle { position: absolute; left: 0; right: 0; bottom: -3px; height: 10px; cursor: ns-resize; }
.resize-handle::after { content: ''; position: absolute; left: 50%; bottom: 3px; width: 40px; height: 3px; transform: translateX(-50%); border-radius: 3px; background: var(--border); }
.resize-handle:hover::after { background: var(--primary); }
.chart-card.maximized { position: fixed; inset: 64px 16px 16px; z-index: 40; margin: 0; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.chart-card.maximized .chart-body { height: calc(100vh - 150px) !important; }
.field-xs { padding: 4px 7px; font-size: 12px; max-width: 92px; }
.rec-bar { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.rec-bar .tgroup { flex-wrap: wrap; }

/* gaveta de configurações do gráfico (⚙) */
.chart-settings {
  display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: flex-start;
  padding: 12px 14px; margin: 0 0 10px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 12px;
}
.cs-group { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.cs-group + .cs-group { border-left: 1px solid var(--border); padding-left: 18px; }
.cs-title { width: 100%; font-size: 11px; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.cs-field { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.cs-lbl { white-space: nowrap; }
.cs-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
.cs-check input { accent-color: var(--primary); }
.cs-color { width: 30px; height: 24px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); cursor: pointer; }
.cs-range { display: inline-flex; align-items: center; gap: 6px; }
.cs-slider { width: 96px; accent-color: var(--primary); }
.cs-out { font-family: ui-monospace, monospace; font-size: 11.5px; color: var(--text); min-width: 40px; }
.cs-hint { font-size: 11px; color: var(--muted); font-style: italic; }

.btn-xs { padding: 3px 8px; font-size: 11.5px; border-radius: 7px; background: var(--bg); color: var(--muted); border: 1px solid var(--border); cursor: pointer; }
.btn-xs:hover { color: var(--text); background: var(--panel-2); }
.btn-xs.on { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn.on { background: var(--primary); color: var(--primary-ink); }

/* painel de similaridade */
.sim-panel { margin-bottom: 16px; }
.sim-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.sim-row label { color: var(--muted); font-size: 13px; }
.sim-row input[type=range] { accent-color: var(--primary); }
.sim-readout { display: flex; gap: 16px; margin-top: 14px; }
.sim-box { flex: 1; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; text-align: center; }
.sim-lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.sim-score, .sim-count { font-size: 34px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, monospace; }

/* toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast { padding: 12px 16px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--border); box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s; max-width: 340px; font-size: 14px; }
.toast.show { opacity: 1; transform: none; }
.toast-error { border-color: #7f1d1d; color: #fecaca; }
.toast-success { border-color: #14532d; color: #bbf7d0; }

/* ---- módulo Ponte (coletores Android) ---- */
.bridge-head { margin-bottom: 20px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.stat { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.stat-v { font-size: 22px; font-weight: 700; line-height: 1.1; }
.stat-k { font-size: 12px; color: var(--muted); margin-top: 4px; }

.dev-list { display: flex; flex-direction: column; gap: 8px; max-height: 620px; overflow: auto; }
.dev-item {
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px;
  background: var(--bg); cursor: pointer; transition: border-color .15s, background .15s;
}
.dev-item:hover { background: var(--panel-2); }
.dev-item.active { border-color: var(--primary); background: var(--panel-2); }
.dev-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dev-meta { margin-top: 4px; }

.badge {
  font-size: 10.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted);
}
.badge-rec { background: #3a1420; color: #fecaca; border-color: #7f1d1d; }
.badge-warn { background: #3a2f14; color: #fde68a; border-color: #854d0e; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--muted);
  padding: 8px 12px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--primary); }

.loglist-tall { max-height: 460px; }
.logtag { color: #7dd3fc; flex-shrink: 0; min-width: 62px; }
.log-warn { background: rgba(234, 179, 8, .08); color: #fde68a; }
.log-debug { color: var(--muted); }
.cmd-pending { color: #fde68a; }
.cmd-sent { color: #7dd3fc; }
.cmd-failed, .cmd-expired { background: rgba(239, 68, 68, .09); color: #fca5a5; }

.media-list { display: flex; flex-direction: column; gap: 10px; }
.media-item {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--bg);
}
.media-item audio { height: 34px; max-width: 320px; }

.diag-tree { display: flex; flex-direction: column; }
.diag-group { margin: 8px 0 8px 0; padding-left: 12px; border-left: 2px solid var(--border); }
.diag-key { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--primary); margin-bottom: 4px; }

.bands-mini { display: flex; gap: 8px; align-items: flex-end; height: 110px; margin-top: 8px; }
.bandm { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.bandm-bar { flex: 1; width: 100%; background: var(--bg); border-radius: 6px; display: flex; align-items: flex-end; overflow: hidden; }
.bandm-fill { width: 100%; border-radius: 6px 6px 0 0; transition: height .3s; }
.bandm-k { font-size: 10px; color: var(--muted); text-align: center; white-space: pre-line; line-height: 1.15; }
