/* ============================================================
   کتابخانهٔ مدرسه — استایل صفحهٔ کتابخانه (lb-*)
   همهٔ رنگ‌ها از توکن‌های app.css می‌آیند تا حالت شب بدون
   بازنویسی سنگین درست بماند. ساختار با extraclass.css هم‌خوان است.
   ============================================================ */

.lb-page { display: flex; flex-direction: column; gap: 14px; }

/* دکمهٔ بسیار ریز (در app.css وجود نداشت) */
.btn.xs {
  padding: 3px 8px; font-size: var(--fs-2xs); font-weight: 700;
  border-radius: var(--radius-xs); gap: 4px; line-height: 1.7;
}

/* ---------- اسکلت بارگذاری ---------- */
.lb-skel {
  position: relative; overflow: hidden; border-radius: var(--radius-lg);
  background: var(--surface-2); border: 1px solid var(--line);
}
.lb-skel::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent,
    color-mix(in srgb, var(--paper) 70%, transparent), transparent);
  transform: translateX(-100%); animation: lbShimmer 1.2s infinite;
}
@keyframes lbShimmer { to { transform: translateX(100%); } }
.lb-skel-hero { height: 132px; }
.lb-skel-kpi { height: 70px; }
.lb-skel-tabs { height: 50px; }
.lb-skel-list { height: 280px; }
.lb-skel-card { height: 190px; }

