/* =========================================================
   Shreya Notebook ? Premium Real Estate Inventory UI
   Apple Wallet ? Notes ? Airbnb ? Linear ? Material 3
   ========================================================= */

:root {
  --accent: #C89B3C;
  --accent-hover: #D4AB4F;
  --accent-pressed: #B08A32;
  --accent-soft: rgba(200, 155, 60, 0.16);
  --accent-glow: rgba(200, 155, 60, 0.32);

  --bg: #F7F8FC;
  --bg-soft: #EEF0F6;
  --bg-elevated: rgba(255, 255, 255, 0.82);
  --card: rgba(255, 255, 255, 0.78);
  --card-solid: #FFFFFF;
  --card-border: rgba(15, 17, 21, 0.07);
  --text: #12141A;
  --text-secondary: #5A6170;
  --text-muted: #8B92A0;

  --danger: #E5484D;
  --danger-soft: rgba(229, 72, 77, 0.12);
  --call: #3B82F6;
  --call-soft: rgba(59, 130, 246, 0.12);
  --wa: #25D366;
  --wa-soft: rgba(37, 211, 102, 0.14);
  --edit: #C89B3C;
  --edit-soft: rgba(200, 155, 60, 0.14);

  --hot: #EF4444;
  --hot-soft: rgba(239, 68, 68, 0.14);
  --warm: #F59E0B;
  --warm-soft: rgba(245, 158, 11, 0.16);
  --cold: #22C55E;
  --cold-soft: rgba(34, 197, 94, 0.14);

  --req-1: #6366F1;
  --req-2: #0EA5E9;
  --req-3: #8B5CF6;
  --req-shop: #EC4899;
  --req-office: #64748B;
  --req-plot: #10B981;
  --req-villa: #D97706;
  --req-default: #94A3B8;

  --shadow-sm: 0 1px 2px rgba(15, 17, 21, 0.04);
  --shadow: 0 8px 28px rgba(15, 17, 21, 0.07), 0 2px 6px rgba(15, 17, 21, 0.04);
  --shadow-lg: 0 20px 50px rgba(15, 17, 21, 0.12), 0 6px 14px rgba(15, 17, 21, 0.06);
  --shadow-fab: 0 10px 30px rgba(200, 155, 60, 0.45);
  --shadow-search: 0 4px 18px rgba(15, 17, 21, 0.06);

  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 24px;
  --radius-xl: 28px;
  --radius-full: 999px;

  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Instrument Serif", Georgia, serif;

  --btn-h: 52px;
  --fab-size: 62px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --vv-offset: 0px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration: 250ms;
  --app-max: 680px;
  --top-z: 45;
}

html[data-theme="dark"] {
  --bg: #0B0D10;
  --bg-soft: #14171D;
  --bg-elevated: rgba(18, 21, 27, 0.88);
  --card: rgba(22, 26, 33, 0.82);
  --card-solid: #161A21;
  --card-border: rgba(255, 255, 255, 0.07);
  --text: #F4F5F7;
  --text-secondary: #A8AEB8;
  --text-muted: #6E7583;

  --danger: #F2555A;
  --danger-soft: rgba(242, 85, 90, 0.16);
  --call: #60A5FA;
  --call-soft: rgba(96, 165, 250, 0.14);
  --wa: #34D399;
  --wa-soft: rgba(52, 211, 153, 0.14);
  --edit: #C89B3C;
  --edit-soft: rgba(200, 155, 60, 0.16);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 10px 32px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55), 0 6px 16px rgba(0, 0, 0, 0.35);
  --shadow-fab: 0 10px 34px rgba(200, 155, 60, 0.5);
  --shadow-search: 0 4px 20px rgba(0, 0, 0, 0.4);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(ellipse 110% 70% at 50% -18%, var(--accent-soft), transparent 52%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
  transition: background-color var(--duration) var(--ease), color var(--duration) var(--ease);
}

