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

:root {
    --primary: #0891b2;
    --primary-dark: #0e7490;
    --primary-light: #e0f7fa;
    --primary-50: #ecfeff;
    --secondary: #0f172a;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --bg: #f8fafc;
    --bg-white: #ffffff;
    --border: #e2e8f0;
    --success: #22c55e;
    --success-bg: #dcfce7;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --info: #3b82f6;
    --info-bg: #dbeafe;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --sidebar-width: 260px;
    --font: 'Vazirmatn', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

a {
    text-decoration: none;
    color: inherit;
}

.sidebar {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--secondary);
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 800;
}

.logo-text {
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
}

.sidebar-role {
    display: block;
    margin-top: 8px;
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 500;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: rgba(255,255,255,0.7);
    font-size: 0.93rem;
    font-weight: 500;
    transition: all 0.2s;
    border-right: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
    border-right-color: var(--primary);
}

.nav-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    margin-bottom: 8px;
}

.user-name {
    font-size: 0.88rem;
    color: rgba(255,255,255,0.8);
}

.logout-btn {
    color: var(--danger) !important;
    font-size: 0.85rem;
}

.main-content {
    margin-right: var(--sidebar-width);
    min-height: 100vh;
}

.top-bar {
    background: var(--bg-white);
    padding: 20px 32px;
    border-bottom: 1px solid var(--border);
}

.page-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}

.content-area {
    padding: 24px 32px;
}

.flash-messages {
    padding: 0 32px;
    margin-top: 16px;
}

.alert {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: 0.9rem;
    font-weight: 500;
}

.alert-success {
    background: var(--success-bg);
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-danger {
    background: var(--danger-bg);
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: var(--warning-bg);
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert-info {
    background: var(--info-bg);
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.auth-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--bg) 100%);
    padding: 20px;
}

.auth-layout .flash-messages {
    width: 100%;
    max-width: 440px;
    padding: 0;
    margin-bottom: 12px;
}

.auth-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 440px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo .logo {
    justify-content: center;
    margin-bottom: 8px;
}

.auth-logo p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

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

.form-label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.93rem;
    color: var(--text);
    background: var(--bg);
    transition: border-color 0.2s;
    direction: rtl;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(8,145,178,0.1);
}

select.form-input {
    cursor: pointer;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-align: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #16a34a;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

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

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-outline {
    border: 2px solid var(--border);
    background: transparent;
    color: var(--text);
}

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

.btn-sm {
    padding: 6px 14px;
    font-size: 0.82rem;
}

.btn-block {
    width: 100%;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    background: var(--bg);
}

.card-body {
    padding: 20px;
}

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

.stat-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-number {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--primary);
    display: block;
    line-height: 1.2;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin-top: 4px;
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead {
    background: var(--bg);
}

th {
    padding: 12px 16px;
    text-align: right;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

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

tr:hover {
    background: var(--primary-50);
}

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-normal {
    background: var(--info-bg);
    color: #1e40af;
}

.badge-emergency {
    background: var(--warning-bg);
    color: #92400e;
}

.badge-critical {
    background: var(--danger-bg);
    color: #991b1b;
}

.badge-status {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.badge-approved {
    background: var(--success-bg);
    color: #166534;
}

.badge-pending {
    background: var(--warning-bg);
    color: #92400e;
}

.timeline {
    display: flex;
    align-items: center;
    gap: 0;
    margin: 16px 0;
    padding: 16px 0;
    overflow-x: auto;
}

.timeline-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    flex: 1;
    min-width: 100px;
}

.timeline-step::before {
    content: '';
    position: absolute;
    top: 16px;
    right: 50%;
    width: 100%;
    height: 3px;
    background: var(--border);
    z-index: 0;
}

.timeline-step:first-child::before {
    display: none;
}

.timeline-step.completed::before {
    background: var(--success);
}

.timeline-step.active::before {
    background: var(--primary);
}

.timeline-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-light);
    z-index: 1;
    transition: all 0.3s;
}

.timeline-step.completed .timeline-dot {
    background: var(--success);
    color: white;
}

.timeline-step.active .timeline-dot {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 0 4px rgba(8,145,178,0.2);
}

.timeline-label {
    font-size: 0.72rem;
    color: var(--text-light);
    margin-top: 8px;
    text-align: center;
    white-space: nowrap;
}

.timeline-step.completed .timeline-label,
.timeline-step.active .timeline-label {
    color: var(--text);
    font-weight: 600;
}

.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.search-bar .form-input {
    flex: 1;
}

.filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-tab {
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--bg-white);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.filter-tab:hover,
.filter-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.case-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s;
}

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

.case-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.case-id {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.95rem;
}

