/* HR Academy Trainer, admin console styles.
   Palette: navy #1f3a5f, red #9b1c1c, green #15803d, amber #b45309, greys.
   No build step, no external resources. */

:root {
  --navy: #1f3a5f;
  --navy-dark: #16283f;
  --navy-100: #e8edf4;
  --red: #9b1c1c;
  --red-100: #fbe9e9;
  --green: #15803d;
  --green-100: #e7f5ec;
  --amber: #b45309;
  --amber-100: #fdf1e0;
  --grey-50: #f6f7f9;
  --grey-100: #eef0f3;
  --grey-200: #e2e5ea;
  --grey-300: #ccd2db;
  --grey-400: #a7aeb9;
  --grey-500: #7a8291;
  --grey-600: #5b6270;
  --grey-700: #414753;
  --grey-800: #2b303a;
  --grey-900: #1a1d23;
  --bg: var(--grey-50);
  --surface: #ffffff;
  --text: var(--grey-900);
  --muted: var(--grey-600);
  --border: var(--grey-200);
  --topbar-h: 54px;
  --radius: 8px;
  --shadow: 0 2px 10px rgba(26, 29, 35, 0.08);
  --shadow-lg: 0 12px 32px rgba(26, 29, 35, 0.18);
  font-size: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
}

body { min-height: 100vh; }

h1, h2, h3, h4 { margin: 0 0 8px; color: var(--navy); font-weight: 650; }
h1 { font-size: 1.3rem; }
h2 { font-size: 1.08rem; }
h3 { font-size: 0.95rem; }
p { margin: 0 0 8px; }
a { color: var(--navy); }
a:hover { color: var(--red); }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
#topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--navy);
  color: #fff;
  padding: 0 16px;
  box-shadow: var(--shadow);
}
body.is-login #topbar { display: none; }

.brand { font-weight: 700; white-space: nowrap; display: flex; align-items: baseline; gap: 8px; }
.brand-tag { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; background: rgba(255,255,255,0.16); padding: 2px 7px; border-radius: 999px; }

#nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: thin; }
#nav a {
  color: rgba(255,255,255,0.78);
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 6px;
  white-space: nowrap;
}
#nav a:hover { color: #fff; background: rgba(255,255,255,0.08); }
#nav a.active { color: var(--navy); background: #fff; }

.topbar-right { display: flex; align-items: center; gap: 10px; white-space: nowrap; }

#coachPill { font-size: 0.78rem; }

#view {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 16px 60px;
}

.screen-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.screen-head h1 { margin: 0; }
.screen-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.section { margin-bottom: 26px; }
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--grey-300);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 13px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.2;
}
.btn:hover { border-color: var(--grey-400); background: var(--grey-50); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 4px 9px; font-size: 0.78rem; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-dark); border-color: var(--navy-dark); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #7d1616; border-color: #7d1616; }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #106731; border-color: #106731; }
.btn-ghost { background: transparent; border-color: transparent; color: inherit; }
.btn-ghost:hover { background: rgba(0,0,0,0.06); }
#topbar .btn-ghost { color: #fff; }
#topbar .btn-ghost:hover { background: rgba(255,255,255,0.12); }
.btn-block { width: 100%; justify-content: center; }

/* ---------- forms ---------- */
label { font-size: 0.82rem; font-weight: 600; color: var(--grey-700); }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field-inline { flex-direction: row; align-items: center; gap: 8px; }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

input[type="text"], input[type="password"], input[type="number"], input[type="search"], select, textarea {
  border: 1px solid var(--grey-300);
  border-radius: 6px;
  padding: 7px 9px;
  background: #fff;
  min-width: 0;
  width: 100%;
}
textarea { resize: vertical; min-height: 70px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.82rem; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 1px;
}
.help-text { font-size: 0.76rem; color: var(--muted); font-weight: 400; margin-top: 2px; }
.error-text { color: var(--red); font-size: 0.82rem; margin: 4px 0 0; }
fieldset { border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; margin: 0 0 10px; }
fieldset legend { font-size: 0.82rem; font-weight: 700; color: var(--navy); padding: 0 4px; }
.radio-line { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; }
.radio-line input { width: auto; margin-top: 3px; }
.radio-line .radio-label { font-weight: 700; color: var(--text); }
.radio-line .radio-desc { font-weight: 400; color: var(--muted); font-size: 0.8rem; }

