:root {
  --bg: #FAF7F2;
  --bg-card: #FFFFFF;
  --bg-subtle: #F2ECE1;
  --text: #1F2421;
  --text-muted: #5A625E;
  --border: #E2D9C8;
  --primary: #2A5C43;
  --primary-hover: #1E4632;
  --primary-light: #E6F2EC;
  --accent: #C86D51;
  --accent-light: #FDF1ED;
  --mine: #1D4ED8;
  --mine-light: #EFF6FF;
  --claimed: #64748B;
  --claimed-light: #F1F5F9;
  --gold: #D97706;
  --gold-light: #FEF3C7;
  --danger: #DC2626;
  --shadow-sm: 0 2px 6px rgba(31, 36, 33, 0.06);
  --shadow-md: 0 8px 24px rgba(31, 36, 33, 0.1);
  --shadow-lg: 0 20px 40px rgba(31, 36, 33, 0.18);
  --radius: 14px;
  --radius-sm: 8px;
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .serif {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.02em;
}

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

/* Top Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 247, 242, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
}

.navbar-inner {
  max-width: 1360px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  box-shadow: var(--shadow-sm);
}

.brand-text h1 {
  font-size: 1.2rem;
  line-height: 1.15;
}

.brand-text span {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: block;
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-subtle);
  padding: 0.3rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  overflow-x: auto;
}

.nav-tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.48rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
}

.nav-tab:hover {
  color: var(--text);
}

.nav-tab.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.badge-pill {
  background: var(--primary);
  color: #fff;
  font-size: 0.74rem;
  padding: 0.1rem 0.48rem;
  border-radius: 999px;
  font-weight: 700;
}

.badge-pill.mine {
  background: var(--mine);
}

.badge-pill.accent {
  background: var(--accent);
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-accent:hover:not(:disabled) {
  background: #b35a3e;
}

.btn-mine {
  background: var(--mine);
  color: #fff;
}

.btn-outline {
  background: var(--bg-card);
  color: var(--text);
  border-color: var(--border);
}

.btn-outline:hover:not(:disabled) {
  background: var(--bg-subtle);
}

.btn-danger-outline {
  background: #fff;
  color: var(--danger);
  border-color: #FCA5A5;
}

.btn-danger-outline:hover:not(:disabled) {
  background: #FEF2F2;
}

.btn-sm {
  padding: 0.36rem 0.7rem;
  font-size: 0.82rem;
}

.btn-lg {
  padding: 0.75rem 1.35rem;
  font-size: 1rem;
}

/* Container & Hero */
.container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 1.25rem;
}

