@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&display=swap');
:root{font-family:Vazirmatn,Tahoma,sans-serif;color:#1e293b;background:#f3f6fb;font-synthesis:none}
*{box-sizing:border-box}
body{margin:0;min-height:100vh}
button,input,select{font:inherit}
.container{width:min(1120px,calc(100% - 32px));margin:38px auto}
.login-card{max-width:420px;margin:8vh auto;background:#fff;padding:34px;border:1px solid #e5eaf2;border-radius:20px;box-shadow:0 16px 45px #1d35570d}
.brand-mark{width:52px;height:52px;border-radius:16px;background: #f1f1f1;color:white;display:grid;place-items:center;font-size:25px;font-weight:800}
h1{font-size:23px;margin:18px 0 5px}h2{font-size:19px;margin:0 0 6px}
p{line-height:1.8}.muted{color:#64748b;font-size:13px}
label{display:block;font-size:13px;margin:13px 0 6px}
input,select{width:100%;padding:11px 12px;border:1px solid #d8e0eb;border-radius:10px;background:#fff;outline:none}
input:focus,select:focus{border-color:#5386ef;box-shadow:0 0 0 3px #2563eb18}
button{border:0;border-radius:10px;padding:10px 15px;cursor:pointer;font-weight:600}
button:disabled{opacity:.55;cursor:not-allowed}
.primary{background:#2458c6;color:#fff}.secondary{background:#eaf0fa;color:#29446d}.danger{background:#fff0f0;color:#b42318}
.full{width:100%;margin-top:20px}.error{color:#b42318;font-size:13px}
.topbar{display:flex;justify-content:space-between;align-items:center;background:#fff;border:1px solid #e5eaf2;padding:16px 20px;border-radius:16px}
.topbar strong{display:block}.topbar .muted{display:block}
.tabs{display:flex;gap:8px;flex-wrap:wrap;margin:18px 0}
.tab{background:#e8edf5;color:#52627a}.tab.active{background:#1e40af;color:#fff}
.panel{background:#fff;border:1px solid #e5eaf2;border-radius:16px;padding:22px;box-shadow:0 8px 30px #1d355708}
.section-heading{display:flex;justify-content:space-between;gap:16px;align-items:center;margin-bottom:18px}
.search{max-width:280px}
.table-wrap{overflow-x:auto;margin-top:18px}
table{width:100%;border-collapse:collapse;white-space:nowrap}
th,td{text-align:right;padding:13px 12px;border-bottom:1px solid #edf0f5;font-size:13px}
th{background:#f8fafc;color:#53627a;font-weight:600}
.status{display:inline-block;padding:4px 10px;border-radius:30px;font-size:12px}
.inside{background:#e8f7ef;color:#167344}.outside{background:#eef2f7;color:#596579}
.action{padding:7px 12px;font-size:12px;margin:2px}
.form-grid{display:grid;grid-template-columns:repeat(4,minmax(140px,1fr));gap:10px;align-items:end;margin:18px 0}
.form-grid input,.form-grid select{min-width:0}
.report-filters label{margin:0}
.summary-grid{display:flex;gap:12px;flex-wrap:wrap;margin-top:18px}
.summary-card{background:#f4f7fc;border:1px solid #e6ebf3;border-radius:12px;padding:14px 18px;min-width:180px}
.summary-card strong{display:block;font-size:20px;color:#1d4ed8}
.toast{position:fixed;bottom:22px;left:22px;background:#172554;color:white;padding:12px 18px;border-radius:10px;opacity:0;transform:translateY(10px);transition:.2s;pointer-events:none;max-width:90vw}
.toast.show{opacity:1;transform:translateY(0)}
@media(max-width:760px){.container{margin:16px auto}.section-heading{align-items:stretch;flex-direction:column}.search{max-width:none}.form-grid{grid-template-columns:1fr 1fr}.panel{padding:15px}.topbar{padding:13px}}
@media(max-width:480px){.form-grid{grid-template-columns:1fr}.login-card{padding:24px}.tabs{gap:5px}.tab{font-size:12px;padding:9px}}

/* نسخه دوم: تایمر، گزارش درختی و پنجره ویرایش */
.timer-cell{min-width:145px}.live-timer{display:inline-block;direction:ltr;font-variant-numeric:tabular-nums;font-weight:700;font-size:14px;padding:5px 9px;border-radius:8px;background:#edf7f1;color:#167344}.live-timer.timer-out{background:#fff5e8;color:#a15c08}.timer-caption{display:block;color:#718096;font-size:10px;margin-top:3px}.timer-idle{color:#9aa5b5;font-size:12px}.status.absent{background:#fff0f0;color:#b42318}
.report-tree{display:grid;gap:10px;margin-top:18px}.tree-student,.tree-day{border:1px solid #e4eaf2;border-radius:12px;background:#fff;overflow:hidden}.tree-student>summary,.tree-day>summary{list-style:none;cursor:pointer;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:14px 16px}.tree-student>summary::-webkit-details-marker,.tree-day>summary::-webkit-details-marker{display:none}.tree-student>summary:before,.tree-day>summary:before{content:'＋';color:#64748b;font-weight:700;margin-left:8px}.tree-student[open]>summary:before,.tree-day[open]>summary:before{content:'−'}.student-summary{background:#f5f8fd}.tree-name{font-weight:700}.tree-name small{font-weight:400;color:#64748b}.tree-total{font-size:13px;color:#2458c6;white-space:nowrap}.tree-days{padding:10px 14px 14px;display:grid;gap:8px}.tree-day{background:#fbfcfe}.tree-day>summary{font-size:13px}.tree-day>summary strong{font-size:12px;color:#167344;white-space:nowrap}.tree-day .table-wrap{margin:0;padding:0 12px 10px}.tree-day table{background:#fff}.empty-report{padding:18px;text-align:center;background:#f8fafc;border-radius:12px}
.edit-dialog{border:0;border-radius:18px;padding:0;width:min(520px,calc(100% - 28px));max-height:90vh;box-shadow:0 24px 80px #10213d40}.edit-dialog::backdrop{background:#10213d88;backdrop-filter:blur(2px)}.edit-dialog form{padding:22px}.dialog-heading{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.dialog-heading h2{margin:0}.icon-close{font-size:24px;line-height:1;padding:2px 9px;background:#f1f4f8;color:#52627a}.dialog-fields{display:grid;grid-template-columns:1fr 1fr;gap:4px 12px}.dialog-fields label{margin:7px 0}.dialog-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:18px}.edit-dialog .error{min-height:18px;margin:8px 0 0}
@media(max-width:520px){.dialog-fields{grid-template-columns:1fr}.tree-student>summary,.tree-day>summary{align-items:flex-start;flex-direction:column;gap:5px}.tree-total{white-space:normal}}

/* نسخه سوم: تاریخچه قابل ویرایش، پایان روز و خروجی */
.status.ended{background:#eef2ff;color:#3730a3}.action.end-day{background:#fff7e6;color:#925d00}.history-heading{align-items:flex-start}.history-tools{display:flex;gap:7px;flex-wrap:wrap}.day-tools{display:flex;align-items:center;gap:6px;flex-wrap:wrap;padding:8px 12px}.day-note{margin:4px 12px 12px;padding:10px 12px;border-radius:9px;background:#f7f9fc;color:#334155;font-size:13px;white-space:pre-wrap}.day-note small{color:#64748b}.history-status{font-style:normal;font-size:11px;margin-right:7px;padding:3px 7px;border-radius:20px}.absent-text{color:#b42318;background:#fff0f0}.present-text{color:#167344;background:#e8f7ef}.wide-field{grid-column:1/-1}.dialog-fields textarea{width:100%;padding:11px 12px;border:1px solid #d8e0eb;border-radius:10px;font:inherit;resize:vertical}.date-jalali{display:block;color:#64748b;font-size:11px;margin-top:4px;min-height:16px}.reminder-bar{display:flex;align-items:center;gap:10px;flex-wrap:wrap;background:#f7f9fc;border:1px solid #e6ebf3;border-radius:12px;padding:10px 12px;margin:14px 0}.reminder-bar>span{font-weight:600;font-size:13px}.reminder-bar label{display:flex;align-items:center;gap:7px;margin:0}.reminder-bar input{width:115px;padding:6px}.reminder-bar small{font-size:11px}.tree-day .table-wrap{padding-bottom:12px}.tree-day td .action{white-space:nowrap}
@media(max-width:760px){.history-heading{flex-direction:column}.history-tools{width:100%}.history-tools button{flex:1}.reminder-bar{align-items:flex-start}.reminder-bar small{width:100%}}
@media print{.tabs,.topbar,.history-tools,.report-filters,.day-tools,.action{display:none!important}.panel{border:0;box-shadow:none}.tree-student,.tree-day{break-inside:avoid}}

/* تقویم شمسی برای تمام انتخاب‌گرهای تاریخ */
.jalali-picker{position:relative;width:100%}.jalali-date-display{cursor:pointer;background:#fff;min-width:0}.jalali-calendar{display:none;position:absolute;z-index:1000;top:calc(100% + 6px);right:0;width:280px;padding:12px;background:#fff;border:1px solid #dbe3ef;border-radius:14px;box-shadow:0 16px 40px #10213d24}.jalali-picker.open .jalali-calendar{display:block}.jalali-calendar-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px}.jalali-calendar-head strong{font-size:13px}.jalali-calendar-head button{padding:4px 11px;background:#eef3fb;color:#334155;font-size:18px}.jalali-weekdays,.jalali-days{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:4px;text-align:center}.jalali-weekdays span{font-size:11px;color:#64748b;padding:5px 0}.jalali-day,.jalali-empty{min-width:0;padding:7px 2px;border-radius:8px;font-size:12px;background:#f5f7fb;color:#334155}.jalali-day:hover{background:#dbeafe}.jalali-day.selected{background:#2458c6;color:#fff}.history-date-time{display:grid;grid-template-columns:1fr 125px;gap:10px;align-items:end}.history-date-time>label{min-width:0}.reminder-active{color:#167344!important;font-weight:700}.reminder-bar #reminderStatus{padding:3px 8px;border-radius:8px;background:#edf7f1}.reminder-bar #reminderStatus:not(.reminder-active){background:#f1f3f6;color:#64748b}
@media(max-width:520px){.jalali-calendar{width:min(280px,calc(100vw - 48px))}.history-date-time{grid-template-columns:1fr 110px}}

/* پنجره جلسه هنگام باز شدن انتخاب‌گر ساعت، بزرگ‌تر می‌شود تا صفحه اسکرول نخورد. */
.edit-dialog:has(input[type="time"]:focus){
  width:min(700px,calc(100vw - 28px));
  height:min(290px,calc(100dvh - 24px));
  max-height:calc(100dvh - 24px);
  overflow:visible;
}
.edit-dialog:has(input[type="time"]:focus) form{
  height:100%;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
  overflow:visible;
}
.edit-dialog:has(input[type="time"]:focus) .dialog-fields{
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:8px 18px;
}
.edit-dialog:has(input[type="time"]:focus) .dialog-fields label{margin:8px 0}
@media(max-width:520px){
  .edit-dialog:has(input[type="time"]:focus){width:calc(100vw - 20px);height:min(330px,calc(100dvh - 20px))}
  .edit-dialog:has(input[type="time"]:focus) .dialog-fields{grid-template-columns:1fr 1fr;gap:5px 8px}
}


/* برنامه هفتگی نمایشی برای مدیر و مراقب‌ها */
.schedule-hint{margin:10px 0 16px;padding:11px 14px;border-radius:10px;background:#f5f8fd;color:#53627a;font-size:13px;line-height:1.9}
.schedule-wrap{margin-top:12px}
.weekly-schedule{min-width:850px;white-space:normal}
.weekly-schedule th,.weekly-schedule td{text-align:center;vertical-align:middle;min-width:105px}
.weekly-schedule thead th{background:#edf3fc;color:#29446d}
.weekly-schedule tbody th{background:#f8fafc;color:#334155;min-width:90px}
.weekly-schedule tbody td{height:62px;color:#64748b;background:#fff}
.weekly-schedule tbody tr:nth-child(even) td{background:#fbfcff}
@media(max-width:760px){.schedule-hint{font-size:12px}.weekly-schedule th,.weekly-schedule td{padding:10px 8px}}

.permission-editor{border:1px solid #dbe3ef;border-radius:12px;padding:12px 14px;margin:10px 0;background:#f9fbfe;min-width:0}.permission-editor legend{font-weight:700;padding:0 6px}.permission-editor>p{font-size:12px;margin:3px 0 10px}.permission-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px 14px}.permission-option{display:flex!important;align-items:center;gap:8px;margin:0!important;padding:7px 8px;border-radius:8px;background:#fff;font-size:13px;cursor:pointer}.permission-option input{width:17px;height:17px;accent-color:#2563eb;flex:0 0 auto}.permission-option input:disabled{cursor:not-allowed}.permission-editor>small{display:block;margin-top:9px}@media(max-width:520px){.permission-grid{grid-template-columns:1fr}}


/* اصلاحات نسخه دهم: پنجره‌های جلسه با اندازه ثابت و تقویم شناور */
.edit-dialog{width:min(560px,calc(100vw - 28px));max-height:calc(100dvh - 28px);overflow:visible}
.edit-dialog form{max-height:calc(100dvh - 70px);overflow:visible}
.edit-dialog:has(.jalali-picker.open){overflow:visible}
.edit-dialog:has(input[type="time"]:focus){width:min(560px,calc(100vw - 28px));height:auto;max-height:calc(100dvh - 28px);overflow:visible}
.edit-dialog:has(input[type="time"]:focus) form{height:auto;display:block;overflow:visible}
.edit-dialog:has(input[type="time"]:focus) .dialog-fields{grid-template-columns:1fr 1fr;gap:4px 12px}
.edit-dialog input[type="time"]{width:100%;max-width:100%;min-width:0}
.jalali-picker{z-index:1}
.jalali-picker.open{z-index:1100}
.jalali-calendar{max-height:min(360px,calc(100dvh - 100px));overflow:auto}
@media(max-width:520px){.edit-dialog:has(input[type="time"]:focus){width:calc(100vw - 20px);height:auto}.edit-dialog:has(input[type="time"]:focus) .dialog-fields{grid-template-columns:1fr 1fr}}

/* Ensure permission-driven hidden panels and controls stay hidden even when a component has display:flex. */
[hidden]{display:none!important}


/* نسخه چهاردهم: دکمه‌های پنجره ویرایش همیشه داخل کادر می‌مانند؛ محتوای بلند قابل پیمایش است. */
#editDialog{box-sizing:border-box;max-height:calc(100dvh - 28px);overflow:hidden}
#editDialog form{box-sizing:border-box;display:flex;flex-direction:column;max-height:calc(100dvh - 28px);min-height:0;overflow:hidden}
#editDialog .dialog-heading{flex:0 0 auto}
#editDialog .dialog-fields{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:2px 4px 8px 0}
#editDialog .dialog-actions{flex:0 0 auto;padding-top:10px;margin-top:8px;background:#fff}