/* ---------- سربرگ ---------- */
.lb-hero {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; padding: 20px 22px;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(620px 240px at 88% -60%, rgba(251, 191, 36, .30), transparent 70%),
    radial-gradient(520px 260px at 4% 150%, rgba(56, 189, 248, .20), transparent 70%),
    var(--grad-brand);
  color: #fff; box-shadow: var(--shadow-md);
}
.lb-hero::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, .13) 1px, transparent 1px);
  background-size: 22px 22px; opacity: .45;
}
.lb-hero-main {
  display: flex; align-items: flex-start; gap: 14px; min-width: 0;
  flex: 1 1 420px; /* فضا را پر کند تا دکمه‌ها در همان ردیف کنار عنوان بمانند */
  position: relative; z-index: 1;
}
.lb-hero-ic {
  width: 54px; height: 54px; flex: 0 0 auto; display: grid; place-items: center;
  border-radius: 17px; background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .24);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22);
}
.lb-hero-txt { min-width: 0; }
.lb-hero-title { margin: 0 0 5px; font-size: var(--fs-xl); font-weight: 800; letter-spacing: -.2px; }
.lb-hero-sub {
  margin: 0; font-size: var(--fs-sm); color: rgba(255, 255, 255, .88);
  max-width: 780px; line-height: 1.9;
}
.lb-hero-meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.lb-live {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: var(--radius-full);
  background: rgba(0, 0, 0, .18);
  border: 1px solid rgba(255, 255, 255, .2);
  font-size: var(--fs-xs); font-weight: 700; color: #eafff7;
}
.lb-live.is-warn { background: rgba(0, 0, 0, .32); border-color: rgba(254, 202, 202, .55); color: #ffe4e6; }
.lb-hero-actions { display: flex; gap: 7px; flex-wrap: wrap; position: relative; z-index: 1; }
.lb-hero-actions .btn {
  background: rgba(255, 255, 255, .10); border-color: rgba(255, 255, 255, .28);
  color: #fff; backdrop-filter: blur(4px);
}
.lb-hero-actions .btn:hover { background: rgba(255, 255, 255, .2); border-color: rgba(255, 255, 255, .46); }
.lb-hero-actions .btn.accent {
  background: var(--gold); border-color: var(--gold); color: #17252d; font-weight: 800;
}
.lb-hero-actions .btn.accent:hover { background: #fbbf24; }

/* ---------- شاخص‌ها ---------- */
.lb-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.lb-kpi {
  position: relative; overflow: hidden; text-align: right;
  display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto;
  gap: 0 9px; align-items: center;
  padding: 11px 13px; cursor: pointer; font-family: inherit;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}
.lb-kpi::before {
  content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px;
  background: var(--line); border-radius: 0 4px 4px 0;
}
.lb-kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--side-2); }
.lb-kpi:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.lb-kpi-ic { grid-row: 1 / 3; display: grid; place-items: center; color: var(--side-2); }
.lb-kpi b {
  font-size: var(--fs-2xl); line-height: 1.05; font-weight: 800;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
.lb-kpi-l { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.lb-kpi.tone-info::before { background: var(--info); }
.lb-kpi.tone-info b { color: var(--info); }
.lb-kpi.tone-good::before { background: var(--good); }
.lb-kpi.tone-good b { color: var(--good); }
.lb-kpi.tone-warn::before { background: var(--warn); }
.lb-kpi.tone-warn b { color: var(--warn); }
.lb-kpi.tone-bad::before { background: var(--bad); }
.lb-kpi.tone-bad b { color: var(--bad); }

/* ---------- تب‌ها ---------- */
.lb-tabs {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: stretch; padding: 4px;
  background: color-mix(in srgb, var(--paper) 65%, transparent);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
}
.lb-tab {
  flex: 1 1 150px; min-width: 128px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 12px; font-size: var(--fs-sm); font-weight: 700;
  border-radius: var(--radius-md); border: 1px solid transparent;
  background: transparent; color: var(--ink); font-family: inherit; cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast), box-shadow var(--dur-fast);
}
.lb-tab:hover { background: var(--paper); border-color: var(--line); }
.lb-tab.active { background: var(--grad-brand); color: #fff; box-shadow: 0 4px 14px rgba(13, 59, 52, .28); }
.lb-tab-n {
  min-width: 21px; padding: 1px 7px; border-radius: var(--radius-full);
  font-size: var(--fs-2xs); font-weight: 800;
  background: color-mix(in srgb, currentColor 14%, transparent);
}
.lb-tab.active .lb-tab-n { background: rgba(255, 255, 255, .22); }

/* ---------- پنل و کارت ---------- */
.lb-panel { display: flex; flex-direction: column; gap: 12px; }
.lb-panel.lb-in { animation: lbPanelIn var(--dur-base) var(--ease-out) both; }
@keyframes lbPanelIn { from { opacity: 0; transform: translateY(5px); } }
.lb-card {
  padding: 18px; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
}
.lb-list-card { padding: 14px 16px; }
.lb-card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.lb-card-head h3 { margin: 0; font-size: var(--fs-lg); font-weight: 800; display: inline-flex; align-items: center; gap: 7px; }
.lb-card-sub { margin: 3px 0 0; font-size: var(--fs-xs); color: var(--muted); line-height: 1.75; }
.lb-head-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- نوار ابزار ---------- */
.lb-toolbar { display: flex; flex-wrap: wrap; gap: 9px; align-items: flex-end; }
.lb-toolbar .field { margin: 0; min-width: 0; flex: 1 1 150px; }
.lb-toolbar .field label { font-size: var(--fs-2xs); font-weight: 700; color: var(--muted); }
.lb-search { position: relative; flex: 2 1 260px; }
.lb-search input { padding-inline-start: 34px; padding-inline-end: 30px; }
.lb-search-ic {
  position: absolute; inset-inline-start: 10px; bottom: 11px; color: var(--muted);
  pointer-events: none; display: grid; place-items: center;
}
.lb-search-clear {
  position: absolute; inset-inline-end: 6px; bottom: 6px;
  width: 26px; height: 26px; border: 0; border-radius: 50%;
  background: var(--surface-2); color: var(--muted); cursor: pointer;
  display: none; place-items: center; font-family: inherit;
}
.lb-search.has-value .lb-search-clear { display: grid; }
.lb-search-clear:hover { color: var(--bad); }
.lb-f-select { flex: 0 1 150px; }
/* در نوار ابزار، جستجو پهن‌تر از فیلترها بماند (specificity بالاتر از .lb-toolbar .field) */
.lb-toolbar .field.lb-search { flex: 2 1 260px; }
.lb-toolbar .field.lb-f-select { flex: 0 1 150px; }

.lb-viewtoggle {
  display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--paper);
}
.lb-viewtoggle button {
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-family: inherit; transition: background var(--dur-fast), color var(--dur-fast);
}
.lb-viewtoggle button:hover { background: var(--surface-2); color: var(--ink); }
.lb-viewtoggle button.on { background: var(--grad-brand); color: #fff; }

/* ---------- چیپ‌ها ---------- */
.lb-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.lb-chip {
  cursor: pointer; font-family: inherit; font-size: var(--fs-xs); font-weight: 700;
  padding: 5px 11px; border-radius: var(--radius-full);
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
}
.lb-chip:hover { border-color: var(--accent-2); color: var(--accent-2); }
.lb-chip.active { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.lb-chip-n { margin-inline-start: 5px; opacity: .8; font-weight: 600; }

/* ---------- نوار نتیجه و انتخاب ---------- */
.lb-resultbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 10px; padding: 7px 4px 0; font-size: var(--fs-xs); color: var(--muted);
}
.lb-count { font-weight: 700; color: var(--ink); }
.lb-selcount {
  display: inline-flex; align-items: center; gap: 4px; font-weight: 700;
  color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 10%, transparent);
  padding: 2px 8px; border-radius: var(--radius-full);
}
.lb-spacer { flex: 1 1 auto; }
.lb-checkall { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; font-weight: 600; }
.lb-checkall input { width: 15px; height: 15px; accent-color: var(--accent-2); }

/* ---------- فهرست کتاب‌ها: نمای کارت ---------- */
.lb-books { margin-top: 10px; }
.lb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 12px; }
.lb-book {
  position: relative; display: flex; flex-direction: column; gap: 0;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs); cursor: pointer; overflow: hidden;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}
