/* ===========================================================
   LOANER — design tokens
   Concept: a claim-ticket ledger. Every loan is a torn-stub
   ticket; confirmations land as a rotated rubber stamp.
   =========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@500;700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --paper: #e6e3dc;
  --paper-deep: #d9d5c9;
  --card: #f2f0ea;
  --ink: #2a2a28;
  --ink-soft: #6b6a63;
  --ink-faint: #9a9890;
  --brass: #c65d2e;
  --brass-dark: #9c4620;
  --brass-tint: #f0d4c0;
  --stamp-red: #a83226;
  --stamp-green: #5c7a4f;
  --line: #c7c2b5;
  --shadow: 0 2px 0 rgba(42,42,40,0.08), 0 10px 24px -14px rgba(42,42,40,0.4);
  --radius: 3px;
  --font-display: 'Oswald', sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  background-image:
    radial-gradient(circle, rgba(42,42,40,0.07) 1px, transparent 1px);
  background-size: 15px 15px;
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100vh;
}

button, input, textarea, select { font-family: inherit; }

a { color: inherit; }

/* focus visibility, always */
:focus-visible {
  outline: 2px solid var(--brass-dark);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- App shell ---------- */
#app { max-width: 620px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 2px solid var(--ink);
}
.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.02em;
  display: flex; align-items: baseline; gap: 8px;
}
.brand small {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--ink); object-fit: cover;
  cursor: pointer; background: var(--card);
}

.main { flex: 1; padding: 18px 16px 100px; }

.tabbar {
  position: sticky; bottom: 0;
  display: flex; border-top: 2px solid var(--ink);
  background: var(--paper-deep);
}
.tabbar button {
  flex: 1; padding: 12px 4px 10px; background: none; border: none;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-soft); cursor: pointer;
  border-top: 3px solid transparent;
}
.tabbar button.active { color: var(--ink); border-top-color: var(--brass); font-weight: 600; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-body); font-weight: 600; font-size: 15px;
  padding: 12px 18px; border-radius: var(--radius);
  border: 2px solid var(--ink); background: var(--card);
  color: var(--ink); cursor: pointer;
  transition: transform 0.08s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brass); border-color: var(--brass-dark); color: #fff; }
.btn-primary:hover { background: var(--brass-dark); }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-danger { border-color: var(--stamp-red); color: var(--stamp-red); background: transparent; }
.btn-sm { padding: 8px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-family: var(--font-mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft);
  margin-bottom: 6px;
}
.field input[type="text"], .field input[type="date"], .field textarea {
  width: 100%; padding: 11px 12px; border: 2px solid var(--ink);
  border-radius: var(--radius); background: var(--card); font-size: 15px; color: var(--ink);
}
.field textarea { resize: vertical; min-height: 60px; }

.photo-capture {
  border: 2px dashed var(--line); border-radius: var(--radius);
  background: var(--card); text-align: center; padding: 22px 16px;
  cursor: pointer;
}
.photo-capture img { width: 100%; border-radius: var(--radius); display: block; }
.photo-capture .hint { font-size: 13px; color: var(--ink-soft); margin-top: 6px; }

/* ---------- Ticket card ---------- */
.ticket {
  position: relative;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 22px;
  overflow: hidden;
}
.ticket::before {
  content: "";
  position: absolute; top: 11px; left: 12px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--paper-deep);
  z-index: 2;
}
.ticket-stub {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px 10px 32px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.06em; text-transform: uppercase;
}
.ticket-stub .code { color: var(--brass-tint); }
.ticket-perf {
  height: 0; border-top: 2px dashed var(--line); position: relative;
}
.ticket-body { padding: 16px; }
.ticket-item {
  font-family: var(--font-display); font-weight: 700; font-size: 19px;
  margin: 0 0 4px;
}
.ticket-meta {
  font-size: 13px; color: var(--ink-soft); margin-bottom: 12px;
  display: flex; flex-wrap: wrap; gap: 6px 14px;
}
.ticket-meta .overdue { color: var(--stamp-red); font-weight: 700; }
.ticket-photos { display: flex; gap: 10px; margin-bottom: 12px; }
.ticket-photos .ph { flex: 1; }
.ticket-photos img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: var(--radius); border: 2px solid var(--ink);
}
.ticket-photos .ph-label {
  font-family: var(--font-mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-soft); margin-top: 4px;
}
.ticket-status {
  display: inline-block; font-family: var(--font-mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
  padding: 4px 9px; border-radius: 20px; border: 1px solid currentColor;
}
.status-awaiting_borrower { color: var(--ink-soft); }
.status-awaiting_loanout_confirmation { color: var(--brass-dark); }
.status-active { color: var(--stamp-green); }
.status-return_pending { color: var(--brass-dark); }
.status-completed { color: var(--ink-faint); }
.status-cancelled { color: var(--ink-faint); text-decoration: line-through; }

.stamp {
  position: absolute; top: 14px; right: -6px;
  transform: rotate(-9deg);
  font-family: var(--font-display); font-weight: 700; font-size: 13px;
  color: var(--stamp-red); border: 3px solid var(--stamp-red);
  border-radius: 6px; padding: 4px 10px;
  letter-spacing: 0.05em; text-transform: uppercase;
  opacity: 0.88; mix-blend-mode: multiply;
  pointer-events: none;
}

.ticket-actions { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }

/* ---------- Confirm rows ---------- */
.confirm-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border: 1.5px solid var(--line); border-radius: var(--radius);
  margin-bottom: 8px; font-size: 14px; background: rgba(255,255,255,0.35);
}
.confirm-row .who { font-weight: 600; }
.confirm-row .yes { color: var(--stamp-green); font-weight: 700; font-family: var(--font-mono); font-size: 12px; }
.confirm-row .no { color: var(--ink-faint); font-family: var(--font-mono); font-size: 12px; }

