/* =========================================================
   ديوان — نظام التصميم (Design System v2)
   خطوط النظام بالكامل — بدون أي اعتماد على الإنترنت
   ========================================================= */

:root{
  /* ---- ثيم افتراضي: "ليل المكتبة" ---- */
  --bg:            #12172A;
  --bg-elevated:   #1A2138;
  --bg-card:       #1F2740;
  --bg-card-hi:    #242D4A;
  --ink:           #ECE8DC;
  --ink-dim:       #A6A3B0;
  --accent:        #D3A94A;
  --accent-2:      #E9C878;
  --accent-ink:    #14192B;
  --accent-soft:   rgba(211,169,74,0.14);
  --line:          rgba(236,231,218,0.09);
  --line-strong:   rgba(236,231,218,0.16);
  --danger:        #D3705A;
  --success:       #6BA377;
  --info:          #5C93BE;
  --radius-s:      10px;
  --radius-m:      16px;
  --radius-l:      22px;
  --radius-xl:     28px;
  --shadow-1:      0 2px 10px rgba(0,0,0,0.18);
  --shadow-2:      0 10px 28px rgba(0,0,0,0.30);
  --shadow-3:      0 22px 60px rgba(0,0,0,0.45);
  --glass-hi:      rgba(255,255,255,0.05);
  --font-display:  "Segoe UI", "Cairo", "Geeza Pro", "Tahoma", sans-serif;
  --font-body:     "Segoe UI", "Tahoma", "Geeza Pro", sans-serif;
  --ease-spring:   cubic-bezier(.22,.9,.3,1.1);
  --ease-out:      cubic-bezier(.16,.9,.25,1);
  color-scheme: dark;
}

[data-theme="paper"]{
  --bg:            #F1E9D8;
  --bg-elevated:   #FBF8F0;
  --bg-card:       #FFFFFF;
  --bg-card-hi:    #F7F1E3;
  --ink:           #2A2216;
  --ink-dim:       #7C7059;
  --accent:        #9C5B33;
  --accent-2:      #B87A44;
  --accent-ink:    #FBF7EC;
  --accent-soft:   rgba(156,91,51,0.12);
  --line:          rgba(42,34,22,0.10);
  --line-strong:   rgba(42,34,22,0.18);
  --danger:        #B23B22;
  --success:       #356B43;
  --info:          #2C6491;
  --shadow-1:      0 2px 10px rgba(90,70,40,0.08);
  --shadow-2:      0 10px 26px rgba(90,70,40,0.14);
  --shadow-3:      0 24px 60px rgba(90,70,40,0.22);
  --glass-hi:      rgba(255,255,255,0.5);
  color-scheme: light;
}

[data-theme="teal"]{
  --bg:            #0D2422;
  --bg-elevated:   #10302D;
  --bg-card:       #143E3A;
  --bg-card-hi:    #184A45;
  --ink:           #E6F3EF;
  --ink-dim:       #94B6AF;
  --accent:        #4FC2AE;
  --accent-2:      #7ADCC9;
  --accent-ink:    #0D2422;
  --accent-soft:   rgba(79,194,174,0.14);
  --line:          rgba(230,243,239,0.09);
  --line-strong:   rgba(230,243,239,0.16);
  --danger:        #D3705A;
  --success:       #6BA377;
  --info:          #5C93BE;
  --shadow-1:      0 2px 10px rgba(0,0,0,0.2);
  --shadow-2:      0 10px 28px rgba(0,0,0,0.32);
  --shadow-3:      0 22px 60px rgba(0,0,0,0.45);
  --glass-hi:      rgba(255,255,255,0.05);
  color-scheme: dark;
}

[data-theme="rose"]{
  --bg:            #221621;
  --bg-elevated:   #2B1A29;
  --bg-card:       #32202F;
  --bg-card-hi:    #3B2637;
  --ink:           #F3E6EE;
  --ink-dim:       #B296AA;
  --accent:        #E087A0;
  --accent-2:      #F0A8BB;
  --accent-ink:    #221621;
  --accent-soft:   rgba(224,135,160,0.14);
  --line:          rgba(243,230,238,0.09);
  --line-strong:   rgba(243,230,238,0.16);
  --danger:        #D3705A;
  --success:       #6BA377;
  --info:          #5C93BE;
  --shadow-1:      0 2px 10px rgba(0,0,0,0.2);
  --shadow-2:      0 10px 28px rgba(0,0,0,0.32);
  --shadow-3:      0 22px 60px rgba(0,0,0,0.45);
  --glass-hi:      rgba(255,255,255,0.05);
  color-scheme: dark;
}

*{ box-sizing:border-box; margin:0; padding:0; }
html,body{ height:100%; overflow-x:hidden; }

body{
  background:
    radial-gradient(circle at 12% -8%, var(--accent-soft), transparent 40%),
    radial-gradient(circle at 100% 8%, rgba(255,255,255,0.03), transparent 35%),
    var(--bg);
  background-attachment:fixed;
  color:var(--ink);
  font-family:var(--font-body);
  line-height:1.55;
  -webkit-font-smoothing:antialiased;
  transition:background .3s ease,color .3s ease;
}

button, input, select, textarea{ font-family:inherit; }
.hidden{ display:none !important; }

::-webkit-scrollbar{ width:9px; height:9px; }
::-webkit-scrollbar-track{ background:transparent; }
::-webkit-scrollbar-thumb{ background:var(--line-strong); border-radius:20px; }
::-webkit-scrollbar-thumb:hover{ background:var(--accent); }

:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; border-radius:4px; }

/* ---------------- سطوح زجاجية موحّدة ---------------- */
.card-panel, .auth-card, .modal-box, .stat-card, .book-card, .category-row, .loan-row,
.theme-swatch, .duplicate-warning, .health-card{
  background:
    linear-gradient(180deg, var(--glass-hi), transparent 40%),
    var(--bg-elevated);
  position:relative;
}

/* =========================================================
   شاشات كاملة (البداية / إعداد / دخول)
   ========================================================= */
.splash{
  position:fixed; inset:0; z-index:2000;
  background:
    radial-gradient(circle at 25% 15%, var(--accent-soft), transparent 50%),
    radial-gradient(circle at 80% 85%, var(--accent-soft), transparent 45%),
    var(--bg);
  display:flex; align-items:center; justify-content:center; flex-direction:column; gap:16px;
  transition:opacity .5s ease, visibility .5s ease;
}
.splash.hide{ opacity:0; visibility:hidden; pointer-events:none; }
.splash-mark-img{
  width:92px; height:92px; border-radius:26px;
  animation:splashPop .7s var(--ease-spring) both, splashFloat 2.6s ease-in-out .7s infinite;
  box-shadow:var(--shadow-3), 0 0 0 9px var(--accent-soft);
}
.splash-name{
  font-family:var(--font-display); font-size:21px; font-weight:700; letter-spacing:.5px;
  opacity:0; animation:splashFade .6s ease .25s forwards;
  background:linear-gradient(90deg, var(--ink), var(--accent-2), var(--ink));
  background-size:200% auto; -webkit-background-clip:text; background-clip:text; color:transparent;
  animation:splashFade .6s ease .25s forwards, shimmerText 3s linear 1s infinite;
}
.splash-bar{ width:130px; height:3px; border-radius:3px; background:var(--line); overflow:hidden; margin-top:4px; }
.splash-bar::after{
  content:""; display:block; height:100%; width:40%;
  background:linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius:3px; animation:splashLoad 1.1s ease-in-out infinite;
}