/* toggle switch */
.switch { position: relative; display: inline-block; width: 38px; height: 21px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch-track {
  position: absolute; inset: 0; background: var(--grey-300); border-radius: 999px; transition: background 0.15s;
}
.switch-track::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; background: #fff; border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3); transition: transform 0.15s;
}
.switch input:checked + .switch-track { background: var(--green); }
.switch input:checked + .switch-track::before { transform: translateX(17px); }
.switch input:disabled + .switch-track { opacity: 0.5; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.data { border-collapse: collapse; width: 100%; font-size: 0.84rem; }
table.data th, table.data td {
  padding: 7px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td.wrap { white-space: normal; }
table.data thead th {
  position: sticky;
  top: var(--topbar-h);
  background: var(--grey-100);
  color: var(--grey-700);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  z-index: 2;
  border-bottom: 1px solid var(--grey-300);
}
table.data tbody tr:hover { background: var(--navy-100); }
table.data tbody tr.clickable { cursor: pointer; scroll-margin-top: calc(var(--topbar-h) + 36px); }
table.data tfoot td { color: var(--muted); font-size: 0.8rem; padding: 8px 10px; }
.col-actions { display: flex; gap: 6px; flex-wrap: nowrap; }
.empty-row td { color: var(--muted); font-style: italic; text-align: center; padding: 18px; }

/* ---------- pills / chips ---------- */
.pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1.6;
}
.pill-navy { background: var(--navy-100); color: var(--navy); }
.pill-green { background: var(--green-100); color: var(--green); }
.pill-amber { background: var(--amber-100); color: var(--amber); }
.pill-red { background: var(--red-100); color: var(--red); }
.pill-grey { background: var(--grey-100); color: var(--grey-600); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--grey-100);
  color: var(--grey-700);
  margin: 2px 4px 2px 0;
  border: 1px solid var(--grey-200);
}
.chip-green { background: var(--green-100); color: var(--green); border-color: #bfe4cc; }
.chip-amber { background: var(--amber-100); color: var(--amber); border-color: #f2d5ab; }
.chip-red { background: var(--red-100); color: var(--red); border-color: #f0c3c3; }
.chip-wrap { display: flex; flex-wrap: wrap; }

.type-chip { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; padding: 3px 8px; border-radius: 5px; }
.type-chip.obj { background: var(--navy-100); color: var(--navy); }
.type-chip.short { background: var(--amber-100); color: var(--amber); }
.type-chip.board { background: var(--red-100); color: var(--red); }

/* ---------- toasts ---------- */
#toasts {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}
.toast {
  background: var(--grey-900);
  color: #fff;
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 0.84rem;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--grey-500);
  animation: toast-in 0.15s ease-out;
}
.toast-error { border-left-color: var(--red); }
.toast-success { border-left-color: var(--green); }
.toast-info { border-left-color: var(--navy); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- side panel ---------- */
#panelOverlay {
  position: fixed; inset: 0; background: rgba(26,29,35,0.4); z-index: 90;
}
#panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(440px, 100vw);
  background: var(--surface);
  z-index: 91;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border); flex: none;
}
.panel-head h2 { margin: 0; }
#panelBody { padding: 16px; overflow-y: auto; flex: 1; }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 360px; text-align: left; box-shadow: var(--shadow); }
.auth-card h1 { text-align: center; }
.auth-card .muted { text-align: center; margin-bottom: 16px; }

/* ---------- overview ---------- */
.coach-box { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; }
.coach-stat { min-width: 120px; }
.coach-stat .label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 700; }
.coach-stat .value { font-size: 1.05rem; font-weight: 700; color: var(--navy); }
.copy-link { display: flex; align-items: center; gap: 6px; }
.copy-link .lnk { font-size: 0.78rem; max-width: 190px; overflow: hidden; text-overflow: ellipsis; }

