:root {
    --bg-main: #f5f7fb;
    --bg-secondary: #eef3fb;
    --bg-soft: rgba(255, 255, 255, 0.55);
    --bg-white-strong: rgba(255, 255, 255, 0.78);
    --bg-white-solid: #ffffff;
    --border-soft: rgba(255, 255, 255, 0.65);
    --border-light: rgba(203, 213, 225, 0.9);
    --border-mid: rgba(148, 163, 184, 0.18);
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --text-light: #94a3b8;
    --accent: #4f7cff;
    --accent-hover: #3f6df0;
    --accent-soft: rgba(79, 124, 255, 0.12);
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --shadow-lg: 0 20px 60px rgba(31, 41, 55, 0.12);
    --shadow-md: 0 12px 35px rgba(31, 41, 55, 0.08);
    --shadow-sm: 0 8px 24px rgba(31, 41, 55, 0.06);
    --blur: blur(20px);
    --radius-xxl: 32px;
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 12px;
    --container-width: 1328px;
    --transition: 0.2s ease;
}

html[data-theme="dark"] {
    --bg-main: #0b1220;
    --bg-secondary: #111827;
    --bg-soft: rgba(15, 23, 42, 0.78);
    --bg-white-strong: rgba(17, 24, 39, 0.92);
    --bg-white-solid: #111827;
    --border-soft: rgba(51, 65, 85, 0.72);
    --border-light: rgba(71, 85, 105, 0.85);
    --border-mid: rgba(148, 163, 184, 0.22);
    --text-main: #e5eefc;
    --text-muted: #a8b3c7;
    --text-light: #94a3b8;
    --accent: #7aa2ff;
    --accent-hover: #8db0ff;
    --accent-soft: rgba(122, 162, 255, 0.16);
    --success: #22c55e;
    --danger: #f87171;
    --warning: #f59e0b;
    --shadow-lg: 0 20px 60px rgba(2, 6, 23, 0.45);
    --shadow-md: 0 12px 35px rgba(2, 6, 23, 0.35);
    --shadow-sm: 0 8px 24px rgba(2, 6, 23, 0.28);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, Arial, sans-serif;
    color: var(--text-main);
    background:
        radial-gradient(circle at top left, rgba(79, 124, 255, 0.18), transparent 28%),
        radial-gradient(circle at bottom right, rgba(88, 208, 255, 0.18), transparent 30%),
        linear-gradient(180deg, var(--bg-main) 0%, var(--bg-secondary) 100%);
    transition: background var(--transition), color var(--transition);
}

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

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

button,
input,
textarea,
select {
    font: inherit;
}

.container {
    width: 100%;
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 20px;
}

.glass-card {
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    box-shadow: var(--shadow-lg);
}

.page-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 16px 0;
    background: color-mix(in srgb, var(--bg-main) 80%, transparent);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.7);
}

.site-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 800;
    color: var(--text-main);
    flex-shrink: 0;
}

.site-logo-image {
    width: 72px;
    height: 72px;
    display: block;
    object-fit: contain;
    flex-shrink: 0;
}

.site-header-right {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: nowrap;
    justify-content: flex-end;
    margin-left: auto;
    min-width: 0;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
    min-width: 0;
}

.site-nav a,
.site-nav-form button {
    padding: 10px 14px;
    border-radius: 14px;
    color: var(--text-main);
    transition: var(--transition);
    font-weight: 700;
}

.site-nav-form {
    margin: 0;
}

.site-nav-form button {
    border: 0;
    background: transparent;
    cursor: pointer;
}

.site-nav a:last-child,
.site-nav-form:last-child {
    margin-right: 28px;
}

.admin-site-nav a:last-child,
.admin-site-nav .site-nav-form:last-child {
    margin-right: 0;
}

.user-site-nav a:last-child,
.user-site-nav .site-nav-form:last-child {
    margin-right: 0;
}

.site-nav a:hover,
.site-nav a.active,
.site-nav-form button:hover {
    background: rgba(255, 255, 255, 0.7);
    box-shadow: var(--shadow-sm);
}

.user-badge-panel {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(203, 213, 225, 0.65);
    box-shadow: var(--shadow-sm);
    min-width: auto;
    flex-shrink: 0;
    margin-left: 0 !important;
}

.admin-user-badge-panel {
    margin-left: 0 !important;
}

.site-nav {
    margin-right: 0;
}

.user-badge-link {
    display: flex;
    text-decoration: none;
    transition: var(--transition);
    margin-left: 0 !important;
}

.user-profile-badge-panel {
    margin-left: 18px !important;
}

.user-badge-link:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-md);
}

.user-badge-main {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
    color: var(--text-main);
    white-space: nowrap;
}

.user-badge-name {
    font-weight: 700;
}

.user-badge-sep {
    color: var(--text-light);
}

.user-badge-login {
    color: var(--text-muted);
    font-weight: 600;
}

.main-content {
    flex: 1;
    padding: 34px 0 40px;
}

.site-advisory-banner {
    margin-bottom: 18px;
    padding: 14px 18px;
    border-radius: 18px;
    border: 1px solid rgba(245, 158, 11, 0.26);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.16), rgba(249, 115, 22, 0.1));
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
    line-height: 1.65;
}

.site-advisory-banner strong {
    display: inline-block;
    margin-right: 8px;
}

.hero-card {
    border-radius: var(--radius-xxl);
    padding: 44px 48px;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.65fr);
    gap: 36px;
    align-items: center;
    overflow: hidden;
}

.hero-copy {
    min-width: 0;
}

.hero-title {
    margin: 0 0 14px;
    font-size: 52px;
    line-height: 1.08;
    font-weight: 800;
    max-width: 880px;
}