.case-filename {
    color: var(--text-secondary);
    font-size: 0.88rem;
}

.case-date {
    color: var(--text-light);
    font-size: 0.82rem;
}

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

.detail-item {
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.detail-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.detail-value {
    font-weight: 600;
    font-size: 0.95rem;
}

.report-section {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    border-right: 4px solid var(--primary);
}

.report-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text);
}

.report-content {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.8;
    white-space: pre-wrap;
}

#viewer-3d {
    width: 100%;
    height: 500px;
    background: #1a1a2e;
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
    margin-bottom: 20px;
}

.viewer-toolbar {
    position: absolute;
    bottom: 12px;
    right: 12px;
    left: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    z-index: 10;
    background: rgba(15,23,42,0.85);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    backdrop-filter: blur(8px);
}

.viewer-btn {
    padding: 6px 14px;
    border-radius: 6px;
    font-family: var(--font);
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.1);
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
}

.viewer-btn:hover {
    background: rgba(255,255,255,0.2);
}

.viewer-btn.active {
    background: var(--primary);
    border-color: var(--primary);
}

.viewer-separator {
    width: 1px;
    background: rgba(255,255,255,0.15);
    margin: 0 4px;
}

.viewer-slider {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #fff;
    font-size: 0.75rem;
}

.viewer-slider input[type="range"] {
    width: 80px;
    accent-color: var(--primary);
}

.viewer-slider input[type="color"] {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.viewer-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255,255,255,0.6);
    font-size: 1rem;
    text-align: center;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
}

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

