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

:root {
    --bg-primary: #212121;
    --bg-secondary: #171717;
    --bg-tertiary: #2f2f2f;
    --text-primary: #ececec;
    --text-secondary: #b4b4b4;
    --text-muted: #808080;
    --accent: #d1d5db;
    --accent-hover: #e5e7eb;
    --border: #2e2e2e;
    --ai-bubble: #1e1e1e;
    --danger: #ef4444;
    --success: #22c55e;
    --sidebar-width: 260px;
    --radius: 12px;
    --radius-sm: 8px;
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f3f4f6;
    --text-primary: #1a1a1a;
    --text-secondary: #555555;
    --text-muted: #999999;
    --accent: #6b7280;
    --accent-hover: #4b5563;
    --border: #d1d5db;
    --ai-bubble: #f3f4f6;
    --danger: #dc2626;
    --success: #16a34a;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

/* === AUTH PAGES === */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: radial-gradient(ellipse at top, #1a1a2e 0%, #111 100%);
}

.auth-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.auth-card h1 {
    font-size: 30px;
    font-weight: 700;
    text-align: center;
    color: var(--accent);
    margin-bottom: 4px;
}

.auth-card h2 {
    font-size: 18px;
    font-weight: 400;
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-card input {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.auth-card input:focus {
    border-color: var(--accent);
}

.auth-card button {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.auth-card button:hover {
    background: var(--accent-hover);
}

.auth-link {
    text-align: center;
    margin-top: 20px;
    font-size: 16px;
    color: var(--text-secondary);
}

.auth-link a {
    color: var(--accent);
    text-decoration: none;
}

.auth-link a:hover {
    text-decoration: underline;
}

.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    text-align: center;
}

/* === CHAT LAYOUT === */
.chat-layout {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100%;
}

/* === SIDEBAR === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;
    flex: 1;
    color: var(--text-muted);
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
    line-height: 1;
}

.theme-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-body {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
}

.sidebar-body::-webkit-scrollbar {
    width: 4px;
}

.sidebar-body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.new-chat-btn {
    width: 100%;
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
    margin-bottom: 8px;
}

.new-chat-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
}

.conv-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.conv-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 15px;
    transition: background 0.15s;
    cursor: pointer;
}

.conv-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.conv-item.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-left: 2px solid var(--accent);
}

.conv-item .conv-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.conv-item .conv-date {
    font-size: 13px;
    color: var(--text-muted);
}

.conv-item {
    position: relative;
}

.conv-delete {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
    line-height: 1;
}

.conv-item:hover .conv-delete {
    opacity: 1;
}

.conv-delete:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.15);
}

.sidebar-user {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
}

.sidebar-user .avatar {
    width: 32px;
    height: 32px;
    background: var(--text-muted);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-user .username {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
}

.sidebar-user .logout-btn {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
}

.sidebar-user .logout-btn:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* === MAIN CHAT === */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.chat-header {
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.chat-header .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    flex-shrink: 0;
}

.chat-header .status-text {
    font-size: 15px;
    color: var(--text-muted);
}

.chat-header h3 {
    font-size: 17px;
    font-weight: 600;
}

/* === MESSAGES AREA === */
.messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scroll-behavior: smooth;
}

.messages::-webkit-scrollbar {
    width: 6px;
}

.messages::-webkit-scrollbar-track {
    background: transparent;
}

.messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.welcome-message {
    text-align: center;
    margin: auto;
    max-width: 480px;
    padding: 40px 20px;
}

.welcome-message .welcome-icon {
    font-size: 50px;
    margin-bottom: 16px;
}

.welcome-message h2 {
    font-size: 26px;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.welcome-message p {
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1.6;
}

.welcome-message .suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 24px;
}

.welcome-message .suggestion-chip {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 15px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.welcome-message .suggestion-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* === MESSAGE BUBBLES === */
.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.assistant {
    align-self: flex-start;
}

.message .avatar-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 4px;
}

.message.user .avatar-icon,
.message.assistant .avatar-icon,
[data-theme="light"] .message.user .avatar-icon,
[data-theme="light"] .message.assistant .avatar-icon {
    background: #e5e7eb;
}

.message .msg-body {
    position: relative;
}

.message .bubble {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 16px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message.user .bubble {
    color: var(--text-primary);
    border-bottom-right-radius: 4px;
}

.message.assistant .bubble {
    background: var(--ai-bubble);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.msg-actions {
    display: none;
    gap: 2px;
    margin-top: 2px;
}

.message:hover .msg-actions {
    display: flex;
}

.msg-action {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 15px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
    line-height: 1;
}

.msg-action:hover {
    background: var(--bg-tertiary);
}

.msg-action.edit-btn:hover {
    color: var(--accent);
}

.msg-action.delete-btn:hover {
    color: var(--danger);
}

.edit-textarea {
    background: var(--bg-primary);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    line-height: 1.6;
    resize: vertical;
    min-height: 60px;
    width: 100%;
    outline: none;
}

.message.user .edit-textarea {
    background: rgba(147, 51, 234, 0.15);
    border-color: var(--accent);
    color: #fff;
}

.message .bubble p {
    margin-bottom: 8px;
}

.message .bubble p:last-child {
    margin-bottom: 0;
}

.message .bubble code {
    background: rgba(0,0,0,0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 15px;
    font-family: 'Courier New', monospace;
}

.message .bubble pre {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    overflow-x: auto;
    margin: 8px 0;
}

.message .bubble pre code {
    background: none;
    padding: 0;
    border-radius: 0;
}

.message .time {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
    padding: 0 4px;
}

.message.user .time {
    text-align: right;
}

.typing-indicator {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 12px 0;
}

.typing-indicator .avatar-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 8px 16px;
    background: var(--ai-bubble);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    border-bottom-left-radius: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* === INPUT AREA === */
.input-area {
    padding: 16px 24px 24px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 10;
    position: relative;
}

.input-wrapper {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    gap: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    transition: border-color 0.2s;
}

[data-theme="light"] .input-wrapper {
    background: #f3f4f6;
}

.input-wrapper:focus-within {
    border-color: var(--accent);
}

.input-wrapper textarea {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    outline: none;
    resize: none;
    max-height: 150px;
    line-height: 1.5;
}

.input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.input-wrapper .send-btn {
    background: var(--text-muted);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    align-self: flex-end;
    transition: background 0.2s;
}

.input-wrapper .send-btn:hover {
    background: var(--accent-hover);
}

.input-wrapper .send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.attach-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 8px 6px 8px 10px;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
    align-self: flex-end;
    line-height: 1;
}

.attach-btn:hover {
    color: var(--accent);
    background: var(--bg-tertiary);
}

.file-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    margin-top: 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    color: var(--text-secondary);
    max-width: 400px;
}

.file-preview-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-preview-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

.file-preview-remove:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.15);
}

/* === FILE ATTACHMENT IN MESSAGES === */
.file-attachment {
    margin-top: 8px;
}

.uploaded-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: block;
    transition: opacity 0.2s;
}

