:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --ink: #1f2328;
  --ink-soft: #5b6169;
  --border: #e4e0d8;

  --steel: #2c4a5e;
  --steel-dark: #1e3646;
  --steel-soft: #e4ecf0;

  --brass: #a8763a;
  --brass-soft: #f3e7d2;

  --teal: #3f7d6b;
  --teal-soft: #dceae6;

  --danger: #b3413a;

  --font-display: "Roboto Slab", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --radius: 10px;
  --shadow: 0 8px 24px rgba(31, 35, 40, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Top bar + perforation signature ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  background: var(--steel);
  color: #fff;
}
.brand { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}
.brand-sub {
  font-size: 0.78rem;
  color: #cdd9de;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-top: 2px;
}

.topbar-actions { display: flex; gap: 8px; }
@media (max-width: 480px) {
  .topbar-actions { flex-direction: column; }
}

.scan-status {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 8px;
  margin: 4px 0;
}
.scan-status.ok { background: var(--teal-soft); color: #285547; }
.scan-status.warn { background: var(--brass-soft); color: #7a5626; }

/* A row of little "punched" dots, like the perforated edge of a checkbook */
.perforation {
  height: 10px;
  background:
    radial-gradient(circle, var(--bg) 3.5px, transparent 3.6px) repeat-x;
  background-size: 18px 10px;
  background-position: 9px -5px;
  background-color: var(--steel-dark);
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brass); color: #fff; }
.btn-primary:hover { background: #966a30; }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--border); }
.btn-ghost:hover { background: #f1efe9; }
.btn-small {
  font-size: 0.78rem;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--steel-dark);
  cursor: pointer;
  white-space: nowrap;
}
.btn-small:hover { background: var(--steel-soft); }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}
.input {
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
}
.search { flex: 1 1 200px; min-width: 160px; }
.select { min-width: 160px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
}
.chip.is-active { background: var(--steel); border-color: var(--steel); color: #fff; }

/* ---------- Table ---------- */
.list-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.check-table { width: 100%; border-collapse: collapse; }
.check-table thead th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: #f7f5f0;
}
.check-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  vertical-align: middle;
}
.check-table tbody tr:last-child td { border-bottom: none; }
.check-table tbody tr:hover { background: #fbfaf7; }

.mono-num {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  position: relative;
  padding-left: 10px;
}
.mono-num::before {
  content: "";
  position: absolute;
  left: 0;
  top: 2px;
  bottom: 2px;
  width: 3px;
  background: var(--brass);
  border-radius: 2px;
}
.mono-num.is-used::before { background: var(--teal); }

.amount-cell { font-variant-numeric: tabular-nums; }

.status-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.status-pill.location { background: var(--brass-soft); color: #7a5626; }
.status-pill.customer { background: var(--teal-soft); color: #285547; }

.photo-link { font-size: 0.8rem; color: var(--steel); text-decoration: none; font-weight: 600; }
.photo-link:hover { text-decoration: underline; }
.no-photo { color: var(--ink-soft); font-size: 0.8rem; }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--ink-soft); }
.empty-sub { font-size: 0.85rem; }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(31, 35, 40, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 50;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%; max-width: 460px;
  box-shadow: var(--shadow);
  animation: modal-in 0.15s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-family: var(--font-display); font-size: 1.05rem; margin: 0; }
.modal-close {
  background: none; border: none; font-size: 1.4rem; line-height: 1;
  color: var(--ink-soft); cursor: pointer; padding: 4px;
}
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-sub { font-size: 0.85rem; color: var(--ink-soft); margin: -4px 0 0; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; font-weight: 600; }
.field input, .field select {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.92rem;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.field .hint { font-weight: 400; font-size: 0.78rem; color: var(--ink-soft); }
.field em { font-weight: 400; color: var(--ink-soft); font-style: normal; }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.form-msg { font-size: 0.82rem; min-height: 1em; }
.form-msg.error { color: var(--danger); }
.form-msg.success { color: var(--teal); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--steel-dark);
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  z-index: 60;
}
.toast[hidden] { display: none; }

/* ---------- Responsive: collapse table to cards ---------- */
@media (max-width: 760px) {
  .check-table thead { display: none; }
  .check-table, .check-table tbody, .check-table tr, .check-table td { display: block; width: 100%; }
  .check-table tbody tr {
    border-bottom: 1px solid var(--border);
    padding: 14px;
  }
  .check-table tbody td {
    border: none;
    padding: 4px 0;
    display: flex;
    justify-content: space-between;
    gap: 12px;
  }
  .check-table tbody td::before {
    content: attr(data-label);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-soft);
    font-weight: 700;
  }
  .row-actions { justify-content: flex-start; padding-top: 8px; }
}
