:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-muted: #f1f3f8;
  --text: #0f172a;
  --text-muted: #475569;
  --border: #e2e8f0;
  --brand: #1d4ed8;
  --brand-strong: #1e40af;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  --radius: 14px;
}

[data-theme=dark] {
  color-scheme: dark;
  --bg: #0f172a;
  --panel: #111827;
  --panel-muted: #1e293b;
  --text: #f8fafc;
  --text-muted: #cbd5f5;
  --border: #334155;
  --brand: #60a5fa;
  --brand-strong: #3b82f6;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #f87171;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

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

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, rgba(96, 165, 250, 0.16), transparent 45%), var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100vh;
  overflow: hidden;
  transition: transform 0.25s ease;
  z-index: 30;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 20;
}

.camera-modal {
  position: fixed;
  inset: 12px;
  z-index: 40;
  background: var(--panel);
  overflow: auto;
}

.camera-modal video {
  max-height: calc(100vh - 180px);
  -o-object-fit: cover;
     object-fit: cover;
}

.camera-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.sidebar h1 {
  font-size: 22px;
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.4px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-link {
  padding: 10px 14px;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 500;
  transition: all 0.2s ease;
}

.nav-link.active,
.nav-link:hover {
  background: var(--panel-muted);
  color: var(--text);
}

.sidebar-menu {
  overflow-y: auto;
  padding-right: 4px;
  flex: 1 1 auto;
  max-height: calc(100vh - 200px);
}

.content {
  padding: 0 40px 20px;
  margin-left: 260px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.topbar-sticky {
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 10px 0;
  z-index: 20;
}

.content-scroll {
  overflow-y: auto;
  padding: 12px 0 40px;
}

.topbar h2 {
  margin: 0;
  font-size: 26px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-user {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}

.topbar-title strong {
  font-size: 18px;
}

body.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
}

body.sidebar-collapsed .content {
  margin-left: 0;
}

body:not(.sidebar-collapsed) .content {
  margin-left: 260px;
}

body:not(.sidebar-collapsed) .sidebar-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn:hover {
  background: var(--brand-strong);
}

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background: var(--panel-muted);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.card h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.card p {
  margin: 0;
  color: var(--text-muted);
}

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 14px;
}

.input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-muted);
  color: var(--text);
  font-size: 14px;
}

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

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
}

.badge.available {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.badge.under_offer {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.badge.sold,
.badge.rented {
  background: rgba(220, 38, 38, 0.2);
  color: var(--danger);
}

.split {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.pagination {
  display: flex;
  gap: 6px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.pagination a,
.pagination span {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.pagination .active span,
.pagination a:hover {
  background: var(--panel-muted);
  color: var(--text);
}

@media (max-width: 960px) {
  .app-shell {
    min-height: auto;
  }
  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    border-right: none;
    border-bottom: 1px solid var(--border);
    position: fixed;
    width: 260px;
    height: 100vh;
  }
  .sidebar-menu {
    width: 100%;
    order: 2;
  }
  .content {
    margin-left: 0;
    padding: 24px 20px 20px;
  }
  .topbar {
    align-items: flex-start;
  }
  .card-grid {
    grid-template-columns: 1fr;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .topbar-left,
  .topbar-right {
    width: 100%;
    justify-content: space-between;
  }
  .topbar-user {
    width: 100%;
    justify-content: space-between;
  }
  .table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}