.auth-screen{
  min-height:100vh;
  display:flex; align-items:center; justify-content:center;
  padding:24px;
  background:
    radial-gradient(circle at 18% 12%, var(--accent-soft), transparent 42%),
    radial-gradient(circle at 88% 90%, var(--accent-soft), transparent 40%),
    var(--bg);
}
.auth-card{
  width:100%; max-width:430px;
  border:1px solid var(--line-strong);
  border-radius:var(--radius-xl);
  padding:38px 34px;
  box-shadow:var(--shadow-3);
  backdrop-filter:blur(18px);
  animation:authIn .55s var(--ease-spring) both;
}
.auth-mark-img{
  width:64px; height:64px; border-radius:19px; margin-bottom:18px;
  box-shadow:var(--shadow-2); animation:splashPop .6s var(--ease-spring) .1s both;
}
.auth-mark-sm{ width:50px; height:50px; margin-bottom:14px; }
.auth-card h1{ font-family:var(--font-display); font-size:27px; font-weight:700; margin-bottom:7px; letter-spacing:.2px; }
.auth-sub{ color:var(--ink-dim); font-size:14.5px; margin-bottom:28px; }

.field{ margin-bottom:17px; animation:fieldIn .45s ease both; }
.field:nth-child(1){ animation-delay:.05s; } .field:nth-child(2){ animation-delay:.1s; }
.field:nth-child(3){ animation-delay:.15s; } .field:nth-child(4){ animation-delay:.2s; }
.field label{ display:block; font-size:12.5px; font-weight:600; color:var(--ink-dim); margin-bottom:7px; letter-spacing:.2px; }
.field input, .field select, .field textarea{
  width:100%;
  background:var(--bg-card);
  border:1.5px solid var(--line);
  color:var(--ink);
  border-radius:var(--radius-s);
  padding:12px 14px;
  font-size:14.5px;
  outline:none;
  transition:border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.field input:hover, .field select:hover{ border-color:var(--line-strong); }
.field input:focus, .field select:focus, .field textarea:focus{
  border-color:var(--accent);
  box-shadow:0 0 0 4px var(--accent-soft);
  background:var(--bg-card-hi);
}
.field-error{ color:var(--danger); font-size:12.5px; margin-top:6px; min-height:1px; }

.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  border:none; cursor:pointer; position:relative; overflow:hidden;
  border-radius:var(--radius-s);
  padding:12px 20px;
  font-size:14.5px; font-weight:600;
  transition:transform .15s var(--ease-out), filter .18s ease, background .18s ease, box-shadow .2s ease;
}
.btn:hover{ transform:translateY(-1.5px); }
.btn:active{ transform:translateY(0) scale(0.97); }
.btn-primary{
  background:linear-gradient(155deg, var(--accent-2), var(--accent));
  color:var(--accent-ink); width:100%;
  box-shadow:0 6px 18px -4px var(--accent-soft), 0 2px 6px rgba(0,0,0,0.15);
}
.btn-primary:hover{ box-shadow:0 10px 26px -4px var(--accent-soft), 0 3px 10px rgba(0,0,0,0.2); }
.btn-ghost{ background:var(--bg-card); color:var(--ink); border:1.5px solid var(--line); }
.btn-ghost:hover{ background:var(--bg-card-hi); border-color:var(--line-strong); }
.btn-danger{ background:transparent; color:var(--danger); border:1.5px solid rgba(211,112,90,0.4); }
.btn-danger:hover{ background:rgba(211,112,90,0.1); }
.btn-icon{ background:var(--bg-card); color:var(--ink); border:1.5px solid var(--line); padding:10px 14px; border-radius:var(--radius-s); font-size:13px; font-weight:600; }
.btn-icon:hover{ background:var(--bg-card-hi); }

.auth-welcome{
  display:flex; align-items:center; gap:13px; margin-bottom:24px;
  background:var(--accent-soft); border:1px solid var(--line); border-radius:var(--radius-m); padding:15px 17px;
}
.avatar{
  width:44px; height:44px; border-radius:50%;
  background:linear-gradient(155deg, var(--accent-2), var(--accent)); color:var(--accent-ink);
  display:flex; align-items:center; justify-content:center;
  font-weight:700; font-size:17px; flex-shrink:0;
  box-shadow:0 4px 12px -2px var(--accent-soft);
}
.avatar-logo{
  object-fit:cover; padding:2px;
  background:linear-gradient(155deg, var(--accent-2), var(--accent));
}
.avatar-lg{
  width:54px; height:54px; font-size:20px;
  box-shadow:0 0 0 4px var(--accent-soft), 0 6px 16px -2px rgba(0,0,0,0.3);
  animation:splashPop .55s var(--ease-spring) .15s both;
}
.avatar-lg.avatar-logo{ animation:splashPop .55s var(--ease-spring) .15s both, avatarBreathe 3.4s ease-in-out 1s infinite; }
@keyframes avatarBreathe{ 0%,100%{ transform:scale(1) rotate(0deg); } 50%{ transform:scale(1.05) rotate(-2deg); } }
.auth-welcome strong{ font-size:15.5px; display:block; }
.auth-welcome span{ font-size:12.5px; color:var(--ink-dim); }

/* =========================================================
   تطبيق رئيسي — الهيكل العام
   ========================================================= */
.app-shell{ display:flex; min-height:100vh; }

.sidebar{
  width:256px; flex-shrink:0;
  background:linear-gradient(180deg, var(--glass-hi), transparent 30%), var(--bg-elevated);
  border-left:1px solid var(--line);
  padding:24px 16px;
  display:flex; flex-direction:column;
  position:sticky; top:0; height:100vh;
  animation:sidebarIn .4s ease both;
}
.sidebar-brand{ display:flex; align-items:center; gap:11px; padding:0 6px 26px; }
.mark-img{ width:40px; height:40px; border-radius:12px; box-shadow:var(--shadow-1); }
.sidebar-brand .name{ font-family:var(--font-display); font-weight:700; font-size:18.5px; letter-spacing:.2px; }
.sidebar-brand .ver{ font-size:10.5px; color:var(--ink-dim); font-weight:600; }

