/* ==========================================================================
   ویرگول مدرسه: کارنامه، جدول نمره، نمودارها، برنامه هفتگی، حضور و غیاب و صفحات عمومی
   ========================================================================== */

/* --- ستون کناری */
.school-badge { text-decoration: none; }
.school-badge .avatar { border-radius: 14px; }
.school-year { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 10px; background: var(--primary-soft, rgba(255, 255, 255, 0.06)); color: var(--primary, #d9d5ca); font-size: 12.5px; font-weight: 700; }

/* --- سطح نمره */
.lv-excellent { --lv: #1d8a5a; } .lv-good { --lv: #2f6bc8; } .lv-fair { --lv: #b07419; } .lv-weak { --lv: #c93e2d; } .lv-none { --lv: #9ca3af; }
.lv-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--lv); flex: none; }
.lv-text { color: var(--lv); font-weight: 800; }
.lv-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; color: var(--lv); background: color-mix(in srgb, var(--lv) 12%, transparent); }

/* --- فهرست قدم‌های راه‌اندازی */
.checklist { display: flex; flex-direction: column; gap: 6px; }
.checklist a { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 14px; background: var(--surface-2); font-weight: 650; font-size: 14px; transition: background 0.2s; }
.checklist a:hover { background: var(--surface-3); }
.checklist .tick { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; border: 2px solid var(--border-strong); color: transparent; }
.checklist .is-done .tick { background: var(--green); border-color: var(--green); color: #fff; }
.checklist .is-done span { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--border-strong); }
.meter { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #1d8a5a, #4cc38a); }

/* --- کارت‌های کوچک فهرستی */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; border-radius: 22px; background: var(--surface); border: 1px solid var(--border); transition: border-color 0.2s, transform 0.3s var(--ease); }
a.tile:hover { border-color: var(--ink); transform: translateY(-2px); }
.tile strong { font-size: 16px; }
.tile small { color: var(--muted); font-size: 12.5px; }
.tile .row { gap: 6px; }
.grade-head { display: flex; align-items: center; gap: 10px; margin: 6px 0 12px; font-size: 16px; }
.grade-head::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* --- جدول ثبت نمره (شبیه برگه اکسل) */
.sheet { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.sheet th { position: sticky; top: 0; z-index: 1; background: #5b3a1e; color: #fff; padding: 10px 12px; font-size: 12.5px; text-align: center; white-space: nowrap; }
.sheet th:first-child { border-radius: 0 14px 0 0; } .sheet th:last-child { border-radius: 14px 0 0 0; }
.sheet td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: center; }
.sheet tbody tr:nth-child(even) td { background: color-mix(in srgb, #f4c48a 10%, transparent); }
.sheet td.name { text-align: start; font-weight: 700; white-space: nowrap; }
.sheet .score-input { width: 90px; height: 40px; text-align: center; direction: ltr; font-weight: 800; font-size: 15px; border-radius: 12px; }
.sheet .score-input:invalid { border-color: var(--red); background: var(--red-soft); }
.sheet .cell-score { font-weight: 800; font-variant-numeric: tabular-nums; }
.sheet .vertical { writing-mode: vertical-rl; transform: rotate(180deg); padding-block: 14px; height: 120px; }
.sheet tfoot td { font-weight: 800; background: var(--surface-2); }
.sheet-wrap { overflow: auto; max-height: 70vh; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); }
.period-bar { display: flex; gap: 4px; flex-wrap: wrap; padding: 5px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.period-bar a { padding: 5px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.period-bar a:hover { background: var(--surface-2); }
.period-bar a.is-active { background: var(--ink); color: var(--on-ink); }
.period-bar a .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--green); margin-inline-start: 6px; vertical-align: middle; }

/* --- کارنامه ماهانه (الهام از کارنامه‌ساز اکسلی) */
.report { --rc: #6b4423; position: relative; width: 100%; max-width: 860px; margin-inline: auto; background: #fff; color: #1a1b20; border: 3px solid var(--rc); border-radius: 18px; padding: 16px; box-shadow: var(--shadow-lg); }
.report.theme-green { --rc: #2e6b33; } .report.theme-pink { --rc: #b0297a; } .report.theme-dark { --rc: #1f2937; }
.report-title { margin: 0 0 12px; padding: 10px; border-radius: 10px; background: var(--rc); color: #fff; text-align: center; font-size: 20px; font-weight: 900; }
.report-info { display: grid; grid-template-columns: 1fr 120px; gap: 10px; margin-bottom: 12px; }
.report-fields { display: grid; grid-template-columns: repeat(3, 1fr); border: 1.5px solid var(--rc); border-radius: 10px; overflow: hidden; font-size: 13.5px; }
.report-fields > div { display: flex; gap: 6px; align-items: center; padding: 8px 10px; border-bottom: 1px solid #e5e0d6; border-inline-start: 1px solid #e5e0d6; background: #fdf8ef; }
.report-fields b { color: var(--rc); white-space: nowrap; }
.report-fields .wide { grid-column: 1 / -1; justify-content: center; font-size: 16px; font-weight: 800; background: #fff6e3; }
.report-photo { border: 1.5px solid var(--rc); border-radius: 10px; overflow: hidden; display: grid; place-items: center; background: #f3efe6; min-height: 130px; }
.report-photo img { width: 100%; height: 100%; object-fit: cover; }
.report-photo span { font-size: 44px; font-weight: 900; color: var(--rc); }
.report-gpa { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 16px; margin-bottom: 14px; border: 1.5px solid var(--rc); border-radius: 10px; background: #fff3d6; font-weight: 800; }
.report-gpa strong { font-size: 20px; }
.report-tables { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 10px; }
.report-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.report-table th { color: var(--rc); border-bottom: 2px solid var(--rc); padding: 4px 6px; text-align: start; font-size: 13px; }
.report-table td { padding: 5px 6px; border-bottom: 1px dotted #c9c2b3; }
.report-table td:last-child { text-align: center; }
.report-table .s { font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }
.bars { display: flex; align-items: flex-end; justify-content: space-around; gap: 8px; height: 200px; padding: 10px 8px 0; border-bottom: 2px solid #d9d2c3; }
.bar { position: relative; flex: 1; max-width: 34px; height: var(--p); min-height: 4px; border-radius: 18px 18px 4px 4px;
  background: linear-gradient(90deg, hsl(var(--h) 60% 38%), hsl(var(--h) 70% 58%) 45%, hsl(var(--h) 60% 42%)); }
.bar::before { content: ""; position: absolute; top: 0; inset-inline: 0; height: 12px; border-radius: 50%; background: hsl(var(--h) 70% 72%); }
.bar span { position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); font-size: 11.5px; font-weight: 800; color: #333; }
.bar-labels { display: flex; justify-content: space-around; gap: 8px; padding: 6px 8px 0; }
.bar-labels span { flex: 1; max-width: 34px; writing-mode: vertical-rl; transform: rotate(180deg); text-align: end; font-size: 11px; font-weight: 700; height: 82px; overflow: hidden; color: #444; }
.report-note { margin-top: 10px; display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; color: #555; }
.report-sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; padding-top: 12px; border-top: 1px dashed #c9c2b3; text-align: center; font-size: 12.5px; color: #666; }
.report-sign div { min-height: 48px; }

/* --- نمودار خطی/سطحی */
.chart-card { padding: 16px; border-radius: 22px; background: var(--surface); border: 1px solid var(--border); }
.lchart { width: 100%; height: auto; overflow: visible; }
.lchart .grid line { stroke: var(--border); stroke-dasharray: 3 4; }
.lchart .grid text, .lchart .xl { font: 600 11px var(--font); fill: var(--muted); }
.lchart .area { fill: hsl(var(--h, 150) 60% 50% / 0.18); }
.lchart .line { fill: none; stroke: hsl(var(--h, 150) 55% 38%); stroke-width: 2.5; stroke-linejoin: round; }
.lchart .node { fill: #fff; stroke: hsl(var(--h, 150) 55% 38%); stroke-width: 2.5; }
.lchart .tag rect { fill: hsl(var(--h, 150) 60% 46%); }
.lchart .tag text { font: 800 11px var(--font); fill: #fff; }
.trend-table td .lv-dot { vertical-align: middle; }

/* --- رتبه‌بندی افقی */
.hbars { display: flex; flex-direction: column; gap: 6px; }
.hbar { display: grid; grid-template-columns: 34px minmax(120px, 200px) 1fr 60px; align-items: center; gap: 10px; font-size: 13.5px; }
.hbar .rank { width: 30px; height: 30px; }
.hbar .track { height: 16px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.hbar .track i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #e5b85a, #c99a2e); width: var(--p); }
.hbar.lv-weak .track i { background: linear-gradient(90deg, #f08a7c, #c93e2d); }
.hbar b { font-variant-numeric: tabular-nums; text-align: end; }

/* --- برنامه هفتگی */
.tt { width: 100%; border-collapse: separate; border-spacing: 6px; table-layout: fixed; }
.tt th { font-size: 13px; color: var(--muted); font-weight: 700; padding: 4px; }
.tt th.day { text-align: start; width: 90px; color: var(--text); }
.tt td { height: 72px; padding: 8px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); vertical-align: top; font-size: 13px; }
.tt td.has { background: hsl(var(--h, 210) 70% 50% / 0.1); border-color: hsl(var(--h, 210) 60% 50% / 0.35); }
.tt td strong { display: block; font-size: 13.5px; line-height: 1.6; }
.tt td small { color: var(--muted); font-size: 11.5px; }
.tt select { width: 100%; height: 40px; font-size: 12.5px; padding-inline: 8px 26px; border-radius: 10px; }

/* --- حضور و غیاب */
.att { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface-2); }
.att input { position: absolute; opacity: 0; pointer-events: none; }
.att label { padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700; cursor: pointer; color: var(--text-2); }
.att input:checked + label.present { background: #1d8a5a; color: #fff; }
.att input:checked + label.absent { background: #c93e2d; color: #fff; }
.att input:checked + label.late { background: #b07419; color: #fff; }
.att input:checked + label.excused { background: #2f6bc8; color: #fff; }
.att input:focus-visible + label { outline: 2px solid var(--gold-500); }

/* --- ورود از اکسل */
.import-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; counter-reset: st; }
.import-steps li { counter-increment: st; padding: 16px; border-radius: 20px; background: var(--surface); border: 1px solid var(--border); font-size: 13.5px; }
.import-steps li::before { content: counter(st, persian); display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: var(--on-ink); font-weight: 900; margin-bottom: 8px; }
.row-error td { background: var(--red-soft) !important; }
.row-skip td { opacity: 0.6; }
.row-update td { background: var(--blue-soft) !important; }
.msg-list { margin: 0; padding: 0; list-style: none; font-size: 12px; }
.msg-list li.err { color: var(--red); } .msg-list li.warn { color: var(--amber); }

/* --- صفحات عمومی */
.school-hero { --h: 150; border-radius: var(--r-xl); margin: 10px var(--gutter) 0; padding: clamp(36px, 6vw, 80px) clamp(24px, 5vw, 64px); }
.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.role-card { --h: 42; display: flex; flex-direction: column; gap: 8px; padding: 20px; border-radius: 24px; background: var(--surface); border: 1px solid var(--border); transition: transform 0.3s var(--ease), border-color 0.2s; }
.role-card:hover { transform: translateY(-3px); border-color: hsl(var(--h) 55% 50% / 0.6); }
.role-card .ic { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: hsl(var(--h) 65% 50% / 0.14); color: hsl(var(--h) 60% 34%); }
[data-theme="dark"] .role-card .ic { color: hsl(var(--h) 70% 72%); }
.role-card h3 { font-size: 16px; }
.role-card p { font-size: 13.5px; color: var(--muted); line-height: 1.9; }
.tree { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.tree-level { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.tree-node { padding: 8px 16px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border-strong); font-weight: 800; font-size: 14px; }
.tree-node.root { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.tree-arrow { color: var(--muted); }
.guide-steps { counter-reset: gs; display: flex; flex-direction: column; gap: 10px; }
.guide-steps li { counter-increment: gs; display: flex; gap: 12px; align-items: flex-start; line-height: 2; }
.guide-steps li::before { content: counter(gs, persian); flex: none; width: 28px; height: 28px; margin-top: 3px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 900; font-size: 13px; }
.guide-toc { position: sticky; top: calc(var(--header-h) + 12px); display: flex; flex-direction: column; gap: 4px; }
.guide-toc a { padding: 6px 12px; border-radius: 12px; font-size: 13.5px; font-weight: 650; color: var(--text-2); }
.guide-toc a:hover { background: var(--surface-2); color: var(--text); }
.guide-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; align-items: start; }

@media (max-width: 980px) {
  .guide-layout { grid-template-columns: 1fr; }
  .guide-toc { position: static; flex-direction: row; flex-wrap: wrap; }
  .import-steps { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .report-info { grid-template-columns: 1fr 90px; }
  .report-fields { grid-template-columns: 1fr 1fr; }
  .report-tables { grid-template-columns: 1fr; }
  .hbar { grid-template-columns: 30px 1fr 50px; }
  .hbar .track { grid-column: 1 / -1; order: 4; }
  .tt th.day { width: 60px; }
}

/* --- چاپ کارنامه */
@media print {
  .panel { display: block; padding: 0; }
  .panel-side, .panel-head .toolbar, .no-print, .period-bar { display: none !important; }
  .report { box-shadow: none; max-width: none; break-inside: avoid; page-break-after: always; }
  .report:last-child { page-break-after: auto; }
  body { background: #fff; }
  .bar { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .report-title, .report-gpa, .report-fields > div { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
