:root {
  --bg: #eef2f9;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, rgba(99,102,241,.14), transparent 60%),
             radial-gradient(900px 500px at -10% 0%, rgba(6,182,212,.12), transparent 55%);
  --surface: #ffffff;
  --surface-2: #f1f4fa;
  --text: #111827;
  --muted: #6b7280;
  --border: #e6e9f2;
  --primary: #5b5bf6;
  --primary-600: #4744e0;
  --primary-grad: linear-gradient(135deg, #6366f1, #8b5cf6);
  --success: #16a34a;
  --warn: #d97706;
  --error: #dc2626;
  --accent: #06b6d4;
  --shadow: 0 10px 30px rgba(17, 24, 39, .08);
  --shadow-hover: 0 16px 40px rgba(79, 70, 229, .16);
  --radius: 18px;
}
[data-theme="dark"] {
  --bg: #0b1120;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, rgba(99,102,241,.20), transparent 60%),
             radial-gradient(900px 500px at -10% 0%, rgba(6,182,212,.14), transparent 55%);
  --surface: #151e31;
  --surface-2: #1d2840;
  --text: #e8edf6;
  --muted: #94a3b8;
  --border: #2a364d;
  --primary: #a5b4fc;
  --primary-600: #818cf8;
  --primary-grad: linear-gradient(135deg, #818cf8, #a78bfa);
  --shadow: 0 10px 30px rgba(0, 0, 0, .4);
  --shadow-hover: 0 16px 40px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Manrope', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background .25s, color .25s;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Navbar */
.nav {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(17,24,39,.05);
  position: sticky; top: 0; z-index: 10;
}
.nav .brand {
  font-weight: 800; font-size: 1.3rem; display: flex; align-items: center; gap: 8px;
  background: var(--primary-grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.nav .brand:hover { text-decoration: none; }
.nav .spacer { flex: 1; }
.nav .nav-link { color: var(--muted); font-weight: 600; padding: 6px 2px; position: relative; }
.nav .nav-link:hover { color: var(--text); text-decoration: none; }
.nav .nav-link:hover::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px;
  background: var(--primary-grad); border-radius: 2px;
}
.nav .badge-role { background: var(--surface-2); padding: 5px 12px; border-radius: 999px; font-size: .8rem; color: var(--muted); }

.container { max-width: 1040px; margin: 32px auto; padding: 0 20px; }
.container-narrow { max-width: 460px; margin: 6vh auto; padding: 0 20px; }

h1, h2, h3 { color: var(--text); }
.page-title { font-size: 1.8rem; margin: 0 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 24px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  transition: transform .18s ease, box-shadow .18s ease;
}
.card:hover { box-shadow: var(--shadow-hover); }
.card + .card { margin-top: 20px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* Stat cards */
.stat {
  position: relative; overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px; text-align: center; box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}
.stat::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--primary-grad);
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.stat .value {
  font-size: 2.2rem; font-weight: 800; line-height: 1.1;
  background: var(--primary-grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.stat .label { color: var(--muted); font-size: .88rem; margin-top: 4px; }

/* Forms */
label { font-weight: 600; font-size: .9rem; display: block; margin-top: 14px; }
input, select, textarea, button {
  width: 100%; padding: 12px 14px; margin-top: 6px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  font-size: 1rem; box-sizing: border-box; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: transparent; }
.btn {
  background: var(--primary-grad); color: #fff; border: none; cursor: pointer;
  font-weight: 700; box-shadow: 0 6px 16px rgba(91,91,246,.28);
  transition: filter .2s, transform .05s, box-shadow .2s;
}
.btn:hover { filter: brightness(1.06); box-shadow: 0 10px 22px rgba(91,91,246,.36); }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.btn-ghost:hover { filter: none; background: var(--border); box-shadow: none; }
.btn-danger { background: var(--error); box-shadow: 0 6px 16px rgba(220,38,38,.25); }
.btn-warn { background: var(--warn); box-shadow: 0 6px 16px rgba(217,119,6,.25); }
.btn-sm { width: auto; padding: 7px 14px; font-size: .85rem; margin-top: 0; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form { display: inline; }

/* Table */
table { width: 100%; border-collapse: collapse; margin-top: 8px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: var(--surface-2); }

/* Pills / chips */
.pill { padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.pill-on { background: rgba(22,163,74,.15); color: var(--success); }
.pill-off { background: rgba(220,38,38,.15); color: var(--error); }

/* Flash */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 12px; font-weight: 600; }
.flash.success { background: rgba(22,163,74,.15); color: var(--success); }
.flash.error { background: rgba(220,38,38,.15); color: var(--error); }
.flash.warn { background: rgba(217,119,6,.15); color: var(--warn); }
.flash.info { background: rgba(79,70,229,.12); color: var(--primary); }

/* Language switch */
.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.lang-switch a { padding: 5px 12px; font-size: .8rem; font-weight: 700; color: var(--muted); }
.lang-switch a:hover { text-decoration: none; color: var(--text); }
.lang-switch a.active { background: var(--primary-grad); color: #fff; }

/* Theme toggle */
.theme-toggle { background: var(--surface-2); border: 1px solid var(--border); width: 40px; height: 40px;
  border-radius: 50%; cursor: pointer; font-size: 1.1rem; display: grid; place-items: center; padding: 0; margin: 0; }

/* Star rating */
.stars { display: flex; flex-direction: row-reverse; justify-content: center; gap: 6px; margin: 10px 0; }
.stars input { display: none; }
.stars label { font-size: 2.4rem; color: var(--border); cursor: pointer; width: auto; margin: 0; transition: color .15s, transform .1s; }
.stars label:hover, .stars label:hover ~ label,
.stars input:checked ~ label { color: #f59e0b; }
.stars label:hover { transform: scale(1.15); }

/* Mood picker */
.moods { display: flex; justify-content: center; gap: 14px; margin: 12px 0; }
.moods input { display: none; }
.moods label { font-size: 2.2rem; cursor: pointer; width: auto; margin: 0; padding: 8px;
  border-radius: 12px; filter: grayscale(.8); opacity: .55; transition: all .15s; }
.moods input:checked + label { filter: none; opacity: 1; background: var(--surface-2); transform: scale(1.12); }

.link-box { background: var(--surface-2); border: 1px dashed var(--primary); border-radius: 10px;
  padding: 14px; text-align: center; word-break: break-all; }
.qr { border: 8px solid var(--surface); border-radius: 12px; background: #fff; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* Print / PDF отчёт */
@media print {
  .nav, .no-print, .theme-toggle { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .stat { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .container { margin: 0; max-width: 100%; }
  a { color: #000; text-decoration: none; }
}
.report-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.report-brand { font-weight: 800; color: var(--primary); font-size: 1.3rem; }

/* Кастомдук модалка */
.ep-modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(15, 23, 42, .55); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; transition: opacity .18s ease;
}
.ep-modal-overlay.open { display: flex; opacity: 1; }
.ep-modal {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
  width: 100%; max-width: 420px; padding: 24px;
  transform: translateY(8px) scale(.98); transition: transform .18s ease;
}
.ep-modal-overlay.open .ep-modal { transform: translateY(0) scale(1); }
.ep-modal-title { margin: 0 0 6px; font-size: 1.2rem; }
.ep-modal-text { margin: 0 0 16px; color: var(--muted); }
.ep-modal-text:empty { display: none; }
.ep-modal-input { margin: 0 0 18px; }
.ep-modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.ep-modal-actions .btn { width: auto; min-width: 96px; }
.center { text-align: center; }
.mt { margin-top: 18px; }
.muted { color: var(--muted); }

/* Карточка сабак (студент тандоо) */
.lesson-card {
  display: block; padding: 16px 18px; border: 1px solid var(--border);
  border-radius: 14px; background: var(--surface-2); color: var(--text);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.lesson-card:hover { text-decoration: none; transform: translateY(-2px);
  box-shadow: var(--shadow-hover); border-color: var(--primary); }
.lesson-card .lesson-name { font-weight: 700; font-size: 1.1rem; }

/* Период тренда */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg a { padding: 6px 12px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.seg a:hover { text-decoration: none; color: var(--text); }
.seg a.active { background: var(--primary-grad); color: #fff; }

/* Адаптивдүүлүк */
@media (max-width: 720px) {
  .container, .container-narrow { margin: 18px auto; padding: 0 14px; }
  .nav { padding: 12px 16px; gap: 10px; }
  .card { padding: 18px; }
  /* таблицалар тар экранда горизонталдык скролл менен */
  table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .stat .value { font-size: 1.8rem; }
  .page-title { font-size: 1.4rem; }
}