.nav-list{ list-style:none; display:flex; flex-direction:column; gap:4px; flex:1; }
.nav-item{
  display:flex; align-items:center; gap:12px;
  padding:11px 14px; border-radius:var(--radius-s);
  color:var(--ink-dim); cursor:pointer; font-size:14px; font-weight:600;
  position:relative; overflow:hidden;
  transition:all .18s var(--ease-out);
}
.nav-item .ic{ width:20px; text-align:center; font-size:16px; }
.nav-item:hover{ background:var(--bg-card); color:var(--ink); }
.nav-item.active{
  background:linear-gradient(90deg, var(--accent-soft), transparent);
  color:var(--accent);
}
.nav-item.active::before{
  content:""; position:absolute; right:0; top:14%; bottom:14%; width:3px;
  background:linear-gradient(180deg, var(--accent-2), var(--accent)); border-radius:4px 0 0 4px;
}
.nav-item::after{
  content:""; position:absolute; inset:0; background:var(--accent); opacity:0; border-radius:inherit;
  transform:scale(.85); transition:opacity .2s ease, transform .2s ease; z-index:-1;
}
.nav-item:active::after{ opacity:.12; transform:scale(1); }

.sidebar-footer{
  padding-top:16px; border-top:1px solid var(--line); margin-top:10px;
  display:flex; flex-direction:column; gap:11px;
}
.sidebar-user{ display:flex; align-items:center; gap:10px; font-size:13.5px; }
.sidebar-user .avatar{ width:32px; height:32px; font-size:13px; }
.logout-btn{
  display:flex; align-items:center; gap:8px; width:100%;
  background:var(--bg-card); border:1.5px solid var(--line); color:var(--danger);
  padding:10px 12px; border-radius:var(--radius-s); font-size:13px; font-weight:700; cursor:pointer;
  transition:background .18s ease, transform .15s ease, border-color .18s ease;
}
.logout-btn:hover{ background:rgba(211,112,90,0.1); border-color:rgba(211,112,90,0.35); }
.logout-btn:active{ transform:scale(0.97); }

.app-footer-badge{
  text-align:center; padding:10px 12px; border-radius:var(--radius-s);
  border:1px solid var(--line-strong); background:transparent;
  box-shadow:0 0 14px -2px var(--accent-soft);
  animation:badgeGlow 3.6s ease-in-out infinite;
}
.fb-app{ display:block; font-family:var(--font-display); font-size:12.5px; font-weight:700; color:var(--accent); letter-spacing:.3px; }
.fb-dev{ display:block; font-size:10.5px; font-weight:600; color:var(--ink-dim); margin-top:3px; letter-spacing:.2px; }
@keyframes badgeGlow{
  0%,100%{ box-shadow:0 0 14px -2px var(--accent-soft); border-color:var(--line-strong); }
  50%{ box-shadow:0 0 20px 0px var(--accent-soft); border-color:color-mix(in srgb, var(--accent) 45%, var(--line-strong)); }
}

.main{ flex:1; padding:30px 36px; max-width:1220px; }
.page{ display:none; }
.page.active{ display:block; animation:pageIn .32s var(--ease-spring) both; }

.page-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:26px; flex-wrap:wrap; gap:12px; }
.page-head h2{ font-family:var(--font-display); font-size:23px; font-weight:700; letter-spacing:.2px; }
.page-head p{ color:var(--ink-dim); font-size:13.5px; margin-top:3px; }

/* =========================================================
   شريط الموبايل: علوي وسفلي
   ========================================================= */
.mobile-tabbar, .mobile-topbar{ display:none; }

@media (max-width:860px){
  .mobile-topbar{
    display:flex; align-items:center; justify-content:space-between;
    padding:13px 18px; background:color-mix(in srgb, var(--bg-elevated) 88%, transparent);
    backdrop-filter:blur(16px);
    border-bottom:1px solid var(--line);
    position:sticky; top:0; z-index:50;
  }
  .mobile-brand{ display:flex; align-items:center; gap:9px; font-family:var(--font-display); font-weight:700; font-size:16px; }
  .mobile-mark{ width:32px; height:32px; border-radius:10px; box-shadow:var(--shadow-1); }
  .mobile-user{ display:flex; align-items:center; gap:9px; }
  .mobile-user .avatar{ width:30px; height:30px; font-size:12px; }
  .mobile-logout{ background:var(--bg-card); border:1px solid var(--line); border-radius:11px; padding:8px; cursor:pointer; transition:background .15s ease; }
  .mobile-logout:active{ background:rgba(211,112,90,0.15); }
  .mobile-logout .icon, .mobile-logout .ic{ width:17px; height:17px; }

  .mobile-tabbar{
    display:flex; align-items:center; gap:4px; position:fixed; bottom:14px; inset-inline:14px; z-index:90;
    background:color-mix(in srgb, var(--bg-elevated) 84%, transparent);
    backdrop-filter:blur(22px);
    border:1px solid var(--line-strong);
    border-radius:26px;
    padding:9px calc(9px + env(safe-area-inset-bottom)/2) calc(9px + env(safe-area-inset-bottom)) 9px;
    box-shadow:var(--shadow-3);
  }
  .mtab{
    flex:1; display:flex; align-items:center; justify-content:center;
    background:none; border:none; color:var(--ink-dim); padding:11px 4px; border-radius:16px; cursor:pointer;
    transition:color .18s ease, transform .15s ease, background .18s ease;
  }
  .mtab:active{ transform:scale(0.9); }
  .mtab .icon, .mtab .ic{ width:23px; height:23px; transition:transform .2s var(--ease-spring); }
  .mtab.active{ color:var(--accent); background:var(--accent-soft); }
  .mtab.active .icon, .mtab.active .ic{ transform:scale(1.08); }
  .mtab-add{ flex:0 0 auto; padding:0; margin:0 2px; }
  .mtab-add .icon, .mtab-add .ic{
    width:48px; height:48px; background:linear-gradient(155deg, var(--accent-2), var(--accent));
    border-radius:50%; padding:0; display:flex; align-items:center; justify-content:center;
    box-shadow:0 10px 22px -4px var(--accent-soft), 0 4px 10px rgba(0,0,0,0.3);
    transform:translateY(-14px);
  }
  .mtab-add:active .icon, .mtab-add:active .ic{ transform:translateY(-14px) scale(0.92); }
  .mtab-add .icon svg path, .mtab-add .ic svg path{ stroke:var(--accent-ink) !important; }

  .app-shell{ flex-direction:column; padding-bottom:92px; }
  .sidebar{ display:none; }
  .main{ padding:20px 18px; }

  /* المودالات كـ bottom-sheet على الموبايل — أسهل بكتير بالإبهام */
  .modal-overlay{ align-items:flex-end; padding:0; }
  .modal-box{
    max-width:100%; width:100%; max-height:88vh;
    border-radius:26px 26px 0 0; padding:22px 20px calc(22px + env(safe-area-inset-bottom));
    animation:sheetIn .32s var(--ease-spring) both;
  }
  .modal-box::before{
    content:""; display:block; width:40px; height:4px; border-radius:4px;
    background:var(--line-strong); margin:0 auto 16px;
  }
  .toolbar{ flex-wrap:wrap; gap:8px; }
  .toolbar .search-box{ flex:1 1 100%; }
  .toolbar .btn-icon{ flex:1 1 auto; justify-content:center; padding:11px 10px; min-width:44px; }
  .toolbar .btn-label{ display:none; }
  .chip-row-scroll{
    flex-wrap:nowrap; overflow-x:auto; -webkit-overflow-scrolling:touch;
    padding-bottom:2px; scrollbar-width:none;
  }
  .chip-row-scroll::-webkit-scrollbar{ display:none; }
  .chip-row-scroll .chip{ flex-shrink:0; }
  .toolbar .btn-icon{ justify-content:center; }
  .book-grid{ grid-template-columns:repeat(auto-fill,minmax(140px,1fr)); gap:13px; }
  .stat-card .n{ font-size:24px; }
  .loan-row{ flex-wrap:wrap; }
  .loan-row .btn{ flex-basis:100%; margin-inline-start:32px; width:calc(100% - 32px); justify-content:center; }
  .modal-actions .btn{ flex:1 1 auto; }
  .settings-tab-btn{ padding:10px 12px; font-size:12.5px; }
}

