:root {
    color-scheme: dark;
    --bg: #080a0f;
    --bg-soft: #0d1118;
    --panel: #10161f;
    --panel-2: #131b25;
    --line: #263241;
    --line-soft: #1b2531;
    --text: #edf5f8;
    --muted: #8ea0aa;
    --faint: #5f727d;
    --cyan: #38d6c7;
    --green: #5ee089;
    --amber: #f4bf50;
    --red: #ff6d6d;
    --violet: #b99cff;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background:
        linear-gradient(rgba(56, 214, 199, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(56, 214, 199, 0.035) 1px, transparent 1px),
        linear-gradient(135deg, rgba(56, 214, 199, 0.08), transparent 38%, rgba(244, 191, 80, 0.04) 72%, rgba(185, 156, 255, 0.05)),
        var(--bg);
    background-size: 36px 36px, 36px 36px, auto, auto;
}

body.login-page {
    display: grid;
    place-items: center;
    padding: 24px;
}

button,
input,
select {
    font: inherit;
}

button {
    border: 0;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

input,
select {
    min-width: 0;
    color: var(--text);
    background: #0b1017;
    border: 1px solid var(--line);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input:focus,
select:focus {
    border-color: rgba(56, 214, 199, 0.9);
    box-shadow: 0 0 0 3px rgba(56, 214, 199, 0.12);
}

input::placeholder {
    color: #60717c;
}

select {
    appearance: none;
}

.app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px 18px;
    background: rgba(8, 10, 15, 0.88);
    border-right: 1px solid var(--line-soft);
    backdrop-filter: blur(18px);
}

.brand {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--line-soft);
}

.login-shell {
    width: min(440px, 100%);
}

.login-card {
    display: grid;
    gap: 22px;
    padding: 24px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(19, 27, 37, 0.96), rgba(10, 15, 21, 0.96));
    box-shadow: var(--shadow);
}

.login-brand {
    padding-bottom: 18px;
}

.login-heading h2 {
    margin: 0;
    font-size: 24px;
    line-height: 1.2;
    letter-spacing: 0;
}

.login-form {
    display: grid;
    gap: 12px;
}

.login-form input {
    height: 44px;
    padding: 0 12px;
}

.login-status {
    min-height: 22px;
    color: var(--cyan);
}

.login-footnote {
    color: var(--muted);
    font-size: 12px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    color: #06100f;
    background: linear-gradient(135deg, var(--cyan), var(--green));
    font-weight: 800;
    letter-spacing: 0;
}

.brand h1,
.topbar h2,
.panel h3,
.auth-panel h3 {
    margin: 0;
    letter-spacing: 0;
}

.brand h1 {
    font-size: 17px;
    line-height: 1.2;
}

.brand span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
}

.nav-stack {
    display: grid;
    gap: 6px;
    margin-top: 22px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 9px 10px;
    color: var(--muted);
    text-decoration: none;
    border-radius: 8px;
    transition: color 0.2s ease, background 0.2s ease;
}

.nav-item:hover,
.nav-item.is-active {
    color: var(--text);
    background: rgba(56, 214, 199, 0.10);
}

.nav-icon {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    color: var(--cyan);
}

.side-status {
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--line-soft);
}

