:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --surface-2: #f3efe8;
  --separator: rgba(31, 36, 32, 0.08);
  --separator-strong: rgba(31, 36, 32, 0.16);
  --text: #1a1f1b;
  --text-2: #2c322d;
  --muted: #6b6f6c;
  --accent: #1f5641;
  --accent-pressed: #18432f;
  --accent-soft: rgba(31, 86, 65, 0.12);
  --accent-fg: #ffffff;
  --warn: #b87523;
  --danger: #a4302d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.18);
  --radius-sm: 12px;
  --radius: 16px;
  --radius-lg: 22px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e0f;
    --surface: #1a1a1b;
    --surface-2: #232325;
    --separator: rgba(255, 255, 255, 0.08);
    --separator-strong: rgba(255, 255, 255, 0.18);
    --text: #f5f3ee;
    --text-2: #e8e6e1;
    --muted: #9a9a9c;
    --accent: #3bb68a;
    --accent-pressed: #34a378;
    --accent-soft: rgba(59, 182, 138, 0.18);
    --accent-fg: #0e0e0f;
    --warn: #e0a85a;
    --danger: #e07469;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.85);
  }
}
:root[data-theme="dark"] {
  --bg: #0e0e0f;
  --surface: #1a1a1b;
  --surface-2: #232325;
  --separator: rgba(255, 255, 255, 0.08);
  --separator-strong: rgba(255, 255, 255, 0.18);
  --text: #f5f3ee;
  --text-2: #e8e6e1;
  --muted: #9a9a9c;
  --accent: #3bb68a;
  --accent-pressed: #34a378;
  --accent-soft: rgba(59, 182, 138, 0.18);
  --accent-fg: #0e0e0f;
  --warn: #e0a85a;
  --danger: #e07469;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.85);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display',
    'Helvetica Neue', 'Inter', system-ui, sans-serif;
  font-size: 17px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
button { font: inherit; cursor: pointer; border: 0; background: transparent; color: inherit; }

/* ---------- Form controls ---------- */
input, textarea, select {
  font: inherit;
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--separator-strong);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none; appearance: none;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
textarea { resize: vertical; min-height: 72px; }
input[type="file"] { padding: 12px 14px; }

label {
  display: block;
  margin: 16px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.1px;
}
label > input, label > textarea, label > select {
  margin-top: 8px; color: var(--text); font-weight: 400; font-size: 16px;
}

.muted { color: var(--muted); font-size: 14px; }

/* ---------- Buttons ---------- */
button.primary {
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
  font-size: 16px;
  padding: 14px 26px;
  border-radius: 980px;
  transition: background 0.15s, transform 0.05s, opacity 0.15s;
  min-height: 48px;
  letter-spacing: 0.1px;
}
button.primary:hover { background: var(--accent-pressed); }
button.primary:active { transform: scale(0.98); }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }

button.secondary {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 16px;
  padding: 14px 26px;
  border-radius: 980px;
  border: 1px solid var(--separator-strong);
  min-height: 48px;
}
button.secondary:hover { background: var(--surface-2); }

button.link {
  color: var(--accent);
  font-weight: 600;
  font-size: 15px;
  padding: 10px 14px;
  border-radius: 8px;
}
button.link:hover { background: var(--accent-soft); }

button.danger {
  color: var(--danger);
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 980px;
  border: 1px solid var(--danger);
  background: transparent;
}
button.danger:hover { background: var(--danger); color: white; }

/* Icon menu button */
.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  width: 40px; height: 40px;
  border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- Top bar (minimal) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--separator);
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 20px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}
.brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

/* Desktop top nav (mirrors bottom tabbar) */
.topnav {
  display: none;
  justify-self: center;
  background: var(--surface-2);
  border: 1px solid var(--separator);
  padding: 3px;
  border-radius: 12px;
  gap: 2px;
}
.topnav .tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.1px;
  transition: background 0.15s, color 0.15s;
}
.topnav .tab:hover { color: var(--text); }
.topnav .tab.active {
  background: var(--accent);
  color: var(--accent-fg);
  box-shadow: var(--shadow-sm);
}
.topnav .tab svg { width: 16px; height: 16px; }

@media (max-width: 899px) {
  .topbar-inner { grid-template-columns: 1fr auto; }
}