/* =========================================================
   لوحة التحكم
   ========================================================= */
.greeting-card{
  background:
    radial-gradient(circle at 15% -20%, var(--accent-soft), transparent 55%),
    linear-gradient(180deg, var(--glass-hi), transparent 40%),
    var(--bg-elevated);
  border:1px solid var(--line-strong); border-radius:var(--radius-xl);
  padding:28px 30px; margin-bottom:26px;
  display:flex; align-items:center; justify-content:space-between; gap:20px; flex-wrap:wrap;
  box-shadow:var(--shadow-1);
  animation:cardIn .45s ease both;
}
.greeting-eyebrow{ display:flex; align-items:center; gap:7px; color:var(--accent); font-size:12.5px; font-weight:700; letter-spacing:.3px; margin-bottom:7px; }
.greeting-eyebrow .icon{ width:16px; height:16px; }
.greeting-title{ font-family:var(--font-display); font-size:25px; font-weight:700; letter-spacing:.2px; }
.greeting-sub{ color:var(--ink-dim); font-size:13.5px; margin-top:6px; }
.greeting-actions{ display:flex; gap:10px; flex-wrap:wrap; }

.stat-grid{ display:grid; grid-template-columns:repeat(auto-fit,minmax(175px,1fr)); gap:14px; margin-bottom:28px; }
.stat-card{
  border:1px solid var(--line); border-radius:var(--radius-m);
  padding:18px 20px; box-shadow:var(--shadow-1);
  animation:cardIn .4s ease both; transition:transform .2s var(--ease-out), box-shadow .2s ease;
}
.stat-card:hover{ transform:translateY(-2px); box-shadow:var(--shadow-2); }
.stat-grid .stat-card:nth-child(1){ animation-delay:.02s; } .stat-grid .stat-card:nth-child(2){ animation-delay:.06s; }
.stat-grid .stat-card:nth-child(3){ animation-delay:.1s; } .stat-grid .stat-card:nth-child(4){ animation-delay:.14s; }
.stat-grid .stat-card:nth-child(5){ animation-delay:.18s; } .stat-grid .stat-card:nth-child(6){ animation-delay:.22s; }
.stat-card .n{ font-family:var(--font-display); font-size:29px; font-weight:700; color:var(--accent); letter-spacing:.2px; }
.stat-card .l{ color:var(--ink-dim); font-size:12.5px; margin-top:5px; font-weight:600; }

.section-title{ font-family:var(--font-display); font-size:16px; font-weight:700; margin:26px 0 14px; display:flex; align-items:center; gap:8px; }

.dash-grid{ display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-bottom:8px; }
.bar-list{ display:flex; flex-direction:column; gap:13px; }
.bar-row{ animation:cardIn .4s ease both; }
.bar-row .bar-top{ display:flex; justify-content:space-between; align-items:center; font-size:12.5px; margin-bottom:6px; }
.bar-row .bar-top span:first-child{ color:var(--ink); font-weight:600; display:flex; align-items:center; }
.bar-row .bar-top span:last-child{ color:var(--ink-dim); font-weight:600; }
.bar-track{ height:8px; border-radius:8px; background:var(--bg-card); overflow:hidden; }
.bar-fill{ height:100%; border-radius:8px; background:linear-gradient(90deg, var(--accent), var(--accent-2)); width:0%; transition:width 1s var(--ease-out); }
.cat-dot{ display:inline-block; width:9px; height:9px; border-radius:50%; margin-inline-end:5px; box-shadow:0 0 0 3px color-mix(in srgb, currentColor 15%, transparent); }

.loan-row{
  display:flex; align-items:center; gap:12px; padding:12px 0; border-bottom:1px solid var(--line);
}
.loan-row:last-child{ border-bottom:none; }
.loan-row .lr-title{ font-weight:700; font-size:13.5px; flex:1; }
.loan-row .lr-meta{ font-size:12px; color:var(--ink-dim); }
.loan-row .lr-meta.overdue{ color:var(--danger); font-weight:700; }
.loan-row .btn{ width:auto; padding:7px 14px; font-size:12.5px; }

/* =========================================================
   بطاقات الكتب / المكتبة
   ========================================================= */
