:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --radius: 10px;
    --shadow: 0 4px 14px rgba(0,0,0,.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header {
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}
.logo {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 8px;
}
.logo i { color: #f59e0b; }
.main-nav { display: flex; align-items: center; gap: 20px; }
.main-nav a { color: var(--gray-700); font-weight: 500; font-size: .95rem; }
.main-nav a:hover { color: var(--primary); text-decoration: none; }
.btn-nav {
    background: var(--primary);
    color: #fff !important;
    padding: 8px 16px;
    border-radius: 8px;
}
.btn-nav:hover { background: var(--primary-dark); }
.menu-toggle { display: none; background: none; border: none; font-size: 1.3rem; cursor: pointer; }

/* Main */
.main-content { flex: 1; padding: 28px 0 48px; }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: .95rem;
}
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* Cards */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}
.card-title { font-size: 1.15rem; font-weight: 600; margin-bottom: 12px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: .95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: var(--gray-500); }
.btn-secondary:hover { background: var(--gray-700); }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 6px; font-size: .9rem; }
.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 1rem;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
textarea.form-control { min-height: 120px; resize: vertical; }
select.form-control { appearance: auto; }
.form-hint { font-size: .85rem; color: var(--gray-500); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* Rating stars input */
.rating-input { display: flex; gap: 4px; flex-direction: row-reverse; justify-content: flex-end; }
.rating-input input { display: none; }
.rating-input label {
    font-size: 1.8rem;
    color: var(--gray-300);
    cursor: pointer;
    transition: color .15s;
}
.rating-input input:checked ~ label,
.rating-input label:hover,
.rating-input label:hover ~ label { color: #f59e0b; }

/* Reviews grid */
.reviews-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}
.review-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform .15s, box-shadow .15s;
}
.review-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.1); }
.review-card .photos { height: 160px; background: var(--gray-100); position: relative; overflow: hidden; }
.review-card .photos img { width: 100%; height: 100%; object-fit: cover; }
.review-card .body { padding: 16px; }
.review-card .title { font-weight: 600; font-size: 1.05rem; margin-bottom: 4px; }
.review-card .company { color: var(--gray-500); font-size: .9rem; margin-bottom: 8px; }
.review-card .meta { display: flex; align-items: center; gap: 12px; font-size: .85rem; color: var(--gray-500); margin-bottom: 8px; }
.review-card .stars { color: #f59e0b; letter-spacing: 1px; }
.review-card .excerpt { font-size: .9rem; color: var(--gray-700); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-pending { background: #e0e7ff; color: #3730a3; }

/* Categories */
.cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
.cat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform .15s;
}
.cat-card:hover { transform: translateY(-2px); text-decoration: none; }
.cat-card i { font-size: 2rem; color: var(--primary); margin-bottom: 10px; }
.cat-card h3 { font-size: 1.05rem; color: var(--gray-900); margin-bottom: 4px; }
.cat-card .count { font-size: .85rem; color: var(--gray-500); }

/* Hero */
.hero {
    background: linear-gradient(135deg, #2563eb, #1e40af);
    color: #fff;
    border-radius: var(--radius);
    padding: 40px 32px;
    margin-bottom: 32px;
    text-align: center;
}
.hero h1 { font-size: 1.8rem; margin-bottom: 8px; }
.hero p { opacity: .9; margin-bottom: 20px; }
.hero .btn { background: #fff; color: var(--primary); }
.hero .btn:hover { background: var(--gray-100); }

/* Stats */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 18px;
    text-align: center;
    box-shadow: var(--shadow);
}
.stat-card .num { font-size: 1.6rem; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: .85rem; color: var(--gray-500); }

/* Pagination */
.pagination {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 28px;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    padding: 8px 14px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--gray-200);
    color: var(--gray-700);
    font-size: .9rem;
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Footer */
.site-footer {
    background: #fff;
    border-top: 1px solid var(--gray-200);
    padding: 24px 0;
    text-align: center;
    color: var(--gray-500);
    font-size: .9rem;
}
.footer-links a { color: var(--gray-500); }

/* Review single */
.review-full .photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin: 16px 0;
}
.review-full .photos-grid img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
}

/* Cabinet */
.cabinet-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.cabinet-nav a {
    padding: 8px 16px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--gray-200);
    color: var(--gray-700);
    font-weight: 500;
}
.cabinet-nav a.active, .cabinet-nav a:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    text-decoration: none;
}

/* Filters */
.filters {
    background: #fff;
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: end;
}
.filters .form-group { margin: 0; min-width: 140px; }