.uploaded-image:hover {
    opacity: 0.9;
}

.file-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    transition: border-color 0.15s, background 0.15s;
}

.file-link:hover {
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

.file-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.file-link-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px;
}

.file-link-size {
    font-size: 13px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.message.user .file-link {
    background: rgba(0,0,0,0.2);
    border-color: rgba(255,255,255,0.15);
}

.message.user .file-link:hover {
    border-color: rgba(255,255,255,0.4);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        width: 100%;
        height: 75vh;
        max-height: 480px;
        z-index: 100;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        border-right: none;
        border-top: 1px solid var(--border);
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 30px rgba(0,0,0,0.4);
    }

    .sidebar.open {
        transform: translateY(0);
    }

    .sidebar::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: var(--text-muted);
        border-radius: 2px;
        margin: 8px auto 0;
        opacity: 0.5;
    }

    .sidebar-header {
        padding: 8px 16px 4px;
    }

    .sidebar-body {
        padding: 8px 12px 4px;
    }

    .conv-item {
        padding: 12px 14px;
        font-size: 16px;
    }

    .conv-item .conv-title {
        font-size: 16px;
    }

    .new-chat-btn {
        padding: 12px;
        font-size: 17px;
    }

    .conv-delete {
        padding: 8px 10px;
        font-size: 16px;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 99;
    }

    .sidebar-overlay.open {
        display: block;
    }

    .message {
        max-width: 95%;
    }

    .messages {
        padding: 12px;
    }

    .input-area {
        padding: 10px 12px 14px;
    }

    .chat-header {
        padding: 10px 14px;
    }

    .chat-header h3 {
        font-size: 16px;
    }

    .auth-card {
        padding: 28px 24px;
    }

    .welcome-message .suggestions {
        flex-direction: column;
        align-items: stretch;
    }

    .welcome-message h2 {
        font-size: 22px;
    }

    .file-preview {
        max-width: 100%;
        font-size: 14px;
    }

    .file-link {
        font-size: 14px;
        padding: 6px 10px;
    }

    .uploaded-image {
        max-height: 200px;
    }

    .msg-actions {
        opacity: 1;
    }

    .conv-delete {
        opacity: 1;
    }
}