.book-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(172px,1fr)); gap:18px; }
.book-card{
  border:1px solid var(--line); border-radius:var(--radius-m);
  overflow:hidden; cursor:pointer; position:relative;
  display:flex; flex-direction:column; box-shadow:var(--shadow-1);
  animation:bookIn .38s var(--ease-spring) both;
  transition:transform .2s var(--ease-out), box-shadow .25s ease, border-color .2s ease;
}
.book-card:hover{ transform:translateY(-5px); box-shadow:var(--shadow-2); border-color:var(--accent); }
.book-cover{
  aspect-ratio:2/3; width:100%; background:var(--bg-card);
  display:flex; align-items:center; justify-content:center;
  color:var(--ink-dim); font-size:12px; text-align:center; padding:10px;
  position:relative; overflow:hidden;
}
.book-cover img{ width:100%; height:100%; object-fit:cover; transition:transform .4s var(--ease-out); }
.book-card:hover .book-cover img{ transform:scale(1.07); }
.book-badge{
  position:absolute; top:8px; right:8px; color:#14192B;
  font-size:10.5px; font-weight:700; padding:3.5px 9px; border-radius:20px;
  box-shadow:0 3px 8px rgba(0,0,0,0.25);
}
.book-badge-wishlist{
  position:absolute; top:8px; inset-inline-start:8px; background:linear-gradient(155deg,#F0A8BB,#D97C93); color:#241820;
  font-size:10px; font-weight:700; padding:3.5px 8px; border-radius:20px; display:flex; align-items:center; gap:3px;
  box-shadow:0 3px 8px rgba(0,0,0,0.25);
}
.book-badge-wishlist .icon{ width:11px; height:11px; }
.book-info{ padding:12px 13px 14px; }
.book-title{ font-size:13.5px; font-weight:700; line-height:1.35; margin-bottom:3px;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.book-author{ font-size:11.5px; color:var(--ink-dim); margin-bottom:9px; }
.book-meta{ display:flex; align-items:center; justify-content:space-between; font-size:10.5px; color:var(--ink-dim); }
.book-meta span{ display:flex; align-items:center; gap:3px; }

.card-quick-actions{
  position:absolute; top:8px; left:8px; z-index:2; display:flex; gap:5px;
  opacity:0; transform:translateY(-4px); transition:opacity .18s ease, transform .18s ease;
}
.book-card:hover .card-quick-actions{ opacity:1; transform:translateY(0); }
.card-quick-btn{
  width:29px; height:29px; border-radius:10px; background:rgba(15,18,32,0.78);
  border:1px solid rgba(255,255,255,0.14); display:flex; align-items:center; justify-content:center; cursor:pointer;
  backdrop-filter:blur(6px); transition:transform .15s ease, background .15s ease;
}
.card-quick-btn:hover{ background:rgba(15,18,32,0.95); transform:scale(1.08); }
.card-quick-btn .icon{ width:15px; height:15px; }
.book-card.is-archived{ opacity:.6; }
.book-card.is-archived::after{
  content:"مؤرشف"; position:absolute; bottom:0; inset-inline:0; text-align:center;
  background:rgba(180,98,47,0.88); color:#fff; font-size:10.5px; font-weight:700; padding:3.5px 0;
}
.book-card.is-loaned::after{
  content:"مُعار"; position:absolute; bottom:0; inset-inline:0; text-align:center;
  background:rgba(139,111,176,0.88); color:#fff; font-size:10.5px; font-weight:700; padding:3.5px 0;
}

.toolbar{ display:flex; gap:10px; margin-bottom:20px; flex-wrap:wrap; align-items:center; }
.search-box{ flex:1; min-width:200px; position:relative; }
.search-box input{
  width:100%; background:var(--bg-elevated); border:1.5px solid var(--line); color:var(--ink);
  padding:10px 14px 10px 38px; border-radius:var(--radius-s); font-size:14px; outline:none;
  transition:border-color .18s ease, box-shadow .18s ease;
}
.search-box input:focus{ border-color:var(--accent); box-shadow:0 0 0 4px var(--accent-soft); }
.search-ic{ position:absolute; top:50%; transform:translateY(-50%); inset-inline-start:14px; width:17px; height:17px; opacity:.6; }

#archiveToggleBtn.active{ background:var(--accent-soft); border-color:var(--accent); color:var(--accent); }
#loanToggleBtn.active{ background:rgba(139,111,176,0.16); border-color:#8B6FB0; color:#8B6FB0; }

.chip-row{ display:flex; gap:8px; flex-wrap:wrap; }
.chip{
  padding:7.5px 15px; border-radius:20px; font-size:12.5px; font-weight:600; cursor:pointer;
  background:var(--bg-elevated); border:1.5px solid var(--line); color:var(--ink-dim);
  transition:all .18s ease;
}
.chip:hover{ color:var(--ink); border-color:var(--line-strong); }
.chip.active{ background:linear-gradient(155deg, var(--accent-2), var(--accent)); color:var(--accent-ink); border-color:transparent;
  box-shadow:0 4px 12px -2px var(--accent-soft); animation:chipPop .3s ease; }

.chip-divider{
  flex-shrink:0; width:1px; align-self:stretch; background:var(--line-strong); margin:2px 4px;
}
.empty-state{
  text-align:center; padding:64px 20px; color:var(--ink-dim);
  border:1.5px dashed var(--line-strong); border-radius:var(--radius-m);
  background:var(--bg-elevated);
}
.ic-big{ display:inline-flex; width:40px; height:40px; margin-bottom:10px; }
.ic-big .icon{ width:100%; height:100%; }
.cover-fallback{ display:flex; flex-direction:column; align-items:center; gap:6px; }
.cover-fallback .icon{ width:30px; height:30px; }
.cover-fallback em{ font-style:normal; font-size:11px; color:var(--ink-dim); }

/* =========================================================
   إضافة/تعديل كتاب
   ========================================================= */
.add-tabs{ display:flex; gap:8px; margin-bottom:22px; }
.add-tab-btn{
  display:flex; align-items:center; gap:7px;
  padding:9.5px 19px; border-radius:var(--radius-s); font-size:13.5px; font-weight:600;
  background:var(--bg-elevated); border:1.5px solid var(--line); color:var(--ink-dim); cursor:pointer;
  transition:all .18s ease;
}
.add-tab-btn:hover{ color:var(--ink); }
.add-tab-btn.active{ background:var(--accent-soft); color:var(--accent); border-color:var(--accent); }
.form-grid{ display:grid; grid-template-columns:1fr 1fr; gap:17px; }
.form-grid .full{ grid-column:1/-1; }
.card-panel{ border:1px solid var(--line); border-radius:var(--radius-l); padding:26px; max-width:780px; box-shadow:var(--shadow-1); }

.duplicate-warning{
  display:flex; align-items:flex-start; gap:11px;
  border:1.5px solid rgba(211,112,90,0.4); color:var(--ink);
  border-radius:var(--radius-s); padding:13px 15px; margin-bottom:18px; font-size:13px; line-height:1.65;
  animation:cardIn .3s ease both;
}
.duplicate-warning .icon{ width:20px; height:20px; flex-shrink:0; margin-top:1px; }
.duplicate-warning b{ display:block; margin-bottom:2px; color:var(--danger); }

.rating-input{ display:flex; gap:5px; font-size:22px; color:var(--line); cursor:pointer; user-select:none; }
.rating-input span{ display:inline-flex; transition:transform .15s var(--ease-spring); }
.rating-input span .icon{ width:24px; height:24px; }
.rating-input span:hover{ transform:scale(1.2) rotate(-4deg); }
.rating-static{ display:flex; gap:3px; margin-bottom:14px; }
.rating-static .icon{ width:18px; height:18px; }

/* ---- الحقول المخصَّصة ---- */
.custom-fields-list{ display:flex; flex-direction:column; gap:8px; }
.custom-field-row{ display:flex; gap:8px; align-items:center; }
.custom-field-row input{
  flex:1; background:var(--bg-card); border:1.5px solid var(--line); color:var(--ink);
  border-radius:var(--radius-s); padding:10px 12px; font-size:13.5px; outline:none;
}
.custom-field-row input:focus{ border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-soft); }
.custom-field-row .cfr-remove{
  flex-shrink:0; width:36px; height:36px; border-radius:var(--radius-s); background:var(--bg-card);
  border:1.5px solid var(--line); color:var(--danger); cursor:pointer; display:flex; align-items:center; justify-content:center;
}
.custom-field-row .cfr-remove:hover{ background:rgba(211,112,90,0.1); border-color:rgba(211,112,90,0.35); }

/* ---- شارة السلسلة على البطاقة وفي التفاصيل ---- */
.book-series-badge{
  display:flex; align-items:center; gap:4px; font-size:10.5px; font-weight:600; color:var(--accent);
  margin-bottom:5px;
}
.book-series-badge .icon{ width:12px; height:12px; }
.series-group-header{
  display:flex; align-items:center; gap:9px; margin:22px 0 12px; font-family:var(--font-display);
  font-size:15px; font-weight:700; color:var(--ink);
}
.series-group-header .icon{ width:18px; height:18px; }
.series-group-header .sgh-count{ font-family:var(--font-body); font-size:12px; font-weight:600; color:var(--ink-dim); }
.series-group-block{ margin-bottom:8px; }
.series-group-block .book-grid{ margin-top:0; }

/* ---- وضع التحديد المتعدد ---- */
.book-card.selectable .card-quick-actions{ display:none; }
.book-card.selectable{ cursor:pointer; }
.book-select-check{
  position:absolute; top:8px; left:8px; z-index:3; width:26px; height:26px;
  filter:drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}
.book-card.is-selected{ outline:2.5px solid var(--accent); outline-offset:-2px; }
.book-card.is-selected .book-cover{ filter:brightness(0.85); }

.batch-bar{
  position:sticky; bottom:14px; z-index:60; margin-top:20px;
  display:flex; justify-content:center; animation:sheetIn .25s var(--ease-spring) both;
}
.batch-bar-inner{
  display:flex; align-items:center; gap:10px; flex-wrap:wrap; justify-content:center;
  background:color-mix(in srgb, var(--bg-elevated) 92%, transparent); backdrop-filter:blur(16px);
  border:1px solid var(--line-strong); border-radius:var(--radius-l); padding:12px 16px; box-shadow:var(--shadow-3);
}
.batch-count{ font-size:13px; font-weight:700; color:var(--accent); white-space:nowrap; }
.batch-select{
  background:var(--bg-card); border:1.5px solid var(--line); color:var(--ink);
  border-radius:var(--radius-s); padding:9px 12px; font-size:12.5px; outline:none;
}
.batch-bar-inner .btn{ width:auto; padding:9px 15px; font-size:12.5px; }
#selectionToggleBtn.active{ background:rgba(139,111,176,0.16); border-color:#8B6FB0; color:#8B6FB0; }
#seriesGroupToggleBtn.active{ background:var(--accent-soft); border-color:var(--accent); color:var(--accent); }

@media (max-width:860px){
  .batch-bar{ bottom:calc(78px + env(safe-area-inset-bottom)); }
  .batch-bar-inner{ width:100%; }
}

/* ---- منطقة رفع صورة الغلاف (سحب وإفلات) ---- */
.cover-dropzone{
  position:relative; width:190px; max-width:100%; aspect-ratio:2/3; min-height:270px;
  border:2px dashed var(--line-strong); border-radius:var(--radius-m);
  cursor:pointer; overflow:hidden; background:var(--bg-card);
  transition:border-color .2s ease, background .2s ease, transform .2s var(--ease-out);
}
.cover-dropzone:hover{ border-color:var(--accent); background:var(--bg-card-hi); }
.cover-dropzone.dragover{ border-color:var(--accent); background:var(--accent-soft); transform:scale(1.03); box-shadow:var(--shadow-2); }
.cdz-state{ position:absolute; inset:0; }
.cdz-empty, .cdz-progress{
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  text-align:center; padding:16px; gap:9px;
}
.cdz-icon{ width:32px; height:32px; opacity:.75; transition:transform .2s ease; }
.cover-dropzone:hover .cdz-icon{ transform:translateY(-3px); }
.cdz-title{ font-size:12.5px; font-weight:700; color:var(--ink); line-height:1.4; }
.cdz-sub{ font-size:10.5px; color:var(--ink-dim); line-height:1.6; }
.cdz-progress .icon{ width:26px; height:26px; }
.cdz-filled img{ width:100%; height:100%; object-fit:cover; display:block; }
.cdz-actions{
  position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px;
  background:rgba(8,10,20,0.74); backdrop-filter:blur(2px);
  opacity:0; transition:opacity .2s ease; padding:14px;
}
.cover-dropzone:hover .cdz-actions, .cover-dropzone:focus-within .cdz-actions, .cover-dropzone:focus-visible .cdz-actions{ opacity:1; }
.cdz-actions .btn{ width:auto; padding:8px 16px; font-size:12px; }

.scan-box{
  border:2px dashed var(--line-strong); border-radius:var(--radius-m); padding:32px; text-align:center;
  color:var(--ink-dim); margin-bottom:16px; transition:border-color .2s ease;
}
#scanVideo{ width:100%; max-width:420px; border-radius:var(--radius-s); display:none; margin:0 auto 14px; box-shadow:var(--shadow-2); }
.scan-result{ font-size:13.5px; margin-top:12px; display:flex; align-items:center; justify-content:center; gap:6px; flex-wrap:wrap; }
.scan-pulse{ animation:scanPulse 1.1s ease-in-out infinite; border-color:var(--accent); }

/* =========================================================
   الإعدادات
   ========================================================= */
.settings-tabs{ display:flex; gap:4px; border-bottom:1px solid var(--line); margin-bottom:26px; flex-wrap:wrap; }
.settings-tab-btn{
  padding:11px 17px; background:none; border:none; color:var(--ink-dim); font-size:13.5px; font-weight:600;
  cursor:pointer; border-bottom:2.5px solid transparent; margin-bottom:-1px; transition:color .18s ease, border-color .18s ease;
}
.settings-tab-btn:hover{ color:var(--ink); }
.settings-tab-btn.active{ color:var(--accent); border-bottom-color:var(--accent); }
.settings-panel{ display:none; }
.settings-panel.active{ display:block; animation:pageIn .3s var(--ease-spring) both; }
.settings-hint{ color:var(--ink-dim); font-size:12.5px; margin:-8px 0 14px; max-width:560px; line-height:1.7; }
.section-title-sub{ font-family:var(--font-body); font-size:11.5px; font-weight:600; color:var(--ink-dim); margin-inline-start:6px; }

.segmented{ display:inline-flex; background:var(--bg-card); border:1px solid var(--line); border-radius:var(--radius-s); padding:4px; gap:4px; margin-bottom:8px; }
.segmented-btn{
  background:none; border:none; color:var(--ink-dim); font-size:13px; font-weight:600; cursor:pointer;
  padding:8px 18px; border-radius:8px; transition:all .18s ease;
}
.segmented-btn:hover{ color:var(--ink); }
.segmented-btn.active{ background:linear-gradient(155deg, var(--accent-2), var(--accent)); color:var(--accent-ink); box-shadow:var(--shadow-1); }

/* ---- الفحص الشامل ---- */
.diag-panel{}
.diag-summary{
  display:flex; gap:16px; flex-wrap:wrap; margin:16px 0; padding:14px 16px;
  background:var(--bg-card); border-radius:var(--radius-s); border:1px solid var(--line);
}
.diag-summary .ds-item{ display:flex; align-items:center; gap:7px; font-size:13px; font-weight:600; }
.diag-summary .ds-dot{ width:9px; height:9px; border-radius:50%; }
.diag-results{ display:flex; flex-direction:column; gap:8px; margin-top:10px; }
.diag-row{
  display:flex; align-items:flex-start; gap:11px; padding:12px 14px;
  background:var(--bg-card); border:1px solid var(--line); border-radius:var(--radius-s);
  animation:cardIn .35s ease both;
}
.diag-row .dr-icon{ width:19px; height:19px; flex-shrink:0; margin-top:1px; }
.diag-row .dr-title{ font-size:13.5px; font-weight:700; }
.diag-row .dr-detail{ font-size:12px; color:var(--ink-dim); margin-top:3px; line-height:1.6; }
.diag-row.status-ok{ border-inline-start:3px solid var(--success); }
.diag-row.status-warn{ border-inline-start:3px solid #E9B94F; }
.diag-row.status-err{ border-inline-start:3px solid var(--danger); }
.diag-row.status-info{ border-inline-start:3px solid var(--info); }
.diag-row.status-pending .dr-icon{ animation:spin .8s linear infinite; }

/* ---- توحيد عرض محتوى تبويبات الإعدادات لاتساق بصري كامل ---- */
.settings-panel{ max-width:680px; }
.settings-actions-row{ display:flex; gap:10px; flex-wrap:wrap; }
.danger-zone{ border-color:rgba(211,112,90,0.35); }

/* ---- حول التطبيق ---- */
.about-hero{ text-align:center; padding:8px 0 28px; }
.about-logo{ width:80px; height:80px; border-radius:22px; box-shadow:var(--shadow-2); margin-bottom:16px; animation:avatarBreathe 4s ease-in-out infinite; }
.about-name{ font-family:var(--font-display); font-size:25px; font-weight:700; }
.about-tagline{ color:var(--accent); font-size:13px; font-weight:600; margin-top:5px; }
.about-philosophy{ line-height:2; font-size:14px; color:var(--ink); }
.about-philosophy p{ margin-bottom:14px; }
.about-philosophy p:last-child{ margin-bottom:0; }

.theme-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(152px,1fr)); gap:14px; }
.theme-swatch{
  border:2px solid var(--line); border-radius:var(--radius-m); padding:15px; cursor:pointer; text-align:center;
  transition:transform .2s var(--ease-out), border-color .2s ease, box-shadow .2s ease;
}
.theme-swatch:hover{ transform:translateY(-3px); box-shadow:var(--shadow-1); }
.theme-swatch.active{ border-color:var(--accent); animation:chipPop .3s ease; box-shadow:var(--shadow-2); }
.theme-dots{ display:flex; justify-content:center; gap:6px; margin-bottom:11px; }
.theme-dots span{ width:18px; height:18px; border-radius:50%; display:inline-block; box-shadow:var(--shadow-1); }
.theme-swatch .tname{ font-size:13px; font-weight:600; }

