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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    background-color: #f5f7fa;
    color: #333;
}

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

/* Header */
header {
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    color: white;
    padding: 15px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Шапка: заголовок слева; справа — имя (отдельной строкой) над меню */
.header-bar {
    flex-wrap: wrap;
    gap: 10px 16px;
}

header h1 {
    font-size: 1.5rem;
}

.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    min-width: 0;
}

.user-line {
    font-size: 0.9rem;
    line-height: 1.3;
    text-align: right;
    max-width: 460px;
    overflow-wrap: anywhere;
}

.user-name {
    font-weight: 600;
}

.user-role {
    opacity: 0.85;
}

nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

nav a {
    color: white;
    text-decoration: none;
    margin-left: 0;
    padding: 8px 14px;
    border-radius: 4px;
    transition: background 0.3s;
    white-space: nowrap;
}

nav a:hover {
    background: rgba(255,255,255,0.2);
}

/* Компактный переключатель языка */
.lang-select {
    margin-left: 6px;
    padding: 7px 10px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.55);
    background: rgba(255,255,255,0.15);
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
}

.lang-select:hover {
    background: rgba(255,255,255,0.25);
}

.lang-select option {
    color: #222;
    background: #fff;
}

/* Сообщения: список диалогов */
.convo-list { display: flex; flex-direction: column; }
.convo-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 10px;
    border-bottom: 1px solid #eee;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}
