:root {
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-soft: #eef4ef;
  --text: #17251d;
  --muted: #718078;
  --primary: #77c56a;
  --primary-strong: #397a50;
  --navy: #17382a;
  --line: #e5ece7;
  --danger: #b95b58;
  --shadow: 0 16px 44px rgba(29, 70, 48, .09);
}

* { box-sizing: border-box; }
html, body { height:100%; overflow-x:hidden; scrollbar-width:none; -ms-overflow-style:none; }
html::-webkit-scrollbar, body::-webkit-scrollbar, *::-webkit-scrollbar { width:0; height:0; display:none; }
body { margin: 0; font-family: "Noto Naskh Arabic", "Inter", sans-serif; background: var(--bg); color: var(--text); }
body.dark {
  --bg: #101713;
  --surface: #18211d;
  --surface-soft: #202d27;
  --text: #edf4ef;
  --muted: #a1ada6;
  --primary: #86cf78;
  --primary-strong: #9ad08d;
  --navy: #0d261b;
  --line: #2c3932;
  --shadow: 0 16px 44px rgba(0, 0, 0, .22);
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 32px; position: relative; overflow: hidden; background: radial-gradient(circle at 75% 20%, rgba(119,197,106,.18), transparent 22%), linear-gradient(135deg, #f7faf8 0%, #edf4f0 100%); }
body.dark .login-screen { background: radial-gradient(circle at 75% 20%, rgba(119,197,106,.12), transparent 24%), #101713; }
.login-card { width: min(920px, 92vw); min-height: 610px; background: var(--surface); border: 1px solid rgba(119,197,106,.18); border-radius: 32px; box-shadow: 0 28px 80px rgba(34,78,52,.14); padding: 48px 66px; position: relative; z-index: 2; direction: rtl; }
.login-card::before { content: ""; position: absolute; inset: 0 50% 0 0; border-radius: 32px 0 0 32px; background: radial-gradient(circle at 42% 48%, rgba(119,197,106,.08), transparent 35%); pointer-events: none; }
.login-brand { display: flex; align-items: center; gap: 14px; }
.logo-ring { width: 70px; height: 70px; border: 4px solid #86c97a; border-radius: 50%; overflow: hidden; background: white; }
.logo-ring img { width: 100%; height: 100%; object-fit: cover; }
.login-brand div:last-child { display: flex; flex-direction: column; }
.login-brand div:last-child span { font: 700 25px "Inter"; letter-spacing: 5px; color: var(--primary-strong); }
.login-brand small { color: var(--muted); margin-top: 2px; }
.login-tools { position: absolute; left: 38px; top: 38px; display: flex; gap: 8px; }
.login-tool { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.login-heading { margin: 55px 0 26px; width: 48%; }
.login-heading h1 { font-size: 38px; margin: 0 0 4px; }
.login-heading p { color: var(--muted); margin: 0; }
#loginForm { width: 48%; direction: rtl; }
#loginForm label > span { display: block; font-weight: 700; margin-bottom: 8px; }
.input-wrap { height: 54px; border: 1px solid var(--line); border-radius: 12px; display: flex; align-items: center; padding: 0 15px; background: var(--surface); margin-bottom: 18px; }
.input-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(119,197,106,.12); }
.input-wrap > span { color: var(--primary-strong); margin-left: 10px; }
.input-wrap input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); height: 100%; }
.input-wrap button { border: 0; background: transparent; color: var(--muted); }
.login-options { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 22px; }
.remember { display: flex; align-items: center; gap: 7px; color: var(--muted); }
.remember input { accent-color: var(--primary-strong); }
.login-options button { border: 0; background: transparent; color: var(--primary-strong); }
.login-submit { height: 56px; width: 100%; border: 0; border-radius: 13px; background: var(--navy); color: white; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; font-weight: 700; font-size: 16px; box-shadow: 0 12px 24px rgba(23,56,42,.18); }
.login-submit b { font-size: 22px; }
.login-error { color: var(--danger); min-height: 20px; margin: 0; }
.demo-note { position: absolute; left: 66px; bottom: 48px; display: flex; flex-direction: column; color: var(--muted); direction: ltr; }
.demo-note code { color: var(--primary-strong); background: var(--surface-soft); padding: 7px 10px; border-radius: 8px; margin-top: 5px; }
.login-orb { position: absolute; border-radius: 50%; filter: blur(2px); }
.orb-one { width: 380px; height: 380px; right: -180px; top: -180px; background: rgba(119,197,106,.12); }
.orb-two { width: 260px; height: 260px; left: -130px; bottom: -130px; background: rgba(48,117,82,.10); }

.app-shell { display: none; min-height: 100vh; }
.app-shell.visible { display: flex; }
.sidebar { width: 260px; min-width: 260px; height: 100vh; position: sticky; top: 0; background: linear-gradient(180deg, #17382a 0%, #1d4935 100%); border-left: 1px solid rgba(255,255,255,.06); display: flex; flex-direction: column; padding: 24px 16px 18px; z-index: 20; box-shadow: 12px 0 32px rgba(21,70,46,.10); }
.sidebar .brand { border-bottom-color: rgba(255,255,255,.10); }
.sidebar .brand span { color: rgba(255,255,255,.62); }
.sidebar .brand strong { color: #aadd9d; }
.sidebar .nav-item { color: rgba(255,255,255,.70); }
.sidebar .nav-item.active { background: linear-gradient(135deg, #79c66d, #5aa85b); color: #fff; box-shadow: 0 8px 18px rgba(0,0,0,.16); }
.sidebar .nav-item:not(.active):hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar .logout { color: #ffc0bd; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 28px; border-bottom: 1px solid var(--line); }
.brand img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 2px solid #82c977; }
.brand div { display: flex; flex-direction: column; }
.brand strong { font: 700 18px "Inter"; letter-spacing: 3px; color: var(--primary-strong); }
.brand span { font-size: 12px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 5px; margin-top: 22px; }
.nav-item, .logout { height: 48px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); display: flex; align-items: center; gap: 12px; padding: 0 15px; text-align: right; }
.nav-item.active { background: var(--navy); color: white; }
.nav-icon { width: 24px; text-align: center; font-size: 19px; }
.logout { margin-top: auto; color: var(--danger); }
.main { flex: 1; min-width: 0; }
.topbar { height: 78px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: flex-end; padding: 0 28px; position: sticky; top: 0; z-index: 10; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.calendar-clock { min-width: 228px; height: 48px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); display: flex; align-items: center; gap: 10px; padding: 5px 12px; direction: rtl; }
.calendar-clock > strong { font: 700 13px "Inter"; direction: ltr; color: var(--primary-strong); border-left: 1px solid var(--line); padding-left: 10px; }
.calendar-clock div { display: flex; flex-direction: column; line-height: 1.25; font-size: 9.5px; color: var(--muted); }
.calendar-clock div span:last-child { direction: ltr; text-align: right; }
.icon-button, .language-button { height: 42px; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 11px; }
.icon-button { width: 42px; }
.language-button { display: flex; align-items: center; gap: 8px; padding: 0 12px; direction: rtl; }
.language-button span { color: var(--primary-strong); }
.profile { display: flex; align-items: center; gap: 9px; margin-right: 4px; padding-right: 12px; border-right: 1px solid var(--line); direction: rtl; }
.profile-avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--surface-soft); color: var(--primary-strong); display: grid; place-items: center; font-weight: 700; }
.profile-copy { display: flex; flex-direction: column; min-width: 95px; }
.profile-copy strong { font-size: 13px; }
.profile-copy span { color: var(--muted); font-size: 11px; }
.menu-button { display: none; margin-left: auto; }
.content { padding: 28px 32px 40px; direction: rtl; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; }
.page-heading h1 { margin: 0; font-size: 28px; }
.page-heading p { margin: 3px 0 0; color: var(--muted); }
.primary-button { border: 0; height: 44px; border-radius: 10px; background: var(--navy); color: white; padding: 0 16px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); }
.stat-card-top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; }
.stat-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-soft); color: var(--primary-strong); }
.stat-card strong { display: block; font: 700 30px "Inter"; margin-top: 14px; direction: ltr; text-align: right; }
.stat-card small { color: #6fae64; }
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; box-shadow: var(--shadow); }
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.panel-header h2 { margin: 0; font-size: 17px; }
.panel-header button { border: 0; background: transparent; color: var(--primary-strong); }
.chart { height: 210px; display: flex; align-items: flex-end; gap: 14px; border-bottom: 1px solid var(--line); padding: 10px 8px 0; direction: ltr; }
.bar-group { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 4px; position: relative; }
.bar { width: 40%; max-width: 18px; border-radius: 6px 6px 0 0; background: var(--primary); }
.bar.secondary { background: #dce9df; }
.bar-group::after { content: attr(data-month); position: absolute; bottom: -24px; color: var(--muted); font-size: 11px; direction: ltr; }
.chart-wrap { padding-bottom: 28px; }
.library-list { display: flex; flex-direction: column; gap: 12px; }
.library-row { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 10px; }
.library-row .rank { width: 38px; height: 38px; border-radius: 10px; background: var(--surface-soft); display: grid; place-items: center; color: var(--primary-strong); }
.library-row strong { display: block; font-size: 13px; }
.library-row span { color: var(--muted); font-size: 11px; }
.library-row b { font: 600 14px "Inter"; direction: ltr; }
.table-panel { margin-top: 18px; }
.table-wrap { overflow-x:auto; overflow-y:hidden; scrollbar-width:none; -ms-overflow-style:none; }
.table-wrap::-webkit-scrollbar { width:0; height:0; display:none; }
table { width: 100%; border-collapse: collapse; direction: rtl; }
th { color: var(--muted); font-size: 12px; font-weight: 600; text-align: right; padding: 12px 10px; border-bottom: 1px solid var(--line); }
td { padding: 14px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
.status { display: inline-block; padding: 4px 9px; border-radius: 999px; background: #edf7ec; color: #4d8350; }
body.dark .status { background: #26382d; }
.search-box { height: 42px; width: 250px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); padding: 0 12px; outline: 0; }
.empty-page { min-height: 420px; display: grid; place-items: center; text-align: center; }
.empty-page div { max-width: 420px; }
.empty-page h2 { margin-bottom: 8px; }
.empty-page p { color: var(--muted); }
.book-form { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.book-form label { display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: 13px; }
.book-form input, .book-form select { width: 100%; height: 44px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--text); padding: 0 11px; outline: 0; }
.book-form input:focus, .book-form select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(119,197,106,.10); }
.book-form-wide { grid-column: span 2; }
.book-submit { align-self: end; }
.table-action { border: 1px solid var(--line); background: var(--surface); color: var(--primary-strong); height: 34px; border-radius: 8px; padding: 0 8px; margin: 2px; }
.table-action.danger { color: var(--danger); }
.nav-item { transition: background .22s ease, color .22s ease, transform .22s ease, box-shadow .22s ease; }
.nav-item:hover { transform: translateX(-3px); }
[dir="ltr"] .nav-item:hover { transform: translateX(3px); }
.nav-item.active { animation: navPulse .45s ease both; }
.sidebar { overflow-y:auto; overflow-x:hidden; scrollbar-width:none; -ms-overflow-style:none; }
.sidebar::-webkit-scrollbar, .sidebar .nav::-webkit-scrollbar { width:0; height:0; display:none; }
.sidebar .nav { overflow-y:auto; overflow-x:hidden; scrollbar-width:none; -ms-overflow-style:none; padding-bottom:8px; }
.content > * { animation: sectionIn .38s cubic-bezier(.22,.61,.36,1) both; }
.panel, .stat-card { transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease; }
.panel:hover, .stat-card:hover { transform: translateY(-2px); }
.primary-button, .table-action, .period-button { transition: transform .18s ease, box-shadow .18s ease, background .18s ease; }
.primary-button:active, .table-action:active, .period-button:active { transform: scale(.96); }
.library-name-button { border:0; background:transparent; color:var(--text); padding:0; text-align:right; }
.library-detail-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:12px; }
.library-detail-grid div { border:1px solid var(--line); border-radius:12px; padding:14px; display:flex; flex-direction:column; gap:5px; }
.library-detail-grid span { color:var(--muted); font-size:12px; }
.library-detail-grid strong { font-size:14px; }
.library-detail-grid .detail-wide { grid-column:1/-1; }
.book-about { max-width:220px; }
.book-about summary { color:var(--primary-strong); cursor:pointer; font-weight:600; }
.book-about span { display:block; margin-top:6px; color:var(--muted); white-space:normal; }
.report-periods { display:flex; gap:8px; margin:-6px 0 18px; flex-wrap:wrap; }
.period-button { height:38px; border:1px solid var(--line); border-radius:999px; background:var(--surface); color:var(--muted); padding:0 14px; }
.period-button.active { background:var(--navy); color:white; border-color:var(--navy); }
.password-modal { position:fixed; inset:0; z-index:100; background:rgba(5,20,12,.58); backdrop-filter:blur(8px); display:grid; place-items:center; animation:fadeIn .25s ease both; }
.password-modal-card { width:min(420px,90vw); background:var(--surface); border:1px solid var(--line); border-radius:20px; padding:24px; box-shadow:var(--shadow); }
.password-modal-card h2 { margin:0 0 6px; }
.password-modal-card p { color:var(--muted); }
.password-modal-card form { display:flex; gap:8px; }
.password-modal-card input { flex:1; height:44px; border:1px solid var(--line); border-radius:9px; background:var(--surface); color:var(--text); padding:0 10px; }

@keyframes sectionIn { from { opacity:0; transform:translateY(10px) scale(.995); } to { opacity:1; transform:none; } }
@keyframes navPulse { from { box-shadow:none; } to { box-shadow:0 8px 18px rgba(0,0,0,.16); } }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

[dir="ltr"] .login-card, [dir="ltr"] .content, [dir="ltr"] .sidebar, [dir="ltr"] .topbar { direction: ltr; }
[dir="ltr"] .nav-item, [dir="ltr"] .logout { text-align: left; }
[dir="ltr"] .profile { border-right: 0; border-left: 1px solid var(--line); padding-right: 0; padding-left: 12px; }
[dir="ltr"] .login-submit b { transform: rotate(180deg); }
[dir="ltr"] .login-tools { right: 38px; left: auto; }
[dir="ltr"] .demo-note { right: 66px; left: auto; }

@media (max-width: 980px) {
  .sidebar { position: fixed; right: 0; transform: translateX(100%); transition: .25s; box-shadow: var(--shadow); }
  [dir="ltr"] .sidebar { left: 0; right: auto; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .menu-button { display: block; }
  .topbar { justify-content: space-between; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .login-card { width: min(520px, 94vw); min-height: 620px; padding: 36px; }
  .login-card::before { display: none; }
  .login-heading, #loginForm { width: 100%; }
  .login-heading { margin-top: 38px; }
  .demo-note { left: 36px; bottom: 28px; }
  .book-form { grid-template-columns: repeat(2, 1fr); }
  .calendar-clock { min-width: 190px; }
  .library-detail-grid { grid-template-columns:repeat(2,1fr); }
}
@media (max-width: 600px) {
  .login-screen { padding: 12px; }
  .login-card { min-height: 610px; padding: 24px 20px; border-radius: 22px; }
  .login-brand small { max-width: 180px; }
  .login-tools { left: 20px; top: 20px; }
  .login-heading h1 { font-size: 30px; }
  .demo-note { display: none; }
  .content { padding: 20px 14px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .profile-copy { display: none; }
  .topbar { height: 66px; padding: 0 12px; }
  .language-button { width: 42px; padding: 0; justify-content: center; }
  .language-button strong { display: none; }
  .page-heading { align-items: flex-start; }
  .page-heading h1 { font-size: 23px; }
  .search-box { width: 180px; }
  .book-form { grid-template-columns: 1fr; }
  .book-form-wide { grid-column: span 1; }
  .calendar-clock { min-width: 48px; width: 48px; padding: 5px; justify-content: center; }
  .calendar-clock div { display: none; }
  .calendar-clock > strong { border: 0; padding: 0; }
  .library-detail-grid { grid-template-columns:1fr; }
}

@media (max-width: 420px) {
  .login-card { padding: 20px 16px; min-height: 590px; }
  .login-brand .logo-ring { width: 58px; height: 58px; }
  .login-brand div:last-child span { font-size: 20px; }
  .login-heading { margin: 28px 0 18px; }
  .login-heading h1 { font-size: 26px; }
  .input-wrap { height: 50px; }
  .login-submit { height: 52px; }
  .content { padding: 16px 10px 28px; }
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card strong { font-size: 26px; }
  .panel { border-radius: 13px; padding: 14px; }
  .page-heading { gap: 10px; }
  .primary-button { height: 40px; font-size: 13px; white-space: nowrap; }
  .search-box { width: 150px; }
  .top-actions { gap: 6px; }
  .icon-button { width: 38px; height: 38px; }
  .language-button { width: 38px; height: 38px; }
  .profile-avatar { width: 38px; height: 38px; }
  .password-modal-card form { flex-direction: column; }
  .password-modal-card input { width: 100%; }
}
