:root {
  color-scheme: dark;
  --bg: #0b1220;
  --surface: #131c2e;
  --surface-2: #1a2437;
  --border: #263045;
  --text: #e8edf6;
  --muted: #8b96ab;
  --accent: #35c2a3;
  --accent-strong: #2aa88e;
  --owner: #35c2a3;
  --business: #f5a524;
  --unknown: #64748b;
  --danger: #f76b6b;
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-2: 0 6px 20px rgba(0, 0, 0, 0.35);
}

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

html {
  font-size: calc(16px * var(--font-scale, 1));
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Vazirmatn", Tahoma, sans-serif;
}

body { overscroll-behavior-y: none; }

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

.icon { display: inline-flex; width: 20px; height: 20px; }
.icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.screen[hidden] { display: none; }

/* ---- Login ---- */
.login-card {
  max-width: 340px;
  margin: 18vh auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 28px 24px;
}

.login-icon {
  width: 64px;
  height: 64px;
  color: var(--accent);
  margin-bottom: 4px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-icon .icon { width: 32px; height: 32px; }

.login-card h1 { margin: 0; font-size: 1.4rem; }
.login-sub { margin: 0 0 8px; color: var(--muted); font-size: 0.85rem; }

.login-card input, .login-card button {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: transform 0.1s ease, filter 0.15s ease;
}

.login-card input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-card button {
  background: var(--accent);
  color: #06231c;
  font-weight: 700;
  border: none;
  box-shadow: var(--shadow-1);
}

.login-card button:active { transform: scale(0.98); filter: brightness(0.95); }

.error { color: var(--danger); font-size: 0.85rem; }

/* ---- App shell ---- */
#app-screen { display: flex; flex-direction: column; height: 100%; }

.topbar {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar h1 { margin: 0; font-size: 1.15rem; font-weight: 700; }

.topbar::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  flex: 0 0 auto;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}

#content { flex: 1; overflow-y: auto; padding: 12px 12px calc(84px + var(--safe-bottom)); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.filter-row-wrap { flex-wrap: wrap; }
.filter-row-wrap input { min-width: 45%; flex: 1; }

.filter-row input, .filter-row select {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.btn-icon {
  flex: 0 0 auto;
  width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.btn-secondary {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-text {
  background: none;
  border: none;
  color: var(--muted);
  padding: 10px;
  width: 100%;
  text-align: center;
}

/* ---- Cards ---- */
.card-list { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-1);
  transition: transform 0.1s ease;
}

.card:active { transform: scale(0.99); }

.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card-price { font-size: 1.15rem; font-weight: 700; color: var(--accent); }
.card-title { margin: 4px 0; font-size: 0.95rem; font-weight: 600; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
}

.card-desc { color: var(--muted); font-size: 0.85rem; margin: 6px 0; line-height: 1.6; }

.card-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.card-actions a, .card-actions button {
  flex: 1;
  text-align: center;
  padding: 9px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.card-actions .primary { background: var(--accent); color: #06231c; border: none; font-weight: 700; box-shadow: var(--shadow-1); }
.card-actions a:active, .card-actions button:active,
.btn-secondary:active, .btn-icon:active { transform: scale(0.96); filter: brightness(0.95); }
.card-actions a, .card-actions button, .btn-secondary, .btn-icon { transition: transform 0.1s ease, filter 0.15s ease; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge.owner { background: color-mix(in srgb, var(--owner) 20%, transparent); color: var(--owner); }
.badge.real_estate_business { background: color-mix(in srgb, var(--business) 20%, transparent); color: var(--business); }
.badge.unknown { background: color-mix(in srgb, var(--unknown) 30%, transparent); color: #cbd5e1; }

.priority-high { color: var(--danger); font-weight: 700; }
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.empty-state::before {
  content: "";
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

/* ---- Bottom nav ---- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  z-index: 10;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.3);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--muted);
  padding: 10px 2px 8px;
  font-size: 0.68rem;
}

.nav-item.active { color: var(--accent); }
.nav-item.active .icon { transform: translateY(-1px); }
.nav-item { transition: color 0.15s ease; }

/* ---- Bottom sheets ---- */
.sheet {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 15, 0.7);
  display: flex;
  align-items: flex-end;
  z-index: 30;
}

.sheet[hidden] { display: none; }

.sheet-content {
  background: var(--surface);
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 10px 18px calc(20px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-2);
  animation: sheet-rise 0.2s ease-out;
}

@keyframes sheet-rise {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  margin: 4px auto 8px;
}

.sheet-content h2 { margin: 0 0 4px; font-size: 1.05rem; }
.sheet-content input, .sheet-content select, .sheet-content textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}
.sheet-content textarea { min-height: 70px; resize: vertical; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.modal-actions { display: flex; gap: 8px; margin-top: 4px; }
.modal-actions button { flex: 1; padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
.modal-actions button[type="submit"] { background: var(--accent); color: #06231c; font-weight: 700; border: none; }

/* Valuation / brief detail blocks */
.valuation-scenarios { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.scenario-box { background: var(--surface-2); border-radius: 12px; padding: 10px; text-align: center; }
.scenario-box .label { color: var(--muted); font-size: 0.72rem; }
.scenario-box .value { font-weight: 700; margin-top: 4px; font-size: 0.95rem; }
.scenario-box .sub-value { color: var(--muted); font-size: 0.68rem; margin-top: 2px; }

a.tel-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tag-input {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}
.tag-input input {
  flex: 1;
  min-width: 120px;
  border: none;
  background: none;
  padding: 6px;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 6px 4px 10px;
  font-size: 0.82rem;
}
.tag-chip button {
  background: none;
  border: none;
  color: var(--muted);
  padding: 0 4px;
  font-size: 1rem;
  line-height: 1;
}

.policy-warning {
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  color: var(--danger);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.82rem;
  line-height: 1.6;
}

.verify-list { margin: 0; padding-inline-start: 18px; color: var(--muted); font-size: 0.85rem; line-height: 1.8; }

.opening-script {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 10px 0;
}
.opening-script strong { color: var(--accent); font-size: 0.82rem; }
.opening-script .card-desc { color: var(--text); font-size: 0.9rem; margin-top: 6px; }

.toast {
  position: fixed;
  bottom: calc(96px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  z-index: 50;
}
.toast[hidden] { display: none; }

/* ---- Property images ---- */
.image-section { margin-top: 14px; }
.image-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.image-upload-label {
  width: auto;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--accent);
  font-size: 0.8rem;
  cursor: pointer;
}
.image-gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.image-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.image-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-delete {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.9rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Folders (کمد/زونکن) home screen ---- */
.mode-toggle {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 14px;
}
.mode-option {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.88rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.mode-option.active { background: var(--accent); color: #06231c; }

.queue-callout {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 6px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-1);
}
.queue-callout-open {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  color: var(--text);
  padding: 8px;
  text-align: right;
}
.queue-callout-open .icon { color: var(--danger); flex-shrink: 0; }
.queue-callout-text { display: flex; flex-direction: column; gap: 2px; }
.queue-callout-text strong { font-size: 0.9rem; }
.queue-callout-count { color: var(--muted); font-size: 0.78rem; }
.queue-build-btn { flex: 0 0 auto; width: auto; padding: 8px 10px; font-size: 0.78rem; white-space: nowrap; }

.folder-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 2px 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.folder-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.folder-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow-1);
  color: var(--text);
  text-align: right;
  transition: transform 0.1s ease;
}
.folder-card:active { transform: scale(0.97); }
.folder-icon { color: var(--folder-accent, var(--accent)); }
.folder-name { font-weight: 700; font-size: 0.92rem; }
.folder-count { color: var(--muted); font-size: 0.76rem; }

/* ---- Pin toggle ---- */
.btn-pin {
  margin-inline-start: auto;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-pin .icon { width: 15px; height: 15px; }
.btn-pin.pinned { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: color-mix(in srgb, var(--danger) 15%, transparent); }
.btn-pin.pinned .icon svg { fill: currentColor; }

.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.detail-head h2 { margin: 0; }

.topbar { justify-content: space-between; }
.topbar-settings { margin-inline-start: auto; width: 38px; }

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.settings-row select { width: auto; min-width: 140px; }