.convo-item:hover { background: #f5f8fc; }
.convo-name { font-weight: 600; }
.convo-snippet { color: #666; font-size: 0.9rem; margin-top: 2px; }
.convo-side { text-align: right; white-space: nowrap; }
.convo-time { font-size: 0.78rem; color: #999; }
.convo-badge {
    display: inline-block;
    margin-top: 4px;
    background: #dc3545;
    color: #fff;
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 0.78rem;
}

/* Сообщения: лента переписки (чат) */
.chat-thread {
    max-height: 460px;
    overflow-y: auto;
    padding: 10px 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f7f9fc;
    border: 1px solid #eee;
    border-radius: 8px;
}
.chat-msg { display: flex; }
.chat-msg.mine { justify-content: flex-end; }
.chat-msg.theirs { justify-content: flex-start; }
.chat-bubble {
    max-width: 75%;
    padding: 8px 12px;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
    word-wrap: break-word;
}
.chat-msg.mine .chat-bubble { background: #2a5298; color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.theirs .chat-bubble { background: #fff; color: #222; border: 1px solid #e6e6e6; border-bottom-left-radius: 4px; }
.chat-body { white-space: pre-wrap; }
.chat-time { font-size: 0.72rem; opacity: 0.7; margin-top: 4px; text-align: right; }
.chat-compose { display: flex; gap: 10px; align-items: flex-end; }
.chat-input {
    flex: 1;
    resize: vertical;
    min-height: 46px;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
}
.chat-input:focus { outline: none; border-color: #2a5298; }

/* Flash messages */
.flash-messages {
    margin: 20px 0;
}

.flash {
    padding: 12px 20px;
    border-radius: 4px;
    margin-bottom: 10px;
}

.flash.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.flash.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.flash.warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

/* Cards */
.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    padding: 25px;
    margin-bottom: 20px;
}

.card h2 {
    color: #1e3c72;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #444;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #2a5298;
}

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

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 60, 114, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.875rem;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    color: #444;
}

tr:hover {
    background: #f8f9fa;
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-pending {
    background: #fff3cd;
    color: #856404;
}

.badge-completed {
    background: #d4edda;
    color: #155724;
}

/* Progress */
.progress-bar {
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 5px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #28a745, #20c997);
    transition: width 0.3s;
}

/* Criteria form */
.criteria-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
}

.criteria-item h4 {
    color: #1e3c72;
    margin-bottom: 15px;
}

.criteria-number {
    display: inline-block;
    width: 28px;
    height: 28px;
    background: #1e3c72;
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 28px;
    margin-right: 10px;
    font-size: 0.9rem;
}

.score-select {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.score-option {
    flex: 1;
}

.score-option input[type="radio"] {
    display: none;
}

.score-option label {
    display: block;
    padding: 12px;
    text-align: center;
    background: white;
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.score-option input[type="radio"]:checked + label {
    border-color: #1e3c72;
    background: #1e3c72;
    color: white;
}

.char-counter {
    text-align: right;
    font-size: 0.85rem;
    color: #666;
    margin-top: 5px;
}

/* Expert checkboxes */
.expert-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px;
}

.expert-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.expert-item:last-child {
    border-bottom: none;
}

.expert-item label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.expert-item input[type="checkbox"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
}

/* Grid */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

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

/* Hero section */
.hero {
    text-align: center;
    padding: 60px 20px;
}

.hero h2 {
    font-size: 2rem;
    color: #1e3c72;
    margin-bottom: 20px;
}

.hero p {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 30px;
}

.hero-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* Evaluation results */
.evaluation-result {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
}

.evaluation-result .score {
    font-size: 1.5rem;
    font-weight: bold;
    color: #1e3c72;
}

.evaluation-result .rubric-description {
    margin-top: 10px;
    padding: 10px;
    background: #e8f4f8;
    border-radius: 4px;
    border-left: 4px solid #2a5298;
    color: #1e3c72;
    font-style: italic;
}

.evaluation-result .justification {
    margin-top: 10px;
    padding: 10px;
    background: white;
    border-radius: 4px;
    white-space: pre-wrap;
}

/* Summary */
.summary-stats {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.stat-box {
    flex: 1;
    min-width: 150px;
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    color: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.stat-box .number {
    font-size: 2rem;
    font-weight: bold;
}

.stat-box .label {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: #666;
    margin-top: 40px;
}

/* Sort controls */
.sort-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.sort-btn {
    transition: all 0.2s;
}

.sort-btn.active {
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    color: white;
}

/* Rubric styles */
.rubric-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rubric-option {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    transition: all 0.2s;
}

.rubric-option:hover {
    border-color: #2a5298;
}

.rubric-option label {
    display: flex;
    align-items: flex-start;
    padding: 12px 15px;
    cursor: pointer;
    gap: 12px;
}

.rubric-option input[type="radio"] {
    margin-top: 3px;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.rubric-option input[type="radio"]:checked + .rubric-score {
    background: #1e3c72;
    color: white;
}

.rubric-option:has(input:checked) {
    border-color: #1e3c72;
    background: #f0f4ff;
}

.rubric-score {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    background: #e9ecef;
    color: #333;
    border-radius: 50%;
    font-weight: bold;
    font-size: 1rem;
    flex-shrink: 0;
}

.rubric-text {
    flex: 1;
    line-height: 1.5;
    color: #444;
}

/* Research area search */
.hint {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.area-search-container {
    position: relative;
    margin-bottom: 10px;
}

.area-search-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.area-search-input:focus {
    outline: none;
    border-color: #2a5298;
}

.area-search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.search-result-item {
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    gap: 10px;
    align-items: center;
    border-bottom: 1px solid #eee;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: #f0f4ff;
}

.search-no-results {
    padding: 15px;
    color: #666;
    text-align: center;
}

.area-code {
    background: #1e3c72;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}

.area-name {
    flex: 1;
}

/* Selected areas */
.selected-areas {
    min-height: 50px;
    border: 2px dashed #ddd;
    border-radius: 4px;
    padding: 10px;
}

.selected-area-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 8px;
}

.selected-area-item:last-child {
    margin-bottom: 0;
}

.selected-area-item.dragging {
    opacity: 0.5;
    background: #e0e0e0;
}

.drag-handle {
    cursor: grab;
    color: #999;
    font-size: 1.2rem;
}

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

.remove-area {
    background: #dc3545;
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    flex-shrink: 0;
}

.remove-area:hover {
    background: #c82333;
}

/* Expert list with areas */
.expert-item {
    padding: 12px;
    border-bottom: 1px solid #eee;
}

.expert-item label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
}

.expert-item input[type="checkbox"] {
    margin-top: 3px;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.expert-info {
    flex: 1;
}

.expert-name {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.expert-email {
    font-size: 0.85rem;
    color: #666;
    margin-top: 2px;
}

.expert-area {
    font-size: 0.85rem;
    color: #444;
    margin-top: 5px;
    padding: 5px 8px;
    background: #e8f4f8;
    border-radius: 4px;
    display: inline-block;
}

.expert-area.no-area {
    background: #f8f8f8;
    color: #999;
    font-style: italic;
}

.area-code-small {
    background: #1e3c72;
    color: white;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 5px;
}

.expert-match {
    background: #e8f5e9;
    border-left: 3px solid #28a745;
}

.match-badge {
    background: #28a745;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

/* Wide expert list */
.expert-list-wide {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 10px;
    max-height: 500px;
    overflow-y: auto;
}

.expert-list-wide .expert-item {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 0;
}

.expert-list-wide .expert-item:hover {
    border-color: #2a5298;
}

/* Expert stats */
.expert-stats {
    display: flex;
    gap: 8px;
    margin-top: 5px;
}

.expert-stats span {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.stat-pending {
    background: #fff3cd;
    color: #856404;
}

.stat-pending::before {
    content: "⏳ ";
}

.stat-completed {
    background: #d4edda;
    color: #155724;
}

.stat-completed::before {
    content: "✓ ";
}

/* Import info */
.import-info {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
}

.import-columns-table {
    width: 100%;
    margin-top: 10px;
    font-size: 0.9rem;
}

.import-columns-table th {
    background: #1e3c72;
    color: white;
}

.import-columns-table td {
    background: white;
}

.optional-badge {
    background: #6c757d;
    color: white;
    font-size: 0.65rem;
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: normal;
    margin-left: 3px;
}

/* Quality Rating Stars */
.rating-stars {
    display: flex;
    gap: 2px;
}

.star-label {
    cursor: pointer;
}

.star-label input {
    display: none;
}

.star-label .star {
    font-size: 1.5rem;
    color: #ddd;
    transition: color 0.2s;
}

.star-label .star.active,
.star-label .star.hover {
    color: #ffc107;
}

/* Stat rating badge */
.stat-rating {
    background: linear-gradient(135deg, #ffc107, #ff9800);
    color: #333;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.75rem;
}

.quality-rating-form {
    background: #f8f9fa;
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

/* Expert publication links */
.expert-links {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.expert-link {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 3px;
    text-decoration: none;
    font-weight: 600;
    transition: opacity 0.2s;
}

.expert-link:hover {
    opacity: 0.8;
}

.scopus-link {
    background: #e9711c;
    color: white;
}

.wos-link {
    background: #5856d6;
    color: white;
}

/* Commission Voting */
.vote-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.vote-option {
    display: flex;
    align-items: flex-start;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.vote-option:hover {
    border-color: #1e3c72;
    background: #f8f9fa;
}

.vote-option input[type="radio"] {
    margin-right: 15px;
    margin-top: 3px;
    transform: scale(1.2);
}

.vote-option input[type="radio"]:checked + .vote-option-content {
    font-weight: 500;
}

.vote-option-content strong {
    display: block;
    margin-bottom: 5px;
}

.vote-option-content p {
    color: #666;
    font-size: 0.9rem;
    margin: 0;
}

.vote-option-recommend:has(input:checked) {
    border-color: #28a745;
    background: rgba(40, 167, 69, 0.1);
}

.vote-option-revise:has(input:checked) {
    border-color: #ffc107;
    background: rgba(255, 193, 7, 0.1);
}

.vote-option-reject:has(input:checked) {
    border-color: #dc3545;
    background: rgba(220, 53, 69, 0.1);
}

/* Vote summary badges in dashboard */
.vote-summary {
    display: flex;
    gap: 5px;
}

.vote-summary span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
}

.vote-recommend {
    background: #28a745;
}

.vote-revise {
    background: #ffc107;
    color: #333 !important;
}

.vote-reject {
    background: #dc3545;
}

.badge-rejected {
    background-color: #dc3545;
    color: white;
}

/* Affiliated expert highlighting */
.expert-affiliated {
    background: #ffeef0;
    border-left: 3px solid #dc3545;
}

.affiliated-badge {
    background: #dc3545;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

/* Organization search container */
.org-search-container {
    position: relative;
    margin-bottom: 10px;
}

/* Activity Log Badges */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: #28a745;
    color: white;
}

.badge-danger {
    background: #dc3545;
    color: white;
}

.badge-primary {
    background: #1e3c72;
    color: white;
}

.badge-info {
    background: #17a2b8;
    color: white;
}

.badge-secondary {
    background: #6c757d;
    color: white;
}
