/* HomeworkX admin console — self-contained, reuses the app's design tokens. */
:root {
  --bg: #f6f7f9; --card: #ffffff; --ink: #111827; --muted: #6b7280;
  --line: #e5e7eb; --accent: #4f46e5; --accent-ink: #fff; --accent-fg: #4338ca;
  --danger: #dc2626; --ok: #15803d; --warn: #b45309;
}
html[data-theme="dark"] {
  --bg: #0b0d12; --card: #151922; --ink: #e8eaf0; --muted: #98a1b3;
  --line: #262c38; --accent: #6366f1; --accent-fg: #a5b4fc; --danger: #f87171; --ok: #4ade80; --warn: #fbbf24;
}
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    --bg: #0b0d12; --card: #151922; --ink: #e8eaf0; --muted: #98a1b3;
    --line: #262c38; --accent: #6366f1; --accent-fg: #a5b4fc; --danger: #f87171; --ok: #4ade80; --warn: #fbbf24;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 ui-sans-serif, -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---- sidebar (console) ---- */
body.console { padding-left: 232px; }
#side {
  position: fixed; left: 0; top: 0; bottom: 0; width: 232px; z-index: 5;
  display: flex; flex-direction: column; gap: 4px; padding: 18px 12px 14px;
  background: var(--card); border-right: 1px solid var(--line); overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; text-decoration: none; color: var(--ink); padding: 2px 8px 16px; }
.adminmark { font-size: 11px; font-weight: 700; color: var(--accent-ink); background: var(--accent); padding: 2px 7px; border-radius: 6px; }
#tabs { display: flex; flex-direction: column; gap: 2px; }
#tabs a { padding: 9px 12px; border-radius: 9px; text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 500; }
#tabs a:hover { background: var(--bg); color: var(--ink); }
#tabs a.on { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent-fg); font-weight: 600; }
.who { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.inline-form { display: inline; margin: 0; }
@media (max-width: 760px) {
  body.console { padding-left: 0; }
  #side { position: static; width: auto; border-right: none; border-bottom: 1px solid var(--line); padding: 12px; }
  #tabs { flex-direction: row; overflow-x: auto; }
  #tabs a { white-space: nowrap; }
  .brand { padding-bottom: 8px; }
}

/* ---- dashboard jump links ---- */
.dash-links { display: flex; flex-direction: column; gap: 8px; }
.dash-link {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  text-decoration: none; color: var(--ink); transition: border-color .12s, background .12s;
}
.dash-link:hover { border-color: var(--accent); background: var(--card); }
.dash-link-t { font-weight: 600; }
.linkbtn {
  background: none; border: none; color: var(--accent); cursor: pointer;
  padding: 0; font: inherit; text-decoration: underline;
}
main { max-width: 960px; margin: 0 auto; padding: 28px 24px 60px; }

/* ---- cards & rows ---- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 10px; font-size: 17px; }
.card h3 { font-size: 15px; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.grow { flex: 1; min-width: 140px; }

.task {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-top: 1px solid var(--line);
}
.task:first-of-type { border-top: none; }
.task .title { flex: 1; }

.badge {
  font-size: 12px; padding: 1px 8px; border-radius: 20px;
  background: var(--line); color: var(--ink); white-space: nowrap;
}
.badge.today { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-fg); }
.badge.future { background: var(--bg); color: var(--muted); }
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] .badge.today { background: #3a2e12; }
  html[data-theme="system"] .badge.future { background: #26303b; }
}
html[data-theme="dark"] .badge.today { background: #3a2e12; }
html[data-theme="dark"] .badge.future { background: #26303b; }

.del {
  color: var(--muted); text-decoration: none; font-size: 16px;
  padding: 2px 6px; border-radius: 6px;
}
.del:hover { background: var(--line); color: var(--danger); }

/* ---- user lookup: clickable result cards ---- */
#ul-results { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.ul-hit {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); cursor: pointer; transition: border-color .12s, background .12s, transform .05s;
}
.ul-hit:hover { border-color: var(--accent); background: var(--card); }
.ul-hit:active { transform: scale(.995); }
.ul-hit.sel { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.ul-avatar {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}
.ul-avatar.lg { width: 48px; height: 48px; font-size: 20px; }
.ul-hit-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ul-hit-name { font-weight: 600; }
.ul-hit-email { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ul-chevron { color: var(--muted); font-size: 22px; line-height: 1; flex: none; }
.ul-hit:hover .ul-chevron { color: var(--accent); }

/* ---- user detail card ---- */
.udetail {
  margin-top: 14px; border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; background: var(--bg);
}
.udetail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.udetail-id { min-width: 0; }
.udetail-name { font-size: 18px; font-weight: 700; }
.udetail-email { color: var(--muted); font-size: 14px; }
.udetail-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.stat-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 8px;
}
.stat-grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .stat-grid.two { grid-template-columns: 1fr; }
}
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 8px; text-align: center; display: flex; flex-direction: column; gap: 2px;
}
.stat-n { font-size: 20px; font-weight: 700; }
.stat-l { font-size: 11px; color: var(--muted); }
.intg-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px;
}
@media (max-width: 560px) { .intg-grid { grid-template-columns: 1fr; } }
.intg {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
}
.intg-dot {
  flex: none; width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted); opacity: .5;
}
.intg.on .intg-dot { background: var(--ok); opacity: 1; }
.intg-label { font-size: 13px; color: var(--muted); }
.intg-val { margin-left: auto; font-size: 13px; font-weight: 600; text-align: right; }

