:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --success: #16a34a;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 0.9375rem;
}

/* ---- Layout ----------------------------------------------------------- */
#app {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---------------------------------------------------------- */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.logo {
  font-size: 1.375rem;
  font-weight: 800;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -0.5px;
  padding: 0.25rem 0.75rem 1.25rem;
  display: block;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  position: relative;
}

.nav-link:hover { background: var(--primary-light); color: var(--primary); }
.nav-link.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.3rem;
  background: var(--primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 9999px;
  margin-left: auto;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  margin-top: auto;
  margin-bottom: 0.5rem;
}

/* ---- Avatar ----------------------------------------------------------- */
.avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8125rem;
  flex-shrink: 0;
}

.avatar.sm { width: 1.75rem; height: 1.75rem; font-size: 0.75rem; }

/* ---- Main content ----------------------------------------------------- */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 2rem 2.5rem;
  max-width: 1100px;
}

/* ---- Cards ------------------------------------------------------------ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 1.25rem;
}

.form-card { margin-bottom: 0; }

/* ---- Buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0.5625rem 1.125rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--primary-dark); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-ghost:hover { background: var(--bg-main); color: var(--text-main); }
.btn-ghost.btn-danger { color: var(--danger); border-color: #fca5a5; }
.btn-ghost.btn-danger:hover { background: var(--danger-light); }

.btn-sm {
  display: inline-flex;
  align-items: center;
  background: var(--bg-main);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 0.3125rem 0.625rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-sm:hover { background: var(--border); }
.btn-sm.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-sm.btn-danger { color: var(--danger); border-color: #fca5a5; }
.btn-sm.btn-danger:hover { background: var(--danger-light); }

/* ---- Inputs ----------------------------------------------------------- */
.input {
  display: block;
  width: 100%;
  padding: 0.5625rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text-main);
  background: var(--bg-card);
  outline: none;
  transition: border-color 0.15s;
  margin-bottom: 0.875rem;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1); }
textarea.input { resize: vertical; }
select.input { cursor: pointer; }

/* ---- Form helpers ----------------------------------------------------- */
.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.375rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1.25rem;
}

/* ---- Badges ----------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-green  { background: #dcfce7; color: #15803d; }
.badge-yellow { background: #fef9c3; color: #a16207; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-gray   { background: #f1f5f9; color: #475569; }

/* Kept for backwards compat */
.badge-pending   { background: #fef9c3; color: #a16207; }
.badge-confirmed { background: #dcfce7; color: #15803d; }

/* ---- Role badges ------------------------------------------------------ */
.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.625rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
}
.role-owner { background: #faf5ff; color: #7c3aed; }
.role-admin { background: #eff6ff; color: #1d4ed8; }
.role-staff { background: #f8fafc; color: #475569; }

/* ---- Table ------------------------------------------------------------ */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg-main);
}
.table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfc; }

/* ---- Page header ------------------------------------------------------ */
.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 1.375rem; font-weight: 700; flex: 1; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.875rem;
}
.section-header h2 { font-size: 1rem; font-weight: 600; }

/* ---- Stats grid ------------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.stat-card { margin-bottom: 0; }
.stat-label { font-size: 0.8125rem; color: var(--text-muted); font-weight: 500; margin-bottom: 0.5rem; }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1; }

/* ---- Link ------------------------------------------------------------- */
.link {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.875rem;
}
.link:hover { text-decoration: underline; }

/* ---- Empty state ------------------------------------------------------ */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ---- Tabs ------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}
.tab {
  padding: 0.625rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text-main); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---- Detail grid ------------------------------------------------------ */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
}
.detail-row:last-child { border-bottom: none; }
.detail-row > span:first-child { color: var(--text-muted); }

/* ---- Masked email ----------------------------------------------------- */
.mask-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  word-break: break-all;
}

/* ---- Reviews ---------------------------------------------------------- */
.review-card { cursor: default; }
.review-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.25rem;
}
.stars { font-size: 1.125rem; color: #f59e0b; letter-spacing: 1px; }

.reply-box {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.75rem 1rem;
  margin-top: 0.75rem;
  font-size: 0.875rem;
}
.reply-form { margin-top: 0.75rem; }

/* ---- Team ------------------------------------------------------------- */
.member-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

/* ---- Properties ------------------------------------------------------- */
.property-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.property-card {
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.15s;
}
.property-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.property-img-wrap { height: 160px; overflow: hidden; background: var(--bg-main); }
.property-img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  background: linear-gradient(135deg, #e0e7ff 0%, #ede9fe 100%);
}
.property-card-body { padding: 1rem; }
.property-card-body h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0; }

/* ---- Auth pages ------------------------------------------------------- */
.auth-bg {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  padding: 1rem;
}

.auth-card { width: 100%; max-width: 420px; margin-bottom: 0; }

.auth-logo {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
  margin-bottom: 1.25rem;
}

.error-box {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #fca5a5;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

/* ---- Auth container (compat) ----------------------------------------- */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
}

/* ---- Toast ------------------------------------------------------------ */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 9999;
  animation: slide-up 0.2s ease;
  max-width: 360px;
}
.toast-success { background: #166534; color: #fff; }
.toast-error   { background: var(--danger); color: #fff; }

@keyframes slide-up {
  from { opacity: 0; transform: translateY(0.5rem); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Loading ---------------------------------------------------------- */
.center-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
}

.spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 9999px;
  animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Responsive ------------------------------------------------------- */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-grid   { grid-template-columns: 1fr; }
  .main-content { padding: 1.25rem; }
}

@media (max-width: 640px) {
  .sidebar { display: none; }
  .stats-grid { grid-template-columns: 1fr; }
}
