:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #141b2d;
  --muted: #667085;
  --line: #e2e7ee;
  --line-strong: #cbd5e1;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --green: #13795b;
  --amber: #a16207;
  --red: #b4232c;
  --blue: #2563eb;
  --violet: #6d28d9;
  --shadow: 0 16px 40px rgba(20, 27, 45, 0.08);
  --radius: 8px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(246, 247, 249, 0.96) 260px),
    var(--bg);
  color: var(--text);
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

.app-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  background: linear-gradient(180deg, #101820 0%, #13252b 100%);
  color: #eef2f7;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 20px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: var(--radius);
  background: #d9f4ef;
  color: var(--primary-dark);
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.12);
}

.brand strong,
.brand span {
  display: block;
}

.brand span:not(.brand-mark) {
  margin-top: 2px;
  color: #b6c1ce;
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 42px;
  padding: 10px 11px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: #dce5ea;
  text-align: left;
}

.nav-item:hover,
.nav-item:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.nav-item.active {
  background: #effaf7;
  color: var(--primary-dark);
}

.nav-count {
  min-width: 24px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  color: inherit;
  font-size: 12px;
  text-align: center;
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 82px;
  padding: 14px 22px;
  border-bottom: 1px solid rgba(226, 231, 238, 0.86);
  background: rgba(246, 247, 249, 0.9);
  backdrop-filter: blur(10px);
}

.topbar h1 {
  margin: 3px 0 0;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar-controls {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.sync-badge.online {
  border-color: rgba(19, 121, 91, 0.28);
  background: #e9f8f0;
  color: var(--green);
}

.sync-badge.syncing {
  border-color: rgba(37, 99, 235, 0.24);
  background: #eaf2ff;
  color: var(--blue);
}

.sync-badge.error {
  border-color: rgba(180, 35, 44, 0.24);
  background: #fdebec;
  color: var(--red);
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  padding: 8px 10px;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

textarea {
  min-height: 82px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.15);
  outline: none;
}

#app {
  display: grid;
  gap: 18px;
  padding: 20px 22px 36px;
}

.auth-screen {
  display: grid;
  min-height: calc(100vh - 140px);
  place-items: center;
}

.auth-card {
  display: grid;
  width: min(100%, 460px);
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 22px;
}

.auth-card h2 {
  margin: 3px 0 5px;
  font-size: 24px;
  letter-spacing: 0;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.secondary-auth {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.section {
  display: grid;
  gap: 14px;
}

.dashboard-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(37, 99, 235, 0.06)),
    #fff;
  box-shadow: var(--shadow);
}

.dashboard-summary h2 {
  margin: 4px 0;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

.dashboard-summary p {
  margin: 0;
  color: var(--muted);
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
}

.summary-stats div {
  min-width: 120px;
  padding: 12px;
  border: 1px solid rgba(226, 231, 238, 0.92);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
}

.summary-stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.summary-stats strong {
  display: block;
  margin-top: 5px;
  font-size: 18px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-header h2,
.panel h2,
.panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.section-header h2 {
  font-size: 19px;
}

.section-header p,
.empty-state,
.muted {
  margin: 0;
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.split {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.4fr);
  gap: 16px;
  align-items: start;
}

.panel,
.card,
.metric,
.table-wrap,
.form-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel,
.card,
.metric,
.form-panel {
  position: relative;
}

.panel,
.form-panel {
  padding: 18px;
}

.panel.tight {
  padding: 12px;
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-header h2,
.panel-header h3 {
  font-size: 16px;
}

.metric {
  min-height: 106px;
  overflow: hidden;
  padding: 16px;
  border-color: rgba(226, 231, 238, 0.96);
}

.metric::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  content: "";
  background: linear-gradient(180deg, var(--primary), var(--blue));
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0;
}

.metric em {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-style: normal;
}

.button-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  padding: 8px 12px;
  font-weight: 800;
  text-decoration: none;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.button:hover,
.button:focus-visible {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.18);
  outline: none;
}

.button.secondary {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
}

.button.secondary:hover,
.button.secondary:focus-visible {
  background: #eef3f7;
}

.button.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text);
}

.button.danger {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

.button.danger.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--red);
}