.lb-book:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent-2); }
.lb-book:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.lb-book.is-picked { border-color: var(--accent-2); box-shadow: 0 0 0 2px var(--ring), var(--shadow-xs); }
.lb-pick {
  position: absolute; top: 8px; inset-inline-start: 8px; z-index: 2;
  width: 24px; height: 24px; display: grid; place-items: center;
  border-radius: 7px; background: rgba(255, 255, 255, .82);
  border: 1px solid rgba(23, 37, 45, .14); box-shadow: var(--shadow-xs);
  cursor: pointer; backdrop-filter: blur(3px);
}
.lb-pick input { width: 14px; height: 14px; margin: 0; accent-color: var(--accent-2); cursor: pointer; }

/* جلد رنگی — رنگ‌ها از کلاس lb-c0..7 روی خود جلد یا والدش می‌آیند */
.lb-cover {
  position: relative; display: grid; place-items: center; flex: 0 0 auto;
  width: 100%; height: 94px; overflow: hidden;
  background: linear-gradient(135deg, var(--lb-g1, #0d3b34), var(--lb-g2, #047857));
  color: #fff;
}
.lb-cover::after {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .16) 1px, transparent 1px);
  background-size: 16px 16px; opacity: .5; pointer-events: none;
}
.lb-cover-t { font-size: 40px; font-weight: 800; line-height: 1; text-shadow: 0 2px 10px rgba(0, 0, 0, .28); }
.lb-cover-ic { position: absolute; bottom: 8px; inset-inline-end: 9px; opacity: .5; }
.lb-cover.is-big { width: 84px; height: 108px; border-radius: var(--radius-md); flex: 0 0 auto; }
.lb-cover.is-big .lb-cover-t { font-size: 34px; }
.lb-cover.is-tiny { width: 38px; height: 38px; border-radius: 10px; flex: 0 0 auto; }
.lb-cover.is-tiny .lb-cover-t { font-size: 18px; }
.lb-cover.is-tiny .lb-cover-ic { display: none; }

