/* ── CCR Online Stylesheet ── */
:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-input: #252836;
  --bg-hover: #2a2d3a;
  --border: #2e3142;
  --text: #e4e6ed;
  --text-dim: #8b8fa3;
  --text-muted: #5c6078;
  --accent: #4f8cff;
  --accent-hover: #3a7aff;
  --accent-dim: rgba(79,140,255,0.12);
  --green: #34d399;
  --green-dim: rgba(52,211,153,0.12);
  --red: #f87171;
  --red-dim: rgba(248,113,113,0.12);
  --yellow: #fbbf24;
  --yellow-dim: rgba(251,191,36,0.12);
  --orange: #fb923c;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.3);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 14px;
}

/* ── Screens ── */
.screen { display: none; height: 100%; }
.screen.active { display: flex; flex-direction: column; }

/* ── Login ── */
.login-container {
  margin: auto;
  width: 380px;
  padding: 48px 40px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.logo-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff; font-size: 20px; font-weight: 800;
  letter-spacing: 1px; margin-bottom: 16px;
}
.login-logo h1 { font-size: 24px; font-weight: 700; color: var(--text); }
.login-subtitle { color: var(--text-dim); font-size: 13px; margin-top: 4px; }
.login-footer { text-align: center; color: var(--text-muted); font-size: 12px; margin-top: 20px; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-dim); margin-bottom: 6px; }
input[type="text"], input[type="password"], input[type="number"], input[type="email"],
select, textarea {
  width: 100%; padding: 10px 14px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 14px; font-family: var(--font);
  transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border: none; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; cursor: pointer;
  font-family: var(--font); transition: all 0.15s;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-success { background: var(--green); color: #000; }
.btn-success:hover:not(:disabled) { opacity: 0.9; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: 0.9; }
.btn-warning { background: var(--yellow); color: #000; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-dim); }
.btn-outline:hover { border-color: var(--text-dim); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-dim); padding: 6px 12px; }
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; padding: 12px; }
.btn-group { display: flex; gap: 8px; }

/* ── Header ── */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 52px;
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 24px; }
.header-logo { font-weight: 800; font-size: 16px; color: var(--accent); letter-spacing: 0.5px; }
.header-right { display: flex; align-items: center; gap: 12px; }
#user-info { color: var(--text-dim); font-size: 13px; }
#main-nav { display: flex; gap: 4px; }
.nav-btn {
  padding: 6px 14px; border-radius: var(--radius);
  background: transparent; border: none; color: var(--text-dim);
  font-size: 13px; cursor: pointer; font-family: var(--font);
  transition: all 0.15s;
}
.nav-btn:hover { color: var(--text); background: var(--bg-hover); }
.nav-btn.active { color: var(--accent); background: var(--accent-dim); }

/* ── Main content ── */
#main-content {
  flex: 1; overflow-y: auto; padding: 24px;
}

/* ── Cards ── */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px; margin-bottom: 16px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 16px; font-weight: 600; }
.card-subtitle { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
tr:hover td { background: var(--bg-hover); }

/* ── Tags / Badges ── */
.badge {
  display: inline-flex; align-items: center; padding: 2px 10px;
  border-radius: 99px; font-size: 11px; font-weight: 600;
}
.badge-green { background: var(--green-dim); color: var(--green); }
.badge-red { background: var(--red-dim); color: var(--red); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); }
.badge-blue { background: var(--accent-dim); color: var(--accent); }

/* ── Score display ── */
.score { font-weight: 700; font-family: var(--mono); }
.score-full { color: var(--green); }
.score-partial { color: var(--yellow); }
.score-zero { color: var(--red); }
.score-na { color: var(--text-muted); }