.eyebrow {
    display: block;
    margin-bottom: 6px;
    color: var(--cyan);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.session-pill,
.status-message {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    max-width: 100%;
    padding: 7px 11px;
    border: 1px solid rgba(244, 191, 80, 0.3);
    border-radius: 999px;
    color: var(--amber);
    background: rgba(244, 191, 80, 0.09);
}

.session-pill {
    cursor: pointer;
}

.session-pill.is-online {
    color: var(--green);
    border-color: rgba(94, 224, 137, 0.34);
    background: rgba(94, 224, 137, 0.10);
}

.workspace {
    min-width: 0;
    padding: 24px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.topbar h2 {
    font-size: 26px;
    line-height: 1.2;
}

.status-message {
    justify-content: center;
    min-width: 140px;
    color: var(--cyan);
    border-color: rgba(56, 214, 199, 0.30);
    background: rgba(56, 214, 199, 0.08);
    white-space: nowrap;
}

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

.account-summary {
    margin-bottom: 10px;
    color: var(--text);
    font-size: 13px;
    overflow-wrap: anywhere;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.metric-tile,
.panel,
.auth-panel {
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(19, 27, 37, 0.94), rgba(12, 17, 24, 0.94));
    box-shadow: var(--shadow);
}

.metric-tile {
    padding: 16px;
    min-height: 94px;
}

.metric-tile span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.metric-tile strong {
    display: block;
    margin-top: 10px;
    color: var(--text);
    font-size: 28px;
    line-height: 1;
}

.auth-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 14px;
    padding: 20px;
}

.auth-panel p {
    margin: 8px 0 0;
    color: var(--muted);
}

.account-login-panel {
    margin-bottom: 14px;
}

.account-login-form {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
    gap: 10px;
    padding: 18px;
}

.account-login-form input,
.admin-card input,
.admin-card select {
    height: 42px;
    padding: 0 12px;
}

.panel {
    margin-bottom: 14px;
    overflow: hidden;
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line-soft);
}

.panel h3 {
    font-size: 17px;
}

.panel h3 span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

.panel-note {
    color: var(--muted);
    font-size: 13px;
}

.search-panel {
    padding-bottom: 18px;
}

.search-box {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 18px;
}

.search-box input,
.search-box select,
.library-toolbar input {
    height: 44px;
    padding: 0 12px;
}

.btn,
.icon-btn,
.segmented button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.btn:hover:not(:disabled),
.icon-btn:hover:not(:disabled),
.segmented button:hover {
    transform: translateY(-1px);
}

.btn-primary {
    padding: 0 16px;
    color: #04100f;
    background: linear-gradient(135deg, var(--cyan), var(--green));
    font-weight: 800;
}

.btn-ghost {
    padding: 0 13px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line);
}

.btn-danger {
    padding: 0 13px;
    color: #ffdede;
    background: rgba(255, 109, 109, 0.10);
    border: 1px solid rgba(255, 109, 109, 0.30);
}

.icon-btn {
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line);
}

.icon-btn.danger {
    color: var(--red);
    border-color: rgba(255, 109, 109, 0.30);
    background: rgba(255, 109, 109, 0.08);
}

.toolbar,
.list-controls,
.library-toolbar,
.selection-bar,
.list-footer,
.pagination,
.task-actions,
.row-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.list-controls,
.library-toolbar {
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line-soft);
}

.library-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto auto;
}

.admin-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 18px;
    border-bottom: 1px solid var(--line-soft);
}

.admin-card {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.025);
}

.admin-card h4 {
    margin: 0 0 4px;
    color: var(--text);
    font-size: 14px;
}

.segmented {
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
}

.segmented button {
    min-height: 30px;
    padding: 0 12px;
    color: var(--muted);
    background: transparent;
}

.segmented button.is-active {
    color: #04100f;
    background: var(--cyan);
    font-weight: 800;
}

.bulk-hint {
    padding: 10px 18px 0;
    color: var(--faint);
    font-size: 12px;
}

.table-shell {
    width: 100%;
    overflow: auto;
}

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

#results-table {
    min-width: 1180px;
    table-layout: fixed;
}

#papers-table {
    min-width: 1360px;
    table-layout: fixed;
}

#users-table {
    min-width: 900px;
    table-layout: fixed;
}

#model-configs-table {
    min-width: 1380px;
    table-layout: fixed;
}

th,
td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: top;
    overflow-wrap: anywhere;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: var(--muted);
    background: #0b1017;
    font-size: 12px;
    font-weight: 700;
    text-align: left;
}

tbody tr {
    background: rgba(255, 255, 255, 0.01);
}

tbody tr:hover {
    background: rgba(56, 214, 199, 0.05);
}

tbody tr.is-testing-row {
    background: rgba(56, 214, 199, 0.055);
}

td {
    color: #d8e4e8;
}

#results-table th:nth-child(1),
#results-table td:nth-child(1),
#papers-table th:nth-child(1),
#papers-table td:nth-child(1) {
    width: 44px;
    text-align: center;
}