/* Admin specific overrides in admin css */

@media (max-width: 768px) {
    .main-nav { display: none; }
    .main-nav.open { display: flex; flex-direction: column; position: absolute; top: 60px; left: 0; right: 0; background: #fff; padding: 16px; border-bottom: 1px solid var(--gray-200); gap: 12px; }
    .menu-toggle { display: block; }
}

/* Ads */
.ad-block {
    background: #fffbeb;
    border: 1px dashed #f59e0b;
    border-radius: 10px;
    padding: 12px 16px;
    margin: 16px 0;
    position: relative;
    text-align: center;
}
.ad-block .ad-label {
    position: absolute;
    top: 4px;
    right: 8px;
    font-size: .7rem;
    color: #92400e;
    background: #fef3c7;
    padding: 1px 6px;
    border-radius: 4px;
}
.ad-block .ad-img {
    max-width: 100%;
    max-height: 120px;
    border-radius: 6px;
    margin-bottom: 8px;
}
.ad-block .ad-title { font-weight: 600; }
.ad-block a { color: inherit; text-decoration: none; }
.ad-top { margin-bottom: 20px; }
.ad-bottom { margin-top: 20px; }

/* Mobile-first extras */
@media (max-width: 768px) {
  .container { padding: 0 12px; }
  .hero { padding: 24px 16px; }
  .hero h1 { font-size: 1.35rem; }
  .reviews-grid { grid-template-columns: 1fr; }
  .cat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .admin-grid { grid-template-columns: 1fr !important; }
  .header-inner { gap: 8px; height: auto; min-height: 56px; flex-wrap: wrap; padding: 8px 0; }
  .city-select { order: 3; }
  #installAppBtn { order: 2; font-size: .8rem; padding: 6px 10px; }
  table.admin-table, .card table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .cabinet-nav a { font-size: .85rem; padding: 8px 12px; }
  .ad-block { margin: 12px 0; }
}

@media (max-width: 480px) {
  .cat-grid { grid-template-columns: 1fr; }
  .main-nav a { padding: 10px 0; }
}
.suggest-box {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 50;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.1); max-height: 240px; overflow: auto;
}
.suggest-item { padding: 10px 12px; cursor: pointer; font-size: .92rem; }
.suggest-item:hover { background: #eff6ff; }
.form-group { position: relative; }

.test-mode-bar {
  background: #f1f5f9;
  border-top: 1px solid #e2e8f0;
  color: #64748b;
  font-size: .82rem;
  line-height: 1.45;
  padding: 8px 0;
  text-align: center;
}
.test-mode-bar .container { max-width: 1100px; margin: 0 auto; padding: 0 14px; }
.test-mode-link {
  color: var(--primary, #2563eb);
  font-weight: 600;
  text-decoration: underline;
  white-space: nowrap;
}
body { padding-bottom: 0; }

.notif-badge{background:#ef4444;color:#fff;border-radius:10px;font-size:.65rem;padding:1px 5px;margin-left:2px;vertical-align:top;}
.notif-drop{position:absolute;right:0;top:110%;background:#fff;border:1px solid #e5e7eb;border-radius:10px;min-width:280px;max-width:360px;box-shadow:0 10px 30px rgba(0,0,0,.12);z-index:300;max-height:360px;overflow:auto;}
.notif-item{display:block;padding:10px 12px;border-bottom:1px solid #f1f5f9;color:#111;text-decoration:none;font-size:.88rem;}
.notif-item:hover{background:#f8fafc;}
.notif-item small{display:block;color:#94a3b8;margin-top:2px;}

/* Header layout fix */
.site-header, header.site-header, .header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}
.header-inner, .site-header .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  width: 100%;
}
.logo, .site-logo, .brand {
  flex: 0 0 auto;
  max-width: 40%;
  font-size: clamp(0.95rem, 2.5vw, 1.25rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-search { order: 3; flex: 1 1 180px; }
.site-header nav, header nav, .main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: center;
  flex: 1 1 auto;
  justify-content: flex-end;
  min-width: 0;
}
.site-header nav a, header nav a {
  white-space: nowrap;
  font-size: .9rem;
}
@media (max-width: 768px) {
  .logo, .site-logo, .brand { max-width: 100%; flex: 1 1 auto; }
  .header-search { order: 2; flex: 1 1 100%; max-width: none; }
  .site-header nav, header nav, .main-nav {
    order: 3;
    flex: 1 1 100%;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
}
