/* Accounts: menu, sign-up, announcement ------------------------------------------ */

.m-only-flex { display: none; }

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.role-badge.role-admin { background: var(--brand-soft); color: var(--brand); }
.role-badge.role-student { background: var(--ev-deadline-bg); color: var(--ev-deadline-title); }

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text-2);
  font: 600 11px/1 var(--font);
}

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--brand);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

.login-alt { margin: 14px 0 0; text-align: center; }
.optional { font-style: normal; font-weight: 400; color: var(--text-muted); }
.login-bg.no-slides .slide { display: none; }

.announce {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 30;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: min(560px, calc(100vw - 32px));
  padding: 12px 10px 12px 14px;
  border-left: 4px solid var(--brand);
  border-radius: 12px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-float);
}
.announce > .icon { margin-top: 2px; color: var(--brand); }
.announce p { flex: 1; margin: 0; font-size: 13px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Admin panel ---------------------------------------------------------------------- */

body.admin-open { overflow: hidden; }

.admin-root {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(28, 20, 16, 0.5);
}

.admin {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1080px, 100%);
  height: min(780px, 100%);
  overflow: hidden;
  border-radius: 16px;
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: 0 24px 64px rgba(20, 12, 8, 0.45);
}

.admin-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 12px 18px;
  border-bottom: 1px solid var(--border);
}

.admin-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 10px;
  background: var(--brand);
  color: var(--text-on-accent);
}
.admin-mark .icon { width: 19px; height: 19px; }
.admin-titles h2 { margin: 0; font-size: 17px; line-height: 1.2; }
.admin-titles .sub { margin: 1px 0 0; font-size: 11.5px; }
.admin-keys { margin-left: auto; font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }
.admin-close { width: 34px; height: 34px; border-radius: 9px; }

.admin-body {
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px;
  border-right: 1px solid var(--border);
  background: var(--surface-2);
}

.admin-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
}
.admin-tab:hover { background: var(--surface-3); color: var(--text); }
.admin-tab.is-active { background: var(--active-nav); color: var(--active-nav-text); font-weight: 700; }

.admin-main { position: relative; overflow-y: auto; padding: 18px 22px 24px; outline: none; }

.admin-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.admin-section-head h3 { margin: 0; font-size: 18px; line-height: 1.25; }
.admin-section-head .sub { margin-top: 2px; font-size: 12px; }