#results-table th:nth-child(2),
#results-table td:nth-child(2) {
    width: 38%;
}

#results-table th:nth-child(3),
#results-table td:nth-child(3) {
    width: 90px;
}

#results-table th:nth-child(4),
#results-table td:nth-child(4) {
    width: 17%;
}

#results-table th:nth-child(5),
#results-table td:nth-child(5) {
    width: 15%;
}

#results-table th:nth-child(6),
#results-table td:nth-child(6) {
    width: 76px;
}

#results-table th:nth-child(7),
#results-table td:nth-child(7) {
    width: 21%;
}

#papers-table th:nth-child(2),
#papers-table td:nth-child(2) {
    width: 26%;
}

#papers-table th:nth-child(3),
#papers-table td:nth-child(3) {
    width: 15%;
}

#papers-table th:nth-child(4),
#papers-table td:nth-child(4) {
    width: 72px;
}

#papers-table th:nth-child(5),
#papers-table td:nth-child(5) {
    width: 17%;
}

#papers-table th:nth-child(6),
#papers-table td:nth-child(6),
#papers-table th:nth-child(7),
#papers-table td:nth-child(7),
#papers-table th:nth-child(8),
#papers-table td:nth-child(8) {
    width: 92px;
}

#papers-table th:nth-child(9),
#papers-table td:nth-child(9) {
    width: 132px;
}

#users-table th:nth-child(1),
#users-table td:nth-child(1) {
    width: 22%;
}

#users-table th:nth-child(6),
#users-table td:nth-child(6) {
    width: 150px;
}

#model-configs-table th:nth-child(2),
#model-configs-table td:nth-child(2) {
    width: 180px;
}

#model-configs-table th:nth-child(5),
#model-configs-table td:nth-child(5) {
    width: 210px;
}

#model-configs-table th:nth-child(9),
#model-configs-table td:nth-child(9) {
    width: 220px;
}

#model-configs-table th:nth-child(10),
#model-configs-table td:nth-child(10) {
    width: 250px;
}

#model-configs-table th:nth-child(10),
#model-configs-table td:nth-child(10) {
    position: sticky;
    right: 0;
    z-index: 2;
    background: #0b1017;
    box-shadow: -10px 0 18px rgba(8, 10, 15, 0.42);
}

#model-configs-table td:nth-child(10) {
    background: #0d131b;
}

.title-cell {
    color: #f4fbfc;
    font-weight: 700;
}

.model-title-stack {
    display: grid;
    gap: 6px;
}

.inline-action {
    justify-self: start;
    padding: 0;
    color: var(--cyan);
    background: transparent;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.inline-action:hover {
    color: var(--green);
}

.file-type,
.status-chip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 999px;
    white-space: nowrap;
    font-size: 12px;
}

.file-type {
    color: var(--cyan);
    background: rgba(56, 214, 199, 0.10);
    border: 1px solid rgba(56, 214, 199, 0.24);
}

.status-chip {
    color: var(--muted);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
}

.status-chip.is-success {
    color: var(--green);
    border-color: rgba(94, 224, 137, 0.28);
    background: rgba(94, 224, 137, 0.08);
}

.status-chip.is-running {
    color: var(--cyan);
    border-color: rgba(56, 214, 199, 0.30);
    background: rgba(56, 214, 199, 0.08);
}

.status-chip.is-warning {
    color: var(--amber);
    border-color: rgba(244, 191, 80, 0.30);
    background: rgba(244, 191, 80, 0.08);
}

.status-chip.is-danger {
    color: var(--red);
    border-color: rgba(255, 109, 109, 0.30);
    background: rgba(255, 109, 109, 0.08);
}

.status-chip.is-pending {
    color: var(--violet);
    border-color: rgba(185, 156, 255, 0.28);
    background: rgba(185, 156, 255, 0.08);
}

.status-chip.is-muted {
    color: #90a1a8;
}

.model-test-state {
    display: grid;
    gap: 5px;
}

.model-test-detail {
    display: block;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
    max-height: 3.9em;
    overflow: hidden;
}

.selection-bar,
.pagination,
.list-footer {
    justify-content: space-between;
    padding: 14px 18px;
    border-top: 1px solid var(--line-soft);
}

