:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #121826;
  --muted: #667085;
  --line: #d9e2ef;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #0f766e;
  --sidebar: #101827;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
}

.sidebar {
  background: var(--sidebar);
  color: #fff;
  padding: 24px 18px;
}
.brand {
  display: grid;
  gap: 4px;
  margin-bottom: 30px;
}
.brand span {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--blue);
  border-radius: 8px;
  font-weight: 800;
}
.brand small { color: #b8c2d6; }
.sidebar a {
  display: block;
  color: #d8deea;
  text-decoration: none;
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 6px;
}
.sidebar a:hover, .sidebar a.active {
  background: #1e293b;
  color: #fff;
}

.content {
  padding: 30px;
  overflow: auto;
}
.hero, .card, .stats article, .filters, .book-section, .auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(15, 23, 42, .06);
}
.hero {
  padding: 34px;
  min-height: 280px;
}
.page-head { margin-bottom: 22px; }
.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
h1 { font-size: 32px; margin: 0 0 8px; }
h2 { margin-top: 0; font-size: 18px; }
p { color: var(--muted); line-height: 1.55; }

.actions, .filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}
.filters { padding: 18px; margin-bottom: 20px; }
.button, button {
  display: inline-block;
  border: 0;
  border-radius: 7px;
  padding: 11px 16px;
  cursor: pointer;
  text-decoration: none;
  font: inherit;
  transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
}
.button:hover, button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(37, 99, 235, .18);
}
.is-loading {
  opacity: .76;
  pointer-events: none;
}
.primary, button {
  color: #fff;
  background: var(--blue);
}
.primary:hover, button:hover { background: var(--blue-dark); }
.secondary {
  color: #1f2937;
  background: #e8edf5;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stats article { padding: 18px; }
.stats strong {
  display: block;
  color: var(--blue);
  font-size: 28px;
}
.stats span { color: var(--muted); }

.admin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.card { padding: 20px; }
.card.wide { grid-column: span 3; }
label {
  display: block;
  font-weight: 700;
  color: #344054;
  font-size: 13px;
  margin-bottom: 13px;
}
input, select {
  display: block;
  width: 100%;
  border: 1px solid #cfd8e6;
  border-radius: 7px;
  padding: 11px 12px;
  margin-top: 6px;
  outline: none;
}
input:focus, select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}

table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid #edf1f7;
  font-size: 13px;
}
th { background: #f1f5f9; color: #475467; }

.book-section { padding: 20px; margin-bottom: 16px; }
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}
.book-card {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 14px;
  padding: 16px;
  border: 1px solid #e3eaf4;
  border-radius: 8px;
  background: #fff;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.book-card:hover {
  transform: translateY(-3px);
  border-color: #b9c9e5;
  box-shadow: 0 16px 30px rgba(15, 23, 42, .1);
}
.cover {
  height: 96px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #2563eb, #0f766e);
  color: #fff;
  font-weight: 800;
}
.book-card h3 { margin: 0 0 5px; font-size: 16px; }
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.chips span {
  border-radius: 999px;
  background: #eef4ff;
  color: #1d4ed8;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 700;
}
.empty, .alert {
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  background: #fff;
  border: 1px dashed #cfd8e6;
  color: var(--muted);
}
.alert.success {
  color: #0f5132;
  background: #dcfce7;
  border: 1px solid #86efac;
}
.alert.error {
  color: #842029;
  background: #fee2e2;
  border: 1px solid #fca5a5;
}

.auth-page {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(440px, 100%);
  padding: 28px;
}
.auth-card form { margin-top: 18px; }
.auth-link { margin-bottom: 0; }
.auth-link a { color: var(--blue); font-weight: 700; }

.js-animations .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .5s ease, transform .5s ease;
}
.js-animations .reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .admin-grid, .stats { grid-template-columns: 1fr; }
  .card.wide { grid-column: auto; }
}

/* Reader modal and embed styles */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2,6,23,.6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1200;
}
.modal-overlay.open { display: flex; }
.modal {
  width: min(1100px, 100%);
  max-height: 90vh;
  background: var(--panel);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(2,6,23,.5);
  display: grid;
  grid-template-rows: auto 1fr;
}
.modal-header {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.modal-title { font-weight: 800; font-size: 16px; }
.modal-close {
  margin-left: auto;
  background: transparent;
  border: 0;
  font-size: 18px;
  cursor: pointer;
}
.modal-body { padding: 12px; overflow: auto; }
.reader-controls { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.reader-controls input { flex: 1; }
.reader-embed iframe { width: 100%; height: 68vh; border: 0; }

/* Small responsive tweaks for modal */
@media (max-width: 720px) {
  .modal { width: 100%; height: 100%; max-height: 100vh; border-radius: 0; }
  .reader-embed iframe { height: 56vh; }
}
