:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --border: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #fbbf24;
  --accent2: #3b82f6;
  --danger: #ef4444;
  --ok: #22c55e;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--accent2);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem;
}

nav.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.75rem 0 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

nav.top .brand {
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--accent);
  margin-right: auto;
}

nav.top a.nav-link {
  color: var(--muted);
  font-size: 0.9rem;
}

nav.top a.nav-link.active {
  color: var(--text);
  font-weight: 600;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
}

.stat {
  text-align: center;
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
}

.stat .num {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
}

.stat .label {
  font-size: 0.8rem;
  color: var(--muted);
}

h1 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

h2 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  color: var(--accent);
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

button,
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent2);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  margin-right: 0.5rem;
  margin-bottom: 0.5rem;
}

button.secondary {
  background: var(--border);
}

button.danger {
  background: var(--danger);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  text-align: left;
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-weight: 600;
}

.error {
  color: var(--danger);
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.success {
  color: var(--ok);
  margin-bottom: 0.75rem;
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.qr-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.5rem;
}

.qr-page canvas,
.qr-page img {
  margin: 1rem 0;
  background: #fff;
  padding: 12px;
  border-radius: 8px;
}

#qr-reader,
.isbn-reader {
  width: 100%;
  max-width: 400px;
  margin: 1rem auto;
}

.add-mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.row-inline {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.row-inline input {
  flex: 1;
  margin-bottom: 0;
}

.file-upload-btn {
  display: inline-block;
  margin: 0.5rem 0 1rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  background: var(--border);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.file-upload-btn input[type="file"] {
  display: none;
}

.scan-step {
  padding: 1rem;
  border: 2px dashed var(--border);
  border-radius: 10px;
  margin-bottom: 1rem;
}

.scan-step.done {
  border-color: var(--ok);
  border-style: solid;
}

.login-box {
  max-width: 360px;
  margin: 4rem auto;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.cover-cell {
  width: 48px;
}

.book-cover-thumb,
.book-cover {
  object-fit: cover;
  border-radius: 4px;
  background: #fff;
}

.book-detail-panel .book-detail-header {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.book-detail-panel h2 {
  margin-bottom: 0.35rem;
}

.ol-metadata-details {
  margin-top: 1rem;
}

.ol-metadata-details pre {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 6px;
  font-size: 0.75rem;
  overflow: auto;
  max-height: 320px;
}

@media (max-width: 600px) {
  table {
    font-size: 0.8rem;
  }
  nav.top {
    flex-direction: column;
    align-items: flex-start;
  }
}

.isbn-similar-list {
  list-style: none;
  margin: 0.75rem 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.isbn-similar-item {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.65rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.isbn-similar-item button {
  flex-shrink: 0;
}
