/* Кітапхана жүйесінің стильдері.
   Көркемдік негізі — 1960–80 жылдардағы қазақ офсет баспасы («Жазушы» мұқабалары):
   тегіс бояу өрістері, суық ақ қағаз, градиент пен жұмсақ көлеңкесіз.
   Қаріптер: Geologica (тақырыптар) және Golos Text (интерфейс), екеуі де қазақ әріптерін толық қамтиды. */

:root {
  /* Қағаз және бояу */
  --paper: #f2f3ef;
  --paper-2: #e6e8e2;
  --sheet: #fbfbf9;
  --ink: #16191d;
  --ink-2: #4b5157;
  --rule: #cdd1ca;
  --rule-soft: #dfe2dc;

  /* Негізгі бояулар */
  --blue: #0b5c77;
  --blue-deep: #08465b;
  --on-blue: #ffffff;
  --on-blue-2: #cfe3ea;
  --ochre: #e3a21a;
  --ochre-deep: #c98a0a;
  --on-ochre: #16191d;
  --on-ochre-2: #3d2f08;
  /* Беттің тақырыбы тұрған жолақ: көк бояудың жеңіл реңкі */
  --band: #dde9ed;
  --on-band: #16191d;
  --on-band-2: #3c4a50;
  --band-rule: rgb(11 92 119 / .28);
  --carmine: #b3261e;
  --carmine-text: #9e1f18;
  --carmine-soft: #f6deda;
  --green: #23704a;
  --green-text: #1b5e3d;
  --green-soft: #dcede2;
  --amber-text: #7a4f00;
  --amber-soft: #fbebc5;
  --link: var(--blue);

  /* Санат бояулары: әр санатқа біреуі (app.js → categoryInk) */
  --cat-0: #0b5c77;
  --cat-1: #2e7d32;
  --cat-2: #8a5d00;
  --cat-3: #6a3f8f;
  --cat-4: #23272b;
  --cat-5: #2347a0;
  --cat-6: #3a4856;
  --cat-7: #5e6316;
  --cat-8: #00776e;
  --cat-9: #a62f66;
  --cat-10: #8e2c8a;
  --cat-11: #b4501a;
  --cat-12: #5c3d28;

  /* Қаріптер және өлшемдер: тек төрт кегль */
  --font-ui: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Geologica", "Golos Text", system-ui, sans-serif;
  --fs-s: 13px;
  --fs-m: 15px;
  --fs-l: 20px;
  --fs-xl: 34px;

  --radius: 3px;
  --ease: cubic-bezier(.2, 0, 0, 1);
  --cover-shadow: 0 1px 2px rgb(0 0 0 / .18), 0 6px 14px -6px rgb(0 0 0 / .35);
  --image-outline: oklch(0 0 0 / .1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111417;
    --paper-2: #1c2126;
    --sheet: #181c20;
    --ink: #e9ece6;
    --ink-2: #a9b0b6;
    --rule: #2e353c;
    --rule-soft: #242a30;
    --blue: #0a4a60;
    --blue-deep: #083a4b;
    --on-blue-2: #b9d6e0;
    --ochre: #e3a21a;
    --band: #15262d;
    --on-band: #e9ece6;
    --on-band-2: #b2c3c9;
    --band-rule: rgb(124 196 219 / .25);
    --carmine: #e2574b;
    --carmine-text: #f59287;
    --carmine-soft: #3a1f1c;
    --green: #4fae7c;
    --green-text: #8fd3ad;
    --green-soft: #1b3127;
    --amber-text: #f0c76a;
    --amber-soft: #3a2f16;
    --link: #7cc4db;
    --cover-shadow: 0 1px 2px rgb(0 0 0 / .5), 0 6px 14px -6px rgb(0 0 0 / .7);
    --image-outline: oklch(1 0 0 / .1);
    color-scheme: dark;
  }
}

/* Негіз */
* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--fs-m)/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  caret-color: var(--blue);
  scrollbar-color: var(--rule) transparent;
}
::selection { background: var(--ochre); color: var(--on-ochre); }

