* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #7c3aed;
    --primary-dark: #6d28d9;
    --secondary: #14b8a6;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --gradient: linear-gradient(135deg, #7c3aed 0%, #14b8a6 100%);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.site-header {
    background: white;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 20px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--gradient);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
}

.main-nav {
    display: flex;
    gap: 24px;
}

.main-nav a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 14px;
    transition: color 0.2s;
}

.main-nav a:hover, .main-nav a.active {
    color: var(--primary);
}

.user-actions {
    display: flex;
    gap: 8px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--gradient);
    color: white;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    background: var(--bg);
    color: var(--text);
}

.btn-outline {
    background: white;
    border: 2px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Hero */
.hero {
    background: var(--gradient);
    color: white;
    padding: 80px 0;
    text-align: center;
}

.hero h1 {
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 16px;
}

.hero p {
    font-size: 18px;
    opacity: 0.9;
    margin-bottom: 32px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.hero-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.hero .btn-primary {
    background: white;
    color: var(--primary);
}

.hero .btn-outline {
    background: transparent;
    border-color: white;
    color: white;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 24px;
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: 0 10px 40px -10px rgba(0,0,0,0.1);
}

.card-header {
    margin-bottom: 16px;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.card-subtitle {
    color: var(--text-muted);
    font-size: 14px;
}

/* Grid */
.grid {
    display: grid;
    gap: 24px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .main-nav { display: none; }
}

/* Section */
.section {
    padding: 60px 0;
}

.section-title {
    font-size: 32px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 40px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

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

.form-input, .form-textarea, .form-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Badge */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
}

.badge-primary {
    background: rgba(124, 58, 237, 0.1);
    color: var(--primary);
}

.badge-success {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.badge-secondary {
    background: var(--bg);
    color: var(--text-muted);
}

/* Auth Pages */
.auth-page {
    min-height: calc(100vh - 64px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.auth-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.1);
    max-width: 400px;
    width: 100%;
    padding: 40px;
}

.auth-card .logo-icon {
    width: 48px;
    height: 48px;
    font-size: 24px;
    margin: 0 auto 20px;
}

.auth-card h1 {
    text-align: center;
    font-size: 24px;
    margin-bottom: 8px;
}

.auth-card .subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 30px;
}

/* Messages */
.messages-mobile-toggle {
    display: none;
}

.messages-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    height: calc(100vh - 180px);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: white;
}

.contacts-list {
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.contact-item {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.contact-item:hover, .contact-item.active {
    background: var(--bg);
}

.chat-area {
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

@media (max-width: 640px) {
    .messages-mobile-toggle {
        display: flex;
        gap: 8px;
        margin-bottom: 12px;
    }

    .messages-container {
        grid-template-columns: 1fr;
        height: auto;
    }

    .messages-container[data-view="contacts"] .chat-area {
        display: none;
    }

    .messages-container[data-view="chat"] .contacts-list {
        display: none;
    }

    .contacts-list {
        max-height: 220px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .chat-area {
        min-height: 60vh;
    }

    .message {
        max-width: 85%;
    }
}

.message {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 16px;
    margin-bottom: 12px;
}

.message.sent {
    background: var(--gradient);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.message.received {
    background: var(--bg);
    border-bottom-left-radius: 4px;
}

.chat-input {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
}

.chat-input input,
.chat-input select {
    flex: 1;
}

.recipient-picker {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 220px;
    max-width: 280px;
}

.recipient-list {
    max-height: 160px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    background: white;
}

.recipient-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    padding: 6px 4px;
    cursor: pointer;
}

.recipient-item input {
    width: 16px;
    height: 16px;
}

.footer-message-link {
    color: #dc2626;
    font-weight: 600;
}

.footer-message-link:hover {
    color: #b91c1c;
}

@media (max-width: 768px) {
    .chat-input {
        flex-direction: column;
    }

    .chat-input input,
    .chat-input select,
    .recipient-picker,
    .chat-input button {
        width: 100%;
    }
}

/* Footer */
.site-footer {
    background: white;
    border-top: 1px solid var(--border);
    padding: 60px 0 30px;
    margin-top: 60px;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 40px;
}

@media (max-width: 768px) {
    .footer-grid { grid-template-columns: 1fr 1fr; }
}

.footer-brand p {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 16px;
}

.footer-links h4 {
    font-weight: 600;
    margin-bottom: 16px;
}

.footer-links ul {
    list-style: none;
}

.footer-links li {
    margin-bottom: 8px;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary);
}

.footer-social h4 {
    font-weight: 600;
    margin-bottom: 16px;
}

.social-icons {
    display: flex;
    gap: 12px;
}

.social-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
}

.social-icon:hover {
    background: var(--primary);
    color: white;
}

.footer-bottom {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* Alert */
.alert {
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
}

.alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #22c55e;
}

/* Table */
.table {
    width: 100%;
    border-collapse: collapse;
}

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

.table th {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* Admin */
.admin-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}

.admin-tab {
    padding: 12px 20px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.admin-tab:hover, .admin-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Utilities */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
