:root {
  --primary: #2980b9;
  --primary-dark: #2471a3;
  --dark: #2c3e50;
  --dark-light: #34495e;
  --gray: #7f8c8d;
  --gray-light: #ddd;
  --gray-bg: #f5f7fa;
  --white: #fff;
  --green: #27ae60;
  --green-bg: #d5f5e3;
  --red: #e74c3c;
  --red-bg: #fadbd8;
  --yellow: #f39c12;
  --yellow-bg: #fef9e7;
  --orange: #e67e22;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.15);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--gray-bg);
  color: #333;
  min-height: 100vh;
}

.public-nav {
  background: var(--dark);
  padding: 12px 20px;
  text-align: center;
}
.public-nav h2 {
  color: var(--white);
  margin: 0;
  font-size: 16px;
  font-weight: 400;
}

.navbar {
  background: var(--dark);
  color: var(--white);
  padding: 0 16px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-container {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.nav-brand {
  color: var(--white);
  text-decoration: none;
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--white);
  font-size: 26px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 20px;
  align-items: center;
}

.nav-links a {
  color: #ddd;
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s;
  white-space: nowrap;
}

.nav-links a:hover { color: var(--white); }

@media (max-width: 768px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--dark);
    flex-direction: column;
    gap: 0;
    padding: 8px 0;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  }
  .nav-links.open { display: flex; }
  .nav-links li { width: 100%; }
  .nav-links a {
    display: block;
    padding: 14px 24px;
    font-size: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px;
}

h1 { font-size: 26px; margin-bottom: 18px; color: var(--dark); }
h2 { font-size: 20px; margin: 22px 0 14px; color: var(--dark-light); }

@media (max-width: 480px) {
  h1 { font-size: 22px; }
  h2 { font-size: 18px; }
}

.stats-grid {
  display: flex;
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  flex: 1;
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  text-align: center;
}

.stat-card h3 { font-size: 32px; margin: 0; color: var(--dark); }
.stat-card p { font-size: 13px; color: var(--gray); margin-top: 4px; }

@media (max-width: 600px) {
  .stats-grid { flex-direction: column; gap: 12px; }
  .stat-card { padding: 16px; }
  .stat-card h3 { font-size: 28px; }
}

.actions-grid {
  display: flex;
  gap: 16px;
}

.action-card {
  flex: 1;
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: #333;
  transition: box-shadow 0.2s, transform 0.2s;
}

.action-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.action-card h3 { margin: 0 0 6px; color: var(--primary); font-size: 18px; }
.action-card p { font-size: 13px; color: var(--gray); }

@media (max-width: 600px) {
  .actions-grid { flex-direction: column; gap: 12px; }
}

.inline-form {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--white);
  padding: 16px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.inline-form input,
.inline-form select {
  padding: 10px 14px;
  border: 1px solid var(--gray-light);
  border-radius: 6px;
  font-size: 14px;
  min-height: 44px;
}

button, .btn, .inline-form button {
  padding: 10px 24px;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
  display: inline-block;
  min-height: 44px;
  line-height: 1.4;
}

button:hover, .btn:hover, .inline-form button:hover { background: var(--primary-dark); }