.new-link-banner {
  background: var(--green-100);
  border: 1px solid #bfe4cc;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- attempt detail ---------- */
.attempt-header { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.attempt-header .titles h1 { margin-bottom: 2px; }
.attempt-header .pills { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.attempt-meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 10px; }
.attempt-meta-grid .k { font-size: 0.7rem; text-transform: uppercase; color: var(--muted); font-weight: 700; letter-spacing: 0.03em; }
.attempt-meta-grid .v { font-weight: 650; }

.context-panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin-bottom: 20px; }
.context-panel .card h3 { margin-bottom: 8px; }
.history-mini { width: 100%; font-size: 0.8rem; border-collapse: collapse; }
.history-mini td, .history-mini th { padding: 3px 6px; border-bottom: 1px solid var(--border); text-align: left; }
.note-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.note-list li { background: var(--grey-50); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-size: 0.8rem; white-space: pre-wrap; }

.item-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.item-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.item-head .item-idx { font-weight: 700; color: var(--muted); font-size: 0.8rem; }
.item-points { font-weight: 700; }
.item-points.correct { color: var(--green); }
.item-points.incorrect { color: var(--red); }
.item-points.pending { color: var(--amber); }
.item-stem { font-size: 0.96rem; margin-bottom: 10px; white-space: pre-wrap; }
.item-source { font-size: 0.74rem; color: var(--muted); margin-top: 6px; }
.item-explain { font-size: 0.8rem; color: var(--grey-700); background: var(--grey-50); border-radius: 6px; padding: 6px 9px; margin-top: 8px; }

.answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.answer-col { background: var(--grey-50); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; }
.answer-col h4 { margin: 0 0 6px; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.answer-col .answer-text { white-space: pre-wrap; font-size: 0.88rem; }
.answer-col ol, .answer-col ul.seq { margin: 0; padding-left: 18px; }
.answer-col ul.pairs { list-style: none; margin: 0; padding: 0; }
.answer-col ul.pairs li { padding: 2px 0; }

.grading-block { margin-top: 10px; }
.rubric-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.rubric-chip { border-radius: 6px; padding: 5px 9px; font-size: 0.76rem; text-align: center; min-width: 92px; border: 1px solid var(--grey-200); }
.rubric-chip .name { display: block; font-weight: 700; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.02em; }
.rubric-chip .score { display: block; font-size: 0.95rem; font-weight: 700; }
.rubric-chip.v0 { background: var(--red-100); color: var(--red); }
.rubric-chip.v1 { background: var(--amber-100); color: var(--amber); }
.rubric-chip.v2 { background: var(--green-100); color: var(--green); }

.override-form, .coach-note-section {
  border-top: 1px dashed var(--grey-300);
  margin-top: 12px;
  padding-top: 12px;
}
.override-form .form-row, .coach-note-section .form-row { align-items: flex-end; }
.override-form input[type=number] { width: 90px; }
.coach-note-section textarea { min-height: 90px; font-family: inherit; font-size: 0.88rem; }
.coach-note-section input[type=number] { width: 90px; }

/* ---------- bank ---------- */
.bank-layout { display: grid; grid-template-columns: 1fr; gap: 18px; }
.json-view { background: var(--grey-900); color: #d7e2f0; padding: 12px; border-radius: 6px; font-size: 0.78rem; white-space: pre-wrap; word-break: break-word; max-height: 60vh; overflow: auto; }
.problems-list { margin: 8px 0 0; padding-left: 18px; color: var(--red); font-size: 0.82rem; }
.reload-result { font-size: 0.82rem; margin-top: 8px; }

/* ---------- events ---------- */
.event-feed { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.event-row { display: flex; gap: 10px; align-items: baseline; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 0.84rem; flex-wrap: wrap; }
.event-row:last-child { border-bottom: none; }
.event-row .ev-time { color: var(--muted); font-size: 0.76rem; min-width: 132px; }
.event-row .ev-kind { font-weight: 700; color: var(--navy); }
.event-row .ev-student { color: var(--grey-700); }
.event-row .ev-data { color: var(--muted); font-size: 0.8rem; }

/* ---------- loading ---------- */
.loading-line { color: var(--muted); padding: 20px 4px; font-style: italic; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  :root { --topbar-h: 48px; }
  #topbar { gap: 10px; padding: 0 10px; }
  .brand-tag { display: none; }
  #view { padding: 12px 10px 50px; }
  .answer-grid { grid-template-columns: 1fr; }
  .attempt-header { flex-direction: column; }
  #panel { width: 100vw; }
  table.data th, table.data td { padding: 6px 8px; }
}
