*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; font-size: 14px; color: #1a1a1a; background: #f5f5f5; }
.app-header { display: flex; align-items: center; justify-content: space-between; padding: 0 20px; height: 48px; background: #2c3e50; color: #fff; }
.app-header .logo { font-weight: 600; font-size: 16px; }
.app-header .user-info { display: flex; align-items: center; gap: 8px; cursor: pointer; position: relative; }
.app-header .user-info .avatar { width: 32px; height: 32px; border-radius: 50%; background: #5d7d9a; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.app-header .dropdown { position: absolute; top: 40px; right: 0; background: #fff; color: #1a1a1a; border: 1px solid #ddd; border-radius: 4px; min-width: 180px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); z-index: 100; display: none; }
.app-header .dropdown.show { display: block; }
.app-header .dropdown-item { padding: 10px 16px; cursor: pointer; border: none; background: none; width: 100%; text-align: left; font-size: 13px; }
.app-header .dropdown-item:hover { background: #f0f0f0; }
.main-content { display: flex; height: calc(100vh - 48px); }
.panel-left { flex: 0 0 65%; overflow-y: auto; padding: 20px; }
.panel-right { flex: 0 0 35%; overflow-y: auto; padding: 20px; border-left: 1px solid #ddd; background: #fff; }
.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.search-bar input { flex: 1; padding: 8px 12px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px; }
.search-bar button { padding: 8px 16px; border: none; border-radius: 4px; background: #3498db; color: #fff; cursor: pointer; font-size: 13px; }
.search-bar button:hover { background: #2980b9; }
.costing-item { padding: 12px; border-bottom: 1px solid #eee; cursor: pointer; }
.costing-item:hover { background: #f8f9fa; }
.costing-item.selected { background: #e8f4fd; border-left: 3px solid #3498db; }
.costing-item .title { font-weight: 500; margin-bottom: 4px; }
.costing-item .meta { font-size: 12px; color: #888; }
.version-toggle { display: inline-block; width: 14px; margin-right: 4px; color: #7f8c8d; cursor: pointer; user-select: none; }
.version-tree { margin: 0 0 8px; padding: 4px 0 4px 24px; border-left: 2px solid #eee; }
.version-node { padding: 4px 8px; font-size: 12px; color: #555; cursor: pointer; border-radius: 3px; }
.version-node:hover { background: #f0f0f0; }
.version-node.current { color: #2c3e50; font-weight: 500; }
.version-approved { color: #27ae60; margin-left: 6px; font-size: 11px; }
.login-page { display: flex; align-items: center; justify-content: center; height: 100vh; background: #f5f5f5; }
.login-card { background: #fff; padding: 40px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); width: 380px; }
.login-card h2 { margin-bottom: 24px; font-weight: 600; text-align: center; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 4px; font-size: 13px; color: #555; }
.form-group input { width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 4px; font-size: 14px; }
.btn { padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; font-size: 14px; }
.btn-primary { background: #3498db; color: #fff; width: 100%; }
.btn-primary:hover { background: #2980b9; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-success { background: #27ae60; color: #fff; }
.btn-warning { background: #f39c12; color: #fff; }
.action-bar { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.costing-detail h3 { margin-bottom: 12px; }
.costing-detail .status-badge { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 12px; background: #eee; margin-bottom: 12px; }
.costing-detail table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.costing-detail th, .costing-detail td { padding: 8px 10px; text-align: left; border-bottom: 1px solid #eee; font-size: 13px; }
.costing-detail th { background: #f8f9fa; font-weight: 600; }
.costing-detail thead th { position: sticky; top: 0; z-index: 2; }
.costing-detail tbody tr:not(.note-row) td:nth-child(1),
.costing-detail tbody tr:not(.note-row) td:nth-child(2) { position: sticky; z-index: 1; background: #f5f5f5; }
.costing-detail thead th:nth-child(1),
.costing-detail thead th:nth-child(2) { z-index: 3; }
.costing-detail th:nth-child(1),
.costing-detail tbody tr:not(.note-row) td:nth-child(1) { left: 0; width: 40px; }
.costing-detail th:nth-child(2),
.costing-detail tbody tr:not(.note-row) td:nth-child(2) { left: 40px; }

/* Реквизиты: строки с возможностью замечания (подсветка — только для ролей, видящих замечания) */
.detail-rows { margin: 12px 0 0; font-size: 13px; }
.detail-row { display: grid; grid-template-columns: 220px 1fr; column-gap: 16px; align-items: baseline; border: 1px solid transparent; border-radius: 4px; padding: 2px 6px; margin: 0 -6px; }
.notes-enabled .detail-row { cursor: pointer; }
.notes-enabled .detail-row:hover { border-color: #e74c3c; }
.notes-enabled .detail-row.note-present, .notes-enabled .detail-row.note-selected { border-color: #e74c3c; background: #fbe3e1; }
.detail-row-label { color: #777; }
.detail-row-value { white-space: pre-wrap; }

/* Форма редактирования: поля в столбик, как в режиме просмотра */
.edit-rows { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; font-size: 13px; }
.edit-row { display: grid; grid-template-columns: 220px 1fr; column-gap: 16px; align-items: center; }
.edit-row-label { color: #555; }

/* Таблица элементов: подсветка строки */
.notes-enabled.costing-detail tbody tr:not(.note-row):hover > td,
.notes-enabled.costing-detail tbody tr.note-present > td,
.notes-enabled.costing-detail tbody tr.note-selected > td { box-shadow: inset 0 1px 0 #e74c3c, inset 0 -1px 0 #e74c3c; }
.notes-enabled.costing-detail tbody tr.note-present > td,
.notes-enabled.costing-detail tbody tr.note-selected > td { background: #fbe3e1; }
.notes-enabled.costing-detail tbody tr:not(.note-row):hover > td:first-child,
.notes-enabled.costing-detail tbody tr.note-present > td:first-child,
.notes-enabled.costing-detail tbody tr.note-selected > td:first-child { box-shadow: inset 1px 0 0 #e74c3c, inset 0 1px 0 #e74c3c, inset 0 -1px 0 #e74c3c; }
.notes-enabled.costing-detail tbody tr:not(.note-row):hover > td:last-child,
.notes-enabled.costing-detail tbody tr.note-present > td:last-child,
.notes-enabled.costing-detail tbody tr.note-selected > td:last-child { box-shadow: inset -1px 0 0 #e74c3c, inset 0 1px 0 #e74c3c, inset 0 -1px 0 #e74c3c; }

/* Редактор замечания */
.note-editor { border: 1px solid #e74c3c; border-radius: 4px; padding: 8px; margin: 4px 0 8px; }
.note-editor-title { display: inline-block; border: 1px solid #e74c3c; color: #e74c3c; border-radius: 3px; padding: 1px 6px; font-size: 12px; margin-bottom: 6px; }
.note-editor textarea { width: 100%; border: 1px solid #ddd; border-radius: 4px; padding: 6px; font-size: 13px; box-sizing: border-box; }
.note-editor-text { white-space: pre-wrap; font-size: 13px; color: #555; border: 1px dashed #ddd; border-radius: 4px; padding: 6px; }
.note-editor-actions { display: flex; gap: 8px; margin-top: 6px; }
.comments-section { margin-top: 20px; }
.comment { padding: 8px 0; border-bottom: 1px solid #f0f0f0; font-size: 13px; }
.comment .author { font-weight: 500; margin-bottom: 2px; }
.comment .text { color: #555; }
.comment .meta { font-size: 11px; color: #999; margin-top: 2px; }
.add-btn { background: #27ae60; color: #fff; border: none; border-radius: 50%; width: 32px; height: 32px; font-size: 18px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.empty-state { color: #999; text-align: center; padding: 40px; font-size: 14px; }
.error-message { color: #e74c3c; font-size: 13px; margin-top: 8px; }

.spinner {
    width: 14px; height: 14px;
    border: 2px solid rgba(52, 152, 219, 0.25);
    border-top-color: #3498db;
    border-radius: 50%;
    display: inline-block;
    animation: spin 0.8s linear infinite;
    flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.import-status { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 12px; color: #555; }
.import-status.ok { color: #27ae60; }
.import-status.err { color: #e74c3c; }
.add-btn.disabled { opacity: 0.45; pointer-events: none; }

/* ===== Header: notifications ===== */
.header-actions { display: flex; align-items: center; gap: 16px; }
.notification-wrapper { position: relative; }
.notification-bell { position: relative; border: none; background: transparent; color: #fff; font-size: 18px; cursor: pointer; padding: 4px; }
.notification-badge { position: absolute; top: -2px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: #e74c3c; color: #fff; font-size: 10px; line-height: 16px; text-align: center; }
.notification-dropdown { position: absolute; top: 32px; right: 0; width: 340px; max-height: 420px; overflow-y: auto; background: #fff; color: #1a1a1a; border: 1px solid #ddd; border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); z-index: 100; }
.notification-dropdown-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid #eee; }
.notification-read-all { border: none; background: none; color: #3498db; cursor: pointer; font-size: 12px; }
.notification-empty { padding: 16px; color: #888; font-size: 13px; text-align: center; }
.notification-item { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; cursor: pointer; }
.notification-item:hover { background: #f8f9fa; }
.notification-item.unread { border-left: 3px solid #3498db; background: #f4f9fd; }
.notification-item.read { opacity: 0.75; }
.notification-title { font-weight: 600; font-size: 13px; margin-bottom: 3px; }
.notification-message { font-size: 12px; color: #555; white-space: pre-wrap; }
.notification-date { font-size: 11px; color: #999; margin-top: 4px; }

/* ===== Doctor comments ===== */
.doctor-comments { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.doctor-comment { border: 1px solid #ddd; border-radius: 4px; padding: 10px 12px; background: #fff; }
.doctor-comment.pending { border-color: #f39c12; background: #fffaf0; }
.doctor-comment.accepted { border-color: #27ae60; background: #f4fbf6; }
.doctor-comment-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; font-size: 13px; }
.doctor-comment-target { color: #555; font-size: 12px; }
.doctor-comment-date { color: #999; font-size: 11px; margin-left: auto; }
.doctor-comment-status { font-size: 11px; padding: 1px 6px; border-radius: 3px; background: #eee; color: #555; }
.doctor-comment-text { margin-top: 6px; font-size: 13px; white-space: pre-wrap; }
.doctor-comment-decision { margin-top: 6px; font-size: 11px; color: #27ae60; }
.doctor-comment-actions { display: flex; gap: 8px; margin-top: 8px; }
.review-status { display: inline-flex; align-items: center; padding: 6px 12px; border-radius: 4px; background: #eafaf1; color: #27ae60; font-size: 12px; font-weight: 600; }
/* Disabled buttons must be visually distinct, including warning buttons. */
.btn:disabled,
.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-warning:disabled {
    background: #bdc3c7;
    color: #fff;
}
/* ===== Review status dropdown ===== */
.review-status-wrapper { position: relative; }
.review-status-dropdown { position: absolute; top: 36px; right: 0; width: 360px; max-height: 420px; overflow-y: auto; background: #fff; color: #1a1a1a; border: 1px solid #ddd; border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); z-index: 120; }
.review-status-dropdown-header { display: flex; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid #eee; font-size: 12px; }
.review-status-empty { padding: 14px; color: #888; font-size: 13px; text-align: center; }
.review-status-item { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; border-bottom: 1px solid #f0f0f0; font-size: 12px; }
.review-status-item.reviewed { color: #1e8449; background: #f4fbf6; }
.review-status-item.not-reviewed { color: #777; }