/* Painel do administrador: usa os tokens de app.css e acrescenta tabelas, cartões e gavetas. */
body.admin { overflow-y: auto; }
body.admin .topbar { position: sticky; top: 0; z-index: 20; }
body.admin a.ghost { text-decoration: none; display: inline-block; font-size: 14px; }
body.admin .ghost { font-size: 14px; }
body.admin .primary { font-size: 14px; }
.muted { color: var(--ui-muted); }
.small { font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }
[hidden] { display: none !important; }

/* ---------------- logon */
.logon-view { min-height: calc(100vh - 48px); display: grid; place-items: center; padding: 24px 16px; }
.logon-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; }
.logon-card h1 { font-size: 20px; margin: 0; }
.logon-card p { margin: 0; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--ui-muted); }
input, select, textarea {
  font: inherit;
  font-size: 14px;
  color: var(--ui-text);
  background: var(--ui-bg);
  border: 1px solid var(--ui-line);
  border-radius: 7px;
  padding: 8px 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(69, 224, 106, .45); outline-offset: 0; border-color: var(--ui-accent); }
input[name='userid'], .upper { text-transform: uppercase; font-family: var(--mono); }
textarea { resize: vertical; min-height: 110px; }
.hint { font-size: 13px; color: var(--ui-warn); }
.form-msg { min-height: 1.2em; font-size: 13px; color: var(--ui-err); font-family: var(--mono); }

/* ---------------- estrutura */
.admin-view { max-width: 1320px; margin: 0 auto; padding: 0 16px 48px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--ui-line); margin: 12px 0 18px; overflow-x: auto; }
.tabs button {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--ui-muted);
  padding: 10px 14px;
  font-size: 14px;
  white-space: nowrap;
}
.tabs button[aria-selected='true'] { color: var(--ui-text); border-bottom-color: var(--ui-accent); font-weight: 600; }
.tabs button:hover { color: var(--ui-text); }

.card { background: var(--ui-panel); border: 1px solid var(--ui-line); border-radius: 10px; padding: 16px; min-width: 0; }
.card-head { margin-bottom: 12px; display: flex; flex-direction: column; gap: 3px; }
.card h2 { font-size: 15px; margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--ui-panel); border: 1px solid var(--ui-line); border-radius: 10px; padding: 12px 14px; }
.kpi .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi .l { font-size: 12.5px; color: var(--ui-muted); }
.kpi.warn .v { color: var(--ui-warn); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar input[type='search'] { width: min(280px, 100%); }
.toolbar .spacer { flex: 1; }

/* ---------------- tabelas */
.table-card { padding: 0; overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--ui-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--ui-line);
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--ui-panel);
}
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--ui-line); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr.click { cursor: pointer; }
table.data tbody tr.click:hover td, table.data tbody tr.click:focus-visible td { background: var(--ui-panel-2); }
table.data tbody tr.click:focus-visible { outline: none; }
table.data .uid { font-family: var(--mono); font-weight: 600; }
.w-prog { width: 190px; }
.empty { padding: 24px; text-align: center; color: var(--ui-muted); margin: 0; }

.pbar { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ui-muted); font-variant-numeric: tabular-nums; }
.pbar .track { flex: 1; height: 6px; background: var(--ui-panel-2); border-radius: 99px; overflow: hidden; min-width: 60px; }
.pbar .track span { display: block; height: 100%; background: var(--ui-accent); border-radius: 99px; }

.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; padding: 2px 8px; border-radius: 99px; font-weight: 600; white-space: nowrap; margin: 1px 4px 1px 0; }
.tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.ok { background: rgba(69, 224, 106, .12); color: var(--ui-accent); }
.tag.online { background: rgba(64, 216, 216, .12); color: var(--t-turq); }
.tag.warn { background: rgba(255, 216, 74, .12); color: var(--ui-warn); }
.tag.bad { background: rgba(255, 123, 123, .13); color: var(--ui-err); }
.tag.adm { background: rgba(255, 122, 224, .12); color: var(--t-pink); }
.tag.plain { background: var(--ui-panel-2); color: var(--ui-muted); }
.tag.plain::before { display: none; }
.plan { font-size: 11.5px; font-weight: 700; letter-spacing: .03em; }
.plan.PREMIUM { color: var(--t-blue); }
.plan.FREE { color: var(--ui-muted); }