.empty-state p {
    margin-bottom: 16px;
    font-size: 1rem;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.pagination a {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    color: var(--text);
    transition: all 0.2s;
}

.pagination a:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.auth-link {
    text-align: center;
    margin-top: 20px;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.auth-link a {
    color: var(--primary);
    font-weight: 600;
}

.pending-card {
    text-align: center;
    padding: 48px;
}

.pending-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.pending-card h2 {
    margin-bottom: 12px;
    color: var(--text);
}

.pending-card p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.inline-form {
    display: inline;
}

.actions-cell {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: relative;
        height: auto;
    }

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

    .content-area {
        padding: 16px;
    }

    .flash-messages {
        padding: 0 16px;
    }

    .top-bar {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .timeline {
        flex-wrap: wrap;
    }

    .auth-card {
        padding: 24px;
    }
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.93rem;
    color: var(--text);
    background: var(--bg);
    transition: border-color 0.2s;
    direction: rtl;
}

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

.form-control-sm {
    padding: 6px 10px;
    font-size: 0.82rem;
}

select.form-control {
    cursor: pointer;
}

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

.tab {
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--bg-white);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover,
.tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-secondary {
    background: #64748b;
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

.badge-success {
    background: var(--success-bg);
    color: #166534;
}

.badge-warning {
    background: var(--warning-bg);
    color: #92400e;
}

.text-center {
    text-align: center;
}

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

.info-item {
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.info-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 4px;
}

.info-value {
    font-weight: 600;
    font-size: 0.95rem;
}

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

.dashboard-actions {
    margin-bottom: 24px;
}

.case-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.case-info {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.case-status {
    color: var(--primary);
    font-weight: 500;
    font-size: 0.88rem;
}

/* ── Demo login & enhanced dashboards ── */
.auth-card-wide { max-width: 720px; }

.demo-login-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.demo-login-section h3 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.demo-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.demo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.demo-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    transition: all 0.2s;
    font-size: 0.82rem;
}

.demo-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.demo-card code {
    font-size: 0.72rem;
    color: var(--text-secondary);
    direction: ltr;
    text-align: left;
}

.demo-card small { color: var(--text-light); }

.demo-role {
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--primary);
}

.demo-admin { border-right: 3px solid #ef4444; }
.demo-patient { border-right: 3px solid #3b82f6; }
.demo-doctor { border-right: 3px solid #22c55e; }
.demo-expert { border-right: 3px solid #8b5cf6; }
.demo-secretary { border-right: 3px solid #f59e0b; }
.demo-operator { border-right: 3px solid #06b6d4; }

.auth-public-links { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.link-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.pill { padding: 6px 14px; border-radius: 999px; color: #fff; font-size: 0.85rem; }
.pill-blue { background: #3b82f6; }
.pill-purple { background: #8b5cf6; }
.pill-teal { background: #06b6d4; }
.pill-green { background: #22c55e; }

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

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.panel-title { font-size: 1.05rem; font-weight: 600; margin-bottom: 12px; }

.dashboard-grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.workflow-stats-list { display: flex; flex-direction: column; gap: 8px; }
.wf-stat-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

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

.activity-list { list-style: none; }
.activity-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.activity-action { font-weight: 500; display: block; }
.activity-meta { font-size: 0.82rem; color: var(--text-secondary); }

.stat-link {
    display: block;
    margin-top: 8px;
    font-size: 0.82rem;
    color: var(--primary);
}

.stat-primary { border-top: 3px solid var(--primary); }
.stat-warning { border-top: 3px solid var(--warning); }
.stat-info { border-top: 3px solid var(--info); }
.stat-success { border-top: 3px solid var(--success); }

.info-banner {
    background: var(--info-bg);
    color: #1e40af;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.muted { color: var(--text-secondary); font-size: 0.9rem; }

.workflow-panel {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.next-action-banner {
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 0.9rem;
}

.workflow-track {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.wf-step {
    flex: 1 1 100px;
    min-width: 90px;
    padding: 10px;
    border-radius: var(--radius-sm);
    text-align: center;
    border: 1px solid var(--border);
    opacity: 0.5;
}

.wf-step.wf-done { opacity: 1; background: var(--success-bg); border-color: var(--success); }
.wf-step.wf-current { opacity: 1; background: var(--info-bg); border-color: var(--info); box-shadow: var(--shadow-md); }
.wf-icon { font-size: 1.3rem; }
.wf-label { display: block; font-size: 0.78rem; font-weight: 600; }
.wf-role { font-size: 0.68rem; color: var(--text-secondary); }

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

.tool-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: all 0.2s;
    border: 1px solid var(--border);
}

.tool-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.tool-icon { font-size: 2rem; display: block; margin-bottom: 10px; }
.tool-card h3 { font-size: 1rem; margin-bottom: 6px; }
.tool-card p { font-size: 0.85rem; color: var(--text-secondary); }

.case-card-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-white);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    border: 1px solid var(--border);
}

.cases-list.compact { margin-top: 12px; }

.viewer-container-lg {
    width: 100%;
    height: 520px;
    border-radius: var(--radius);
    overflow: hidden;
    background: #1a1a2e;
}

.viewer-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.analyzer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 16px;
}

.analyzer-tool {
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.result-box {
    margin-top: 10px;
    padding: 10px;
    background: var(--success-bg);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.check-list { padding-right: 20px; }
.steps-list { padding-right: 24px; line-height: 2; }

.table-wrap { overflow-x: auto; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

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

/* ── Finder (global search) ── */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.finder {
    position: relative;
    flex: 1;
    max-width: 420px;
    min-width: 220px;
}

.finder-input {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-family: var(--font);
    font-size: 0.88rem;
    background: var(--bg-white);
}

.finder-input:focus { outline: none; border-color: var(--primary); }

.finder-results {
    display: none;
    position: absolute;
    top: 110%;
    right: 0;
    left: 0;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    max-height: 360px;
    overflow-y: auto;
}

.finder-item {
    display: block;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text);
}

.finder-item:hover { background: var(--bg); }

/* ── Study viewer (NiiVue) ── */
.viewer-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 16px;
}

.mpr-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 6px;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    min-height: 600px;
}

.mpr-cell {
    position: relative;
    background: #0a0a14;
    min-height: 295px;
}

.mpr-cell canvas { width: 100%; height: 100%; display: block; }

.mpr-label {
    position: absolute;
    top: 6px;
    right: 8px;
    z-index: 5;
    color: #06b6d4;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(0,0,0,0.5);
    padding: 2px 8px;
    border-radius: 4px;
}

.seg-sidebar {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    align-self: start;
    position: sticky;
    top: 16px;
}

.seg-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.seg-swatch { width: 16px; height: 16px; border-radius: 4px; flex-shrink: 0; }
.seg-name { flex: 1; font-size: 0.85rem; }
.seg-vol { font-size: 0.72rem; color: var(--text-secondary); }
.seg-row input[type=range] { width: 70px; }

.viewer-tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.viewer-tab {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-white);
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.82rem;
}
.viewer-tab.active { background: var(--primary); color: #fff; border-color: transparent; }

.measure-toolbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.measure-result { margin-top: 10px; font-size: 0.85rem; }

@media (max-width: 900px) {
    .viewer-layout { grid-template-columns: 1fr; }
    .seg-sidebar { position: static; }
}

/* ── Upload drop zone ── */
.drop-zone {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg);
}

.drop-zone:hover, .drop-zone.drag-active {
    border-color: var(--primary);
    background: var(--primary-50);
}

.drop-zone .drop-icon { font-size: 2.4rem; display: block; margin-bottom: 8px; }
.drop-zone input[type=file] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-hints {
    margin-top: 24px;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.upload-hints h4 { margin-bottom: 8px; }
.upload-hints ul { padding-right: 20px; font-size: 0.88rem; line-height: 2; }
