:root {
    --primary: #040e9b;
    --primary-hover: #0615b3;
    --primary-light: rgba(4,14,155,0.06);
    --primary-glow: rgba(4,14,155,0.15);
    --bg: #f9fafb;
    --surface: #ffffff;
    --text: #111827;
    --text2: #6b7280;
    --text3: #9ca3af;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --danger: #ef4444;
    --success: #10b981;
    --r-sm: 6px;
    --r-md: 8px;
    --r-lg: 12px;
    --r-xl: 16px;
    --r-full: 9999px;
    --tr: 0.15s ease;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
    background: var(--bg);
    min-height: 100vh;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* ===== LOGIN ===== */
#login-form {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 9999;
}
#login-form.hidden { display: none; }
.login-card {
    background: var(--surface);
    border-radius: var(--r-xl);
    border: 1px solid var(--border);
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
    width: 100%;
    max-width: 400px;
    overflow: hidden;
}
.login-header {
    padding: 40px 36px 0;
    text-align: center;
    background: transparent;
    border-bottom: none;
}
.login-header h2 {
    color: var(--text);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}
.login-content { display: block; }
.login-icon {
    width: 56px;
    height: 56px;
    background: var(--primary);
    border-radius: var(--r-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    border: none;
    box-shadow: 0 4px 12px rgba(4,14,155,0.25);
}
.login-icon svg { width: 28px; height: 28px; fill: white; }
.login-subtitle { color: var(--text2); font-size: 14px; }
.login-body { padding: 28px 36px 36px; background: transparent; }
.login-grid { display: grid; gap: 18px; }
.login-row { display: flex; flex-direction: column; }
.form-group { margin-bottom: 0; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text2);
    font-weight: 500;
    font-size: 13px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-size: 14px;
    font-family: inherit;
    transition: all var(--tr);
    background: var(--surface);
    color: var(--text);
}
.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover { border-color: #d1d5db; }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-group input::placeholder { color: var(--text3); }

.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrapper input {
    padding-right: 40px;
    width: 100%;
}

.password-toggle {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text2);
    font-size: 16px;
    padding: 4px;
}

.password-toggle:hover {
    color: var(--brand);
}


.login-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 28px; }
.btn-login {
    width: 100%;
    padding: 11px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--r-full);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--tr);
    flex: none;
    min-width: auto;
}
.btn-login:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(4,14,155,0.25);
}
.btn-cancel {
    width: 100%;
    padding: 11px 24px;
    background: transparent;
    color: var(--text2);
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--tr);
    min-width: auto;
}
.btn-cancel:hover { background: var(--bg); }