.category-manage-list{ display:flex; flex-direction:column; gap:8px; }
.category-row{
  display:flex; align-items:center; gap:10px; padding:10px 13px;
  border:1px solid var(--line); border-radius:var(--radius-s);
  transition:border-color .18s ease;
}
.category-row:hover{ border-color:var(--line-strong); }
.category-row .cat-dot{ width:11px; height:11px; }
.category-row .name{ flex:1; font-size:13.5px; font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.category-row .name input{
  width:100%; background:var(--bg-card); border:1.5px solid var(--accent); color:var(--ink);
  border-radius:8px; padding:6px 10px; font-size:13.5px;
}
.category-row .count{ font-size:11.5px; color:var(--ink-dim); }
.row-btn{
  background:none; border:none; cursor:pointer; padding:6px; border-radius:8px;
  display:flex; align-items:center; justify-content:center; transition:background .15s ease;
}
.row-btn:hover{ background:var(--bg-card); }
.row-btn .icon{ width:16px; height:16px; }

.health-card{ border:1px solid var(--line); border-radius:var(--radius-m); padding:20px; margin-bottom:14px; }
.health-row{ display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:5px 14px; padding:9.5px 0; border-bottom:1px solid var(--line); font-size:13.5px; }
.health-row span{ flex-shrink:0; }
.health-row strong{ text-align:end; display:flex; align-items:center; }
.health-row strong .icon{ width:15px; height:15px; margin-inline-end:5px; }
.health-row:last-child{ border-bottom:none; }
.health-ok{ color:var(--success); font-weight:700; }
.health-warn{ color:var(--danger); font-weight:700; }
.read-log-list{ margin-top:8px; max-height:130px; overflow-y:auto; font-size:12.5px; color:var(--ink-dim); }
.read-log-list div{ padding:5px 0; border-bottom:1px solid var(--line); display:flex; align-items:center; gap:5px; }

/* =========================================================
   مودالات
   ========================================================= */
.modal-overlay{
  position:fixed; inset:0; background:rgba(6,8,16,0.62); backdrop-filter:blur(4px);
  display:flex; align-items:center; justify-content:center; padding:20px; z-index:1000;
  animation:overlayIn .2s ease both;
}
.modal-box{
  border:1px solid var(--line-strong); border-radius:var(--radius-xl);
  max-width:490px; width:100%; padding:28px; max-height:85vh; overflow-y:auto;
  box-shadow:var(--shadow-3); animation:modalIn .32s var(--ease-spring) both;
}
.modal-box h3{ font-family:var(--font-display); margin-bottom:14px; font-size:19px; }
.modal-actions{ display:flex; gap:9px; margin-top:20px; flex-wrap:wrap; }
.modal-actions .btn{ width:auto; }
.modal-cover{ width:100%; max-width:155px; aspect-ratio:2/3; object-fit:cover; border-radius:var(--radius-s); margin-bottom:16px; background:var(--bg-card); box-shadow:var(--shadow-2); }

/* =========================================================
   توست
   ========================================================= */
.toast{
  position:fixed; bottom:24px; left:50%; transform:translateX(-50%);
  border:1px solid var(--accent); color:var(--ink);
  padding:12px 22px; border-radius:var(--radius-s); box-shadow:var(--shadow-3);
  font-size:13.5px; z-index:999; opacity:0; pointer-events:none;
  transition:opacity .28s ease, transform .28s var(--ease-spring);
  display:flex; align-items:center; gap:9px; backdrop-filter:blur(12px);
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(-6px); }
.toast .icon{ width:18px; height:18px; }
@media (max-width:860px){ .toast{ bottom:calc(96px + env(safe-area-inset-bottom)); } }

/* =========================================================
   نظام الأيقونات
   ========================================================= */
.icon, .ic{ display:inline-flex; align-items:center; justify-content:center; width:1.15em; height:1.15em; vertical-align:-0.22em; flex-shrink:0; }
.icon svg, .ic svg{ width:100%; height:100%; display:block; }
.icon-spin{ animation:spin .8s linear infinite; }

/* =========================================================
   حركات وانتقالات
   ========================================================= */
@keyframes splashPop{ from{ transform:scale(.4) rotate(-8deg); opacity:0; } to{ transform:scale(1) rotate(0); opacity:1; } }
@keyframes splashFloat{ 0%,100%{ transform:translateY(0); } 50%{ transform:translateY(-6px); } }
@keyframes splashFade{ to{ opacity:1; } }
@keyframes splashLoad{ 0%{ transform:translateX(-120%); } 100%{ transform:translateX(340%); } }
@keyframes shimmerText{ to{ background-position:-200% center; } }
@keyframes authIn{ from{ opacity:0; transform:translateY(20px) scale(.97); } to{ opacity:1; transform:translateY(0) scale(1); } }
@keyframes fieldIn{ from{ opacity:0; transform:translateY(8px); } to{ opacity:1; transform:translateY(0); } }
@keyframes pageIn{ from{ opacity:0; transform:translateY(10px); } to{ opacity:1; transform:translateY(0); } }
@keyframes sidebarIn{ from{ opacity:0; transform:translateX(16px); } to{ opacity:1; transform:translateX(0); } }
@keyframes cardIn{ from{ opacity:0; transform:translateY(12px); } to{ opacity:1; transform:translateY(0); } }
@keyframes bookIn{ from{ opacity:0; transform:translateY(14px) scale(.97); } to{ opacity:1; transform:translateY(0) scale(1); } }
@keyframes chipPop{ 0%{ transform:scale(.9); } 60%{ transform:scale(1.05); } 100%{ transform:scale(1); } }
@keyframes overlayIn{ from{ opacity:0; } to{ opacity:1; } }
@keyframes modalIn{ from{ opacity:0; transform:translateY(18px) scale(.95); } to{ opacity:1; transform:translateY(0) scale(1); } }
@keyframes sheetIn{ from{ opacity:0; transform:translateY(60px); } to{ opacity:1; transform:translateY(0); } }
@keyframes scanPulse{ 0%,100%{ box-shadow:0 0 0 0 var(--accent-soft); } 50%{ box-shadow:0 0 0 12px transparent; } }
@keyframes spin{ to{ transform:rotate(360deg); } }
@keyframes shake{ 0%,100%{ transform:translateX(0); } 20%{ transform:translateX(-6px); } 40%{ transform:translateX(6px); } 60%{ transform:translateX(-4px); } 80%{ transform:translateX(4px); } }

/* =========================================================
   قالب PDF (يُرسم بعيدًا عن الشاشة ثم يُلتقط بـ html2canvas)
   ألوان ثابتة مستقلة عن ثيم التطبيق لضمان طباعة نظيفة دائمًا
   ========================================================= */
.pdf-template{
  position:fixed; top:0; inset-inline-start:-99999px; width:1100px;
  background:#FBF7EC; color:#2C2416; font-family:var(--font-body);
  padding:40px 46px; direction:rtl;
}
.pdf-header{ display:flex; align-items:center; justify-content:space-between; border-bottom:3px solid #C89B3C; padding-bottom:18px; margin-bottom:22px; }
.pdf-brand{ display:flex; align-items:center; gap:14px; }
.pdf-brand img{ width:52px; height:52px; border-radius:14px; }
.pdf-brand-text .t{ font-size:24px; font-weight:700; }
.pdf-brand-text .s{ font-size:12.5px; color:#7A6E58; }
.pdf-meta{ text-align:left; font-size:12px; color:#5C5140; line-height:1.9; }
.pdf-meta b{ color:#2C2416; }
.pdf-table{ width:100%; border-collapse:collapse; font-size:12.5px; }
.pdf-table th{ background:#C89B3C; color:#FBF7EC; padding:10px 8px; text-align:right; font-weight:700; }
.pdf-table td{ padding:9px 8px; border-bottom:1px solid #E5D9BE; }
.pdf-table tr:nth-child(even) td{ background:#F3ECDC; }
.pdf-footer{ margin-top:18px; font-size:11px; color:#9C8F72; display:flex; justify-content:space-between; }
.pdf-table .icon{ width:13px; height:13px; margin-inline-end:1px; }

/* =========================================================
   استجابة عامة
   ========================================================= */
@media (max-width:860px){
  .form-grid{ grid-template-columns:1fr; }
  .dash-grid{ grid-template-columns:1fr; }
  .greeting-card{ padding:22px 20px; }
  .stat-grid{ grid-template-columns:repeat(2,1fr); }
}

@media (prefers-reduced-motion:reduce){
  *{ animation:none !important; transition:none !important; }
}

/* ---- تفضيلات المستخدم: كثافة العرض والحركة ---- */
.motion-reduced *{ animation:none !important; transition:none !important; }

[data-density="compact"] .book-grid{ gap:11px; }
[data-density="compact"] .book-card .book-info{ padding:9px 10px 10px; }
[data-density="compact"] .book-title{ font-size:12.5px; margin-bottom:2px; }
[data-density="compact"] .book-author{ font-size:11px; margin-bottom:5px; }
[data-density="compact"] .stat-card{ padding:13px 15px; }
[data-density="compact"] .stat-card .n{ font-size:23px; }
[data-density="compact"] .card-panel{ padding:17px; }
[data-density="compact"] .health-row, [data-density="compact"] .category-row, [data-density="compact"] .loan-row{ padding:7px 0; }
[data-density="compact"] .greeting-card{ padding:18px 20px; }
