:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f7f9fa;
  --border: #e2e7eb;
  --text: #16212a;
  --text-2: #53616d;
  --muted: #8994a0;
  --primary: #0d6e63;
  --primary-hover: #0a5a51;
  --primary-soft: #e2f2ee;
  --accent: #3b82a0;
  --sidebar: #0f2530;
  --sidebar-text: #b5c4cb;
  --sidebar-active: #1a3a47;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #935400;
  --warn-soft: #fff3d9;
  --ok: #1c7a3d;
  --ok-soft: #e4f4e9;
  --neutral-soft: #edf1f4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 34, 43, .06), 0 1px 1px rgba(16, 34, 43, .04);
  --font: "Segoe UI", Tahoma, "Noto Sans Arabic", "Geeza Pro", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 var(--font); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h2 { font-size: 1.05rem; font-weight: 700; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: .9em; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.num { text-align: left !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.icon { width: 20px; height: 20px; flex: none; }
.mt { margin-top: 22px; }

/* ------------------------------------------------ الهيكل */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex: none; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 18px; }
.brand strong { display: block; color: #fff; font-size: 1rem; line-height: 1.35; }
.brand small { display: block; font-size: .76rem; opacity: .75; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 10px; flex: none; overflow: hidden;
  display: grid; place-items: center; background: var(--primary); color: #fff;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; padding: 6px 10px; flex: 1; }
.sidebar nav a, .sidebar-user a, .sidebar-user .link-btn {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px;
  color: var(--sidebar-text); font-size: .93rem;
}
.sidebar nav a:hover, .sidebar-user a:hover, .sidebar-user .link-btn:hover { background: var(--sidebar-active); color: #fff; text-decoration: none; }
.sidebar nav a.active, .sidebar-user a.active { background: var(--sidebar-active); color: #fff; box-shadow: inset -3px 0 0 #3fb8a6; }
.nav-badge { margin-inline-start: auto; background: #d97706; color: #fff; border-radius: 999px; padding: 0 8px; font-size: .74rem; font-weight: 700; }
.sidebar-user { border-top: 1px solid rgba(255, 255, 255, .08); padding: 10px; }
.sidebar-user small { display: block; font-size: .74rem; opacity: .7; }
.sidebar-user .link-btn { width: 100%; }

.main { flex: 1; min-width: 0; padding: 0 30px 48px; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 22px 0 16px; }
.topbar h1 { font-size: 1.4rem; }
.page-sub { margin: 2px 0 0; color: var(--text-2); font-size: .88rem; }
.menu-btn { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px; color: var(--text); cursor: pointer; }

/* ------------------------------------------------ البطاقات */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head.padded { padding: 16px 20px 0; }
.card-head a { font-size: .88rem; }
.narrow { max-width: 680px; }
.lead { color: var(--text-2); margin: 0 0 16px; }
.hint { color: var(--muted); font-size: .83rem; }
.empty { color: var(--muted); text-align: center; padding: 32px 16px; }
.crumbs { color: var(--muted); font-size: .9rem; margin: -6px 0 14px; }
.callout { background: var(--primary-soft); color: var(--primary); border-radius: 8px; padding: 10px 14px; font-size: .92rem; }
.callout.muted { background: var(--surface-2); color: var(--text-2); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.grid-2 .span-2 { grid-column: 1 / -1; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stats.compact { margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; color: var(--text); display: flex; flex-direction: column; gap: 2px; border-top: 3px solid var(--border);
}
a.stat:hover { text-decoration: none; border-color: #c9d3da; }
.stat span { color: var(--text-2); font-size: .86rem; }
.stat strong { font-size: 1.8rem; font-weight: 700; line-height: 1.2; }
.stat strong.sm { font-size: 1.05rem; padding: 6px 0; }
.stat small { color: var(--muted); font-size: .78rem; }
.stat-neutral { border-top-color: var(--primary); }
.stat-ok { border-top-color: var(--ok); }
.stat-ok strong { color: var(--ok); }
.stat-danger { border-top-color: var(--danger); }
.stat-danger strong { color: var(--danger); }
.stat-warn { border-top-color: #d97706; }
.stat-warn strong { color: var(--warn); }
.stat-muted { border-top-color: var(--muted); }

.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 40px; align-items: center; gap: 10px; font-size: .9rem; }
.bar-label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--neutral-soft); border-radius: 4px; height: 10px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--primary); border-radius: 4px; min-width: 4px; }
.bar-fill.alt { background: var(--accent); }
.bar-value { font-weight: 600; text-align: left; }

.split { display: flex; flex-direction: column; gap: 14px; }
.split-row { display: grid; grid-template-columns: 70px 1fr; gap: 4px 12px; align-items: center; font-size: .9rem; }
.split-row small { grid-column: 2; color: var(--muted); }
.split-bar { height: 14px; border-radius: 7px; background: #d8e3ea; overflow: hidden; }
.split-bar span { display: block; height: 100%; }
.split-bar .a { background: var(--primary); }
.split-bar .b { background: var(--accent); }

.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: grid; grid-template-columns: 150px 1fr auto; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.activity li:last-child { border-bottom: 0; }
.activity .act { font-weight: 600; }
.activity .who { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity time { color: var(--muted); font-size: .8rem; direction: ltr; }

.todo { list-style: none; margin: 0; padding: 0; }
.todo li a { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); color: var(--text); font-size: .9rem; }
.todo li:last-child a { border-bottom: 0; }
.todo li a:hover { text-decoration: none; color: var(--primary); }
.todo .badge { min-width: 92px; text-align: center; }

.person-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.person-chip { display: inline-flex; flex-direction: column; padding: 6px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-size: .88rem; font-weight: 600; }
.person-chip small { color: var(--muted); font-weight: 400; font-size: .76rem; }
.person-chip:hover { border-color: var(--primary); text-decoration: none; }
.person { display: flex; align-items: center; gap: 10px; color: var(--text); }
.person:hover { text-decoration: none; }
.person:hover strong { color: var(--primary); }
.welcome h2 { font-size: 1.3rem; }
.welcome p { margin: 2px 0 16px; color: var(--text-2); }

/* ------------------------------------------------ الجداول */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 10px 14px; text-align: right; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--surface-2); color: var(--text-2); font-weight: 600; font-size: .83rem; white-space: nowrap; }
tbody tr:hover { background: #fafcfc; }
tbody tr:last-child td { border-bottom: 0; }
.card:not(.flush) > .table-wrap th:first-child, .card:not(.flush) > .table-wrap td:first-child { padding-inline-start: 0; }
.sub { display: block; color: var(--muted); font-size: .79rem; }
.file-name { display: inline-block; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
td.details { color: var(--text-2); font-size: .85rem; max-width: 360px; }
.row-actions { display: flex; gap: 12px; align-items: center; white-space: nowrap; font-size: .88rem; flex-wrap: wrap; }
.row-actions form { display: inline-flex; gap: 6px; align-items: center; }
.row-actions a { display: inline-flex; align-items: center; gap: 4px; }
.row-actions .icon { width: 16px; height: 16px; }
.decide input[type=text] { width: 150px; min-height: 32px; padding: 4px 8px; font-size: .85rem; }
table.kv td { padding: 9px 4px; }
table.kv td.num { white-space: normal; }
table.kv .num { min-width: 110px; }
table.kv tr.total td { font-weight: 700; border-top: 2px solid var(--border); }
tr.total td { font-weight: 700; background: var(--surface-2); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .77rem; font-weight: 600; white-space: nowrap; line-height: 1.6; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--neutral-soft); color: var(--text-2); }
.badge-neutral { background: var(--primary-soft); color: var(--primary); }
a.badge:hover { text-decoration: none; filter: brightness(.96); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 4px; }

.date .hijri { display: block; color: var(--muted); font-size: .76rem; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 14px; border-top: 1px solid var(--border); font-size: .9rem; }
.page { padding: 4px 12px; border: 1px solid var(--border); border-radius: 6px; }
.page.disabled { color: var(--muted); opacity: .6; }
.page-info { color: var(--text-2); }

/* ------------------------------------------------ التبويبات والأعوام */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 18px -20px -20px; padding: 0 14px; overflow-x: auto; }
.card > .tabs:first-child { margin-top: -6px; }
.tabs a { padding: 11px 14px; color: var(--text-2); font-weight: 600; font-size: .92rem; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-count { display: inline-block; margin-inline-start: 6px; background: var(--neutral-soft); color: var(--text-2); border-radius: 999px; padding: 0 7px; font-size: .74rem; }
section.card > nav.tabs + * { margin-top: 0; }

.year-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.card-head .year-tabs { margin-bottom: 0; }
.year-tab { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 8px; border: 1px solid var(--border); color: var(--text-2); font-weight: 600; font-size: .9rem; background: var(--surface); }
.year-tab span { background: var(--neutral-soft); border-radius: 999px; padding: 0 7px; font-size: .74rem; }
.year-tab:hover { border-color: var(--primary); text-decoration: none; }
.year-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.year-tab.active span { background: rgba(255, 255, 255, .22); color: #fff; }
.year-tab.hire { border-style: dashed; }
.year-heading { font-size: .98rem; margin: 18px 0 8px; color: var(--primary); }

.year-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.year-chip { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; color: var(--text); display: flex; flex-direction: column; }
.year-chip small { color: var(--muted); font-size: .76rem; }
.year-chip.has { border-color: #a9d6cd; background: var(--primary-soft); }
.year-chip:hover { border-color: var(--primary); text-decoration: none; }

.year-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.year-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; color: var(--text); border-top: 4px solid var(--accent); }
.year-card.current { border-top-color: var(--primary); }
.year-card:hover { text-decoration: none; border-color: #c4d2da; }
.year-num { font-size: 1.7rem; font-weight: 800; color: var(--primary); margin-bottom: 8px; }
.year-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 0; }
.year-card dt { color: var(--muted); font-size: .76rem; }
.year-card dd { margin: 0; font-weight: 700; }

.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-top: 16px; }
.folder { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.folder-head { display: flex; flex-direction: column; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); color: var(--text); }
.folder-head small { color: var(--muted); }
.folder ul { list-style: none; margin: 0; padding: 6px 14px; }
.folder li { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: .88rem; }
.folder li span:first-child { flex: 1; }

/* ------------------------------------------------ النماذج */
input[type=text], input[type=search], input[type=email], input[type=tel], input[type=password],
input[type=date], input[type=number], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid #cdd6dc; border-radius: 8px;
  padding: 8px 12px; min-height: 40px; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(13, 110, 99, .25); border-color: var(--primary); }
input[type=file] { font: inherit; padding: 9px; border: 1px dashed #b8c4cc; border-radius: 8px; width: 100%; background: var(--surface-2); }
input.num { width: 90px; display: inline-block; text-align: center; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.field > span { color: var(--text-2); font-weight: 600; }
.req { color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.one { grid-template-columns: 1fr; }
.span-all { grid-column: 1 / -1; }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.form-actions.sticky { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; margin-top: 0; }
.form-card { max-width: 1000px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; white-space: nowrap; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.inline { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; font-size: .9rem; }
.inline input, .inline select { width: auto; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.inline-form input[type=text] { width: 220px; }
.add-type { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
table.types td { padding-inline-start: 0; }
table.types .inline-form { margin: 0; }
.logo-preview { display: flex; align-items: center; gap: 16px; margin-top: 14px; }
.logo-preview img { height: 64px; border: 1px solid var(--border); border-radius: 8px; padding: 4px; background: #fff; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: .9rem;
  padding: 8px 16px; min-height: 40px; border-radius: 8px; cursor: pointer; background: var(--surface); color: var(--text);
  border: 1px solid #cdd6dc; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn .icon { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: #166230; }
.btn-danger { background: var(--surface); border-color: #f1b5af; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { min-height: 32px; padding: 3px 12px; font-size: .85rem; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 1; }
.filters input[type=search] { width: 280px; flex: 0 1 280px; }
.filters select { width: auto; min-width: 130px; }
.filter-note { margin: -6px 0 14px; color: var(--text-2); font-size: .9rem; }
.actions-row { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.profile-head .actions-row { margin: 0; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-weight: 600; font-size: .92rem; }
.flash-success { background: var(--ok-soft); color: var(--ok); border: 1px solid #bfe5cc; }
.flash-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #f5c2bd; }

/* ------------------------------------------------ ملف الموظف */
.profile { padding-bottom: 20px; }
.profile-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.profile-title h2 { font-size: 1.3rem; }
.profile-title p { margin: 2px 0 8px; color: var(--text-2); }
.spacer { flex: 1; }
.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 700; object-fit: cover; }
.avatar.sm { width: 34px; height: 34px; font-size: .9rem; }
.avatar.lg { width: 84px; height: 84px; font-size: 2rem; }
.avatar-wrap { position: relative; }
.photo-form { position: absolute; bottom: -2px; left: -2px; }
.photo-btn { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; cursor: pointer; border: 2px solid #fff; }
.photo-btn .icon { width: 16px; height: 16px; }
.photo-btn input { display: none; }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; margin: 0; }
.info-grid.compact { margin: 18px 0 8px; padding-top: 16px; border-top: 1px solid var(--border); }
.card.narrow .info-grid.compact { margin: 0; padding: 0; border: 0; }
.info-grid dt { color: var(--muted); font-size: .8rem; }
.info-grid dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.hash { font-size: .78rem; font-weight: 400; color: var(--text-2); }
.notes { background: var(--surface-2); border-radius: 8px; padding: 12px 14px; margin: 16px 0 0; color: var(--text-2); white-space: pre-wrap; }
.plain { margin: 0; padding-inline-start: 18px; color: var(--text-2); }
.plain li { margin-bottom: 6px; }
.path { background: var(--surface-2); padding: 8px 12px; border-radius: 6px; text-align: left; overflow-wrap: anywhere; }

.balance { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.balance-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.balance-head b { font-size: 1.3rem; color: var(--primary); }
.meter { height: 12px; background: var(--neutral-soft); border-radius: 6px; overflow: hidden; }
.meter span { display: block; height: 100%; background: linear-gradient(90deg, #3fb8a6, var(--primary)); border-radius: 6px; }

.eval-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-top: 16px; }
.eval-card { border: 1px solid var(--border); border-radius: 8px; padding: 14px; }
.eval-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.eval-card dl { margin: 0 0 8px; font-size: .9rem; }
.eval-card dt { color: var(--muted); font-size: .78rem; margin-top: 6px; }
.eval-card dd { margin: 0; }

.timeline { list-style: none; margin: 12px 0 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; top: 0; bottom: 0; right: 7px; width: 2px; background: var(--border); }
.tl-year { position: relative; padding: 6px 26px 6px 0; font-weight: 800; color: var(--primary); }
.tl-year::before { content: ""; position: absolute; right: 2px; top: 13px; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); }
.tl-item { position: relative; margin: 0 26px 12px 0; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.tl-item::before { content: ""; position: absolute; right: -23px; top: 16px; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.tl-ok::before { background: var(--ok); }
.tl-warn::before { background: #d97706; }
.tl-danger::before { background: var(--danger); }
.tl-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.tl-head form { margin-inline-start: auto; }
.tl-item p { margin: 6px 0 2px; color: var(--text-2); font-size: .9rem; }

/* ------------------------------------------------ التقويم */
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-head { text-align: center; font-weight: 700; font-size: .82rem; color: var(--text-2); padding: 6px 0; }
.cal-cell { min-height: 92px; border: 1px solid var(--border); border-radius: 6px; padding: 4px 6px; display: flex; flex-direction: column; gap: 2px; font-size: .78rem; overflow: hidden; }
.cal-cell.empty { border: 0; }
.cal-cell.weekend { background: var(--surface-2); }
.cal-cell.today { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.cal-day { font-weight: 700; color: var(--text-2); }
.cal-cell a { background: var(--primary-soft); color: var(--primary); border-radius: 4px; padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------ صفحات الدخول والتحقق */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; background: linear-gradient(160deg, #0f2530 0%, #12404a 100%); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 14px; padding: 28px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.auth-card.wide { max-width: 640px; }
.auth-brand { padding: 0 0 18px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.auth-brand strong { color: var(--text); }
.auth-brand small { color: var(--muted); opacity: 1; }
.auth-card h2 { font-size: 1.2rem; margin-bottom: 14px; }
.verify { padding: 14px; border-radius: 8px; margin-bottom: 14px; }
.verify.ok { background: var(--ok-soft); color: var(--ok); }
.verify.bad { background: var(--danger-soft); color: var(--danger); }

/* ------------------------------------------------ الخطاب الرسمي */
.letter-body { background: #e9edf0; padding: 24px 12px; }
.letter-tools { display: flex; gap: 10px; justify-content: center; margin-bottom: 16px; }
.letter { background: #fff; max-width: 210mm; min-height: 270mm; margin: 0 auto; padding: 18mm 20mm; box-shadow: 0 6px 30px rgba(0, 0, 0, .12); font-size: 15.5px; line-height: 2; display: flex; flex-direction: column; }
.letter-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; border-bottom: 2px solid var(--primary); padding-bottom: 12px; margin-bottom: 24px; }
.letter-org strong { display: block; font-size: 1.15rem; color: var(--primary); }
.letter-org small { color: var(--text-2); font-size: .78rem; line-height: 1.5; display: block; }
.letter-logo img { max-height: 80px; max-width: 140px; }
.letter-meta { margin: 0; justify-self: end; font-size: .85rem; line-height: 1.6; }
.letter-meta div { display: flex; gap: 8px; }
.letter-meta dt { color: var(--muted); }
.letter-meta dd { margin: 0; font-weight: 600; }
.letter-title { text-align: center; font-size: 1.35rem; margin: 6px 0 18px; text-decoration: underline; text-underline-offset: 8px; }
.letter-to { font-weight: 700; }
.letter p { margin: 0 0 12px; text-align: justify; }
.letter p .date .hijri { display: inline; font-size: .85em; color: var(--text-2); }
.letter p .date .hijri::before { content: " ("; }
.letter p .date .hijri::after { content: ")"; }
.letter-table { max-width: 360px; margin: 0 auto 14px; font-size: .95rem; }
.letter-sign { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 36px; }
.letter-sign div:first-child { display: flex; flex-direction: column; gap: 4px; text-align: center; min-width: 200px; }
.sign-line { margin-top: 24px; color: var(--muted); }
.stamp { width: 120px; height: 120px; border: 2px dashed #c9d3da; border-radius: 50%; display: grid; place-items: center; color: #b0bcc4; font-size: .85rem; }
.letter-verify { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); font-size: .76rem; color: var(--text-2); line-height: 1.6; }

/* ------------------------------------------------ الشاشات الصغيرة */
@media (max-width: 1100px) {
  .form-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; inset: 0 0 0 auto; z-index: 20; height: 100vh; transform: translateX(100%); transition: transform .2s ease; box-shadow: -10px 0 30px rgba(0, 0, 0, .2); }
  body.nav-open .sidebar { transform: none; }
  .menu-btn { display: inline-flex; }
  .main { padding: 0 16px 40px; }
  .grid-2, .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .filters input[type=search] { flex: 1 1 100%; width: 100%; }
  .inline { white-space: normal; flex-wrap: wrap; }
  .activity li { grid-template-columns: 1fr; gap: 0; }
  .bar-row { grid-template-columns: 96px 1fr 32px; }
  .tabs { margin-left: -20px; margin-right: -20px; }
  .cal-cell { min-height: 64px; }
  .cal-cell a { font-size: .68rem; }
  .letter { padding: 10mm 8mm; min-height: 0; }
  .letter-head { grid-template-columns: 1fr; text-align: center; }
  .letter-meta { justify-self: center; }
}
@media (max-width: 520px) {
  .info-grid, .info-grid.compact { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat strong { font-size: 1.45rem; }
}
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .sidebar, .toolbar, .menu-btn, .row-actions, .no-print, .tabs, .form-actions, .photo-form { display: none !important; }
  .main { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  .letter-body { padding: 0; background: #fff; }
  .letter { box-shadow: none; padding: 0; max-width: none; min-height: 268mm; }
}