/* ---- analytics bars ---- */
.bars { margin: 8px 0; }
.bar-row { display: flex; align-items: center; gap: 8px; margin: 3px 0; font-size: 13px; }
.bar-day { width: 46px; color: var(--muted); }
.bar-track { flex: 1; background: var(--line); border-radius: 6px; height: 14px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); }
.bar-n { width: 34px; text-align: right; color: var(--muted); }

/* ---- forms / buttons ---- */
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px;
}
button {
  font: inherit; cursor: pointer; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); border-radius: 8px; padding: 7px 12px;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.checkrow { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: 14px; }
.checkrow input[type=checkbox] { width: auto; flex: none; }

/* ---- auth pages (login / forced pw) ---- */
body.authpage {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
}
.authcard {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 28px; width: 340px; max-width: 90vw;
}
.authcard h1 { margin: 0 0 4px; font-size: 22px; }
.authcard .hint { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.authcard label { display: block; margin: 10px 0; font-size: 14px; }
.authcard input { width: 100%; margin-top: 4px; }
.authcard button { width: 100%; margin-top: 14px; }
.err { color: var(--danger); font-size: 14px; margin: 8px 0; }

/* ---- flash toast ---- */
#flash {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; max-width: 90vw;
}
#flash.show { opacity: 1; }

