/* ==========================================================================
   DTT-Ebook — giao diện hiện đại cho Calibre-Web
   Sidebar trái + thanh tìm kiếm + lưới ảnh bìa. Nạp sau style.css.
   ========================================================================== */

:root {
  --cw-bg: #f6f6f8;
  --cw-surface: #ffffff;
  --cw-sidebar: #fbfbfc;
  --cw-text: #1d1d1f;
  --cw-text-2: #6e6e73;
  --cw-text-3: #a1a1a6;
  --cw-line: #e8e8ed;
  --cw-hover: #f0f0f3;
  --cw-accent: #d6342b;
  --cw-accent-soft: #fdecea;
  --cw-kindle: #1a7f64;
  --cw-radius: 12px;
  --cw-radius-sm: 8px;
  --cw-shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.06);
  --cw-shadow-cover: 0 2px 4px rgba(0,0,0,.12), 0 10px 22px -8px rgba(0,0,0,.28);
  --cw-sidebar-w: 248px;
  --cw-font: "Be Vietnam Pro", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- nền tảng ---------- */
body.cw-modern {
  background: var(--cw-bg);
  color: var(--cw-text);
  font-family: var(--cw-font);
  font-size: 14px;
  margin: 0;
  -webkit-font-smoothing: antialiased;
}
.cw-modern a { color: inherit; }
.cw-modern a:hover, .cw-modern a:focus { color: var(--cw-accent); text-decoration: none; }
.cw-modern .cw-muted { color: var(--cw-text-3); }
.cw-modern h1, .cw-modern h2, .cw-modern h3, .cw-modern h4 { font-family: var(--cw-font); color: var(--cw-text); }
.cw-modern .row-fluid.text-center { margin-top: 0; }

.cw-app { display: flex; min-height: 100vh; }

/* ---------- sidebar ---------- */
.cw-sidebar {
  position: sticky; top: 0;
  flex: 0 0 var(--cw-sidebar-w);
  width: var(--cw-sidebar-w);
  height: 100vh;
  display: flex; flex-direction: column;
  background: var(--cw-sidebar);
  border-right: 1px solid var(--cw-line);
  z-index: 1030;
}
.cw-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 20px 16px;
  font-weight: 700; font-size: 19px; letter-spacing: -.01em;
  color: var(--cw-text) !important;
}
.cw-logo {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 auto;
  display: block; object-fit: contain;
  box-shadow: 0 3px 8px rgba(214,52,43,.35);
}
.cw-top-logo { display: none; }
.cw-brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cw-nav { flex: 1; overflow-y: auto; padding: 4px 12px 16px; }
/* nhóm menu thu gọn / sổ xuống */
.cw-nav-sec { margin-bottom: 4px; }
.cw-nav-head {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: var(--cw-radius-sm);
  background: transparent; color: var(--cw-text); text-align: left;
  font-size: 14.5px; font-weight: 600; cursor: pointer;
}
.cw-nav-head:hover { background: var(--cw-hover); }
.cw-nav-head .glyphicon { width: 18px; text-align: center; color: var(--cw-text-2); font-size: 14px; top: 0; }
.cw-nav-sec.open > .cw-nav-head .glyphicon { color: var(--cw-accent); }
.cw-nav-count {
  min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--cw-hover);
  font-size: 11.5px; font-weight: 600; color: var(--cw-text-2); text-align: center;
}
.cw-chev {
  width: 8px; height: 8px; margin-right: 4px; flex: 0 0 auto;
  border-right: 2px solid var(--cw-text-3); border-bottom: 2px solid var(--cw-text-3);
  transform: rotate(-45deg); transition: transform .25s ease;
}
.cw-nav-sec.open > .cw-nav-head .cw-chev { transform: rotate(45deg); }
.cw-nav-collapse {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows .28s ease;
}
.cw-nav-sec.open > .cw-nav-collapse { grid-template-rows: 1fr; }
.cw-nav-collapse > .cw-nav-group {
  min-height: 0; overflow: hidden; padding-left: 14px;
  opacity: 0; transform: translateY(-4px); transition: opacity .2s ease, transform .2s ease;
}
.cw-nav-sec.open > .cw-nav-collapse > .cw-nav-group { opacity: 1; transform: none; }
.cw-nav-collapse .cw-nav-item { font-size: 14px; padding: 7px 10px; }
.cw-nav-collapse .cw-nav-item.active { margin: 2px 0; }

/* tải trang tiếp khi cuộn */
.cw-loader { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 28px 0; color: var(--cw-text-2); }
.cw-spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--cw-line); border-top-color: var(--cw-accent);
  animation: cw-spin .8s linear infinite;
}
@keyframes cw-spin { to { transform: rotate(360deg); } }
.cw-infinite .cw-pagination { display: none; }

/* toast có liên kết */
.cw-toast a { color: #fff !important; text-decoration: underline; font-weight: 600; }
.cw-toast .cw-toast-sub { display: block; margin-top: 4px; font-weight: 400; opacity: .9; font-size: 13px; }
.cw-toast.show { pointer-events: auto; }
.cw-nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px; margin: 1px 0;
  border-radius: var(--cw-radius-sm);
  color: var(--cw-text) !important; font-size: 14.5px;
  transition: background .12s;
}
.cw-nav-item .glyphicon { width: 18px; text-align: center; color: var(--cw-text-2); font-size: 14px; top: 0; }
.cw-nav-item:hover { background: var(--cw-hover); }
.cw-nav-item.active { background: var(--cw-surface); box-shadow: var(--cw-shadow); font-weight: 600; }
.cw-nav-item.active .glyphicon { color: var(--cw-accent); }
.cw-nav-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cw-nav-tag { font-size: 11px; color: var(--cw-text-3); }
.cw-nav-muted { color: var(--cw-text-2) !important; }

.cw-sidebar-foot {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 14px; border-top: 1px solid var(--cw-line);
}
.cw-user { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--cw-text) !important; }
.cw-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--cw-accent-soft); color: var(--cw-accent); font-weight: 700;
}
.cw-user-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }

/* ---------- main + topbar ---------- */
.cw-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cw-topbar {
  position: sticky; top: 0; z-index: 1020;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 32px;
  background: rgba(246,246,248,.86);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
}
.cw-burger { display: none !important; }
.cw-search {
  flex: 1; max-width: 760px; position: relative; margin: 0;
}
.cw-search .glyphicon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--cw-text-3); }
.cw-search input {
  width: 100%; height: 44px;
  padding: 0 18px 0 44px;
  border: 1px solid var(--cw-line); border-radius: 999px;
  background: var(--cw-surface); color: var(--cw-text);
  font-size: 15px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.cw-search input:focus { border-color: #d0d0d6; box-shadow: 0 0 0 4px rgba(214,52,43,.08); }
.cw-top-actions {
  margin-left: auto; display: flex; align-items: center; gap: 4px;
  padding: 4px; border-radius: 999px; background: var(--cw-surface); border: 1px solid var(--cw-line);
}
.cw-top-actions:empty { display: none; }
.cw-upload { margin: 0; display: inline-flex; }

.cw-icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--cw-text) !important;
  cursor: pointer; padding: 0; position: relative;
}
.cw-icon-btn:hover { background: var(--cw-hover); }
.cw-icon-btn .glyphicon { top: 0; }
.cw-icon-btn.btn-file input[type=file] { cursor: pointer; }

.cw-content { padding: 8px 32px 48px; flex: 1; }
.cw-flash-anchor.navbar { min-height: 0; margin: 0; border: 0; display: block; height: 0; }
.cw-modern .alert { margin: 8px 32px; border-radius: var(--cw-radius-sm); border: 0; }

/* ---------- tiêu đề trang ---------- */
.cw-page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin: 10px 0 20px;
}
.cw-h1 { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin: 0; line-height: 1.2; }
.cw-sub { color: var(--cw-text-2); margin-top: 6px; font-size: 14px; }
.cw-head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cw-back { display: inline-flex; align-items: center; gap: 4px; color: var(--cw-text-2) !important; font-size: 13px; margin-top: 6px; }
.cw-back .glyphicon { font-size: 11px; top: 0; }

.cw-section { margin-bottom: 36px; }
.cw-section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.cw-section-head h2 { font-size: 19px; font-weight: 700; margin: 0; }
.cw-link { color: var(--cw-accent) !important; font-weight: 500; }

/* ---------- chip / nút ---------- */
.cw-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--cw-line);
  background: var(--cw-surface); color: var(--cw-text) !important;
  font-size: 13.5px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.cw-chip:hover { background: var(--cw-hover); }
