/* ============================================================
   НейроТест — Система нейропсихологического обследования
   Main Stylesheet
   ============================================================ */

/* --- CSS Variables --- */
:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --primary-light: #e8f0fe;
  --accent: #34a853;
  --accent-dark: #2d9249;
  --danger: #ea4335;
  --danger-light: #fce8e6;
  --warning: #fbbc04;
  --warning-light: #fef7e0;
  --text: #202124;
  --text-secondary: #5f6368;
  --text-muted: #9aa0a6;
  --bg: #f8f9fa;
  --white: #ffffff;
  --border: #dadce0;
  --border-light: #e8eaed;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.08);
  --shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.1), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.12);
  --radius: 8px;
  --radius-lg: 12px;
  --sidebar-width: 260px;
  --header-height: 56px;
  --transition: .2s ease;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

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

img { max-width: 100%; display: block; }

h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.4rem; font-weight: 600; }
h3 { font-size: 1.15rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; }

/* --- Utility --- */
.hidden { display: none !important; }
.text-muted { color: var(--text-secondary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--accent); }
.text-center { text-align: center; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .55rem 1.2rem;
  font-size: .9rem;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-secondary {
  background: var(--white);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg); }

.btn-success {
  background: var(--accent);
  color: var(--white);
}
.btn-success:hover:not(:disabled) { background: var(--accent-dark); }

.btn-danger {
  background: var(--danger);
  color: var(--white);
}
.btn-danger:hover:not(:disabled) { background: #c5221f; }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover:not(:disabled) { background: var(--primary-light); }

.btn-sm { padding: .35rem .75rem; font-size: .82rem; }
.btn-lg { padding: .7rem 1.6rem; font-size: 1rem; }
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
}
.btn-block { display: flex; width: 100%; }

/* --- Forms --- */
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  margin-bottom: .3rem;
  font-size: .88rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.form-control {
  width: 100%;
  padding: .55rem .75rem;
  font-size: .93rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,.15);
}
.form-control::placeholder { color: var(--text-muted); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
}

.form-error {
  color: var(--danger);
  font-size: .82rem;
  margin-top: .25rem;
}

.form-hint {
  color: var(--text-muted);
  font-size: .8rem;
  margin-top: .2rem;
}

/* --- Login Page --- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e8f0fe 0%, #f8f9fa 100%);
  padding: 1rem;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: 2.5rem 2rem;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo .logo-icon {
  width: 56px;
  height: 56px;
  background: var(--primary);
  color: var(--white);
  border-radius: var(--radius-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin-bottom: .75rem;
}

.login-logo h1 {
  font-size: 1.4rem;
  color: var(--text);
}

.login-logo p {
  color: var(--text-secondary);
  font-size: .88rem;
  margin-top: .25rem;
}

.login-card .alert {
  margin-bottom: 1rem;
}

/* --- App Layout --- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--white);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: .75rem;
}

.sidebar-header .logo-icon {
  width: 38px;
  height: 38px;
  background: var(--primary);
  color: var(--white);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.sidebar-header .logo-text h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.sidebar-header .logo-text small {
  font-size: .7rem;
  color: var(--text-muted);
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: .75rem 0;
  overflow-y: auto;
}

.nav-section-title {
  padding: .5rem 1.25rem .25rem;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1.25rem;
  color: var(--text-secondary);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  border-left: 3px solid transparent;
  text-decoration: none;
}
.nav-item:hover {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  border-left-color: var(--primary);
}
.nav-item .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 1rem;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-light);
}

.user-info {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  flex-shrink: 0;
}

.user-details {
  flex: 1;
  min-width: 0;
}

.user-details .user-name {
  font-size: .88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-details .user-role {
  font-size: .75rem;
  color: var(--text-muted);
}

.btn-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: .25rem;
  font-size: 1rem;
  transition: color var(--transition);
}
.btn-logout:hover { color: var(--danger); }

/* --- Main Content --- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Top Bar --- */
.topbar {
  height: var(--header-height);
  background: var(--white);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .85rem;
  color: var(--text-muted);
}
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb .separator { color: var(--border); }

/* --- Page Content --- */
.page-content {
  flex: 1;
  padding: 1.5rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-header h1 {
  font-size: 1.5rem;
}

.page-header .page-actions {
  display: flex;
  gap: .5rem;
}

/* --- Cards --- */
.card {
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

.card-header h3 {
  font-size: 1rem;
}

.card-body {
  padding: 1.25rem;
}

.card-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--border-light);
  background: var(--bg);
}