.admin-card {
  min-width: 0;
  margin: 0 0 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.admin-card h4 { margin: 0; font-size: 13.5px; }
.admin-card > .sub { margin: 2px 0 0; font-size: 11.5px; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.card-row .sub { margin: 2px 0 0; font-size: 11.5px; }
.admin-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.admin-muted { margin: 8px 0 0; font-size: 12.5px; color: var(--text-muted); }

.admin-flash { margin: 0 0 12px; padding: 8px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600; }
.admin-flash.tone-ok { background: var(--ok-soft); color: var(--ok); }
.admin-flash.tone-danger { background: var(--danger-soft); color: var(--danger); }
.admin-flash.tone-muted { background: var(--surface-3); color: var(--text-2); }

.admin-loading, .admin-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 260px;
  color: var(--text-muted);
  text-align: center;
}
.admin-empty > .icon { width: 26px; height: 26px; color: var(--warn); }
.admin-empty strong { color: var(--text); font-size: 13.5px; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.primary.with-icon, .ghost.with-icon { display: inline-flex; align-items: center; gap: 7px; text-decoration: none; white-space: nowrap; }
.primary:disabled, .danger:disabled, .ghost:disabled, .chip:disabled { opacity: 0.55; cursor: not-allowed; }

/* Stat tiles */
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat-tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.stat-label { font-size: 11.5px; color: var(--text-muted); }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.15; color: var(--text); }
.stat-sub { font-size: 11.5px; color: var(--text-muted); }
.stat-tile.tone-warn { border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.warn-link { display: inline-flex; align-items: center; gap: 4px; color: var(--warn); font-size: 11.5px; }

/* Column chart: one series, 4px rounded caps, square baseline, 2px gaps, hairline grid */
.colchart {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  grid-template-rows: 150px auto;
  column-gap: 8px;
  margin-top: 14px;
}
.colchart-y { position: relative; }
.colchart-y span {
  position: absolute;
  right: 0;
  transform: translateY(50%);
  font-size: 10.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.colchart-plot { position: relative; }
.gridline { position: absolute; left: 0; right: 0; border-top: 1px solid var(--grid-line-strong); }
.colchart-cols { position: absolute; inset: 0; display: flex; gap: 2px; }
.col {
  position: relative;
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 4px 4px 0 0;
  background: transparent;
}
.col:hover, .col:focus-visible { background: color-mix(in srgb, var(--chart-bar) 9%, transparent); }
.col-bar { width: min(24px, 72%); border-radius: 4px 4px 0 0; background: var(--chart-bar); }
.col-val {
  position: absolute;
  left: 50%;
  margin-bottom: 3px;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
}
.colchart-x { grid-column: 2; display: flex; gap: 2px; margin-top: 6px; }
.colchart-x span { flex: 1; min-width: 0; font-size: 10.5px; color: var(--text-muted); text-align: center; white-space: nowrap; overflow: visible; }

/* Horizontal bars: same colour, value at the tip */
.barlist { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.barrow {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 10px;
  border-radius: 6px;
}
.barrow-label { font-size: 12px; color: var(--text-2); }
.barrow-track { display: flex; align-items: center; height: 16px; border-left: 1px solid var(--grid-line-strong); }
.barrow-bar { display: block; height: 14px; border-radius: 0 4px 4px 0; background: var(--chart-bar); }
.barrow:hover .barrow-bar, .barrow:focus-visible .barrow-bar { filter: brightness(1.15); }
.barrow-val { font-size: 12px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

.admin-tip {
  position: absolute;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--text);
  color: var(--surface-solid);
  box-shadow: var(--shadow-float);
  font-size: 11.5px;
  pointer-events: none;
}
.admin-tip strong { font-size: 13px; }
.admin-tip .tip-extra { opacity: 0.8; }

.chart-table { margin-top: 10px; }
.chart-table summary { font-size: 11.5px; color: var(--text-muted); cursor: pointer; }
.admin-table { width: 100%; margin-top: 8px; border-collapse: collapse; font-size: 12.5px; }
.admin-table th { padding: 6px 8px; border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 600; color: var(--text-muted); text-align: left; }
.admin-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.admin-table tr:last-child td { border-bottom: 0; }

/* Activity */
.act-list { margin: 8px 0 0; padding: 0; list-style: none; }
.act-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.act-row:last-child { border-bottom: 0; }
.act-icon { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--surface-3); color: var(--text-2); }
.act-row.is-warn .act-icon { background: var(--warn-soft); color: var(--warn); }
.act-text { margin: 0; font-size: 12.5px; overflow-wrap: anywhere; }
.act-meta { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.admin-filters { margin: 0 0 12px; }
.act-more { margin-top: 10px; }

/* Accounts */
.admin-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.admin-search { width: 260px; }
.acc-list { display: flex; flex-direction: column; gap: 6px; }
.acc-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto 110px 56px 14px;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}
.acc-row:hover, .acc-row:focus-visible { border-color: color-mix(in srgb, var(--brand) 35%, transparent); background: var(--surface-solid); }
.acc-row.is-disabled .acc-main, .acc-row.is-disabled .avatar-initials { opacity: 0.6; }
.acc-main { display: flex; flex-direction: column; min-width: 0; }
.acc-main strong, .acc-main > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-main strong { font-size: 13px; }
.acc-main > span { font-size: 11.5px; color: var(--text-muted); }
.acc-badges { display: inline-flex; gap: 6px; align-items: center; }
.acc-meta { display: flex; flex-direction: column; font-size: 12px; color: var(--text); white-space: nowrap; }
.acc-meta span { font-size: 10.5px; color: var(--text-muted); }
.acc-go { color: var(--text-faint); }

.avatar-initials {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--control);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 700;
}
.avatar-initials.role-admin { background: var(--brand-soft); color: var(--brand); }
.avatar-xl { width: 56px; height: 56px; flex: 0 0 56px; font-size: 19px; }

.you {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--control);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
}

.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px; }
.acc-hero { display: flex; align-items: center; gap: 14px; margin: 0 0 16px; }
.acc-hero-text { flex: 1; min-width: 0; }
.acc-hero h3 { margin: 0; font-size: 18px; }
.acc-hero .sub { margin: 3px 0 0; font-size: 12px; }