.lb-c0 { --lb-g1: #0d3b34; --lb-g2: #047857; }
.lb-c1 { --lb-g1: #1e3a8a; --lb-g2: #2563eb; }
.lb-c2 { --lb-g1: #7c2d12; --lb-g2: #d97706; }
.lb-c3 { --lb-g1: #4c1d95; --lb-g2: #7c3aed; }
.lb-c4 { --lb-g1: #134e4a; --lb-g2: #0d9488; }
.lb-c5 { --lb-g1: #831843; --lb-g2: #db2777; }
.lb-c6 { --lb-g1: #3f3f46; --lb-g2: #71717a; }
.lb-c7 { --lb-g1: #78350f; --lb-g2: #b45309; }

.lb-book-main { display: flex; flex-direction: column; gap: 8px; padding: 11px 12px 12px; flex: 1; }
.lb-book-top { display: flex; flex-direction: column; gap: 6px; }
.lb-book-title {
  margin: 0; font-size: var(--fs-md); font-weight: 800; line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.lb-tags { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.lb-tag {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: var(--radius-full);
  font-size: var(--fs-2xs); font-weight: 700;
  background: color-mix(in srgb, var(--accent-2) 10%, transparent);
  color: var(--accent-2); border: 1px solid color-mix(in srgb, var(--accent-2) 20%, transparent);
}
.lb-tag.is-soft {
  background: var(--surface-2); color: var(--muted);
  border-color: var(--line);
}
.lb-book-sub {
  margin: 0; font-size: var(--fs-xs); color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lb-meter { height: 5px; border-radius: var(--radius-full); background: var(--surface-2); overflow: hidden; }
.lb-meter span { display: block; height: 100%; border-radius: inherit; background: var(--grad-good); transition: width var(--dur) var(--ease); }
.lb-book-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: auto; }
.lb-barcode {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--fs-2xs);
  color: var(--muted); background: var(--surface-2); border: 1px solid var(--line);
  padding: 2px 7px; border-radius: 6px; cursor: pointer; font-family: ui-monospace, monospace;
  max-width: 52%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: color var(--dur-fast), border-color var(--dur-fast);
}
.lb-barcode:hover { color: var(--accent-2); border-color: var(--accent-2); }
.lb-book-acts { display: flex; gap: 5px; flex-wrap: wrap; }
.lb-book-acts .btn { flex: 1 1 auto; }

/* ---------- فهرست کتاب‌ها: نمای جدول ---------- */
.lb-tablewrap { overflow-x: auto; border-radius: var(--radius-md); }
.lb-table { width: 100%; }
.lb-table tbody tr { cursor: pointer; transition: background var(--dur-fast); }
.lb-table tbody tr:hover { background: var(--surface-2); }
.lb-table tbody tr.is-picked { background: color-mix(in srgb, var(--accent-2) 7%, transparent); }
.lb-table tbody tr.is-late { background: color-mix(in srgb, var(--bad) 6%, transparent); }
.lb-table tbody tr.is-late:hover { background: color-mix(in srgb, var(--bad) 10%, transparent); }
.lb-th-pick { width: 38px; text-align: center; }
.lb-th-pick input { width: 15px; height: 15px; accent-color: var(--accent-2); cursor: pointer; }
.lb-table td small { display: block; font-size: var(--fs-2xs); }
.lb-row-acts { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.lb-link {
  background: none; border: 0; padding: 0; font-family: inherit; cursor: pointer;
  color: var(--ink); font-weight: 700; font-size: inherit; text-align: right;
}
.lb-link:hover { color: var(--accent-2); text-decoration: underline; }
.lb-phone {
  display: inline-flex; align-items: center; gap: 3px; margin-top: 2px;
  font-size: var(--fs-2xs); color: var(--info); text-decoration: none; font-weight: 600;
}
.lb-phone:hover { text-decoration: underline; }

/* ---------- جزئیات کتاب (مودال) ---------- */
.lb-modal-wide { width: min(880px, 96vw) !important; }
.lb-detail-head {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px; border-radius: var(--radius-lg); margin-bottom: 14px;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--lb-g1, #0d3b34) 12%, var(--paper)),
    color-mix(in srgb, var(--lb-g2, #047857) 12%, var(--paper)));
  border: 1px solid var(--line);
}
.lb-detail-title { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 5px; }
.lb-detail-title h4 { margin: 0; font-size: var(--fs-lg); font-weight: 800; line-height: 1.5; }
.lb-detail-title p { margin: 0; font-size: var(--fs-xs); color: var(--muted); }
.lb-detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.lb-dcell {
  display: flex; flex-direction: column; gap: 3px; padding: 8px 10px;
  border-radius: var(--radius-md); background: var(--surface-2); border: 1px solid var(--line);
  min-width: 0;
}
.lb-dcell span { font-size: var(--fs-2xs); color: var(--muted); font-weight: 600; }
.lb-dcell b { font-size: var(--fs-sm); font-weight: 700; word-break: break-word; }
.lb-dcell .lb-barcode { align-self: flex-start; max-width: 100%; }
.lb-subhead {
  display: flex; align-items: center; gap: 6px; margin: 16px 0 8px;
  font-size: var(--fs-sm); font-weight: 800; color: var(--ink);
}
.lb-mini-list { display: flex; flex-direction: column; gap: 6px; }
.lb-mini-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius-md);
  background: var(--surface-2); border: 1px solid var(--line); flex-wrap: wrap;
}
.lb-mini-row b { font-size: var(--fs-sm); font-weight: 700; }
.lb-mini-row small { display: block; font-size: var(--fs-2xs); color: var(--muted); margin-top: 2px; }
.lb-mini-acts { display: flex; gap: 4px; flex-wrap: wrap; }
.lb-muted-line { margin: 6px 0; font-size: var(--fs-xs); color: var(--muted); line-height: 1.8; }
.lb-history { margin-top: 12px; }
.lb-history summary {
  cursor: pointer; font-size: var(--fs-xs); font-weight: 700; color: var(--accent-2);
  padding: 6px 0; user-select: none;
}
.lb-history[open] summary { margin-bottom: 6px; }
.lb-modal-actions {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line);
}
.lb-modal-actions .lb-spacer { flex: 1 1 auto; }

/* ---------- فرم‌ها ---------- */
.lb-form-row { display: flex; gap: 9px; flex-wrap: wrap; }
.lb-form-row .field { flex: 1 1 150px; min-width: 0; }
.lb-check-line {
  display: inline-flex; align-items: center; gap: 7px; margin: 8px 0;
  font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
}
.lb-check-line input { width: 16px; height: 16px; accent-color: var(--bad); cursor: pointer; }

/* ---------- برچسب بارکد ---------- */
.lb-label-list { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow: auto; }
.lb-label-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-md);
  background: var(--surface-2); border: 1px solid var(--line);
}
.lb-label-book { display: flex; align-items: center; gap: 9px; min-width: 0; }
.lb-label-book b { display: block; font-size: var(--fs-sm); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-label-book small { font-size: var(--fs-2xs); color: var(--muted); }
.lb-label-count { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.lb-label-count label { font-size: var(--fs-2xs); color: var(--muted); font-weight: 600; }
.lb-label-count input { width: 64px; }
.lb-label-preview {
  display: grid; place-items: center; padding: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-md);
  min-height: 90px;
}
.lb-label-preview .label {
  width: 62mm; box-sizing: border-box; border: 1px dashed #9aa; border-radius: 2mm;
  padding: 2mm; text-align: center; overflow: hidden; background: #fff; color: #000;
  transform: scale(.82); transform-origin: center;
}
.lb-label-preview .label svg { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.lb-label-preview .lt { font-size: 9px; font-weight: 700; margin-top: 1mm; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-label-preview .lm { font-size: 7px; color: #556; margin-top: .5mm; }

/* ---------- امانت‌ها: هشدارها ---------- */
.lb-alert {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; border-radius: var(--radius-md); margin-bottom: 8px;
  border: 1px solid var(--line); background: var(--surface-2);
}
.lb-alert > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 220px; }
.lb-alert b { font-size: var(--fs-sm); font-weight: 800; }
.lb-alert span { font-size: var(--fs-2xs); color: var(--muted); line-height: 1.7; }
.lb-alert.is-bad {
  background: color-mix(in srgb, var(--bad) 7%, var(--paper));
  border-color: color-mix(in srgb, var(--bad) 30%, var(--line));
}
.lb-alert.is-bad b, .lb-alert.is-bad > svg { color: var(--bad); }
.lb-alert.is-warn {
  background: color-mix(in srgb, var(--warn) 8%, var(--paper));
  border-color: color-mix(in srgb, var(--warn) 30%, var(--line));
}
.lb-alert.is-warn b, .lb-alert.is-warn > svg { color: var(--warn); }
.lb-alert.is-good {
  background: color-mix(in srgb, var(--good) 7%, var(--paper));
  border-color: color-mix(in srgb, var(--good) 26%, var(--line));
}
.lb-alert.is-good b, .lb-alert.is-good > svg { color: var(--good); }

/* ---------- انتخاب کتاب برای امانت ---------- */
.lb-picklist {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 48vh; overflow: auto; margin-top: 10px;
}
.lb-pick-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: var(--radius-md); cursor: pointer;
  background: var(--paper); border: 1px solid var(--line); font-family: inherit;
  text-align: right; transition: background var(--dur-fast), border-color var(--dur-fast);
}
.lb-pick-row:hover { background: var(--surface-2); border-color: var(--accent-2); }
.lb-pick-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.lb-pick-txt b { font-size: var(--fs-sm); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-pick-txt small { font-size: var(--fs-2xs); color: var(--muted); }

/* ---------- کارت کتاب در مودال امانت/برگشت ---------- */
.lb-lend-book {
  display: flex; align-items: center; gap: 11px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 12px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-md);
}
.lb-lend-book > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1 1 180px; }
.lb-lend-book b { font-size: var(--fs-sm); font-weight: 800; }
.lb-lend-book small { font-size: var(--fs-2xs); color: var(--muted); }

/* ---------- تمدید سریع ---------- */
.lb-quickdue { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 12px; }

/* ---------- پیامک ---------- */
.lb-sms-vars { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.lb-sms-preview {
  padding: 10px 12px; border-radius: var(--radius-md);
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: var(--fs-xs); line-height: 1.9; max-height: 170px; overflow: auto;
}
.lb-sms-preview p { margin: 0 0 6px; }
.lb-sms-preview p:last-child { margin-bottom: 0; }

/* ---------- اسکن سریع ---------- */
.lb-scan-layout { display: grid; grid-template-columns: 1.05fr .95fr; gap: 12px; align-items: start; }
.lb-scan-layout > .lb-card:last-child { grid-column: 1 / -1; }
.lb-scan-card { display: flex; flex-direction: column; gap: 10px; }
.lb-seg {
  display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface-2);
}
.lb-seg-btn {
  display: inline-flex; align-items: center; gap: 5px; padding: 7px 11px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-family: inherit; font-size: var(--fs-xs); font-weight: 700;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.lb-seg-btn + .lb-seg-btn { border-inline-start: 1px solid var(--line); }
.lb-seg-btn:hover { background: var(--paper); color: var(--ink); }
.lb-seg-btn.active { background: var(--grad-brand); color: #fff; }
.lb-scan-inputwrap { position: relative; display: flex; gap: 8px; align-items: center; }
.lb-scan-inputwrap input {
  flex: 1; min-width: 0;
  padding-inline-start: 12px; padding-inline-end: 38px;
  font-size: var(--fs-md); letter-spacing: .5px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding-block: 10px;
  background: var(--paper); color: var(--ink); outline: none; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.lb-scan-inputwrap input:focus {
  border-color: var(--accent-2); box-shadow: 0 0 0 4px var(--ring);
}
.lb-label-count input {
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 6px 8px; background: var(--paper); color: var(--ink);
  outline: none; font-family: inherit; text-align: center;
  transition: border-color .15s, box-shadow .15s;
}
.lb-label-count input:focus {
  border-color: var(--accent-2); box-shadow: 0 0 0 3px var(--ring);
}
.lb-scan-ic {
  position: absolute; right: 11px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none; display: grid; place-items: center;
}
.lb-cam { border-radius: var(--radius-md); overflow: hidden; }
.lb-cam video { display: block; width: 100%; max-height: 300px; background: #000; }
.lb-cam p { margin: 0; padding: 10px 12px; font-size: var(--fs-xs); color: var(--muted); }
.lb-scan-hint {
  display: flex; align-items: flex-start; gap: 6px; font-size: var(--fs-2xs);
  color: var(--muted); line-height: 1.8; padding: 8px 10px;
  border-radius: var(--radius-md); background: var(--surface-2); border: 1px dashed var(--line);
}
.lb-scan-empty {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  text-align: center; padding: 26px 18px; color: var(--muted);
}
.lb-scan-empty h3 { margin: 4px 0 0; font-size: var(--fs-md); font-weight: 800; color: var(--ink); }
.lb-scan-empty p { margin: 0; font-size: var(--fs-xs); line-height: 1.9; max-width: 420px; }
.lb-scan-empty.is-error { color: var(--bad); }
.lb-scan-empty.is-error h3 { color: var(--bad); }
.lb-scan-result { display: flex; flex-direction: column; gap: 4px; }
.lb-scan-book {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px; border-radius: var(--radius-lg); margin-bottom: 8px;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--lb-g1, #0d3b34) 12%, var(--paper)),
    color-mix(in srgb, var(--lb-g2, #047857) 12%, var(--paper)));
  border: 1px solid var(--line);
}
.lb-scan-booktxt { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 5px; }
.lb-scan-booktxt h3 { margin: 0; font-size: var(--fs-lg); font-weight: 800; line-height: 1.5; }
.lb-scan-booktxt p { margin: 0; font-size: var(--fs-xs); color: var(--muted); }
.lb-scan-acts { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 6px; }

/* اسکن‌های اخیر */
.lb-recent { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }
.lb-recent-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 9px;
  border-radius: var(--radius-md); cursor: pointer; font-family: inherit;
  background: var(--surface-2); border: 1px solid var(--line); text-align: right;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.lb-recent-item:hover { border-color: var(--accent-2); background: var(--paper); }
.lb-recent-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.lb-recent-txt b { font-size: var(--fs-xs); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-recent-txt small { font-size: var(--fs-2xs); color: var(--muted); }
.lb-recent-time { font-size: var(--fs-2xs); color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- گزارش و آمار ---------- */
.lb-reports { display: flex; flex-direction: column; gap: 12px; }
.lb-rep-loading { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.lb-rep-top {
  display: grid; grid-template-columns: 132px 132px 1fr; gap: 14px; align-items: center;
}
.lb-donut {
  --p: 0;
  width: 128px; height: 128px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--accent-2) calc(var(--p) * 1%), var(--surface-2) 0);
  box-shadow: inset 0 0 0 1px var(--line);
}
.lb-donut.is-good {
  background: conic-gradient(var(--good) calc(var(--p) * 1%), var(--surface-2) 0);
}
.lb-donut > div {
  width: 78%; height: 78%; border-radius: 50%; background: var(--paper);
  display: grid; place-items: center; align-content: center; gap: 1px;
  box-shadow: 0 0 0 1px var(--line);
}
.lb-donut b { font-size: var(--fs-xl); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.lb-donut span { font-size: var(--fs-2xs); color: var(--muted); font-weight: 600; }
.lb-rep-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 7px; }
.lb-fact {
  display: flex; flex-direction: column; gap: 2px; padding: 8px 10px;
  border-radius: var(--radius-md); background: var(--surface-2); border: 1px solid var(--line);
}
.lb-fact b { font-size: var(--fs-lg); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.15; }
.lb-fact span { font-size: var(--fs-2xs); color: var(--muted); font-weight: 600; }
.lb-fact.tone-good b { color: var(--good); }
.lb-fact.tone-bad b { color: var(--bad); }
.lb-fact.tone-warn b { color: var(--warn); }

.lb-rep-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); gap: 12px; }
.lb-rep-card h3 {
  display: flex; align-items: center; gap: 6px; margin: 0 0 12px;
  font-size: var(--fs-md); font-weight: 800;
}

/* نوارهای افقی */
.lb-bars { display: flex; flex-direction: column; gap: 9px; }
.lb-bar-row { display: flex; flex-direction: column; gap: 4px; }
.lb-bar-label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.lb-bar-label b { font-size: var(--fs-xs); font-weight: 700; }
.lb-bar-label span { font-size: var(--fs-2xs); color: var(--muted); }
.lb-bar { height: 8px; border-radius: var(--radius-full); background: var(--surface-2); overflow: hidden; }
.lb-bar span {
  display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), #34d399);
  transition: width var(--dur) var(--ease);
}
.lb-bar.is-bad span { background: linear-gradient(90deg, #dc2626, #f87171); }
.lb-bar.is-info span { background: linear-gradient(90deg, #2563eb, #60a5fa); }

/* رتبه‌بندی */
.lb-rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lb-rank li {
  display: flex; align-items: center; gap: 9px; padding: 7px 9px;
  border-radius: var(--radius-md); background: var(--surface-2); border: 1px solid var(--line);
}
.lb-rank-n {
  width: 22px; height: 22px; flex: 0 0 auto; display: grid; place-items: center;
  border-radius: 50%; background: var(--grad-brand); color: #fff;
  font-size: var(--fs-2xs); font-weight: 800;
}
.lb-rank-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.lb-rank-txt b { font-size: var(--fs-xs); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-rank-txt small { font-size: var(--fs-2xs); color: var(--muted); }
.lb-rank-v { font-size: var(--fs-2xs); font-weight: 700; color: var(--accent-2); white-space: nowrap; }

/* نمودار ستونی ماهانه */
.lb-chart {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 5px;
  height: 176px; padding: 6px 2px 0; overflow-x: auto;
}
.lb-chart-col {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  gap: 3px; height: 100%; min-width: 30px; flex: 1 1 0;
}
.lb-chart-v { font-size: var(--fs-2xs); font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.lb-chart-bar {
  width: 100%; max-width: 30px; min-height: 6px; border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, #34d399, var(--accent-2));
  transition: height var(--dur) var(--ease);
}
.lb-chart-col:hover .lb-chart-bar { background: linear-gradient(180deg, #fbbf24, var(--gold)); }
.lb-chart-l { font-size: var(--fs-2xs); color: var(--muted); white-space: nowrap; }

/* ---------- حالت شب ---------- */
[data-theme="dark"] .lb-kpi.tone-info b { color: #60a5fa; }
[data-theme="dark"] .lb-kpi.tone-good b { color: #34d399; }
[data-theme="dark"] .lb-kpi.tone-warn b { color: #fbbf24; }
[data-theme="dark"] .lb-kpi.tone-bad b { color: #f87171; }
[data-theme="dark"] .lb-fact.tone-good b { color: #34d399; }
[data-theme="dark"] .lb-fact.tone-bad b { color: #f87171; }
[data-theme="dark"] .lb-fact.tone-warn b { color: #fbbf24; }
[data-theme="dark"] .lb-search-clear { background: var(--surface-2); }
[data-theme="dark"] .lb-pick { background: rgba(20, 34, 30, .8); border-color: rgba(255, 255, 255, .18); }
[data-theme="dark"] .lb-label-preview { background: #f8fafc; }
[data-theme="dark"] .lb-cover { filter: saturate(.92) brightness(.94); }

/* ---------- واکنش‌گرا ---------- */
@media (max-width: 1024px) {
  .lb-scan-layout { grid-template-columns: 1fr; }
  .lb-rep-top { grid-template-columns: 1fr 1fr; }
  .lb-rep-top .lb-rep-facts { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .lb-hero { padding: 16px; }
  .lb-hero-ic { width: 44px; height: 44px; border-radius: 13px; }
  .lb-kpis { grid-template-columns: repeat(2, 1fr); }
  .lb-kpi { grid-template-columns: 28px 1fr; padding: 9px 10px; }
  .lb-kpi b { font-size: var(--fs-xl); }
  .lb-tab { flex: 1 1 120px; min-width: 0; padding: 9px 8px; }
  .lb-grid { grid-template-columns: 1fr; }
  .lb-toolbar .field { flex: 1 1 100%; }
  .lb-toolbar .field.lb-search { flex: 1 1 100%; }
  .lb-toolbar .field.lb-f-select { flex: 1 1 100%; }
  .lb-detail-grid { grid-template-columns: 1fr 1fr; }
  .lb-modal-actions .btn { flex: 1 1 auto; }
  .lb-form-row .field { flex: 1 1 100%; }
  .lb-rep-grid { grid-template-columns: 1fr; }
  .lb-rep-top { grid-template-columns: 1fr 1fr; }
  .lb-donut { width: 108px; height: 108px; }
  .lb-recent { grid-template-columns: 1fr; }
  .lb-chart { height: 150px; }
}
@media (max-width: 430px) {
  .lb-kpis { grid-template-columns: 1fr 1fr; }
  .lb-detail-grid { grid-template-columns: 1fr; }
  .lb-rep-facts { grid-template-columns: repeat(2, 1fr); }
  .lb-scan-inputwrap { flex-wrap: wrap; }
  .lb-scan-inputwrap .btn { flex: 1 1 100%; }
}

/* ---------- احترام به کاهش حرکت ---------- */
@media (prefers-reduced-motion: reduce) {
  .lb-book, .lb-kpi, .lb-tab, .lb-chip, .lb-cover, .lb-bar span,
  .lb-chart-bar, .lb-meter span { transition: none; }
  .lb-panel.lb-in { animation: none; }
  .lb-skel::after { animation: none; }
  .lb-book:hover, .lb-kpi:hover { transform: none; }
}

