:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --warning: #f59e0b;
    --sidebar-width: 240px;
    --bg: #f3f4f6;
    --card-bg: #ffffff;
    --text: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --border-radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: #1f2937;
    color: #d1d5db;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 20px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid #374151;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand .icon { font-size: 22px; }

.sidebar-nav { list-style: none; padding: 12px 0; }

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: #d1d5db;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
    background: #374151;
    color: #fff;
}

.sidebar-nav li a.active {
    background: #374151;
    color: #fff;
    border-left-color: var(--primary);
}

.sidebar-nav li a .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.sidebar-user {
    padding: 16px 20px;
    border-top: 1px solid #374151;
    font-size: 13px;
}

.sidebar-user .name { color: #fff; font-weight: 600; }
.sidebar-user .role { color: #9ca3af; }

.main {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 24px;
}

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

.topbar h1 {
    font-size: 22px;
    font-weight: 700;
}

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

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

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.card-body { padding: 20px; }

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

.stat-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 20px;
    transition: box-shadow 0.2s;
}

.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 12px;
}

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

.stat-card .stat-label {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
}

.stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-icon.green { background: #d1fae5; color: #059669; }
.stat-icon.orange { background: #fed7aa; color: #ea580c; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    text-decoration: none;
}

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

.btn-secondary { background: #fff; color: #374151; border-color: var(--border); }
.btn-secondary:hover { background: #f9fafb; text-decoration: none; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); text-decoration: none; }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-icon:hover { background: #f3f4f6; }

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

table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    background: #f9fafb;
}

table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table tr:last-child td { border-bottom: none; }
table tr:hover { background: #f9fafb; }

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

.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-orange { background: #fed7aa; color: #9a3412; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-gray { background: #f3f4f6; color: #374151; }
.badge-yellow { background: #fef3c7; color: #92400e; }

.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }

.flash {
    padding: 12px 16px;
    border-radius: var(--border-radius);
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
}

.flash-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.flash-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.flash-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

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

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

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: #fff;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

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

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.form-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.link-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.link-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: box-shadow 0.2s, transform 0.15s;
    text-decoration: none;
    color: var(--text);
}

.link-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    text-decoration: none;
}

.link-card .link-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.link-card .link-title { font-weight: 600; font-size: 15px; }
.link-card .link-desc { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.activity-list { list-style: none; }

.activity-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.activity-list li:last-child { border-bottom: none; }

.activity-label { font-size: 13px; }
.activity-time { color: var(--text-muted); font-size: 12px; }

.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

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

.modal {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}

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

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

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

.modal-body { padding: 20px; }
.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.section-tree { list-style: none; }

.section-tree .section-item {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 6px;
    background: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-tree .section-children {
    list-style: none;
    margin-left: 24px;
    margin-top: 6px;
    padding-left: 12px;
    border-left: 2px solid var(--border);
}

.drag-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 16px;
}

.drag-handle:active { cursor: grabbing; }

.section-name { flex: 1; font-weight: 500; }

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

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

.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }

.template-editor {
    width: 100%;
    min-height: 400px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    resize: vertical;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

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

.login-box .form-group { margin-bottom: 18px; }
.login-box .btn { display: flex; width: 100%; margin-top: 8px; justify-content: center; }

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

.preset-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    background: #fef3c7;
    color: #92400e;
    font-size: 11px;
    font-weight: 600;
    margin-left: 6px;
}

@media (max-width: 768px) {
    .sidebar { width: 64px; }
    .sidebar-brand span,
    .sidebar-nav li a span:not(.nav-icon),
    .sidebar-user .user-info { display: none; }
    .sidebar-brand { justify-content: center; }
    .sidebar-nav li a { justify-content: center; padding: 12px; }
    .main { margin-left: 64px; padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ==================================================================
 * EasyMDE editor integration (black & white print-style)
 * ================================================================== */

.EasyMDEContainer { width: 100%; }

.EasyMDEContainer .CodeMirror {
    height: 560px !important;
    min-height: 560px !important;
    width: 100% !important;
    padding: 14px;
    border: 1px solid #000;
    border-radius: 4px;
    font-size: 15px;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #fff;
    color: #000;
    line-height: 1.6;
}

.EasyMDEContainer .CodeMirror-focused { border-color: #000; box-shadow: 0 0 0 2px rgba(0,0,0,0.2); }

.EasyMDEContainer .editor-toolbar {
    background: #f9fafb;
    border: 1px solid #000;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    padding: 8px 6px;
}

.EasyMDEContainer .editor-toolbar button { color: #111; border-radius: 3px; }

.EasyMDEContainer .editor-toolbar button.active,
.EasyMDEContainer .editor-toolbar button:hover {
    background: #e5e7eb;
    border-color: #000;
}

.EasyMDEContainer .editor-statusbar {
    border: 1px solid #000;
    border-top: none;
    border-radius: 0 0 4px 4px;
    color: #374151;
    background: #f9fafb;
}

.EasyMDEContainer .editor-preview {
    background: #fff;
    color: #000;
    padding: 18px 22px;
    border: 1px solid #000;
    border-left: none;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.7;
}

.editor-preview blockquote,
.md-render blockquote {
    border: 2px solid #000 !important;
    background: #fff;
    padding: 14px 16px 12px;
    margin: 12px 0;
    position: relative;
    padding-top: 32px;
    color: #000;
}

.editor-preview blockquote::before,
.md-render blockquote::before {
    content: "Quote:";
    position: absolute;
    top: 6px; left: 10px;
    font-size: 12px; font-weight: 700;
    background: #fff;
    border: 1px solid #000;
    padding: 2px 8px;
    border-radius: 3px;
    letter-spacing: 0.5px;
}

.editor-preview blockquote p,
.md-render blockquote p { margin: 0; }

.editor-preview pre,
.md-render pre {
    border: 2px solid #000 !important;
    background: #fff;
    color: #000;
    padding: 28px 14px 12px;
    margin: 12px 0;
    position: relative;
    border-radius: 4px;
    overflow-x: auto;
    font-family: "Courier New", Consolas, monospace;
    font-size: 13px;
}

.editor-preview pre::before,
.md-render pre::before {
    content: "Code:";
    position: absolute;
    top: 6px; left: 10px;
    font-size: 12px; font-weight: 700;
    background: #fff;
    border: 1px solid #000;
    padding: 2px 8px;
    border-radius: 3px;
    letter-spacing: 0.5px;
}

.editor-preview code,
.md-render code {
    background: #f3f4f6;
    border: 1px solid #000;
    padding: 1px 4px;
    border-radius: 2px;
    font-family: "Courier New", Consolas, monospace;
    color: #000;
}

.editor-preview pre code,
.md-render pre code { background: transparent; border: none; padding: 0; }

.editor-preview table,
.md-render table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
    border: 2px solid #000;
}

.editor-preview table th, .editor-preview table td,
.md-render table th, .md-render table td {
    border: 1px solid #000;
    padding: 6px 10px;
    text-align: left;
    color: #000;
}

.editor-preview table th, .md-render table th { background: #f3f4f6; font-weight: 700; }

.editor-preview ul, .editor-preview ol,
.md-render ul, .md-render ol { margin: 8px 0 8px 22px; color: #000; }

.editor-preview li, .md-render li { margin: 2px 0; }

.editor-preview h1, .editor-preview h2, .editor-preview h3,
.md-render h1, .md-render h2, .md-render h3 {
    border-bottom: 2px solid #000;
    padding-bottom: 4px;
    margin: 18px 0 10px;
    color: #000;
    font-weight: 700;
}

.editor-preview h1, .md-render h1 { font-size: 24px; }
.editor-preview h2, .md-render h2 { font-size: 20px; }
.editor-preview h3, .md-render h3 { font-size: 17px; }

.md-render img.img-logo { width: 30%; max-width: 220px; }
.md-render img.img-cover { width: 60%; max-width: 480px; }
.md-render img.img-panel { width: 100%; max-width: 720px; }
.md-render img.img-system { width: 100%; max-width: 720px; }
.md-render img.img-default { max-width: 100%; }

.editor-preview img { max-width: 100%; }

.EasyMDEContainer.side-by-side .CodeMirror,
.EasyMDEContainer.side-by-side .editor-preview-side {
    width: 50% !important;
    float: left;
    box-sizing: border-box;
}

.EasyMDEContainer.side-by-side::after { content: ""; display: table; clear: both; }

.image-preview-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-preview-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.8); }

.image-preview-content { position: relative; max-width: 90vw; max-height: 90vh; }

.image-preview-content img {
    max-width: 90vw;
    max-height: 90vh;
    border: 2px solid #fff;
    background: #fff;
}

.image-preview-close {
    position: absolute;
    top: -32px; right: 0;
    background: #fff;
    color: #000;
    border: 1px solid #000;
    border-radius: 4px;
    width: 28px; height: 28px;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
}

.md-render {
    background: #fff;
    color: #000;
    padding: 16px 20px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.7;
}

.md-render p { margin: 8px 0; color: #111; }
.md-render a { color: #1d4ed8; }
.md-render hr { border: none; border-top: 2px solid #000; margin: 16px 0; }
.md-render strong { font-weight: 700; }

/* =================================== */
/* Dashboard / User pages              */
/* =================================== */

/* Top navbar (user-facing pages, NOT admin sidebar) */
.navbar {
    background: #1f2937;
    color: #fff;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .nav-brand a,
.navbar .nav-brand {
    color: #fff;
    font-weight: 700;
    font-size: 18px;
    text-decoration: none;
}

.navbar .nav-brand a:hover {
    text-decoration: none;
    color: #c7d2fe;
}

.navbar .nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar .user-info {
    color: #d1d5db;
    font-size: 14px;
}

.navbar .btn-outline {
    background: transparent;
    color: #fff !important;
    border: 1px solid #4b5563;
}

.navbar .btn-outline:hover {
    background: #374151;
    text-decoration: none !important;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

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

.page-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

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

/* Manuals grid (dashboard cards) */
.manuals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.manual-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 20px;
    border: 1px solid var(--border);
    transition: transform 0.15s, box-shadow 0.15s;
}

.manual-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.manual-card h3 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
    line-height: 1.3;
}

.manual-card .model {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 12px;
}

.manual-card .meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.manual-card .meta .status {
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.manual-card .status-completed {
    background: #d1fae5;
    color: #065f46;
}

.manual-card .status-draft {
    background: #fef3c7;
    color: #92400e;
}

.manual-card .version-hint {
    background: #eff6ff;
    border-left: 3px solid var(--primary);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    margin-bottom: 12px;
    color: #1e3a8a;
}

.manual-card .version-hint .highlight {
    font-weight: 700;
    color: var(--primary);
}

.manual-card .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--border-radius);
    margin-bottom: 16px;
    border: 1px solid transparent;
    font-size: 14px;
}

.alert-success { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.alert-error { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.alert-warning { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.alert-info { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.pagination .btn-sm {
    min-width: 36px;
    text-align: center;
}

/* Empty state (default styling) */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state .icon,
.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    color: var(--text-muted);
    opacity: 0.6;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--text);
    margin-bottom: 6px;
}

.empty-state p {
    margin-bottom: 16px;
}

/* Hint text */
.hint {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 4px;
}

/* Btn variants used across pages */
.btn-outline {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background: #f9fafb;
    text-decoration: none;
}

.btn-center {
    text-align: center;
    padding: 16px 0;
}

/* Cover upload (create manual page) */
.cover-upload {
    border: 2px dashed var(--border);
    border-radius: var(--border-radius);
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.cover-upload:hover {
    border-color: var(--primary);
    background: #f9fafb;
}

.cover-upload.has-images {
    padding: 12px;
}

.cover-upload .upload-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.cover-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.cover-preview-item {
    position: relative;
    width: 96px;
    height: 96px;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.cover-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cover-preview-item .remove-img {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Logo upload (preview) */
.logo-upload img {
    max-height: 40px;
    vertical-align: middle;
    margin-right: 8px;
}

/* Badge variants (status badges) */
.badge-completed { background: #d1fae5; color: #065f46; }
.badge-draft { background: #fef3c7; color: #92400e; }
.badge-published { background: #dbeafe; color: #1e40af; }
.badge-archived { background: #f3f4f6; color: #374151; }

/* Stat icons in admin link cards */
.link-icon.stat-icon {
    font-size: 24px;
    margin-bottom: 8px;
}

.stat-icon.blue { color: #2563eb; }
.stat-icon.green { color: #16a34a; }
.stat-icon.orange { color: #ea580c; }
.stat-icon.red { color: #dc2626; }
.stat-icon.purple { color: #9333ea; }

/* Link cards (admin index page) */
.link-card {
    display: block;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: #fff;
    text-decoration: none;
    color: var(--text);
    transition: all 0.15s;
}

.link-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
    text-decoration: none;
}

.link-card .link-title {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.link-card .link-desc {
    font-size: 12px;
    color: var(--text-muted);
}

/* Grid for cards (admin) */
.link-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

/* Admin dashboard cards layout */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Form controls (input/select/textarea) */
.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

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

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

.form-text {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 4px;
}

/* Inline form (search bar) */
.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Table actions column */
.table td.actions {
    white-space: nowrap;
}

/* Margins */
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }

/* Flex utilities */
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

/* Badges general */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #f3f4f6;
    color: #374151;
}

/* ================================================================
   WYSIWYG preview area (contenteditable) visual enhancement
   Makes the right-hand preview pane look & feel editable
   ================================================================ */

.EasyMDEContainer .editor-preview-side[contenteditable="true"],
.EasyMDEContainer .editor-preview[contenteditable="true"] {
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
    border-left: 1px solid var(--border, #e5e7eb);
}

/* Hover visual hint (subtle dashed border top) */
.EasyMDEContainer .editor-preview-side[contenteditable="true"]:hover,
.EasyMDEContainer .editor-preview[contenteditable="true"]:hover {
    background: #fafbfc;
}

/* Focus highlight: clearly indicate the WYSIWYG pane has input focus */
.EasyMDEContainer .editor-preview-side[contenteditable="true"]:focus,
.EasyMDEContainer .editor-preview[contenteditable="true"]:focus {
    outline: none;
    background: #ffffff;
    box-shadow: inset 2px 0 0 var(--primary, #4f46e5),
                inset 0 0 0 1px rgba(79, 70, 229, 0.15);
}

/* Floating "WYSIWYG" badge in the corner so users know this pane is editable */
.EasyMDEContainer.side-by-side {
    position: relative;
}
.EasyMDEContainer .editor-preview-side[contenteditable="true"]::before {
    content: "WYSIWYG \2014  Click to edit";
    display: inline-block;
    position: sticky;
    top: 0;
    float: right;
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    background: rgba(79, 70, 229, 0.08);
    border: 1px solid rgba(79, 70, 229, 0.2);
    padding: 2px 8px;
    border-radius: 4px;
    margin: 4px 6px 4px 8px;
    letter-spacing: 0.3px;
    pointer-events: none;
}
.EasyMDEContainer .editor-preview-side[contenteditable="true"]:focus::before {
    color: var(--primary, #4f46e5);
    background: rgba(79, 70, 229, 0.12);
    border-color: rgba(79, 70, 229, 0.35);
}

/* Minimal typography inside the WYSIWYG pane so default placeholder looks nice */
.EasyMDEContainer .editor-preview .text-muted.italic,
.EasyMDEContainer .editor-preview-side .text-muted.italic {
    color: #9ca3af;
    font-style: italic;
}

/* Selection color match the primary accent for consistency */
.EasyMDEContainer .editor-preview-side[contenteditable="true"] ::selection,
.EasyMDEContainer .editor-preview[contenteditable="true"] ::selection {
    background: rgba(79, 70, 229, 0.2);
    color: inherit;
}