/* ===== SIDEBAR ===== */
.dashboard { display: block; min-height: 100vh; position: relative; z-index: 1; }
.sidebar {
    width: 240px;
    background: var(--surface);
    min-height: 100vh;
    position: fixed;
    left: 0; top: 0;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    z-index: 10;
}
.sidebar-header {
    padding: 22px 20px 18px;
    border-bottom: none;
    background: transparent;
}
.sidebar-header h3 {
    color: var(--text);
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 8px;
}
.sidebar-header h3 i { color: var(--primary); font-size: 18px; }
.nav-menu { padding: 8px 12px; }
.nav-menu button {
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    color: var(--text2);
    border: none;
    border-left: 3px solid transparent;
    text-align: left;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--tr);
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    font-weight: 500;
    margin-bottom: 2px;
}
.nav-menu button i {
    font-size: 16px;
    width: 20px;
    text-align: center;
    color: var(--text3);
    transition: color var(--tr);
}
.nav-menu button:hover { background: var(--bg); color: var(--text); }
.nav-menu button:hover i { color: var(--text2); }
.nav-menu button.active {
    background: var(--primary-light);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 600;
}
.nav-menu button.active i { color: var(--primary); }
.nav-menu hr { border: none; border-top: 1px solid var(--border); margin: 10px 8px; }
.section-title {
    color: var(--text3);
    padding: 14px 14px 6px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 600;
}
.logout-btn { margin-top: 8px; color: var(--text2) !important; }
.logout-btn:hover { background: #fef2f2 !important; color: var(--danger) !important; }
.logout-btn:hover i { color: var(--danger) !important; }

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: 240px;
    background: var(--bg);
    min-height: 100vh;
}
.top-header {
    background: var(--surface);
    padding: 14px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 5;
}
.top-header h1 {
    color: var(--text2);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.user-info { color: var(--text2); font-size: 13px; font-weight: 500; }
.content-area { padding: 28px 30px; }
.section { display: none; }
.section.active { display: block; }
.section-header {
    background: transparent;
    padding: 0 0 20px;
    border-radius: 0;
    border: none;
    margin-bottom: 0;
    display: flex;
    align-items: center;
}
.section-header h2 {
    color: var(--text);
    font-size: 24px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.02em;
}
.section-header h2 i { color: var(--primary); font-size: 22px; }
.content-card {
    background: var(--surface);
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    padding: 24px;
}

/* ===== BUTTONS ===== */
.btn-primary {
    background: var(--primary);
    color: white;
    padding: 9px 20px;
    border: none;
    border-radius: var(--r-full);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--tr);
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(4,14,155,0.2);
}
.btn-danger {
    background: var(--danger);
    color: white;
    padding: 9px 20px;
    border: none;
    border-radius: var(--r-full);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--tr);
}
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); }
.btn-secondary {
    background: var(--surface);
    color: var(--text2);
    padding: 9px 20px;
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--tr);
}
.btn-secondary:hover { background: var(--bg); border-color: #d1d5db; }
.btn-primary:disabled, .btn-secondary:disabled, .btn-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-primary:disabled:hover, .btn-secondary:disabled:hover {
    transform: none;
    box-shadow: none;
}
.btn-danger:disabled:hover {
    transform: none;
    background: #ef4444;
}
.toolbar { display: flex; gap: 8px; margin-bottom: 18px; align-items: center; }

/* ===== TABLES ===== */
.manuscripts-table,
.users-table { width: 100%; border-collapse: collapse; }
.manuscripts-table th,
.users-table th {
    background: transparent;
    color: var(--text3);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.manuscripts-table td,
.users-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
    color: var(--text);
}
.manuscripts-table tbody tr,
.users-table tbody tr { transition: background var(--tr); }
.manuscripts-table tbody tr:hover,
.users-table tbody tr:hover { background: var(--bg); }
.manuscripts-table tbody tr:last-child td,
.users-table tbody tr:last-child td { border-bottom: none; }
.users-table input[type="checkbox"],
.manuscripts-table input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
    transform: none;
}

.users-table th.sortable,
.manuscripts-table th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.users-table th.sortable:hover,
.manuscripts-table th.sortable:hover {
    color: var(--primary);
}
.users-table th.sortable i,
.manuscripts-table th.sortable i {
    font-size: 12px;
    margin-left: 4px;
    opacity: 0.7;
}
.users-table th.sortable:hover i,
.manuscripts-table th.sortable:hover i {
    opacity: 1;
}

.users-table td.sortable,
.manuscripts-table td.sortable {
    cursor: pointer;
    user-select: none;
}
.users-table td.sortable:hover,
.manuscripts-table td.sortable:hover {
    color: var(--primary);
}
.users-table td.sortable i,
.manuscripts-table td.sortable i {
    font-size: 12px;
    margin-left: 4px;
    opacity: 0.7;
}
.users-table td.sortable:hover i,
.manuscripts-table td.sortable:hover i {
    opacity: 1;
}

/* ===== MANUSCRIPT ENTRY ===== */
.manuscript-entry {
    background: var(--bg);
    padding: 24px;
    border-radius: var(--r-lg);
    margin-bottom: 14px;
    border: 1px solid var(--border);
    transition: border-color var(--tr);
}
.manuscript-entry:hover { border-color: #d1d5db; }
.manuscript-entry .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-bottom: 16px;
}
.manuscript-entry .form-group { margin-bottom: 0; }
.manuscript-entry label {
    display: block;
    margin-bottom: 6px;
    color: var(--text2);
    font-weight: 500;
    font-size: 13px;
}
.manuscript-entry input[type="text"],
.manuscript-entry select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-size: 14px;
    font-family: inherit;
    background: var(--surface);
    transition: all var(--tr);
    color: var(--text);
}
.manuscript-entry input[type="text"]:hover,
.manuscript-entry select:hover { border-color: #d1d5db; }
.manuscript-entry input[type="text"]:focus,
.manuscript-entry select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    outline: none;
}
.manuscript-entry input[type="file"] { padding: 10px 0; font-size: 13px; color: var(--text2); }
.manuscript-entry textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-size: 14px;
    font-family: inherit;
    min-height: 140px;
    resize: vertical;
    background: var(--surface);
    transition: all var(--tr);
    color: var(--text);
}
.manuscript-entry textarea:hover { border-color: #d1d5db; }
.manuscript-entry textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    outline: none;
}
.manuscript-entry .form-actions { margin-top: 16px; }
.form-actions { display: flex; gap: 8px; margin-bottom: 20px; }
.form-actions-top { display: flex; gap: 8px; margin-bottom: 20px; }
.form-heading { margin-bottom: 20px; }
.form-actions .btn-secondary:last-child { margin-left: auto; }

