:root {
  --bg: #f4f1ea;
  --bg-2: #ebe6db;
  --surface: #ffffff;
  --surface-2: #faf8f3;
  --ink: #16233b;
  --ink-2: #334155;
  --muted: #6b7280;
  --line: #e3ded2;
  --brand: #0f4c5c;
  --brand-2: #146b73;
  --brand-3: #0b3946;
  --accent: #e9c46a;
  --accent-2: #f4d58d;
  --success: #2a9d8f;
  --success-bg: #e6f4f1;
  --warning: #b7791f;
  --warning-bg: #fdf4e3;
  --danger: #c2413b;
  --danger-bg: #fbe9e7;
  --shadow-sm: 0 2px 8px rgba(22, 35, 59, .06);
  --shadow: 0 12px 34px rgba(22, 35, 59, .09);
  --radius: 18px;
  --radius-sm: 12px;
  --font: "Segoe UI", "Tahoma", "Arial", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(233, 196, 106, .18), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(15, 76, 92, .10), transparent 60%),
    var(--bg);
  min-height: 100vh;
  line-height: 1.6;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}
.icon-sm { width: 14px; height: 14px; }

body:not(.is-admin) .admin-only { display: none !important; }

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: linear-gradient(135deg, var(--brand-3), var(--brand) 55%, var(--brand-2));
  color: #fff;
  box-shadow: 0 10px 30px rgba(11, 57, 70, .22);
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, .55);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 5px 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .18);
}
.brand-mark img { width: 100%; height: auto; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 1.05rem; letter-spacing: .2px; white-space: nowrap; }
.brand-text small { color: rgba(255, 255, 255, .72); font-size: .78rem; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 700;
  background: rgba(255, 255, 255, .10);
  border: 1px solid rgba(255, 255, 255, .18);
  color: rgba(255, 255, 255, .82);
  white-space: nowrap;
}
.mode-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(233, 196, 106, .18);
}
.mode-badge.is-admin { background: rgba(42, 157, 143, .22); border-color: rgba(126, 232, 216, .35); color: #d9fff8; }
.mode-badge.is-admin::before { background: #7ee8d8; box-shadow: 0 0 0 3px rgba(126, 232, 216, .18); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 9px 14px;
  font-size: .86rem;
  font-weight: 600;
  transition: transform .15s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 3px solid rgba(233, 196, 106, .55); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: #2b2410; box-shadow: 0 6px 16px rgba(233, 196, 106, .25); }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .20); color: #fff; }
.btn-ghost:hover { background: rgba(255, 255, 255, .15); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a8342f; }
.btn-sm { padding: 6px 10px; font-size: .78rem; border-radius: 9px; }

.menu-wrap { position: relative; }
.menu {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  min-width: 210px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 60;
}
.menu button {
  display: block;
  width: 100%;
  text-align: start;
  border: 0;
  background: transparent;
  padding: 9px 11px;
  border-radius: 8px;
  font-size: .84rem;
  color: var(--ink);
}
.menu button:hover { background: var(--surface-2); }

/* ---------- Layout ---------- */
.layout {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 92px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  max-height: calc(100vh - 116px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-head h2 { margin: 0; font-size: 1rem; }
.count-pill {
  min-width: 28px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: .74rem;
  text-align: center;
}
.category-list { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; padding-inline-end: 2px; }
.category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  padding: 9px 11px;
  border-radius: 10px;
  text-align: start;
  font-size: .84rem;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.category-item:hover { background: var(--surface-2); border-color: var(--line); }
.category-item.active { background: rgba(15, 76, 92, .08); border-color: rgba(15, 76, 92, .18); color: var(--brand); font-weight: 700; }
.category-item .category-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-count {
  flex: 0 0 auto;
  min-width: 26px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: .7rem;
  text-align: center;
}
.category-item.active .category-count { background: #fff; border-color: rgba(15, 76, 92, .18); color: var(--brand); }
.sidebar-note { margin: 0; color: var(--muted); font-size: .74rem; line-height: 1.6; border-top: 1px dashed var(--line); padding-top: 10px; }

/* ---------- Stats ---------- */
.content { min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 15px 16px;
  box-shadow: var(--shadow-sm);
}
.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: rgba(15, 76, 92, .08);
  color: var(--brand);
  flex: 0 0 auto;
}
.stat-icon .icon { width: 21px; height: 21px; }
.stat-card:nth-child(2) .stat-icon { background: rgba(233, 196, 106, .22); color: #8a6414; }
.stat-card:nth-child(3) .stat-icon { background: var(--success-bg); color: var(--success); }
.stat-card:nth-child(4) .stat-icon { background: #eef2ff; color: #4f46e5; }
.stat-value { display: block; font-size: 1.35rem; font-weight: 800; line-height: 1.1; letter-spacing: -.3px; }
.stat-label { display: block; color: var(--muted); font-size: .76rem; margin-top: 2px; }

/* ---------- Toolbar ---------- */
.toolbar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 0 12px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.search-wrap:focus-within {
  border-color: rgba(15, 76, 92, .45);
  box-shadow: 0 0 0 4px rgba(15, 76, 92, .08);
  background: #fff;
}
.search-icon { color: var(--muted); }
.search-wrap input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 13px 0;
  font-size: .92rem;
  outline: none;
}
.search-wrap input::placeholder { color: #9aa3af; }
.search-wrap kbd {
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  background: #fff;
  color: var(--muted);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: .7rem;
  font-family: inherit;
}
.toolbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.segmented { display: inline-flex; gap: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 13px;
  border-radius: 8px;
  font-size: .8rem;
  font-weight: 600;
}
.segmented button:hover { color: var(--ink); }
.segmented button.active { background: #fff; color: var(--brand); box-shadow: var(--shadow-sm); }
.select {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: .8rem;
  color: var(--ink-2);
  outline: none;
}
.select:focus { border-color: rgba(15, 76, 92, .45); box-shadow: 0 0 0 3px rgba(15, 76, 92, .08); }

/* ---------- Results head ---------- */
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; min-height: 24px; }
.results-info { margin: 0; color: var(--muted); font-size: .8rem; }
.active-category {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 76, 92, .08);
  border: 1px solid rgba(15, 76, 92, .16);
  color: var(--brand);
  border-radius: 999px;
  padding: 3px 6px 3px 10px;
  font-size: .76rem;
  font-weight: 700;
}
.active-category button {
  border: 0;
  background: rgba(15, 76, 92, .12);
  color: var(--brand);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1rem;
  line-height: 1;
}
.active-category button:hover { background: rgba(15, 76, 92, .22); }

/* ---------- Messages ---------- */
.error-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--danger-bg);
  border: 1px solid #f3c9c5;
  color: #8f2f2a;
  border-radius: 12px;
  padding: 10px 13px;
  font-size: .84rem;
}
.error-banner span { flex: 1; }
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: .84rem;
  padding: 22px;
}
.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2.5px solid rgba(15, 76, 92, .18);
  border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Books ---------- */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 14px;
  transition: opacity .2s ease;
}
.books-grid.is-loading { opacity: .55; pointer-events: none; }
.book-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.book-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #d6cfbf; }
.book-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.category-chip {
  max-width: 68%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(15, 76, 92, .07);
  color: var(--brand);
  border: 1px solid rgba(15, 76, 92, .12);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: .68rem;
  font-weight: 700;
}
.status-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: .68rem;
  font-weight: 800;
  white-space: nowrap;
}
.status-available { background: var(--success-bg); color: #1f7a6f; }
.status-partial { background: var(--warning-bg); color: var(--warning); }
.status-out { background: var(--danger-bg); color: var(--danger); }
.book-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.45;
  font-weight: 800;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.9em;
}
.book-author { margin: -4px 0 0; color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; padding: 0; font-size: .72rem; color: var(--muted); }
.book-meta div { display: flex; align-items: baseline; gap: 5px; min-width: 0; }
.book-meta dt { color: var(--muted); }
.book-meta dd { margin: 0; color: var(--ink-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }
.availability { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.availability-text { font-size: .74rem; color: var(--muted); }
.availability-text strong { color: var(--ink); font-size: .86rem; }
.progress { height: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-2), var(--success)); border-radius: inherit; transition: width .3s ease; }
.book-card[data-available="0"] .progress span { background: var(--danger); }
.book-actions { display: flex; align-items: center; gap: 6px; padding-top: 10px; border-top: 1px dashed var(--line); }
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
  border-radius: 9px;
  padding: 6px 9px;
  font-size: .72rem;
  font-weight: 700;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.action-btn:hover:not(:disabled) { background: #fff; border-color: #cfc7b6; color: var(--brand); }
.action-btn:disabled { opacity: .45; cursor: not-allowed; }
.action-btn.icon-only { padding: 6px; margin-inline-start: auto; }
.action-btn.icon-only + .action-btn.icon-only { margin-inline-start: 0; }
.action-btn.danger:hover { color: var(--danger); border-color: #efc4c0; background: var(--danger-bg); }
.action-btn .icon { width: 14px; height: 14px; }

/* ---------- Empty state ---------- */
.empty-state {
  background: var(--surface);
  border: 1px dashed #d6cfbf;
  border-radius: var(--radius);
  padding: 42px 22px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: rgba(15, 76, 92, .07);
  color: var(--brand);
  margin-bottom: 4px;
}
.empty-icon .icon { width: 30px; height: 30px; }
.empty-state h3 { margin: 0; font-size: 1.05rem; }
.empty-state p { margin: 0; color: var(--muted); font-size: .84rem; max-width: 440px; }
.empty-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.empty-actions .btn-ghost { background: var(--surface-2); border-color: var(--line); color: var(--ink-2); }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 4px 0 16px; flex-wrap: wrap; }
.page-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 10px;
  padding: 7px 13px;
  font-size: .8rem;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.page-btn:hover:not(:disabled) { border-color: #cfc7b6; color: var(--brand); }
.page-btn:disabled { opacity: .45; cursor: not-allowed; }
.page-info { font-size: .8rem; color: var(--muted); }

/* ---------- Footer ---------- */
.app-footer {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px 24px;
  color: var(--muted);
  font-size: .74rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.app-footer p { margin: 0; }
.footer-note { color: #8a94a3; }
.footer-brand { display: flex; align-items: center; gap: 9px; }
.footer-logo-wrap {
  display: inline-flex;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px 6px;
  box-shadow: var(--shadow-sm);
}
.footer-logo-wrap img { width: 42px; height: auto; display: block; }
.footer-brand-text { font-size: .78rem; font-weight: 700; color: var(--ink-2); }

/* ---------- Dialogs ---------- */
.dialog {
  border: 0;
  padding: 22px;
  border-radius: 20px;
  width: min(680px, calc(100vw - 32px));
  max-height: min(88vh, 820px);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(11, 57, 70, .3);
  overflow: auto;
}
.dialog::backdrop { background: rgba(11, 57, 70, .52); backdrop-filter: blur(3px); }
.dialog form { padding: 0; }
.dialog-sm { width: min(440px, calc(100vw - 32px)); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.dialog-head h2 { margin: 0; font-size: 1.12rem; }
.dialog-subtitle { margin: 3px 0 0; color: var(--muted); font-size: .78rem; }
.dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.dialog .btn-ghost { background: var(--surface-2); border-color: var(--line); color: var(--ink-2); }
.dialog .btn-ghost:hover { background: #fff; }
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.icon-btn:hover { color: var(--ink); background: #fff; }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-bg); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn .icon { width: 16px; height: 16px; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field > span { font-size: .78rem; font-weight: 700; color: var(--ink-2); }
.field em { color: var(--danger); font-style: normal; }
.field input, .field select, .field textarea, .inline-form input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: .85rem;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus, .inline-form input:focus {
  border-color: rgba(15, 76, 92, .45);
  box-shadow: 0 0 0 3px rgba(15, 76, 92, .08);
  background: #fff;
}
.field textarea { resize: vertical; min-height: 76px; }
.field input::placeholder, .field textarea::placeholder, .inline-form input::placeholder { color: #9aa3af; }
.form-error {
  margin: 12px 0 0;
  background: var(--danger-bg);
  border: 1px solid #f3c9c5;
  color: #8f2f2a;
  border-radius: 10px;
  padding: 8px 11px;
  font-size: .8rem;
}
.auth-fields { display: flex; flex-direction: column; gap: 10px; }
.check-field { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: .8rem; color: var(--ink-2); cursor: pointer; }
.check-field input { width: 16px; height: 16px; accent-color: var(--brand); flex: 0 0 auto; }
.auth-note { margin: 12px 0 0; padding: 9px 11px; border-radius: 10px; background: rgba(15, 76, 92, .06); color: var(--muted); font-size: .76rem; line-height: 1.7; }
.auth-logo { display: flex; justify-content: center; margin: -2px 0 10px; }
.auth-logo img { width: 112px; height: auto; display: block; }
.auth-logo-full img { width: 132px; }
.network-list { display: flex; flex-direction: column; gap: 8px; }
.network-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 11px;
}
.network-item-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.network-item code {
  direction: ltr;
  unicode-bidi: embed;
  font-family: "Consolas", "Courier New", monospace;
  font-size: .82rem;
  color: var(--brand);
  font-weight: 700;
  word-break: break-all;
}
.network-item .btn { padding: 6px 10px; font-size: .76rem; flex: 0 0 auto; }
.network-tag { font-size: .66rem; color: #1d7a6f; background: var(--success-bg); border-radius: 999px; padding: 2px 7px; width: fit-content; }
.network-empty { margin: 0; padding: 12px; text-align: center; color: var(--muted); font-size: .82rem; }
#accountMenu [data-account-action="logout"] { color: var(--danger); }
.confirm-message { margin: 0; color: var(--ink-2); font-size: .9rem; line-height: 1.7; }
.install-steps { display: flex; flex-direction: column; gap: 9px; }
.install-step { border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 10px 13px; }
.install-step h3 { margin: 0 0 3px; font-size: .86rem; color: var(--brand); }
.install-step p { margin: 0; color: var(--muted); font-size: .8rem; line-height: 1.7; }
.install-note { margin: 12px 0 0; color: var(--muted); font-size: .75rem; line-height: 1.7; border-top: 1px dashed var(--line); padding-top: 10px; }
.inline-form { display: flex; align-items: center; gap: 8px; }
.inline-form input { flex: 1; }
.categories-admin-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}
.category-admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 12px;
  padding: 9px 11px;
}
.category-admin-main { min-width: 0; display: flex; flex-direction: column; flex: 1; }
.category-admin-name { font-weight: 700; font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-admin-meta { font-size: .72rem; color: var(--muted); }
.category-admin-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.category-admin-empty { color: var(--muted); font-size: .82rem; text-align: center; padding: 18px 0; }
.inline-edit-input {
  border: 1px solid rgba(15, 76, 92, .35);
  background: #fff;
  border-radius: 8px;
  padding: 6px 9px;
  font-size: .84rem;
  outline: none;
  width: 100%;
}
.inline-edit-actions { display: flex; gap: 4px; margin-top: 5px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--brand-3);
  color: #fff;
  padding: 11px 18px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: .84rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 100;
  max-width: min(90vw, 440px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #7f1d1d; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 240px minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 920px) {
  .header-inner { flex-wrap: wrap; }
  .header-actions { width: 100%; justify-content: flex-start; }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .sidebar { position: static; max-height: none; padding: 12px; min-width: 0; }
  .sidebar-head { margin-bottom: 2px; }
  .category-list { flex-direction: row; overflow-x: auto; overflow-y: hidden; padding-bottom: 4px; min-width: 0; }
  .category-item { flex: 0 0 auto; max-width: 230px; }
  .sidebar-note { display: none; }
}

@media (max-width: 680px) {
  .header-inner { padding: 12px 14px; gap: 10px; }
  .brand-text strong { font-size: .95rem; }
  .brand-text small { font-size: .7rem; }
  .brand-mark { width: 40px; height: 40px; border-radius: 12px; }
  .brand-mark .icon { width: 22px; height: 22px; }
  .header-actions { gap: 6px; }
  .header-actions .btn { padding: 8px 10px; }
  .header-actions .btn-label { display: none; }
  .mode-badge { order: -1; }
  .layout { padding: 12px; gap: 14px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat-card { padding: 11px 12px; gap: 9px; }
  .stat-icon { width: 36px; height: 36px; border-radius: 11px; }
  .stat-value { font-size: 1.15rem; }
  .stat-label { font-size: .7rem; }
  .toolbar { padding: 11px; }
  .search-wrap kbd { display: none; }
  .toolbar-row { flex-direction: column; align-items: stretch; }
  .segmented { justify-content: space-between; }
  .segmented button { flex: 1; padding: 7px 8px; }
  .select { width: 100%; }
  .books-grid { grid-template-columns: 1fr; }
  .book-title { min-height: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .dialog { padding: 16px; border-radius: 16px; }
  .dialog-head h2 { font-size: 1rem; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .app-footer { padding: 0 14px 18px; }
}

@media (max-width: 380px) {
  .stats { grid-template-columns: 1fr; }
  .brand-text small { display: none; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- Print ---------- */
@media print {
  body { background: #fff; }
  .app-header, .sidebar, .toolbar, .pagination, .app-footer, .book-actions,
  .mode-badge, .active-category, .error-banner, .loading, .toast { display: none !important; }
  .layout { display: block; max-width: none; padding: 0; }
  .content { gap: 10px; }
  .stats { grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
  .stat-card { box-shadow: none; border-color: #ccc; padding: 8px; }
  .stat-icon { display: none; }
  .books-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .book-card { break-inside: avoid; box-shadow: none; border-color: #ccc; padding: 10px; }
  .book-title { min-height: 0; font-size: .9rem; }
  .progress { display: none; }
  .results-info { color: #000; }
  .results-head { margin-bottom: 8px; }
}

