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

:root {
    --bg-dark: #1F1F1F;
    --bg-card: #282828;
    --bg-input: #333;
    --text-primary: #fff;
    --text-secondary: #aaa;
    --accent-red: #E24C4A;
    --accent-blue: #386BB7;
    --border-color: rgba(255,255,255,.1);
    --border-light: rgba(255,255,255,.05);
    --bg-hover: rgba(255,255,255,.08);
    --bg-hover-strong: rgba(255,255,255,.12);
    --overlay-bg: rgba(0,0,0,.65);
    --gradient: linear-gradient(146deg, var(--accent-red) 0%, var(--accent-blue) 100%);
    --radius: 15px;
    --radius-sm: 10px;
    --content-text: #ddd;
    --pre-bg: #111;
}

[data-theme="light"] {
    --bg-dark: #F0F2F5;
    --bg-card: #FFFFFF;
    --bg-input: #FFFFFF;
    --text-primary: #1A1A2E;
    --text-secondary: #6B7280;
    --border-color: rgba(0,0,0,.12);
    --border-light: rgba(0,0,0,.06);
    --bg-hover: rgba(0,0,0,.05);
    --bg-hover-strong: rgba(0,0,0,.08);
    --overlay-bg: rgba(0,0,0,.45);
    --content-text: #374151;
    --pre-bg: #F3F4F6;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--overlay-bg);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-dialog {
    background: var(--bg-card);
    border-radius: var(--radius);
    width: 90%;
    max-width: 440px;
    border: 1px solid var(--border-color);
    animation: modalIn .2s ease;
}

@keyframes modalIn {
    from { transform: scale(.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px 0;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

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

.modal-body {
    padding: 15px 25px 20px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 0 25px 20px;
}

.modal-footer .btn {
    min-width: 120px;
}

html, body {
    height: 100%;
    font-family: 'Montserrat', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow-x: hidden;
    line-height: 1.6;
}

a { color: var(--accent-red); text-decoration: none; transition: opacity .2s; }
a:hover { opacity: .8; }

.wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

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

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

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

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 18px;
    white-space: nowrap;
}

.logo:hover { opacity: .9; }

.nav {
    display: flex;
    gap: 8px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all .2s;
}

.nav-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    opacity: 1;
}

.nav-link-logout {
    color: var(--accent-red);
}

.user-info { display: flex; align-items: center; gap: 10px; }

.user-name {
    font-size: 14px;
    color: var(--text-secondary);
    padding: 6px 14px;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
}

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

/* Hero */
.hero-section {
    text-align: center;
    padding: 50px 0 30px;
}

.hero-section h1 {
    font-size: 42px;
    font-weight: 800;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    color: var(--text-secondary);
    font-size: 16px;
    margin-top: 10px;
}

/* Search */
.search-box {
    max-width: 600px;
    margin: 0 auto 40px;
}

.search-box form {
    display: flex;
    gap: 10px;
}

.search-input {
    flex: 1;
    padding: 14px 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color .2s;
}

.search-input:focus { border-color: var(--accent-red); }

.search-input::placeholder { color: #666; }

.search-box-page {
    margin-bottom: 20px;
}

.search-results-count {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 14px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 30px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .3s;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: var(--bg-hover-strong);
    color: var(--text-primary);
    text-decoration: none;
}

.btn:hover { opacity: .85; }

.btn-primary {
    background: var(--gradient);
    color: #fff;
    position: relative;
    overflow: hidden;
}

.btn-primary::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 2.86vw;
    height: 300%;
    transition: .3s;
    background: linear-gradient(174deg, rgba(255,255,255,.8) 0%, rgba(255,255,255,.85) 100%);
    animation: blick 3s linear infinite;
    transform: rotate(45deg) translateY(-50%);
}

@keyframes blick {
    0% { left: -80%; }
    100% { left: 160%; }
}

.btn-block { width: 100%; }

/* Categories Grid */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 50px;
}

.category-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 25px;
    transition: all .3s;
    border: 1px solid transparent;
    text-decoration: none;
    color: var(--text-primary);
}

.category-card:hover {
    border-color: var(--accent-red);
    transform: translateY(-3px);
    opacity: 1;
}

.category-icon { margin-bottom: 15px; }

.category-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.category-card p {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
}

.article-count {
    display: inline-block;
    margin-top: 12px;
    font-size: 12px;
    color: var(--accent-red);
    font-weight: 500;
}

/* Page Header with Back Button */
.page-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.page-header h1 {
    font-size: 26px;
    font-weight: 700;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-hover);
    transition: all .2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-back:hover {
    background: var(--bg-hover-strong);
    color: var(--text-primary);
    opacity: 1;
}

/* Section Title */
.section-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-primary);
}

/* Articles List */
.articles-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 40px;
}

.article-item {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 18px 22px;
    transition: all .2s;
    border: 1px solid transparent;
    text-decoration: none;
    color: var(--text-primary);
}

.article-item:hover {
    border-color: rgba(226,76,74,.3);
    opacity: 1;
}

.article-category {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-red);
    font-weight: 500;
}

.article-title {
    font-size: 16px;
    font-weight: 600;
    margin: 5px 0;
}