/* ===== FORMATTING TOOLBAR ===== */
.toolbar-formatting {
    display: flex;
    gap: 4px;
    padding: 6px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--r-md) var(--r-md) 0 0;
}
.fmt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
    cursor: pointer;
    font-size: 16px;
    color: var(--text);
    transition: all var(--tr);
}
.fmt-btn i { font-size: 18px; }
.fmt-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* ===== EDITOR TOGGLE ===== */
.editor-toggle-bar {
    display: flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 0 0 var(--r-md) var(--r-md);
    overflow: hidden;
}
.editor-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 32px;
    border: none;
    background: var(--surface);
    cursor: pointer;
    font-size: 15px;
    color: var(--text2);
    transition: all var(--tr);
}
.editor-toggle-btn:not(:last-child) {
    border-right: 1px solid var(--border);
}
.editor-toggle-btn:hover {
    color: var(--text);
    background: var(--bg);
}
.editor-toggle-btn.active {
    background: var(--primary);
    color: #fff;
}

/* ===== WYSIWYG EDITOR ===== */
.wysiwyg-editor {
    height: 200px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 0;
    font-size: 14px;
    line-height: 1.6;
    background: var(--surface);
    color: var(--text);
    outline: none;
    overflow-y: auto;
    transition: all var(--tr);
}
.wysiwyg-editor:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.wysiwyg-editor ul,
.wysiwyg-editor ol { padding-left: 24px; margin: 8px 0; }
.wysiwyg-editor li { margin-bottom: 4px; }

/* ===== TOOLTIP EDIT FORM ===== */
#tooltips-edit-form .form-actions {
    margin-top: 20px;
}
#tooltips-edit-form input[readonly] {
    background: var(--bg);
    color: var(--text2);
    cursor: default;
}
#tooltips-edit-form textarea.setting-input {
    height: 200px;
    padding: 12px 14px;
    border-radius: 0;
    border-bottom: none;
    resize: none;
    overflow-y: auto;
}