@media (max-width: 480px) {
    .auth-container {
        padding: 12px;
    }

    .auth-card {
        padding: 20px 14px;
        border-radius: 10px;
    }

    .auth-card h1 {
        font-size: 22px;
    }

    .auth-card h2 {
        font-size: 15px;
    }

    .auth-card input {
        padding: 10px 12px;
        font-size: 16px;
    }

    .auth-card button {
        padding: 10px;
        font-size: 16px;
    }

    .auth-card form {
        gap: 10px;
    }

    .chat-header {
        padding: 8px 12px;
        gap: 8px;
    }

    .chat-header .status-dot {
        display: none;
    }

    .message {
        max-width: 100%;
        gap: 8px;
    }

    .message .bubble {
        font-size: 15px;
        padding: 10px 14px;
    }

    .message .avatar-icon {
        width: 26px;
        height: 26px;
        font-size: 14px;
    }

    .input-wrapper textarea {
        font-size: 15px;
        padding: 8px 10px;
    }

    .input-wrapper {
        gap: 4px;
    }

    .attach-btn {
        padding: 6px 4px 6px 8px;
        font-size: 18px;
    }

    .input-wrapper .send-btn {
        width: 36px;
        height: 36px;
    }

    .messages {
        padding: 8px;
        gap: 4px;
    }

    .input-area {
        padding: 8px 10px 12px;
    }

    .typing-dots {
        padding: 6px 12px;
    }

    .welcome-message {
        padding: 20px 12px;
    }

    .welcome-message h2 {
        font-size: 20px;
    }

    .welcome-message p {
        font-size: 15px;
    }

    .suggestion-chip {
        font-size: 14px !important;
        padding: 6px 12px !important;
    }

    .file-preview {
        font-size: 13px;
        padding: 4px 10px;
        flex-wrap: wrap;
    }
}

/* === MENU TOGGLE (mobile) === */
.menu-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 22px;
    cursor: pointer;
    padding: 4px;
}

.header-theme-toggle {
    display: none;
    margin-left: auto;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: flex !important;
    }

    .header-theme-toggle {
        display: inline-flex;
    }
}

@media (min-width: 769px) {
    .menu-toggle {
        display: none;
    }
}

/* === SCROLLBAR (global) === */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* === ADMIN STYLES === */
.admin-layout {
    display: flex;
    height: 100vh;
}

.admin-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.admin-sidebar-badge {
    font-size: 12px;
    background: var(--accent);
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.admin-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.admin-nav-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 16px;
    transition: background 0.15s, color 0.15s;
}

