:root {
  --bg: #f4f5f9;
  --card-bg: #ffffff;
  --text-dark: #1f2937;
  --text-muted: #6b7280;
  --accent: #f5a623;
  --available: #2f855a;
  --kiv: #dd9d18;
  --booked: #c0392b;
  --sold: #374151;
  --border: #e5e7eb;
  --telegram: #229ed9;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text-dark);
  overflow-x: hidden;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

h1.site-title {
  text-align: center;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin: 20px 0 24px;
}

.filter-bar {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 28px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.filter-bar label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-right: 4px;
}

.filter-bar select, .filter-bar input[type="text"] {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 0.9rem;
  color: var(--text-dark);
}

.filter-bar button {
  background: var(--accent);
  border: none;
  color: #1f2937;
  font-weight: 700;
  padding: 9px 18px;
  border-radius: 8px;
  cursor: pointer;
}

.filter-bar button:hover { filter: brightness(0.95); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  max-width: 100%;
}
@media (max-width: 340px) {
  .grid { grid-template-columns: 1fr; }
}

.card {
  background: var(--card-bg);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
}

.card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: #dfe3ea;
}

.card-body {
  padding: 14px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-title { font-weight: 700; font-size: 1.05rem; margin: 0; }
.card-state { color: var(--text-muted); font-size: 0.85rem; margin: 0 0 4px; }

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.price { color: var(--accent); font-weight: 700; font-size: 1rem; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

.badge.AVAILABLE { background: var(--available); }
.badge.KIV { background: var(--kiv); }
.badge.BOOKED { background: var(--booked); }
.badge.SOLD { background: var(--sold); }
.badge.EXPIRED { background: #9ca3af; }

.tg-btn {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--telegram);
  color: #fff;
  text-decoration: none;
  padding: 9px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}
.tg-btn:hover { filter: brightness(0.95); }

.coa-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px;
}

/* ---------- Admin ---------- */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  color: #fff;
}
.btn-primary { background: var(--accent); color: #1f2937; }
.btn-danger { background: var(--booked); }
.btn-muted { background: #9ca3af; }
.btn-outline { background: #fff; color: var(--text-dark); border: 1px solid var(--border); }

table.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
table.admin-table th, table.admin-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.9rem;
  vertical-align: middle;
}
table.admin-table th { background: #f9fafb; font-weight: 700; color: var(--text-muted); }

.status-select {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.8rem;
}

.login-box {
  max-width: 360px;
  margin: 80px auto;
  background: #fff;
  padding: 32px;
  border-radius: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.login-box h2 { text-align: center; margin-top: 0; }
.login-box input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
}
.login-box button { width: 100%; }

.form-box {
  background: #fff;
  padding: 24px;
  border-radius: 14px;
  max-width: 560px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.form-box label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 12px 0 4px;
  color: var(--text-muted);
}
.form-box input, .form-box select, .form-box textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
}

.alert {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.alert-error { background: #fde8e8; color: #c0392b; }
.alert-success { background: #e6f4ea; color: #2f855a; }

.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 30px;
}
.pagination a, .pagination span {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text-dark);
  font-size: 0.9rem;
  background: #fff;
}
.pagination .active { background: var(--accent); border-color: var(--accent); font-weight: 700; }

@media (max-width: 640px) {
  .admin-header { flex-direction: column; align-items: flex-start; }
}

/* ---------- Top nav (single row) ---------- */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.topbar-row {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.topbar-brand {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text-dark);
  text-decoration: none;
  flex-shrink: 0;
}
.main-nav {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
}
.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  padding-bottom: 4px;
  border-bottom: 2px solid transparent;
}
.nav-link.active, .nav-link:hover {
  color: var(--text-dark);
  border-bottom-color: var(--accent);
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.btn-sm { padding: 7px 16px; font-size: 0.85rem; }

.bell {
  position: relative;
  font-size: 1.2rem;
  text-decoration: none;
  color: var(--text-muted);
  padding: 4px;
}
.bell-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--booked);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 5px;
  line-height: 1.3;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
}
.topbar-user img, .topbar-user-fallback {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
}
.topbar-user-fallback {
  background: var(--accent);
  color: #1f2937;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.topbar-user-info { display: flex; flex-direction: column; line-height: 1.2; }
.topbar-user-name { font-weight: 700; font-size: 0.85rem; color: var(--text-dark); }
.topbar-user-role { font-size: 0.72rem; color: var(--text-muted); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  background: linear-gradient(180deg, #eef1f6 0%, #dde3ec 100%);
  padding: 40px 20px 90px;
  overflow: hidden;
}
.hero-bg {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 55%;
  background-size: cover;
  background-position: center;
  mask-image: linear-gradient(to right, transparent, black 25%);
  -webkit-mask-image: linear-gradient(to right, transparent, black 25%);
  opacity: 0.9;
}
.hero-inner {
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}
.hero h1 {
  font-size: 2rem;
  font-weight: 400;
  color: #1e293b;
  margin: 10px 0 2px;
}
.hero h1 strong {
  display: block;
  font-weight: 800;
  font-size: 2.1rem;
}
.hero p {
  color: #475569;
  margin: 6px 0 26px;
}
.hero-search {
  background: #fff;
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  max-width: 950px;
}
.hero-search input[type="text"], .hero-search input[type="number"], .hero-search select {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.88rem;
}
.hero-search input[type="text"] { flex: 2 1 200px; }
.hero-search select, .hero-search input[type="number"] { flex: 1 1 110px; }
.hero-search button {
  background: #1e293b;
  color: #fff;
  border: none;
  font-weight: 700;
  padding: 10px 22px;
  border-radius: 8px;
  cursor: pointer;
  flex: 0 0 auto;
}

/* ---------- Stats row ---------- */
.stats-row {
  max-width: 1200px;
  margin: -55px auto 0;
  padding: 0 20px;
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
@media (max-width: 900px) { .stats-row { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .stats-row { grid-template-columns: 1fr; } }
.stats-row > * { min-width: 0; }
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: flex;
  gap: 12px;
  align-items: center;
}
.stat-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  color: #fff;
}
.stat-icon.blue { background: #6366f1; }
.stat-icon.green { background: #16a34a; }
.stat-icon.orange { background: #f97316; }
.stat-number { font-size: 1.3rem; font-weight: 800; color: var(--text-dark); line-height: 1.1; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); }
.stat-delta { font-size: 0.72rem; color: #16a34a; font-weight: 700; margin-top: 2px; }
.cta-card {
  background: #1e293b;
  color: #fff;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}
.cta-card strong { font-size: 0.95rem; }
.cta-card p { font-size: 0.78rem; color: #cbd5e1; margin: 0 0 4px; }
.cta-card-actions { display: flex; gap: 8px; }
.cta-card .btn { padding: 6px 12px; font-size: 0.78rem; }

/* ---------- Home content grid ---------- */
.home-grid {
  max-width: 1200px;
  margin: 0 auto;
  padding: 36px 20px;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 28px;
}
@media (max-width: 900px) { .home-grid { grid-template-columns: 1fr; } }
.home-grid > div { min-width: 0; overflow-x: hidden; }

.hscroll {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 10px;
  max-width: 100%;
}
.hscroll .card { flex: 0 0 250px; }

.new-badge {
  position: absolute;
  top: 10px; left: 10px;
  background: #6366f1;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
}
.card-thumb-wrap { position: relative; }
.card-specs { font-size: 0.78rem; color: var(--text-muted); margin: 2px 0; }

.buyer-grid {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 10px;
  max-width: 100%;
}
.buyer-card {
  flex: 0 0 250px;
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.buyer-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.buyer-tag {
  background: #fde8e8; color: #c0392b;
  font-size: 0.68rem; font-weight: 700;
  padding: 3px 9px; border-radius: 6px;
}
.buyer-time { font-size: 0.72rem; color: #9ca3af; }
.buyer-row { display: flex; justify-content: space-between; font-size: 0.85rem; margin: 5px 0; }
.buyer-row .label { color: #9ca3af; }
.buyer-actions { display: flex; gap: 8px; margin-top: 12px; }
.buyer-actions .btn { flex: 1; text-align: center; padding: 8px; font-size: 0.82rem; }

.sidebar-block { margin-bottom: 32px; min-width: 0; }
.sidebar-list { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

@media (max-width: 900px) {
  .sidebar-list {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 8px;
    max-width: 100%;
  }
  .sidebar-list .featured-card { flex: 0 0 240px; }
  .sidebar-list .agent-rank-card { flex: 0 0 240px; }
}

.featured-card {
  display: flex;
  gap: 10px;
  background: #fff;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  text-decoration: none;
  color: inherit;
}
.featured-card img {
  width: 76px; height: 64px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}
.featured-card .info { font-size: 0.82rem; min-width: 0; }
.featured-card .price { font-size: 0.85rem; }
.featured-badge {
  background: #fef3c7; color: #b45309;
  font-size: 0.62rem; font-weight: 700;
  padding: 2px 6px; border-radius: 5px;
  margin-left: 6px;
}

.agent-rank-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  text-decoration: none;
  color: inherit;
  max-width: 100%;
}
.agent-rank-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.agent-rank-info { flex: 1; min-width: 0; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; }
.agent-rank-agency { font-size: 0.72rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-rank-stats { text-align: right; font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }
.agent-rank-stats strong { color: var(--text-dark); font-size: 0.85rem; }
.medal { font-size: 1rem; margin-right: 2px; }
@media (max-width: 400px) {
  .agent-rank-stats { font-size: 0.66rem; }
  .agent-rank-stats strong { font-size: 0.76rem; }
}

.activity-section { max-width: 1200px; margin: 0 auto 50px; padding: 0 20px; }
.activity-row-list { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; max-width: 100%; }
.activity-row {
  flex: 0 0 220px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.activity-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: #dfe3ea; }
.activity-info { font-size: 0.8rem; min-width: 0; }
.activity-info strong { display: block; font-size: 0.82rem; }
.activity-time { font-size: 0.68rem; color: var(--text-muted); }

/* ---------- Footer ---------- */
.site-footer {
  max-width: 1100px;
  margin: 40px auto 0;
  padding: 20px 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.site-footer a { color: var(--telegram); font-weight: 600; text-decoration: none; }

/* ---------- Agent profile meta line ---------- */
.agent-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 24px;
}
.agent-meta .item:not(:first-child)::before {
  content: "-";
  margin-right: 6px;
  color: #cbd5e1;
}
.agent-meta a { color: var(--telegram); text-decoration: none; font-weight: 600; }
@media (max-width: 640px) {
  .agent-meta { flex-direction: column; align-items: flex-start; gap: 4px; }
  .agent-meta .item:not(:first-child)::before { content: none; }
}

/* ---------- Left-aligned page variant (agent profile page) ---------- */
/* Matches the nav bar's max-width (1200px) so this content's left edge lines up with the logo, instead of hugging the browser edge or floating centered with the old 1100px width. */
.container-left {
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 40px;
  padding-right: 20px;
}
@media (max-width: 640px) {
  .container-left {
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* ---------- Search bar ---------- */
.search-bar {
  display: flex;
  gap: 8px;
  max-width: 500px;
  margin: 0 auto 28px;
}
.search-bar input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
}
.search-bar button {
  background: var(--accent);
  border: none;
  color: #1f2937;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
}

/* ---------- Listing age note ---------- */
.listing-age {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 2px 0 0;
}

/* ---------- WTB compact rows (one per line, no image) ---------- */
.wtb-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.wtb-row {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.wtb-title { font-weight: 700; flex: 1 1 220px; }
.wtb-meta { color: var(--text-muted); font-size: 0.85rem; }
.wtb-budget { color: var(--accent); font-weight: 700; }
.wtb-agent { font-size: 0.85rem; color: var(--text-muted); }
.wtb-agent a { color: var(--text-dark); font-weight: 600; text-decoration: none; }

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 36px 0 14px;
  gap: 10px;
  flex-wrap: wrap;
}
.section-heading h2 { margin: 0; font-size: 1.2rem; }
@media (max-width: 480px) {
  .section-heading { flex-wrap: nowrap; }
  .section-heading h2 { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .section-heading .btn { flex-shrink: 0; padding: 6px 12px; font-size: 0.8rem; }
}

/* ---------- About page ---------- */
.about-content { line-height: 1.7; color: var(--text-dark); }
.about-content h2 { font-size: 1.15rem; margin: 28px 0 10px; }
.about-content h2:first-child { margin-top: 0; }
.about-content p { margin: 0 0 12px; color: #374151; }
.about-content ul { margin: 0 0 14px; padding-left: 22px; }
.about-content li { margin-bottom: 4px; color: #374151; }
