:root {
  --primary: #2b6cb0;
  --primary-dark: #1a4f8b;
  --success: #2f855a;
  --danger: #c53030;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1a202c;
  --muted: #718096;
  --border: #e2e8f0;
}

* { box-sizing: border-box; }

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

.container { max-width: 960px; margin: 0 auto; padding: 0 16px; }
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 1.8rem; margin: 16px 0 8px; }
h2 { font-size: 1.25rem; }
.muted { color: var(--muted); }

/* header/footer */
.site-header { background: #fff; border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
.logo { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.site-nav { display: flex; align-items: center; gap: 12px; }
.nav-user { color: var(--muted); }
.site-footer { margin-top: 40px; padding: 16px; text-align: center; color: var(--muted); border-top: 1px solid var(--border); }

/* buttons */
.btn {
  display: inline-block; padding: 9px 16px; border-radius: 6px; border: 1px solid transparent;
  cursor: pointer; font-size: 0.95rem; background: #edf2f7; color: var(--text);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: #fff; border-color: var(--border); }
.btn-sm { padding: 5px 10px; font-size: 0.85rem; }
.btn-lg { padding: 12px 24px; font-size: 1.05rem; }

/* flash */
.flash-wrap { margin: 12px 0; }
.flash { padding: 10px 14px; border-radius: 6px; margin: 6px 0; }
.flash-success { background: #e6fffa; color: #234e52; }
.flash-danger, .flash-error { background: #fff5f5; color: #822727; }
.flash-warning { background: #fffff0; color: #744210; }
.flash-info { background: #ebf8ff; color: #2a4365; }

/* hero & grid */
.hero { text-align: center; padding: 40px 0 24px; }
.hero h1 { font-size: 2rem; margin-bottom: 8px; }
.hero p { color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; padding: 16px 0 40px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 18px; color: var(--text); display: block; transition: box-shadow .15s; }
.card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.card h2 { margin: 0 0 8px; font-size: 1.1rem; }
.card p { color: var(--muted); font-size: .9rem; }
.card-link { color: var(--primary); font-size: .9rem; }

.empty { padding: 24px; text-align: center; color: var(--muted); background: #fff; border: 1px dashed var(--border); border-radius: 8px; }
.notice { background: #ebf8ff; border: 1px solid #bee3f8; padding: 14px; border-radius: 8px; margin: 12px 0; }
.block { margin: 20px 0; }
.back-link { display: inline-block; margin-top: 16px; color: var(--muted); }

/* auth */
.auth-card { max-width: 380px; margin: 40px auto; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 28px; }
.auth-card h1 { font-size: 1.4rem; margin-top: 0; }

/* forms */
label { display: block; margin: 12px 0; font-weight: 500; }
input[type=text], input[type=password], input[type=number], input[type=file], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: .95rem; margin-top: 4px; background: #fff;
}
textarea { font-family: inherit; }
label.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 400; }
label.checkbox input { width: auto; }
.search-row { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.search-row input, .search-row select { width: auto; flex: 1; min-width: 140px; margin-top: 0; }

/* materials */
.materials { list-style: none; padding: 0; margin: 0; }
.material { display: flex; justify-content: space-between; gap: 12px; align-items: center; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin: 8px 0; }
.material-text { white-space: pre-wrap; color: var(--text); margin-top: 6px; font-size: .9rem; }
.material-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* tests rows */
.test-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin: 8px 0; }
.test-actions { flex-shrink: 0; }
.badge-ok { color: var(--success); font-weight: 600; }
.badge-fail { color: var(--danger); font-weight: 600; }

/* test taking */
.timer { position: sticky; top: 0; background: #fff; border: 1px solid var(--border); padding: 8px 14px; border-radius: 8px; font-weight: 600; margin: 12px 0; z-index: 5; }
.question { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 18px; margin: 16px 0; }
.q-num { color: var(--primary); }
.q-image { max-width: 100%; max-height: 320px; display: block; margin: 10px 0; border-radius: 6px; }
.options { margin-top: 10px; }
.option { display: flex; align-items: flex-start; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; margin: 6px 0; cursor: pointer; }
.option:hover { background: #f7fafc; }
.option input { margin-top: 4px; }
.o-image { max-width: 160px; max-height: 100px; border-radius: 4px; }

/* results */
.result-card { text-align: center; padding: 30px; border-radius: 10px; margin: 16px 0; }
.result-passed { background: #e6fffa; border: 1px solid #9ae6b4; }
.result-failed { background: #fff5f5; border: 1px solid #feb2b2; }
.result-score { font-size: 2.4rem; font-weight: 700; }
.result-percent { font-size: 1.4rem; color: var(--muted); }
.result-status { margin-top: 8px; font-weight: 600; }
.review { border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin: 8px 0; background: #fff; }
.review-ok { border-left: 4px solid var(--success); }
.review-bad { border-left: 4px solid var(--danger); }
.review-head { font-weight: 600; }
.review-options { list-style: none; padding: 0; margin: 8px 0 0; }
.review-options li { padding: 4px 0; }
.review-options li.correct { color: var(--success); font-weight: 600; }
.review-options li.wrong { color: var(--danger); }

/* admin layout */
.admin-body { display: flex; min-height: 100vh; }
.admin-sidebar { width: 220px; background: #1a202c; color: #fff; padding: 16px; flex-shrink: 0; }
.admin-brand { font-size: 1.2rem; font-weight: 700; padding: 8px 4px 16px; }
.admin-nav { display: flex; flex-direction: column; gap: 4px; }
.admin-nav a { color: #cbd5e0; padding: 8px 10px; border-radius: 6px; }
.admin-nav a:hover { background: #2d3748; color: #fff; }
.admin-main { flex: 1; padding: 20px 24px; max-width: 1100px; }
.admin-login { max-width: 360px; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin: 8px 0 16px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 16px 0; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 16px; text-align: center; }
.stat-num { font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.panel { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin: 16px 0; }

.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { background: #f7fafc; font-size: .85rem; text-transform: uppercase; color: var(--muted); }
.row-actions { display: flex; gap: 6px; align-items: center; }
.update-output { background: #1a202c; color: #a0f0a0; padding: 12px; border-radius: 6px; white-space: pre-wrap; font-size: .85rem; margin-top: 10px; }

/* editor */
.editor-add { display: flex; gap: 8px; }
.editor-add input { flex: 1; }
.editor-add select { width: auto; margin-top: 0; }
.question-editor { padding: 16px; }
.qe-head { display: flex; gap: 8px; align-items: center; }
.qe-head .qe-text { flex: 1; margin-top: 0; }
.qe-head select { width: auto; margin-top: 0; }
.qe-image img { max-width: 240px; max-height: 160px; margin: 8px 0; border-radius: 6px; }
.qe-image-upload { margin: 6px 0; }
.options { display: flex; flex-direction: column; gap: 6px; }
.option-row { display: flex; gap: 8px; align-items: center; }
.option-row input[type=text] { flex: 1; margin-top: 0; }
.option-row input[type=checkbox] { width: auto; }
.opt-img { max-width: 80px; max-height: 50px; border-radius: 4px; }

/* print protocol */
.print-page { max-width: 700px; margin: 20px auto; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 32px; }
.print-title { text-align: center; font-size: 1.5rem; font-weight: 700; margin: 0 0 4px; }
.print-org { text-align: center; color: var(--muted); margin-bottom: 20px; }
.print-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.print-row span:first-child { color: var(--muted); }
.print-result { margin: 24px 0; text-align: center; font-size: 1.2rem; font-weight: 600; }
.print-signature { margin-top: 60px; display: flex; justify-content: space-between; }
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .print-page { border: none; }
}

/* wp import */
.import-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 12px; }
.import-grid label { margin: 0; }
.import-grid input { margin-top: 2px; }
.import-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.dump-checks { display: flex; gap: 16px; flex-wrap: wrap; margin: 8px 0; }
.dump-checks label.checkbox { margin: 0; }
