@font-face {
  font-family: 'Vazirmatn';
  src: url('/assets/fonts/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('/assets/fonts/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700; font-display: swap;
}
:root {
  --c-primary: #1565c0;
  --c-primary-d: #0d47a1;
  --c-success: #2e7d32;
  --c-warn: #f9a825;
  --c-danger: #c62828;
  --c-bg: #f4f7fb;
  --c-card: #ffffff;
  --c-border: #d6dee8;
  --c-text: #1f2d3d;
  --c-muted: #5b6b7c;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(15,40,80,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.6;
  font-size: 14px;
}
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--c-primary-d); }
button, input, select, textarea { font-family: inherit; font-size: 14px; }

/* Auth */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card {
  background: var(--c-card); width: 100%; max-width: 400px;
  padding: 28px; border-radius: var(--radius); box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 20px; margin: 0 0 4px; }
.auth-card form { display: grid; gap: 10px; margin-top: 16px; }
.auth-card label { font-size: 13px; color: var(--c-muted); }
.auth-card input { padding: 10px 12px; border: 1px solid var(--c-border); border-radius: 8px; width: 100%; }
.auth-card button { margin-top: 8px; padding: 11px; border: 0; border-radius: 8px; background: var(--c-primary); color: #fff; font-weight: 700; cursor: pointer; }

/* Layout */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: #fff; padding: 12px 20px; border-bottom: 1px solid var(--c-border);
  position: sticky; top: 0; z-index: 100;
}
.topbar-brand { display: flex; gap: 10px; align-items: center; }
.brand-icon { font-size: 22px; }
.topbar-brand small { display: block; color: var(--c-muted); font-size: 11px; }
.topbar-user { display: flex; gap: 10px; align-items: center; }

