:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e3e6ec;
  --border-strong: #c8cdd6;
  --text: #1a1d23;
  --muted: #6b7280;
  --accent: #1f6feb;
  --accent-strong: #1958c4;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --radius: 10px;
  --maxw: 1040px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover,
a:focus-visible {
  text-decoration: underline;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 0.85rem;
}
.center {
  text-align: center;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
}
.brand:hover,
.brand:focus-visible {
  text-decoration: none;
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.who {
  font-size: 0.9rem;
  color: var(--muted);
}
.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}
.topnav-link {
  color: var(--muted);
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 7px;
}
.topnav-link:hover,
.topnav-link:focus-visible {
  color: var(--text);
  background: #f1f3f7;
  text-decoration: none;
}
.topnav-link.is-active {
  color: var(--text);
  background: #eef1f6;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
@media (max-width: 540px) {
  .topbar-inner {
    flex-wrap: wrap;
  }
  .topnav {
    order: 3;
    width: 100%;
    justify-content: flex-start;
  }
}

.app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.auth-card {
  max-width: 420px;
  margin: 60px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.auth-title {
  margin: 0 0 4px;
  font-size: 1.4rem;
}
.auth-sub {
  margin: 0 0 20px;
}
.auth-switch {
  margin: 18px 0 0;
  font-size: 0.9rem;
  text-align: center;
}

.field {
  display: block;
  margin-bottom: 14px;
}
.field-label {
  display: block;
  font-weight: 500;
  margin-bottom: 4px;
  font-size: 0.9rem;
}
.field-hint {
  display: block;
  font-size: 0.8rem;
  margin-top: 4px;
}
input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #fff;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input[type="email"]:focus-visible,
input[type="password"]:focus-visible,
input[type="text"]:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.18);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-strong);
}
.btn-ghost {
  border-color: var(--border-strong);
  background: #fff;
}
.btn-ghost:hover:not(:disabled) {
  background: #f1f3f7;
}
.btn-danger {
  color: var(--danger);
  border-color: transparent;
  background: transparent;
  padding: 4px 8px;
  font-size: 0.85rem;
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-bg);
}

.row-form {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.row-form input[type="text"] {
  flex: 1;
}
.row-form .btn-primary {
  width: auto;
  flex: 0 0 auto;
}

.upload-form {
  align-items: stretch;
}
.file-picker {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  padding: 8px 12px;
  background: #fff;
  cursor: pointer;
  min-width: 0;
}
.file-picker:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.18);
}
.file-picker input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.file-picker-label {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-picker-label.has-file {
  color: var(--text);
}

.form-error {
  margin: 6px 0 12px;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.9rem;
}

.dash {
  display: block;
}
.dash-head {
  margin-bottom: 18px;
}
.dash-head h1 {
  margin: 0 0 4px;
  font-size: 1.5rem;
}
.dash-head p {
  margin: 0;
}

.summary-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
  margin-bottom: 22px;
}
@media (min-width: 560px) {
  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }
}
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.summary-link {
  color: inherit;
  transition: border-color 120ms ease, transform 120ms ease;
}
.summary-link:hover,
.summary-link:focus-visible {
  text-decoration: none;
  border-color: var(--accent);
}
.summary-label {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.summary-value {
  font-size: 1.9rem;
  font-weight: 600;
  line-height: 1.1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.summary-hint {
  margin-top: 2px;
}

.dash-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
}
@media (min-width: 760px) {
  .dash-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fdfdfe;
}
.list-item-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.list-item-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item-meta {
  color: var(--muted);
  font-size: 0.8rem;
}
.list-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* ---- Properties ---- */

.dash-grid .card-wide {
  grid-column: 1 / -1;
}

.property-form {
  margin-bottom: 14px;
}
.property-form .field {
  margin-bottom: 10px;
}
.property-form .field-label {
  font-size: 0.85rem;
}
.property-form-row {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}
@media (min-width: 620px) {
  .property-form-row {
    grid-template-columns: 2fr 1fr;
  }
  .property-form-row:nth-of-type(2) {
    grid-template-columns: 2fr 1fr 1fr;
  }
}
.property-field-grow {
  min-width: 0;
}
.property-field-num input {
  text-align: right;
}
.property-form textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #fff;
  outline: none;
  resize: vertical;
  font: inherit;
  color: inherit;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.property-form textarea:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.18);
}
.property-form select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #fff;
  outline: none;
  font: inherit;
  color: inherit;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.property-form select:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.18);
}
.property-form input[type="number"] {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #fff;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.property-form input[type="number"]:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.18);
}
.property-form-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}
.property-submit {
  width: auto;
  flex: 0 0 auto;
}

