/* Property Catalog — mobile-first, no framework */
* { box-sizing: border-box; margin: 0; }

:root {
  --bg: #f5f5f4;
  --card: #ffffff;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --primary: #1c1917;
  --danger: #dc2626;
  --radius: 12px;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; padding: 2rem; }
.error { color: var(--danger); font-size: 0.9rem; margin-top: 0.5rem; }
.small-text { font-size: 0.78rem; }
.spacer { flex: 1; }

/* ---------------- buttons & inputs ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 0.3rem;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 0.55rem 0.9rem; border-radius: 999px; font-size: 0.9rem;
  cursor: pointer; user-select: none;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 0.35rem 0.7rem; font-size: 0.82rem; }
.btn:disabled { opacity: 0.5; cursor: default; }

input, select, textarea {
  width: 100%; padding: 0.6rem 0.75rem; font-size: 1rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--ink); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #a8a29e; }

/* ---------------- login ---------------- */
#login-view { display: grid; place-items: center; min-height: 100dvh; padding: 1rem; }
.login-card {
  width: min(360px, 100%); background: var(--card); padding: 2rem;
  border-radius: 16px; border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 0.8rem;
}
.login-card h1 { font-size: 1.4rem; }

/* ---------------- header ---------------- */
header {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg); border-bottom: 1px solid var(--line);
  padding: max(0.6rem, env(safe-area-inset-top)) 1rem 0.6rem;
  display: flex; flex-direction: column; gap: 0.6rem;
}
.header-row { display: flex; align-items: center; justify-content: space-between; }
.header-row h1 { font-size: 1.15rem; }

.dashboard { display: flex; gap: 1.5rem; }
.stat span { font-weight: 700; font-size: 1.05rem; display: block; }
.stat label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.tabs { display: flex; gap: 0.4rem; overflow-x: auto; scrollbar-width: none; }
.tab {
  --tab-color: var(--ink);
  flex-shrink: 0; border: 1px solid var(--line); background: var(--card);
  padding: 0.4rem 0.8rem; border-radius: 999px; font-size: 0.85rem; cursor: pointer;
}
.tab.active { background: var(--tab-color); border-color: var(--tab-color); color: #fff; }
.tab .count { opacity: 0.65; font-size: 0.75rem; }

.filter-row { display: flex; gap: 0.5rem; align-items: center; }
.filter-row select { width: auto; flex: 1; min-width: 0; padding: 0.45rem 0.6rem; font-size: 0.85rem; }
.filter-row .btn { flex-shrink: 0; }

/* ---------------- grid & cards ---------------- */
.grid {
  display: grid; gap: 0.8rem; padding: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; display: flex; flex-direction: column;
}
.card:active { transform: scale(0.98); }
.card-photo { aspect-ratio: 1; background: #fafaf9; }
.card-photo img { width: 100%; height: 100%; object-fit: contain; }
.photo-placeholder {
  width: 100%; height: 100%; display: grid; place-items: center;
  color: #d6d3d1; font-size: 2rem;
}
.card-body { padding: 0.6rem 0.7rem 0.7rem; display: flex; flex-direction: column; gap: 0.25rem; }
.card-body h3 {
  font-size: 0.85rem; font-weight: 600; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-body p { font-size: 0.78rem; }
.chip {
  --chip: #6b7280;
  align-self: flex-start; font-size: 0.68rem; font-weight: 600;
  color: var(--chip); border: 1px solid color-mix(in srgb, var(--chip) 40%, transparent);
  padding: 0.1rem 0.45rem; border-radius: 999px;
}
.status-badge {
  align-self: flex-start; font-size: 0.7rem; text-transform: uppercase;
  background: #fef3c7; color: #92400e; padding: 0.1rem 0.4rem; border-radius: 4px;
}

/* ---------------- dialogs ---------------- */
dialog {
  border: none; border-radius: 16px; padding: 1.2rem;
  width: min(560px, calc(100vw - 2rem));
  max-height: calc(100dvh - 4rem);
}
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.8rem; }
.dialog-head h2 { font-size: 1.1rem; }
#item-form { display: flex; flex-direction: column; gap: 0.65rem; }
#item-form label { font-size: 0.8rem; color: var(--muted); display: flex; flex-direction: column; gap: 0.25rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; }
.dialog-actions { display: flex; gap: 0.5rem; margin-top: 0.4rem; }

.photo-box { display: flex; flex-direction: column; gap: 0.5rem; align-items: center; }
.photo-box img { max-width: 100%; max-height: 220px; border-radius: var(--radius); }
.photo-box .photo-placeholder {
  height: 120px; width: 100%; border: 1px dashed var(--line); border-radius: var(--radius);
  font-size: 0.9rem; color: var(--muted);
}
.photo-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }

.search-row { display: flex; gap: 0.5rem; margin-bottom: 0.8rem; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.5rem; }
.image-result {
  border: 1px solid var(--line); border-radius: 8px; padding: 0; overflow: hidden;
  background: var(--card); cursor: pointer; aspect-ratio: 1;
}
.image-result img { width: 100%; height: 100%; object-fit: contain; }
.image-result:hover { outline: 2px solid var(--ink); }