a { color: var(--link); text-decoration: none; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
@media (prefers-color-scheme: dark) { :focus-visible { outline-color: var(--ochre); } }

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em; text-wrap: balance; }
h1 { font-size: var(--fs-xl); line-height: 1.1; margin: 0; }
h2 { font-size: var(--fs-l); line-height: 1.25; margin: 0 0 14px; }
p { margin: 0 0 12px; text-wrap: pretty; }

.icon { flex: none; width: 18px; height: 18px; }

.container { width: 100%; max-width: 1320px; margin: 0 auto; padding: 0 24px; }
main.container { flex: 1; padding-top: 0; padding-bottom: 56px; }
@media (max-width: 700px) { .container { padding: 0 16px; } }

/* Жоғарғы мәзір: көк бояу өрісі */
.topbar { background: var(--blue); color: var(--on-blue); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1320px; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; gap: 16px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; color: var(--on-blue); font: 700 var(--fs-l)/1 var(--font-display); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; }
.brand-mark-back { fill: var(--ochre); }
.brand-mark-front { fill: var(--on-blue); }
.brand-mark-line { fill: var(--blue); }
.nav { display: flex; align-items: stretch; align-self: stretch; gap: 0; flex: 1; min-width: 0; }
.nav-link { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 0 9px; color: var(--on-blue-2); font-weight: 500; white-space: nowrap; transition: color .15s var(--ease); }
.nav-link::after { content: ""; position: absolute; left: 9px; right: 9px; bottom: 0; height: 4px; background: var(--ochre); transform: scaleY(0); transform-origin: bottom; transition: transform .2s var(--ease); }
.nav-link:hover { color: var(--on-blue); text-decoration: none; }
.nav-link.active { color: var(--on-blue); }
.nav-link.active::after { transform: scaleY(1); }
.nav-link:focus-visible { outline-color: var(--ochre); outline-offset: -2px; }
.nav-user { margin-left: auto; display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.user-link { max-width: 170px; }
.user-link span { overflow: hidden; text-overflow: ellipsis; }
.nav-toggle { display: none; margin-left: auto; width: 44px; height: 44px; align-items: center; justify-content: center; background: transparent; color: var(--on-blue); border: 1px solid rgb(255 255 255 / .35); border-radius: var(--radius); cursor: pointer; }
.nav-toggle .icon { width: 22px; height: 22px; }
.nav-toggle-close, .nav-toggle[aria-expanded="true"] .nav-toggle-open { display: none; }
.nav-toggle[aria-expanded="true"] .nav-toggle-close { display: inline-flex; }

/* Мәзір бір жолға сыймаса — жиналатын мәзір */
@media (max-width: 1330px) {
  .nav-toggle { display: inline-flex; }
  .topbar-inner { flex-wrap: wrap; }
  .nav { display: none; flex-basis: 100%; flex-direction: column; align-self: auto; padding: 4px 0 14px; }
  .nav.open { display: flex; }
  .nav-link { min-height: 44px; padding: 0 12px; }
  .nav-link::after { left: 0; right: auto; top: 10px; bottom: 10px; width: 4px; height: auto; transform: scaleX(0); transform-origin: left; }
  .nav-link.active::after { transform: scaleX(1); }
  .nav-user { margin: 8px 0 0; padding-top: 10px; border-top: 1px solid rgb(255 255 255 / .2); justify-content: space-between; }
  .user-link { max-width: none; }
}
/* Қонақ пен оқырманның мәзірі қысқа: тек телефонда жиналады */
@media (min-width: 701px) and (max-width: 1330px) {
  .topbar-short .nav-toggle { display: none; }
  .topbar-short .topbar-inner { flex-wrap: nowrap; }
  .topbar-short .nav { display: flex; flex-basis: auto; flex-direction: row; align-self: stretch; padding: 0; }
  .topbar-short .nav-link { min-height: 0; padding: 0 9px; }
  .topbar-short .nav-link::after { left: 9px; right: 9px; top: auto; bottom: 0; width: auto; height: 4px; transform: scaleY(0); transform-origin: bottom; }
  .topbar-short .nav-link.active::after { transform: scaleY(1); }
  .topbar-short .nav-user { margin: 0 0 0 auto; padding-top: 0; border-top: 0; }
}
@media (max-width: 700px) { .topbar-inner { padding: 0 16px; } }

/* Беттің тақырыбы: көк реңкті жолақ бүкіл енге созылады */
.page-head, .imprint {
  margin: 0 calc(50% - 50vw) 28px;
  padding: 26px calc(50vw - 50%) 24px;
  background: var(--band);
  color: var(--on-band);
  border-bottom: 1px solid var(--band-rule);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px 24px;
  flex-wrap: wrap;
}
.page-head > div:first-child { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.page-head p, .page-head .muted, .imprint .muted, .imprint p { color: var(--on-band-2); }
.page-head p { margin: 0; }
.page-head .btn:not(.btn-primary):not(.btn-danger):not(.btn-ghost), .imprint .btn:not(.btn-primary):not(.btn-ink) { border-color: var(--band-rule); }
.page-head .btn-ghost { border-color: transparent; }
.btn.btn-ink { background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.btn.btn-ink:hover { background: var(--blue-deep); border-color: var(--blue-deep); }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-s); font-weight: 500; }
.back-link .icon { width: 16px; height: 16px; }
main > .back-link { margin: 22px 0 4px; }

/* Каталогтың басы */
.imprint-catalog { align-items: flex-end; padding-top: 40px; padding-bottom: 32px; }
.imprint-text { max-width: 560px; }
.imprint-text h1 { margin-bottom: 8px; }
.imprint-text p { margin: 0; }
.hero-search { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; flex: 1 1 520px; max-width: 700px; }
.hero-search .search-field { flex: 1 1 260px; }
.hero-search select { flex: 0 1 190px; width: auto; }
.hero-search .check { color: var(--on-band); }
.imprint input, .imprint select { border-color: var(--band-rule); background: var(--sheet); }
.search-field { position: relative; display: flex; align-items: center; }
.search-field .icon { position: absolute; left: 12px; color: var(--ink-2); pointer-events: none; }
.search-field input { padding-left: 38px; }

/* Санат түстері: каталогтағы сүзгі */
.ink-chips { display: flex; flex-wrap: wrap; gap: 6px; flex-basis: 100%; margin-top: 6px; }
.ink-chip { --swatch: var(--ink); display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 12px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--sheet); color: var(--ink); font-size: var(--fs-s); font-weight: 500; transition: border-color .15s var(--ease), background-color .15s var(--ease), color .15s var(--ease); }
.ink-chip::before { content: ""; width: 10px; height: 10px; background: var(--swatch); flex: none; }
.ink-chip:hover { border-color: var(--swatch); text-decoration: none; }
.ink-chip.active { background: var(--swatch); border-color: var(--swatch); color: #fff; }
.ink-chip.active::before { background: #fff; }
.ink-chips .ink-chip:first-child::before { background: linear-gradient(90deg, var(--cat-0) 0 33%, var(--ochre) 33% 66%, var(--cat-9) 66%); }
.ink-chips .ink-chip:first-child.active { background: var(--ink); border-color: var(--ink); }
/* Тақырып жолағындағы санат чиптері: белсендісі санат бояуымен толтырылады */
.imprint a.ink-chip { text-decoration: none; background: var(--sheet); border-color: var(--band-rule); color: var(--ink); }
.imprint a.ink-chip:hover { border-color: var(--swatch); text-decoration: none; }
.imprint a.ink-chip.active { background: var(--swatch); border-color: var(--swatch); color: #fff; }
.imprint a.ink-chip:first-child.active { background: var(--blue); border-color: var(--blue); }
.ink-tag { --swatch: var(--cat-4); display: inline-block; max-width: 100%; padding: 1px 7px; border-radius: 2px; background: var(--swatch); color: #fff; font-size: var(--fs-s); font-weight: 500; line-height: 1.5; }
@media (max-width: 700px) {
  .ink-chips { flex-wrap: nowrap; overflow-x: auto; margin-right: -16px; padding-right: 16px; scrollbar-width: none; }
  .ink-chips::-webkit-scrollbar { display: none; }
  .ink-chip { flex: none; }
}

.footer { border-top: 1px solid var(--rule); background: var(--paper-2); color: var(--ink-2); font-size: var(--fs-s); padding: 18px 0; }

/* Беттер мен блоктар */
.card { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 24px; }
.card > h2:first-child { margin-top: -2px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin-bottom: 24px; }
.grid-2 > .card { margin-bottom: 0; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }
main > .alert:first-child { margin-top: 20px; }

.empty-state { text-align: center; color: var(--ink-2); padding: 48px 20px; }
.empty-state p { margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: var(--fs-s); }
.center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .9em; }
.num, .num-cell, .mono { font-variant-numeric: tabular-nums; }
.pre-line { white-space: pre-line; }
.text-ok { color: var(--green-text); }
.text-warn { color: var(--amber-text); }
.text-danger { color: var(--carmine-text); }

/* Көрсеткіштер: бір жолақ, маңыздысы үлкенірек */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 24px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--sheet); overflow: hidden; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 16px 20px 18px; color: var(--ink); border-left: 1px solid var(--rule); margin-left: -1px; transition: background-color .15s var(--ease); }
a.stat:hover { background: var(--paper-2); text-decoration: none; }
.stat-label { color: var(--ink-2); font-size: var(--fs-s); font-weight: 500; }
.stat-value { font: 700 var(--fs-xl)/1.15 var(--font-display); font-variant-numeric: tabular-nums; }
/* Басқару тақтасы: күнделікті сандар кішірек, назар аударатындары (брондау, мерзімі өткен) үлкен әрі кең */
.stats-ranked { grid-template-columns: repeat(4, minmax(120px, 1fr)) repeat(2, minmax(180px, 1.5fr)); }
.stats-ranked .stat-label { min-height: 2.9em; }
.stats-ranked .stat:not(.stat-key) .stat-value { font-size: var(--fs-l); line-height: 1.7; }
@media (max-width: 1000px) { .stats-ranked { grid-template-columns: repeat(2, minmax(0, 1fr)); } .stats-ranked .stat { border-top: 1px solid var(--rule); margin-top: -1px; } }
.stat-note { color: var(--ink-2); font-size: var(--fs-s); }
.stat-warn { background: var(--amber-soft); }
.stat-warn .stat-value { color: var(--amber-text); }
a.stat-warn:hover { background: var(--amber-soft); filter: brightness(.97); }
.stat-danger { background: var(--carmine); color: #fff; }
.stat-danger .stat-label, .stat-danger .stat-note { color: #fde8e5; }
a.stat-danger:hover { background: #9c1f18; }
.copies { display: flex; gap: 36px; flex-wrap: wrap; }
.copies > div { display: flex; flex-direction: column; }
.copies .stat-value { font-size: var(--fs-xl); }

/* Батырмалар */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 0 16px;
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--sheet); color: var(--ink);
  font: 500 var(--fs-m)/1 var(--font-ui); white-space: nowrap; cursor: pointer;
  transition-property: background-color, border-color, color, scale;
  transition-duration: .15s; transition-timing-function: var(--ease);
}
.btn:hover { border-color: var(--ink); text-decoration: none; }
.btn:active { scale: .96; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .6; cursor: progress; }
.btn .icon { margin-left: -3px; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.btn-primary:hover { background: var(--blue-deep); border-color: var(--blue-deep); }
.btn-accent { background: var(--ochre); border-color: var(--ochre); color: var(--on-ochre); }
.btn-accent:hover { background: var(--ochre-deep); border-color: var(--ochre-deep); }
.btn-on-ink { background: transparent; border-color: rgb(255 255 255 / .4); color: var(--on-blue); }
.btn-on-ink:hover { border-color: var(--on-blue); background: rgb(255 255 255 / .08); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--rule); color: var(--ink); }
.topbar .btn-ghost { color: var(--on-blue-2); }
.topbar .btn-ghost:hover { color: var(--on-blue); border-color: rgb(255 255 255 / .4); }
/* Жою батырмасы: басқалардан бөлек тұрады, тек меңзер апарғанда толтырылады */
.btn-danger { background: transparent; border-color: var(--carmine-text); color: var(--carmine-text); }
.btn-danger:hover, .btn-danger:focus-visible { background: var(--carmine); border-color: var(--carmine); color: #fff; }
.actions > .btn-danger, .actions > form:has(.btn-danger) { margin-left: 14px; }
.btn-sm { min-height: 32px; padding: 0 11px; font-size: var(--fs-s); }
.btn-sm .icon { width: 16px; height: 16px; }
.btn-lg { min-height: 48px; padding: 0 22px; }
.btn-block { width: 100%; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; margin: 0; }

/* Формалар */
.form { display: flex; flex-direction: column; gap: 16px; }
.form.narrow { max-width: 720px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 700px) { .form-row, .form-row-3 { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 500; font-size: var(--fs-s); color: var(--ink); }
.field small { font-size: var(--fs-s); }
input, select, textarea {
  width: 100%; min-height: 40px; padding: 8px 11px;
  font: inherit; color: var(--ink);
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius);
  transition: border-color .15s var(--ease);
}
textarea { line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--ink-2); opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-2); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: -1px; border-color: var(--blue); }
input[type="checkbox"], input[type="radio"] { width: 18px; min-height: 0; height: 18px; accent-color: var(--blue); }
select[multiple], select[size] { padding: 4px; }
select option { padding: 5px 7px; }
.check { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; min-height: 40px; }
.check input { width: 18px; }
.select-filter { margin-bottom: 4px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 16px; }
.filters input[type="search"], .filters .search-field { flex: 1 1 260px; }
.filters select { flex: 0 1 210px; width: auto; }

/* Кестелер: бағандар тұрақты, күй бүкіл жолды бояйды */
.table-wrap { overflow-x: auto; }
.card.table-wrap { padding: 0; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 11px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule-soft); }
.table th { font-size: var(--fs-s); font-weight: 600; color: var(--ink-2); background: var(--paper-2); border-bottom-color: var(--rule); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background-color .12s var(--ease); }
.table tbody tr:hover { background: var(--paper); }
.table .num { text-align: right; white-space: nowrap; }
.card .table th:first-child, .card .table td:first-child { padding-left: 24px; }
.card .table th:last-child, .card .table td:last-child { padding-right: 24px; }
.table tr.row-overdue, .table tr.row-overdue:hover { background: var(--carmine-soft); }
.table tr.row-overdue td { border-bottom-color: color-mix(in srgb, var(--carmine) 25%, transparent); }
.table tr.row-returned td, .table tr.row-res-issued td, .table tr.row-res-cancelled td, .table tr.row-res-expired td { color: var(--ink-2); }
.table tr.row-res-ready { background: var(--green-soft); }
.table tr.row-res-ready:hover { background: var(--green-soft); }

