:root {
  --color-primary: #0F5C5C;
  --color-primary-dark: #0A4444;
  --color-ink: #1A1A1A;
  --color-bg: #FAF7F2;
  --color-surface: #FFFFFF;
  --color-success: #1E7A3D;
  --color-warning: #B8790A;
  --color-danger: #B3261E;
  --color-border: #E0DACD;

  --font-ui: -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--color-bg);
  color: var(--color-ink);
  font-size: 16px;
  line-height: 1.5;
}

a {
  color: var(--color-primary);
}

/* ---------- Nav ---------- */

nav.app-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 10px 16px;
  flex-wrap: wrap;
}

nav.app-nav .brand {
  font-weight: 700;
  font-size: 18px;
  margin-right: 16px;
  color: var(--color-primary-dark);
  text-decoration: none;
  white-space: nowrap;
}

nav.app-nav a.nav-link {
  padding: 8px 12px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--color-ink);
  font-size: 15px;
}

nav.app-nav a.nav-link:hover {
  background: var(--color-bg);
}

nav.app-nav a.nav-link.active {
  background: var(--color-primary);
  color: white;
}

nav.app-nav a.nav-link:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--color-primary-dark);
  outline-offset: 2px;
}

/* ---------- Layout ---------- */

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px 80px;
}

h1 {
  font-size: 24px;
  margin: 0 0 16px;
}

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

/* ---------- Forms ---------- */

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 14px;
}

.field input,
.field select {
  width: 100%;
  padding: 10px 12px;
  font-size: 16px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-ink);
  min-height: 44px;
}

.field input[data-numeric],
.field .isbn-input {
  font-family: var(--font-mono);
}

.field-row {
  display: flex;
  gap: 12px;
}

.field-row > .field {
  flex: 1;
}

.hint {
  font-size: 13px;
  color: #6b6455;
  margin-top: 4px;
}

.error-text {
  color: var(--color-danger);
  font-size: 14px;
  margin-top: 8px;
}

/* ---------- Buttons ---------- */

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 18px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}
.btn-primary:hover { background: var(--color-primary-dark); }

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-ink);
  border: 1px solid var(--color-border);
}

.btn-danger {
  background: var(--color-danger);
  color: white;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Table ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  overflow: hidden;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
}

th {
  background: var(--color-bg);
  font-weight: 700;
}

tr:last-child td {
  border-bottom: none;
}

td.numeric, th.numeric {
  font-family: var(--font-mono);
}

/* ---------- Status badges (never color-only: always icon + text) ---------- */

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.status-ok {
  background: #E4F3E8;
  color: var(--color-success);
}
.status-low {
  background: #FBEEDA;
  color: var(--color-warning);
}
.status-out {
  background: #FBE7E6;
  color: var(--color-danger);
}

/* ---------- Utility ---------- */

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.muted { color: #6b6455; }
.text-right { text-align: right; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #6b6455;
}

/* ---------- Mobile scan screen ---------- */

.scan-viewport {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}

.scan-viewport video {
  width: 100%;
  display: block;
}

.scan-actions {
  position: sticky;
  bottom: 0;
  background: var(--color-bg);
  padding: 12px 0;
}

/* ---------- Book covers ---------- */

.cover-thumb {
  width: 46px;
  height: 64px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  flex-shrink: 0;
}

.book-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

/* Visual candidate picker — used wherever a clerk needs to confirm "is this
   the right book" against multiple online-search results. A cover thumbnail
   makes a wrong match obvious at a glance, without reading title/author text. */

.candidate-cards {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-top: 6px;
}

.candidate-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100px;
  flex-shrink: 0;
  padding: 8px;
  border-radius: 8px;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
  text-align: center;
  font-size: 12px;
  color: var(--color-ink);
}

.candidate-card .cover-thumb {
  width: 56px;
  height: 78px;
}

.candidate-card-title {
  font-weight: 600;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.candidate-card-author {
  color: #6b6455;
  line-height: 1.2;
}

.candidate-card.selected {
  border-color: var(--color-primary);
  background: #EAF3F2;
}

@media (max-width: 480px) {
  main { padding: 12px 12px 90px; }
  .field-row { flex-direction: column; }
}