.btn-secondary { background: var(--gray); }
.btn-secondary:hover { background: #7f8c8d; }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #c0392b; }
.btn-small { padding: 6px 14px; font-size: 12px; min-height: 32px; }

.data-table {
  width: 100%;
  background: var(--white);
  border-radius: var(--radius);
  overflow-x: auto;
  display: block;
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}

.data-table table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  background: #f8f9fa;
  font-weight: 600;
  font-size: 13px;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table tr:not(:last-child) td { border-bottom: 1px solid #eee; }
.data-table tr:hover td { background: #f8f9fa; }

@media (max-width: 768px) {
  .data-table table { min-width: auto; }
  .data-table th, .data-table td { padding: 10px 12px; white-space: normal; }
}

@media (max-width: 480px) {
  .data-table { font-size: 13px; }
  .data-table th, .data-table td { padding: 8px 10px; }
}

.test-form {
  background: var(--white);
  padding: 22px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 14px;
  color: #555;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--gray-light);
  border-radius: 6px;
  font-size: 15px;
  min-height: 44px;
}

.test-form button[type="submit"] { margin-top: 10px; width: 100%; }

.question-card {
  background: var(--white);
  border: 1px solid #e0e0e0;
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  transition: border-color 0.2s;
}

.question-card:hover { border-color: #b0b0b0; }
.question-card.correct { border-left: 4px solid var(--green); }
.question-card.incorrect { border-left: 4px solid var(--red); }

.q-number { font-weight: 700; color: var(--primary); }
.question-text { font-size: 16px; margin-bottom: 12px; line-height: 1.5; }

.options { margin: 10px 0 0 0; }

.option-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0;
  font-size: 15px;
  cursor: pointer;
  padding: 10px 12px;
  border: 1px solid #eee;
  border-radius: 6px;
  transition: background 0.15s, border-color 0.15s;
}

.option-label:hover { background: #f8f9fa; border-color: var(--gray-light); }

.option-label input[type="radio"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.answer-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--gray-light);
  border-radius: 6px;
  font-size: 15px;
  min-height: 44px;
}

@media (max-width: 480px) {
  .question-card { padding: 14px; }
  .question-text { font-size: 15px; }
  .option-label { font-size: 14px; padding: 12px; }
}

.test-meta { font-size: 14px; color: var(--gray); margin-bottom: 18px; line-height: 1.6; }

.result-summary {
  display: flex;
  gap: 24px;
  align-items: center;
  background: var(--white);
  padding: 22px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.score-display {
  text-align: center;
  min-width: 130px;
  padding: 18px;
  border-radius: var(--radius);
}

.score-number { display: block; font-size: 34px; font-weight: 700; }
.score-pct { font-size: 15px; }
.score-good { background: var(--green-bg); color: #1e8449; }
.score-ok { background: #fdebd0; color: #b7950b; }
.score-bad { background: var(--red-bg); color: #c0392b; }

@media (max-width: 480px) {
  .result-summary { flex-direction: column; text-align: center; gap: 12px; padding: 16px; }
  .score-display { min-width: auto; width: 100%; }
}

.text-green { color: var(--green); font-weight: 600; }
.text-red { color: var(--red); font-weight: 600; }
.text-orange { color: var(--orange); font-weight: 600; }

.alert {
  background: var(--yellow-bg);
  border: 1px solid #f9e79f;
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 14px;
  font-size: 14px;
  line-height: 1.5;
}

.alert-error {
  background: var(--red-bg);
  border-color: var(--red);
  color: #c0392b;
}

.alert-success {
  background: var(--green-bg);
  border-color: var(--green);
  color: #1e8449;
}

.student-list {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.student-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px 24px;
  text-decoration: none;
  color: #333;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
  flex: 1;
  min-width: 200px;
}

.student-card:hover { box-shadow: var(--shadow-hover); }
.student-card h3 { margin: 0 0 4px; color: var(--dark); font-size: 16px; }
.student-card p { font-size: 13px; color: var(--gray); margin: 0; }

.start-screen { text-align: center; padding: 40px 16px; }
.start-screen h2 { font-size: 24px; margin-bottom: 12px; }
.start-screen p { font-size: 15px; color: var(--gray); margin-bottom: 6px; }

.start-btn { font-size: 18px !important; padding: 16px 40px !important; }
.learn-btn {
  font-size: 18px !important;
  padding: 16px 40px !important;
  background: #8e44ad !important;
}
.learn-btn:hover { background: #7d3c98 !important; }

.start-actions { display: flex; gap: 12px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }

@media (max-width: 480px) {
  .start-screen { padding: 24px 12px; }
  .start-screen h2 { font-size: 20px; }
  .start-btn, .learn-btn { width: 100%; text-align: center; }
}

.timer-bar { text-align: right; margin-bottom: 14px; }

#timer {
  display: inline-block;
  background: var(--dark);
  color: var(--white);
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 18px;
  font-weight: 700;
  font-family: monospace;
  letter-spacing: 1px;
}

.token-url-box {
  background: var(--yellow-bg);
  border: 1px solid #f9e79f;
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.token-url-box input {
  flex: 1;
  min-width: 160px;
  padding: 8px 10px;
  border: 1px solid var(--gray-light);
  border-radius: 4px;
  font-size: 12px;
  background: var(--white);
  min-height: 36px;
}

.token-url-box button {
  padding: 8px 14px;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  min-height: 36px;
}

.learn-grid { display: flex; gap: 16px; flex-wrap: wrap; }

.learn-category {
  flex: 1;
  min-width: 220px;
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.learn-category h3 { font-size: 16px; color: var(--dark); margin-bottom: 10px; }

.grade-links { display: flex; flex-wrap: wrap; gap: 6px; }

.grade-link {
  display: inline-block;
  padding: 6px 14px;
  background: #ebf5fb;
  color: var(--primary);
  border-radius: 4px;
  font-size: 13px;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}

.grade-link:hover { background: var(--primary); color: var(--white); }

.lang-selector {
  margin-bottom: 18px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.lang-selector form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.lang-selector label { font-size: 13px; color: var(--gray); }

.lang-selector select {
  padding: 8px 12px;
  border: 1px solid var(--gray-light);
  border-radius: 6px;
  font-size: 14px;
  min-height: 40px;
}

.status-badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 6px;
  font-weight: 600;
}

.status-due { background: var(--orange); color: var(--white); }
.status-paid { background: var(--green); color: var(--white); }
.status-canceled { background: #95a5a6; color: var(--white); }

.correct-badge {
  display: inline-block;
  background: #f1c40f;
  color: var(--white);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 4px;
  font-weight: 600;
}

.apk-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  background: #27ae60;
  color: var(--white);
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  transition: background 0.2s;
  margin-bottom: 20px;
}

.apk-download:hover { background: #219a52; }

/* Bottom navigation for mobile */
.bottom-nav {
  display: none;
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  background: var(--white);
  border-top: 1px solid #e0e0e0;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
  z-index: 999;
  padding: 6px 0;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.bottom-nav-inner {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #95a5a6;
  font-size: 10px;
  padding: 4px 12px;
  border-radius: 8px;
  transition: color 0.2s;
  min-width: 56px;
  gap: 1px;
}

.bottom-nav a.active {
  color: var(--primary);
}

.bottom-nav .nav-icon {
  font-size: 22px;
  line-height: 1;
}

@media (max-width: 768px) {
  .bottom-nav { display: block !important; }
  .container { padding-bottom: 80px; }
}