.article-date {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Breadcrumbs */
.breadcrumbs {
    margin-bottom: 25px;
    font-size: 13px;
    color: var(--text-secondary);
}

.breadcrumbs a { color: var(--text-secondary); }
.breadcrumbs a:hover { color: var(--accent-red); }
.breadcrumbs span { color: var(--text-primary); }

/* Article Full */
.article-full {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 35px;
}

.article-header { margin-bottom: 30px; }

.article-category-badge {
    display: inline-block;
    padding: 4px 14px;
    background: rgba(226,76,74,.15);
    color: var(--accent-red);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 12px;
}

.article-header h1 {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.3;
}

.article-meta {
    display: flex;
    gap: 20px;
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.article-content {
    font-family: 'Manrope', sans-serif;
    font-size: 15px;
    line-height: 1.8;
    color: var(--content-text);
}

.article-content h2,
.article-content h3 {
    color: var(--text-primary);
    margin-top: 25px;
    margin-bottom: 12px;
    font-weight: 600;
}

.article-content h2 { font-size: 22px; }
.article-content h3 { font-size: 18px; }

.article-content p { margin-bottom: 15px; }

.article-content ul,
.article-content ol { margin: 0 0 15px 20px; }

.article-content li { margin-bottom: 5px; }

.article-content code {
    background: rgba(255,255,255,.08);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 14px;
}

.article-content pre {
    background: var(--pre-bg);
    padding: 20px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin-bottom: 15px;
}

.article-content pre code {
    background: none;
    padding: 0;
}

.article-content img {
    max-width: 100%;
    border-radius: var(--radius-sm);
    margin: 15px 0;
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.login-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--overlay-bg);
    z-index: 1;
}

.login-container {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-box {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 40px 35px;
    border: 1px solid var(--border-color);
}

.login-logo {
    text-align: center;
    margin-bottom: 15px;
}

.login-box h1 {
    text-align: center;
    font-size: 24px;
    font-weight: 700;
}

.login-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 25px;
}

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color .2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent-red);
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.form-group select {
    cursor: pointer;
}

.checkbox-group { margin-top: -5px; }

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 1px;
    accent-color: var(--accent-red);
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-text {
    line-height: 1.4;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-size: 13px;
}

.alert-error {
    background: rgba(226,76,74,.15);
    border: 1px solid rgba(226,76,74,.3);
    color: var(--accent-red);
}

.alert-success {
    background: rgba(56,107,183,.15);
    border: 1px solid rgba(56,107,183,.3);
    color: #6a9fd8;
}

/* Admin */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

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

.admin-header-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.admin-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 25px;
    position: relative;
    transition: all .3s;
    border: 1px solid transparent;
    text-decoration: none;
    color: var(--text-primary);
}

.admin-card:hover {
    border-color: var(--accent-red);
    transform: translateY(-2px);
    opacity: 1;
}

.admin-card h3 { font-size: 18px; font-weight: 600; margin-bottom: 6px; }

.admin-card p { color: var(--text-secondary); font-size: 13px; }

.admin-count {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--gradient);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

/* Table */
.table-wrap {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
}

.admin-table th {
    background: var(--bg-hover);
    padding: 14px 16px;
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    font-weight: 500;
}

.admin-table td {
    padding: 12px 16px;
    font-size: 14px;
    border-top: 1px solid var(--border-light);
}

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

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

.btn-small {
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    background: var(--bg-hover);
    color: var(--text-primary);
    text-decoration: none;
    transition: background .2s;
    border: none;
    cursor: pointer;
    display: inline-block;
}

.btn-small:hover { background: var(--bg-hover-strong); opacity: 1; }

.btn-small-danger { background: rgba(226,76,74,.2); color: var(--accent-red); }
.btn-small-danger:hover { background: rgba(226,76,74,.35); }

.btn-small-success { background: rgba(56,107,183,.2); color: #6a9fd8; }
.btn-small-success:hover { background: rgba(56,107,183,.35); }

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.badge-admin { background: rgba(226,76,74,.2); color: var(--accent-red); }
.badge-user { background: var(--bg-hover); color: var(--text-secondary); }
.badge-active { background: rgba(56,107,183,.2); color: #6a9fd8; }
.badge-blocked { background: rgba(226,76,74,.2); color: var(--accent-red); }

/* Admin Form */
.admin-form {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 30px;
    max-width: 700px;
}

.admin-form-inline {
    margin-bottom: 20px;
}

.form-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-row input,
.form-row select {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    outline: none;
    min-width: 150px;
    flex: 1;
}

.form-row input:focus { border-color: var(--accent-red); }

/* Settings */
.settings-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 25px;
    margin-bottom: 20px;
}

.settings-section h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
}

/* Footer */
.footer {
    background: var(--bg-card);
    padding: 20px 0;
    text-align: center;
    border-top: 1px solid var(--border-light);
}

.footer p {
    color: var(--text-secondary);
    font-size: 13px;
}

/* Empty State */
.empty-message {
    color: var(--text-secondary);
    font-size: 14px;
    padding: 30px;
    text-align: center;
}

/* Error Page */
.error-page {
    text-align: center;
    padding: 60px 20px;
}

.error-page h1 {
    font-size: 80px;
    font-weight: 800;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.error-page p {
    color: var(--text-secondary);
    margin-bottom: 25px;
    font-size: 16px;
}

/* Editor textarea */
.editor {
    font-family: 'Manrope', monospace;
    font-size: 14px;
    line-height: 1.7;
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all .3s;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}

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

html { transition: background .3s, color .3s; }
html, body { transition: background .3s; }

/* Responsive */
@media (max-width: 768px) {
    .header-inner { flex-wrap: wrap; }
    .nav { order: 3; width: 100%; justify-content: center; }
    .user-info { display: none; }
    .hero-section h1 { font-size: 28px; }
    .categories-grid { grid-template-columns: 1fr; }
    .article-full { padding: 20px; }
    .article-header h1 { font-size: 22px; }
    .form-row { flex-direction: column; }
    .form-row input { min-width: auto; }
    .admin-header { flex-direction: column; align-items: flex-start; }
    .admin-header-buttons { flex-wrap: wrap; }
}

@media (max-width: 480px) {
    .container { padding: 0 15px; }
    .login-box { padding: 25px 20px; }
    .admin-form { padding: 20px; }
}
