/* ===== CSS Variables – Rosneft brand palette ===== */
:root {
  --bg:        #111318;
  --bg2:       #1a1d24;
  --bg3:       #22262f;
  --border:    #2e3340;
  --text:      #e2e4ea;
  --text-muted:#8a8fa0;
  --orange:    #f37021;
  --orange-d:  #c95a14;
  --yellow:    #fdd835;
  --green:     #4caf50;
  --green-d:   #388e3c;
  --red:       #e53935;
  --red-d:     #b71c1c;
  --blue:      #2196f3;
  --radius:    8px;
  --shadow:    0 2px 12px rgba(0,0,0,.45);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}

a { color: var(--orange); text-decoration: none; }
a:hover { color: var(--yellow); }

/* ===== Layout ===== */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  min-height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo img { height: 36px; }

.sidebar-logo-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.sidebar-logo-text span { color: var(--orange); font-size: 10px; display: block; }

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-muted);
  font-size: 14px;
  transition: background .15s, color .15s;
}
.sidebar-nav a:hover { background: var(--bg3); color: var(--text); }
.sidebar-nav a.active { background: rgba(243,112,33,.12); color: var(--orange); border-right: 3px solid var(--orange); }
.sidebar-nav .icon { font-size: 18px; width: 22px; text-align: center; }