button, input, textarea, select { font: inherit; color: inherit; }
button {
  cursor: pointer;
  border: none;
  background: none;
  -webkit-user-select: none;
  user-select: none;
}
input, textarea {
  outline: none;
  border: none;
  background: transparent;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

/* ---------- Splash ---------- */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  background: var(--bg);
  transition: opacity var(--duration) var(--ease), visibility var(--duration) var(--ease);
}
.loading-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.splash-brand { text-align: center; }
.splash-mark {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: linear-gradient(145deg, var(--accent), var(--accent-pressed));
  color: #0B0D10;
  font-family: var(--font-display);
  font-size: 2.2rem;
  box-shadow: var(--shadow-fab);
}
.splash-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}
.splash-sub {
  margin-top: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--card-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- App ---------- */
html.page-app,
body.page-app {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

body.page-app {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: hidden;
}

.app {
  --app-top-height: 0px;
  max-width: var(--app-max);
  margin: 0 auto;
  padding: 0 16px;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Pinned header (outside inventory scroller) ---------- */
.app-top {
  position: relative;
  top: 0;
  z-index: var(--top-z);
  flex: 0 0 auto;
  margin: 0 -16px;
  padding: calc(6px + var(--safe-top)) 16px 10px;
  /* Opaque ? list scrolls in a sibling, never under the header */
  background: var(--bg);
  isolation: isolate;
  transition: box-shadow var(--duration) var(--ease), background var(--duration) var(--ease);
}
.app-top.is-scrolled {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--card-border);
  box-shadow: 0 10px 28px rgba(15, 17, 21, 0.06);
}
html[data-theme="dark"] .app-top.is-scrolled {
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.4);
}

/* Independent scroll region for inventory ? fills leftover viewport under header */
.app-scroll {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  /* Gap between pinned header and first card */
  padding-top: 8px;
  /* Clearance so last card sits above the fixed FAB */
  padding-bottom: calc(92px + var(--safe-bottom));
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 2px 14px;
  animation: fadeSlideDown var(--duration) var(--ease);
}
.header-text { min-width: 0; flex: 1; }
.app-title {
  font-family: var(--font-display);
  font-size: clamp(1.95rem, 6.4vw, 2.45rem);
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1.08;
}
.app-subtitle {
  margin-top: 8px;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
}
.inventory-count {
  margin: 0 0 8px 2px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding-top: 4px;
}
.theme-toggle,
.install-btn {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: var(--card-solid);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-sm);
  color: var(--text-secondary);
  font-size: 1rem;
  position: relative;
  overflow: hidden;
  transition: transform var(--duration) var(--ease), color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.theme-toggle:hover,
.install-btn:hover { color: var(--accent); box-shadow: var(--shadow); }
.theme-toggle:active,
.install-btn:active { transform: scale(0.94); }

.theme-toggle:focus-visible,
.install-btn:focus-visible,
.fab:focus-visible,
.card-btn:focus-visible,
.btn-save:focus-visible,
.chip:focus-visible,
.sheet-close:focus-visible,
.btn-secondary:focus-visible,
.btn-danger:focus-visible,
.fav-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Search ---------- */
.search-wrap { padding: 0 0 10px; }
.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 12px 18px;
  border-radius: var(--radius-xl);
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-search);
  backdrop-filter: blur(24px) saturate(1.6);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  transition: box-shadow var(--duration) var(--ease), border-color var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow);
  transform: scale(1.012);
}
.search-icon {
  color: var(--text-muted);
  font-size: 0.95rem;
  flex-shrink: 0;
  transition: color var(--duration) var(--ease);
}
.search-bar:focus-within .search-icon { color: var(--accent); }
.search-input {
  flex: 1;
  min-width: 0;
  font-size: 1rem;
  color: var(--text);
}
.search-input::placeholder { color: var(--text-muted); }
.clear-search {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  background: var(--bg-soft);
  font-size: 0.75rem;
  transition: color var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.clear-search:active { transform: scale(0.92); }

/* ---------- Filter Chips ---------- */
.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  margin: 0 -2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--card-border);
  background: var(--card-solid);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 650;
  white-space: nowrap;
  transition: background-color var(--duration) var(--ease), color var(--duration) var(--ease), border-color var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.chip:active { transform: scale(0.96); }