.button.small {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid .full {
  grid-column: 1 / -1;
}

.inline-form-grid {
  display: grid;
  flex: 1;
  min-width: 0;
  grid-template-columns: minmax(150px, 1.2fr) minmax(110px, 0.75fr) minmax(130px, 0.9fr) minmax(110px, 0.75fr);
  gap: 10px;
}

.user-edit-form {
  align-items: end;
}

.user-actions {
  justify-content: flex-end;
  flex: 0 0 auto;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody tr:hover {
  background: #fbfcfe;
}

tr:last-child td {
  border-bottom: 0;
}

.status-pill,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  background: #edf2f7;
  color: #344054;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-New,
.status-Planned,
.status-Pending {
  background: #eaf2ff;
  color: var(--blue);
}

.status-Qualified,
.status-Completed,
.status-Approved,
.status-Won,
.status-Paid,
.status-On-sale,
.status-Available,
.status-Scheduled,
.status-Active {
  background: #e9f8f0;
  color: var(--green);
}

.status-Negotiating,
.status-Offer,
.status-Interested {
  background: #fff4dd;
  color: var(--amber);
}

.status-Closed-Lost,
.status-Lost,
.status-Sold,
.status-Sold-Out,
.status-Inactive,
.status-Cancelled,
.status-No-Show,
.status-Overdue {
  background: #fdebec;
  color: var(--red);
}

.card {
  overflow: hidden;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.card:hover {
  border-color: rgba(15, 118, 110, 0.28);
  box-shadow: 0 18px 46px rgba(20, 27, 45, 0.12);
  transform: translateY(-1px);
}

.card-body {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.card-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.card-title h3 {
  margin: 0;
  font-size: 16px;
}

.property-photo {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #dbe5ea;
}

.property-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.match-score {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--green) calc(var(--score) * 1%), #e8eef4 0);
  color: var(--text);
  font-weight: 900;
}

.score-inner {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 50%;
  background: #fff;
}

.breakdown {
  display: grid;
  gap: 7px;
}

.breakdown-row {
  display: grid;
  grid-template-columns: 92px 1fr 42px;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.bar {
  position: relative;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2f7;
}

.bar span {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--value);
  border-radius: inherit;
  background: var(--primary);
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.list-item strong,
.list-item span {
  display: block;
  overflow-wrap: anywhere;
}

.list-item span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.kanban {
  display: grid;
  grid-auto-columns: minmax(250px, 1fr);
  grid-auto-flow: column;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.kanban-column {
  display: grid;
  align-content: start;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f3f6f9;
}

.kanban-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 11px;
  border-bottom: 1px solid var(--line);
  font-weight: 900;
}

.kanban-body {
  display: grid;
  align-content: start;
  gap: 9px;
  min-height: 360px;
  padding: 10px;
}

.deal-card {
  display: grid;
  gap: 8px;
  padding: 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 8px 18px rgba(20, 27, 45, 0.08);
}

.deal-card:active {
  cursor: grabbing;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tab {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 6px 10px;
  font-weight: 800;
}

.tab.active {
  border-color: var(--primary);
  background: #e9f8fb;
  color: var(--primary-dark);
}

.avatar {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: #dceaf4;
  color: #0f5269;
  font-weight: 900;
}

.audit-log {
  max-height: 380px;
  overflow: auto;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: 360px;
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  border-radius: var(--radius);
  background: #111827;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.empty-state {
  display: grid;
  min-height: 110px;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel-soft);
  text-align: center;
}

.subtle-box {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.money {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hide {
  display: none !important;
}

@media (max-width: 1120px) {
  .grid.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid.three,
  .split {
    grid-template-columns: 1fr;
  }

  .inline-form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 12px;
  }

  .brand {
    padding-bottom: 12px;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-controls,
  .topbar-controls label,
  .sync-badge {
    width: 100%;
  }

  #app {
    padding: 16px 14px 28px;
  }

  .grid.two,
  .grid.four,
  .form-grid,
  .form-grid.three,
  .filter-row {
    grid-template-columns: 1fr;
  }

  .dashboard-summary {
    align-items: stretch;
    flex-direction: column;
  }

  .user-edit-form {
    align-items: stretch;
    flex-direction: column;
  }

  .user-edit-form > div:first-child,
  .user-actions,
  .user-panel .panel-header .button-row {
    width: 100%;
  }

  .user-actions .button {
    flex: 1 1 136px;
  }
}

@media (max-width: 520px) {
  .nav-list {
    grid-template-columns: 1fr;
  }

  .section-header,
  .panel-header,
  .list-item,
  .card-title {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-summary {
    padding: 15px;
  }

  .summary-stats {
    grid-template-columns: 1fr;
  }

  .button,
  .tab {
    width: 100%;
  }

  .topbar h1 {
    font-size: 21px;
  }

  .property-grid {
    grid-template-columns: 1fr;
  }

  .match-score {
    width: 52px;
    height: 52px;
  }

  .score-inner {
    width: 42px;
    height: 42px;
  }
}