/* ---------- Menu dropdown ---------- */
.menu {
  position: absolute;
  top: 60px;
  right: 12px;
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  min-width: 240px;
  padding: 6px;
  z-index: 50;
  animation: popIn 0.15s ease;
}
.menu.hidden { display: none; }
.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.who { color: var(--muted); cursor: default; font-size: 13px; padding-bottom: 4px; }
.menu-item.who:hover { background: transparent; }
.menu-divider { height: 1px; background: var(--separator); margin: 6px 4px; }
.menu select {
  background: var(--surface-2); border: 0; padding: 6px 10px;
  border-radius: 8px; font-size: 13px; font-weight: 600;
  width: auto;
}

/* ---------- Layout ---------- */
main {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 20px 120px;
}
.panel { display: none; animation: fadeIn 0.2s ease; }
.panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.96) translateY(-4px); } to { opacity: 1; transform: none; } }

.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.6px; margin: 0; }
h2 { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; margin: 0; }
h3 { font-size: 20px; font-weight: 700; letter-spacing: -0.2px; margin: 0 0 16px; }
h4 { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; margin: 22px 0 10px; }

.search {
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--separator-strong);
  border-radius: 14px;
  padding: 13px 18px;
  font-size: 16px;
}

/* ---------- Inventory grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.item {
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.item:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow-md); }
.item .thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 12px;
  background: var(--surface-2);
  margin-bottom: 12px;
}
.item .thumb-empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13px;
}
.item .name { font-weight: 600; font-size: 16px; line-height: 1.3; }
.item .meta {
  margin-top: 8px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px;
}

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 980px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.badge.in { background: var(--accent-soft); color: var(--accent); }
.badge.in::before { background: var(--accent); }
.badge.out {
  background: var(--accent); color: var(--accent-fg);
}
.badge.out::before { background: var(--accent-fg); }
.badge.maintenance { background: var(--surface-2); color: var(--muted); border: 1px solid var(--separator); }

/* ---------- List rows ---------- */
.list { display: flex; flex-direction: column; gap: 12px; }
.row-card {
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  gap: 14px;
  align-items: center;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s;
}
.row-card:hover { transform: translateY(-1px); border-color: var(--accent); box-shadow: var(--shadow-sm); }
.row-card .thumb {
  width: 56px; height: 56px;
  object-fit: cover;
  border-radius: 12px;
  background: var(--surface-2);
  flex-shrink: 0;
}
.row-card .body { flex: 1; min-width: 0; }
.row-card .body .title { font-weight: 600; font-size: 16px; }
.row-card .body .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.list.compact .row-card { padding: 12px 14px; cursor: default; }
.list.compact .row-card:hover { transform: none; box-shadow: none; }

/* ---------- Empty states ---------- */
.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
}
.empty .icon {
  font-size: 36px;
  margin-bottom: 14px;
  opacity: 0.4;
  display: inline-flex;
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--surface-2);
  align-items: center; justify-content: center;
}
.empty p { margin: 6px 0; }
.empty p strong { color: var(--text); font-weight: 600; }

/* ---------- Bottom tab bar ---------- */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 30;
  background: var(--bg);
  border-top: 1px solid var(--separator);
  padding: 6px 6px max(8px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-around;
  gap: 4px;
}
.tabbar .tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 4px;
  border-radius: 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  transition: color 0.15s, background 0.15s;
}
.tabbar .tab svg { width: 22px; height: 22px; }
.tabbar .tab.active { color: var(--accent); background: var(--accent-soft); }
.tabbar .tab:hover { color: var(--text); }

/* ---------- Floating action button ---------- */
.fab {
  position: fixed;
  bottom: calc(80px + max(8px, env(safe-area-inset-bottom)));
  right: 22px;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 30px;
  font-weight: 300;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  transition: transform 0.15s, background 0.15s;
  z-index: 28;
}
.fab:hover { transform: scale(1.06); background: var(--accent-pressed); }
.fab:active { transform: scale(0.94); }