.pagination {
    justify-content: flex-start;
    flex-wrap: wrap;
}

.page-jump {
    margin-left: auto;
}

.page-jump input {
    width: 82px;
    height: 36px;
    padding: 0 8px;
}

.selection-bar strong {
    color: var(--cyan);
}

.task-list {
    display: grid;
    gap: 8px;
    padding: 14px 18px;
}

.task-item {
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.025);
}

.task-main {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 12px;
}

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

.task-title-line {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.task-title-line strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.progress-bar {
    height: 3px;
    background: rgba(255, 255, 255, 0.06);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--cyan), var(--green), var(--amber));
    transition: width 0.3s ease;
}

.task-detail {
    display: none;
    gap: 10px;
    padding: 10px 12px 12px 50px;
    color: var(--muted);
    border-top: 1px solid var(--line-soft);
    font-size: 12px;
}

.task-item.is-expanded .task-detail {
    display: flex;
    flex-wrap: wrap;
}

.task-error {
    color: var(--red);
}

.viewer-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(rgba(8, 10, 15, 0.74), rgba(8, 10, 15, 0.88)),
        linear-gradient(135deg, rgba(56, 214, 199, 0.08), transparent 46%, rgba(185, 156, 255, 0.06));
    backdrop-filter: blur(10px);
}

.viewer-shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: min(1180px, 100%);
    height: min(86vh, 920px);
    min-height: 520px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0b1017;
    box-shadow: 0 28px 100px rgba(0, 0, 0, 0.48);
}

.viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line-soft);
    background: linear-gradient(180deg, rgba(19, 27, 37, 0.98), rgba(11, 16, 23, 0.98));
}

.viewer-title-group {
    min-width: 0;
}

.viewer-title-group h3 {
    margin: 0;
    max-width: 720px;
    overflow: hidden;
    color: var(--text);
    font-size: 16px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.viewer-meta {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.viewer-actions {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 8px;
}

.viewer-body {
    position: relative;
    min-height: 0;
    background: #070b10;
}

.viewer-body iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: #111821;
}

.viewer-empty {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 8px;
    min-height: 100%;
    padding: 32px;
    color: var(--muted);
    text-align: center;
}

.viewer-empty strong {
    color: var(--text);
    font-size: 18px;
}

.is-viewer-open {
    overflow: hidden;
}

.empty-state,
.empty-row {
    padding: 28px;
    color: var(--muted);
    text-align: center;
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--cyan);
}

[hidden] {
    display: none !important;
}

@media (max-width: 1100px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        display: grid;
        grid-template-columns: minmax(220px, 1fr) auto;
        gap: 12px;
        padding: 14px;
    }

    .brand {
        padding-bottom: 0;
        border-bottom: 0;
    }

    .nav-stack {
        grid-column: 1 / -1;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        margin-top: 0;
    }

    .side-status {
        position: static;
        padding-top: 0;
        border-top: 0;
        align-self: center;
    }

    .workspace {
        padding: 16px;
    }

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

@media (max-width: 760px) {
    .topbar,
    .auth-panel,
    .topbar-actions,
    .list-controls,
    .selection-bar,
    .list-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar h2 {
        font-size: 22px;
    }

    .panel-heading {
        flex-wrap: wrap;
    }

    .panel-note {
        width: 100%;
    }

    .metrics-grid,
    .search-box,
    .library-toolbar,
    .account-login-form,
    .admin-layout {
        grid-template-columns: 1fr;
    }

    .nav-stack {
        grid-template-columns: 1fr;
    }

    .task-main {
        grid-template-columns: 24px minmax(0, 1fr);
    }

    .task-actions {
        grid-column: 2;
        justify-content: flex-start;
    }

    .task-detail {
        padding-left: 12px;
    }

    .page-jump {
        margin-left: 0;
    }

    .viewer-overlay {
        padding: 10px;
    }

    .viewer-shell {
        height: 92vh;
        min-height: 0;
    }

    .viewer-header,
    .viewer-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .viewer-title-group h3 {
        max-width: none;
        white-space: normal;
    }
}
