:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 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: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Header */
.header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.logo span {
    color: var(--text);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover {
    background: var(--bg);
}

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
}

/* Main */
.main {
    flex: 1;
    padding: 24px 0;
}

/* Ad blocks */
.ad-block {
    content-visibility: auto;
    contain-intrinsic-size: auto 420px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}

.ad-photo {
    width: 100%;
    height: auto;
    max-height: none;
    object-fit: contain;
    display: block;
    background: #e2e8f0;
    vertical-align: top;
}

/* На очень больших экранах ограничиваем, чтобы не было гигантских баннеров */
@media (min-width: 900px) {
    .ad-photo {
        max-height: 520px;
        object-fit: contain;
    }
}

.ad-body {
    padding: 20px;
}

.ad-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text);
}

.ad-text {
    color: var(--muted);
    margin-bottom: 16px;
    font-size: 0.95rem;
}

.ad-text .expand-link {
    color: var(--primary);
    font-size: 0.9rem;
    margin-left: 4px;
}

.ad-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.votes {
    display: flex;
    align-items: center;
    gap: 8px;
}

.vote-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
}
.vote-btn:hover {
    background: var(--bg);
}
.vote-btn.liked {
    border-color: var(--success);
    color: var(--success);
}
.vote-btn.disliked {
    border-color: var(--danger);
    color: var(--danger);
}

.apply-count {
    font-size: 0.85rem;
    color: var(--muted);
}

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

.review-link {
    font-size: 0.9rem;
    color: var(--primary);
    text-decoration: none;
}
.review-link:hover {
    text-decoration: underline;
}

/* Footer */
.footer {
    background: var(--card);
    border-top: 1px solid var(--border);
    padding: 16px 0;
    text-align: center;
    font-size: 0.9rem;
    color: var(--muted);
    margin-top: auto;
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
@media (max-width: 600px) {
    .footer-inner {
        flex-direction: column;
        gap: 16px;
    }
    .footer-messengers {
        max-width: none;
    }
}

.footer-stats {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.footer-datetime {
    font-weight: 500;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.footer-messengers {
    display: grid;
    grid-template-columns: repeat(3, 64px);
    gap: 8px 6px;
    align-items: start;
    justify-items: center;
    min-width: 200px;
    max-width: 210px;
}

.footer-left { justify-content: start; }
.footer-right { justify-content: end; }

.footer-msg {
    text-decoration: none;
    line-height: 1.15;
    transition: transform 0.15s;
    width: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    color: var(--text);
}
.footer-msg:hover {
    transform: scale(1.06);
    color: var(--primary);
}
.footer-msg-icon {
    width: 32px !important;
    height: 32px !important;
    max-width: 32px !important;
    max-height: 32px !important;
    object-fit: contain;
    display: block;
    border-radius: 8px;
}
.footer-msg-emoji {
    font-size: 1.4rem;
    line-height: 1;
}
.footer-msg-label {
    font-size: 0.68rem;
    text-align: center;
    color: var(--muted);
    word-break: break-word;
    max-width: 64px;
    line-height: 1.2;
}
.footer-msg:hover .footer-msg-label {
    color: var(--primary);
}

/* На узких экранах — чуть компактнее */
@media (max-width: 600px) {
    .footer-messengers {
        grid-template-columns: repeat(3, 56px);
        gap: 6px 4px;
        min-width: 176px;
        max-width: 190px;
    }
    .footer-msg {
        width: 56px;
    }
    .footer-msg-icon {
        width: 28px !important;
        height: 28px !important;
        max-width: 28px !important;
        max-height: 28px !important;
    }
    .footer-msg-label {
        font-size: 0.62rem;
        max-width: 56px;
    }
}

.badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    padding: 0 5px;
    margin-left: 4px;
    vertical-align: middle;
}

.review-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.review-avatar {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    flex-shrink: 0 !important;
    display: block !important;
}

.review-avatar-default {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    background: #e2e8f0;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    border-radius: 50%;
}

.review-text {
    line-height: 1.5;
}

/* Modals / Auth */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--card);
    border-radius: var(--radius);
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--muted);
    line-height: 1;
}

.modal-body {
    padding: 20px;
}

.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 4px;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.15s;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-hint {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 4px;
}

.avatar-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    background: #e2e8f0;
    display: block;
    margin-bottom: 8px;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.95rem;
}
.alert-success {
    background: #dcfce7;
    color: #166534;
}
.alert-error {
    background: #fee2e2;
    color: #991b1b;
}
.alert-info {
    background: #e0f2fe;
    color: #075985;
}

/* Admin */
.admin-layout {
    display: flex;
    min-height: 100vh;
    background: #f1f5f9;
}
.admin-sidebar {
    width: 240px;
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    color: #e2e8f0;
    padding: 20px 0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(15,23,42,.15);
}
.admin-sidebar .logo {
    display: block;
    padding: 4px 20px 20px;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    letter-spacing: -0.02em;
}
.admin-sidebar .logo span { color: #60a5fa; }
.admin-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 10px;
    flex: 1;
}
.admin-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 10px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    transition: all .15s;
}
.admin-nav a:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}
.admin-nav a.active {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37,99,235,.35);
}
.admin-nav .nav-ico { font-size: 1.05rem; width: 1.4em; text-align: center; }
.admin-nav .nav-badge {
    margin-left: auto;
    background: #ef4444;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}
.admin-nav .nav-divider {
    height: 1px;
    background: rgba(255,255,255,.08);
    margin: 10px 8px;
}
.admin-nav a.nav-add-btn {
    border: 1px dashed rgba(255,255,255,.2);
    margin-top: 4px;
}
.admin-nav a.nav-add-btn:hover {
    border-color: #60a5fa;
    background: rgba(96,165,250,.12);
}
.admin-content {
    flex: 1;
    padding: 24px;
    overflow-x: auto;
}
.admin-header {
    margin-bottom: 20px;
}
.admin-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
}

.admin-content {
    flex: 1;
    padding: 24px;
    background: var(--bg);
    overflow-x: auto;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.admin-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

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

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 4px;
}

.table {
    width: 100%;
    border-collapse: collapse;
}
.table th,
.table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.table th {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--muted);
}

.settings-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-bottom: 24px;
}

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

/* Responsive */
@media (max-width: 768px) {
    .admin-layout {
        flex-direction: column;
    }
    .admin-sidebar {
        width: 100%;
        padding: 12px 0;
    }
    .admin-nav {
        display: flex;
        overflow-x: auto;
        gap: 0;
    }
    .admin-nav a {
        white-space: nowrap;
        padding: 10px 14px;
    }
    .ad-footer {
        flex-direction: column;
        align-items: stretch;
    }
    .ad-actions {
        justify-content: space-between;
    }
    .header-inner {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 12px;
    }
    .ad-body {
        padding: 16px;
    }
    .btn {
        padding: 9px 14px;
        font-size: 0.9rem;
    }
}