/* ---------- Modals (sheet style on mobile) ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  z-index: 100;
  animation: fadeOverlay 0.18s ease;
}
@keyframes fadeOverlay { from { opacity: 0; } to { opacity: 1; } }
.modal.hidden { display: none; }
.modal-card {
  background: var(--surface);
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  padding: 26px 24px;
  box-shadow: var(--shadow-lg);
  animation: sheetIn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes sheetIn { from { opacity: 0; transform: scale(0.96) translateY(12px); } to { opacity: 1; transform: none; } }

@media (max-width: 700px) {
  .modal { align-items: flex-end; }
  .modal-card {
    max-width: 100%;
    max-height: 94vh;
    border-radius: 22px 22px 0 0;
    padding: 24px 20px max(24px, env(safe-area-inset-bottom));
    animation: slideUp 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
  }
  @keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
}

/* ---------- Auth ---------- */
body.auth {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
  background: var(--bg);
  position: relative;
}
.auth-corner-left {
  position: fixed;
  top: 18px; left: 18px;
  z-index: 5;
}
.auth-corner-right {
  position: fixed;
  top: 18px; right: 18px;
  z-index: 5;
}
body.auth .modal-card {
  max-width: 400px;
  border: 1px solid var(--separator);
  box-shadow: var(--shadow-md);
  animation: none;
}
body.auth h1 { margin: 0 0 6px; font-size: 32px; color: var(--accent); }
body.auth button.primary { width: 100%; margin-top: 10px; }
body.auth .name-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
body.auth .name-row label { margin: 16px 0 0; }

/* Sign in / Sign up toggle */
.auth-tabs {
  display: flex;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 3px;
  margin: 0 0 18px;
  gap: 0;
}
.auth-tabs .auth-tab {
  flex: 1;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.auth-tabs .auth-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.auth-form { display: none; }
.auth-form.active { display: block; }
.error { color: var(--danger); margin-top: 10px; min-height: 1em; font-size: 13px; font-weight: 500; }

/* ---------- Detail view ---------- */
.detail-hero {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 16px;
  margin-bottom: 14px;
  background: var(--surface-2);
}
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 6px;
  margin-bottom: 14px;
}
.gallery .ph {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  background: var(--surface-2);
}
.gallery .ph.cover { border-color: var(--accent); }
.gallery .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery .ph .cover-tag {
  position: absolute; top: 4px; left: 4px;
  background: var(--accent); color: var(--accent-fg);
  font-size: 9px; font-weight: 700;
  padding: 2px 6px; border-radius: 4px;
  letter-spacing: 0.4px;
}
.gallery .ph .x {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px;
  background: rgba(0,0,0,0.7); color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1;
  opacity: 0; transition: opacity 0.15s;
}
.gallery .ph:hover .x { opacity: 1; }
.gallery .ph.add {
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--separator-strong);
  color: var(--muted); font-size: 24px;
}
.gallery .ph.add input { display: none; }

.detail-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.detail-photos figure { margin: 0; }
.detail-photos img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 12px; }
.detail-photos figcaption { font-size: 11px; color: var(--muted); margin-top: 4px; text-align: center; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.rental-block { border-top: 1px solid var(--separator); padding: 16px 0; }
.rental-block:first-of-type { border-top: 0; padding-top: 0; }

/* ---------- Photo previews chips ---------- */
.previews {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 6px;
  margin-top: 10px;
}
.previews .pv {
  position: relative; aspect-ratio: 1 / 1;
  border-radius: 10px; overflow: hidden;
  background: var(--surface-2);
  border: 2px solid transparent;
}
.previews .pv.cover { border-color: var(--accent); }
.previews .pv img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: pointer; }
.previews .pv .cover-tag {
  position: absolute; top: 4px; left: 4px;
  background: var(--accent); color: var(--accent-fg);
  font-size: 9px; font-weight: 700;
  padding: 2px 6px; border-radius: 4px;
}

/* ---------- Signature pad ---------- */
.sigpad-wrap {
  position: relative;
  border: 1px dashed var(--separator-strong);
  border-radius: 14px;
  background: var(--surface-2);
  margin-top: 8px;
  overflow: hidden;
}
.sigpad {
  display: block; width: 100%; height: 180px;
  background: transparent;
  touch-action: none; cursor: crosshair;
}
.sigpad-clear {
  position: absolute; top: 8px; right: 8px;
  font-size: 12px; padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: 980px;
  color: var(--text);
}

/* ---------- PDF preview frame ---------- */
.pdf-frame {
  width: 100%;
  height: 360px;
  border: 1px solid var(--separator);
  border-radius: 14px;
  background: var(--surface-2);
  margin: 10px 0 6px;
}
.pdf-row { display: flex; align-items: center; gap: 12px; }
.pdf-row .doc-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
}

/* ---------- Public signing page ---------- */
body.signing-page { background: var(--bg); padding: 0; }
.signing-wrap { max-width: 760px; margin: 0 auto; padding: 28px 20px 60px; }
.signing-doc {
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: 16px;
  padding: 28px;
  margin: 18px 0;
  white-space: pre-wrap;
  font-size: 15px; line-height: 1.55;
}
.signing-meta { color: var(--muted); font-size: 13px; margin: 0 0 6px; }
.signed-block {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 16px;
  padding: 22px;
  text-align: center;
  margin-top: 18px;
}
.signed-block img { max-width: 280px; max-height: 120px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: calc(100px + max(8px, env(safe-area-inset-bottom)));
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: var(--bg);
  padding: 14px 26px;
  border-radius: 980px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.1), opacity 0.3s;
  pointer-events: none;
  max-width: calc(100vw - 40px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); color: white; }