/* Белгілер (күйлер) */
.badge { display: inline-block; padding: 2px 8px; border-radius: 2px; font-size: var(--fs-s); font-weight: 600; line-height: 1.5; background: var(--paper-2); color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge-active, .badge-pending { background: var(--amber-soft); color: var(--amber-text); }
.badge-overdue, .badge-expired { background: var(--carmine); color: #fff; }
.badge-returned, .badge-ready { background: var(--green-soft); color: var(--green-text); }
.badge-muted { background: var(--paper-2); color: var(--ink-2); }
.badge-role-admin { background: var(--ink); color: var(--paper); }
.badge-role-librarian { background: var(--blue); color: var(--on-blue); }
.badge-role-reader { background: var(--paper-2); color: var(--ink-2); }

/* Хабарламалар */
.alert { padding: 13px 16px; border-radius: var(--radius); margin-bottom: 20px; border: 1px solid transparent; }
.alert:focus { outline: none; }
.alert:focus-visible { outline: 2px solid var(--carmine); outline-offset: 2px; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-success { background: var(--green-soft); color: var(--green-text); border-color: color-mix(in srgb, var(--green) 45%, transparent); }
.alert-error { background: var(--carmine-soft); color: var(--carmine-text); border-color: color-mix(in srgb, var(--carmine) 45%, transparent); }

.details { display: grid; grid-template-columns: 160px 1fr; gap: 9px 18px; margin: 0 0 14px; }
.details dt { color: var(--ink-2); }
.details dd { margin: 0; }
@media (max-width: 500px) { .details { grid-template-columns: 1fr; gap: 2px; } .details dd { margin-bottom: 10px; } }

.tabs { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 1px solid var(--rule); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; }
.tab { position: relative; display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; color: var(--ink-2); font-weight: 500; }
.tab::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--blue); transform: scaleY(0); transform-origin: bottom; transition: transform .2s var(--ease); }
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.active { color: var(--ink); }
.tab.active::after { transform: scaleY(1); }
@media (prefers-color-scheme: dark) { .tab::after { background: var(--ochre); } }

.pagination { display: flex; gap: 14px; align-items: center; justify-content: center; margin: 8px 0 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pagination a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--sheet); color: var(--ink); }
.pagination a:hover { border-color: var(--ink); text-decoration: none; }