.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0B0D10;
  box-shadow: 0 4px 14px rgba(200, 155, 60, 0.35);
}

/* ---------- List ---------- */
.inventory-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 0;
}

/* ---------- Cards ---------- */
.card {
  position: relative;
  padding: 20px 18px 16px;
  border-radius: var(--radius-xl);
  background: var(--card);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px) saturate(1.35);
  -webkit-backdrop-filter: blur(20px) saturate(1.35);
  overflow: hidden;
  content-visibility: auto;
  contain-intrinsic-size: auto 340px;
  opacity: 0;
  transform: translateY(14px) scale(0.985);
  transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease), opacity var(--duration) var(--ease);
}
.card.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  animation: cardIn var(--duration) var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 30ms);
}
.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 16px;
  bottom: 16px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-pressed));
}
.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.card.is-favourite {
  border-color: rgba(200, 155, 60, 0.35);
}

.card-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding-left: 12px;
  margin-bottom: 14px;
}
.rm-avatar {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--accent), var(--accent-pressed));
  color: #0B0D10;
  font-weight: 750;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  box-shadow: 0 4px 14px rgba(200, 155, 60, 0.35);
}
.card-identity { flex: 1; min-width: 0; }
.card-rm {
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.card-client {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  word-break: break-word;
}
.card-top-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
.fav-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  font-size: 1rem;
  transition: color var(--duration) var(--ease), transform var(--duration) var(--ease), background-color var(--duration) var(--ease);
}
.fav-btn.is-on {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(200, 155, 60, 0.35);
}
.fav-btn:active { transform: scale(0.9); }
.card-time {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-left: 12px;
  margin-bottom: 14px;
}
.req-chip,
.source-chip,
.budget-badge,
.priority-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.req-chip { color: #fff; }
.req-chip--1bhk { background: var(--req-1); }
.req-chip--2bhk { background: var(--req-2); }
.req-chip--3bhk { background: var(--req-3); }
.req-chip--shop { background: var(--req-shop); }
.req-chip--office { background: var(--req-office); }
.req-chip--plot { background: var(--req-plot); }
.req-chip--villa { background: var(--req-villa); }
.req-chip--default { background: var(--req-default); color: #0B0D10; }

.source-chip {
  background: rgba(120, 140, 170, 0.16);
  color: var(--text);
  border: 1px solid rgba(120, 140, 170, 0.28);
  font-weight: 650;
}

.budget-badge {
  background: linear-gradient(135deg, rgba(200, 155, 60, 0.22), rgba(200, 155, 60, 0.1));
  color: var(--accent);
  border: 1px solid rgba(200, 155, 60, 0.35);
}

.priority-badge--hot { background: var(--hot-soft); color: var(--hot); }
.priority-badge--warm { background: var(--warm-soft); color: var(--warm); }
.priority-badge--cold { background: var(--cold-soft); color: var(--cold); }

.card-body {
  display: grid;
  gap: 9px;
  padding-left: 12px;
  margin-bottom: 16px;
}
.card-row {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px;
  align-items: start;
  font-size: 0.9rem;
}
.card-label {
  color: var(--text-muted);
  font-weight: 650;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: 3px;
}
.card-value {
  color: var(--text-secondary);
  word-break: break-word;
  line-height: 1.45;
  font-weight: 500;
}
.card-value.empty {
  color: var(--text-muted);
  font-style: italic;
  font-weight: 400;
  opacity: 0.7;
}
.card-value a.phone-link {
  color: var(--call);
  font-weight: 650;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 7px;
  padding-left: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--card-border);
}
.card-btn {
  position: relative;
  overflow: hidden;
  height: var(--btn-h);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0 4px;
  border-radius: var(--radius);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: transform var(--duration) var(--ease), background-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.card-btn i { font-size: 0.95rem; }
.card-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.card-btn:active { transform: scale(0.96); }
.card-btn--call { background: var(--call-soft); color: var(--call); }
.card-btn--wa { background: var(--wa-soft); color: var(--wa); }
.card-btn--edit { background: var(--edit-soft); color: var(--edit); }
.card-btn--delete { background: var(--danger-soft); color: var(--danger); }
.card-btn.is-disabled { opacity: 0.4; pointer-events: none; }

.ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  animation: ripple 250ms linear;
  background: rgba(255, 255, 255, 0.35);
  pointer-events: none;
}
@keyframes ripple {
  to { transform: scale(2.6); opacity: 0; }
}

/* ---------- Empty ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 64px 24px 48px;
  animation: fadeSlideUp var(--duration) var(--ease);
}
.empty-illustration {
  width: 112px;
  height: 112px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-xl);
  background: linear-gradient(160deg, var(--accent-soft), transparent);
  color: var(--accent);
  font-size: 2.5rem;
  margin-bottom: 22px;
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
}
.empty-title {
  font-family: var(--font-display);
  font-size: 1.7rem;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.empty-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 240px;
}

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: max(18px, calc(50% - (var(--app-max) / 2) + 18px));
  bottom: calc(22px + var(--safe-bottom));
  z-index: 50;
  width: var(--fab-size);
  height: var(--fab-size);
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #0B0D10;
  font-size: 1.4rem;
  box-shadow: var(--shadow-fab);
  overflow: hidden;
  transition: transform var(--duration) var(--ease), background-color var(--duration) var(--ease);
}
.fab:hover { background: var(--accent-hover); transform: scale(1.06); }
.fab:active { background: var(--accent-pressed); transform: scale(0.94); }
.fab.is-open { transform: rotate(45deg); }
.fab.is-open:hover { transform: rotate(45deg) scale(1.06); }

/* ---------- Sheets ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(11, 13, 16, 0.55);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  opacity: 0;
  transition: opacity var(--duration) var(--ease);
}
.sheet-backdrop.is-visible { opacity: 1; }

.bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  max-width: var(--app-max);
  max-height: min(94dvh, 880px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: var(--card-solid);
  border: 1px solid var(--card-border);
  border-bottom: none;
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform var(--duration) var(--ease-out);
  padding-bottom: calc(var(--vv-offset));
}
.bottom-sheet.is-open { transform: translateY(0); }
.sheet-handle {
  width: 40px;
  height: 5px;
  margin: 10px auto 4px;
  border-radius: var(--radius-full);
  background: var(--text-muted);
  opacity: 0.3;
  flex-shrink: 0;
}
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 20px 12px;
  flex-shrink: 0;
}
.sheet-title {
  font-family: var(--font-display);
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}
.sheet-close {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: var(--bg-soft);
  color: var(--text-secondary);
  border: 1px solid var(--card-border);
  transition: transform var(--duration) var(--ease);
}
.sheet-close:active { transform: scale(0.94); }
.sheet-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 20px 16px;
  -webkit-overflow-scrolling: touch;
}
.sheet-footer {
  flex-shrink: 0;
  padding: 12px 20px calc(16px + var(--safe-bottom));
  border-top: 1px solid var(--card-border);
  background: var(--card-solid);
}

.entry-form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group label,
.form-label-text {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.required { color: var(--accent); }
.form-group input,
.form-group textarea,
.form-group select {
  min-height: var(--btn-h);
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--card-border);
  font-size: 16px;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.form-group textarea { min-height: 96px; }
.form-group select {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 36px;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.form-group input:focus,
.form-group textarea:focus {
  background: var(--card-solid);
}
.form-group input.is-invalid,
.form-group textarea.is-invalid,
.form-group select.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px var(--danger-soft);
}

.req-picks,
.priority-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.req-pick,
.priority-pick {
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--card-border);
  background: var(--bg-soft);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 650;
  transition: background-color var(--duration) var(--ease), color var(--duration) var(--ease), border-color var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.req-pick.is-active,
.priority-pick.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.req-pick:active,
.priority-pick:active { transform: scale(0.96); }
.priority-pick[data-priority="hot"].is-active { border-color: var(--hot); background: var(--hot-soft); color: var(--hot); }
.priority-pick[data-priority="warm"].is-active { border-color: var(--warm); background: var(--warm-soft); color: var(--warm); }
.priority-pick[data-priority="cold"].is-active { border-color: var(--cold); background: var(--cold-soft); color: var(--cold); }

.btn-save {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: var(--btn-h);
  border-radius: var(--radius-lg);
  background: var(--accent);
  color: #0B0D10;
  font-size: 1.05rem;
  font-weight: 750;
  box-shadow: var(--shadow-fab);
  transition: transform var(--duration) var(--ease), background-color var(--duration) var(--ease);
}
.btn-save:hover { background: var(--accent-hover); }
.btn-save:active { transform: scale(0.98); background: var(--accent-pressed); }
.btn-save:disabled { opacity: 0.6; pointer-events: none; }

/* ---------- Confirm ---------- */
.confirm-backdrop { z-index: 80; }
.confirm-dialog {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 90;
  width: min(360px, calc(100% - 40px));
  padding: 28px 22px 22px;
  border-radius: var(--radius-xl);
  background: var(--card-solid);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-lg);
  text-align: center;
  transform: translate(-50%, -50%) scale(0.94);
  opacity: 0;
  transition: transform var(--duration) var(--ease-out), opacity var(--duration) var(--ease);
}
.confirm-dialog.is-open {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}
.confirm-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 1.3rem;
}
.confirm-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 8px; }
.confirm-desc { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 24px; }
.confirm-actions { display: flex; gap: 10px; }
.btn-secondary,
.btn-danger {
  position: relative;
  overflow: hidden;
  flex: 1;
  height: var(--btn-h);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 700;
  transition: transform var(--duration) var(--ease);
}
.btn-secondary:active,
.btn-danger:active { transform: scale(0.97); }
.btn-secondary {
  background: var(--bg-soft);
  color: var(--text-secondary);
  border: 1px solid var(--card-border);
}
.btn-danger { background: var(--danger); color: #fff; }

/* ---------- Toast / Install / Offline ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(100px + var(--safe-bottom));
  z-index: 100;
  max-width: calc(100% - 40px);
  padding: 14px 22px;
  border-radius: var(--radius-full);
  background: var(--text);
  color: var(--bg);
  font-size: 0.875rem;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, 16px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: transform var(--duration) var(--ease-out), opacity var(--duration) var(--ease);
  white-space: nowrap;
}
.toast.is-visible { transform: translate(-50%, 0) scale(1); opacity: 1; }
html[data-theme="dark"] .toast { background: #F4F5F7; color: #0B0D10; }

.install-banner {
  position: fixed;
  left: 50%;
  bottom: calc(94px + var(--safe-bottom));
  z-index: 55;
  width: min(420px, calc(100% - 28px));
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: var(--card-solid);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-lg);
  transition: transform var(--duration) var(--ease-out), opacity var(--duration) var(--ease);
}
.install-banner.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.install-banner-icon { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; }
.install-banner-text { flex: 1; min-width: 0; }
.install-banner-title { font-size: 0.875rem; font-weight: 700; }
.install-banner-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.install-banner-actions { display: flex; gap: 6px; }
.install-banner-cta {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #0B0D10;
  font-size: 0.8rem;
  font-weight: 750;
}
.install-banner-dismiss {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  background: var(--bg-soft);
}

.offline-badge {
  position: fixed;
  top: calc(10px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  z-index: 200;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  background: var(--danger);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.offline-badge.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

body.sheet-open { overflow: hidden; touch-action: none; }

@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Responsive ---------- */

/* Compact mobile header ? max-width 480px, sticky header ~170?180px */
@media (max-width: 480px) {
  .app-top {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: calc(2px + var(--safe-top)) 12px 6px;
    /* Natural height target ~170?180px (plus safe-area); never cover the list */
    overflow: visible;
  }

  .header {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0;
    min-height: 36px;
    max-height: 40px;
  }

  .header-text {
    min-width: 0;
    flex: 1 1 auto;
  }

  /* Hide "REAL ESTATE INVENTORY" subtitle on small phones */
  .app-subtitle {
    display: none !important;
  }

  .app-title {
    font-size: clamp(1.15rem, 5vw, 1.35rem);
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
  }

  .header-actions {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
    padding-top: 0;
    flex-shrink: 0;
  }

  .theme-toggle,
  .install-btn,
  .profile-btn {
    width: 34px;
    height: 34px;
    font-size: 0.85rem;
  }

  .profile-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
  }

  .search-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0;
    margin: 0;
  }

  .inventory-count {
    margin: 0;
    padding: 0;
    font-size: 0.65rem;
    line-height: 1.2;
    font-weight: 650;
  }

  .search-bar {
    min-height: 40px;
    height: 40px;
    padding: 0 12px;
    gap: 8px;
    border-radius: 12px;
  }

  .search-bar:focus-within {
    transform: none;
    box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-sm);
  }

  .search-icon {
    font-size: 0.85rem;
  }

  .search-input {
    font-size: 0.875rem;
  }

  .clear-search {
    width: 24px;
    height: 24px;
  }

  /* Single horizontal scrolling rows ? never wrap */
  .filter-chips,
  .sort-chips {
    display: flex !important;
    flex-wrap: nowrap !important;
    flex-direction: row;
    overflow-x: auto !important;
    overflow-y: hidden;
    gap: 6px;
    padding: 0 !important;
    margin: 0 !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .filter-chips::-webkit-scrollbar,
  .sort-chips::-webkit-scrollbar {
    display: none;
  }

  .chip {
    flex: 0 0 auto;
    flex-shrink: 0;
    height: 34px;
    padding: 0 12px;
    font-size: 0.72rem;
  }

  /* Cards begin immediately below chips */
  .app-scroll {
    padding-top: 10px;
    padding-bottom: calc(92px + var(--safe-bottom));
  }

  .group-heading {
    padding-top: 4px;
  }

  .group-heading:first-child {
    padding-top: 0;
  }

  .inventory-list {
    padding-top: 0;
  }
}