.admin-nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.admin-nav-item.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-left: 2px solid var(--accent);
}

.admin-main {
    flex: 1;
    padding: 28px 32px;
    overflow-y: auto;
    min-width: 0;
}

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

.admin-header h1 {
    font-size: 24px;
    font-weight: 700;
}

.admin-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.admin-btn:hover {
    background: var(--accent-hover);
}

.admin-btn-sm {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.admin-btn-sm:hover {
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

.admin-btn-danger:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-value {
    font-size: 30px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 15px;
    color: var(--text-muted);
}

.admin-table-wrap {
    overflow-x: auto;
}

.admin-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 17px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 16px;
}

.admin-table th {
    text-align: left;
    padding: 10px 14px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.admin-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.admin-table tbody tr:hover {
    background: var(--bg-tertiary);
}

.actions-cell {
    display: flex;
    gap: 6px;
}

.badge {
    font-size: 13px;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 600;
}

.badge-admin {
    background: rgba(147, 51, 234, 0.15);
    color: var(--accent);
}

.badge-user {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    width: 100%;
    max-width: 460px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

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

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.modal-content form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-content input[type="text"],
.modal-content input[type="email"],
.modal-content input[type="password"] {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.modal-content input:focus {
    border-color: var(--accent);
}

.admin-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    color: var(--text-secondary);
    cursor: pointer;
}

.admin-checkbox input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}

.admin-flash {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    margin-bottom: 16px;
}

.admin-flash.success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--success);
}

.admin-flash.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

@media (max-width: 900px) {
    .admin-layout {
        flex-direction: column;
    }
    .admin-sidebar {
        width: 100%;
        flex-direction: row;
        align-items: center;
        padding: 0 16px;
        border-right: none;
        border-bottom: 1px solid var(--border);
        height: auto;
        flex-wrap: wrap;
    }
    .admin-sidebar .sidebar-header {
        border-bottom: none;
        padding: 10px 0;
    }
    .admin-sidebar .sidebar-body {
        width: 100%;
        padding: 0 0 10px;
    }
    .admin-sidebar .sidebar-body .admin-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
        padding-top: 10px;
    }
    .admin-sidebar .sidebar-body .admin-nav-item {
        flex: 1;
        min-width: 120px;
        text-align: center;
    }
    .admin-sidebar .sidebar-user {
        border-top: none;
        margin-left: 0;
        padding: 10px 0;
    }
    .admin-main {
        padding: 20px 16px;
    }
    .admin-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .admin-header {
        flex-direction: column;
        align-items: stretch;
    }
    .admin-header h1 {
        font-size: 20px;
    }
    .admin-table th,
    .admin-table td {
        padding: 8px 10px;
        font-size: 15px;
    }
    .actions-cell {
        flex-wrap: wrap;
    }
    .modal-content {
        padding: 24px 20px;
        margin: 10px;
    }
    .admin-sidebar-badge {
        display: none;
    }
}

@media (max-width: 480px) {
    .admin-stats {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .stat-card {
        padding: 14px;
    }
    .stat-value {
        font-size: 24px;
    }
    .admin-table {
        font-size: 14px;
    }
    .admin-table th,
    .admin-table td {
        padding: 6px 8px;
    }
    .admin-btn {
        width: 100%;
        text-align: center;
    }

    .modal {
        padding: 8px;
        align-items: flex-end;
    }

    .modal-content {
        padding: 20px 16px;
        border-radius: 12px 12px 0 0;
        max-width: 100%;
        margin: 0;
    }

    .modal-header h2 {
        font-size: 18px;
    }

    .modal-content form {
        gap: 10px;
    }

    .modal-content input[type="text"],
    .modal-content input[type="email"],
    .modal-content input[type="password"],
    .modal-content input[type="url"] {
        padding: 10px 12px;
        font-size: 16px;
    }

    .admin-table {
        font-size: 13px;
    }

    .admin-table th,
    .admin-table td {
        padding: 6px 6px;
        font-size: 13px;
    }

}