/* Кіру және тіркелу */
.auth-card { max-width: 420px; margin: 48px auto; padding: 0 28px 28px; overflow: hidden; }
.auth-card > h1 { margin: 0 -28px 18px; padding: 22px 28px 18px; background: var(--band); color: var(--on-band); border-bottom: 1px solid var(--band-rule); font-size: var(--fs-xl); }
.auth-card > h1 + .muted { margin-top: -4px; }
.auth-card-wide { max-width: 580px; }
.reserve-form { margin: 14px 0 8px; }

/* Каталог: кітап торы. Әр карточкада бірдей құрам: мұқаба, атауы, авторы, санаты, бар-жоғы */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-bottom: 24px; }
.book-card { display: flex; gap: 18px; padding: 18px; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); color: var(--ink); transition: border-color .15s var(--ease); }
.book-card:hover { border-color: var(--ink); text-decoration: none; }
.book-info { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; min-width: 0; padding-top: 2px; }
.book-title { font: 600 var(--fs-m)/1.35 var(--font-display); letter-spacing: -.005em; text-wrap: balance; }
.book-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.book-info .badge { margin-top: auto; white-space: normal; max-width: 100%; }

/* Мұқаба және артындағы сары «баспа табағы» */
.cover-wrap { position: relative; flex: 0 0 80px; width: 80px; height: 118px; isolation: isolate; }
.cover-wrap-lg { flex-basis: 200px; width: 200px; height: 294px; }
.cover-plate { position: absolute; inset: 0; z-index: -1; background: var(--ochre); border-radius: 2px; translate: -3px 3px; transition: translate .35s var(--ease); }
.book-card:hover .cover-plate, .book-card:focus-visible .cover-plate { translate: -7px 7px; }
.cover-wrap-lg .cover-plate { translate: -9px 9px; }
.book-cover { position: relative; width: 100%; height: 100%; border-radius: 2px; overflow: hidden; background: var(--paper-2); box-shadow: var(--cover-shadow); }
.book-cover::after { content: ""; position: absolute; inset: 0; border-radius: inherit; outline: 1px solid var(--image-outline); outline-offset: -1px; pointer-events: none; }
.book-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-fallback { display: none; position: absolute; inset: 0; flex-direction: column; justify-content: space-between; padding: 9px 8px 9px 9px; color: #fff; background: var(--swatch); }
.cover-fallback::before { content: ""; position: absolute; left: 0; right: 0; top: 56%; height: 6px; background: var(--ochre); }
.book-cover.no-img .cover-fallback { display: flex; }
.book-cover.no-img img { display: none; }
/* Мұқабадағы жазулар — сурет бөлігі, сондықтан төрт кегльдік шкалаға кірмейді */
.cover-title { position: relative; font: 700 10px/1.2 var(--font-display); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow-wrap: break-word; }
.cover-author { position: relative; font-size: 9px; line-height: 1.2; opacity: .85; }
.book-cover-lg .cover-fallback { padding: 20px 16px 18px; }
.book-cover-lg .cover-title { font-size: 17px; -webkit-line-clamp: 7; }
.book-cover-lg .cover-author { font-size: var(--fs-s); }
.book-detail { display: flex; gap: 40px; margin-top: 14px; padding: 32px; }
.book-detail h1 { margin-bottom: 6px; }
.book-detail .badge { font-size: var(--fs-s); }
@media (max-width: 640px) {
  .book-detail { flex-direction: column; gap: 28px; padding: 22px; }
  .cover-wrap-lg { align-self: center; }
  .book-grid { grid-template-columns: 1fr; }
}

/* Есептер: бағаналы диаграмма */
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 220px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar { width: 100%; max-width: 46px; height: var(--h); min-height: 2px; background: var(--blue); border-radius: 2px 2px 0 0; }
.bar-col:last-child .bar { background: var(--ochre); }
.bar-value { font-size: var(--fs-s); font-weight: 600; margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.bar-label { font-size: var(--fs-s); color: var(--ink-2); margin-top: 6px; white-space: nowrap; }
.rank { margin: 0; padding-left: 22px; font-variant-numeric: tabular-nums; }
.rank li { padding: 7px 0; border-bottom: 1px solid var(--rule-soft); }
.rank li:last-child { border-bottom: none; }
.rank .badge { float: right; margin-left: 8px; }

/* Каталогты жүктеу блогы */
.import-card { display: flex; gap: 20px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.import-card .muted { color: var(--on-blue-2); }
.import-card p { margin: 0; max-width: 640px; }
.import-card .btn-primary { background: var(--ochre); border-color: var(--ochre); color: var(--on-ochre); }

/* ЖИ көмекшісі */
.assistant { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.assistant-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 18px; border: none; border-radius: var(--radius); background: var(--ink); color: var(--paper); font: 600 var(--fs-m)/1 var(--font-ui); cursor: pointer; box-shadow: 0 2px 4px rgb(0 0 0 / .15), 0 10px 24px -8px rgb(0 0 0 / .45); transition: background-color .15s var(--ease), scale .15s var(--ease); }
.assistant-toggle:hover { background: var(--blue); color: var(--on-blue); }
.assistant-toggle:active { scale: .96; }
.assistant-toggle svg { width: 20px; height: 20px; fill: var(--ochre); }
@media (prefers-color-scheme: dark) { .assistant-toggle { background: var(--ochre); color: var(--on-ochre); } .assistant-toggle svg { fill: var(--on-ochre); } }
.assistant.open .assistant-toggle { display: none; }
.assistant-panel { width: min(400px, calc(100vw - 32px)); height: min(580px, calc(100vh - 100px)); background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: 0 2px 6px rgb(0 0 0 / .12), 0 24px 48px -16px rgb(0 0 0 / .4); display: flex; flex-direction: column; overflow: hidden; }
.assistant-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 14px 12px 16px; background: var(--blue); color: var(--on-blue); }
.assistant-head .muted { color: var(--on-blue-2); }
.assistant-head .btn-ghost { color: var(--on-blue-2); }
.assistant-head .btn-ghost:hover { color: var(--on-blue); border-color: rgb(255 255 255 / .4); }
.assistant-head > div:first-child { display: flex; flex-direction: column; min-width: 0; }
.assistant-head strong { font-family: var(--font-display); }
.assistant-head .actions { flex-wrap: nowrap; gap: 2px; }
.assistant-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; padding: 9px 13px; border-radius: var(--radius); line-height: 1.5; white-space: pre-wrap; overflow-wrap: break-word; }
.msg-bot { align-self: flex-start; background: var(--paper-2); }
.msg-user { align-self: flex-end; background: var(--blue); color: var(--on-blue); }
.msg-user a { color: var(--on-blue); text-decoration: underline; }
.msg-error { background: var(--carmine-soft); color: var(--carmine-text); }
.msg a { font-weight: 600; }
.typing { display: flex; gap: 4px; padding: 12px 14px; }
.typing span { width: 7px; height: 7px; background: var(--ink-2); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.assistant-suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--rule); background: var(--sheet); color: var(--link); border-radius: var(--radius); padding: 7px 11px; font: inherit; font-size: var(--fs-s); cursor: pointer; text-align: left; transition: border-color .15s var(--ease); }
.chip:hover { border-color: var(--blue); }
.assistant-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--rule); }
.assistant-form textarea { resize: none; min-height: 40px; max-height: 120px; }
.assistant-note { font-size: var(--fs-s); text-align: center; margin: 0; padding: 0 10px 8px; }
@media (max-width: 500px) { .assistant { right: 12px; bottom: 12px; } }