/* ---------- Mobile/iPad tweaks ---------- */
@media (max-width: 700px) {
  body { font-size: 16px; }
  main { padding: 20px 16px 130px; }
  .topbar-inner { padding: 12px 16px; }
  .brand { font-size: 18px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  h2 { font-size: 24px; }
  .menu { right: 12px; left: 12px; }
}

/* ---------- Filter chips ---------- */
.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.chip {
  background: var(--surface);
  border: 1px solid var(--separator-strong);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 980px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover { border-color: var(--accent); }
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

/* ---------- Page tabs (in field editor) ---------- */
.page-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--separator);
  padding-bottom: 8px;
}
.page-tabs .page-tab {
  padding: 7px 14px;
  background: var(--surface-2);
  border: 1px solid var(--separator);
  color: var(--muted);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.page-tabs .page-tab:hover { color: var(--text); border-color: var(--separator-strong); }
.page-tabs .page-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.page-tabs .page-tab .count {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 980px;
  background: rgba(0,0,0,0.15);
  font-size: 10px;
}
.page-tabs .page-tab.active .count { background: rgba(255,255,255,0.25); }

/* Hide non-active pages in editor */
.pdf-pages .pdf-page-wrap { display: none; }
.pdf-pages .pdf-page-wrap.active { display: block; }

/* ---------- Team modal ---------- */
.team-row .badge.admin {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.team-row .badge.admin::before { background: var(--accent-fg); }

/* ---------- Field editor (DocuSign-style) ---------- */
.field-editor h3 { font-size: 18px; }
.field-toolbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.field-toolbar .chip { padding: 7px 14px; }
.field-toolbar .chip:hover { background: var(--accent-soft); }

.pdf-pages {
  max-height: 70vh;
  overflow-y: auto;
  background: var(--surface-2);
  padding: 16px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.pdf-page-wrap {
  position: relative;
  background: white;
  box-shadow: var(--shadow-sm);
  border-radius: 4px;
  overflow: hidden;
  max-width: 100%;
}
.pdf-page-wrap canvas { display: block; max-width: 100%; height: auto; }
.pdf-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none; /* page itself doesn't capture clicks; markers do */
}
.pdf-page-label {
  position: absolute;
  top: 8px; left: 8px;
  background: var(--text);
  color: var(--bg);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  pointer-events: none;
}

.field-marker {
  position: absolute;
  background: rgba(31, 86, 65, 0.18);
  border: 2px solid var(--accent);
  border-radius: 4px;
  cursor: move;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 0 6px;
  user-select: none;
  display: flex;
  align-items: center;
  touch-action: none;
  pointer-events: auto;
  background-clip: padding-box;
}
.field-marker.type-signature { background: rgba(31, 86, 65, 0.22); }
:root[data-theme="dark"] .field-marker,
.field-marker { /* keep readable in dark mode too */ }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .field-marker {
    background: rgba(59, 182, 138, 0.22);
    color: #fff;
  }
}
:root[data-theme="dark"] .field-marker {
  background: rgba(59, 182, 138, 0.22);
  color: #fff;
}

.field-marker .lbl { pointer-events: none; }
.field-marker .resize {
  position: absolute;
  bottom: -7px; right: -7px;
  width: 16px; height: 16px;
  background: var(--accent);
  border: 2px solid white;
  border-radius: 50%;
  cursor: nwse-resize;
  touch-action: none;
}
.field-marker .x {
  position: absolute;
  top: -10px; right: -10px;
  width: 22px; height: 22px;
  background: #c33;
  color: white;
  border: 2px solid white;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}

/* Field hint inside visitor modal */
.field-hint {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 10px 0 4px;
  font-size: 13px;
  line-height: 1.45;
}
.field-hint strong { display: block; margin-bottom: 4px; }

/* ---------- Desktop overrides (kept at end so they win) ---------- */
@media (min-width: 900px) {
  .topnav { display: inline-flex; }
  .tabbar { display: none; }
  .fab { bottom: 30px; right: 30px; }
  main { padding-bottom: 60px; }
  .toast { bottom: 30px; }
}