.cw-chip.active { background: var(--cw-text); border-color: var(--cw-text); color: #fff !important; }
.cw-chip .glyphicon { top: 0; font-size: 12px; }

.cw-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 18px;
  border-radius: 10px; border: 1px solid var(--cw-line);
  background: var(--cw-surface); color: var(--cw-text) !important;
  font-size: 14.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .12s, transform .05s;
}
.cw-btn:hover { background: var(--cw-hover); }
.cw-btn:active { transform: translateY(1px); }
.cw-btn .glyphicon { top: 0; }
.cw-btn-primary { background: var(--cw-accent); border-color: var(--cw-accent); color: #fff !important; }
.cw-btn-primary:hover { background: #bf2c24; }
.cw-btn-kindle { background: var(--cw-kindle); border-color: var(--cw-kindle); color: #fff !important; }
.cw-btn-kindle:hover { background: #146a53; }
.cw-btn-ghost { background: transparent; border-style: dashed; color: var(--cw-text-2) !important; }
.cw-btn-sm { height: 34px; padding: 0 12px; font-size: 13px; font-weight: 500; }
.cw-btn-block { width: 100%; justify-content: center; }
.cw-btn-sub { font-weight: 400; opacity: .75; font-size: 12.5px; }

.cw-modern .dropdown-menu {
  border: 1px solid var(--cw-line); border-radius: var(--cw-radius-sm);
  box-shadow: 0 10px 30px rgba(0,0,0,.12); padding: 6px; min-width: 200px;
}
.cw-modern .dropdown-menu > li > a { border-radius: 6px; padding: 7px 10px; color: var(--cw-text); }
.cw-modern .dropdown-menu > li > a:hover { background: var(--cw-hover); color: var(--cw-text); }
.cw-modern .dropdown-menu > li > a .glyphicon { width: 18px; color: var(--cw-text-2); }
.cw-modern .dropdown-menu > .active > a,
.cw-modern .dropdown-menu > .active > a:hover { background: var(--cw-accent-soft); color: var(--cw-accent); }
.cw-modern .dropdown-menu .divider { margin: 5px 0; }
.cw-modern .dropdown-header { padding: 4px 10px; font-size: 11.5px; color: var(--cw-text-3); }

/* ---------- lưới sách ---------- */
.cw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 28px 26px;
}
.cw-row-scroll {
  grid-auto-flow: column; grid-auto-columns: 168px; grid-template-columns: none;
  overflow-x: auto; padding: 4px 4px 14px; margin: 0 -4px;
  scroll-snap-type: x proximity;
}
.cw-row-scroll > * { scroll-snap-align: start; }

.cw-card { display: flex; flex-direction: column; min-width: 0; color: var(--cw-text) !important; }
.cw-cover {
  position: relative; aspect-ratio: 2 / 3;
  border-radius: 6px; overflow: hidden;
  background: linear-gradient(135deg, #ececf0, #dcdce2);
  box-shadow: var(--cw-shadow-cover);
  transition: transform .18s ease, box-shadow .18s ease;
}
.cw-cover > a { display: block; width: 100%; height: 100%; }
.cw-cover img { width: 100%; height: 100%; object-fit: cover; display: block; max-height: none; border: 0; }
.cw-card:hover .cw-cover { transform: translateY(-3px); box-shadow: 0 4px 8px rgba(0,0,0,.12), 0 18px 30px -10px rgba(0,0,0,.35); }

.cw-badge-read, .cw-badge-audio {
  position: absolute; top: 8px; width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.95); font-size: 11px; box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.cw-badge-read { right: 8px; color: #1a7f37; }
.cw-badge-audio { left: 8px; color: var(--cw-text); }
.cw-badge-read .glyphicon, .cw-badge-audio .glyphicon { top: 0; }
.cw-count-badge {
  position: absolute; right: 8px; bottom: 8px; padding: 3px 9px; border-radius: 999px;
  background: rgba(0,0,0,.72); color: #fff; font-size: 12px; font-weight: 600;
}


.cw-card-meta { padding-top: 12px; min-width: 0; }
.cw-card-line { display: flex; align-items: center; justify-content: space-between; gap: 6px; height: 22px; }
.cw-fmt { color: var(--cw-accent); font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cw-menu .cw-icon-btn { width: 28px; height: 22px; border-radius: 6px; color: var(--cw-text-2) !important; }
.cw-dots { font-size: 9px; letter-spacing: 1px; }
.cw-card-title {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-top: 3px; font-size: 14.5px; font-weight: 600; line-height: 1.35; color: var(--cw-text) !important;
}
.cw-card-author, .cw-card-series {
  margin-top: 2px; font-size: 13px; color: var(--cw-text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cw-card-author a, .cw-card-series a { color: var(--cw-text-2) !important; }
.cw-card-author a:hover, .cw-card-series a:hover { color: var(--cw-accent) !important; }
.cw-sep { margin-right: 3px; }
.cw-more-authors { margin-left: 4px; color: var(--cw-text-3); }
.cw-card-rating { font-size: 12px; color: #d8d8dd; letter-spacing: 1px; margin-top: 2px; }
.cw-card-rating .on { color: #f5a623; }

/* ---------- danh sách thực thể (tác giả, bộ sách, ...) ---------- */
.cw-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.cw-toolbar-right { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.cw-filter { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.cw-filter .glyphicon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--cw-text-3); font-size: 12px; }
.cw-filter input {
  width: 100%; height: 36px; padding: 0 14px 0 34px;
  border: 1px solid var(--cw-line); border-radius: 999px; background: var(--cw-surface); outline: none;
}
.cw-filter input:focus { border-color: #d0d0d6; }

.cw-alpha { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 18px; }
.cw-alpha-btn {
  min-width: 32px; height: 30px; padding: 0 9px; border-radius: 8px;
  border: 0; background: transparent; color: var(--cw-text-2); font-weight: 600; font-size: 13px;
}
.cw-alpha-btn:hover { background: var(--cw-hover); color: var(--cw-text); }
.cw-alpha-btn.active { background: var(--cw-text); color: #fff; }

.cw-entity-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px;
}
.cw-entity {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; border-radius: var(--cw-radius);
  background: var(--cw-surface); border: 1px solid var(--cw-line);
  color: var(--cw-text) !important;
  transition: box-shadow .15s, border-color .15s, transform .1s;
}
.cw-entity:hover { border-color: transparent; box-shadow: var(--cw-shadow); transform: translateY(-1px); }
.cw-entity-avatar, .cw-entity-icon {
  flex: 0 0 44px; width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 17px;
}
.cw-entity-avatar { background: var(--cw-accent-soft); color: var(--cw-accent); }
.cw-entity-icon { border-radius: 12px; background: var(--cw-hover); color: var(--cw-text-2); font-size: 16px; }
.cw-entity-icon .glyphicon { top: 0; }
.cw-entity-avatar-lg { flex-basis: 64px; width: 64px; height: 64px; font-size: 26px; }
.cw-entity-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cw-entity-name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cw-entity-count { font-size: 12.5px; color: var(--cw-text-2); margin-top: 1px; }
.cw-entity-go { color: var(--cw-text-3); font-size: 11px; top: 0; }

/* màu avatar tác giả xoay vòng cho sinh động */
.cw-entity:nth-child(6n+2) .cw-entity-avatar { background: #e8f1fd; color: #2564c6; }
.cw-entity:nth-child(6n+3) .cw-entity-avatar { background: #e7f6ee; color: #1a7f4b; }
.cw-entity:nth-child(6n+4) .cw-entity-avatar { background: #fdf3e2; color: #b26a00; }
.cw-entity:nth-child(6n+5) .cw-entity-avatar { background: #f1ebfd; color: #6b3fc6; }
.cw-entity:nth-child(6n+6) .cw-entity-avatar { background: #e6f6f8; color: #0f7a8a; }

.cw-author-head { display: flex; align-items: center; gap: 16px; }
.cw-author-photo { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }
.cw-author-bio { max-width: 820px; color: var(--cw-text-2); margin: -6px 0 24px; line-height: 1.6; }

.cw-empty { text-align: center; padding: 60px 20px; color: var(--cw-text-2); }
.cw-empty .glyphicon { font-size: 36px; color: var(--cw-text-3); margin-bottom: 12px; }

/* ---------- trang chi tiết ---------- */
.cw-detail { display: flex; gap: 36px; align-items: flex-start; padding: 8px 0 24px; }
.cw-detail-cover { flex: 0 0 260px; position: sticky; top: 90px; }
.cw-detail-cover img { width: 100%; height: auto; border-radius: 8px; box-shadow: var(--cw-shadow-cover); display: block; max-height: none; }
.cw-detail-info { flex: 1; min-width: 0; }
.cw-detail-title { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 6px; line-height: 1.2; }
.cw-detail-author { font-size: 16px; color: var(--cw-text-2); margin-bottom: 6px; }
.cw-detail-author a { color: var(--cw-accent) !important; font-weight: 500; }
.cw-detail-series { color: var(--cw-text-2); }
.cw-detail-series a { font-weight: 500; text-decoration: underline; text-underline-offset: 2px; }
.cw-detail-rating { font-size: 16px; margin: 4px 0 8px; }
.cw-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0 10px; }
.cw-hint { font-size: 12.5px; color: var(--cw-text-2); margin: 0 0 18px; }
.cw-hint a { color: var(--cw-accent) !important; }

.cw-facts {
  display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px;
  margin: 22px 0; padding: 18px 20px;
  background: var(--cw-surface); border: 1px solid var(--cw-line); border-radius: var(--cw-radius);
}
.cw-facts:empty { display: none; }
.cw-facts dt { font-weight: 500; color: var(--cw-text-2); }
.cw-facts dd { margin: 0; }
.cw-pill {
  display: inline-block; margin: 0 6px 6px 0; padding: 3px 10px; border-radius: 999px;
  background: var(--cw-hover); font-size: 12.5px; font-weight: 500;
}
.cw-pill-link:hover { background: var(--cw-accent-soft); }

.cw-toggles { display: flex; gap: 20px; flex-wrap: wrap; margin: 0 0 18px; }
.cw-toggles form { margin: 0; }
.cw-switch { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; margin: 0; }
.cw-switch input { width: 16px; height: 16px; margin: 0; accent-color: var(--cw-accent); }

.cw-desc h3 { font-size: 17px; font-weight: 700; margin: 8px 0 10px; }
.cw-desc-body { line-height: 1.7; color: #333; max-width: 760px; }
.cw-modern .more-stuff { margin-top: 24px; display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-start; }
.cw-modern .more-stuff .btn-toolbar { margin: 0; }

/* chi tiết trong modal */
.cw-modern .modal-content { border-radius: 16px; border: 0; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.cw-modern .modal-header { border-bottom-color: var(--cw-line); }
.cw-modern .modal-footer { border-top-color: var(--cw-line); }
.cw-modern #bookDetailsModal .modal-body { padding: 20px 24px; }
.cw-modern #bookDetailsModal .container-fluid { padding: 0; }
.cw-modern #bookDetailsModal .cw-detail-cover { flex-basis: 220px; position: static; }
.cw-modern #bookDetailsModal .cw-detail-title { font-size: 25px; }
@media (min-width: 992px) { .cw-modern #bookDetailsModal .modal-lg { width: 960px; } }

/* OPDS */
.cw-copy { display: flex; gap: 8px; }
.cw-copy input {
  flex: 1; min-width: 0; height: 42px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--cw-line); background: var(--cw-bg); font-family: monospace;
}

/* phân trang */
.cw-pagination { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 36px 0 0; padding: 0; }
.cw-pagination > li > a {
  float: none; display: inline-flex; min-width: 38px; height: 38px; align-items: center; justify-content: center;
  margin: 0 !important; border-radius: 10px !important; border: 1px solid var(--cw-line);
  color: var(--cw-text); background: var(--cw-surface);
}
.cw-pagination > li > a:hover { background: var(--cw-hover); color: var(--cw-text); }
.cw-pagination > .active > a, .cw-pagination > .active > a:hover {
  background: var(--cw-text); border-color: var(--cw-text); color: #fff;
}

/* toast */
.cw-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  max-width: min(92vw, 520px); padding: 12px 18px; border-radius: 12px;
  background: #1d1d1f; color: #fff; font-weight: 500; box-shadow: 0 12px 30px rgba(0,0,0,.3);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 2000;
}
.cw-toast.show { opacity: 1; transform: translate(-50%, 0); }
.cw-toast.danger { background: #b3261e; }
.cw-toast.success { background: #1a7f4b; }

/* các trang quản trị / form cũ vẫn dùng bootstrap: làm mềm chút */
.cw-modern .cw-content > .discover > h2, .cw-modern .cw-content > h1, .cw-modern .cw-content > h2 { font-weight: 700; letter-spacing: -.01em; }
.cw-modern .btn { border-radius: 8px; }
.cw-modern .btn-primary { background: var(--cw-accent); border-color: var(--cw-accent); }
.cw-modern .btn-primary:hover, .cw-modern .btn-primary:focus, .cw-modern .btn-primary.active { background: #bf2c24; border-color: #bf2c24; }
.cw-modern .form-control { border-radius: 8px; box-shadow: none; }
.cw-modern .form-control:focus { border-color: #d0d0d6; box-shadow: 0 0 0 3px rgba(214,52,43,.1); }

/* ---------- responsive ---------- */
@media (max-width: 991px) {
  .cw-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.2);
  }
  .cw-sidebar-open .cw-sidebar { transform: none; }
  .cw-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1025;
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .cw-sidebar-open .cw-backdrop { opacity: 1; pointer-events: auto; }
  .cw-sidebar-open { overflow: hidden; }
  .cw-burger { display: inline-flex !important; flex: 0 0 36px; }
  .cw-top-logo { display: inline-flex; flex: 0 0 auto; }
  .cw-top-logo .cw-logo { width: 32px; height: 32px; box-shadow: none; }
  .cw-topbar { padding: 10px 16px; gap: 8px; }
  .cw-content { padding: 4px 16px 40px; }
  .cw-modern .alert { margin: 8px 16px; }
}
@media (max-width: 640px) {
  .cw-h1 { font-size: 24px; }
  .cw-search input { height: 40px; font-size: 15px; }
  .cw-top-actions { padding: 2px; }
  .cw-top-actions .cw-icon-btn { width: 32px; height: 32px; }
  #advanced_search { display: none; }
  .cw-grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 22px 14px; }
  .cw-row-scroll { grid-auto-columns: 128px; }
  .cw-card-title { font-size: 13.5px; }
  .cw-entity-grid { grid-template-columns: 1fr; }
  .cw-filter { max-width: none; flex-basis: 100%; }
  .cw-toolbar-right { margin-left: 0; }
  .cw-detail { flex-direction: column; gap: 18px; }
  .cw-detail-cover, .cw-modern #bookDetailsModal .cw-detail-cover { flex: none; position: static; width: 170px; margin: 0 auto; }
  .cw-detail-title { font-size: 23px; text-align: center; }
  .cw-detail-author, .cw-detail-series, .cw-detail-rating { text-align: center; }
  .cw-actions { justify-content: center; }
  .cw-actions .cw-btn, .cw-actions .btn-group { flex: 1 1 100%; }
  .cw-actions .btn-group > .cw-btn { width: 100%; justify-content: center; }
  .cw-actions > .cw-btn { justify-content: center; }
  .cw-facts { grid-template-columns: 1fr; gap: 2px 0; }
  .cw-facts dd { margin-bottom: 10px; }
}

/* ---------- đăng nhập ---------- */
.cw-login {
  max-width: 400px; margin: 6vh auto 0; padding: 32px 30px 26px;
  background: var(--cw-surface); border: 1px solid var(--cw-line); border-radius: 18px; box-shadow: var(--cw-shadow);
  text-align: left;
}
.cw-logo-lg { width: 48px; height: 48px; border-radius: 13px; font-size: 22px; margin-bottom: 14px; }
.cw-login-title { font-size: 22px; font-weight: 700; margin: 0 0 20px; }
.cw-login .form-control { height: 42px; }
.cw-login .cw-btn-block { margin-top: 6px; }
.cw-forgot { display: block; margin: 8px auto 0; color: var(--cw-text-2); }
.cw-login-error { max-width: 400px; margin: 14px auto 0; }
.cw-login-error .alert { margin: 0; }

/* ---------- trang sửa thông tin sách ---------- */
.cw-edit { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; align-items: start; max-width: 1180px; }
.cw-edit-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 84px; }
.cw-edit-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; margin: 0; }

.cw-panel {
  background: var(--cw-surface); border: 1px solid var(--cw-line); border-radius: var(--cw-radius);
  padding: 18px 20px;
}
.cw-panel-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.cw-panel .form-group:last-child { margin-bottom: 0; }
.cw-label { font-size: 13px; font-weight: 600; color: var(--cw-text-2); margin-bottom: 6px; display: block; }
.cw-hint-inline { font-size: 12px; font-weight: 400; color: var(--cw-text-3); }
.cw-mt { margin-top: 14px; }
.cw-edit .form-control { height: 40px; border-color: var(--cw-line); }
.cw-edit textarea.form-control { height: auto; }

.cw-cover-panel { padding: 16px; }
.cw-edit-cover { width: 100%; max-width: 208px; margin: 0 auto 14px; aspect-ratio: 2 / 3; border-radius: 6px; overflow: hidden; background: var(--cw-hover); box-shadow: var(--cw-shadow-cover); }
.cw-edit-cover img { width: 100%; height: 100%; object-fit: cover; display: block; max-height: none; }
.cw-file-name { font-size: 12px; color: var(--cw-text-2); margin-top: 6px; word-break: break-all; }
.cw-file-name:empty { display: none; }
.cw-btn.btn-file { position: relative; overflow: hidden; justify-content: center; margin: 0; }
.cw-btn.btn-file input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 100px; }

.cw-format-list { list-style: none; padding: 0; margin: 0 0 12px; }
.cw-format-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--cw-line); }
.cw-format-list li:last-child { border-bottom: 0; }
.cw-format-list .cw-pill { margin: 0; }
.cw-link-danger { margin-left: auto; border: 0; background: transparent; color: var(--cw-text-3); padding: 4px 6px; border-radius: 6px; }
.cw-link-danger:hover { color: #c62828; background: #fdecea; }

.cw-convert { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cw-convert .form-control { flex: 1; min-width: 0; padding: 6px 8px; }
.cw-panel-danger { padding: 12px; border-style: dashed; }
.cw-btn-danger { color: #c62828 !important; border-color: #f3c7c3; }
.cw-btn-danger:hover { background: #fdecea; }

.cw-input-row { display: flex; gap: 8px; align-items: center; }
.cw-input-row .form-control { flex: 1; }
.cw-swap { flex: 0 0 40px; height: 40px; width: 40px; border-radius: 10px; border: 1px solid var(--cw-line) !important; }
.cw-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.cw-grid-2 > .form-group, .cw-grid-2 > div { min-width: 0; }
.cw-span-2 { grid-column: 1 / -1; }
.cw-rating-group .glyphicon { font-size: 20px; color: #f5a623; }

.cw-id-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; margin-top: -8px; }
.cw-id-table td { padding: 0 8px 0 0; vertical-align: middle; }
.cw-id-table td:first-child { width: 34%; }
.cw-id-table td:last-child { width: 40px; padding: 0; }

.cw-savebar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; margin-top: 4px;
  background: rgba(255,255,255,.92); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid var(--cw-line); border-radius: var(--cw-radius);
  box-shadow: 0 -6px 20px rgba(0,0,0,.06);
}
.cw-savebar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cw-savebar .cw-switch { font-size: 13px; color: var(--cw-text-2); }

/* hộp lấy metadata */
.cw-meta-search { margin: 12px 0 6px; }
#metaModal .media { padding: 12px; border: 1px solid var(--cw-line); border-radius: 10px; margin-top: 10px; }
#metaModal .media img { width: 90px; margin-right: 14px; border-radius: 4px; cursor: pointer; box-shadow: var(--cw-shadow); }
#metaModal .media img:hover { outline: 3px solid var(--cw-accent); }
#metaModal .meta_description { max-height: 4.8em; overflow: hidden; color: var(--cw-text-2); }

@media (max-width: 860px) {
  .cw-edit { grid-template-columns: 1fr; }
  .cw-edit-side { position: static; display: grid; grid-template-columns: 1fr 1fr; }
  .cw-cover-panel { grid-row: span 2; }
}
@media (max-width: 560px) {
  .cw-edit-side { grid-template-columns: 1fr; }
  .cw-edit-cover { max-width: 150px; }
  .cw-grid-2 { grid-template-columns: 1fr; }
  .cw-panel { padding: 14px; }
  .cw-savebar { margin: 0 -4px; }
  .cw-savebar-actions { width: 100%; }
  .cw-savebar-actions .cw-btn { flex: 1; justify-content: center; }
}

/* ---------- trang chi tiết đầy đủ trông như cửa sổ bật lên ---------- */
.cw-sheet {
  max-width: 1040px; margin: 8px auto 24px;
  background: var(--cw-surface); border: 1px solid var(--cw-line); border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.08); overflow: hidden;
}
.cw-sheet-head {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 18px;
  border-bottom: 1px solid var(--cw-line);
}
.cw-sheet-back { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 500; color: var(--cw-text-2) !important; }
.cw-sheet-back .glyphicon { font-size: 11px; top: 0; }
.cw-sheet-title { flex: 1; text-align: center; font-weight: 700; font-size: 15px; }
.cw-sheet-close { font-size: 26px; line-height: 1; color: var(--cw-text-2) !important; }
.cw-sheet-close:hover { background: var(--cw-hover); color: var(--cw-text) !important; }
.cw-sheet-body { padding: 24px 28px; }
.cw-sheet .cw-detail-cover { top: 90px; }
@media (max-width: 640px) {
  .cw-sheet { margin: 0 -8px 16px; border-radius: 12px; }
  .cw-sheet-body { padding: 16px; }
  .cw-sheet-back span:not(.glyphicon) { display: none; }
  .cw-sheet-title { text-align: left; }
}
/* ==========================================================================
   Quản trị, hồ sơ người dùng và các trang cài đặt
   ========================================================================== */
.cw-admin { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; max-width: 1180px; }
.cw-span-all { grid-column: 1 / -1; }
.cw-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.cw-panel-head .cw-panel-title { margin: 0; }
.cw-panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cw-panel-title { align-items: center; }
.cw-pi {
  width: 30px; height: 30px; border-radius: 9px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--cw-accent-soft); color: var(--cw-accent); font-size: 13px;
}
.cw-pi .glyphicon { top: 0; }
.cw-pi-kindle { background: #e3f4ee; color: var(--cw-kindle); }
.cw-panel-foot { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--cw-line); }

.cw-table-wrap { overflow-x: auto; margin: 0 -4px; }
.cw-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.cw-table th {
  font-size: 12px; font-weight: 600; color: var(--cw-text-2); text-transform: none;
  padding: 8px 10px; border-bottom: 1px solid var(--cw-line); white-space: nowrap; background: transparent;
}
.cw-table td { padding: 10px; border-bottom: 1px solid var(--cw-line); vertical-align: middle; }
.cw-table tbody tr:last-child td { border-bottom: 0; }
.cw-table tbody tr:hover td { background: #fafafb; }
.cw-user-cell { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; }
.cw-muted-cell { color: var(--cw-text-2); }
.cw-bool { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; align-items: center; justify-content: center; font-size: 10px; }
.cw-bool .glyphicon { top: 0; }
.cw-bool.on { background: #e3f4ea; color: #1a7f4b; }
.cw-bool.off { background: var(--cw-hover); color: var(--cw-text-3); }

.cw-kv { display: grid; grid-template-columns: minmax(140px, 46%) 1fr; gap: 9px 16px; margin: 0; font-size: 13.5px; }
.cw-kv dt { font-weight: 500; color: var(--cw-text-2); }
.cw-kv dd { margin: 0; min-width: 0; word-break: break-word; }
.cw-modern code { background: var(--cw-hover); color: var(--cw-text); border-radius: 6px; padding: 2px 6px; font-size: 12.5px; }

.cw-action-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cw-action {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px;
  border: 1px solid var(--cw-line); border-radius: 10px; cursor: pointer;
  font-size: 13.5px; font-weight: 500; color: var(--cw-text) !important; transition: background .12s, border-color .12s;
}
.cw-action:hover { background: var(--cw-hover); }
.cw-action .glyphicon { color: var(--cw-text-2); top: 0; }
.cw-action-danger { color: #c62828 !important; }
.cw-action-danger .glyphicon { color: #c62828; }
.cw-action-danger:hover { background: #fdecea; border-color: #f3c7c3; }

/* hồ sơ người dùng */
.cw-settings { display: flex; flex-direction: column; gap: 16px; max-width: 860px; margin: 0; }
.cw-settings .form-control, .cw-legacy .form-control { height: 40px; border-color: var(--cw-line); }
.cw-settings select.form-control { padding-top: 6px; padding-bottom: 6px; }
.cw-note { background: var(--cw-bg); border-radius: 10px; padding: 12px 14px; font-size: 13px; color: var(--cw-text-2); }
.cw-note p { margin: 0 0 6px; }
.cw-note p:last-child { margin: 0; }
.cw-note a { color: var(--cw-accent) !important; font-weight: 500; }
.cw-inline-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px dashed var(--cw-line); }
.cw-inline-row:last-child { border-bottom: 0; }
.cw-inline-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- công tắc bật/tắt cho mọi checkbox trong trang cài đặt ---------- */
.cw-switch-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 20px; }
.cw-switch-grid > [data-related] { display: contents; }
.cw-switch-row,
.cw-legacy form .form-group:has(> input[type=checkbox]:first-child) {
  display: flex; align-items: center; gap: 12px; margin: 0; padding: 9px 0;
}
.cw-switch-row label,
.cw-legacy form .form-group > input[type=checkbox]:first-child + label { margin: 0; font-weight: 500; cursor: pointer; line-height: 1.35; }
.cw-switch-row input[type=checkbox],
.cw-legacy form .form-group > input[type=checkbox]:first-child,
.cw-legacy form .checkbox input[type=checkbox] {
  -webkit-appearance: none; appearance: none; flex: 0 0 auto;
  position: relative; width: 38px; height: 22px; margin: 0; border-radius: 999px;
  background: #d9d9de; cursor: pointer; transition: background .18s; outline: none;
}
.cw-switch-row input[type=checkbox]::after,
.cw-legacy form .form-group > input[type=checkbox]:first-child::after,
.cw-legacy form .checkbox input[type=checkbox]::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s;
}
.cw-switch-row input[type=checkbox]:checked,
.cw-legacy form .form-group > input[type=checkbox]:first-child:checked,
.cw-legacy form .checkbox input[type=checkbox]:checked { background: var(--cw-accent); }
.cw-switch-row input[type=checkbox]:checked::after,
.cw-legacy form .form-group > input[type=checkbox]:first-child:checked::after,
.cw-legacy form .checkbox input[type=checkbox]:checked::after { transform: translateX(16px); }
.cw-switch-row input[type=checkbox]:focus-visible,
.cw-legacy form input[type=checkbox]:focus-visible { box-shadow: 0 0 0 3px rgba(214,52,43,.2); }
.cw-legacy form .checkbox label { display: inline-flex; align-items: center; gap: 10px; padding-left: 0; font-weight: 500; }
.cw-legacy form .checkbox input[type=checkbox] { position: relative; margin: 0; }

/* ---------- các trang cài đặt cũ (cấu hình, giao diện, email, CSDL, lịch...) ---------- */
.cw-legacy { max-width: 900px; }
.cw-legacy > h1, .cw-legacy > h2, .cw-legacy > h3 {
  font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin: 10px 0 20px;
}
.cw-legacy > form, .cw-legacy > form > .panel-group, .cw-legacy > .panel-group { float: none; width: auto; padding: 0; }
.cw-legacy > form[class*="col-"] { float: none; width: auto; padding: 0; }
.cw-legacy > form:not(:has(.panel-group)) {
  background: var(--cw-surface); border: 1px solid var(--cw-line); border-radius: var(--cw-radius); padding: 22px 24px;
}
.cw-legacy .panel-group[class*="col-"] { float: none; width: auto; padding: 0; }
.cw-legacy .panel-group .panel {
  border: 1px solid var(--cw-line); border-radius: var(--cw-radius) !important; box-shadow: none;
  overflow: hidden; margin-bottom: 12px;
}
.cw-legacy .panel-group .panel + .panel { margin-top: 0; }
.cw-legacy .panel-default > .panel-heading { background: var(--cw-surface); border: 0; padding: 0; }
.cw-legacy .panel-title { font-size: 15px; font-weight: 700; }
.cw-legacy .panel-title > a {
  display: flex; align-items: center; gap: 12px; padding: 15px 18px; color: var(--cw-text) !important;
}
.cw-legacy .panel-title > a:hover { background: #fafafb; }
.cw-legacy .panel-title .glyphicon {
  width: 26px; height: 26px; border-radius: 8px; top: 0; font-size: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--cw-accent-soft); color: var(--cw-accent);
}
.cw-legacy .panel-default > .panel-heading + .panel-collapse > .panel-body { border-top: 1px solid var(--cw-line); padding: 18px 20px; }
.cw-legacy label { font-size: 13px; font-weight: 600; color: var(--cw-text-2); }
.cw-legacy .form-group { margin-bottom: 14px; }
.cw-legacy .input-group-btn .btn { height: 40px; border-color: var(--cw-line); }
.cw-legacy form > .btn, .cw-legacy form > div > .btn, .cw-legacy form > a.btn, .cw-legacy .col-sm-12 > .btn {
  height: 40px; padding: 0 18px; margin: 14px 8px 0 0; font-weight: 600; display: inline-flex; align-items: center;
}
.cw-legacy button[type=submit][name=submit], .cw-legacy #config_submit, .cw-legacy #db_submit {
  background: var(--cw-accent); border-color: var(--cw-accent); color: #fff;
}
.cw-legacy button[type=submit][name=submit]:hover, .cw-legacy #config_submit:hover, .cw-legacy #db_submit:hover { background: #bf2c24; color: #fff; }
.cw-legacy .table { background: var(--cw-surface); border-radius: var(--cw-radius); overflow: hidden; }
.cw-legacy .table > thead > tr > th { border-bottom: 1px solid var(--cw-line); font-size: 12.5px; color: var(--cw-text-2); }
.cw-legacy .table > tbody > tr > td { border-top: 1px solid var(--cw-line); }
.cw-legacy .well { background: var(--cw-surface); border: 1px solid var(--cw-line); border-radius: var(--cw-radius); box-shadow: none; }
.cw-legacy .fixed-table-container { border-color: var(--cw-line); border-radius: var(--cw-radius); background: var(--cw-surface); }

@media (max-width: 900px) {
  .cw-admin { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .cw-switch-grid, .cw-action-list { grid-template-columns: 1fr; }
  .cw-kv { grid-template-columns: 1fr; gap: 2px; }
  .cw-kv dd { margin-bottom: 8px; }
  .cw-legacy > form:not(:has(.panel-group)) { padding: 16px; }
  .cw-legacy > h1, .cw-legacy > h2 { font-size: 23px; }
}

/* ---------- About ---------- */
.cw-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.cw-stat {
  display: flex; flex-direction: column; gap: 8px; padding: 18px 20px;
  background: var(--cw-surface); border: 1px solid var(--cw-line); border-radius: var(--cw-radius);
  color: var(--cw-text) !important; transition: box-shadow .15s, transform .1s;
}
a.cw-stat:hover { box-shadow: var(--cw-shadow); transform: translateY(-1px); }
.cw-stat-num { font-size: 32px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.cw-stat-label { color: var(--cw-text-2); font-size: 13.5px; line-height: 1.5; }
.cw-stat-label strong { color: var(--cw-text); font-size: 14.5px; }
.cw-howto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.cw-logo.cw-logo-lg { width: 56px; height: 56px; border-radius: 14px; }

/* ---------- trang bảng / trang bên trong ---------- */
.cw-legacy.cw-legacy-wide { max-width: none; }
.cw-legacy > .cw-back { display: inline-flex; margin: 4px 0 0; }
.cw-legacy > .cw-back + h1, .cw-legacy > .cw-back + h2 { margin-top: 4px; }
.cw-legacy > [class*="col-"], .cw-legacy > .filterheader { float: none; width: auto; padding: 0; }
.cw-legacy > [class*="col-"] > .row, .cw-legacy > .filterheader > .row { margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cw-legacy .btn { border-radius: 10px; font-weight: 500; }
.cw-legacy .btn-default { border-color: var(--cw-line); background: var(--cw-surface); }
.cw-legacy .btn-default:hover { background: var(--cw-hover); }
.cw-legacy .btn.disabled { opacity: .45; }

.cw-legacy .bootstrap-table .fixed-table-toolbar { margin-bottom: 8px; }
.cw-legacy .bootstrap-table .fixed-table-toolbar .search input { border-radius: 999px; height: 36px; border-color: var(--cw-line); }
.cw-legacy .bootstrap-table .fixed-table-toolbar .columns .btn { height: 36px; }
.cw-legacy .bootstrap-table .fixed-table-container {
  border: 1px solid var(--cw-line) !important; border-radius: var(--cw-radius); background: var(--cw-surface); overflow: hidden;
}
.cw-legacy .bootstrap-table .table { margin: 0; font-size: 13.5px; }
.cw-legacy .bootstrap-table .table thead th { background: #fafafb; border-bottom: 1px solid var(--cw-line) !important; font-size: 12.5px; color: var(--cw-text-2); vertical-align: bottom; }
.cw-legacy .bootstrap-table .table td { border-top: 1px solid var(--cw-line) !important; vertical-align: middle; }
.cw-legacy .table-striped > tbody > tr:nth-of-type(odd) { background: transparent; }
.cw-legacy .table-hover > tbody > tr:hover, .cw-legacy .bootstrap-table tbody tr:hover { background: #fafafb; }
.cw-legacy .fixed-table-pagination .pagination > li > a { border-radius: 8px !important; margin: 0 2px; border-color: var(--cw-line); color: var(--cw-text); }
.cw-legacy .fixed-table-pagination .pagination > .active > a { background: var(--cw-text); border-color: var(--cw-text); color: #fff; }
.cw-legacy .editable-click, .cw-legacy a.editable-click { color: var(--cw-text); border-bottom: 1px dashed var(--cw-text-3); }
.cw-legacy .editable-empty { color: var(--cw-text-3) !important; font-style: normal; }
.cw-legacy .errorlink { margin-top: 16px; }
.cw-legacy .errorlink .btn { height: 40px; padding: 0 18px; display: inline-flex; align-items: center; }

/* nhật ký */
.cw-legacy #log_group { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 14px; padding: 14px 16px; background: var(--cw-surface); border: 1px solid var(--cw-line); border-radius: var(--cw-radius); }
.cw-legacy #log_group label { margin: 0 6px 0 4px; }
.cw-legacy #renderer, .cw-legacy .logs, .cw-legacy pre {
  background: #1d1d1f; color: #e6e6e6; border: 0; border-radius: var(--cw-radius);
  font-size: 12.5px; line-height: 1.5; padding: 14px 16px;
}

/* sắp xếp giá sách */
.cw-legacy .list-group-item { border-color: var(--cw-line); cursor: grab; }
.cw-legacy .list-group-item:first-child { border-top-left-radius: var(--cw-radius); border-top-right-radius: var(--cw-radius); }
.cw-legacy .list-group-item:last-child { border-bottom-left-radius: var(--cw-radius); border-bottom-right-radius: var(--cw-radius); }
.cw-legacy .cover-height { max-height: 90px; border-radius: 4px; box-shadow: var(--cw-shadow); }

/* tìm kiếm nâng cao */
.cw-legacy > form#search, .cw-legacy > [class*="col-"] > form#search {
  background: var(--cw-surface); border: 1px solid var(--cw-line); border-radius: var(--cw-radius); padding: 22px 24px;
}
.cw-legacy form#search .form-control { height: 40px; border-color: var(--cw-line); }
.cw-legacy form#search button[type=submit] { background: var(--cw-accent); border-color: var(--cw-accent); color: #fff; height: 40px; padding: 0 22px; font-weight: 600; }

/* ==========================================================================
   Bìa tự tạo cho sách không có ảnh bìa (tên sách + tác giả)
   ========================================================================== */
.cw-nocover {
  container-type: inline-size;
  position: relative; display: block; width: 100%; aspect-ratio: 2 / 3; height: auto; box-sizing: border-box;
  padding: 7%; overflow: hidden; color: #f6efe0; text-align: center;
  background: linear-gradient(160deg, var(--nc-a), var(--nc-b));
  font-family: "Literata", "Noto Serif", Cambria, Georgia, serif;
}
.cw-cover > a > .cw-nocover, .cw-edit-cover > .cw-nocover { height: 100%; }
/* ánh sáng nhẹ + gáy sách bên trái cho giống bìa thật */
.cw-nocover::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 70% at 30% 0%, rgba(255,255,255,.16), transparent 60%),
              linear-gradient(90deg, rgba(0,0,0,.28) 0, rgba(0,0,0,.08) 4%, transparent 7%);
}
.cw-nc-frame {
  position: relative; height: 100%; box-sizing: border-box;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5cqw;
  padding: 8cqw 6cqw; border: 1px solid rgba(246, 239, 224, .45); outline: 1px solid rgba(246, 239, 224, .18); outline-offset: 3px;
}
.cw-nc-mark { font-size: 9cqw; line-height: 1; opacity: .7; }
.cw-nc-title {
  font-size: clamp(11px, 10.5cqw, 30px); font-weight: 600; line-height: 1.22; letter-spacing: .01em;
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden;
  text-wrap: balance; word-break: break-word;
}
.cw-nc-rule { width: 28%; height: 1px; background: rgba(246, 239, 224, .6); flex: 0 0 auto; }
.cw-nc-author {
  font-family: "Be Vietnam Pro", "Segoe UI", Arial, sans-serif;
  font-size: clamp(9px, 6.4cqw, 16px); font-weight: 500; letter-spacing: .08em; text-transform: uppercase; opacity: .9;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* 6 bảng màu trầm, chọn theo id sách */
.cw-nc-0 { --nc-a: #9a3b30; --nc-b: #5c1d18; }
.cw-nc-1 { --nc-a: #2c4d7a; --nc-b: #14284a; }
.cw-nc-2 { --nc-a: #3a6b5a; --nc-b: #1b3d32; }
.cw-nc-3 { --nc-a: #8a6a3a; --nc-b: #4e3a1e; }
.cw-nc-4 { --nc-a: #5d4a85; --nc-b: #2f2550; }
.cw-nc-5 { --nc-a: #4a525e; --nc-b: #23282f; }
.cw-detail-cover .cw-nocover { border-radius: 8px; box-shadow: var(--cw-shadow-cover); }
/* trang sửa sách: ẩn ảnh trống khi đang hiện bìa tự tạo, và ngược lại */
.cw-edit-cover.cw-no-img > img { display: none; }
.cw-edit-cover:not(.cw-no-img) > .cw-nocover { display: none; }

/* PWA */
.cw-nav-item[hidden] { display: none !important; }
/* chạy như app trên iPhone có "tai thỏ": chừa vùng an toàn */
.cw-standalone .cw-topbar { padding-top: max(14px, env(safe-area-inset-top)); }