@media (max-width: 700px) { .stats .stat-value { font-size: var(--fs-l); line-height: 1.4; } .stat { padding: 14px 16px; } }

/* Кітап қоры: даналар, түсімдер, есептен шығару */
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head h2 { margin: 0; }
.badge-copy-available { background: var(--green-soft); color: var(--green-text); }
.badge-copy-loaned { background: var(--amber-soft); color: var(--amber-text); }
.badge-copy-reserved { background: var(--band); color: var(--blue); }
.badge-copy-written_off { background: var(--paper-2); color: var(--ink-2); text-decoration: line-through; }
.table tr.row-copy-written_off td { color: var(--ink-2); }
.table .check-col { width: 44px; padding-right: 0; }
.write-off-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--rule-soft); }
.write-off-bar select { width: auto; flex: 0 1 200px; min-height: 32px; padding: 4px 8px; }
.write-off-bar input { flex: 1 1 200px; min-height: 32px; padding: 4px 8px; }
.ledger-notes { margin-top: 16px; display: flex; flex-direction: column; gap: 4px; }
.ledger-notes p { margin: 0; }
.field-static { margin: 0; min-height: 40px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.act { max-width: 820px; }
.act-head { text-align: center; margin-bottom: 20px; }
.act-head h2 { margin-bottom: 4px; }
.act-head p { margin: 0; }
.act .table-wrap { margin: 8px 0 24px; border: 1px solid var(--rule); border-radius: var(--radius); }
.act-signatures { display: flex; flex-direction: column; gap: 18px; }
.act-signatures p { margin: 0; display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.sign-line { flex: 1 1 160px; max-width: 260px; border-bottom: 1px solid var(--ink); height: 1.2em; }
@media print {
  .topbar, .footer, .page-head, .assistant, .alert { display: none !important; }
  body { background: #fff; color: #000; }
  .card.act { border: 0; padding: 0; max-width: none; }
}

/* Хабарламалар */
.bell-link { gap: 6px; }
.bell-count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--ochre); color: var(--on-ochre); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (min-width: 701px) { .topbar-short .bell-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } }
.notice-list { list-style: none; margin: 0 0 24px; padding: 0; }
.notice { display: flex; align-items: flex-start; gap: 14px; padding: 16px 24px; border-bottom: 1px solid var(--rule-soft); }
.notice:last-child { border-bottom: 0; }
.notice-mark { flex: none; width: 10px; height: 10px; margin-top: 7px; background: var(--rule); }
.notice-body { flex: 1; min-width: 0; }
.notice-body p { margin: 0 0 2px; }
.notice-new { background: var(--sheet); }
.notice-new .notice-body p { font-weight: 600; }
.notice-new-label { color: var(--blue); }
.notice-ready .notice-mark, .notice-issued .notice-mark, .notice-extended .notice-mark { background: var(--green); }
.notice-due_soon .notice-mark { background: var(--ochre); }
.notice-overdue .notice-mark, .notice-cancelled .notice-mark, .notice-expired .notice-mark { background: var(--carmine); }

/* Қозғалысты азайтуды қалайтындарға */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .book-card:hover .cover-plate { translate: none; }
}