/* ---------------- gráfico de atividade */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--ui-line); stroke-width: 1; }
.chart .axis text { fill: var(--ui-muted); font-size: 11px; font-family: var(--sans); }
.chart .bar { fill: var(--ui-accent); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.on { fill: #7cf09a; }
.tip-box {
  position: absolute;
  pointer-events: none;
  background: var(--ui-panel-2);
  border: 1px solid var(--ui-line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
  transform: translate(-50%, calc(-100% - 10px));
  z-index: 5;
}
.tip-box b { font-variant-numeric: tabular-nums; }

/* ---------------- funil por aula */
.funnel { display: flex; flex-direction: column; gap: 14px; max-height: 420px; overflow-y: auto; padding-right: 4px; }
.funnel .mod-title { font-size: 12.5px; font-weight: 600; margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
.frow { display: grid; grid-template-columns: minmax(0, 1fr) 120px 34px; gap: 10px; align-items: center; font-size: 12.5px; padding: 2px 0; }
.frow .ft { color: var(--ui-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frow .track { height: 8px; background: var(--ui-panel-2); border-radius: 0 4px 4px 0; overflow: hidden; }
.frow .track span { display: block; height: 100%; background: var(--t-turq); border-radius: 0 4px 4px 0; }
.frow .fn { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------- gaveta de detalhes */
.shade { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 30; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 100%);
  background: var(--ui-panel);
  border-left: 1px solid var(--ui-line);
  z-index: 31;
  display: flex;
  flex-direction: column;
  box-shadow: -12px 0 40px rgba(0, 0, 0, .35);
}
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px; border-bottom: 1px solid var(--ui-line); }
.d-userid { font-family: var(--mono); font-size: 20px; font-weight: 700; }
.icon-btn { background: none; border: 1px solid var(--ui-line); color: var(--ui-text); border-radius: 7px; width: 34px; height: 34px; font-size: 20px; line-height: 1; }
.icon-btn:hover { border-color: var(--ui-accent); }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 20px; }
.drawer-body h3 { font-size: 13px; margin: 0 0 8px; color: var(--ui-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 13.5px; margin: 0; }
.facts dt { color: var(--ui-muted); }
.facts dd { margin: 0; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row button { font-size: 13px; padding: 7px 12px; }
.danger { background: transparent; color: var(--ui-err); border: 1px solid rgba(255, 123, 123, .45); border-radius: 7px; padding: 7px 12px; }
.danger:hover { background: rgba(255, 123, 123, .1); }
.danger.solid { background: var(--ui-err); color: #2a0606; border-color: var(--ui-err); font-weight: 700; }
.mods { display: flex; flex-direction: column; gap: 6px; }
.mods details { border: 1px solid var(--ui-line); border-radius: 8px; }
.mods summary { list-style: none; cursor: pointer; padding: 8px 10px; display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 10px; align-items: center; font-size: 13px; }
.mods summary::-webkit-details-marker { display: none; }
.mods summary .mt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mods details.locked summary { opacity: .55; }
.mods ul { list-style: none; margin: 0; padding: 0 10px 8px; font-size: 12.5px; }
.mods li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-top: 1px dashed var(--ui-line); }
.mods li .ok { color: var(--ui-accent); }
.mods li .no { color: var(--ui-muted); }
.mini { font-size: 12.5px; }
.mini td { padding: 6px 8px; }
.rc-ok { color: var(--ui-accent); }
.rc-warn { color: var(--ui-warn); }
.rc-bad { color: var(--ui-err); }
.linkbtn { background: none; border: 0; color: var(--t-turq); padding: 0; font: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* ---------------- diálogo e aviso */
.dialog {
  background: var(--ui-panel);
  color: var(--ui-text);
  border: 1px solid var(--ui-line);
  border-radius: 12px;
  padding: 0;
  width: min(520px, calc(100% - 32px));
  max-height: calc(100vh - 48px);
}
.dialog.wide { width: min(980px, calc(100% - 32px)); }
.dialog::backdrop { background: rgba(0, 0, 0, .55); }
.dialog form, .dialog .dlg { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.dialog h2 { margin: 0; font-size: 17px; }
.dialog p { margin: 0; font-size: 14px; }
.dialog .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dialog .actions-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.check-row { flex-direction: row; align-items: center; gap: 8px; color: var(--ui-text); font-size: 14px; }
.secret { font-family: var(--mono); font-size: 18px; font-weight: 700; letter-spacing: .08em; background: var(--ui-bg); border: 1px dashed var(--ui-line); border-radius: 8px; padding: 10px 12px; user-select: all; }
.secret-note { font-size: 13px; color: var(--ui-warn); }
.spool { font-family: var(--mono); font-size: 12px; line-height: 1.4; background: #000; color: var(--t-green); border-radius: 8px; padding: 12px; overflow: auto; max-height: 65vh; margin: 0; white-space: pre; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ui-panel-2);
  border: 1px solid var(--ui-line);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
  max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(255, 123, 123, .5); color: var(--ui-err); }

@media (max-width: 960px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .user-info { display: none; }
  .brand small { display: none; }
  .dialog .row2 { grid-template-columns: 1fr; }
  table.data .hide-sm, table.data th.hide-sm { display: none; }
  .w-prog { width: 120px; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}