.layout { display: flex; min-height: calc(100vh - 60px); }
.sidebar {
  width: 230px; background: #fff; border-left: 1px solid var(--c-border);
  padding: 16px 10px; flex-shrink: 0;
}
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  padding: 9px 12px; border-radius: 8px; color: var(--c-text); font-size: 13.5px;
}
.nav-link:hover { background: #eef3fa; text-decoration: none; }
.nav-link.active { background: var(--c-primary); color: #fff; }
.content { flex: 1; padding: 20px; max-width: 1400px; margin: 0 auto; width: 100%; }

/* Cards */
.card {
  background: var(--c-card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 18px;
}
.card h2 { margin: 0 0 14px; font-size: 16px; }
.page-title { font-size: 20px; margin: 0 0 18px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card { background: var(--c-card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stat-card span { display: block; color: var(--c-muted); font-size: 12px; }
.stat-card strong { display: block; font-size: 22px; color: var(--c-primary-d); margin-top: 4px; }

.grid-2col { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 18px; }
@media (max-width: 900px) { .grid-2col { grid-template-columns: 1fr; } }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--c-muted); }
.form-grid input, .form-grid select { padding: 9px 11px; border: 1px solid var(--c-border); border-radius: 8px; }
.form-grid-full { grid-column: 1 / -1; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 8px; margin-top: 8px; }
fieldset { border: 1px solid var(--c-border); border-radius: 8px; padding: 12px; }
legend { padding: 0 8px; font-weight: 700; color: var(--c-primary-d); }
label.checkbox { flex-direction: row; align-items: center; gap: 6px; display: inline-flex; margin-left: 12px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 9px 14px; border-radius: 8px; border: 1px solid transparent;
  background: #fff; color: var(--c-text); cursor: pointer; font-weight: 600; font-size: 13.5px;
  text-decoration: none; line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-d); }
.btn-success { background: var(--c-success); color: #fff; }
.btn-danger { background: var(--c-danger); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--c-border); color: var(--c-text); }
.btn-ghost:hover { background: #eef3fa; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.inline { display: inline; }

/* Tables */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: 9px 11px; border-bottom: 1px solid var(--c-border); text-align: right; font-size: 13px; }
.table th { background: #eef3fa; color: var(--c-primary-d); font-weight: 700; }
.table tr:hover td { background: #f8fafd; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Alerts */
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13.5px; }
.alert-success { background: #e7f6ec; color: #0b6b34; }
.alert-error { background: #fdecec; color: #a40000; }
.alert-warning { background: #fff7e3; color: #8a5a00; }

/* Misc */
.muted { color: var(--c-muted); font-size: 13px; }
.toolbar { margin-bottom: 14px; }
.filter-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-form input, .filter-form select { padding: 8px 10px; border: 1px solid var(--c-border); border-radius: 8px; }
.simple-list { margin: 0; padding-right: 20px; }
.error-list li { color: var(--c-danger); }
.warning-list li { color: #8a5a00; }
.grade-input { width: 80px; padding: 6px; border: 1px solid var(--c-border); border-radius: 6px; text-align: center; }

/* Report */
.report-body { background: #eef2f7; padding: 20px; }
.report-card { max-width: 800px; margin: 0 auto; background: #fff; padding: 24px; border-radius: var(--radius); box-shadow: var(--shadow); }
.report-header { display: flex; justify-content: space-between; border-bottom: 2px solid var(--c-primary); padding-bottom: 8px; margin-bottom: 12px; }
.report-header h1 { font-size: 18px; margin: 0; }
.report-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin-bottom: 12px; font-size: 13.5px; }
.report-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.report-table th, .report-table td { border: 1px solid #cbd5e1; padding: 6px; text-align: center; }
.report-table th { background: #e3eaf3; }
.report-totals { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 12px; font-size: 13.5px; }
.report-signatures { display: flex; justify-content: space-between; margin-top: 28px; }
.report-signatures > div { border-top: 1px dashed #888; width: 30%; text-align: center; padding-top: 6px; font-size: 12.5px; }
.report-actions { margin-top: 18px; display: flex; gap: 8px; }
.chart-box { margin-top: 18px; }
.chart-legend { font-size: 12px; color: var(--c-muted); text-align: center; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 4px 0 12px; }
.dot-student { background: #1565c0; }
.dot-class { background: #9e9e9e; }

/* Error page */
.error-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.error-card { background: #fff; padding: 32px; border-radius: var(--radius); box-shadow: var(--shadow); text-align: center; max-width: 420px; }
.error-card h1 { margin: 0 0 12px; color: var(--c-danger); }

/* Print */
@media print {
  .topbar, .sidebar, .no-print, .report-actions { display: none !important; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 1px solid var(--c-border); }
  body { background: #fff; }
  .report-card { box-shadow: none; }
}

/* Responsive */
@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; border-left: 0; border-bottom: 1px solid var(--c-border); }
  .sidebar nav { flex-direction: row; overflow-x: auto; }
  .nav-link { white-space: nowrap; }
  .content { padding: 12px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .report-meta, .report-totals { grid-template-columns: 1fr; }
}

/* ---------- ثبت نمره: کدهای غیبت و پرچم نظم کلاس ---------- */
.absence-hint {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  background: #f4f8fd; border: 1px dashed var(--c-border);
  border-radius: 8px; padding: 9px 12px; margin: 10px 0; font-size: 12.5px;
}
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.pill-excused { background: #fff4e0; color: #8a5a00; border: 1px solid #f0cf94; }
.pill-absent  { background: #fdecea; color: #a4161a; border: 1px solid #f2b8b3; }

.grade-input.is-excused { background: #fff4e0; border-color: #e0b070; color: #8a5a00; font-weight: 700; }
.grade-input.is-absent  { background: #fdecea; border-color: #e08f88; color: #a4161a; font-weight: 700; }
.table tr.row-flagged td { background: #fff7f6; }
.table tr.row-flagged td:nth-child(2)::after {
  content: ' ⚑'; color: var(--c-danger);
}
.inline-form-hidden { display: none; }