/* ---- in-page dialogs ---- */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(15,18,28,.45);
}
.modal {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px 24px; width: min(440px, 94vw); box-shadow: 0 12px 32px rgba(0,0,0,.25);
}
.dlg h2 { font-size: 18px; margin: 0 0 8px; overflow-wrap: anywhere; }
.dlg-msg { margin: 0 0 14px; color: var(--muted); }
.dlg label { display: block; margin: 10px 0 4px; font-size: 13px; color: var(--muted); }
.dlg input { width: 100%; font: inherit; padding: 8px 10px; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; }
.dlg-btns { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.dlg-btns button { font: inherit; padding: 7px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.dlg-btns .primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.dlg-btns .dangerfill { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.dlg-btns button:disabled { opacity: .45; cursor: default; }

/* testers & features */
.ctl-label { font-size: 12px; white-space: nowrap; }
.badge.tester { background: #f59e0b; color: #1f1300; }
.feat-row select { margin-left: auto; }
.feat-row .su-cap { margin-left: auto; width: 90px; }
.feat-row #su-save { margin-left: 8px; }



/* ---- shared helpers that replace former inline styles (CSP blocks style="") ---- */
.note-sm { margin-top: 12px; font-size: 12px; }
.pw-out { word-break: break-all; }
.mt8 { margin-top: 8px; }
.card { border-radius: 14px; }
h1.page { font-size: 24px; letter-spacing: -.02em; margin: 0 0 16px; }

/* ---- AI usage ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.kpi b { display: block; font-size: 26px; line-height: 1.2; }
.kpi span { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.vchart { display: grid; grid-template-columns: repeat(14, 1fr); gap: 6px; align-items: end; height: 130px; margin-top: 8px; }
.vcol { display: flex; flex-direction: column; align-items: center; height: 100%; gap: 3px; }
.vwrap { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.vbar { width: 100%; min-height: 2px; background: var(--accent); opacity: .6; border-radius: 4px 4px 0 0; }
.vcol:last-child .vbar { opacity: 1; }
.vnum, .vday { font-size: 11px; color: var(--muted); }
.utable { width: 100%; border-collapse: collapse; font-size: 14px; }
.utable th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 6px; border-bottom: 1px solid var(--line); }
.utable td { padding: 9px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.utable tr:last-child td { border-bottom: none; }
.utable .num { text-align: right; font-variant-numeric: tabular-nums; }
.utable input.capin { width: 72px; }
.atcap { color: var(--danger); font-weight: 700; }
.tablewrap { overflow-x: auto; }

/* ---- announcements ---- */
.ann { border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; padding: 12px 14px; margin: 10px 0; }
.ann.off { border-left-color: var(--line); opacity: .7; }
.ann-top { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.ann-top .grow { min-width: 0; }
.ann-msg { font-weight: 600; }
.ann-meta { font-size: 12px; color: var(--muted); }
.pill { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--bg); color: var(--muted); }
.pill.live { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.annform label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.annform input[type=text], .annform textarea, .annform input[type=url] { width: 100%; }
.annform textarea { resize: vertical; }
.preview { margin-top: 12px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; background: var(--bg); }
.preview .pbtn { background: var(--accent); color: var(--accent-ink); font-weight: 600; padding: 6px 12px; border-radius: 8px; font-size: 14px; }

/* ---- status ---- */
.svc { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.svc i { width: 9px; height: 9px; border-radius: 2px; background: var(--muted); display: inline-block; }
.svc.up i { background: var(--ok); }
.svc.down i { background: var(--danger); }
.errlist { font-size: 13px; }
.err-row { border-top: 1px solid var(--line); padding: 8px 2px; display: grid; grid-template-columns: 150px 70px minmax(0, 1fr); gap: 10px; }
.err-row:first-child { border-top: none; }
.err-msg { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; overflow-wrap: anywhere; }
@media (max-width: 640px) { .err-row { grid-template-columns: 1fr; gap: 2px; } }
button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }

/* ---------- dashboard: activity ---------- */
.act-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.act-grid .card { margin-bottom: 0; }
.act-grid + .card { margin-top: 16px; }
.prow-a { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.prow-a:first-of-type { border-top: none; }
.pavatar { width: 32px; height: 32px; flex: none; border-radius: 8px; display: grid; place-content: center;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-weight: 700; font-size: 14px; }
.pwho { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pwho b, .pwho .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pright { flex: none; text-align: right; }
.top-head, .top-row { display: grid; grid-template-columns: minmax(0, 2.6fr) .7fr .8fr .6fr 1.1fr; gap: 10px; align-items: center; }
.top-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding-bottom: 6px; }
.top-row { padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.pwho-inline { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank { display: inline-block; width: 20px; color: var(--muted); font-weight: 700; }
@media (max-width: 760px) {
  .act-grid { grid-template-columns: 1fr; }
  .top-head { display: none; }
  .top-row { grid-template-columns: 1fr 1fr 1fr; }
  .top-row .pwho-inline { grid-column: 1 / -1; }
}

/* feature usage card */
.fu-h { font-size: 15px; margin: 18px 0 6px; }
.fu-h:first-child { margin-top: 4px; }
.fu-recent { margin: 6px 0 4px; }
.fu-recent summary { cursor: pointer; }
.fu-recent ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.fu-recent li { margin: 3px 0; }