.admin-form .field { margin-bottom: 10px; }
.admin-form h4 { margin-bottom: 10px; }
.admin-form > .sub { margin: -6px 0 10px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.field-narrow { max-width: 240px; }
.field-error { margin: 4px 0 0; }

.danger-zone { border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.danger-zone h4 { color: var(--danger); }
.danger-row { display: flex; gap: 8px; margin-top: 10px; }
.danger-row input {
  flex: 1;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface-2);
  color: var(--text);
}
.danger { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }

/* Switch */
.switch { position: relative; display: flex; align-items: flex-start; gap: 10px; margin: 4px 0 12px; cursor: pointer; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch-track {
  position: relative;
  flex: 0 0 38px;
  width: 38px;
  height: 22px;
  margin-top: 1px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--control);
  transition: background-color 150ms ease-out;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface-solid);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 150ms ease-out;
}
.switch input:checked + .switch-track { border-color: transparent; background: var(--ev-task-bar); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: var(--focus); outline-offset: 2px; }
.switch-text { display: flex; flex-direction: column; gap: 1px; font-size: 13px; font-weight: 600; color: var(--text); }
.switch-text small { font-size: 11.5px; font-weight: 400; color: var(--text-muted); }
.switch.is-disabled { opacity: 0.55; cursor: not-allowed; }

/* Settings */
.admin-settings fieldset.admin-card { padding-top: 10px; }
.admin-settings legend {
  padding: 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.admin-settings .field { max-width: 560px; }
.field .help { display: flex; justify-content: space-between; gap: 12px; font-size: 11.5px; font-weight: 400; color: var(--text-muted); }
.field .help span { font-size: 11.5px; font-weight: 400; color: var(--text-muted); }
.settings-bar {
  position: sticky;
  bottom: -24px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin: 0 -22px -24px;
  padding: 12px 22px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-solid);
}
.dirty-note { margin-right: auto; font-size: 12px; font-weight: 600; color: var(--warn); }

/* Maintenance */
.cli-list { margin: 8px 0 0; }
.cli-list dt { margin-top: 10px; }
.cli-list dd { margin: 3px 0 0; font-size: 12px; color: var(--text-muted); }
code { padding: 2px 6px; border-radius: 5px; background: var(--surface-3); font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; }

/* Phone ------------------------------------------------------------------------------ */

@media (max-width: 850px) {
  .m-only-flex { display: flex; }
  .announce { bottom: calc(var(--nav-h) + 76px + env(safe-area-inset-bottom)); }

  /* The panel takes the whole screen; sections become a scrolling tab row */
  .admin-root { padding: 0; }
  .admin { width: 100%; height: 100%; border-radius: 0; }
  .admin-keys { display: none; }
  .admin-close { margin-left: auto; }       /* the hidden key hint no longer pushes it right */
  .admin-body { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .admin-nav { flex-direction: row; overflow-x: auto; padding: 8px; border-right: 0; border-bottom: 1px solid var(--border); scrollbar-width: none; }
  .admin-tab { flex: 0 0 auto; }
  .admin-main { padding: 14px; }
  .settings-bar { flex-wrap: wrap; margin: 0 -14px -24px; padding: 12px 14px 16px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-grid-2 { grid-template-columns: 1fr; }
  .acc-row { grid-template-columns: 36px minmax(0, 1fr) auto 14px; }
  .acc-row .acc-meta { display: none; }
  .admin-search { width: 100%; }
  .card-row, .acc-hero { flex-wrap: wrap; }
}