.hero-text {
    margin: 0 0 24px;
    color: var(--text-muted);
    font-size: 19px;
    line-height: 1.75;
    max-width: 900px;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.hero-visual {
    position: relative;
    justify-self: end;
    width: min(360px, 100%);
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.hero-xray-logo {
    position: relative;
    width: 78%;
    height: 78%;
    object-fit: contain;
    opacity: 1;
    filter: none;
}

.primary-btn,
.secondary-btn,
.danger-btn {
    border: none;
    outline: none;
    cursor: pointer;
    border-radius: 16px;
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 700;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.primary-btn {
    background: linear-gradient(135deg, var(--accent), #6ea8ff);
    color: #ffffff;
    box-shadow: 0 14px 28px rgba(79, 124, 255, 0.25);
}

.primary-btn:hover {
    transform: translateY(-1px);
    background: linear-gradient(135deg, var(--accent-hover), #629cff);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.75);
    color: var(--text-main);
    border: 1px solid rgba(203, 213, 225, 0.7);
    box-shadow: var(--shadow-sm);
}

.secondary-btn:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.92);
}

.danger-btn {
    background: linear-gradient(135deg, #ef4444, #f87171);
    color: #ffffff;
    box-shadow: 0 14px 28px rgba(239, 68, 68, 0.22);
}

.danger-btn:hover {
    transform: translateY(-1px);
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
}

.features-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
    align-items: stretch;
}

.feature-grid-compact {
    display: grid;
    grid-template-columns: repeat(3, minmax(250px, 300px));
    gap: 18px;
    align-items: stretch;
    grid-auto-rows: 1fr;
    justify-content: center;
    max-width: 988px;
    margin: 0 auto;
}

.info-card,
.panel-card,
.feature-card,
.result-card,
.history-card,
.reference-card,
.upload-card {
    border-radius: var(--radius-xl);
    padding: 24px;
}

.feature-card-equal {
    min-height: 320px;
    padding: 32px 28px;
    border-radius: 32px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    text-align: left;
}

.feature-card-pathology {
    min-height: 220px;
    padding-top: 22px;
    padding-bottom: 18px;
}

.feature-card-compact {
    min-height: 220px;
    height: 100%;
    width: 100%;
    max-width: 300px;
    padding: 20px 20px;
    border-radius: 26px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 10px;
    overflow: hidden;
}

.feature-title {
    margin: 0 0 18px;
    font-size: 28px;
    line-height: 1.15;
    font-weight: 800;
    color: var(--text-main);
    word-break: normal;
    overflow-wrap: normal;
    hyphens: none;
}

.feature-text {
    margin: 0;
    font-size: 18px;
    line-height: 1.7;
    color: var(--text-muted);
    max-width: 100%;
    word-break: normal;
    overflow-wrap: break-word;
}

.feature-title-pathology {
    font-size: 24px;
    line-height: 1.14;
}

.feature-text-pathology {
    font-size: 16px;
    line-height: 1.6;
}

.feature-title-compact {
    margin-bottom: 0;
    min-height: 4.6rem;
    font-size: 21px;
    line-height: 1.15;
    max-width: 100%;
    overflow-wrap: break-word;
    word-break: keep-all;
    hyphens: manual;
}

.feature-text-compact {
    font-size: 16px;
    line-height: 1.5;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.section-title {
    margin: 0 0 18px;
    font-size: 30px;
    line-height: 1.2;
    font-weight: 800;
}

.info-card > .section-title {
    margin-bottom: 28px;
}

.section-subtitle {
    margin: 0 0 24px;
    color: var(--text-muted);
    line-height: 1.7;
    font-size: 16px;
}

.section-subtitle-centered {
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

.card-title {
    margin: 0 0 10px;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
}

.card-text {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.7;
    font-size: 15px;
}

.flash-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 18px;
}

.flash-message {
    border-radius: 14px;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.45;
    border: 1px solid transparent;
}

.flash-success {
    background: rgba(22, 163, 74, 0.10);
    border-color: rgba(22, 163, 74, 0.18);
    color: #166534;
}

.flash-danger {
    background: rgba(220, 38, 38, 0.10);
    border-color: rgba(220, 38, 38, 0.18);
    color: #991b1b;
}

.flash-warning {
    background: rgba(217, 119, 6, 0.10);
    border-color: rgba(217, 119, 6, 0.18);
    color: #92400e;
}

.form-card {
    border-radius: var(--radius-xl);
    padding: 28px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    border: 1px solid var(--border-light);
    background: var(--bg-white-strong);
    border-radius: 16px;
    padding: 14px 16px;
    font-size: 15px;
    color: var(--text-main);
    outline: none;
    transition: var(--transition);
}

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

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: rgba(79, 124, 255, 0.8);
    box-shadow: 0 0 0 4px rgba(79, 124, 255, 0.12);
    background: rgba(255, 255, 255, 0.92);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #9ca3af;
}

.upload-zone {
    border: 2px dashed rgba(79, 124, 255, 0.28);
    background: rgba(255, 255, 255, 0.58);
    border-radius: 20px;
    padding: 28px;
    text-align: center;
    transition: var(--transition);
}

.upload-zone:hover {
    border-color: rgba(79, 124, 255, 0.52);
    background: rgba(255, 255, 255, 0.72);
}

.upload-zone-title {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 700;
}

.upload-zone-text {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.6;
}

.table-wrap {
    overflow-x: auto;
    border-radius: 20px;
}

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

.data-table th,
.data-table td {
    padding: 16px 14px;
    text-align: left;
    border-bottom: 1px solid rgba(203, 213, 225, 0.45);
    vertical-align: middle;
}

.data-table th {
    font-size: 13px;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
}

.data-table td {
    font-size: 15px;
    color: var(--text-main);
    background: transparent;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.result-predictions-table {
    table-layout: fixed;
}

.result-predictions-table th,
.result-predictions-table td {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.result-predictions-table th:first-child,
.result-predictions-table td:first-child {
    width: 42%;
}

.result-predictions-table th:nth-child(2),
.result-predictions-table td:nth-child(2),
.result-predictions-table th:nth-child(3),
.result-predictions-table td:nth-child(3) {
    width: 16%;
    white-space: nowrap;
}

.result-predictions-table th:last-child,
.result-predictions-table td:last-child {
    width: 26%;
}

.result-predictions-table-simple th:first-child,
.result-predictions-table-simple td:first-child {
    width: 54%;
}

.result-predictions-table-simple th:nth-child(2),
.result-predictions-table-simple td:nth-child(2) {
    width: 16%;
    white-space: nowrap;
}

.result-predictions-table-simple th:last-child,
.result-predictions-table-simple td:last-child {
    width: 30%;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;
}

.badge-blue {
    background: rgba(79, 124, 255, 0.12);
    color: var(--accent);
}

.badge-green {
    background: rgba(22, 163, 74, 0.12);
    color: var(--success);
}

.badge-red {
    background: rgba(220, 38, 38, 0.12);
    color: var(--danger);
}

.badge-orange {
    background: rgba(217, 119, 6, 0.12);
    color: var(--warning);
}

.result-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    align-items: start;
}

.result-main {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.result-sidebar {
    position: sticky;
    top: 92px;
    max-height: calc(100vh - 112px);
    max-height: calc(100svh - 112px);
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding-right: 4px;
    -webkit-overflow-scrolling: touch;
}

.result-visual-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
}

.result-image-box {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 22px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.75);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 560px;
    min-height: 360px;
    padding: 14px;
    margin: 0 auto;
}

.result-image-box img {
    width: 100%;
    max-height: 420px;
    height: auto;
    object-fit: contain;
    display: block;
}

.result-image-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px 18px 20px;
    border-radius: 20px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(255, 255, 255, 0.03);
}

.result-image-head {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    text-transform: uppercase;
}

.result-image-note {
    margin: 0;
    font-size: 14px;
    line-height: 1.65;
    color: var(--text-muted);
}

.result-image-box-empty {
    background: rgba(255, 255, 255, 0.04);
    border-style: dashed;
}

.result-image-empty-copy {
    max-width: 320px;
    text-align: center;
    color: var(--text-muted);
    line-height: 1.6;
}

.result-main-card {
    border-radius: 22px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(255, 255, 255, 0.03);
    box-shadow: none;
}

.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.result-stat {
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: var(--shadow-sm);
    min-width: 150px;
}

.result-stat-label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.result-stat-value {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
}

.result-pathology-pill {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid rgba(122, 162, 255, 0.32);
    background: rgba(122, 162, 255, 0.12);
    color: var(--text-main);
    font-size: 14px;
    font-weight: 800;
    line-height: 1.2;
    word-break: break-word;
}

.findings-list {
    margin: 0;
    padding-left: 20px;
    color: var(--text-main);
    line-height: 1.8;
}

.findings-list li + li {
    margin-top: 8px;
}

.agent-card {
    border-radius: 28px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.agent-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.agent-avatar {
    position: relative;
    width: 52px;
    height: 52px;
    border-radius: 18px;
    background: rgba(122, 162, 255, 0.1);
    border: 1px solid rgba(122, 162, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.agent-avatar-dot {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: linear-gradient(135deg, #8ab4ff, #5f8fff);
    box-shadow: 0 0 0 6px rgba(122, 162, 255, 0.14);
}

.agent-avatar-ring {
    position: absolute;
    inset: 10px;
    border-radius: 14px;
    border: 1px solid rgba(122, 162, 255, 0.18);
}

.agent-header-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.agent-title {
    margin: 0;
    font-size: 19px;
    font-weight: 800;
    line-height: 1.2;
}

.agent-subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.55;
}

.agent-chat {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: 420px;
    overflow-y: auto;
    padding: 4px 6px 4px 0;
}

.chat-bubble {
    max-width: 78%;
    padding: 16px 20px;
    border-radius: 28px;
    font-size: 15px;
    word-break: break-word;
    display: block;
    width: fit-content;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.chat-bubble.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.chat-bubble.user {
    align-self: flex-end;
    background: rgba(79, 124, 255, 0.18);
    color: var(--text-main);
    border: 1px solid rgba(79, 124, 255, 0.18);
}

.chat-bubble.bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
    border: 1px solid rgba(148, 163, 184, 0.22);
}

.chat-bubble-content {
    display: block;
    width: auto;
    margin: 0;
    padding: 0;
    line-height: 1.7;
    text-align: left !important;
    text-indent: 0 !important;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-bubble-thinking {
    min-width: 260px;
}

.thinking-inline {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.thinking-label {
    font-weight: 600;
}

.thinking-dots {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.thinking-dots span {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: currentColor;
    opacity: 0.35;
    animation: thinking-bounce 1.2s infinite ease-in-out;
}

.thinking-dots span:nth-child(2) {
    animation-delay: 0.18s;
}

.thinking-dots span:nth-child(3) {
    animation-delay: 0.36s;
}

@keyframes thinking-bounce {
    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: 0.3;
    }
    40% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

@keyframes assistant-pulse {
    0%,
    100% {
        opacity: 0.45;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.03);
    }
}

.reference-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
}

.reference-card h3 {
    margin: 0 0 10px;
    font-size: 20px;
    font-weight: 800;
    line-height: 1.25;
}

.reference-card p {
    margin: 0;
    line-height: 1.7;
    color: var(--text-muted);
}

.reference-card p + p {
    margin-top: 12px;
}

.reference-page-card {
    border-radius: 32px;
    padding: 34px 30px 30px;
}

.reference-page-header {
    margin-bottom: 22px;
}

.reference-page-title {
    margin-bottom: 12px;
}

.reference-page-subtitle {
    max-width: 980px;
    margin-bottom: 0;
}

.pathology-grid-clean {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    align-items: stretch;
}

.pathology-card-clean {
    border-radius: 28px;
    padding: 26px 28px;
    min-height: 250px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    background: rgba(255, 255, 255, 0.62);
}

.pathology-card-top {
    margin-bottom: 14px;
}

.pathology-card-title {
    margin: 0 0 12px;
    font-size: 24px;
    line-height: 1.2;
    font-weight: 800;
    color: var(--text-main);
}

.pathology-card-short {
    margin: 0;
    font-size: 17px;
    line-height: 1.55;
    font-weight: 600;
    color: var(--text-main);
    opacity: 0.78;
}

.pathology-card-divider {
    width: 100%;
    height: 1px;
    background: rgba(148, 163, 184, 0.18);
    margin: 0 0 16px;
}

.pathology-card-description {
    margin: 0;
    font-size: 16px;
    line-height: 1.75;
    color: var(--text-muted);
}

.auth-page {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, Arial, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(79, 124, 255, 0.18), transparent 28%),
        radial-gradient(circle at bottom right, rgba(88, 208, 255, 0.18), transparent 30%),
        var(--bg-main);
    color: var(--text-main);
}

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
}

.auth-card {
    width: 100%;
    max-width: 460px;
    border-radius: var(--radius-xl);
    padding: 36px 30px;
}

.auth-card-wide {
    max-width: 560px;
}

.auth-header {
    margin-bottom: 24px;
}

.auth-header h1 {
    margin: 0 0 10px;
    font-size: 32px;
    line-height: 1.15;
    font-weight: 700;
}

.auth-header p {
    margin: 0;
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.5;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.auth-submit-btn {
    margin-top: 6px;
}

.auth-switch {
    margin-top: 22px;
    text-align: center;
    font-size: 15px;
    color: var(--text-muted);
}

.auth-switch-link {
    margin-left: 6px;
    color: var(--accent);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: var(--transition);
}

.auth-switch-link:hover {
    color: var(--accent-hover);
}

.empty-state {
    text-align: center;
    padding: 28px;
    border-radius: 22px;
}

.empty-state-title {
    margin: 0 0 10px;
    font-size: 22px;
    font-weight: 800;
}

.empty-state-text {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.7;
}

.admin-stats-grid {
    margin-top: 10px;
}

.admin-stat-card {
    padding: 22px;
    border-radius: 22px;
}

.admin-stat-label {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.admin-stat-value {
    font-size: 34px;
    font-weight: 800;
    color: var(--text-main);
}

.diagnostics-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.diagnostics-card-row {
    display: flex;
    align-items: center;
}

.diagnostics-message {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.diagnostics-table td {
    vertical-align: top;
    overflow-wrap: anywhere;
}

.admin-header-row {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.admin-search-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.admin-search-form input,
.admin-search-form select {
    min-width: 320px;
    border: 1px solid var(--border-light);
    background: var(--bg-white-strong);
    border-radius: 14px;
    padding: 12px 14px;
    font-size: 15px;
    color: var(--text-main);
    outline: none;
}

.admin-search-form select {
    min-width: 190px;
    cursor: pointer;
}

.admin-search-form input:focus,
.admin-search-form select:focus {
    border-color: rgba(79, 124, 255, 0.8);
    box-shadow: 0 0 0 4px rgba(79, 124, 255, 0.12);
}

.admin-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.admin-actions form {
    margin: 0;
}

.pagination-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 22px;
}

.pagination-link,
.pagination-gap {
    min-width: 42px;
    min-height: 42px;
    padding: 10px 14px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.pagination-link {
    border: 1px solid var(--border-light);
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.03);
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.pagination-link:hover,
.pagination-link.active {
    transform: translateY(-1px);
    border-color: rgba(122, 162, 255, 0.55);
    background: rgba(122, 162, 255, 0.14);
}

.pagination-gap {
    color: var(--text-muted);
}

.password-hint {
    margin-top: -4px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-muted);
}

.footer {
    padding: 22px 0 34px;
    color: var(--text-muted);
    font-size: 14px;
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.mt-0 {
    margin-top: 0;
}

.mb-0 {
    margin-bottom: 0;
}

.mb-12 {
    margin-bottom: 12px;
}

.mb-16 {
    margin-bottom: 16px;
}

.mb-20 {
    margin-bottom: 20px;
}

.mb-24 {
    margin-bottom: 24px;
}

a,
button,
input,
textarea,
select,
.glass-card,
.user-badge-panel,
.site-nav a,
.site-nav-form button,
.result-stat,
.upload-zone,
.pathology-card-clean,
.data-table th,
.data-table td {
    transition: background var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.theme-switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--border-light);
    background: rgba(255, 255, 255, 0.78);
    padding: 6px 8px 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.theme-switch-track {
    position: relative;
    width: 64px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(203, 213, 225, 0.85);
}

.theme-switch-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1;
}

.theme-switch-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #7cb6ff);
    box-shadow: 0 8px 20px rgba(79, 124, 255, 0.28);
    transition: transform var(--transition);
}

.theme-switch-icon {
    position: relative;
    z-index: 1;
    font-size: 14px;
    line-height: 1;
}

html[data-theme="dark"] .theme-switch-thumb {
    transform: translateX(30px);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 13px;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    background: var(--bg-white-strong);
    color: var(--text-main);
    font-size: 14px;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.back-link:hover {
    transform: translateY(-1px);
}

.section-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.result-top-actions {
    width: 100%;
}

.result-top-actions .result-new-study-link {
    margin-left: auto;
}

html[data-theme="dark"] .site-nav a:hover,
html[data-theme="dark"] .site-nav a.active,
html[data-theme="dark"] .site-nav-form button:hover,
html[data-theme="dark"] .user-badge-panel,
html[data-theme="dark"] .result-stat,
html[data-theme="dark"] .upload-zone,
html[data-theme="dark"] .pathology-card-clean,
html[data-theme="dark"] .chat-bubble.bot,
html[data-theme="dark"] .secondary-btn,
html[data-theme="dark"] .back-link,
html[data-theme="dark"] .admin-search-form input,
html[data-theme="dark"] .admin-search-form select,
html[data-theme="dark"] .form-group input,
html[data-theme="dark"] .form-group textarea,
html[data-theme="dark"] .form-group select,
html[data-theme="dark"] .agent-textarea,
html[data-theme="dark"] .result-image-box,
html[data-theme="dark"] .theme-switch-track {
    background: var(--bg-white-strong);
    color: var(--text-main);
    border-color: var(--border-light);
}

html[data-theme="dark"] .flash-success {
    background: rgba(34, 197, 94, 0.14);
    color: #bbf7d0;
}

html[data-theme="dark"] .flash-danger {
    background: rgba(248, 113, 113, 0.14);
    color: #fecaca;
}

html[data-theme="dark"] .flash-warning {
    background: rgba(245, 158, 11, 0.14);
    color: #fde68a;
}

html[data-theme="dark"] .badge-green {
    background: rgba(34, 197, 94, 0.16);
    color: #86efac;
}

html[data-theme="dark"] .badge-red {
    background: rgba(248, 113, 113, 0.16);
    color: #fecaca;
}

html[data-theme="dark"] .badge-blue {
    background: rgba(122, 162, 255, 0.18);
    color: #bfd2ff;
}

html[data-theme="dark"] .badge-orange {
    background: rgba(245, 158, 11, 0.16);
    color: #fde68a;
}

html[data-theme="dark"] .data-table th,
html[data-theme="dark"] .data-table td,
html[data-theme="dark"] .pathology-card-short,
html[data-theme="dark"] .pathology-card-description,
html[data-theme="dark"] .card-text,
html[data-theme="dark"] .section-subtitle,
html[data-theme="dark"] .hero-text,
html[data-theme="dark"] .feature-text,
html[data-theme="dark"] .upload-zone-text,
html[data-theme="dark"] .result-stat-label,
html[data-theme="dark"] .admin-stat-label,
html[data-theme="dark"] .agent-subtitle,
html[data-theme="dark"] .password-hint,
html[data-theme="dark"] .footer,
html[data-theme="dark"] .user-badge-login {
    color: var(--text-muted);
}

html[data-theme="dark"] .site-header {
    border-bottom-color: rgba(51, 65, 85, 0.65);
}

html[data-theme="dark"] .site-logo,
html[data-theme="dark"] .feature-title,
html[data-theme="dark"] .section-title,
html[data-theme="dark"] .card-title,
html[data-theme="dark"] .pathology-card-title,
html[data-theme="dark"] .result-stat-value,
html[data-theme="dark"] .user-badge-main,
html[data-theme="dark"] .admin-stat-value,
html[data-theme="dark"] .auth-header h1 {
    color: var(--text-main);
}

html[data-theme="dark"] .auth-page {
    background:
        radial-gradient(circle at top left, rgba(79, 124, 255, 0.16), transparent 28%),
        radial-gradient(circle at bottom right, rgba(88, 208, 255, 0.14), transparent 30%),
        linear-gradient(180deg, var(--bg-main) 0%, var(--bg-secondary) 100%);
}

@media (max-width: 1100px) {
    .result-layout,
    .grid-3,
    .features-row {
        grid-template-columns: 1fr;
    }

    .hero-card {
        grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
        gap: 28px;
    }

    .hero-visual {
        width: min(280px, 100%);
    }

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

    .feature-grid-compact {
        grid-template-columns: repeat(2, minmax(250px, 300px));
    }

    .result-sidebar {
        position: static;
    }

    .feature-card-equal {
        min-height: unset;
    }
}

@media (max-width: 900px) {
    .hero-card {
        grid-template-columns: 1fr;
    }

    .hero-visual {
        justify-self: center;
        width: min(280px, 72vw);
    }

    .grid-2,
    .reference-grid,
    .form-row,
    .pathology-grid-clean {
        grid-template-columns: 1fr;
    }

    .hero-title {
        font-size: 40px;
    }

    .hero-text {
        font-size: 17px;
    }

    .site-header-right {
        width: auto;
        align-items: center;
        justify-content: flex-end;
        flex-wrap: nowrap;
    }

    .site-nav {
        flex-wrap: nowrap;
    }

    .user-badge-panel {
        width: auto;
        flex-shrink: 1;
    }

    .user-badge-main {
        white-space: nowrap;
        flex-wrap: nowrap;
    }

    .pathology-card-clean {
        min-height: unset;
    }

}

@media (max-width: 768px) {
    .main-content {
        padding-top: 26px;
    }

    .hero-card {
        padding: 28px 22px;
    }

    .site-header-inner {
        align-items: flex-start;
        flex-direction: column;
    }

    .site-nav {
        width: 100%;
    }

    .site-nav a,
    .site-nav-form,
    .site-nav-form button {
        flex: 1 1 auto;
        text-align: center;
    }

    .info-card,
    .panel-card,
    .feature-card,
    .result-card,
    .history-card,
    .reference-card,
    .upload-card,
    .form-card {
        padding: 20px;
    }

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

    .feature-grid-compact {
        grid-template-columns: 1fr;
        grid-auto-rows: auto;
        max-width: 300px;
    }

    .admin-search-form {
        width: 100%;
    }

    .admin-search-form input,
    .admin-search-form select {
        min-width: 100%;
        width: 100%;
    }
}

@media (max-width: 576px) {
    .container {
        padding: 0 14px;
    }

    .auth-card {
        padding: 28px 20px;
        border-radius: 22px;
    }

    .auth-header h1 {
        font-size: 28px;
    }

    .hero-title {
        font-size: 31px;
    }

    .hero-visual {
        width: min(230px, 78vw);
    }

    .section-title {
        font-size: 24px;
    }

    .feature-card-equal {
        padding: 24px 20px;
        border-radius: 24px;
    }

    .feature-title {
        font-size: 24px;
    }

    .feature-text {
        font-size: 17px;
    }

    .feature-card-compact {
        min-height: unset;
        height: auto;
        padding: 22px 18px;
        border-radius: 22px;
        max-width: 300px;
    }

    .feature-title-compact {
        min-height: unset;
        font-size: 20px;
    }

    .feature-text-compact {
        font-size: 15px;
    }

    .pathology-card-clean {
        padding: 22px 20px;
        border-radius: 22px;
    }

    .pathology-card-title {
        font-size: 22px;
    }

    .pathology-card-short {
        font-size: 16px;
    }

    .pathology-card-description {
        font-size: 15px;
    }

    .reference-page-card {
        padding: 24px 18px 20px;
        border-radius: 24px;
    }

    .primary-btn,
    .secondary-btn,
    .danger-btn {
        width: 100%;
    }

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

    .user-badge-main {
        white-space: normal;
    }

    .site-logo {
        gap: 12px;
    }

    .site-logo-image {
        width: 56px;
        height: 56px;
    }
}


html[data-theme="dark"] .theme-switch {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}

html[data-theme="dark"] .theme-switch-label {
    color: var(--text-main);
}

html[data-theme="dark"] .theme-switch-track {
    background: rgba(17, 24, 39, 0.96);
    border-color: rgba(71, 85, 105, 0.85);
}


/* Dark theme toggle capsule fix */
html[data-theme="dark"] .theme-switch {
    background: rgba(15, 23, 42, 0.92) !important;
    border: 1px solid rgba(71, 85, 105, 0.85) !important;
    box-shadow: var(--shadow-sm) !important;
}

html[data-theme="dark"] .theme-switch-label {
    color: var(--text-main) !important;
}

html[data-theme="dark"] .theme-switch-track {
    background: rgba(17, 24, 39, 0.96) !important;
    border: 1px solid rgba(71, 85, 105, 0.85) !important;
}
.password-input-wrap {
    position: relative;
}

.password-input-wrap input {
    padding-right: 56px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 14px;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 10px;
    padding: 0;
    box-shadow: none;
}

.password-toggle:hover {
    background: rgba(79, 124, 255, 0.10);
    color: var(--text-main);
}

.password-toggle:focus-visible {
    outline: 2px solid rgba(79, 124, 255, 0.45);
    outline-offset: 2px;
}

.eye-icon {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
    display: block;
}

.eye-on {
    display: none;
}

.password-toggle.is-visible .eye-off {
    display: none;
}

.password-toggle.is-visible .eye-on {
    display: block;
}

html[data-theme="dark"] .password-toggle:hover {
    background: rgba(122, 162, 255, 0.12);
}

.admin-user-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
    gap: 24px;
    align-items: start;
    margin-bottom: 24px;
}

.admin-user-hero,
.admin-user-sidebar {
    padding: 28px;
}

.admin-user-hero-top {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.admin-user-eyebrow {
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.admin-user-badges {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-user-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.admin-user-stat,
.admin-user-detail-card,
.admin-user-summary-item {
    border: 1px solid var(--border-light);
    background: var(--bg-white-strong);
    border-radius: 18px;
    box-shadow: var(--shadow-sm);
}

.admin-user-stat {
    padding: 18px 20px;
}

.admin-user-stat-label,
.admin-user-detail-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 14px;
}

.admin-user-stat-value,
.admin-user-detail-value {
    color: var(--text-main);
    font-size: 18px;
    line-height: 1.45;
}

.admin-user-sidebar-title {
    margin-bottom: 18px;
}

.admin-user-summary-list {
    display: grid;
    gap: 12px;
}

.admin-user-summary-item {
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.admin-user-summary-item span {
    color: var(--text-muted);
}

.admin-user-summary-item strong {
    color: var(--text-main);
    text-align: right;
}

.admin-user-side-actions {
    display: grid;
    gap: 12px;
    margin-top: 20px;
}

.admin-user-side-actions form {
    margin: 0;
}

.admin-action-btn-wide {
    width: 100%;
}

.admin-user-details-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.admin-user-detail-card {
    padding: 18px 20px;
}

html[data-theme="dark"] .admin-user-stat,
html[data-theme="dark"] .admin-user-detail-card,
html[data-theme="dark"] .admin-user-summary-item {
    background: var(--bg-white-strong);
    border-color: var(--border-light);
}

html[data-theme="dark"] .admin-user-eyebrow,
html[data-theme="dark"] .admin-user-stat-label,
html[data-theme="dark"] .admin-user-detail-label,
html[data-theme="dark"] .admin-user-summary-item span {
    color: var(--text-muted);
}

html[data-theme="dark"] .admin-user-stat-value,
html[data-theme="dark"] .admin-user-detail-value,
html[data-theme="dark"] .admin-user-summary-item strong {
    color: var(--text-main);
}

.admin-actions-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-actions-row form {
    margin: 0;
}

.admin-action-btn {
    min-width: 170px;
    min-height: 48px;
    padding: 12px 18px;
    border-radius: 16px;
    justify-content: center;
    white-space: nowrap;
}

.data-table td .admin-actions-row {
    justify-content: flex-start;
}

@media (max-width: 768px) {
    .admin-actions-row {
        flex-direction: row;
        align-items: stretch;
        gap: 12px;
    }

    .admin-action-btn {
        flex: 1 1 220px;
        width: auto;
    }

    .admin-user-layout,
    .admin-user-details-grid,
    .admin-user-stats {
        grid-template-columns: 1fr;
    }
}

/* Compact pathology reference cards */
.pathology-grid-compact {
    align-items: start;
    gap: 20px;
}

.pathology-card-compact {
    min-height: unset;
    height: 100%;
    padding: 20px 22px 18px;
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.pathology-card-compact .pathology-card-top {
    margin-bottom: 10px;
}

.pathology-card-compact .pathology-card-title {
    margin: 0 0 8px;
    font-size: 22px;
    line-height: 1.2;
}

.pathology-card-compact .pathology-card-short {
    margin: 0;
    font-size: 15px;
    line-height: 1.55;
}

.pathology-card-compact .pathology-card-divider {
    margin: 0 0 12px;
}

.pathology-card-compact .pathology-card-description {
    margin: 0;
    font-size: 14px;
    line-height: 1.65;
}

@media (max-width: 576px) {
    .pathology-grid-compact {
        gap: 16px;
    }

    .pathology-card-compact {
        padding: 18px 18px 16px;
        border-radius: 20px;
    }

    .pathology-card-compact .pathology-card-title {
        font-size: 20px;
    }

    .pathology-card-compact .pathology-card-short,
    .pathology-card-compact .pathology-card-description {
        font-size: 14px;
    }
}

/* Analysis page */
.analysis-hero {
    border-radius: 32px;
    padding: 34px;
}

.analysis-upload-card {
    border-radius: 30px;
    padding: 32px;
    text-align: center;
}

.analysis-upload-shell {
    max-width: 760px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.analysis-hidden-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.analysis-upload-button {
    width: min(620px, 100%);
    min-height: 210px;
    border-radius: 28px;
    border: 1.5px dashed rgba(148, 163, 184, 0.42);
    background: rgba(255, 255, 255, 0.05);
    padding: 30px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
    color: var(--text-main);
    cursor: pointer;
    transition: var(--transition);
}

.analysis-upload-button:hover {
    transform: translateY(-1px);
    border-color: rgba(122, 162, 255, 0.52);
    background: rgba(255, 255, 255, 0.08);
}

.analysis-upload-button-selected {
    border-color: rgba(122, 162, 255, 0.72);
    background: rgba(122, 162, 255, 0.1);
}

.analysis-upload-icon {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(122, 162, 255, 0.14);
    color: var(--accent);
    font-size: 34px;
    font-weight: 500;
    line-height: 1;
}

.analysis-upload-title {
    font-size: 28px;
    font-weight: 800;
    line-height: 1.15;
}

.analysis-upload-subtitle {
    max-width: 420px;
    color: var(--text-muted);
    font-size: 17px;
    line-height: 1.55;
}

.analysis-upload-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
}

.analysis-upload-hint {
    margin: 0;
    color: var(--text-muted);
    font-size: 15px;
}

.analysis-upload-note {
    margin: 0;
    color: var(--text-light);
    font-size: 14px;
    line-height: 1.5;
}

.analysis-submit-btn {
    min-width: 220px;
}

.analysis-submit-btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.analysis-job-card {
    padding: 34px;
}

.analysis-job-status {
    margin-top: 28px;
    color: var(--text-main);
    font-size: 22px;
    font-weight: 800;
    line-height: 1.35;
}

.analysis-job-progress {
    position: relative;
    overflow: hidden;
    height: 10px;
    margin-top: 22px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.18);
}

.analysis-job-progress span {
    position: absolute;
    inset: 0 auto 0 0;
    width: 42%;
    border-radius: inherit;
    background: linear-gradient(90deg, rgba(122, 162, 255, 0.2), rgba(122, 162, 255, 0.92));
    animation: analysis-job-progress 1.15s ease-in-out infinite alternate;
}

.analysis-job-card.is-error .analysis-job-progress span {
    background: linear-gradient(90deg, rgba(248, 113, 113, 0.2), rgba(248, 113, 113, 0.88));
    animation: none;
}

@keyframes analysis-job-progress {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(138%);
    }
}

.assistant-chat-box {
    min-height: 430px;
    max-height: 430px;
    padding: 6px;
}

.assistant-chat-form {
    display: grid;
    gap: 14px;
}

.result-chat-card {
    width: 100%;
    min-width: 0;
    min-height: 0;
    height: calc(100vh - 190px);
    height: calc(100svh - 190px);
    max-height: 820px;
    margin: 0;
    padding: 20px;
    border-radius: 28px;
    display: grid;
    grid-template-rows: auto minmax(0, 2fr) minmax(240px, 1fr);
    gap: 14px;
    overflow: hidden;
}

.result-chat-top {
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.result-chat-thread-shell {
    min-height: 0;
    display: flex;
    overflow: hidden;
    padding: 12px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid rgba(203, 213, 225, 0.72);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.result-chat-form-shell {
    min-height: 0;
    display: flex;
    padding: 0;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(203, 213, 225, 0.8);
    box-shadow: none;
    overflow: hidden;
}

.result-chat-card.is-thinking .agent-avatar-dot {
    box-shadow: 0 0 0 8px rgba(122, 162, 255, 0.18);
}

.result-chat-card.is-thinking .agent-avatar-ring {
    animation: assistant-pulse 1.8s infinite ease-in-out;
}

.result-chat-card.is-error .agent-avatar-dot {
    background: linear-gradient(135deg, #f59e0b, #f87171);
    box-shadow: 0 0 0 8px rgba(248, 113, 113, 0.14);
}

.result-chat-card .assistant-chat-box {
    flex: 1;
    height: 100%;
    min-height: 0;
    max-height: none;
    padding: 4px 4px 4px 0;
    border-radius: 18px;
    background: transparent;
    border: none;
    scroll-padding-top: 10px;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
}

.result-chat-card .chat-bubble {
    max-width: 92%;
    padding: 14px 16px;
    border-radius: 22px;
    font-size: 14px;
}

.result-chat-card .chat-bubble.bot {
    border-color: rgba(203, 213, 225, 0.82);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 250, 255, 0.98)),
        rgba(255, 255, 255, 0.92);
    color: var(--text-main);
    box-shadow: 0 10px 28px rgba(31, 41, 55, 0.06);
}

.result-chat-card .chat-bubble.user {
    max-width: 82%;
}

.result-chat-card .chat-bubble-content {
    line-height: 1.6;
}

.result-chat-actions {
    justify-content: flex-end;
}

.result-chat-actions .primary-btn {
    margin-right: 0;
}

.result-chat-input-panel {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    gap: 0;
}

.result-chat-input-panel.is-busy {
    opacity: 0.88;
}

.result-chat-custom-form {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 12px;
    margin: 0;
    padding: 18px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(248, 251, 255, 0.98)),
        rgba(255, 255, 255, 0.88);
}

.result-chat-input-label {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--text-muted);
}

.result-chat-input-row {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 12px;
    min-height: 0;
    height: 100%;
}

.result-chat-custom-input {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: none;
    resize: none;
    border-radius: 18px;
    border: 1px solid rgba(203, 213, 225, 0.9);
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-main);
    padding: 14px 15px;
    font: inherit;
    font-size: 14px;
    line-height: 1.55;
    outline: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.result-chat-custom-input::placeholder {
    color: var(--text-light);
    opacity: 1;
}

.result-chat-custom-input:focus {
    border-color: rgba(122, 162, 255, 0.72);
    box-shadow:
        0 0 0 4px rgba(122, 162, 255, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.result-chat-send-btn {
    width: 100%;
    min-width: 0;
    min-height: 54px;
    justify-self: stretch;
    border-radius: 18px;
    padding-inline: 18px;
}

.result-chat-card .agent-header {
    align-items: flex-start;
    gap: 14px;
}

.result-chat-card .agent-subtitle {
    max-width: 30rem;
}

html[data-theme="dark"] .result-chat-thread-shell {
    background: rgba(255, 255, 255, 0.025);
    border-color: rgba(148, 163, 184, 0.16);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

html[data-theme="dark"] .result-chat-form-shell {
    background: rgba(13, 20, 36, 0.52);
    border-color: rgba(122, 162, 255, 0.18);
}

html[data-theme="dark"] .result-chat-card .chat-bubble.bot {
    border-color: rgba(148, 163, 184, 0.28);
    background:
        linear-gradient(180deg, rgba(17, 24, 43, 0.96), rgba(13, 20, 35, 0.98)),
        rgba(255, 255, 255, 0.04);
    color: var(--text-main);
    box-shadow: none;
}

html[data-theme="dark"] .result-chat-custom-form {
    background:
        linear-gradient(180deg, rgba(24, 36, 61, 0.78), rgba(12, 18, 32, 0.86)),
        rgba(13, 20, 36, 0.72);
}

html[data-theme="dark"] .result-chat-input-label {
    color: var(--text-light);
}

html[data-theme="dark"] .result-chat-custom-input {
    border-color: rgba(122, 162, 255, 0.2);
    background: rgba(8, 13, 25, 0.52);
    color: var(--text-main);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* Result split layout */
.result-layout-split {
    grid-template-columns: minmax(0, 1.75fr) minmax(360px, 0.95fr);
    align-items: start;
    gap: 28px;
}

.agent-card-large {
    min-height: unset;
}

.agent-card-large .agent-chat {
    min-height: 0;
    max-height: none;
    padding: 6px;
}

@media (max-width: 1200px) {
    .result-layout-split {
        grid-template-columns: 1fr;
    }

    .result-sidebar {
        position: static;
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }

    .result-visual-grid {
        grid-template-columns: 1fr;
    }

    .agent-card-large {
        min-height: unset;
    }

    .agent-card-large .agent-chat {
        min-height: 0;
        max-height: none;
    }

    .result-chat-card .assistant-chat-box {
        min-height: 0;
        max-height: none;
    }

    .result-chat-input-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .analysis-upload-card {
        padding: 24px 18px;
    }

    .result-image-box {
        min-height: 280px;
        max-width: 100%;
    }

    .result-image-box img {
        max-height: 320px;
    }

    .analysis-upload-button {
        min-height: 176px;
        padding: 24px 20px;
        border-radius: 24px;
    }

    .analysis-upload-icon {
        width: 48px;
        height: 48px;
        border-radius: 16px;
        font-size: 30px;
    }

    .analysis-upload-title {
        font-size: 24px;
    }

    .analysis-upload-subtitle {
        font-size: 16px;
    }

    .assistant-chat-card {
        padding: 20px;
    }

    .result-predictions-table th:first-child,
    .result-predictions-table td:first-child,
    .result-predictions-table th:nth-child(2),
    .result-predictions-table td:nth-child(2),
    .result-predictions-table th:nth-child(3),
    .result-predictions-table td:nth-child(3),
    .result-predictions-table th:last-child,
    .result-predictions-table td:last-child {
        width: auto;
        white-space: normal;
    }
}