/* --- Stat Cards --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: #e6f4ea; color: var(--accent); }
.stat-icon.orange { background: var(--warning-light); color: #e37400; }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }

.stat-info .stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-info .stat-label {
  font-size: .82rem;
  color: var(--text-secondary);
}

/* --- Tables --- */
.table-container {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

.data-table th {
  text-align: left;
  padding: .75rem 1rem;
  font-weight: 600;
  font-size: .82rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .03em;
  background: var(--bg);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.data-table td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: #f1f3f4;
}

.data-table tbody tr {
  cursor: pointer;
  transition: background var(--transition);
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .6rem;
  font-size: .75rem;
  font-weight: 600;
  border-radius: 999px;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: #e6f4ea; color: #1e8e3e; }
.badge-warning { background: var(--warning-light); color: #e37400; }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-neutral { background: #e8eaed; color: var(--text-secondary); }

/* --- Alerts --- */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .88rem;
  display: flex;
  align-items: flex-start;
  gap: .5rem;
}

.alert-info { background: var(--primary-light); color: var(--primary-dark); }
.alert-success { background: #e6f4ea; color: #1e8e3e; }
.alert-warning { background: var(--warning-light); color: #e37400; }
.alert-danger { background: var(--danger-light); color: var(--danger); }

/* --- Search --- */
.search-box {
  position: relative;
}

.search-box input {
  padding-left: 2.2rem;
}

.search-box .search-icon {
  position: absolute;
  left: .75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: .9rem;
  pointer-events: none;
}

/* --- Tabs --- */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border-light);
  margin-bottom: 1.5rem;
  gap: 0;
}

.tab-btn {
  padding: .6rem 1.25rem;
  font-size: .9rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* --- Patient Card --- */
.patient-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  transition: box-shadow var(--transition);
  cursor: pointer;
}
.patient-card:hover {
  box-shadow: var(--shadow);
}

.patient-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.patient-info {
  flex: 1;
  min-width: 0;
}

.patient-name {
  font-weight: 600;
  font-size: .95rem;
}

.patient-meta {
  font-size: .82rem;
  color: var(--text-secondary);
}

/* --- Test Selection Grid --- */
.test-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.test-card {
  border: 2px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1rem;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  display: flex;
  align-items: flex-start;
  gap: .75rem;
}
.test-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}
.test-card.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.test-card .test-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.test-card .test-name {
  font-weight: 600;
  font-size: .92rem;
}

.test-card .test-category {
  font-size: .78rem;
  color: var(--text-secondary);
}

.test-card .test-check {
  margin-left: auto;
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
}
.test-card.selected .test-check {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

/* --- Test Runner Overlay --- */
.test-overlay {
  position: fixed;
  inset: 0;
  background: var(--white);
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.test-overlay-header {
  height: 48px;
  background: var(--text);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  flex-shrink: 0;
}

.test-overlay-header .test-title {
  font-size: .95rem;
  font-weight: 600;
}

.test-overlay-header .test-progress {
  font-size: .82rem;
  color: rgba(255,255,255,.7);
}

.test-overlay-header .btn-close-test {
  background: rgba(255,255,255,.15);
  border: none;
  color: var(--white);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: background var(--transition);
}
.test-overlay-header .btn-close-test:hover {
  background: rgba(255,255,255,.25);
}

.test-overlay-body {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.test-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

/* --- Results --- */
.result-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.result-metric {
  text-align: center;
  padding: 1rem;
  background: var(--bg);
  border-radius: var(--radius);
}

.result-metric .metric-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
}

.result-metric .metric-label {
  font-size: .82rem;
  color: var(--text-secondary);
}

.result-metric .metric-norm {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .15rem;
}

.interpretation-block {
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-top: 1rem;
}

.interpretation-block h4 {
  margin-bottom: .5rem;
}

/* --- Conclusion / Report --- */
.conclusion-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 300px;
  padding: 1.25rem;
  font-family: inherit;
  font-size: .93rem;
  line-height: 1.7;
}

.conclusion-editor:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,.15);
}

.conclusion-editor h2 {
  font-size: 1.3rem;
  margin: 0 0 .5rem;
}

.conclusion-editor h3 {
  font-size: 1.1rem;
  margin: 1rem 0 .5rem;
  color: var(--text);
}

.conclusion-editor h4 {
  font-size: 1rem;
  margin: .75rem 0 .25rem;
  color: var(--primary);
}

.conclusion-editor table {
  width: 100%;
  border-collapse: collapse;
  margin: .5rem 0;
}