@media (max-width: 374px) {
  .app { padding-left: 12px; padding-right: 12px; }
  .app-top { margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
  .app-title { font-size: 1.3rem; }
  .card-row { grid-template-columns: 76px 1fr; }
  .card-btn span { font-size: 0.62rem; }
  .card-actions { gap: 5px; }
}

@media (min-width: 430px) {
  .app { padding-left: 18px; padding-right: 18px; }
  .app-top { margin: 0 -18px; padding-left: 18px; padding-right: 18px; }
}

@media (min-width: 640px) {
  .app { padding-left: 28px; padding-right: 28px; }
  .app-top {
    margin: 0 -28px;
    padding-left: 28px;
    padding-right: 28px;
    padding-top: calc(12px + var(--safe-top));
  }
  .header { padding-top: 26px; }
  .card { padding: 22px 22px 18px; }
  .card-row { grid-template-columns: 110px 1fr; }
  .card-btn {
    flex-direction: row;
    gap: 7px;
    font-size: 0.78rem;
  }
}

@media (min-width: 900px) {
  .app { max-width: 720px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .card { opacity: 1; transform: none; }
}

/* =========================================================
   Usability Extensions (no redesign ? same design language)
   ========================================================= */

.sort-chips {
  padding-top: 0;
  margin-top: -2px;
}

@media (max-width: 480px) {
  .sort-chips {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }
}

.group-heading {
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 14px 4px 4px;
}

.phone-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.copy-btn {
  flex-shrink: 0;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 700;
  transition: color var(--duration) var(--ease), background-color var(--duration) var(--ease);
}

.copy-btn:hover { color: var(--accent); }

.card-actions {
  grid-template-columns: repeat(5, 1fr);
}

.card-btn--share {
  background: rgba(139, 92, 246, 0.12);
  color: #8B5CF6;
}

html[data-theme="dark"] .card-btn--share {
  background: rgba(167, 139, 250, 0.14);
  color: #A78BFA;
}

.card.is-highlight {
  box-shadow: 0 0 0 2px var(--accent), var(--shadow-lg);
}

.field-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: -2px;
}

.field-error {
  font-size: 0.75rem;
  color: var(--danger);
  font-weight: 600;
}

.skeleton-card {
  padding: 22px 20px;
  border-radius: var(--radius-xl);
  background: var(--card);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
}

.skeleton-line {
  height: 12px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--bg-soft) 25%, var(--card-border) 50%, var(--bg-soft) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.1s ease-in-out infinite;
  margin-bottom: 12px;
}

