/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: #f0f2f5;
    color: #333;
    line-height: 1.5;
}
a { color: #1565c0; text-decoration: none; }
a:hover { text-decoration: underline; color: #0d47a1; }
img { max-width: 100%; display: block; }
button { cursor: pointer; }

/* ===== LAYOUT ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 12px;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-block;
    padding: 8px 18px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background .15s;
}
.btn-add {
    background: #43a047;
    color: #fff;
}
.btn-add:hover { background: #2e7d32; color: #fff; text-decoration: none; }

.btn-login {
    background: #1565c0;
    color: #fff;
}
.btn-login:hover { background: #0d47a1; color: #fff; text-decoration: none; }

.btn-search {
    background: #1565c0;
    color: #fff;
    padding: 8px 22px;
    border-radius: 0 4px 4px 0;
    font-size: 13px;
    border: none;
}
.btn-search:hover { background: #0d47a1; }

.btn-primary {
    background: #1565c0;
    color: #fff;
    padding: 9px 22px;
}
.btn-primary:hover { background: #0d47a1; color: #fff; text-decoration: none; }

.btn-edit {
    background: #f57c00;
    color: #fff;
    padding: 7px 16px;
}
.btn-edit:hover { background: #e65100; color: #fff; text-decoration: none; }

.btn-fav {
    background: #fff;
    color: #1565c0;
    border: 1px solid #1565c0;
    padding: 7px 16px;
}
.btn-fav.active, .btn-fav:hover { background: #1565c0; color: #fff; }

/* ===== HEADER ===== */
.site-header {
    background: #fff;
    color: #fff;
    padding: 10px 0;
}
.site-header .container {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    text-decoration: none;
}
.logo img { display: block;height: 64px;}
.logo:hover { opacity: .9; }

.header-stats {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 12px;
    color: #bbdefb;
    flex: 1;
}
.header-stats b { color: #fff; }

.header-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
}

/* ===== SEARCH BAR ===== */
.search-bar {
    background: #1976d2;
    padding: 10px 0;
    border-top: 1px solid rgba(255,255,255,.15);
}
.search-form {
    display: flex;
    gap: 0;
    height: 40px;
}
.search-input {
    flex: 1;
    padding: 0 12px;
    font-size: 14px;
    border: none;
    outline: none;
    border-radius: 4px 0 0 4px;
    background: #fff;
}
.search-select {
    padding: 0 10px;
    font-size: 13px;
    border: none;
    border-left: 1px solid #e0e0e0;
    background: #fff;
    cursor: pointer;
    min-width: 140px;
    outline: none;
}

/* ===== CATEGORY NAV ===== */
.cat-nav {
    background: #0d47a1;
    padding: 0;
    overflow-x: auto;
}
.cat-nav .container {
    display: flex;
    gap: 0;
    flex-wrap: nowrap;
}
.cat-nav a {
    color: #e3f2fd;
    font-size: 13px;
    padding: 9px 14px;
    white-space: nowrap;
    display: block;
    border-right: 1px solid rgba(255,255,255,.1);
    transition: background .12s;
}
.cat-nav a:hover { background: rgba(255,255,255,.15); color: #fff; text-decoration: none; }

/* ===== MAIN LAYOUT ===== */
.site-main {
    padding: 16px 0 40px;
}

/* ===== BREADCRUMBS ===== */
.breadcrumbs {
    font-family: 'Arsenal', sans-serif;
    font-size: 18px;
    color: #777;
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}
.breadcrumbs a { color: #1565c0; }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs span { color: #aaa; }

/* ===== PAGE HEADING ===== */
h1 {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 12px;
}
h2 {
    font-size: 16px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 10px;
}

/* ===== MAIN PAGE ===== */

/* Category grid */
.main-cats { margin-bottom: 24px; }
.cats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}
.cat-root {
    background: #fff;
    border-radius: 6px;
    padding: 12px 14px;
    border: 1px solid #e8eaf0;
}
.cat-root__title {
    font-size: 14px;
    font-weight: 700;
    color: #1565c0;
    display: block;
    margin-bottom: 6px;
}
.cat-root__title:hover { text-decoration: underline; }
.cat-children {
    list-style: none;
    margin: 0;
    padding: 0;
}
.cat-children li { line-height: 1.8; }
.cat-children a {
    font-size: 12px;
    color: #555;
}
.cat-children a:hover { color: #1565c0; text-decoration: underline; }

/* Items sections */
.items-vip, .items-latest { margin-bottom: 24px; }
.items-vip h2 { color: #b8860b; }

/* Item card grid */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}
.item-card {
    background: #fff;
    border-radius: 6px;
    border: 1px solid #e8eaf0;
    overflow: hidden;
    transition: box-shadow .15s;
}
.item-card:hover { box-shadow: 0 3px 12px rgba(0,0,0,.12); }
.item-card--vip { border-color: #ffd54f; background: #fffde7; }
.item-card > a {
    display: block;
    color: inherit;
    text-decoration: none;
}
.item-card img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    background: #f5f5f5;
}
.item-card__title {
    font-size: 13px;
    font-weight: 600;
    color: #1565c0;
    padding: 8px 10px 4px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.item-card__price {
    font-size: 14px;
    font-weight: 700;
    color: #2e7d32;
    padding: 2px 10px 4px;
}
.item-card__region, .item-card__date {
    font-size: 11px;
    color: #999;
    padding: 0 10px 6px;
}

/* ===== CATEGORY PAGE ===== */
.cat-layout {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

/* Subcategories */
.subcats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}
.subcat-link {
    background: #e3f2fd;
    color: #1565c0;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid #bbdefb;
}
.subcat-link:hover { background: #1565c0; color: #fff; text-decoration: none; }

/* Filters panel */
.filters-panel {
    width: 220px;
    flex-shrink: 0;
    background: #fff;
    border: 1px solid #e8eaf0;
    border-radius: 6px;
    padding: 14px;
}
.filter-group {
    margin-bottom: 14px;
}
.filter-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.filter-group select,
.filter-group input[type="text"],
.filter-group input[type="number"] {
    width: 100%;
    padding: 7px 9px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    background: #fafafa;
    color: #333;
}
.filter-group select:focus,
.filter-group input:focus {
    border-color: #1565c0;
    background: #fff;
    outline: none;
}
.range-inputs { display: flex; gap: 6px; }
.range-inputs input { flex: 1; }
.checkbox-label { display: flex !important; align-items: center; gap: 6px; font-size: 13px !important; font-weight: 400 !important; text-transform: none !important; letter-spacing: 0 !important; cursor: pointer; }
.filter-group button[type="submit"] {
    width: 100%;
    background: #1565c0;
    color: #fff;
    border: none;
    padding: 9px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 6px;
}
.filter-group button[type="submit"]:hover { background: #0d47a1; }
.filters-panel > form > a {
    display: block;
    text-align: center;
    font-size: 12px;
    color: #999;
}
.filters-panel > form > button[type="submit"],
.filters-panel > form > a {
    margin-top: 4px;
    padding: 5px 10px;
}

/* Items list */
.items-list { flex: 1; min-width: 0; }
.items-count {
    font-size: 13px;
    color: #777;
    margin-bottom: 10px;
}
.no-items {
    background: #fff;
    border: 1px solid #e8eaf0;
    border-radius: 6px;
    padding: 30px;
    text-align: center;
    color: #999;
}

/* List view (cat page) */
.items-list .items-grid {
    grid-template-columns: 1fr;
    gap: 8px;
}
.items-list .item-card > a {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.items-list .item-card img {
    width: 130px;
    height: 100px;
    flex-shrink: 0;
    border-radius: 4px 0 0 4px;
}
.items-list .item-card__body {
    flex: 1;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.items-list .item-card__title {
    padding: 0;
    font-size: 14px;
    -webkit-line-clamp: 2;
}
.items-list .item-card__price { padding: 0; font-size: 15px; }
.items-list .item-card__region,
.items-list .item-card__date { padding: 0; }
.items-list .item-card__meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: auto;
}
.item-card--vip .item-card__title::before {
    content: 'VIP';
    background: #ffc107;
    color: #5d4037;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    margin-right: 5px;
    vertical-align: middle;
}

/* ===== PAGINATION ===== */
.pagination {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 16px;
    align-items: center;
}
.pagination a,
.pagination .page-current {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border-radius: 4px;
    font-size: 13px;
    border: 1px solid #ddd;
    background: #fff;
    color: #1565c0;
    text-decoration: none;
}
.pagination a:hover { background: #e3f2fd; border-color: #1565c0; }
.pagination .page-current {
    background: #1565c0;
    color: #fff;
    border-color: #1565c0;
    font-weight: 700;
}

/* ===== ITEM PAGE ===== */
.item-page {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}
.item-gallery {
    width: 460px;
    flex-shrink: 0;
}
.gallery-main {
    border-radius: 6px;
    overflow: hidden;
    background: #f5f5f5;
    margin-bottom: 8px;
}
.gallery-main img {
    width: 100%;
    height: 340px;
    object-fit: cover;
    cursor: pointer;
}
.gallery-thumbs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.gallery-thumbs a img {
    width: 72px;
    height: 56px;
    object-fit: cover;
    border-radius: 4px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color .12s;
}
.gallery-thumbs a:hover img,
.gallery-thumbs a.active img { border-color: #1565c0; }

.item-info { flex: 1; }
.item-info h1 { font-size: 20px; margin-bottom: 10px; }
.item-price {
    font-size: 24px;
    font-weight: 700;
    color: #2e7d32;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.negotiable {
    font-size: 13px;
    color: #777;
    font-weight: 400;
}
.item-adtype {
    display: inline-block;
    background: #e3f2fd;
    color: #1565c0;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    margin-bottom: 12px;
}
.item-attrs {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 14px;
    font-size: 13px;
}
.item-attrs tr { border-bottom: 1px solid #f0f0f0; }
.item-attrs th {
    text-align: left;
    color: #777;
    font-weight: 400;
    padding: 6px 0;
    width: 40%;
}
.item-attrs td { padding: 6px 0; font-weight: 500; }

.item-description {
    font-size: 14px;
    line-height: 1.7;
    color: #444;
    background: #fff;
    border: 1px solid #e8eaf0;
    border-radius: 6px;
    padding: 14px;
    margin-bottom: 16px;
}

.item-contacts {
    background: #fff;
    border: 1px solid #e8eaf0;
    border-radius: 6px;
    padding: 14px 16px;
    margin-bottom: 14px;
}
.contact-name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}
.contact-agency {
    font-size: 12px;
    color: #777;
    margin-bottom: 6px;
}
.contact-phone a {
    font-size: 20px;
    font-weight: 700;
    color: #1565c0;
    letter-spacing: .5px;
}
.contact-district {
    font-size: 13px;
    color: #888;
    margin-top: 6px;
}

.item-actions { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }

.item-author {
    font-size: 13px;
    color: #777;
    margin-bottom: 8px;
}
.item-meta {
    font-size: 12px;
    color: #aaa;
    line-height: 1.7;
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.88);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}
.lightbox.open { display: flex; }
.lightbox img {
    max-width: 92vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
}
.lightbox-close {
    position: fixed;
    top: 18px;
    right: 24px;
    color: #fff;
    font-size: 34px;
    cursor: pointer;
    line-height: 1;
    background: none;
    border: none;
    z-index: 10000;
}
.lightbox-prev, .lightbox-next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    font-size: 42px;
    cursor: pointer;
    background: rgba(0,0,0,.4);
    border: none;
    padding: 10px 14px;
    z-index: 10000;
}
.lightbox-prev { left: 10px; }
.lightbox-next { right: 10px; }

/* ===== ADD FORM ===== */
.add-form {
    background: #fff;
    border: 1px solid #e8eaf0;
    border-radius: 6px;
    padding: 24px;
    max-width: 720px;
}
.form-errors {
    background: #ffebee;
    border: 1px solid #ef9a9a;
    border-radius: 4px;
    padding: 12px 16px;
    margin-bottom: 16px;
}
.form-errors .error { color: #c62828; font-size: 13px; }

.form-group { margin-bottom: 16px; }
.form-group > label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 5px;
}
.form-group input[type="text"],
.form-group input[type="tel"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    background: #fafafa;
    color: #333;
    transition: border-color .12s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #1565c0;
    background: #fff;
    outline: none;
}
.form-group textarea { resize: vertical; }
.price-row { display: flex; gap: 8px; align-items: center; }
.price-row input { flex: 2; }
.price-row select { flex: 1; }
.price-row label { display: flex; align-items: center; gap: 5px; font-size: 13px; white-space: nowrap; font-weight: 400; }
.radio-group { display: flex; gap: 14px; flex-wrap: wrap; }
.radio-group label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 400; cursor: pointer; }

#submit-btn {
    background: #43a047;
    color: #fff;
    border: none;
    padding: 12px 32px;
    font-size: 15px;
    font-weight: 700;
    border-radius: 4px;
    cursor: pointer;
    transition: background .15s;
}
#submit-btn:hover { background: #2e7d32; }
#submit-btn:disabled { background: #bbb; cursor: default; }

/* Photo upload */
#photo-upload-area {
    border: 2px dashed #bbdefb;
    border-radius: 6px;
    padding: 16px;
    background: #f8fbff;
}
#photo-upload-area button[type="button"] {
    background: #1565c0;
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    margin-bottom: 10px;
}
#photo-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.photo-preview {
    position: relative;
    width: 90px;
    height: 90px;
}
.photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}
.photo-preview button {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0,0,0,.65);
    color: #fff;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 11px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* ===== SEARCH PAGE ===== */
.find-form { display: flex; gap: 8px; margin-bottom: 16px; max-width: 600px; }
.find-form input {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}
.find-form button {
    background: #1565c0;
    color: #fff;
    border: none;
    padding: 9px 20px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.find-results-header {
    font-size: 14px;
    color: #555;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e8eaf0;
}
.find-hint { font-size: 13px; color: #999; }

/* ===== CABINET ===== */
.cabinet-nav {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e8eaf0;
    margin-bottom: 20px;
}
.cabinet-nav a {
    padding: 9px 18px;
    font-size: 14px;
    color: #555;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}
.cabinet-nav a.active {
    color: #1565c0;
    border-bottom-color: #1565c0;
    font-weight: 600;
}
.cabinet-nav a:hover { color: #1565c0; text-decoration: none; }

.cnt { font-size: 13px; color: #999; font-weight: 400; }

.btn-add {
    display: inline-block;
    background: #43a047;
    color: #fff;
    padding: 8px 18px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
}
.btn-add:hover { background: #2e7d32; color: #fff; text-decoration: none; }

.my-items-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #e8eaf0;
    border-radius: 6px;
    overflow: hidden;
    font-size: 13px;
}
.my-items-table thead { background: #f5f7fb; }
.my-items-table th {
    text-align: left;
    padding: 10px 12px;
    color: #777;
    font-weight: 600;
    border-bottom: 1px solid #e8eaf0;
}
.my-items-table td {
    padding: 10px 12px;
    vertical-align: middle;
    border-bottom: 1px solid #f5f5f5;
}
.my-items-table tr:last-child td { border-bottom: none; }
.my-items-table td img {
    width: 54px;
    height: 44px;
    object-fit: cover;
    border-radius: 3px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}
.my-items-table .btn-up {
    background: #e3f2fd;
    color: #1565c0;
    border: 1px solid #bbdefb;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    margin-left: 8px;
}
.my-items-table .btn-up:hover { background: #1565c0; color: #fff; }

.profile-table {
    background: #fff;
    border: 1px solid #e8eaf0;
    border-radius: 6px;
    overflow: hidden;
    border-collapse: collapse;
    font-size: 14px;
}
.profile-table th, .profile-table td {
    padding: 11px 16px;
    border-bottom: 1px solid #f0f0f0;
    text-align: left;
}
.profile-table th { color: #777; font-weight: 400; width: 160px; }
.profile-table tr:last-child th,
.profile-table tr:last-child td { border-bottom: none; }

/* ===== FOOTER ===== */
.site-footer {
    background: #263238;
    color: #90a4ae;
    padding: 20px 0;
    font-size: 13px;
    margin-top: 20px;
}
.site-footer .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.footer-links { display: flex; gap: 16px; }
.footer-links a { color: #90a4ae; }
.footer-links a:hover { color: #fff; text-decoration: none; }

/* ===== ADMIN ===== */
/* (minimal, the main CSS is shared) */

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .cat-layout { flex-direction: column; }
    .filters-panel { width: 100%; }
    .item-page { flex-direction: column; }
    .item-gallery { width: 100%; }
}
@media (max-width: 640px) {
    .header-stats { display: none; }
    .search-select { display: none; }
    .items-grid { grid-template-columns: repeat(2, 1fr); }
    .items-list .items-grid { grid-template-columns: 1fr; }
    .items-list .item-card > a { flex-direction: column; }
    .items-list .item-card img { width: 100%; height: 180px; border-radius: 6px 6px 0 0; }
    .cats-grid { grid-template-columns: repeat(2, 1fr); }
    h1 { font-size: 17px; }
}
@media (max-width: 400px) {
    .items-grid { grid-template-columns: 1fr; }
}