.conclusion-editor td {
  padding: 4px 8px;
  vertical-align: top;
}

.conclusion-editor hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: .75rem 0;
}

.conclusion-editor ol,
.conclusion-editor ul {
  margin: .5rem 0;
  padding-left: 1.5rem;
}

.conclusion-editor li {
  margin-bottom: .25rem;
}

.conclusion-editor p {
  margin: .25rem 0;
}

.conclusion-section {
  margin-bottom: 1.5rem;
}

.conclusion-section h3 {
  margin-bottom: .75rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border-light);
}

/* --- Chart container --- */
.chart-container {
  position: relative;
  width: 100%;
  height: 350px;
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: .4;
}

.empty-state h3 {
  margin-bottom: .5rem;
  color: var(--text);
}

/* --- Loading / Spinner --- */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 1rem;
  color: var(--text-secondary);
}

/* --- Modal --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn .15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow: auto;
  animation: slideUp .2s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.modal-header h3 { font-size: 1.1rem; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: .25rem;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
}

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.toast {
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: .75rem 1rem;
  min-width: 280px;
  max-width: 400px;
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  font-size: .88rem;
  animation: slideIn .3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(50px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast.toast-exit {
  animation: slideOut .25s ease forwards;
}

@keyframes slideOut {
  to { opacity: 0; transform: translateX(50px); }
}

.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-success .toast-icon { color: var(--accent); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: #e37400; }
.toast-info .toast-icon { color: var(--primary); }

.toast-message { flex: 1; }
.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .9rem;
  padding: 0;
  line-height: 1;
}

/* --- Progress Bar --- */
.progress {
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width .4s ease;
}

.progress-bar.green { background: var(--accent); }

/* --- Session Test Queue --- */
.test-queue {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.test-queue-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  font-size: .9rem;
}

.test-queue-item .queue-status {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: .8rem;
}

.test-queue-item.pending .queue-status { background: var(--border-light); color: var(--text-muted); }
.test-queue-item.active .queue-status { background: var(--primary); color: var(--white); }
.test-queue-item.done .queue-status { background: var(--accent); color: var(--white); }

.test-queue-item .queue-name { flex: 1; font-weight: 500; }

/* --- Dynamics / History --- */
.timeline {
  position: relative;
  padding-left: 2rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: .6rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-light);
}

.timeline-item {
  position: relative;
  padding-bottom: 1.5rem;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.6rem;
  top: .3rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--white);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.timeline-date {
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: .25rem;
}

.timeline-content {
  background: var(--bg);
  border-radius: var(--radius);
  padding: .75rem 1rem;
}

/* --- Print Styles --- */
@media print {
  body {
    background: white !important;
    color: black !important;
    font-size: 11pt;
    line-height: 1.5;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  * {
    box-shadow: none !important;
  }

  .sidebar,
  .topbar,
  .no-print,
  .btn,
  .toast-container,
  .page-header,
  .card-header.no-print,
  .page-actions {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
  }

  #app-layout {
    display: block !important;
  }

  .page-content {
    padding: 0;
    max-width: none;
  }

  .card {
    border: none;
    box-shadow: none;
    margin: 0;
    break-inside: auto;
  }

  .card-body {
    padding: 0;
  }

  /* Conclusion editor — contenteditable area */
  .conclusion-editor {
    border: none;
    padding: 0;
    min-height: auto;
  }

  .conclusion-editor[contenteditable] {
    cursor: default;
  }

  /* Generated report heading */
  .conclusion-editor h2 {
    font-size: 14pt;
    margin: 0 0 6pt;
    text-align: center;
    color: black !important;
  }

  .conclusion-editor h3 {
    font-size: 12pt;
    font-weight: bold;
    margin: 14pt 0 6pt;
    color: black !important;
    page-break-after: avoid;
    border-bottom: 0.5pt solid #999;
    padding-bottom: 3pt;
  }

  .conclusion-editor h4 {
    font-size: 10.5pt;
    font-weight: bold;
    margin: 10pt 0 4pt;
    color: #333 !important;
    page-break-after: avoid;
  }

  .conclusion-editor table {
    width: 100%;
    border-collapse: collapse;
    margin: 6pt 0;
    page-break-inside: avoid;
  }

  .conclusion-editor td {
    padding: 2pt 6pt;
    vertical-align: top;
    font-size: 10pt;
  }

  .conclusion-editor td strong {
    white-space: nowrap;
  }

  .conclusion-editor hr {
    border: none;
    border-top: 0.5pt solid #999;
    margin: 8pt 0;
  }

  .conclusion-editor ol,
  .conclusion-editor ul {
    margin: 6pt 0;
    padding-left: 18pt;
  }

  .conclusion-editor li {
    margin-bottom: 3pt;
    font-size: 10pt;
  }

  .conclusion-editor p {
    margin: 3pt 0;
    font-size: 10pt;
    orphans: 3;
    widows: 3;
  }

  /* Override inline color styles for score labels */
  .conclusion-editor p[style*="color:#666"],
  .conclusion-editor p[style*="color: #666"] {
    color: #555 !important;
    font-size: 9pt !important;
  }

  /* Centered subtitle in report header */
  .conclusion-editor p[style*="text-align:center"] {
    color: #444 !important;
  }

  /* Keep report sections together */
  .conclusion-editor h3 + *,
  .conclusion-editor h4 + * {
    page-break-before: avoid;
  }

  /* Recommendations list — keep together */
  .conclusion-editor ol {
    page-break-inside: avoid;
  }

  /* Print-visible header and footer */
  .print-header {
    display: block !important;
    text-align: center;
    margin-bottom: 12pt;
    padding-bottom: 8pt;
    border-bottom: 1.5pt solid #333;
  }

  .print-header h1 {
    font-size: 14pt;
    margin: 0 0 2pt;
  }

  .print-header p {
    font-size: 9pt;
    color: #666;
    margin: 0;
  }

  .print-footer {
    display: block !important;
    margin-top: 18pt;
    padding-top: 8pt;
    border-top: 0.5pt solid #ccc;
    font-size: 9pt;
    color: #444;
    page-break-inside: avoid;
  }

  .print-footer p {
    margin: 2pt 0;
  }

  /* A4 page setup */
  @page {
    margin: 1.5cm 2cm;
    size: A4;
  }

  @page :first {
    margin-top: 2cm;
  }

  /* Links should not show URLs */
  a[href]::after {
    content: none !important;
  }
}

