:root {
  --bg: #f5f6f2;
  --surface: #ffffff;
  --surface-2: #f8f9f6;
  --ink: #171a16;
  --muted: #72786e;
  --line: #e5e8e1;
  --accent: #cffa31;
  --accent-deep: #8cab0c;
  --orange: #ff8a00;
  --green: #16a66c;
  --red: #dc554b;
  --blue: #4285f4;
  --shadow: 0 12px 36px rgba(31, 38, 27, .07);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Noto Sans SC", system-ui, sans-serif; }
button, input, select { font: inherit; }
.admin-login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(23, 26, 22, .94), rgba(39, 45, 37, .9)),
    var(--bg);
}
.admin-login-shell { grid-column: auto; width: min(430px, calc(100vw - 32px)); }
.admin-login-panel {
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .24);
}
.admin-login-brand { padding: 0 0 24px; color: var(--ink); text-decoration: none; }
.admin-login-kicker { margin: 0 0 7px; color: var(--muted); font: 600 10px "DM Mono"; letter-spacing: 1.6px; }
.admin-login-panel h1 { margin: 0 0 24px; font-size: 25px; }
.admin-login-panel form { display: grid; gap: 14px; }
.admin-login-panel label { display: grid; gap: 8px; color: var(--muted); font-size: 13px; }
.admin-login-panel input {
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  outline: 0;
}
.admin-login-panel input:focus {
  border-color: var(--accent-deep);
  box-shadow: 0 0 0 3px rgba(140, 171, 12, .14);
}
.admin-login-panel button {
  height: 44px;
  margin-top: 6px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  cursor: pointer;
  font-weight: 700;
}
.admin-login-panel button:disabled { opacity: .6; cursor: wait; }
.admin-login-status { min-height: 20px; margin: 14px 0 0; color: var(--muted); text-align: center; font-size: 12px; }
.admin-login-status[data-state="error"] { color: var(--red); }
.admin-login-return { display: block; margin-top: 12px; color: var(--muted); text-align: center; text-decoration: none; font-size: 12px; }
.admin-login-return:hover { color: var(--ink); }
.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.admin-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 5; width: 224px; display: flex; flex-direction: column; padding: 25px 17px 18px; background: #171a16; color: #f5f6f1; }
.admin-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 35px; color: inherit; text-decoration: none; }
.admin-brand > span { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 9px; background: var(--accent); color: #171a16; font: 700 12px "DM Mono"; transform: rotate(-3deg); }
.admin-brand strong { font-size: 18px; }.admin-brand em { color: var(--accent); font-style: normal; }
.admin-label { padding: 0 12px 11px; color: #6f766a; font: 500 9px "DM Mono"; letter-spacing: 1.7px; }
.admin-sidebar nav { display: grid; gap: 5px; }
.admin-sidebar nav button { display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 0 13px; border: 0; border-radius: 8px; background: transparent; color: #969d91; cursor: pointer; text-align: left; font-size: 13px; }
.admin-sidebar nav button span { width: 18px; text-align: center; font: 500 15px "DM Mono"; }
.admin-sidebar nav button:hover, .admin-sidebar nav button.active { background: #292d27; color: white; }
.admin-sidebar nav button.active { box-shadow: inset 3px 0 var(--accent); }
.admin-sidebar-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 12px; color: #747b70; font-size: 10px; }
.admin-live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
main { grid-column: 2; min-width: 0; }
.admin-topbar { position: sticky; top: 0; z-index: 3; min-height: 78px; display: flex; align-items: center; justify-content: space-between; padding: 0 36px; border-bottom: 1px solid var(--line); background: rgba(245, 246, 242, .9); backdrop-filter: blur(12px); }
.admin-topbar p { margin: 0 0 3px; color: var(--muted); font: 500 8px "DM Mono"; letter-spacing: 1.5px; }
.admin-topbar h1 { margin: 0; font-size: 19px; }
.admin-top-actions { display: flex; align-items: center; gap: 19px; }
.admin-top-actions > a { color: var(--muted); text-decoration: none; font-size: 12px; }
.admin-top-actions > a:hover { color: var(--ink); }
.admin-operator { display: flex; align-items: center; gap: 9px; }
.admin-operator > span { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 10px; background: var(--ink); color: var(--accent); font-weight: 800; }
.admin-operator strong, .admin-operator small { display: block; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-operator strong { font-size: 11px; }.admin-operator small { color: var(--muted); font-size: 9px; }
.admin-content { max-width: 1260px; margin: auto; padding: 34px 36px 70px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.metric-card { min-height: 142px; padding: 20px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); box-shadow: var(--shadow); }
.metric-card header { display: flex; align-items: center; justify-content: space-between; }
.metric-card header span:first-child { color: var(--muted); font-size: 11px; }
.metric-icon { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 8px; background: var(--surface-2); color: var(--accent-deep); font: 600 13px "DM Mono"; }
.metric-card strong { display: block; margin: 18px 0 5px; font: 600 27px "DM Mono"; }
.metric-card small { color: var(--muted); font-size: 9px; }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.admin-panel { padding: 22px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); box-shadow: var(--shadow); }
.admin-panel > header { display: flex; align-items: center; justify-content: space-between; }
.admin-panel > header span { color: var(--muted); font: 500 8px "DM Mono"; letter-spacing: 1.3px; }
.admin-panel h2 { margin: 4px 0 0; font-size: 15px; }.admin-panel header b { font: 600 22px "DM Mono"; }
.acceptance-track { height: 8px; margin: 23px 0 18px; overflow: hidden; border-radius: 10px; background: var(--surface-2); }
.acceptance-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent-deep); transition: width .4s; }
.member-track span { background: var(--orange); }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mini-stats div { padding: 10px; border-radius: 8px; background: var(--surface-2); }
.mini-stats strong, .mini-stats small { display: block; }.mini-stats strong { font: 600 13px "DM Mono"; }.mini-stats small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.admin-note { display: flex; align-items: flex-start; gap: 13px; margin-top: 18px; box-shadow: none; }
.admin-note > span { display: grid; flex: 0 0 25px; height: 25px; place-items: center; border-radius: 50%; background: #edf2e8; color: var(--accent-deep); font-weight: 800; }
.admin-note strong { font-size: 12px; }.admin-note p { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.section-toolbar { min-height: 64px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-toolbar h2 { margin: 0; font-size: 20px; }.section-toolbar p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.section-toolbar form { display: flex; gap: 8px; }
.section-toolbar input, .section-toolbar select, .section-toolbar + select, .section-toolbar > select { min-height: 38px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.section-toolbar input { width: 300px; padding: 0 12px; }
.section-toolbar select { padding: 0 11px; }
.section-toolbar button { min-width: 66px; border: 0; border-radius: 8px; background: var(--ink); color: white; cursor: pointer; }
.toolbar-actions { display: flex; gap: 8px; }
.toolbar-actions button, .toolbar-actions a, .row-action {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  font-size: 10px;
}
.toolbar-actions button { background: var(--ink); color: white; }
.row-actions-cell { display: flex; align-items: center; gap: 6px; }
.row-action.danger { border-color: #f1c3bf; color: var(--red); }
.row-action.approve { border-color: #bfe0cc; color: var(--green); }
.row-action[disabled] { opacity: .45; cursor: not-allowed; }
.data-card { overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); box-shadow: var(--shadow); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { height: 44px; padding: 0 16px; background: var(--surface-2); color: var(--muted); text-align: left; font-size: 9px; font-weight: 600; letter-spacing: .5px; }
td { height: 60px; padding: 0 16px; border-top: 1px solid var(--line); font-size: 11px; }
td small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.mono { font-family: "DM Mono"; font-size: 10px; }
.status-pill { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 12px; background: #eef0eb; color: var(--muted); font-size: 9px; }
.status-pill.active, .status-pill.paid, .status-pill.accepted { background: #e8f8f1; color: var(--green); }
.status-pill.pending, .status-pill.judging, .status-pill.queued { background: #fff4e3; color: var(--orange); }
.status-pill.locked, .status-pill.deleted, .status-pill.wrong_answer, .status-pill.compile_error, .status-pill.runtime_error, .status-pill.system_error { background: #fff0ee; color: var(--red); }
.role-pill { margin-right: 4px; color: var(--accent-deep); font-size: 9px; font-weight: 700; }
.data-card footer { min-height: 47px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.pager { display: flex; align-items: center; gap: 7px; }
.pager button { min-width: 52px; height: 28px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); cursor: pointer; font-size: 9px; }
.pager button:disabled { opacity: .4; cursor: not-allowed; }
.empty-row { height: 130px; color: var(--muted); text-align: center; }
.admin-state { min-height: calc(100vh - 78px); display: grid; place-content: center; justify-items: center; text-align: center; }
.admin-state h2 { margin: 16px 0 6px; font-size: 18px; }.admin-state p { margin: 0; color: var(--muted); font-size: 11px; }
.admin-spinner { width: 30px; height: 30px; border: 3px solid var(--line); border-top-color: var(--accent-deep); border-radius: 50%; animation: spin .7s linear infinite; }
.admin-denied > span { display: grid; width: 44px; height: 44px; place-items: center; border-radius: 50%; background: #fff0ee; color: var(--red); font-size: 22px; font-weight: 800; }
.admin-denied a { margin-top: 20px; padding: 10px 15px; border-radius: 8px; background: var(--ink); color: white; text-decoration: none; font-size: 11px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 980px) {
  .admin-shell { grid-template-columns: 74px minmax(0, 1fr); }
  .admin-sidebar { width: 74px; padding-inline: 10px; }
  .admin-brand strong, .admin-label, .admin-sidebar nav button:not(.active)::after, .admin-sidebar nav button { font-size: 0; }
  .admin-brand { padding-inline: 9px; }.admin-sidebar nav button { justify-content: center; padding: 0; }.admin-sidebar nav button span { font-size: 16px; }
  .admin-sidebar-foot span:last-child { display: none; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 680px) {
  .admin-shell { display: block; }.admin-sidebar { position: static; width: 100%; height: 63px; flex-direction: row; align-items: center; padding: 8px 12px; }
  .admin-brand { padding: 0; }.admin-sidebar nav { display: flex; margin-left: auto; }.admin-sidebar nav button { width: 38px; }.admin-label, .admin-sidebar-foot { display: none; }
  main { display: block; }.admin-topbar { padding: 0 17px; }.admin-top-actions > a { display: none; }
  .admin-content { padding: 24px 16px 50px; }.metric-grid, .dashboard-grid { grid-template-columns: 1fr; }
  .section-toolbar { align-items: stretch; flex-direction: column; }.section-toolbar form, .section-toolbar input { width: 100%; }
}
/* Problem Bank Markdown authoring */
.problem-editor-dialog {
  width: min(1080px, calc(100vw - 32px));
  max-width: none;
  height: min(820px, calc(100vh - 32px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 80px rgb(0 0 0 / 28%);
}
.problem-editor-dialog::backdrop { background: rgb(13 18 24 / 58%); backdrop-filter: blur(3px); }
.problem-editor-shell { display: grid; grid-template-rows: auto auto 1fr auto; height: 100%; }
.problem-editor-shell > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}
.problem-editor-shell h2 { margin: 4px 0 0; }
.problem-editor-shell small,
.problem-editor-shell .editor-help,
.solution-language-editor span { color: var(--text-secondary); }
.dialog-close { border: 0; background: transparent; font-size: 25px; }
.problem-editor-tabs { display: flex; gap: 6px; padding: 10px 18px 0; border-bottom: 1px solid var(--line); }
.problem-editor-tabs button { padding: 10px 15px; border: 0; border-bottom: 2px solid transparent; background: transparent; }
.problem-editor-tabs button.active { border-bottom-color: var(--accent); color: var(--accent); }
.problem-editor-panel { min-height: 0; overflow: auto; padding: 18px 24px; }
.problem-editor-panel textarea {
  width: 100%;
  height: calc(100% - 44px);
  min-height: 420px;
  resize: none;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  font: 14px/1.75 "DM Mono", Consolas, monospace;
}
.markdown-editor-toolbar,
.code-group-editor-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}
.markdown-editor-toolbar p { margin: 0; }
.markdown-editor-toolbar > div,
.code-group-editor-toolbar { display: flex; align-items: end; gap: 9px; }
.solution-video-editor {
  margin-bottom: 18px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.solution-video-editor header {
  margin-bottom: 12px;
}
.solution-video-editor header span {
  margin-left: 6px;
  color: var(--text-secondary);
  font-size: 12px;
}
.solution-video-editor > div {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 0.8fr;
  gap: 12px;
}
.solution-video-editor label {
  display: grid;
  gap: 6px;
}
.code-group-editor-toolbar { justify-content: flex-start; }
.code-group-editor-toolbar label { display: grid; gap: 6px; }
.code-group-editor-toolbar label:nth-child(2) { flex: 1; }
.code-group-editor-toolbar input { width: 100%; min-width: 220px; padding: 9px 11px; }
.markdown-code-group-preview {
  margin: 22px 0;
  padding: 18px;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 6%, var(--surface-2));
}
.markdown-code-group-preview small { display: block; margin-top: 5px; color: var(--text-secondary); }
.statement-editor-panel { display: block; }
.statement-editor-panel > label,
.statement-io-grid > label { display: grid; min-height: 0; gap: 7px; margin-bottom: 18px; }
.statement-description-field textarea { min-height: 210px; }
.statement-io-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.statement-editor-panel textarea { height: auto; min-height: 120px; resize: vertical; }
.statement-io-grid textarea { min-height: 165px; }
.statement-constraints-field span,
.statement-samples-editor header span { margin-left: 6px; color: var(--text-secondary); font-size: 12px; }
.statement-constraints-field textarea { min-height: 130px; }
.statement-samples-editor { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }
.statement-samples-editor > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
#statementSampleEditors { display: grid; gap: 14px; }
.statement-sample-card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
}
.statement-sample-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.statement-sample-card > div { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.statement-sample-card label { display: grid; gap: 6px; }
.statement-sample-card textarea { min-height: 125px; background: var(--surface); }
.statement-sample-card .sample-explanation { grid-column: 1 / -1; }
.statement-sample-card .sample-explanation textarea { min-height: 76px; }
.remove-statement-sample { color: var(--danger, #e5484d); }
.solution-language-editor {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
}
.solution-language-editor label { display: grid; gap: 6px; }
.problem-markdown-preview article { max-width: 820px; margin: auto; }
.problem-markdown-preview h2,
.problem-markdown-preview h3 { margin-top: 28px; padding-bottom: 9px; border-bottom: 1px solid var(--line); }
.problem-markdown-preview p,
.problem-markdown-preview li { line-height: 1.9; }
.problem-markdown-preview code { padding: 2px 5px; border-radius: 4px; background: var(--surface-3); }
.problem-markdown-preview .markdown-image { margin: 18px 0; text-align: center; }
.problem-markdown-preview .markdown-image img { display: block; max-width: 100%; max-height: 360px; margin: 0 auto; object-fit: contain; }
.problem-markdown-preview .markdown-image figcaption { margin-top: 8px; color: var(--muted); font-size: 12px; }
.preview-solution-video {
  margin: 18px 0 24px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.preview-solution-video strong {
  display: block;
  margin-bottom: 10px;
}
.preview-solution-video video {
  display: block;
  width: 100%;
  max-height: 420px;
  border-radius: 6px;
  background: #000;
}
.preview-preserve-lines { white-space: pre-wrap; line-height: 1.9; }
.preview-sample { margin: 14px 0 22px; }
.preview-sample h3 { border-bottom: 0; }
.preview-sample pre {
  overflow: auto;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  white-space: pre-wrap;
}
.problem-editor-shell > footer {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
}
.problem-editor-shell > footer label { display: grid; flex: 1; gap: 6px; }
.problem-editor-shell > footer input { padding: 10px 12px; }
.problem-editor-shell > footer > div { display: flex; gap: 9px; }
@media (max-width: 720px) {
  .problem-editor-shell > footer,
  .solution-language-editor { align-items: stretch; flex-direction: column; }
  .statement-io-grid,
  .statement-sample-card > div,
  .solution-video-editor > div { grid-template-columns: 1fr; }
  .statement-sample-card .sample-explanation { grid-column: auto; }
  .markdown-editor-toolbar,
  .code-group-editor-toolbar { align-items: stretch; flex-direction: column; }
}