.hero-banner {
  background: linear-gradient(135deg, #2A5C43 0%, #1D402F 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow-md);
}

.hero-content {
  max-width: 780px;
}

.hero-content h2 {
  font-size: 1.55rem;
  margin-bottom: 0.4rem;
  color: #FFFDF9;
}

.hero-content p {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.95rem;
  line-height: 1.55;
}

.hero-stats {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.stat-box {
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 0.7rem 1.1rem;
  min-width: 105px;
  text-align: center;
}

.stat-box .num {
  font-family: 'Fraunces', serif;
  font-size: 1.5rem;
  font-weight: 700;
  display: block;
  line-height: 1.1;
}

.stat-box .lbl {
  font-size: 0.75rem;
  opacity: 0.88;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* AI Processing Alert Bar */
.ai-status-bar {
  background: var(--gold-light);
  border: 1px solid #FCD34D;
  color: #92400E;
  padding: 0.75rem 1.15rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-weight: 500;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Filter & Search Toolbar */
.toolbar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  box-shadow: var(--shadow-sm);
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 240px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 0.62rem 1rem 0.62rem 2.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s;
}

.search-box input:focus {
  border-color: var(--primary);
  background: #fff;
}

.search-box .search-icon {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.filter-select {
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
}

.status-pills {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.status-pill {
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.status-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Items Grid */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(295px, 1fr));
  gap: 1.25rem;
}

.item-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  position: relative;
}

.item-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.item-card.is-claimed {
  background: #FCFBF9;
}

.item-card.is-mine {
  border: 2px solid var(--mine);
}

.item-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #EAE3D5;
  overflow: hidden;
  cursor: pointer;
}

.item-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s ease;
}

.item-media:hover img {
  transform: scale(1.03);
}

.item-badges-top {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  right: 0.65rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.4rem;
  pointer-events: none;
}

.tag-badge {
  background: rgba(31, 36, 33, 0.78);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.24rem 0.6rem;
  border-radius: 999px;
}

.status-badge {
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.26rem 0.68rem;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.status-badge.available {
  background: var(--primary);
  color: #fff;
}

.status-badge.mine {
  background: var(--mine);
  color: #fff;
}

.status-badge.claimed {
  background: #334155;
  color: #fff;
}

.view-context-btn {
  position: absolute;
  bottom: 0.6rem;
  right: 0.6rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(4px);
  color: var(--text);
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 999px;
  padding: 0.28rem 0.68rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.view-context-btn:hover {
  background: #fff;
}

.item-body {
  padding: 1rem 1.1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.item-meta-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.item-title {
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.item-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.claimed-banner {
  margin-top: 0.35rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  background: var(--claimed-light);
  color: #334155;
  border-left: 3px solid var(--claimed);
}

.claimed-banner.mine {
  background: var(--mine-light);
  color: #1E3A8A;
  border-left-color: var(--mine);
}

.item-footer {
  padding: 0.75rem 1.1rem 1rem;
  border-top: 1px solid var(--bg-subtle);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.item-footer .btn {
  flex: 1;
}

/* Interactive Photos Grid & Bounding Box Overlay */
.photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 1.5rem;
}

.photo-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.photo-stage-wrapper {
  position: relative;
  width: 100%;
  background: #18181B;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.photo-stage {
  position: relative;
  display: inline-block;
  width: 100%;
  line-height: 0;
  user-select: none;
}

.photo-stage img {
  width: 100%;
  height: auto;
  display: block;
}

/* Interactive Bounding Boxes on Photos */
.bbox-overlay {
  position: absolute;
  border: 2.5px solid #22C55E;
  background: rgba(34, 197, 94, 0.12);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.16s ease;
  z-index: 10;
}

.bbox-overlay:hover,
.bbox-overlay.active-highlight {
  background: rgba(34, 197, 94, 0.28);
  border-width: 3px;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85), 0 4px 16px rgba(0, 0, 0, 0.35);
  z-index: 25;
}

.bbox-overlay.is-claimed {
  border-color: #94A3B8;
  border-style: dashed;
  background: rgba(15, 23, 42, 0.22);
}

.bbox-overlay.is-claimed:hover,
.bbox-overlay.is-claimed.active-highlight {
  background: rgba(15, 23, 42, 0.38);
}

.bbox-overlay.is-mine {
  border-color: #3B82F6;
  border-style: solid;
  background: rgba(59, 130, 246, 0.2);
}

.bbox-tag {
  position: absolute;
  top: -11px;
  left: -2px;
  background: #15803D;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 2px 5px rgba(0,0,0,0.35);
  pointer-events: none;
}

.bbox-overlay.is-claimed .bbox-tag {
  background: #475569;
}

.bbox-overlay.is-mine .bbox-tag {
  background: #1D4ED8;
}

/* Modal System */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 20, 18, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  max-width: 1180px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.modal-sm {
  max-width: 520px;
}

.modal-header {
  padding: 1rem 1.35rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 30;
}

.modal-body {
  padding: 1.35rem;
}

/* Photo Inspector Split Layout */
.photo-inspector {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 1.35rem;
  align-items: start;
}

@media (max-width: 900px) {
  .photo-inspector {
    grid-template-columns: 1fr;
  }
}

.inspector-items-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 72vh;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.inspector-item-row {
  display: flex;
  gap: 0.85rem;
  padding: 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  transition: all 0.15s;
  cursor: pointer;
}

.inspector-item-row:hover,
.inspector-item-row.active-highlight {
  border-color: var(--primary);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.inspector-item-row.is-mine {
  border-color: var(--mine);
  background: var(--mine-light);
}

.inspector-item-thumb {
  width: 74px;
  height: 74px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #e5e0d5;
  border: 1px solid var(--border);
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.86rem;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.form-control {
  width: 100%;
  padding: 0.62rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
}

/* Roster & Tables */
.person-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.person-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--bg-subtle);
  margin-bottom: 0.85rem;
}

.claim-mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}

.claim-mini-item {
  display: flex;
  gap: 0.7rem;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  align-items: center;
}

.claim-mini-item img {
  width: 58px;
  height: 58px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

/* Manual Box Drawing Crosshair */
.drawing-mode .photo-stage {
  cursor: crosshair;
}

.draw-rect {
  position: absolute;
  border: 2.5px dashed #F59E0B;
  background: rgba(245, 158, 11, 0.25);
  pointer-events: none;
  z-index: 40;
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: #1F2421;
  color: #fff;
  padding: 0.75rem 1.15rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 0.9rem;
  font-weight: 500;
  max-width: 360px;
}

.toast.success {
  background: var(--primary);
}

.toast.error {
  background: var(--danger);
}

/* Mobile Floating Upload Button for Heather */
.fab-upload {
  position: fixed;
  bottom: 1.35rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  box-shadow: 0 10px 25px rgba(42, 92, 67, 0.4);
  border-radius: 999px;
  padding: 0.8rem 1.5rem;
  font-size: 0.98rem;
}

@media (min-width: 769px) {
  .fab-upload {
    left: auto;
    right: 1.5rem;
    transform: none;
  }
}

@media (max-width: 640px) {
  .photos-grid {
    grid-template-columns: 1fr;
  }
  .hero-banner {
    padding: 1.15rem;
  }
  .hero-content h2 {
    font-size: 1.25rem;
  }
}

@media print {
  .navbar, .toolbar, .fab-upload, .no-print {
    display: none !important;
  }
  body {
    background: #fff;
  }
  .person-card, .item-card {
    break-inside: avoid;
    box-shadow: none;
  }
}
