/* منصة الحلقات — التنسيق العام. الألوان الأساسية تأتي من الإعدادات عبر متغيرات :root */
:root {
  --primary: #1F6B47; --accent: #B8862B; --bg: #F6F3EC;
  --card: #FFFFFF; --ink: #1E2B24; --ink-2: #4F5D55; --ink-3: #6B756F;
  --line: #E2DCCF; --line-2: #EFEAE0; --soft: #FAF8F3;
  --success: #1F6B47; --success-soft: #E3EFE7; --warn: #8A5F12; --warn-soft: #F7EBCF;
  --danger: #A3401E; --danger-soft: #F8E1D6; --info: #2F5F8F; --info-soft: #E2ECF6;
  --radius: 14px; --radius-sm: 10px; --shadow: 0 1px 2px rgba(30,43,36,.06), 0 4px 14px rgba(30,43,36,.05);
  --font: "IBM Plex Sans Arabic", system-ui, Tahoma, sans-serif; --title-font: "Amiri", serif;
  --topbar: 60px; --sidebar: 264px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.65; color: var(--ink); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.35; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1.02rem; }
p { margin: 0 0 .8em; }
img { max-width: 100%; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .86em; background: var(--line-2); padding: 1px 5px; border-radius: 5px; direction: ltr; unicode-bidi: embed; }
.muted { color: var(--ink-2); }
.small { font-size: .86rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ltr { direction: ltr; unicode-bidi: embed; display: inline-block; }
.nowrap { white-space: nowrap; }
.skip { position: absolute; top: -40px; inset-inline-start: 8px; background: var(--primary); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { top: 8px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; }
.ic { flex: none; }

/* ===== الإطار ===== */
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar); display: flex; align-items: center; gap: 10px; padding: 0 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; min-width: 0; text-decoration: none !important; }
.brand-logo { max-height: 40px; max-width: 180px; object-fit: contain; }
.brand-name { font-family: var(--title-font); font-size: 1.35rem; font-weight: 700; color: var(--primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.bell { position: relative; }
.bell-count { position: absolute; top: 2px; inset-inline-end: 0; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink); text-decoration: none !important; }
[dir=rtl] .user-chip { padding: 4px 4px 4px 10px; }
.uc-name { font-weight: 600; font-size: .9rem; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-btn { display: none; }
.shell { display: flex; min-height: calc(100vh - var(--topbar)); }
.sidebar { width: var(--sidebar); flex: none; background: var(--card); border-inline-end: 1px solid var(--line); position: sticky; top: var(--topbar); height: calc(100vh - var(--topbar)); overflow-y: auto; display: flex; flex-direction: column; padding: 10px 10px 0; }
.sb-head { display: none; }
.sb-section { font-size: .76rem; font-weight: 700; color: var(--ink-3); padding: 14px 12px 4px; letter-spacing: .02em; }
.sb-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); color: var(--ink); font-size: .94rem; text-decoration: none !important; min-height: 42px; }
.sb-link:hover { background: var(--soft); }
.sb-link.active { background: color-mix(in srgb, var(--primary) 11%, white); color: var(--primary); font-weight: 700; }
.sb-foot { margin-top: auto; padding: 14px 12px; font-size: .78rem; }
.sb-foot a { color: var(--ink-3); }
.main { flex: 1; min-width: 0; padding: 22px 26px 40px; max-width: 1240px; }
.foot { margin-top: 36px; font-size: .82rem; text-align: center; }
.scrim { display: none; }
.bottom-nav { display: none; }

@media (max-width: 960px) {
  .menu-btn { display: inline-flex; }
  .sidebar { position: fixed; top: 0; bottom: 0; inset-inline-start: 0; height: 100vh; z-index: 50; transform: translateX(100%); transition: transform .22s ease; box-shadow: 0 0 40px rgba(0,0,0,.18); }
  [dir=ltr] .sidebar { transform: translateX(-100%); }
  .sb-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 4px 6px 10px; }
  body.drawer-open .sidebar { transform: none; }
  body.drawer-open .scrim { display: block; position: fixed; inset: 0; background: rgba(20,30,25,.38); z-index: 40; }
  .main { padding: 16px 16px 90px; }
  .uc-name { display: none; }
  .user-chip { padding: 2px !important; }
}
@media (max-width: 720px) {
  .bottom-nav { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--card); border-top: 1px solid var(--line); padding: 4px 6px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; color: var(--ink-2); font-size: .74rem; text-decoration: none !important; }
  .bottom-nav a.active { color: var(--primary); font-weight: 700; }
  body { font-size: 15.5px; }
}