.sidebar-user {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.sidebar-user .name { font-weight: 600; color: var(--text); }
.sidebar-user .role { color: var(--text-muted); font-size: 12px; }
.sidebar-user a { font-size: 12px; color: var(--text-muted); }
.sidebar-user a:hover { color: var(--red); }

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar h1 { font-size: 18px; font-weight: 600; }
.topbar .breadcrumb { font-size: 12px; color: var(--text-muted); }

.content { padding: 28px; flex: 1; }

/* ===== Auth pages ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}

.auth-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo img { height: 48px; margin-bottom: 10px; }
.auth-logo h2 { font-size: 20px; font-weight: 700; }
.auth-logo p  { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ===== Form elements ===== */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-muted);
}
input[type=text], input[type=password], input[type=email], select, textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--orange);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
}
.btn:hover { opacity: .88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-danger  { background: var(--red);   color: #fff; }
.btn-ghost   { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-full { width: 100%; }

/* ===== Alerts / Flash messages ===== */
.alerts { margin-bottom: 20px; }
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 8px;
  border-left: 3px solid;
}
.alert-error   { background: rgba(229,57,53,.12);  border-color: var(--red);    color: #ff6b6b; }
.alert-success { background: rgba(76,175,80,.12);  border-color: var(--green);  color: #69d46d; }
.alert-info    { background: rgba(33,150,243,.12); border-color: var(--blue);   color: #64b5f6; }

/* ===== Cards ===== */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px 24px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 16px; font-weight: 600; }

.stat-row {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.stat-card {
  flex: 1;
  min-width: 140px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  text-align: center;
}
.stat-card .num { font-size: 28px; font-weight: 700; }
.stat-card .lbl { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.stat-orange { border-top: 3px solid var(--orange); }
.stat-green  { border-top: 3px solid var(--green); }
.stat-red    { border-top: 3px solid var(--red); }
.stat-blue   { border-top: 3px solid var(--blue); }

/* ===== Test cards (dashboard) ===== */
.test-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.test-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color .2s;
}
.test-card:hover { border-color: var(--orange); }
.test-card.passed   { border-left: 4px solid var(--green); }
.test-card.failed   { border-left: 4px solid var(--red); }
.test-card.progress { border-left: 4px solid var(--blue); }

.test-card-code {
  font-size: 11px;
  font-weight: 700;
  color: var(--orange);
  letter-spacing: .05em;
  text-transform: uppercase;
}
.test-card-title { font-size: 15px; font-weight: 600; line-height: 1.4; }
.test-card-meta { font-size: 12px; color: var(--text-muted); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-pass    { background: rgba(76,175,80,.2);  color: #69d46d; }
.badge-fail    { background: rgba(229,57,53,.2);  color: #ff6b6b; }
.badge-pending { background: rgba(138,143,160,.15); color: var(--text-muted); }
.badge-progress{ background: rgba(33,150,243,.2); color: #64b5f6; }

/* ===== Test question page ===== */
.test-wrapper {
  max-width: 740px;
  margin: 0 auto;
}

.test-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.test-counter { font-size: 13px; color: var(--text-muted); }
.test-title   { font-weight: 700; font-size: 15px; }

.progress-bar-wrap {
  background: var(--bg3);
  border-radius: 4px;
  height: 6px;
  margin-bottom: 28px;
}
.progress-bar-fill {
  height: 6px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--orange), var(--yellow));
  transition: width .3s;
}

.question-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px;
}
.question-text {
  font-size: 17px;
  font-weight: 500;
  line-height: 1.6;
  margin-bottom: 24px;
}

.options { display: flex; flex-direction: column; gap: 10px; }

.option-label {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 18px;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  font-size: 14px;
  line-height: 1.5;
}
.option-label:hover { border-color: var(--orange); background: rgba(243,112,33,.06); }
.option-label input[type=radio],
.option-label input[type=checkbox] {
  width: auto;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--orange);
}

.option-letter {
  min-width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.multi-hint {
  font-size: 12px;
  color: var(--blue);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.question-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ===== Result page ===== */
.result-hero {
  text-align: center;
  padding: 32px 0 20px;
}
.result-icon { font-size: 64px; margin-bottom: 12px; }
.result-score { font-size: 56px; font-weight: 800; }
.result-score.pass { color: var(--green); }
.result-score.fail { color: var(--red); }
.result-label { font-size: 20px; font-weight: 600; margin-top: 4px; }
.result-sub   { font-size: 14px; color: var(--text-muted); margin-top: 8px; }

.review-list { margin-top: 24px; display: flex; flex-direction: column; gap: 14px; }
.review-item {
  background: var(--bg3);
  border-radius: var(--radius);
  padding: 16px 18px;
  border-left: 4px solid var(--border);
}
.review-item.correct { border-color: var(--green); }
.review-item.wrong   { border-color: var(--red); }
.review-q { font-size: 14px; font-weight: 500; margin-bottom: 10px; }
.review-options { display: flex; flex-direction: column; gap: 5px; }
.review-opt {
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.review-opt.correct-ans { background: rgba(76,175,80,.18); color: #69d46d; }
.review-opt.wrong-ans   { background: rgba(229,57,53,.18);  color: #ff6b6b; }

/* ===== Admin table ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: var(--bg3);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:hover td { background: var(--bg3); }
tbody tr:last-child td { border-bottom: none; }

.cell-pass   { color: var(--green);  font-weight: 700; text-align: center; }
.cell-fail   { color: var(--red);    font-weight: 700; text-align: center; }
.cell-empty  { color: var(--text-muted); text-align: center; font-size: 16px; }

/* ===== Utilities ===== */
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.flex-gap { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ===== Timer ===== */
.timer-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .3s, background .3s;
}
.timer-val {
  font-family: 'Courier New', monospace;
  font-size: 22px;
  font-weight: 700;
  color: var(--green);
  letter-spacing: .05em;
  min-width: 58px;
  text-align: center;
  transition: color .3s;
}
.timer-wrap.timer-warning {
  border-color: rgba(253,216,53,.5);
  background: rgba(253,216,53,.07);
}
.timer-wrap.timer-warning .timer-val { color: var(--yellow); }
.timer-wrap.timer-critical {
  border-color: rgba(229,57,53,.6);
  background: rgba(229,57,53,.1);
  animation: timer-pulse 1s ease-in-out infinite;
}
.timer-wrap.timer-critical .timer-val { color: var(--red); }
@keyframes timer-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .7; }
}

/* ===== Mobile menu (details/summary, hidden on desktop) ===== */
.mobile-menu { display: none; position: relative; }

.mobile-menu-btn {
  list-style: none;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}
.mobile-menu-btn::-webkit-details-marker { display: none; }
.mobile-menu[open] .mobile-menu-btn {
  background: var(--bg2);
  border-color: var(--orange);
  color: var(--orange);
}

.mobile-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 160px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 200;
}
.mobile-menu-dropdown a {
  display: block;
  padding: 13px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.mobile-menu-dropdown a:last-child { border-bottom: none; }
.mobile-menu-dropdown a:hover { background: var(--bg3); color: var(--orange); }
.mobile-menu-logout { color: #e05252 !important; }
.mobile-menu-logout:hover { background: rgba(224,82,82,.1) !important; color: #e05252 !important; }
.mobile-menu-divider { border: none; border-top: 1px solid var(--border); margin: 0; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar     { display: none; }
  .mobile-menu { display: block; }
  .content     { padding: 16px; }
  .topbar      { padding: 10px 16px; }
  .test-grid   { grid-template-columns: 1fr; }
  .auth-card   { padding: 28px 20px; }
  .card-header { flex-wrap: wrap; gap: 10px; }
}
