/* =====================================================================
   GIAO DIỆN OPAC (bạn đọc)
   ===================================================================== */
body { font-size: 15.5px; }
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); }

/* Dải công vụ trên cùng */
.govbar { background: linear-gradient(90deg, var(--red-900), var(--red-800) 55%, var(--red-900)); color: #fbe9c4; font-size: 12.5px; }
.govbar .container { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 34px; }
.govbar a { color: #fde7b0; }
.govbar .sep { opacity: .45; margin: 0 8px; }
.govbar .left, .govbar .right { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.govbar .upper { font-weight: 600; letter-spacing: .06em; }
@media (max-width: 720px) { .govbar .hide-sm { display: none; } }

/* Masthead với hoa văn trống đồng cách điệu */
.masthead {
  position: relative; overflow: hidden;
  background:
    radial-gradient(circle at 92% 50%, rgba(245, 194, 66, .16) 0 90px, transparent 91px),
    linear-gradient(180deg, #fffdf7, #fbf3e2);
  border-bottom: 1px solid var(--line);
}
.masthead::after {
  content: ''; position: absolute; right: -60px; top: 50%; width: 360px; height: 360px; transform: translateY(-50%);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cg fill='none' stroke='%23c48a00' stroke-opacity='.22'%3E%3Ccircle cx='100' cy='100' r='96'/%3E%3Ccircle cx='100' cy='100' r='86'/%3E%3Ccircle cx='100' cy='100' r='70'/%3E%3Ccircle cx='100' cy='100' r='52'/%3E%3Ccircle cx='100' cy='100' r='30'/%3E%3C/g%3E%3Cg fill='%23c48a00' fill-opacity='.2'%3E%3Cpath d='M100 72l6 16 17 1-13 11 4 17-14-9-14 9 4-17-13-11 17-1z'/%3E%3C/g%3E%3Cg stroke='%23c48a00' stroke-opacity='.2' stroke-width='2'%3E%3Cpath d='M100 4v12M100 184v12M4 100h12M184 100h12M32 32l9 9M159 159l9 9M168 32l-9 9M41 159l-9 9'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
  pointer-events: none;
}
.masthead .container { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 16px; padding-bottom: 16px; position: relative; z-index: 1; }
.brand { display: flex; align-items: center; gap: 16px; color: inherit; text-decoration: none !important; min-width: 0; }
.brand .emblem { flex: none; filter: drop-shadow(0 3px 6px rgba(120, 30, 10, .25)); }
.brand .org { font-size: 12.5px; font-weight: 600; color: var(--red-700); letter-spacing: .08em; text-transform: uppercase; }
.brand .name { font-family: var(--serif); font-size: 1.85rem; font-weight: 700; color: var(--red-800); text-transform: uppercase; letter-spacing: .02em; line-height: 1.15; }
.brand .tagline { font-family: var(--serif); font-style: italic; color: var(--gold-700); font-size: 14px; }
.masthead .account { display: flex; align-items: center; gap: 10px; flex: none; }
.masthead .account .avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid var(--gold-400); }
@media (max-width: 720px) {
  .brand .name { font-size: 1.25rem; }
  .brand .emblem { width: 48px; height: 48px; }
  .brand .tagline { display: none; }
  .masthead .account .who { display: none; }
}

/* Thanh điều hướng chính */
.mainnav { background: linear-gradient(180deg, var(--red-600), var(--red-700)); border-bottom: 3px solid var(--gold-500); box-shadow: 0 2px 8px rgba(120, 20, 10, .18); position: sticky; top: 0; z-index: 50; }
.mainnav .container { display: flex; align-items: center; gap: 4px; min-height: 48px; }
.mainnav .links { display: flex; align-items: stretch; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.mainnav .links::-webkit-scrollbar { display: none; }
.mainnav a.nav {
  display: inline-flex; align-items: center; gap: 7px; padding: 0 14px; min-height: 48px; color: #fff; font-weight: 500; font-size: 14.5px;
  white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -3px; text-decoration: none;
}
.mainnav a.nav:hover { background: rgba(255, 255, 255, .1); }
.mainnav a.nav.active { background: rgba(0, 0, 0, .14); border-bottom-color: var(--gold-400); color: #fff7dc; }
.mainnav .quick { margin-left: auto; display: flex; }
.mainnav .quick .input { height: 34px; width: 240px; border: 0; border-radius: var(--r-sm) 0 0 var(--r-sm); }
.mainnav .quick .btn { height: 34px; border-radius: 0 var(--r-sm) var(--r-sm) 0; }
@media (max-width: 900px) { .mainnav .quick { display: none; } }

main.opac-main { min-height: 60vh; padding: 26px 0 48px; }

/* Hero trang chủ */
.hero {
  position: relative; padding: 46px 0 40px; margin-top: -26px; margin-bottom: 30px; overflow: hidden;
  background:
    linear-gradient(115deg, rgba(255, 250, 235, .96) 30%, rgba(255, 244, 214, .88)),
    repeating-linear-gradient(90deg, #d8b979 0 10px, #b78a3c 10px 13px, #c99d52 13px 26px, #8f1b14 26px 30px, #d8b979 30px 44px, #6f5a2a 44px 47px, #e3c68a 47px 60px);
  border-bottom: 1px solid var(--line);
}
.hero::before {
  content: ''; position: absolute; inset: auto 0 0 0; height: 16px;
  background: linear-gradient(180deg, #8a5a2b, #6b4420); opacity: .9;
}
.hero .container { position: relative; }
.hero h1 { font-size: 2.2rem; margin-bottom: 8px; }
.hero .lead { font-size: 1.05rem; color: var(--ink-2); max-width: 760px; margin-bottom: 22px; }
.searchbar { display: flex; background: #fff; border-radius: 14px; box-shadow: 0 10px 30px -12px rgba(120, 60, 10, .45); border: 2px solid var(--gold-400); overflow: hidden; max-width: 900px; }
.searchbar .select { width: 190px; border: 0; border-right: 1px solid var(--line); border-radius: 0; height: 58px; font-weight: 500; background-color: #fffaf0; }
.searchbar .input { border: 0; border-radius: 0; height: 58px; font-size: 17px; padding: 0 18px; }
.searchbar .input:focus, .searchbar .select:focus { box-shadow: none; }
.searchbar .btn { height: 58px; border-radius: 0; padding: 0 26px; font-size: 16px; border: 0; }
@media (max-width: 640px) {
  .searchbar { flex-wrap: wrap; }
  .searchbar .select { width: 100%; height: 44px; border-right: 0; border-bottom: 1px solid var(--line); }
  .searchbar .input { height: 50px; flex: 1; }
  .searchbar .btn { height: 50px; padding: 0 16px; }
  .hero h1 { font-size: 1.6rem; }
}
.hero .hints { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 14px; }

/* Lưới sách */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px 18px; }
.book-card { display: flex; flex-direction: column; gap: 8px; color: inherit; text-decoration: none !important; }
.book-card .cover { transition: transform .18s, box-shadow .18s; }
.book-card:hover .cover { transform: translateY(-4px) rotate(-.6deg); box-shadow: 0 2px 3px rgba(0,0,0,.15), 8px 14px 24px -10px rgba(60, 30, 5, .55); }
.book-card .t { font-family: var(--serif); font-weight: 700; color: var(--ink); line-height: 1.3; font-size: 15px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-card:hover .t { color: var(--red-700); }
.book-card .a { font-size: 13px; color: var(--muted); }

/* Kết quả tìm kiếm */
.result { display: grid; grid-template-columns: 92px 1fr auto; gap: 18px; padding: 18px 20px; border-bottom: 1px solid var(--line-2); }
.result:last-child { border-bottom: 0; }
.result .title { font-family: var(--serif); font-size: 1.15rem; font-weight: 700; color: var(--red-800); line-height: 1.3; }
.result .title a { color: inherit; }
.result .num { font-family: var(--mono); color: var(--faint); font-size: 12px; }
.result .acts { display: flex; flex-direction: column; gap: 6px; align-items: stretch; min-width: 150px; }
@media (max-width: 760px) {
  .result { grid-template-columns: 70px 1fr; }
  .result .acts { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; min-width: 0; }
}
.facets .facet-group { border-bottom: 1px solid var(--line-2); padding: 12px 16px; }
.facets .facet-group:last-child { border-bottom: 0; }
.facets h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--red-800); margin: 0 0 8px; }
.facets .facet { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 14px; cursor: pointer; color: var(--ink-2); }
.facets .facet:hover { color: var(--red-700); }
.facets .facet .c { margin-left: auto; font-size: 12px; color: var(--faint); background: var(--paper-2); border-radius: 999px; padding: 0 7px; }
.facets .facet input { accent-color: var(--red-700); }

.layout-2 { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 22px; align-items: start; }
.layout-2.side-right { grid-template-columns: minmax(0, 1fr) 320px; }
@media (max-width: 960px) { .layout-2, .layout-2.side-right { grid-template-columns: 1fr; } }

/* Tài khoản */
.account-nav a { display: flex; align-items: center; gap: 10px; padding: 10px 14px; color: var(--ink-2); border-left: 3px solid transparent; font-weight: 500; }
.account-nav a:hover { background: var(--gold-50); text-decoration: none; }
.account-nav a.active { background: var(--red-50); color: var(--red-800); border-left-color: var(--red-700); font-weight: 600; }
.account-nav .badge { margin-left: auto; }

/* Tin tức */
.news-item { padding: 14px 0; border-bottom: 1px dashed var(--line); }
.news-item:last-child { border-bottom: 0; }
.news-item .date { font-size: 12.5px; color: var(--gold-700); font-weight: 600; }
.news-item .t { font-family: var(--serif); font-weight: 700; color: var(--ink); margin: 2px 0 4px; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }

/* Chân trang */
.footer { background: linear-gradient(180deg, var(--red-900), #4d0f0b); color: #f3dcc0; border-top: 4px solid var(--gold-500); font-size: 14px; }
.footer .container { padding-top: 32px; padding-bottom: 20px; }
.footer h4 { color: var(--gold-400); font-family: var(--serif); font-size: 1.05rem; margin-bottom: 10px; }
.footer a { color: #ffe3a3; }
.footer .cols { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 28px; }
.footer .bottom { border-top: 1px solid rgba(255, 220, 160, .18); margin-top: 22px; padding-top: 14px; font-size: 12.5px; color: #d8b99a; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer .line { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 6px; }
.footer .line svg { color: var(--gold-400); margin-top: 3px; flex: none; }
@media (max-width: 760px) { .footer .cols { grid-template-columns: 1fr; } }

/* Trang đăng nhập */
.auth-wrap { max-width: 440px; margin: 10px auto; }
.auth-wrap .card { border-top: 5px solid var(--red-700); }

/* =====================================================================
   PHÂN HỆ OPAC — tra cứu, chi tiết, đặt mượn, tài khoản bạn đọc
   ===================================================================== */
@media (max-width: 720px) { .hide-sm { display: none !important; } }
@media (max-width: 480px) { .hide-xs { display: none !important; } }
.container.narrow { max-width: 900px; }
.is-loading { opacity: .55; pointer-events: none; transition: opacity .15s; }
code { font-family: var(--mono); font-size: .9em; background: var(--paper-2); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 5px; }
ul.reasons, ul.plain-list { margin: 4px 0 0; padding-left: 18px; }
ol.steps { margin: 4px 0 0; padding-left: 20px; }
ol.steps li { margin-bottom: 3px; }
.label.mb-1 { display: block; }

/* Bảng trong thẻ, bảng co giãn thành thẻ trên màn hình hẹp */
.table-wrap.flat { border: 0; border-radius: 0; border-top: 1px solid var(--line-2); }
.card > .table-wrap.flat:last-child { border-radius: 0 0 var(--r-lg) var(--r-lg); }
.table-wrap.flat > .table th:first-child { border-top-left-radius: 0; }
.table tr.row-success td { background: #f3fbf5; }
.table tr.row-danger td { background: #fff6f5; }
.table tr.row-disabled td { color: var(--faint); }
.table tr.row-void td { color: var(--faint); text-decoration: line-through; text-decoration-color: rgba(0,0,0,.25); }
.table tr.clickable { cursor: pointer; }
.table tfoot td { background: var(--surface-2); border-top: 2px solid var(--line); padding: 10px 12px; }
.table td.doc-cell { min-width: 230px; }
@media (max-width: 640px) {
  .table.rtable thead { display: none; }
  .table.rtable, .table.rtable tbody, .table.rtable tfoot { display: block; width: 100%; }
  .table.rtable tr { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line-2); }
  .table.rtable tbody tr:last-child { border-bottom: 0; }
  .table.rtable td { display: flex; gap: 10px; padding: 3px 0; border: 0; text-align: left !important; min-width: 0 !important; }
  .table.rtable td[data-label]::before { content: attr(data-label); flex: 0 0 38%; color: var(--muted); font-size: 12.5px; font-weight: 600; }
  .table.rtable td > * { min-width: 0; }
  .table.rtable td.num { justify-content: flex-start; }
  .table.rtable tfoot td { display: inline-block; border: 0; background: none; padding: 4px 0; }
  .table.rtable td.sel-cell { float: right; }
}

/* ---------- Trang kết quả tra cứu ---------- */
.refine { padding: 14px 16px; margin-bottom: 18px; border-top: 4px solid var(--gold-500); }
.refine-row { display: flex; gap: 8px; }
.refine-row .select { width: 200px; flex: none; }
.refine-opts { margin-top: 10px; gap: 16px; }
@media (max-width: 640px) {
  .refine-row { flex-wrap: wrap; }
  .refine-row .select { width: 100%; }
  .refine-row .input { flex: 1 1 60%; }
}
.results-head { padding: 2px 2px 0; }
.results-count { font-size: 1.02rem; line-height: 1.7; }
.terms .term { white-space: normal; }
.bool-op { display: inline-block; font-size: 11.5px; font-weight: 700; letter-spacing: .04em; color: #fff; background: var(--red-700); border-radius: 4px; padding: 0 6px; line-height: 1.7; vertical-align: 1px; }
.applied { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.applied .chip.active .x { margin-left: 2px; }
.results-toolbar { gap: 10px; }
.sort-select { width: auto; min-width: 210px; }
@media (max-width: 480px) { .sort-select { min-width: 0; flex: 1; } }
.results-list { overflow: hidden; }
.result.selected { background: var(--gold-50); }
.result-cover { display: flex; flex-direction: column; gap: 6px; }
.result-check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.result-check input { width: 16px; height: 16px; accent-color: var(--red-700); margin: 0; }
.result .title { margin: 0 0 4px; }
.result .subtitle { font-weight: 500; color: var(--ink-2); font-size: .92em; }
.result .meta { display: flex; gap: 6px; align-items: flex-start; font-size: 14px; color: var(--ink-2); margin-top: 2px; }
.result .meta svg { flex: none; margin-top: 3px; color: var(--gold-700); }
.result .meta-badges { margin-top: 6px; }
.result-body { min-width: 0; }
.facets-toggle { display: none; width: 100%; justify-content: space-between; }
.facets .card-head { padding: 12px 16px; }
.facets .facet span.grow { overflow-wrap: anywhere; }
.facet-more { margin-top: 4px; padding: 0; height: auto; font-size: 13px; }
@media (max-width: 960px) {
  .facets-toggle { display: inline-flex; margin-bottom: 10px; }
  .facets-wrap:not(.open) .facets { display: none; }
}

/* ---------- Tra cứu nâng cao ---------- */
.adv-rows { display: flex; flex-direction: column; gap: 8px; }
.adv-row { display: grid; grid-template-columns: 150px 210px minmax(0, 1fr) 34px; gap: 8px; align-items: center; }
@media (max-width: 720px) {
  .adv-row { grid-template-columns: 1fr 1fr 34px; padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
  .adv-row .adv-val { grid-column: 1 / 3; grid-row: 2; }
  .adv-row .btn { grid-column: 3; grid-row: 1; }
}
.limit-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px 22px; }
.limit-group .label { display: block; margin-bottom: 6px; }
.limit-options { display: flex; flex-wrap: wrap; gap: 6px; }
.limit-opt { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 13px; cursor: pointer; user-select: none; }
.limit-opt input { accent-color: var(--red-700); margin: 0; }
.limit-opt:hover { border-color: var(--gold-500); }
.limit-opt.on { background: var(--red-50); border-color: #e7b3ab; color: var(--red-800); font-weight: 600; }
legend .badge { margin-left: 6px; vertical-align: 2px; }

/* ---------- Chi tiết tài liệu ---------- */
.detail-hero { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 26px; padding: 22px 24px; border-top: 4px solid var(--red-700); background: linear-gradient(180deg, #fffdf8, #fff 60%); }
.detail-cover .cover.lg { width: 100%; }
.detail-title { font-size: 1.8rem; margin: 10px 0 6px; color: var(--red-900); }
.detail-title .sub { font-weight: 500; color: var(--ink-2); font-size: .72em; }
.detail-hero .resp { font-family: var(--serif); font-style: italic; color: var(--ink-2); margin-bottom: 8px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 14px; color: var(--ink-2); }
.detail-meta svg { color: var(--gold-700); }
.detail-summary { margin: 12px 0; padding-left: 12px; border-left: 3px solid var(--gold-400); color: var(--ink-2); }
.detail-avail { margin-top: 12px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
@media (max-width: 720px) {
  .detail-hero { grid-template-columns: 1fr; padding: 18px; gap: 14px; }
  .detail-cover { display: flex; justify-content: center; }
  .detail-cover .cover.lg { width: 150px; }
  .detail-title { font-size: 1.45rem; }
}
.holdings-sum { font-size: 14px; }
.holdings .tabs { margin-top: -4px; }
.related { display: flex; flex-direction: column; gap: 12px; }
.related-item { display: flex; gap: 12px; align-items: flex-start; color: inherit; text-decoration: none !important; }
.related-item .cover.sm { width: 44px; flex: none; }
.related-item .t { display: block; font-family: var(--serif); font-weight: 700; line-height: 1.3; color: var(--ink); }
.related-item .grow { display: flex; flex-direction: column; }
.related-item:hover .t { color: var(--red-700); }
.place { padding-bottom: 8px; border-bottom: 1px dashed var(--gold-200); }
.place:last-child { border-bottom: 0; padding-bottom: 0; }
.tag-chip { padding-right: 6px; }
.tag-chip .x { border: 0; background: transparent; cursor: pointer; padding: 0 2px; color: inherit; display: inline-flex; }
.tag-chip.s0 { border-style: dashed; border-color: var(--gold-500); }
.tag-chip.s-1 { border-color: #f0bdb6; color: var(--red-800); }

/* ---------- Đặt mượn ---------- */
.hold-biblio { display: flex; gap: 14px; align-items: flex-start; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); }
.hold-biblio .cover.sm { width: 60px; flex: none; }
.level-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 560px) { .level-options { grid-template-columns: 1fr; } }
.level-opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; cursor: pointer; }
.level-opt input { accent-color: var(--red-700); margin-top: 4px; }
.level-opt > span { display: flex; flex-direction: column; }
.level-opt.on { border-color: var(--red-600); background: var(--red-50); box-shadow: 0 0 0 1px var(--red-600) inset; }
.level-opt.disabled { opacity: .5; cursor: not-allowed; }
.hold-success { text-align: center; padding: 18px 8px; }
.hold-success h3 { margin: 10px 0 8px; font-size: 1.35rem; }
.hold-foot { padding-top: 4px; }

/* ---------- Giá sách ảo, tag, xuất dữ liệu ---------- */
.shelf-pick { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r); }
.shelf-pick li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.shelf-pick li:last-child { border-bottom: 0; }
.shelf-new { border-top: 1px dashed var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.export-opt { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; cursor: pointer; font: inherit; color: inherit; }
.export-opt:hover { border-color: var(--gold-500); background: var(--gold-50); }
.export-opt .grow { display: flex; flex-direction: column; }
.shelves-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1100px) { .shelves-layout { grid-template-columns: 1fr; } }
.shelf-list { padding: 6px; display: flex; flex-direction: column; gap: 2px; }
@media (max-width: 1100px) { .shelf-list { flex-direction: row; overflow-x: auto; } .shelf-item { min-width: 190px; } }
.shelf-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px 12px; border: 0; border-left: 3px solid transparent; border-radius: 6px; background: transparent; cursor: pointer; font: inherit; color: var(--ink-2); }
.shelf-item .grow { display: flex; flex-direction: column; min-width: 0; }
.shelf-item:hover { background: var(--gold-50); }
.shelf-item.active { background: var(--red-50); color: var(--red-800); border-left-color: var(--red-700); }
.shelf-item svg { flex: none; color: var(--gold-700); }
.shelf-head { flex-wrap: wrap; }
.share-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 20px; background: var(--gold-50); border-bottom: 1px solid var(--gold-200); }
.share-bar a { overflow-wrap: anywhere; }
.flat-toolbar { border-radius: 0; border-left: 0; border-right: 0; border-top: 0; }
.shelf-view .results-list .result:last-child { border-radius: 0 0 var(--r-lg) var(--r-lg); }
.shelf-links { list-style: none; margin: 0; padding: 0; }
.shelf-links li { display: flex; flex-direction: column; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.shelf-links li:last-child { border-bottom: 0; }

/* ---------- Tài khoản bạn đọc ---------- */
.account-layout { grid-template-columns: 270px minmax(0, 1fr); }
.account-side { overflow: hidden; position: sticky; top: 64px; }
.account-id { display: flex; align-items: center; gap: 12px; padding: 16px; border-bottom: 1px solid var(--line-2); background: linear-gradient(135deg, var(--gold-50), #fff); }
.avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 2px solid var(--gold-400); flex: none; background: var(--paper-2); }
.avatar.xl { width: 92px; height: 92px; border-width: 3px; }
.account-nav { padding: 6px 0; }
.account-nav a.logout { color: var(--red-700); border-top: 1px solid var(--line-2); margin-top: 4px; }
@media (max-width: 960px) {
  .account-side { position: static; }
  .account-nav { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .account-nav a.logout { border-top: 0; margin-top: 0; }
}
.patron-head { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.patron-head h2 { font-size: 1.35rem; }
.patron-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 18px; }
.patron-facts > div { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.patron-facts .muted { font-size: 12.5px; }
.patron-facts .badge { align-self: flex-start; }
.stat-row .stat { color: inherit; text-decoration: none !important; transition: border-color .15s; }
a.stat:hover { border-color: var(--gold-500); }
.stat .val.money { font-size: 1.25rem; }
.renew-cell { min-width: 150px; }
.renew-reason { max-width: 230px; }
.hold-mini { list-style: none; margin: 0; padding: 0; }
.hold-mini li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 14px; padding: 12px 20px; border-top: 1px solid var(--line-2); }
.hold-mini li > a { grid-column: 1; }
.hold-mini li > span { grid-column: 1; }
.hold-mini li > .hold-status { grid-column: 2; grid-row: 1 / 3; text-align: right; }
@media (max-width: 560px) { .hold-mini li { grid-template-columns: 1fr; } .hold-mini li > .hold-status { grid-column: 1; grid-row: auto; text-align: left; } }
.hold-status { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.hold-mini .hold-status { align-items: flex-end; }
@media (max-width: 560px) { .hold-mini .hold-status { align-items: flex-start; } }
.hold-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.hold-legend .badge { margin-right: 4px; }
.actions-cell .row { flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 6px; }
@media (max-width: 640px) { .actions-cell .row { flex-direction: row; flex-wrap: wrap; } }
.profile-card { display: flex; gap: 22px; align-items: flex-start; }
@media (max-width: 560px) { .profile-card { flex-direction: column; } }
.narrow-card { max-width: 600px; }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: #d6cdbb; border-radius: 999px; transition: background .15s; }
.switch span::before { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + span { background: var(--green-700); }
.switch input:checked + span::before { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Đăng nhập / khôi phục mật khẩu ---------- */
.auth-head { text-align: center; margin-bottom: 18px; }
.auth-head h1 { font-size: 1.45rem; margin: 10px 0 6px; }
.auth-ico { width: 62px; height: 62px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--red-50); color: var(--red-700); border: 2px solid var(--gold-200); }
.auth-help { text-align: center; margin-top: 14px; }
.pw-toggle { width: 50px; padding: 0; }
.auth-wrap .btn-lg { width: 100%; }
.auth-wrap .input-group .btn-lg { width: 50px; }

/* ---------- Sách mới ---------- */
.na-filters { gap: 8px; }
.na-grid .cover-wrap { position: relative; }
.avail-dot { position: absolute; top: 8px; right: 8px; width: 13px; height: 13px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.avail-dot.on { background: var(--green-600); }
.avail-dot.off { background: var(--gold-500); }
.na-meta { gap: 6px; }
.na-meta .badge { font-size: 11.5px; }

/* ---------- Giới thiệu ---------- */
.about-hero { background: linear-gradient(115deg, #fffaf0 40%, var(--gold-50)); border-top: 4px solid var(--red-700); }
.about-hero .card-body { gap: 20px; }
@media (max-width: 560px) { .about-hero .card-body { flex-wrap: wrap; } }
.hours { white-space: pre-line; font-family: var(--serif); font-size: 1.08rem; font-weight: 600; color: var(--red-900); line-height: 1.8; }
.contact > div { display: flex; gap: 8px; align-items: flex-start; }
.contact svg, .branch-card .line svg { color: var(--gold-700); flex: none; margin-top: 3px; }
.branch-card .line { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.branch-card .card-head { flex-wrap: wrap; }
.holiday-list { list-style: none; margin: 0; padding: 0; }
.holiday-list li { display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--gold-200); font-size: 14px; }
.holiday-list li:last-child { border-bottom: 0; }
.holiday-list .date { font-family: var(--mono); color: var(--red-700); font-weight: 600; flex: none; }
.service .svc-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--red-50); color: var(--red-700); flex: none; }

/* ---------- In ấn ---------- */
@media print {
  main.opac-main { padding: 0; }
  .container { max-width: none; padding: 0; }
  .layout-2, .layout-2.side-right, .account-layout { display: block; }
  .detail-page aside, .facets-wrap, .account-side, .toolbar, .pagination, .acts, .detail-actions, .tabs, .refine, .breadcrumbs { display: none !important; }
  .detail-hero { grid-template-columns: 120px 1fr; border: 0; padding: 0 0 12px; background: none; }
  .cover { box-shadow: none; }
  .card { break-inside: avoid; margin-bottom: 12px; }
  a { color: inherit; text-decoration: none; }
  .table-wrap { overflow: visible; }
}
/* Hàng flex không xuống dòng nhưng chữ bên trong vẫn tự ngắt dòng (khác lớp .nowrap chung) */
.row.nw { flex-wrap: nowrap; }
.row.nw > .grow, .row.nw > div:last-child { min-width: 0; }
.table td.num, .table th.num { white-space: nowrap; }
/* Màn hình hẹp: một cột, không để nội dung rộng (bảng) kéo giãn lưới */
@media (max-width: 960px) {
  .layout-2, .layout-2.side-right, .account-layout { grid-template-columns: minmax(0, 1fr); }
  .layout-2 > * { min-width: 0; }
}

/* Dải công vụ trên điện thoại: gọn một dòng */
@media (max-width: 520px) {
  .govbar { font-size: 11.5px; }
  .govbar .container { min-height: 30px; }
  .govbar .left > svg, .govbar .right svg { display: none; }
  .govbar .upper { letter-spacing: .02em; }
  .govbar .right a { white-space: nowrap; }
}
@media (max-width: 440px) {
  .govbar .right { display: none; }
  .govbar .left { flex-wrap: nowrap; white-space: nowrap; }
}