/* ===== عناوين الصفحات ===== */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.ph-text h1 { margin: 0; }
.ph-text p { margin: 4px 0 0; }
.ph-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ===== الأزرار ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; text-decoration: none !important; white-space: nowrap; background: none; color: var(--ink); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(.94); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-ghost { background: var(--card); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--soft); }
.btn-ghost.danger, .btn-danger-ghost { color: var(--danger); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-light { background: rgba(255,255,255,.95); color: var(--primary); }
.btn-success { background: var(--success); color: #fff; }
.btn-icon { width: 42px; padding: 0; }
.btn-sm { min-height: 34px; padding: 0 11px; font-size: .84rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.inline-form { display: inline; margin: 0; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ===== البطاقات ===== */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card > h2:first-child, .card-head { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card.table-card { padding: 0; overflow: hidden; }
.card.hero { background: var(--primary); color: #fff; border: none; }
.card.hero .muted { color: rgba(255,255,255,.82); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
@media (max-width: 960px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .g2, .g3 { grid-template-columns: minmax(0, 1fr); } .span2 { grid-column: auto; } }
.cols { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.cols > .main-col { flex: 999 1 560px; min-width: 0; }
.cols > .side-col { flex: 1 1 300px; min-width: 0; }

.stat { display: flex; flex-direction: column; gap: 2px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--ink); text-decoration: none !important; position: relative; }
a.stat:hover { border-color: var(--primary); }
.stat-ic { position: absolute; top: 14px; inset-inline-end: 14px; color: var(--primary); opacity: .7; }
.stat-label { font-size: .84rem; color: var(--ink-2); }
.stat-value { font-size: 1.55rem; font-weight: 700; }
.stat-sub { font-size: .8rem; color: var(--ink-3); }

/* ===== الشارات ===== */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; line-height: 1.7; }
.b-success { background: var(--success-soft); color: #164F34; }
.b-warn { background: var(--warn-soft); color: #6B4A0E; }
.b-danger { background: var(--danger-soft); color: #7A2A10; }
.b-info { background: var(--info-soft); color: #234A70; }
.b-neutral { background: var(--line-2); color: var(--ink-2); }
.b-primary { background: var(--primary); color: #fff; }
.swatch { display: inline-block; width: 16px; height: 16px; border-radius: 4px; vertical-align: middle; border: 1px solid rgba(0,0,0,.1); }

/* ===== التنبيهات ===== */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 14px; font-weight: 500; border: 1px solid; }
.flash-success { background: var(--success-soft); border-color: #BFD9C8; color: #164F34; }
.flash-error { background: var(--danger-soft); border-color: #EDBFAA; color: #7A2A10; }
.flash-warn { background: var(--warn-soft); border-color: #E8D29B; color: #6B4A0E; }
.flash-info { background: var(--info-soft); border-color: #C3D6EA; color: #234A70; }
.callout { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: .93rem; }
.callout p:last-child { margin: 0; }
.callout-info { background: var(--info-soft); color: #1F3F60; }
.callout-warn { background: var(--warn-soft); color: #5A3E0B; }
.callout-success { background: var(--success-soft); color: #164F34; }
.callout-error { background: var(--danger-soft); color: #6E2A10; }
.callout .ic { margin-top: 2px; }

/* ===== النماذج ===== */
.form-card { max-width: 920px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 680px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .flabel { font-weight: 600; font-size: .9rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.req { color: var(--danger); }
.hint { color: var(--ink-2); font-size: .8rem; line-height: 1.55; }
input[type=text], input[type=email], input[type=tel], input[type=url], input[type=password], input[type=number], input[type=date], input[type=time], input[type=datetime-local], input[type=search], input[type=month], select, textarea {
  font: inherit; color: var(--ink); width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid #CFC8B8; border-radius: var(--radius-sm); background: #fff;
}
textarea { min-height: 88px; resize: vertical; }
select[multiple] { min-height: 140px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: 3px solid color-mix(in srgb, var(--primary) 18%, transparent); }
input[type=file] { font: inherit; padding: 8px; border: 1px dashed #CFC8B8; border-radius: var(--radius-sm); background: var(--soft); width: 100%; }
input[type=color] { width: 54px; height: 44px; padding: 3px; border: 1px solid #CFC8B8; border-radius: var(--radius-sm); background: #fff; }
.color-row { display: flex; align-items: center; gap: 10px; }
.pw-row { display: flex; gap: 6px; }
.ro { padding: 9px 12px; background: var(--soft); border-radius: var(--radius-sm); }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line-2); }
.file-current { margin-top: 6px; font-size: .85rem; }
.file-current img { max-height: 60px; background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0/14px 14px; border-radius: 6px; padding: 4px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 14px; }
legend { font-weight: 700; padding: 0 6px; }

/* مفتاح تشغيل */
.field-bool { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.field-bool .hint { flex-basis: 100%; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: .92rem; min-height: 40px; }
.switch input[type=checkbox] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { width: 44px; height: 26px; border-radius: 13px; background: #CFC8B8; position: relative; transition: background .15s; flex: none; }
.switch-ui::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: inset-inline-start .15s; }
.switch input:checked + .switch-ui { background: var(--primary); }
.switch input:checked + .switch-ui::after { inset-inline-start: 21px; }
.switch input:focus-visible + .switch-ui { outline: 3px solid color-mix(in srgb, var(--primary) 40%, transparent); outline-offset: 2px; }

/* أزرار الاختيار */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.seg-wrap { display: flex; flex-wrap: wrap; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 44px; padding: 6px 14px; border: 1px solid #CFC8B8; border-radius: var(--radius-sm); background: #fff; cursor: pointer; font-size: .9rem; user-select: none; }
.seg-wrap label { border-radius: 999px; min-height: 40px; }
.seg input:checked + label { border: 2px solid var(--primary); background: color-mix(in srgb, var(--primary) 12%, white); color: var(--primary); font-weight: 700; }
.seg input:focus-visible + label { outline: 3px solid color-mix(in srgb, var(--primary) 40%, transparent); }
@media (max-width: 520px) { .seg:not(.seg-wrap) { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* شرح بعلامة استفهام */
.help-tip { width: 22px; height: 22px; border-radius: 50%; border: 1px solid #CFC8B8; background: #fff; color: var(--ink-2); font-size: 12px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0; flex: none; }
.help-tip:hover { border-color: var(--primary); color: var(--primary); }
.tip-pop { position: absolute; z-index: 80; max-width: 300px; background: #1E2B24; color: #fff; font-size: .84rem; line-height: 1.6; padding: 10px 12px; border-radius: 10px; box-shadow: var(--shadow); }

/* ===== الجداول ===== */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: start; font-weight: 700; font-size: .82rem; color: var(--ink-2); background: var(--soft); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #FCFBF8; }
.t-actions { text-align: end; white-space: nowrap; }
.t-actions .btn { min-height: 34px; padding: 0 10px; font-size: .84rem; }
.t-num { font-variant-numeric: tabular-nums; }
@media (max-width: 720px) {
  .table.stack thead { display: none; }
  .table.stack tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 4px; }
  .table.stack td { display: flex; justify-content: space-between; gap: 12px; border: none; padding: 5px 12px; }
  .table.stack td::before { content: attr(data-label); font-weight: 600; color: var(--ink-2); font-size: .82rem; }
  .table.stack td.t-actions { justify-content: flex-start; flex-wrap: wrap; }
  .table.stack td.t-actions::before { display: none; }
}
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line-2); font-size: .88rem; }
.pager-links { display: flex; align-items: center; gap: 8px; }
.per-form select { width: auto; min-height: 34px; padding: 4px 8px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.toolbar select, .toolbar input[type=date], .toolbar input[type=month] { width: auto; min-width: 140px; }
.search { position: relative; flex: 1 1 220px; max-width: 380px; }
.search .ic { position: absolute; top: 12px; inset-inline-start: 12px; color: var(--ink-3); }
.search input { padding-inline-start: 38px; }

/* ===== عناصر متنوعة ===== */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--ink-2); border-bottom: 3px solid transparent; white-space: nowrap; text-decoration: none !important; font-weight: 600; font-size: .92rem; }
.tabs a.active { color: var(--primary); border-color: var(--primary); }
.progress { height: 8px; background: var(--line-2); border-radius: 4px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.empty { text-align: center; padding: 40px 20px; color: var(--ink-2); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty .ic { color: var(--ink-3); }
.empty h3 { margin-top: 10px; color: var(--ink); }
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; font-weight: 700; object-fit: cover; flex: none; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person-name { font-weight: 600; }
.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 6px 14px; font-size: .92rem; margin: 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 11px 0; border-bottom: 1px solid var(--line-2); }
.list > li:last-child { border-bottom: none; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.divider { height: 1px; background: var(--line-2); margin: 14px 0; }
.mt { margin-top: 14px; } .mb0 { margin-bottom: 0; }
.text-end { text-align: end; }
.big-num { font-size: 2rem; font-weight: 700; line-height: 1.2; }
.pre { white-space: pre-line; }
.copy-box { display: flex; gap: 6px; }
.copy-box input { direction: ltr; text-align: left; font-family: ui-monospace, monospace; font-size: .84rem; }

/* ===== الحصص ===== */
.session-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.session-card.is-next { border: 2px solid var(--primary); }
.session-card.needs-log { border-color: #E8D29B; background: #FFFCF4; }
.session-card.is-done { opacity: .82; }
.sc-time { font-size: 1.15rem; font-weight: 700; }
.sc-meta { font-size: .86rem; color: var(--ink-2); }
.next-hero { background: var(--primary); color: #fff; border-radius: 18px; padding: 20px; display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.next-hero .muted { color: rgba(255,255,255,.82); }
.next-hero .nh-when { font-size: 1.5rem; font-weight: 700; line-height: 1.3; }
.next-hero .pill { background: rgba(255,255,255,.16); padding: 3px 12px; border-radius: 999px; font-size: .84rem; }
.next-hero .btn-light { min-height: 50px; font-size: 1.05rem; }
.day-group { margin-bottom: 18px; }
.day-head { font-weight: 700; font-size: .95rem; color: var(--ink-2); margin: 0 0 8px; display: flex; gap: 8px; align-items: center; }
.day-head .today { color: var(--primary); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.countdown { font-variant-numeric: tabular-nums; }

/* خريطة الحفظ */
.juz-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
@media (min-width: 900px) { .juz-grid { grid-template-columns: repeat(10, minmax(0, 1fr)); } }
.juz { min-height: 52px; border-radius: 10px; font: inherit; font-weight: 700; font-size: 1rem; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; border: 1px solid #CFC8B8; background: #fff; color: var(--ink-2); text-decoration: none !important; position: relative; overflow: hidden; }
.juz small { font-size: .66rem; font-weight: 500; }
.juz.st-done { background: var(--primary); border-color: var(--primary); color: #fff; }
.juz.st-progress { background: #F2D58A; border-color: #C79A2E; color: #3B2A05; }
.juz.st-review { background: #F6C9B4; border: 1px dashed #B5532B; color: #6E2A10; }
.juz.sel { outline: 3px solid var(--ink); outline-offset: 1px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: .84rem; margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 1px solid #CFC8B8; }
.lg.done { background: var(--primary); border-color: var(--primary); }
.lg.progress { background: #F2D58A; border-color: #C79A2E; }
.lg.review { background: #F6C9B4; border: 1px dashed #B5532B; }
.st-chip-done { background: var(--success-soft); color: #164F34; }
.st-chip-progress { background: #F2D58A; color: #3B2A05; }
.st-chip-review { background: #F6C9B4; color: #6E2A10; }
.st-chip-none { background: var(--line-2); color: var(--ink-2); }

/* تسجيل الحصة */
.log-student { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); margin-bottom: 14px; }
.log-student > summary { list-style: none; cursor: pointer; padding: 14px 16px; display: flex; align-items: center; gap: 10px; font-weight: 700; }
.log-student > summary::-webkit-details-marker { display: none; }
.log-student[open] > summary { border-bottom: 1px solid var(--line-2); }
.log-body { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.log-block { border-top: 1px dashed var(--line); padding-top: 14px; }
.log-block:first-child { border-top: none; padding-top: 0; }
.log-block h3 { font-size: .98rem; margin-bottom: 10px; }
.inline-3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .inline-3 { grid-template-columns: 1fr 1fr; } .inline-3 > :first-child { grid-column: 1 / -1; } }
.sticky-save { position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 70%, transparent); padding: 14px 0 6px; z-index: 5; }
@media (max-width: 720px) { .sticky-save { bottom: 64px; } }

/* الإشعارات */
.notif { display: flex; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line-2); color: var(--ink); text-decoration: none !important; }
.notif.unread { background: color-mix(in srgb, var(--primary) 6%, white); }
.notif .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); margin-top: 8px; flex: none; }
.notif:not(.unread) .dot { background: transparent; }
.notif-title { font-weight: 700; }
.notif-body { font-size: .88rem; color: var(--ink-2); white-space: pre-line; }

/* الرسائل */
.thread { display: flex; flex-direction: column; gap: 10px; padding: 16px; max-height: 60vh; overflow-y: auto; background: var(--soft); border-radius: var(--radius); }
.msg { max-width: 78%; padding: 9px 13px; border-radius: 14px; background: #fff; border: 1px solid var(--line); align-self: flex-start; }
.msg.mine { align-self: flex-end; background: color-mix(in srgb, var(--primary) 12%, white); border-color: transparent; }
.msg-meta { font-size: .74rem; color: var(--ink-3); margin-top: 3px; }

/* صفحة الدخول */
body.bare { background: var(--bg); }
.bare-main { min-height: 100vh; }
.auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); min-height: 100vh; }
.auth-side { background: var(--primary); color: #fff; display: flex; flex-direction: column; justify-content: space-between; padding: 40px; position: relative; overflow: hidden; }
.auth-side::after { content: ""; position: absolute; inset: auto -120px -120px auto; width: 360px; height: 360px; border-radius: 50%; border: 50px solid rgba(255,255,255,.06); }
.auth-side .brand-logo { max-height: 130px; max-width: 260px; }
.auth-side .brand-name { color: #fff; font-size: 2rem; }
.auth-verse { font-family: var(--title-font); font-size: 2rem; line-height: 1.6; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-box { width: 100%; max-width: 420px; }
.auth-box h1 { font-size: 1.5rem; }
.auth-mobile-brand { display: none; text-align: center; margin-bottom: 18px; }
.auth-mobile-brand .brand-logo { max-height: 70px; }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth-side { display: none; } .auth-mobile-brand { display: block; } }
.public-wrap { max-width: 640px; margin: 0 auto; padding: 28px 16px 60px; }
.public-head { text-align: center; margin-bottom: 18px; }
.public-head .brand-logo { max-height: 70px; }
.error-card { text-align: center; max-width: 520px; margin: 40px auto; padding: 36px 24px; }
.error-code { font-size: 3rem; font-weight: 700; color: var(--primary); }

/* الطباعة: الفواتير والتقارير والشهادات */
.print-only { display: none; }
@media print {
  @page { margin: 12mm; }
  body { background: #fff; font-size: 12pt; }
  .topbar, .sidebar, .bottom-nav, .no-print, .flash, .foot, .ph-actions, .scrim, .skip { display: none !important; }
  .main { padding: 0; max-width: none; }
  .card { border: none; padding: 0; break-inside: avoid; }
  .print-only { display: block; }
  a { color: inherit; text-decoration: none; }
}
.doc { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; max-width: 860px; }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; border-bottom: 3px solid var(--primary); padding-bottom: 16px; margin-bottom: 18px; }
.doc-head .brand-logo { max-height: 64px; }

/* الشهادة */
.cert-wrap { display: flex; justify-content: center; }
.cert { width: 1000px; max-width: 100%; aspect-ratio: 1.414 / 1; background: #FFFDF7; position: relative; padding: 4.5%; display: flex; flex-direction: column; align-items: center; text-align: center; color: #2B2B2B; container-type: inline-size; }
.cert-frame { position: absolute; inset: 2.2%; border: 3px solid var(--cert-color); outline: 1px solid var(--cert-accent); outline-offset: -12px; border-radius: 6px; pointer-events: none; }
.cert-frame::before, .cert-frame::after { content: "❖"; position: absolute; color: var(--cert-accent); font-size: 3cqw; top: 1%; }
.cert-frame::before { right: 1.5%; } .cert-frame::after { left: 1.5%; }
.cert-logo { max-height: 9cqw; margin-bottom: 1cqw; }
.cert-academy { font-family: var(--title-font); color: var(--cert-color); font-size: 3cqw; font-weight: 700; }
.cert-heading { font-family: var(--title-font); color: var(--cert-accent); font-size: 6cqw; line-height: 1.2; margin: 1.5cqw 0; }
.cert-body { font-size: 2.1cqw; line-height: 1.9; white-space: pre-line; max-width: 85%; }
.cert-body strong { font-family: var(--title-font); color: var(--cert-color); font-size: 3.2cqw; }
.cert-sanad { font-size: 1.4cqw; color: #555; margin-top: 1cqw; white-space: pre-line; max-width: 80%; }
.cert-footer { font-family: var(--title-font); color: var(--cert-color); font-size: 1.9cqw; margin-top: 1cqw; }
.cert-bottom { margin-top: auto; width: 100%; display: flex; justify-content: space-between; align-items: flex-end; gap: 2cqw; }
.cert-sign { min-width: 22%; font-size: 1.5cqw; }
.cert-sign .line { border-top: 1px solid #999; margin: 3cqw 0 .6cqw; }
.cert-qr { text-align: center; font-size: 1.1cqw; color: #666; }
.cert-qr canvas, .cert-qr img { width: 9cqw !important; height: 9cqw !important; }
@media print { .cert { width: 100%; border: none; } body.r-certificates.view-cert { margin: 0; } }

/* لوحة الأسبوع */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.week-day { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px; min-height: 120px; }
.week-day h4 { font-size: .84rem; margin: 0 0 6px; color: var(--ink-2); }
.week-item { font-size: .78rem; padding: 5px 7px; border-radius: 7px; margin-bottom: 4px; background: var(--soft); border-inline-start: 3px solid var(--primary); display: block; color: var(--ink); text-decoration: none !important; }
@media (max-width: 900px) { .week { grid-template-columns: minmax(0, 1fr); } .week-day { min-height: 0; } }
.avail-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.avail-row .day-name { width: 90px; font-weight: 700; }
.avail-slot { display: inline-flex; align-items: center; gap: 6px; background: var(--success-soft); color: #164F34; padding: 4px 10px; border-radius: 999px; font-size: .86rem; }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 80px; gap: 10px; align-items: center; font-size: .86rem; }
.bar-track { height: 12px; background: var(--line-2); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 6px; }
.chart-cols { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.chart-col .col-bar { width: 100%; max-width: 42px; background: var(--primary); border-radius: 6px 6px 0 0; min-height: 2px; }
.chart-col span { font-size: .7rem; color: var(--ink-2); white-space: nowrap; }
.stars { color: var(--accent); letter-spacing: 2px; }
.rating-input { display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: 4px; }
.rating-input input { position: absolute; opacity: 0; }
.rating-input label { font-size: 2rem; color: #D7CFBF; cursor: pointer; line-height: 1; }
.rating-input input:checked ~ label, .rating-input label:hover, .rating-input label:hover ~ label { color: var(--accent); }
.install-steps { counter-reset: st; list-style: none; padding: 0; }
.install-steps li { counter-increment: st; position: relative; padding-inline-start: 40px; margin-bottom: 14px; }
.install-steps li::before { content: counter(st); position: absolute; inset-inline-start: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem; }
.help-article h2 { margin-top: 1.3em; }
.help-article ul, .help-article ol { padding-inline-start: 22px; }
.help-article li { margin-bottom: 4px; }

/* إصلاحات */
.topbar .menu-btn { display: none; }
@media (max-width: 960px) { .topbar .menu-btn { display: inline-flex; } }
.auth-side .muted { color: rgba(255,255,255,.82); }
.grid.keep3 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
.grid.keep2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
@media (max-width: 620px) {
  .grid.keep3 .stat, .grid.keep2 .stat { padding: 10px 12px; }
  .grid.keep3 .stat-value { font-size: 1.3rem; }
  .grid.keep3 .stat-label { font-size: .76rem; }
  .grid.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
[hidden] { display: none !important; }
.brand { gap: 8px; }
.brand-sub { font-size: 1.15rem; }
@media (max-width: 380px) { .brand-sub { display: none; } }