.skeleton-line.lg { height: 18px; width: 60%; }
.skeleton-line.md { width: 80%; }
.skeleton-line.sm { width: 40%; }
.skeleton-line.full { width: 100%; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.dup-icon {
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
}

.dup-details {
  text-align: left;
  margin: 0 0 20px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
}

.dup-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  font-size: 0.875rem;
}

.dup-row span { color: var(--text-muted); font-weight: 600; }
.dup-row strong { color: var(--text); text-align: right; font-weight: 700; }

.dup-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dup-btn { height: var(--btn-h); }

.settings-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 75;
  max-width: var(--app-max);
  margin: 0 auto;
  max-height: min(80dvh, 560px);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: var(--card-solid);
  border: 1px solid var(--card-border);
  border-bottom: none;
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform var(--duration) var(--ease-out);
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-bottom);
}

.settings-panel.is-open { transform: translateY(0); }

.settings-body {
  padding: 8px 20px 24px;
  overflow-y: auto;
}

.settings-group { margin-bottom: 22px; }

.settings-label {
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.settings-theme-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.settings-theme-btn {
  height: 48px;
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  background: var(--bg-soft);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: border-color var(--duration) var(--ease), background-color var(--duration) var(--ease), color var(--duration) var(--ease);
}

.settings-theme-btn.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.settings-about {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 8px;
}

.settings-version {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.settings-clear {
  width: 100%;
  height: var(--btn-h);
}

/* =========================================================
   Auth ? Login + Profile (same design language)
   ========================================================= */

.login-body {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-page {
  width: 100%;
  max-width: 420px;
  padding: 24px 16px calc(24px + var(--safe-bottom));
}

.login-card {
  padding: 32px 24px 28px;
  border-radius: var(--radius-xl);
  background: var(--card);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-title {
  font-family: var(--font-display);
  font-size: 1.9rem;
  letter-spacing: -0.02em;
  margin-top: 14px;
}

.login-subtitle {
  margin-top: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrap input {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  right: 10px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  border-radius: var(--radius-full);
}

.login-error {
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.login-submit {
  margin-top: 4px;
}

.login-submit:disabled {
  opacity: 0.6;
  pointer-events: none;
}

/* Profile menu */
.profile-wrap {
  position: relative;
}

.profile-btn {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  padding: 0;
  border: 1px solid rgba(200, 155, 60, 0.35);
  background: transparent;
}

.profile-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--accent), var(--accent-pressed));
  color: #0B0D10;
  font-weight: 750;
  font-size: 0.95rem;
}

.profile-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 180px;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--card-solid);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-lg);
  z-index: 60;
}

.profile-menu-name {
  font-size: 0.9rem;
  font-weight: 700;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--card-border);
  margin-bottom: 6px;
  color: var(--text);
}

.profile-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 0.875rem;
  font-weight: 700;
  text-align: left;
  transition: background-color var(--duration) var(--ease);
}

.profile-menu-item:hover {
  background: var(--danger-soft);
}

/* Export button ? green Excel accent, same size as other header icons */
#exportBtn {
  color: #217346;
}
#exportBtn:hover {
  color: #1a5c38;
}
html[data-theme="dark"] #exportBtn {
  color: #3CB371;
}
html[data-theme="dark"] #exportBtn:hover {
  color: #5FCF8F;
}
