/* Soran University Academic Digital Library — base stylesheet.
   Colors, fonts and radius come from CSS variables emitted by templates/header.php
   (managed by the Super Admin in Admin → Appearance). */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: var(--font-size, 16px); }
body {
  margin: 0;
  font-family: var(--font, "Segoe UI", Tahoma, sans-serif);
  color: var(--text, #1f2933);
  background: var(--bg, #f5f7fa);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img { max-width: 100%; }
a { color: var(--primary); }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; color: var(--primary); }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; top: -50px; left: 8px; background: var(--accent); color: #000; padding: 8px 12px; z-index: 1000; border-radius: var(--radius); }
.skip-link:focus { top: 8px; }
.container { width: min(1200px, 100% - 2rem); margin-inline: auto; }
.site-main { flex: 1; padding-bottom: 3rem; }
.muted { color: #6b7280; }
.small { font-size: .875rem; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mb-2 { margin-bottom: 1rem; }
.flex { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.text-center { text-align: center; }

/* Header */
.site-header { background: var(--primary); color: #fff; position: sticky; top: 0; z-index: 50; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.header-inner { display: flex; align-items: center; gap: 1rem; min-height: calc(var(--logo-h, 76px) + 16px); flex-wrap: wrap; padding: 6px 0; }
/* One logo in each corner of the menu bar; no wordmark text. Height set in Admin → Appearance. */
.header-logo { flex: 0 0 auto; display: flex; align-items: center; text-decoration: none; }
.header-logo img { height: var(--logo-h, 76px); width: auto; max-width: calc(var(--logo-h, 76px) * 3.4); object-fit: contain; display: block; }
.nav-icon { font-size: 1.05em; }
.header-logo:hover { text-decoration: none; }
.header-logo.logo-empty { color: rgba(255,255,255,.75); border: 1px dashed rgba(255,255,255,.45); border-radius: var(--radius); font-size: .78rem; padding: .35rem .7rem; }
.header-logo.logo-empty:hover { color: #fff; border-color: #fff; }
.header-logo.logo-spacer { width: 0; }
.nav-toggle { margin-inline-start: auto; background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.4); border-radius: var(--radius); font-size: 1.3rem; padding: .2rem .6rem; cursor: pointer; display: none; }
.primary-nav { display: flex; align-items: center; gap: .15rem; flex: 1 1 auto; justify-content: center; flex-wrap: wrap; }
.primary-nav > a { color: #fff; text-decoration: none; padding: .5rem .7rem; border-radius: var(--radius); font-size: .95rem; opacity: .9; }
.primary-nav > a:hover, .primary-nav > a.active { background: rgba(255,255,255,.15); opacity: 1; }
.nav-tools { display: flex; align-items: center; gap: .35rem; margin-inline-start: auto; }
.site-header .btn-ghost { color: #fff; border-color: rgba(255,255,255,.35); }
.site-header .btn-ghost:hover { background: rgba(255,255,255,.15); }
.notif-btn { position: relative; }
.notif-count { position: absolute; top: -4px; inset-inline-end: -4px; background: var(--accent); color: #000; font-size: .7rem; font-weight: 700; border-radius: 999px; padding: 0 .4em; min-width: 1.4em; text-align: center; }
.online-btn .online-count { background: #22c55e; color: #fff; }
[data-dropdown] { position: relative; }
.dropdown-menu { display: none; position: absolute; top: calc(100% + 4px); inset-inline-end: 0; background: var(--surface); color: var(--text); min-width: 180px; border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: .35rem; z-index: 60; }
[data-dropdown].open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu .link-btn { display: block; width: 100%; text-align: start; padding: .5rem .75rem; color: var(--text); text-decoration: none; border-radius: calc(var(--radius) - 4px); background: none; border: 0; font: inherit; cursor: pointer; }
.dropdown-menu a:hover, .dropdown-menu .link-btn:hover, .dropdown-menu a.active { background: var(--bg); }

.lang-switch .lang-code { display: none; }
.user-menu .user-name { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }
.dropdown-head { padding: .4rem .75rem .5rem; border-bottom: 1px solid #e5e7eb; margin-bottom: .25rem; font-weight: 700; }

@media (max-width: 900px) {
  /* Row 1: the two logos. Row 2: language · bell · account · menu button (always visible). Row 3: the menu. */
  .header-inner { gap: .4rem .75rem; min-height: 0; }
  .header-logo.start { order: 1; }
  .header-logo.end { order: 2; margin-inline-start: auto; }
  .header-logo img { height: calc(var(--logo-h, 76px) * 0.7); max-width: calc(var(--logo-h, 76px) * 2.4); }
  .nav-tools { order: 3; flex: 1 1 70%; margin: 0; justify-content: flex-end; gap: .3rem; flex-wrap: nowrap; min-width: 0; }
  .nav-tools .btn-sm { padding: .45rem .6rem; font-size: .9rem; }
  .lang-switch .lang-name { display: none; }
  .lang-switch .lang-code { display: inline; font-weight: 700; }
  .user-menu .user-name { max-width: 28vw; }
  .nav-toggle { display: block; order: 4; margin-inline-start: 0; }
  .primary-nav { display: none; width: 100%; order: 5; flex-direction: column; align-items: stretch; justify-content: flex-start; padding-bottom: .75rem; }
  .primary-nav.open { display: flex; }
  .primary-nav > a { padding: .7rem .8rem; font-size: 1rem; }
  /* Dropdowns open full width under the bar so nothing is clipped or off-screen. */
  .nav-tools [data-dropdown] { position: static; }
  .nav-tools .dropdown-menu { inset-inline: .5rem; top: 100%; min-width: 0; font-size: 1rem; }
  .nav-tools .dropdown-menu a, .nav-tools .dropdown-menu .link-btn { padding: .75rem .9rem; }
}

/* Buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .55rem 1.1rem; border-radius: var(--radius); border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2; transition: filter .15s; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-accent { background: var(--accent); color: #1a1a1a; }
.btn-danger { background: #c0392b; color: #fff; }
.btn-success { background: #1e8449; color: #fff; }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text); border-color: #d1d5db; }
.btn-sm { padding: .35rem .75rem; font-size: .875rem; }
.btn-lg { padding: .8rem 1.5rem; font-size: 1.05rem; }
.btn[disabled], .btn.disabled { opacity: .55; cursor: not-allowed; filter: none; }
.btn-block { width: 100%; }
.form-group { margin-bottom: 1rem; }
label { display: block; font-weight: 600; margin-bottom: .3rem; }
label .req { color: #c0392b; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], input[type=color], input[type=file], select, textarea {
  width: 100%; padding: .55rem .75rem; border: 1px solid #cbd2d9; border-radius: var(--radius); font: inherit; background: var(--surface); color: var(--text);
}
input[type=color] { padding: .2rem; height: 44px; }
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--secondary) 45%, transparent); outline-offset: 1px; }
.check { display: flex; align-items: flex-start; gap: .5rem; font-weight: 500; }
.check input { width: auto; margin-top: .3em; }
.help { font-size: .85rem; color: #6b7280; margin-top: .25rem; }
.form-row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.field-error { color: #c0392b; font-size: .85rem; }
fieldset { border: 1px solid #e5e7eb; border-radius: var(--radius); padding: 1rem 1.25rem; margin: 0 0 1.25rem; }
legend { font-weight: 700; color: var(--primary); padding: 0 .4rem; }

/* Cards / panels */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: 0 1px 3px rgba(0,0,0,.08); padding: 1.25rem; }
.card-title { margin-bottom: .75rem; }
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: 0 1px 3px rgba(0,0,0,.08); padding: 1.5rem; margin-bottom: 1.5rem; }
.section { margin: 2.25rem 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.section-head h2 { margin: 0; }

/* Alerts & badges */
.alert { padding: .8rem 1rem; border-radius: var(--radius); margin: 1rem 0; border: 1px solid transparent; }
.alert-success { background: #e6f4ea; color: #1e5631; border-color: #b7dfc2; }
.alert-danger { background: #fdecea; color: #7a1c14; border-color: #f5c6c2; }
.alert-warning { background: #fff6e0; color: #7a4b00; border-color: #ffe0a3; }
.alert-info { background: #e8f4fd; color: #0b4f6c; border-color: #b9dcf2; }
.badge { display: inline-block; padding: .15em .6em; border-radius: 999px; font-size: .78rem; font-weight: 700; vertical-align: middle; }
.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #7a4b00; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-muted { background: #e5e7eb; color: #374151; }
.type-chip { display: inline-block; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--secondary); font-weight: 700; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { padding: .65rem .8rem; text-align: start; border-bottom: 1px solid #edf0f3; vertical-align: top; }
th { background: color-mix(in srgb, var(--primary) 7%, var(--surface)); color: var(--primary); font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td .btn { margin: .1rem 0; }
.table-actions { white-space: nowrap; }
/* Admin → Books list: compact rows so the action buttons stay on screen without sideways scrolling. */
.books-table th, .books-table td { padding: .5rem .6rem; }
.books-table td { vertical-align: middle; }
.books-table .table-actions .btn-sm { padding: .3rem .5rem; }
.books-table .table-actions .inline-form { display: inline-block; }
.books-table th a { white-space: nowrap; }

/* Hero */
.hero { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: #fff; padding: 3.5rem 0; text-align: center; position: relative; }
.hero.has-bg { background: var(--hero-bg) center/cover no-repeat; }
.hero.has-bg::before { content: ""; position: absolute; inset: 0; background: color-mix(in srgb, var(--primary) 70%, transparent); }
.hero > .container { position: relative; }
.hero h1 { color: #fff; font-size: clamp(1.6rem, 3.5vw, 2.6rem); margin-bottom: .5rem; }
.hero p { font-size: 1.1rem; opacity: .95; max-width: 720px; margin: 0 auto 1.5rem; }
.hero-search { display: flex; max-width: 760px; margin: 0 auto; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.hero-search input { border: 0; border-radius: 0; padding: .9rem 1.1rem; font-size: 1.05rem; flex: 1; min-width: 0; }
.hero-search button { border-radius: 0; padding: .9rem 1.4rem; }
.hero-links { margin-top: .75rem; font-size: .9rem; }
.hero-links a { color: #fff; }
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-top: -2rem; position: relative; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 1rem; text-align: center; box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.stat strong { display: block; font-size: 1.6rem; color: var(--primary); }
.stat span { font-size: .85rem; color: #6b7280; }

/* Quick access & categories */
.quick-card { display: flex; gap: 1rem; align-items: flex-start; text-decoration: none; color: inherit; border-inline-start: 5px solid var(--secondary); }
.quick-card:hover { text-decoration: none; transform: translateY(-2px); }
.quick-card .icon { font-size: 2rem; }
.quick-card h3 { margin-bottom: .25rem; }
.quick-card p { margin: 0; font-size: .9rem; color: #6b7280; }
.cat-card { text-decoration: none; color: inherit; text-align: center; transition: transform .15s; }
.cat-card:hover { transform: translateY(-3px); text-decoration: none; }
.cat-card .icon { font-size: 2.4rem; }
.cat-card h3 { margin: .4rem 0 .2rem; font-size: 1.02rem; }
.cat-card .count { font-size: .82rem; color: #6b7280; }
.topic-list { display: flex; flex-wrap: wrap; gap: .5rem; }
.topic-list a { background: var(--surface); border: 1px solid #d1d5db; padding: .35rem .8rem; border-radius: 999px; text-decoration: none; color: var(--text); font-size: .9rem; }
.topic-list a:hover, .topic-list a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Book cards */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.1rem; }
.book-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.book-cover { display: block; aspect-ratio: 3 / 4; background: linear-gradient(160deg, #e3ecf3, #cfdbe6); text-align: center; overflow: hidden; }
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-placeholder { font-size: 3.5rem; line-height: 1; display: flex; align-items: center; justify-content: center; height: 100%; }
.book-body { padding: .85rem; display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.book-body h3 { font-size: 1rem; margin: 0; }
.book-body h3 a { text-decoration: none; color: var(--text); }
.book-author { margin: 0; font-size: .88rem; color: #4b5563; }
.book-meta { margin: 0; font-size: .8rem; color: #6b7280; }
.book-meta .code { font-family: ui-monospace, Consolas, monospace; }
.book-foot { margin-top: auto; padding-top: .5rem; display: flex; justify-content: space-between; align-items: center; gap: .4rem; flex-wrap: wrap; }

/* Book detail */
.detail-layout { display: grid; grid-template-columns: 260px 1fr; gap: 2rem; }
.detail-cover { aspect-ratio: 3/4; border-radius: var(--radius); overflow: hidden; background: linear-gradient(160deg, #e3ecf3, #cfdbe6); display: flex; align-items: center; justify-content: center; font-size: 5rem; }
.detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.meta-list { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 1rem 0; }
.meta-list dt { font-weight: 600; color: #4b5563; }
.meta-list dd { margin: 0; }
.action-box { background: color-mix(in srgb, var(--primary) 6%, var(--surface)); border-radius: var(--radius); padding: 1.25rem; margin-top: 1.25rem; }
@media (max-width: 720px) { .detail-layout { grid-template-columns: 1fr; } .detail-cover { max-width: 220px; } }

/* Countdown */
.countdown { font-weight: 700; font-family: ui-monospace, Consolas, monospace; color: var(--primary); }
.countdown.expired { color: #c0392b; }
.countdown.done { color: #1e8449; }
.countdown.urgent { color: #b45309; }
.countdown-big { font-size: 1.6rem; }

/* Announcements */
.announcement { border-inline-start: 4px solid var(--accent); }
.announcement .kind { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: #6b7280; }
.announcement time { font-size: .82rem; color: #6b7280; }

/* Empty state */
.empty-state { text-align: center; padding: 3rem 1rem; color: #6b7280; }
.empty-icon { font-size: 3rem; }

/* Pagination */
.pagination { display: flex; gap: .3rem; flex-wrap: wrap; margin: 1.5rem 0; }
.pagination a { padding: .4rem .75rem; border-radius: var(--radius); background: var(--surface); color: var(--text); text-decoration: none; border: 1px solid #e5e7eb; }
.pagination a.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-gap { padding: .4rem .3rem; }

/* Filters */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; align-items: end; }
.filters .form-group { margin: 0; }

/* Auth pages */
.auth-wrap { min-height: calc(100vh - 64px); display: grid; place-items: center; padding: 2rem 1rem; background: var(--login-bg, none) center/cover; }
.auth-card { width: min(520px, 100%); }
.auth-card h1 { text-align: center; }
.guidance-box { max-height: 50vh; overflow: auto; border: 1px solid #e5e7eb; padding: 1rem 1.25rem; border-radius: var(--radius); background: var(--bg); margin-bottom: 1rem; }

/* Dashboards */
.dash-layout { display: grid; grid-template-columns: 230px 1fr; gap: 1.5rem; margin-top: 1.5rem; }
.dash-nav { background: var(--surface); border-radius: var(--radius); padding: .75rem; box-shadow: 0 1px 3px rgba(0,0,0,.08); align-self: start; position: sticky; top: 80px; }
.dash-nav a { display: block; padding: .55rem .8rem; border-radius: calc(var(--radius) - 4px); color: var(--text); text-decoration: none; font-size: .95rem; }
.dash-nav a:hover, .dash-nav a.active { background: color-mix(in srgb, var(--primary) 10%, var(--surface)); color: var(--primary); }
.dash-nav .nav-title { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: #6b7280; padding: .6rem .8rem .2rem; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.kpi { background: var(--surface); border-radius: var(--radius); padding: 1rem 1.2rem; box-shadow: 0 1px 3px rgba(0,0,0,.08); border-top: 4px solid var(--secondary); }
.kpi strong { display: block; font-size: 1.8rem; color: var(--primary); }
.kpi span { color: #6b7280; font-size: .88rem; }
.kpi.warn { border-top-color: var(--accent); }
.kpi.danger { border-top-color: #c0392b; }
.tabs { display: flex; gap: .25rem; border-bottom: 2px solid #e5e7eb; margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .6rem 1rem; text-decoration: none; color: #4b5563; border-bottom: 3px solid transparent; margin-bottom: -2px; font-weight: 600; }
.tabs a.active, .tabs a:hover { color: var(--primary); border-bottom-color: var(--primary); }
@media (max-width: 860px) { .dash-layout { grid-template-columns: 1fr; } .dash-nav { position: static; display: flex; flex-wrap: wrap; gap: .25rem; } .dash-nav .nav-title { width: 100%; } }

/* Reader */
.reader-page { background: #1f2933; color: #fff; min-height: 100vh; display: flex; flex-direction: column; }
.reader-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .6rem 1rem; background: #111827; flex-wrap: wrap; }
.reader-bar h1 { color: #fff; font-size: 1rem; margin: 0; }
.reader-bar .notice { font-size: .82rem; opacity: .85; }
.reader-frame { flex: 1; border: 0; width: 100%; min-height: calc(100vh - 56px); background: #374151; }
.reader-page { -webkit-user-select: none; user-select: none; }

/* Notifications */
.notif-list { display: grid; gap: .5rem; }
.notif { background: var(--surface); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: 0 1px 3px rgba(0,0,0,.06); display: flex; gap: 1rem; justify-content: space-between; align-items: flex-start; }
.notif.unread { border-inline-start: 4px solid var(--secondary); }
.notif h3 { font-size: 1rem; margin-bottom: .2rem; }
.notif time { font-size: .8rem; color: #6b7280; }

/* Footer */
.site-footer { background: #111827; color: #d1d5db; padding: 2.5rem 0 1.25rem; margin-top: auto; }
.site-footer h4 { color: #fff; }
.site-footer a { color: #fff; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 2rem; }
.footer-copy { border-top: 1px solid #374151; margin-top: 1.5rem; padding-top: 1rem; font-size: .85rem; text-align: center; }

/* Rich text */
.rich h1, .rich h2, .rich h3 { margin-top: 1em; }
.rich ol, .rich ul { padding-inline-start: 1.5em; }

/* Inline forms */
.inline-form { display: inline; }
.file-current { font-size: .85rem; background: var(--bg); padding: .4rem .6rem; border-radius: var(--radius); display: inline-block; margin-top: .3rem; }
.color-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
pre.meta { white-space: pre-wrap; font-size: .78rem; margin: 0; max-width: 360px; }
.progress { height: 8px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--secondary); }
/* Category › Sub-category › Topic trail */
.trail-sep { color: #9aa5b1; margin: 0 .2rem; }
.trail { font-size: .92rem; }

/* Google sign-in */
.btn-google { background: #fff; color: #3c4043; border: 1px solid #dadce0; font-weight: 600; }
.btn-google:hover { background: #f7f8f8; filter: none; }
.auth-divider { display: flex; align-items: center; gap: .75rem; margin: 1.1rem 0; color: #6b7280; font-size: .85rem; }
.auth-divider::before, .auth-divider::after { content: ""; height: 1px; background: #e5e7eb; flex: 1; }

/* Search-and-pick widget (staff desk loan) */
.pick-box { border: 1px solid #e5e7eb; border-radius: var(--radius); padding: 1rem; background: var(--surface); }
.pick-result { max-height: 280px; overflow: auto; border: 1px solid #edf0f3; border-radius: var(--radius); margin-top: .6rem; }
.pick-result table { font-size: .9rem; }
.pick-chosen { background: color-mix(in srgb, var(--secondary) 12%, var(--surface)); border-radius: var(--radius); padding: .75rem 1rem; }

/* CSV import report */
.import-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .75rem; margin: 1rem 0; }
.import-summary > div { background: var(--surface); border-radius: var(--radius); padding: .75rem; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.import-summary strong { display: block; font-size: 1.5rem; color: var(--primary); }
.col-map { display: flex; flex-wrap: wrap; gap: .4rem; }
.col-map span { background: var(--bg); border: 1px solid #e5e7eb; border-radius: 999px; padding: .15rem .65rem; font-size: .8rem; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }

/* Integration status */
.status-dot { display: inline-block; width: .6em; height: .6em; border-radius: 50%; margin-inline-end: .4em; }
.status-dot.on { background: #1e8449; }
.status-dot.off { background: #9aa5b1; }
.status-dot.warn { background: var(--accent); }
.setup-steps { counter-reset: step; padding-inline-start: 0; list-style: none; }
.setup-steps li { counter-increment: step; margin-bottom: .5rem; padding-inline-start: 2.1rem; position: relative; }
.setup-steps li::before { content: counter(step); position: absolute; inset-inline-start: 0; top: .1rem; background: var(--primary); color: #fff; width: 1.5rem; height: 1.5rem; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; font-weight: 700; }
code.copyable { background: var(--bg); padding: .35rem .55rem; border-radius: 6px; word-break: break-all; display: inline-block; }

/* Additional classification rows (Admin → Books) */
.cls-extra { border-top: 1px dashed #e5e7eb; margin-top: .75rem; padding-top: .75rem; }
.cls-extra h3 { font-size: 1rem; margin-bottom: .2rem; }
.cls-row { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; background: var(--bg); border-radius: var(--radius); padding: .6rem .75rem; margin-bottom: .6rem; }
.cls-row .form-group { margin: 0; }
.cls-row label { font-size: .8rem; font-weight: 600; color: #6b7280; }
.cls-row .cls-remove { flex: 0 0 auto; }
.cls-trails { margin: 0; padding: 0; list-style: none; display: grid; gap: .2rem; }
.cls-trails li.primary::after { content: " ★"; color: var(--accent); }

/* AI assistant (Admin → Books) */
.ai-box { margin-top: 1rem; border: 1px solid color-mix(in srgb, var(--secondary) 40%, #e5e7eb); background: color-mix(in srgb, var(--secondary) 6%, var(--surface)); border-radius: var(--radius); padding: 1rem 1.1rem; }
.ai-head { display: flex; gap: .8rem; align-items: flex-start; margin-bottom: .5rem; }
.ai-head h3 { margin: 0 0 .2rem; font-size: 1.05rem; }
.ai-head .help { margin: 0; }
.ai-icon { font-size: 1.8rem; line-height: 1; }
.ai-options .form-group { margin-bottom: .5rem; }
.ai-status { font-size: .9rem; color: #4b5563; }
.ai-status.busy::before { content: "⏳ "; }
.ai-status.ok { color: #1e8449; font-weight: 600; }
.ai-status.error { color: #c0392b; font-weight: 600; }
.ai-thumb-list { display: flex; gap: .6rem; flex-wrap: wrap; }
.ai-thumb { background: var(--surface); border: 2px solid #e5e7eb; border-radius: 8px; padding: .3rem; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: .25rem; font: inherit; font-size: .75rem; color: #4b5563; }
.ai-thumb canvas { width: 72px; height: auto; display: block; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.ai-thumb.chosen { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
.ai-thumb.chosen span { color: var(--primary); font-weight: 700; }
.ai-thumb .ai-badge { font-size: .65rem; line-height: 1.4; padding: 0 .45rem; border-radius: 999px; background: #e5e7eb; color: #374151; font-weight: 700; }
.ai-thumb .ai-badge.toc { background: #dbeafe; color: #1d4ed8; }
.ai-thumb.chosen .ai-badge.cover { background: var(--primary); color: #fff; }
.ai-result { display: flex; gap: 1rem; align-items: flex-start; margin-top: .8rem; }
.ai-cover { width: 110px; aspect-ratio: 3/4; object-fit: cover; border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.ai-info { font-size: .9rem; display: grid; gap: .3rem; }
input.ai-filled, select.ai-filled { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--secondary) 55%, transparent); }
.ai-modes { display: flex; gap: .4rem; margin: .4rem 0 .8rem; flex-wrap: wrap; }
.ai-mode { background: var(--surface); border: 1px solid #d1d5db; border-radius: 999px; padding: .45rem 1rem; font: inherit; font-weight: 600; cursor: pointer; color: var(--text); }
.ai-mode.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.scan-actions .btn { min-height: 48px; }   /* tablet-friendly targets */
.scan-strip { display: flex; gap: .7rem; flex-wrap: wrap; margin: .8rem 0; min-height: 2rem; align-items: flex-start; }
.scan-item { background: var(--surface); border: 2px solid #e5e7eb; border-radius: 8px; padding: .35rem; display: flex; flex-direction: column; align-items: center; gap: .25rem; font-size: .78rem; color: #4b5563; }
.scan-item.cover { border-color: var(--accent); }
.scan-item img { width: 86px; height: 112px; object-fit: contain; background: #f3f4f6; border-radius: 4px; }
.scan-tools { display: flex; gap: .2rem; }
.scan-tools button { border: 1px solid #d1d5db; background: var(--surface); border-radius: 6px; min-width: 2rem; height: 2rem; cursor: pointer; font: inherit; }
.scan-modal { position: fixed; inset: 0; background: #000; z-index: 1000; display: flex; flex-direction: column; }
.scan-modal[hidden] { display: none; }
.scan-stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.scan-live-wrap { position: relative; display: flex; max-width: 100%; max-height: 100%; }
/* Only one view at a time: the hidden attribute must beat the display rules above/below. */
.scan-live-wrap[hidden], .scan-review[hidden], .scan-stage video[hidden], .scan-flash[hidden] { display: none !important; }
.scan-flash { position: absolute; right: .8rem; bottom: .8rem; width: 22%; max-width: 160px; border: 3px solid #22c55e; border-radius: 8px; overflow: hidden; background: #fff; box-shadow: 0 4px 16px rgba(0,0,0,.5); animation: scan-flash-in .25s ease-out; }
.scan-flash img { display: block; width: 100%; height: auto; }
@keyframes scan-flash-in { from { transform: scale(1.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.scan-stage video { display: block; max-width: 100vw; max-height: calc(100vh - 80px); width: auto; height: auto; }
.scan-live { pointer-events: none; }
.scan-live polygon { fill: rgba(245,158,11,.14); stroke: #f59e0b; stroke-width: 3; vector-effect: non-scaling-stroke; transition: fill .2s, stroke .2s; }
.scan-live.steady polygon { fill: rgba(34,197,94,.2); stroke: #22c55e; stroke-width: 4; }
.scan-steady { position: absolute; bottom: .8rem; left: 50%; transform: translateX(-50%); width: 44%; height: 6px; background: rgba(255,255,255,.3); border-radius: 3px; overflow: hidden; }
.scan-steady[hidden] { display: none; }
.scan-steady > i { display: block; height: 100%; width: 0; background: #22c55e; transition: width .15s; }
.scan-auto { color: #fff; display: inline-flex; align-items: center; gap: .3rem; padding: 0 .5rem; margin: 0; }
.scan-review { position: relative; max-width: 100%; max-height: 100%; display: flex; }
.scan-review canvas { max-width: 100vw; max-height: calc(100vh - 80px); width: auto; height: auto; display: block; }
.scan-overlay { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.scan-overlay polygon { fill: rgba(34,197,94,.18); stroke: #22c55e; stroke-width: 3; vector-effect: non-scaling-stroke; }
.scan-overlay circle { fill: #fff; stroke: #22c55e; stroke-width: 4; cursor: grab; vector-effect: non-scaling-stroke; }
.scan-overlay circle.drag { fill: #22c55e; }
/* Corner editor: side bars move a whole side, the spine line/handles split two pages, hidden parts stay hidden. */
.scan-overlay [hidden] { display: none; }
.scan-overlay rect { fill: #fff; stroke: #22c55e; stroke-width: 3; cursor: grab; vector-effect: non-scaling-stroke; }
.scan-overlay rect.drag { fill: #22c55e; }
.scan-overlay .scan-spine { stroke: #f59e0b; stroke-width: 5; stroke-dasharray: 14 10; vector-effect: non-scaling-stroke; cursor: ew-resize; }
.scan-overlay .scan-spine-handle { fill: #f59e0b; stroke: #fff; stroke-width: 3; cursor: ew-resize; vector-effect: non-scaling-stroke; }
.scan-overlay .scan-spine-handle.drag { fill: #fff; stroke: #f59e0b; }
.scan-magnifier { position: absolute; width: 130px; height: 130px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 10px rgba(0,0,0,.6); pointer-events: none; background: #000; z-index: 2; }
.scan-magnifier[hidden] { display: none; }
.scan-live .scan-live-deco, .scan-live #scan-live-deco { pointer-events: none; }
.scan-live #scan-live-deco line { stroke: rgba(245,158,11,.45); stroke-width: 1; vector-effect: non-scaling-stroke; }
.scan-live #scan-live-deco path { stroke: #f59e0b; stroke-width: 5; fill: none; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.scan-live #scan-live-deco rect { fill: #f59e0b; }
.scan-live.steady #scan-live-deco line { stroke: rgba(34,197,94,.5); }
.scan-live.steady #scan-live-deco path { stroke: #22c55e; }
.scan-live.steady #scan-live-deco rect { fill: #22c55e; }
.scan-orient { position: absolute; top: 3rem; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.65); color: #fff; padding: .4rem .9rem; border-radius: 8px; font-weight: 600; white-space: nowrap; }
.scan-orient[hidden] { display: none; }
.scan-settings { gap: 1rem; }
.scan-item img { cursor: pointer; }
.scan-item span { max-width: 110px; text-align: center; }
/* Form helpers: fill from an existing copy, ISBN suggestions, AI suggestions */
.from-copy-results { display: grid; gap: .4rem; margin-top: .6rem; max-height: 380px; overflow: auto; }
.from-copy-row { display: flex; gap: .6rem; align-items: center; background: var(--bg); border-radius: var(--radius); padding: .4rem .6rem; }
.from-copy-row img, .from-copy-nocover { width: 40px; height: 54px; object-fit: cover; border-radius: 4px; background: #e5e7eb; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; }
.from-copy-row > div { flex: 1; min-width: 0; }
.isbn-result, .ai-suggest-result { background: var(--bg); border: 1px dashed #cbd2d9; border-radius: var(--radius); padding: .6rem .8rem; margin-top: .5rem; }
.isbn-result[hidden], .ai-suggest-result[hidden] { display: none; }
.isbn-result td { padding: .25rem .4rem; }
.ai-suggest { margin: .5rem 0 1rem; }
.ai-suggest-result textarea { min-height: 90px; margin: .3rem 0 .6rem; }
.sug-keywords { display: flex; flex-wrap: wrap; gap: .3rem; }
.scan-tip { position: absolute; left: 0; right: 0; top: .8rem; text-align: center; color: #fff; font-weight: 600; text-shadow: 0 1px 3px #000; padding: 0 1rem; pointer-events: none; }
.scan-bar { display: flex; gap: .5rem; padding: .6rem; background: #111827; flex-wrap: wrap; }
.scan-bar .btn { flex: 1 1 auto; min-height: 50px; }
.btn-success { background: #1e8449; color: #fff; }

/* "Ask me" assistant widget */
.askme { position: fixed; bottom: 1.1rem; inset-inline-end: 1.1rem; z-index: 90; font-size: .95rem; }
.askme-toggle { background: var(--primary); color: #fff; border: 0; border-radius: 999px; padding: .65rem 1.1rem; font: inherit; font-weight: 700; cursor: pointer; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.askme-toggle:hover { filter: brightness(1.1); }
.askme-panel { position: absolute; bottom: calc(100% + .6rem); inset-inline-end: 0; width: min(360px, calc(100vw - 2rem)); max-height: min(70vh, 560px); background: var(--surface, #fff); color: var(--text, #1f2933); border-radius: var(--radius, 12px); box-shadow: 0 16px 40px rgba(0,0,0,.28); display: flex; flex-direction: column; overflow: hidden; }
.askme-panel[hidden] { display: none; }
.askme-head { display: flex; justify-content: space-between; align-items: center; background: var(--primary); color: #fff; padding: .6rem .9rem; }
.askme-close { background: transparent; border: 0; color: #fff; font-size: 1.1rem; cursor: pointer; }
.askme-intro { font-size: .85rem; color: #6b7280; margin: .6rem .9rem 0; }
.askme-form { display: flex; gap: .4rem; padding: .6rem .9rem; }
.askme-form input { flex: 1; min-width: 0; }
.askme-answers { overflow: auto; padding: 0 .9rem .6rem; flex: 1; }
.askme-item { border: 1px solid #e5e7eb; border-radius: 8px; padding: .4rem .6rem; margin-bottom: .4rem; background: var(--bg, #f5f7fa); }
.askme-item summary { cursor: pointer; font-weight: 600; }
.askme-answer { font-size: .9rem; margin-top: .3rem; }
.askme-answer p:last-child { margin-bottom: 0; }
.askme-none, .askme-thinking { font-size: .9rem; color: #6b7280; }
.askme-suggest { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.askme-suggest .small { width: 100%; }
.askme-chip { background: var(--bg, #f5f7fa); border: 1px solid #d1d5db; border-radius: 999px; padding: .25rem .7rem; font: inherit; font-size: .82rem; cursor: pointer; color: var(--text, #1f2933); text-align: start; }
.askme-chip:hover { border-color: var(--primary); color: var(--primary); }
.askme-foot { margin: 0; padding: .5rem .9rem; border-top: 1px solid #e5e7eb; font-size: .85rem; }
.reader-page .askme { bottom: .8rem; }
.reader-page .askme-panel { color: #1f2933; }
/* Quick-add sub-category / topic (Admin → Books) */
.quick-add { margin: .5rem 0 1rem; }
.quick-add-form { background: var(--bg); border: 1px dashed #cbd2d9; border-radius: var(--radius); padding: .75rem 1rem; margin-top: .6rem; }
.quick-add-form .form-row { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* Admin → Menu */
.menu-table td { vertical-align: middle; }
.menu-labels { display: grid; gap: .3rem; min-width: 220px; }
.menu-labels input { padding: .35rem .5rem; font-size: .9rem; }

/* ID-card capture (staff desk) */
.idcap { border: 1px solid #e5e7eb; border-radius: var(--radius); padding: 1rem 1.1rem; margin-top: 1rem; background: var(--bg); }
.idcap h3 { margin-bottom: .2rem; }
.idcap-stage { background: #111827; border-radius: 8px; min-height: 120px; display: flex; align-items: center; justify-content: center; overflow: hidden; max-width: 560px; }
.idcap-stage video, .idcap-stage img { width: 100%; max-height: 360px; object-fit: contain; display: block; }
.idcap-stage [hidden] { display: none; }
.idcap-thumb { height: 44px; width: 70px; object-fit: cover; border-radius: 4px; border: 1px solid #d1d5db; }
.idcap-current { max-width: 420px; width: 100%; border-radius: 8px; border: 1px solid #d1d5db; display: block; margin-top: .5rem; }

/* Admin → Reports */
.report-head { align-items: center; }
.report-meta { font-size: .85rem; color: #6b7280; margin: -.5rem 0 1rem; }
.report-section { break-inside: avoid; page-break-inside: avoid; }
.report-section h2 { font-size: 1.15rem; }
.chart-wrap { position: relative; margin: .25rem 0 .9rem; }
.chart-wrap[hidden] { display: none; }
.chart-sm { max-width: 460px; }
.report-table { font-size: .9rem; }
.report-table td, .report-table th { padding: .4rem .6rem; }
.table-scroll { max-height: 360px; overflow: auto; }
@page { size: A4; margin: 14mm 12mm; }
@media print {
  .no-print, .dash-nav, .site-header, .site-footer, .askme { display: none !important; }
  body { background: #fff; color: #000; font-size: 11px; }
  .container { width: 100%; }
  .dash-layout { display: block; margin: 0; }
  .panel, .kpi, .table-wrap { box-shadow: none; border: 1px solid #ddd; }
  .panel { padding: .6rem .8rem; margin-bottom: .6rem; }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); gap: .4rem; }
  .kpi strong { font-size: 1.2rem; }
  .report-grid { display: block; }
  .report-section { margin-bottom: .6rem; }
  .table-scroll { max-height: none; overflow: visible; }
  .chart-wrap canvas { max-height: 240px !important; }
  a { color: inherit; text-decoration: none; }
  h1 { font-size: 1.3rem; }
}

/* Libraries */
.book-lib { color: var(--primary); font-weight: 600; }
.library-card h2 { font-size: 1.2rem; }
.library-card .meta-list { margin: .5rem 0 1rem; }

/* Public "all questions" page */
.faq-list details { background: var(--surface); border-radius: var(--radius); padding: .8rem 1.1rem; margin-bottom: .6rem; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.faq-list summary { cursor: pointer; font-weight: 700; color: var(--primary); }
.faq-list .rich { margin-top: .5rem; }

@media print { .site-header, .site-footer, .nav-tools, .btn, .askme { display: none !important; } }

/* Barcode scanning (staff desk) */
.scan-card { border: 2px dashed var(--primary); background: color-mix(in srgb, var(--primary) 6%, var(--surface)); }
.scan-card input[data-scan-input] { font-family: ui-monospace, Consolas, monospace; font-size: 1.15rem; letter-spacing: .05em; }
.scan-cam { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 200; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .8rem; padding: 1rem; }
.scan-cam video { max-width: 100%; max-height: 70vh; border-radius: 10px; }
.scan-cam .scan-cam-tip { color: #fff; }
.scan-result .meta-list { margin: .4rem 0 .8rem; }

/* Labels & barcodes: the sheet is laid out with CSS variables filled from the admin settings. */
.label-sheet { display: grid; grid-template-columns: repeat(var(--cols, 4), var(--lw, 50mm)); column-gap: var(--gx, 2mm); row-gap: var(--gy, 2mm); padding: var(--mt, 10mm) var(--ml, 8mm); background: #fff; color: #000; justify-content: start; direction: ltr; }
.label-sheet.mode-roll { display: block; padding: 0; }
.label-sheet.mode-roll .label { margin: 0; page-break-after: always; break-after: page; }
.label { width: var(--lw, 50mm); height: var(--lh, 25mm); box-sizing: border-box; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; font-family: Arial, Helvetica, sans-serif; font-size: var(--fs, 8pt); line-height: 1.15; padding: 1mm 1.5mm; break-inside: avoid; page-break-inside: avoid; }
.label-sheet.bordered .label { outline: .2mm dashed #9ca3af; outline-offset: -.1mm; }
.label .l-lib, .label .l-title { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label .l-lib { font-size: calc(var(--fs, 8pt) * .9); color: #333; }
.label .l-title { font-size: calc(var(--fs, 8pt) * .9); }
.label .barcode { max-width: 100%; height: auto; display: block; }
/* Call number: one part per line, a thin rule between the parts as long as the longest part. */
.label .l-dewey { font-size: var(--ds, 16pt); font-weight: 700; letter-spacing: .02em; display: inline-flex; flex-direction: column; align-items: stretch; max-width: 100%; line-height: 1.1; }
.label .l-part { display: block; text-align: center; unicode-bidi: isolate; white-space: nowrap; }
.label .l-rule { display: none; }
.label-dewey.ruled .l-rule { display: block; height: 0; border-top: .3mm solid #000; margin: .35mm 0; }
.label .l-line { font-size: calc(var(--fs, 8pt) * 1.25); font-weight: 600; }
.label .l-code { font-size: var(--fs, 8pt); font-family: ui-monospace, Consolas, monospace; }
.label-preview { overflow: auto; border: 1px solid #e5e7eb; border-radius: var(--radius); background: #f3f4f6; padding: .6rem; }
.label-preview .label-sheet { transform-origin: top left; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
/* Print pages: one block per A4 page with the same margins; no bottom padding so a full page never spills. */
.label-page { width: 210mm; min-height: 297mm; padding: var(--mt, 10mm) var(--ml, 8mm) 0; align-content: start; box-shadow: 0 2px 8px rgba(0,0,0,.15); margin: 0 auto 8mm; }
.label-page.mode-roll { width: auto; min-height: 0; margin: 0; box-shadow: none; }
.inline-confirm { display: inline-flex; align-items: center; gap: .4rem; background: #fff6e0; border: 1px solid #ffe0a3; border-radius: var(--radius); padding: .3rem .6rem; font-size: .9rem; }
.inline-confirm[hidden] { display: none; }
@media print {
  .labels-print .site-main, .labels-print .container { padding: 0 !important; margin: 0 !important; width: auto !important; max-width: none !important; }
  .labels-print .label-tools, .labels-print .alert { display: none !important; }
  .labels-print body, .labels-print { background: #fff; }
  .label-sheet { padding: var(--mt, 10mm) var(--ml, 8mm); }
  .label-page { padding-bottom: 0; margin: 0; box-shadow: none; min-height: 0; height: 297mm; overflow: hidden; }
  .label-page + .label-page { page-break-before: always; break-before: page; }
  .label-page.mode-roll { height: auto; overflow: visible; }
  .label-sheet.bordered .label { outline-color: #bbb; }
}

/* Right-to-left safety: nothing may make the page wider than the screen (tablets zoom out otherwise). */
html, body { max-width: 100%; overflow-x: hidden; }
.dash-layout > *, .form-row > *, .grid > *, .panel, .card, .flex > input, .flex > select, .flex > div { min-width: 0; }
.scan-cam { inset: 0; }
.scan-cam .scan-cam-note { color: #fde68a; font-weight: 600; min-height: 1.4em; text-align: center; }
.scan-btn { flex: 0 0 auto; }

/* Help page (Kurdish) */
.help-page h2 { font-size: 1.2rem; }
.help-page ol, .help-page ul { padding-inline-start: 1.4em; }
.help-page li { margin-bottom: .4rem; }
.help-page b[dir=ltr] { unicode-bidi: isolate; background: var(--bg); border: 1px solid #e5e7eb; border-radius: 6px; padding: 0 .35em; font-weight: 600; }
.help-toc { font-size: .95rem; line-height: 2; }