/* ===== STATUS & ACTIONS ===== */
.status-badge { padding: 4px 12px; border-radius: var(--r-full); font-size: 12px; font-weight: 600; }
.status-badge.active { background: #ecfdf5; color: #059669; }
.status-badge.disabled { background: #fef2f2; color: #dc2626; }
.status-badge.pending { background: #fef3c7; color: #d97706; }
.status-badge.expired { background: #fef2f2; color: #dc2626; }
.status-badge.unknown { background: #f3f4f6; color: #6b7280; }
.action-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    margin-right: 4px;
    background: var(--surface);
    color: var(--text2);
    transition: all var(--tr);
}
.action-btn:hover { background: var(--bg); border-color: #d1d5db; }
.action-btn.edit-btn { color: var(--primary); border-color: rgba(4,14,155,0.2); }
.action-btn.edit-btn:hover { background: rgba(4,14,155,0.04); border-color: rgba(4,14,155,0.3); }
.action-btn.delete-btn { color: var(--danger); border-color: rgba(239,68,68,0.2); }
.action-btn.delete-btn:hover { background: #fef2f2; border-color: rgba(239,68,68,0.3); }
.action-btn.enable-btn { color: var(--success); border-color: rgba(16,185,129,0.2); }
.action-btn.enable-btn:hover { background: #ecfdf5; border-color: rgba(16,185,129,0.3); }
.action-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ===== FORM CONTAINERS ===== */
.form-container { max-width: 560px; }
.form-container .form-group { margin-bottom: 18px; }
.form-container label {
    display: block;
    margin-bottom: 6px;
    color: var(--text2);
    font-weight: 500;
    font-size: 13px;
}
.form-container input,
.form-container select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-size: 14px;
    font-family: inherit;
    background: var(--surface);
    transition: all var(--tr);
    color: var(--text);
}
.form-container input:hover,
.form-container select:hover { border-color: #d1d5db; }
.form-container input:focus,
.form-container select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    outline: none;
}
.form-container h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}
.back-btn { margin-bottom: 15px; }
.hidden { display: none !important; }

/* ===== MODAL ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}
.modal.hidden { display: none; }
.modal-content {
    background: var(--surface);
    border-radius: var(--r-xl);
    padding: 32px;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.modal-content .form-group { margin-bottom: 24px; }
.modal-content .form-group label { margin-bottom: 10px; }
.modal-content .form-actions { margin-top: 28px; }
.modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: var(--text2);
    line-height: 1;
}
.modal-close:hover { color: var(--text); }

/* ===== REPORT VIEW ===== */
.report-modal { max-width: 800px; }
.report-header-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.report-header-left { flex: 1; }
.report-header-right { text-align: center; }
.report-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}
.report-meta {
    font-size: 14px;
    color: var(--text2);
}
.report-meta .separator {
    margin: 0 8px;
    color: var(--border);
}

.score-gauge-large {
    position: relative;
    width: 120px;
    height: 120px;
}
.score-gauge-large svg { transform: rotate(-90deg); }
.score-gauge-large .gauge-bg { fill: none; stroke: var(--border); stroke-width: 8; }
.score-gauge-large .gauge-fill { fill: none; stroke: var(--primary); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 0.5s ease; }
.score-value-large {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}
.score-label {
    font-size: 12px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 8px;
}

.report-legend {
    margin-top: 16px;
    padding-left: 16px;
    font-size: 12px;
    color: var(--text2);
    line-height: 1.6;
}
.report-legend li {
    margin-bottom: 4px;
}
.report-legend strong {
    font-weight: 600;
    color: var(--text);
}

.report-metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.metric-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 16px;
}
.metric-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.metric-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text2);
}
.metric-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}
.bar-graph {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.bar-graph-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.5s ease;
}
.report-tooltip {
    position: fixed;
    background: #1f2937;
    color: #fff;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.4;
    max-width: 220px;
    display: none;
    z-index: 1000;
    white-space: normal;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    pointer-events: none;
}
.report-tooltip ul {
    list-style-position: inside;
    text-align: left;
}
.report-tooltip.visible {
    display: block;
}
.report-tooltip::after {
    display: none;
}
@media print {
    .report-tooltip, #report-tooltip-container { display: none !important; }
}
.stars-container {
    display: flex;
    gap: 4px;
}
.stars-container i {
    font-size: 20px;
    color: #fbbf24;
}

.report-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary);
    display: inline-block;
}

.genre-match-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.genre-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 12px 16px;
}
.genre-card-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    min-width: 100px;
}
.genre-bar-container {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.genre-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.5s ease;
}
.genre-card-score {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    min-width: 30px;
    text-align: right;
}

.no-data {
    color: var(--text2);
    font-size: 14px;
    grid-column: 1 / -1;
}

/* ===== SMALL BUTTON ===== */
.btn-sm { padding: 6px 14px; font-size: 12px; }

/* ===== REPORT VIEW (SECTION) ===== */
.report-view {
    margin-top: 10px;
}
.report-llm-text {
    font-size: 11px;
    color: var(--text2);
    margin: 12px 0;
    line-height: 1.5;
}
.genre-fit-description {
    font-size: 12px;
    color: var(--text2);
    margin-bottom: 12px;
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}
.loading-overlay.hidden { display: none; }
.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
.loading-text {
    margin-top: 16px;
    color: white;
    font-size: 16px;
    font-weight: 500;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== AUTHOR FEEDBACK ===== */
.author-feedback {
    margin-top: 20px;
}
.feedback-intro {
    font-size: 12px;
    color: var(--text2);
    line-height: 1.6;
    margin-bottom: 16px;
}
.feedback-intro strong {
    font-weight: 600;
    color: var(--text);
}
.feedback-metrics-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.feedback-metrics-header {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 2px solid var(--primary);
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
.feedback-metrics-header span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
.feedback-metric-row {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}
.feedback-metric-row:last-child {
    border-bottom: none;
}
.feedback-metric-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    flex: 0 0 50%;
}
.feedback-metric-value {
    font-size: 13px;
    color: var(--text);
    flex: 0 0 16.66%;
    text-align: right;
}
.feedback-metric-comparison {
    flex: 0 0 16.66%;
    text-align: right;
}
.feedback-metric-avg {
    flex: 0 0 16.66%;
    text-align: right;
}
.comparison-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}
.comparison-badge.positive {
    background: #ecfdf5;
    color: #059669;
}
.comparison-badge.negative {
    background: #fef2f2;
    color: #dc2626;
}
.feedback-metric-avg {
    font-size: 12px;
    color: var(--text2);
    margin-left: auto;
}