/* ---------- Misc ---------- */
.section-title {
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft);
  margin: 4px 0 12px; padding-bottom: 6px; border-bottom: 2px solid var(--ink);
}
.empty-state {
  text-align: center; padding: 48px 20px; color: var(--ink-soft);
}
.empty-state .glyph { font-size: 34px; margin-bottom: 10px; }
.banner {
  position: fixed; left: 50%; bottom: 78px; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 10px 18px;
  border-radius: 20px; font-size: 14px; z-index: 40;
  box-shadow: var(--shadow);
}
.center-screen {
  min-height: 80vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; gap: 14px; padding: 20px;
}
.center-screen h1 { font-family: var(--font-display); font-size: 30px; margin: 0; }
.center-screen p { color: var(--ink-soft); max-width: 320px; margin: 0; }

.auth-divider {
  display: flex; align-items: center; gap: 10px; width: 100%;
  font-family: var(--font-mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-faint); margin: 18px 0 12px;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}
.auth-tabs {
  display: flex; width: 100%; border: 2px solid var(--ink); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 16px;
}
.auth-tab {
  flex: 1; padding: 9px 6px; border: none; background: var(--card);
  font-family: var(--font-mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--ink-soft); cursor: pointer;
}
.auth-tab.active { background: var(--ink); color: var(--paper); font-weight: 600; }
/* ---------- Notification bell ---------- */
.bell-btn {
  position: relative; background: none; border: 2px solid transparent;
  font-size: 20px; cursor: pointer; padding: 4px 6px; border-radius: var(--radius);
}
.bell-btn:hover { border-color: var(--line); }
.notif-badge {
  position: absolute; top: -2px; right: -2px;
  background: var(--stamp-red); color: #fff;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px;
}
.notif-panel {
  position: absolute; top: 42px; right: 0; width: 280px; max-height: 340px;
  overflow-y: auto; background: var(--card); border: 2px solid var(--ink);
  border-radius: var(--radius); box-shadow: var(--shadow); z-index: 50;
}
.notif-item {
  padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px;
}
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--brass-tint); font-weight: 600; }
.notif-item:hover { background: rgba(0,0,0,0.04); }
.notif-msg { line-height: 1.4; }

/* ---------- Toggles / dispute ---------- */
.toggle-row {
  display: flex; align-items: center; gap: 8px; font-size: 14px;
  margin-bottom: 8px; cursor: pointer;
}
.toggle-row input { width: 16px; height: 16px; accent-color: var(--brass-dark); cursor: pointer; }
.dispute-flag {
  display: inline-block; font-family: var(--font-mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700;
  color: #fff; background: var(--stamp-red); padding: 2px 7px; border-radius: 10px;
  vertical-align: middle; margin-left: 6px;
}

.invite-box {
  font-family: var(--font-mono); font-size: 13px; background: var(--card);
  border: 2px solid var(--ink); border-radius: var(--radius); padding: 10px 12px;
  word-break: break-all; margin-bottom: 10px;
}
.back-link {
  font-family: var(--font-mono); font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-soft); background: none; border: none;
  cursor: pointer; padding: 4px 0; margin-bottom: 10px;
}
