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

body {
    margin: 0;
    font-family: Inter, Segoe UI, Arial, sans-serif;
    background: #f4f6fb;
    color: #1f2937;
}

a {
    color: #2563eb;
    text-decoration: none;
}

.layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: #111827;
    color: #fff;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.brand a {
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
}

.brand span {
    display: block;
    margin-top: 4px;
    color: #9ca3af;
    font-size: 0.85rem;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar nav a {
    color: #d1d5db;
    padding: 10px 12px;
    border-radius: 8px;
}

.sidebar nav a.active,
.sidebar nav a:hover {
    background: #1f2937;
    color: #fff;
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid #374151;
    padding-top: 16px;
    font-size: 0.9rem;
}

.content {
    padding: 32px;
}

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

.page-header h1 {
    margin: 0;
    font-size: 1.8rem;
}

.card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    margin-bottom: 20px;
}

.grid {
    display: grid;
    gap: 16px;
}

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

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

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

.btn {
    display: inline-block;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-weight: 600;
    cursor: pointer;
    background: #2563eb;
    color: #fff;
}

.btn-secondary {
    background: #e5e7eb;
    color: #111827;
}

.btn-danger {
    background: #dc2626;
}

.btn-small {
    padding: 6px 10px;
    font-size: 0.875rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font: inherit;
}

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

.form-help {
    margin-top: 6px;
    color: #6b7280;
    font-size: 0.875rem;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.alert.success {
    background: #dcfce7;
    color: #166534;
}

.alert.error {
    background: #fee2e2;
    color: #991b1b;
}

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

.table th,
.table td {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge.published {
    background: #dcfce7;
    color: #166534;
}

.badge.admin {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge.editor,
.badge.draft {
    background: #fef3c7;
    color: #92400e;
}

.template-card {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    background: #fff;
}

.template-card h3 {
    margin: 0 0 8px;
    font-size: 1rem;
}

.template-card p {
    margin: 0 0 12px;
    color: #6b7280;
    font-size: 0.875rem;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.tabs a {
    padding: 10px 14px;
    border-radius: 8px;
    background: #e5e7eb;
    color: #111827;
    font-weight: 600;
}

.tabs a.active {
    background: #2563eb;
    color: #fff;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 420px;
}

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

.quill-editor-wrap {
    background: #fff;
    border-radius: 8px;
}

.quill-editor {
    min-height: 280px;
}

.ql-toolbar.ql-snow {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.element-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 16px;
}

.element-item {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 14px;
    background: #f9fafb;
}

.element-label {
    margin: 0 0 10px;
    font-weight: 600;
    color: #374151;
}

details summary {
    cursor: pointer;
    font-size: 1.05rem;
    margin-bottom: 8px;
}

details summary::-webkit-details-marker {
    margin-right: 8px;
}

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

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 10;
    }

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

.sticky-search {
    position: sticky;
    top: 0;
    z-index: 5;
}

.element-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 16px;
}

.element-item {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 14px;
    background: #f9fafb;
}

.element-label {
    margin: 0 0 10px;
    font-weight: 600;
    color: #111827;
}

.element-type {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #e5e7eb;
    color: #374151;
    font-size: 0.75rem;
    font-weight: 500;
}

details summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

details summary::-webkit-details-marker {
    display: none;
}

.save-bar {
    position: sticky;
    bottom: 0;
    background: #f4f6fb;
    padding: 16px 0;
    margin-top: 8px;
}

.seo-panel {
    margin-bottom: 16px;
}

.seo-panel summary {
    cursor: pointer;
    font-size: 1.05rem;
    margin-bottom: 12px;
}

.seo-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

.seo-section h3 {
    margin: 0 0 12px;
    font-size: 0.95rem;
}

.seo-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.seo-section-header h3 {
    margin: 0;
}

.head-tags-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.head-tag-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: start;
}

.head-tag-row textarea {
    font-family: Consolas, Monaco, 'Courier New', monospace;
    font-size: 0.85rem;
}

.image-element-fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.image-custom-attrs {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px dashed #e5e7eb;
}

.element-type.image {
    background: #eff6ff;
    color: #1d4ed8;
}

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