/* ===== PASSWORD STRENGTH INDICATOR ===== */
.password-strength {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.strength-bar {
    flex: 1;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    transition: width 0.3s ease, background-color 0.3s ease;
    min-width: 60px;
}
.strength-text {
    font-size: 11px;
    font-weight: 600;
    min-width: 50px;
}

.password-requirements {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ===== MESSAGE BOX ===== */
.message-box {
    padding: 12px 16px;
    border-radius: var(--r-md);
    font-size: 13px;
    margin-top: 16px;
}
.message-box.error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}
.message-box.success {
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #a7f3d0;
}

/* ===== CHECKBOX LIST ===== */
.checkbox-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 8px;
}
.checkbox-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    cursor: pointer;
    border-radius: var(--r-sm);
}
.checkbox-list label:hover {
    background: var(--primary-light);
}
.checkbox-list input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* ===== INVOICE DETAIL ===== */
.invoice-detail-header {
    background: var(--primary-light);
    padding: 16px;
    border-radius: var(--r-md);
    margin-bottom: 16px;
}
.invoice-detail-row {
    margin-bottom: 8px;
}
.invoice-detail-row:last-child {
    margin-bottom: 0;
}
.invoice-detail-row strong {
    display: inline-block;
    min-width: 120px;
}

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px;
    text-align: center;
}
.stat-card .stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
}
.stat-card .stat-label {
    font-size: 13px;
    color: var(--text2);
    margin-top: 4px;
}

/* ===== LINK BUTTON ===== */
.btn-link {
    background: transparent;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    padding: 4px 8px;
    text-decoration: underline;
    margin-left: 12px;
}
.btn-link:hover {
    color: var(--primary-hover);
}

/* ===== MODAL HEADER ===== */
.modal-header {
    margin-bottom: 20px;
}
.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}
.modal-subtitle {
    font-size: 14px;
    color: var(--text2);
}

/* ===== USER INFO BUTTON ===== */
.user-info button {
    vertical-align: middle;
}

/* ===== STATUS BADGE ===== */
.status-badge.pending {
    background: #fef3c7;
    color: #d97706;
}

/* ===== RESEND BUTTON ===== */
.action-btn.resend-btn {
    color: var(--primary);
    border-color: rgba(4,14,155,0.2);
}
.action-btn.resend-btn:hover {
    background: rgba(4,14,155,0.04);
    border-color: rgba(4,14,155,0.3);
}

/* ===== SETTINGS TABS ===== */
.tab-container {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
}

.tab-btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text2);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
    font-family: 'Inter', sans-serif;
}

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

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ===== EMAIL LOG DETAIL ===== */
.email-log-detail .detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--primary);
}

.email-log-detail .detail-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
}

.email-log-detail .detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.email-log-detail .detail-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.email-log-detail .detail-field.full-width {
    grid-column: 1 / -1;
}

.email-log-detail .detail-field label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.email-log-detail .detail-field p {
    font-size: 14px;
    color: var(--text1);
    margin: 0;
}

.email-log-detail .detail-field .error-text {
    color: #dc2626;
    font-family: monospace;
    background: #fef2f2;
    padding: 8px 12px;
    border-radius: 4px;
}

.email-log-detail .detail-body-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.email-log-detail .detail-body-section label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 8px;
}

.email-log-detail .email-body-preview {
    font-size: 14px;
    color: var(--text1);
    line-height: 1.6;
    background: #ffffff;
    padding: 20px;
    border-radius: 6px;
    border: 1px solid var(--border);
    max-height: 500px;
    overflow-y: auto;
}

.email-log-detail .email-body-preview img {
    max-width: 100%;
    height: auto;
}