.print-header,
.print-footer {
  display: none;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .form-row-3 {
    grid-template-columns: 1fr;
  }
  .topbar .btn-menu {
    display: flex;
  }
}

@media (min-width: 1025px) {
  .topbar .btn-menu {
    display: none;
  }
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- Chip / Tag --- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .6rem;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 500;
}

.chip-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .85rem;
  padding: 0;
  line-height: 1;
}

/* --- Tooltip --- */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--white);
  padding: .3rem .6rem;
  border-radius: 4px;
  font-size: .75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
}

[data-tooltip]:hover::after { opacity: 1; }

/* --- Category headers in test grid --- */
.category-header {
  grid-column: 1 / -1;
  font-size: .82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  padding: .5rem 0;
  border-bottom: 1px solid var(--border-light);
  margin-top: .5rem;
}
.category-header:first-child { margin-top: 0; }

/* --- Select patient dropdown style --- */
.patient-select-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .75rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}
.patient-select-item:hover {
  background: var(--bg);
}

/* --- Conclusion print area --- */
.conclusion-print-area {
  line-height: 1.8;
}
.conclusion-print-area h2 { margin: 1rem 0 .5rem; }
.conclusion-print-area p { margin-bottom: .75rem; }
.conclusion-print-area table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}
.conclusion-print-area table th,
.conclusion-print-area table td {
  border: 1px solid var(--border);
  padding: .5rem .75rem;
  text-align: left;
  font-size: .88rem;
}
.conclusion-print-area table th {
  background: var(--bg);
  font-weight: 600;
}

/* compact results */
.res-hero{border-left:4px solid #1a73e8}
.res-kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(110px,1fr));gap:8px;margin-top:10px}
.res-kpi{background:#f5f7fa;border-radius:8px;padding:8px 10px;text-align:center}
.res-kpi-v{font-size:18px;font-weight:700;font-variant-numeric:tabular-nums;color:#1a73e8}
.res-kpi-l{font-size:11px;color:#666;margin-top:2px;text-transform:uppercase;letter-spacing:.03em}
.res-auto{margin-top:10px;padding:9px 12px;background:#fffde7;border:1px solid #ffe082;border-radius:8px;font-size:13.5px;line-height:1.45}
.res-details{margin-top:8px}
.res-details summary{cursor:pointer;font-size:13px;color:#1a73e8;padding:4px 0}
.res-full{white-space:pre-wrap;font-size:12.5px;line-height:1.5;background:#fafafa;border:1px solid #eee;border-radius:8px;padding:10px 12px;margin-top:6px;font-family:inherit}
.badge-danger{background:#e53935;color:#fff}