/* ── State icons ── */
.state { font-weight: 600; font-size: 12px; }
.state-A { color: var(--green); }
.state-W { color: var(--red); }
.state-T { color: var(--orange); }
.state-M { color: #a78bfa; }
.state-R { color: var(--red); }
.state-O { color: var(--text-muted); }
.state-I { color: var(--text-muted); }
.state-C { color: var(--yellow); }
.state-F { color: var(--text-muted); }
.state-E { color: var(--red); }

/* ── Upload area ── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius-lg);
  padding: 48px 24px; text-align: center; color: var(--text-dim);
  cursor: pointer; transition: all 0.2s;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent); background: var(--accent-dim);
}
.upload-zone-icon { font-size: 36px; margin-bottom: 12px; opacity: 0.5; }
.upload-zone input[type="file"] { display: none; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px;
  min-width: 420px; max-width: 90vw; max-height: 85vh;
  overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.modal-title { font-size: 18px; font-weight: 600; margin-bottom: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ── Report view ── */
.report-content {
  background: var(--bg-input); border-radius: var(--radius);
  padding: 20px; font-size: 14px; line-height: 1.8;
  white-space: pre-wrap; word-wrap: break-word;
}
.report-content h1, .report-content h2, .report-content h3 {
  margin: 16px 0 8px; color: var(--accent);
}
.report-content code {
  background: var(--bg); padding: 2px 6px; border-radius: 4px;
  font-family: var(--mono); font-size: 13px;
}
.report-content pre {
  background: var(--bg); padding: 16px; border-radius: var(--radius);
  overflow-x: auto; margin: 12px 0;
}
.report-content pre code { background: none; padding: 0; }
.report-content ul, .report-content ol { margin: 8px 0; padding-left: 24px; }
.report-content li { margin: 4px 0; }
.report-content hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.report-content table { margin: 12px 0; }
.report-content h4 { margin: 12px 0 6px; color: var(--text); font-size: 14px; }

/* ── Subtask result grid ── */
.subtask-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.point-dot {
  width: 24px; height: 24px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; cursor: default;
}
.point-A { background: var(--green-dim); color: var(--green); }
.point-W { background: var(--red-dim); color: var(--red); }
.point-T { background: rgba(251,146,60,0.15); color: var(--orange); }
.point-M { background: rgba(167,139,250,0.15); color: #a78bfa; }
.point-R { background: var(--red-dim); color: var(--red); }
.point-O { background: rgba(92,96,120,0.2); color: var(--text-muted); }
.point-I { background: rgba(92,96,120,0.15); color: var(--text-muted); }

/* ── Source code viewer ── */
.code-viewer {
  background: var(--bg); border-radius: var(--radius);
  padding: 16px; font-family: var(--mono); font-size: 13px;
  line-height: 1.5; overflow-x: auto; white-space: pre;
  max-height: 500px; overflow-y: auto;
  tab-size: 4;
}

/* ── Progress bar ── */
.progress-bar {
  width: 100%; height: 6px; background: var(--bg-input);
  border-radius: 3px; overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 3px;
  transition: width 0.3s;
}

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 12px 20px; border-radius: var(--radius);
  font-size: 13px; z-index: 2000;
  animation: slideUp 0.3s ease;
}
.toast-success { background: var(--green); color: #000; }
.toast-error { background: var(--red); color: #fff; }
.toast-info { background: var(--accent); color: #fff; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } }

/* ── Error msg ── */
.error-msg { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 20px; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty-state-icon { font-size: 48px; opacity: 0.3; margin-bottom: 16px; }
.empty-state p { font-size: 14px; }

/* ── Grid layouts ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Loading spinner ── */
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.tab-btn {
  padding: 8px 16px; border: none; background: transparent;
  color: var(--text-dim); font-size: 13px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  font-family: var(--font); transition: all 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Misc ── */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.text-dim { color: var(--text-dim); }
.text-sm { font-size: 12px; }
.text-center { text-align: center; }
.mono { font-family: var(--mono); }

/* ── Solution (anti-copy) ── */
.solution-content {
  background: var(--bg-input); border-radius: var(--radius);
  padding: 20px; font-size: 14px; line-height: 1.8;
}
.solution-content h1, .solution-content h2, .solution-content h3, .solution-content h4 {
  margin: 16px 0 8px; color: var(--accent);
}
.solution-content code {
  background: var(--bg); padding: 2px 6px; border-radius: 4px;
  font-family: var(--mono); font-size: 13px;
}
.solution-content pre {
  background: var(--bg); padding: 16px; border-radius: var(--radius);
  overflow-x: auto; margin: 12px 0;
}
.solution-content pre code { background: none; padding: 0; }
.solution-content ul, .solution-content ol { margin: 8px 0; padding-left: 24px; }
.solution-content li { margin: 4px 0; }

.no-select {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.no-select::selection { background: transparent; }
.no-select *::selection { background: transparent; }

/* ── Monitor ── */
.row-flagged { background: rgba(255,107,107,0.08); }
.row-flagged:hover { background: rgba(255,107,107,0.14); }
.badge-yellow { background: rgba(255,193,7,0.15); color: #ffc107; }
.btn-xs { padding: 2px 8px; font-size: 11px; }
.ml-8 { margin-left: 8px; }
.mt-8 { margin-top: 8px; }
.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.status-online {
  background: #4caf50;
  box-shadow: 0 0 6px rgba(76, 175, 80, 0.6);
}
.status-offline {
  background: #f44336;
  box-shadow: 0 0 6px rgba(244, 67, 54, 0.4);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .login-container { width: 90%; padding: 32px 24px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  #main-content { padding: 16px; }
  .modal { min-width: auto; width: 95vw; }
}