.email-log-detail .email-body-preview a:not(.button) {
    color: var(--primary);
}

.email-log-detail .email-body-preview table {
    border-collapse: collapse;
    width: 100%;
}

.email-log-detail .email-body-preview p {
    margin: 0 0 12px 0;
}

.email-log-detail .email-body-preview ul,
.email-log-detail .email-body-preview ol {
    margin: 0 0 12px 0;
    padding-left: 24px;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    max-width: 360px;
}

.search-bar:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-bar .search-icon {
    color: var(--text3);
    font-size: 14px;
    flex-shrink: 0;
}

.search-bar .search-input {
    border: none;
    outline: none;
    width: 100%;
    font-size: 14px;
    color: var(--text);
    background: transparent;
    font-family: inherit;
}

.search-bar .search-input::placeholder {
    color: var(--text3);
}

.search-bar .search-clear {
    background: none;
    border: none;
    color: var(--text3);
    font-size: 18px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    flex-shrink: 0;
    transition: color var(--tr);
}

.search-bar .search-clear:hover {
    color: var(--text);
}

.search-bar .search-clear.hidden {
    display: none;
}

.search-bar .search-result-count {
    font-size: 12px;
    color: var(--text3);
    white-space: nowrap;
    margin-left: auto;
    flex-shrink: 0;
}

/* ===== MOBILE RESPONSIVENESS ===== */

/* Sidebar toggle button — hidden on desktop */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--primary);
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    margin-right: 10px;
    line-height: 1;
    flex-shrink: 0;
}

/* Overlay — hidden on desktop */
.sidebar-overlay {
    display: none;
}

/* Tablet & below (<= 1024px) */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
    }

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

    .sidebar-overlay.active {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9;
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: block;
    }
}

/* Phone (<= 768px) */
@media (max-width: 768px) {
    .content-area {
        padding: 16px;
    }

    .top-header {
        padding: 10px 16px;
    }

    .content-card {
        padding: 16px;
        overflow-x: auto;
    }

    .modal-content {
        max-width: 95%;
        padding: 24px;
    }

    .manuscript-entry .form-row {
        grid-template-columns: 1fr;
    }

    .email-log-detail .detail-grid {
        grid-template-columns: 1fr;
    }

    .toolbar {
        flex-wrap: wrap;
        gap: 6px;
    }

    .users-table th,
    .users-table td,
    .manuscripts-table th,
    .manuscripts-table td {
        padding: 8px 10px;
        font-size: 13px;
    }

    .report-metrics-grid {
        grid-template-columns: 1fr;
    }

    .genre-match-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* Hide non-essential columns on mobile */
    td[data-desktop], th[data-desktop] {
        display: none;
    }

    /* Hide icons inside action buttons on mobile — text labels are sufficient */
    .action-btn i {
        display: none;
    }

    /* Sticky action column — pins to right edge on mobile */
    .users-table td:last-child,
    .users-table th:last-child {
        position: sticky;
        right: 0;
        background: var(--surface);
        z-index: 1;
    }

    .users-table th:last-child {
        z-index: 2;
    }

    .users-table td:last-child::before,
    .users-table th:last-child::before {
        content: '';
        position: absolute;
        left: -6px;
        top: 0;
        bottom: 0;
        width: 6px;
        background: linear-gradient(to right, transparent, rgba(0,0,0,0.06));
        pointer-events: none;
    }

    /* Sticky checkbox column — pins to left edge on mobile */
    .users-table td:first-child,
    .users-table th:first-child {
        position: sticky;
        left: 0;
        background: var(--surface);
        z-index: 1;
    }

    .users-table th:first-child {
        z-index: 3;
    }

    .users-table td:first-child::after,
    .users-table th:first-child::after {
        content: '';
        position: absolute;
        right: -6px;
        top: 0;
        bottom: 0;
        width: 6px;
        background: linear-gradient(to left, transparent, rgba(0,0,0,0.06));
        pointer-events: none;
    }
}

/* Very small phone (<= 480px) */
@media (max-width: 480px) {
    .modal-content {
        padding: 14px;
    }

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

    .sidebar-header {
        padding: 14px 12px;
    }

    .content-card {
        padding: 12px;
    }

    .top-header h1 {
        font-size: 11px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn-secondary:last-child {
        margin-left: 0;
    }
}