.property-list {
  gap: 8px;
}
.property-item {
  align-items: flex-start;
  padding: 10px 12px;
}
.property-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.property-title {
  font-weight: 600;
}
.property-status {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef1f6;
  color: var(--muted);
}
.property-status[data-status="active"] {
  background: #e6f4ec;
  color: #1f7a3c;
}
.property-status[data-status="pending"] {
  background: #fff4d6;
  color: #8a5a00;
}
.property-status[data-status="sold"] {
  background: #e6edff;
  color: #1f4ad6;
}
.property-status[data-status="off_market"] {
  background: #f1f3f7;
  color: #6b7280;
}
.property-meta {
  margin-top: 2px;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.85rem;
  border-color: var(--border-strong);
}

/* ---- Pages, leads, property grid -------------------------------- */

.page {
  display: block;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.page-head h1 {
  margin: 0 0 4px;
  font-size: 1.5rem;
}
.page-head p {
  margin: 0;
}
.page-state {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  margin-top: 12px;
}
.page-state-error {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: #fecaca;
  border-style: solid;
}

/* Lead form */
.lead-form .field {
  margin-bottom: 10px;
}
.lead-form .field-label {
  font-size: 0.85rem;
}
.lead-form-row {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}
@media (min-width: 620px) {
  .lead-form-row {
    grid-template-columns: 2fr 1fr;
  }
}
.lead-field-grow {
  min-width: 0;
}
.lead-form textarea,
.lead-form select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #fff;
  outline: none;
  font: inherit;
  color: inherit;
  resize: vertical;
}
.lead-form textarea:focus-visible,
.lead-form select:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.18);
}
.lead-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.lead-submit {
  width: auto;
  flex: 0 0 auto;
}

/* Filter chip bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 18px 0 12px;
}
.filter-chip {
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  font-weight: 500;
}
.filter-chip:hover {
  color: var(--text);
}
.filter-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.filter-chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Pipeline */
.pipeline {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: start;
}
.pipeline-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 100px;
}
.pipeline-col-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}
.pipeline-col-title {
  font-weight: 600;
  font-size: 0.95rem;
}
.pipeline-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lead-card {
  background: #fdfdfe;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lead-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.lead-card-name {
  font-weight: 600;
  font-size: 0.95rem;
}
.lead-card-meta {
  word-break: break-word;
}
.lead-card-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 2px;
}
.lead-card-stage-select {
  flex: 1;
  padding: 4px 6px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: #fff;
  font: inherit;
  color: inherit;
  font-size: 0.85rem;
}

/* Property grid */
.property-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-top: 4px;
}
.property-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.property-thumb {
  aspect-ratio: 16 / 9;
  background: #eef1f6;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.property-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.property-thumb-placeholder {
  color: var(--muted);
  font-size: 0.85rem;
}
.property-card-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.property-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.property-card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
}
.property-card-meta {
  margin: 0;
  word-break: break-word;
}
.property-card-price {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
}
.property-card-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 6px;
}
.property-upload {
  display: inline-block;
}
[data-upload-trigger].is-disabled {
  opacity: 0.6;
  pointer-events: none;
}
.property-card-status {
  margin: 4px 0 0;
  min-height: 1em;
}
.form-error-inline {
  color: var(--danger);
}
