:root {
    --bg: #0b1220;
    --panel: rgba(255, 255, 255, 0.06);
    --panel-2: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.12);
    --text: rgba(255, 255, 255, 0.92);
    --muted: rgba(255, 255, 255, 0.65);
    --faint: rgba(255, 255, 255, 0.45);
    --brand: #7c4dff;
    --green: #23c96d;
    --yellow: #f5c542;
    --red: #ff5d5d;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    font-family:
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        "PingFang SC",
        "Hiragino Sans GB",
        "Microsoft YaHei",
        "Helvetica Neue",
        Arial;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
    overscroll-behavior-y: none;
}

body {
    position: relative;
    background: transparent;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: radial-gradient(1200px 700px at 20% 10%, rgba(124, 77, 255, 0.28), transparent 55%),
        radial-gradient(900px 700px at 85% 30%, rgba(35, 201, 109, 0.18), transparent 55%),
        var(--bg);
}

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

.container {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    padding: 20px 16px;
    border-right: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 60%);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px 16px;
    margin-bottom: 6px;
}

.brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(124, 77, 255, 0.9), rgba(35, 201, 109, 0.6));
    box-shadow: var(--shadow);
}

.brand-title {
    font-weight: 700;
    line-height: 1.1;
}

.brand-subtitle {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.nav {
    display: grid;
    gap: 6px;
    padding: 0 6px;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px;
    border-radius: 12px;
    color: var(--muted);
}

.nav a.active {
    background: linear-gradient(135deg, rgba(124, 77, 255, 0.22), rgba(255, 255, 255, 0.08));
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.nav svg {
    width: 18px;
    height: 18px;
    opacity: 0.9;
}

.sidebar-footer {
    margin-top: 18px;
    padding: 12px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 12px;
}

.main {
    padding: 22px 22px 40px;
}

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

.title {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0.2px;
}

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

.controls svg {
    height: 10px;
}

input,
select,
textarea {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    padding: 10px 12px;
    outline: none;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}

input::placeholder,
textarea::placeholder {
    color: rgba(255, 255, 255, 0.45);
}

button {
    border: none;
    border-radius: 12px;
    padding: 10px 12px;
    color: var(--text);
    cursor: pointer;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
}

button.primary {
    background: linear-gradient(135deg, rgba(124, 77, 255, 0.8), rgba(124, 77, 255, 0.35));
    border-color: rgba(124, 77, 255, 0.6);
}

button.danger {
    background: linear-gradient(135deg, rgba(255, 93, 93, 0.85), rgba(255, 93, 93, 0.25));
    border-color: rgba(255, 93, 93, 0.6);
}

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

.clickable {
    cursor: pointer;
}

.clickable:hover {
    border-color: rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.07);
}

.link {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.panel {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 12px;
    padding: 10px 10px;
}

.timeline {
    display: grid;
    gap: 12px;
    position: relative;
}

.timeline-header {
    display: grid;
    gap: 4px;
    padding: 4px 2px 8px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}

.timeline-header-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text);
}

.timeline-header-label {
    color: var(--muted);
}

.timeline-header-arrow {
    color: var(--faint);
}

.timeline-axis,
.timeline-row {
    display: grid;
    grid-template-columns: minmax(160px, 230px) 1fr;
    gap: 12px;
    align-items: center;
}

.timeline-axis-label {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.5;
}

.timeline-axis-track {
    position: relative;
    height: 20px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.timeline-axis-track::before {
    content: "";
    position: absolute;
    left: 6px;
    right: 6px;
    top: 50%;
    height: 1px;
    background: rgba(255, 255, 255, 0.15);
}

.timeline-tick {
    position: absolute;
    top: -18px;
    transform: translateX(-50%);
    font-size: 11px;
    color: var(--faint);
    white-space: nowrap;
}

.timeline-tick::after {
    content: "";
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
}

.timeline-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 12px;
    color: var(--muted);
    padding-left: 2px;
    justify-content: center;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    display: inline-block;
}

.legend-dot.online {
    background: rgba(35, 201, 109, 0.9);
}

.legend-dot.leave {
    background: rgba(88, 179, 255, 0.9);
}

.legend-dot.timeout {
    background: rgba(255, 93, 93, 0.9);
}

.timeline-rows {
    display: grid;
    gap: 10px;
}

.timeline-hover-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(255, 255, 255, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 120ms ease;
}

.timeline-hover-tip {
    position: absolute;
    transform: translateX(-50%);
    background: rgba(15, 22, 38, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 11px;
    color: var(--text);
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    transition: opacity 120ms ease;
}

.timeline-hover-info {
    margin-top: 6px;
    font-size: 11px;
    color: var(--faint);
}

.timeline-row {
    padding: 18px 10px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.timeline-row.teacher {
    background: linear-gradient(135deg, rgba(124, 77, 255, 0.12), rgba(255, 255, 255, 0.03));
    border-color: rgba(124, 77, 255, 0.28);
}

.timeline-user-name {
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: relative;
}

.timeline-user-name.copyable {
    cursor: pointer;
}

.timeline-user-name.copyable::after {
    content: attr(data-user-id);
    position: absolute;
    left: 0;
    top: 22px;
    background: rgba(15, 22, 38, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    padding: 2px 8px;
    font-size: 11px;
    color: var(--text);
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    transition: opacity 120ms ease;
}

.timeline-user-name.copyable:hover::after {
    opacity: 1;
}

.timeline-user-meta {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.timeline-anomaly {
    margin-top: 6px;
    font-size: 12px;
    color: #ff8a8a;
}

.timeline-track {
    position: relative;
    height: 14px;
    border-radius: 999px;
    overflow: visible;
}

.timeline-seg {
    position: absolute;
    top: 0;
    bottom: 0;
    border-radius: 999px;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.25);
}

.timeline-seg.online {
    background: linear-gradient(90deg, rgba(35, 201, 109, 0.95), rgba(35, 201, 109, 0.35));
}

.timeline-seg.leave {
    background: linear-gradient(90deg, rgba(88, 179, 255, 0.95), rgba(88, 179, 255, 0.35));
}

.timeline-seg.timeout {
    background: linear-gradient(90deg, rgba(255, 93, 93, 0.95), rgba(255, 93, 93, 0.35));
}

.timeline-bubble {
    position: absolute;
    top: -22px;
    transform: translateX(-50%);
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 10px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.24);
    white-space: nowrap;
}

.timeline-bubble.warn {
    background: rgba(255, 107, 107, 0.2);
    border-color: rgba(255, 107, 107, 0.45);
}

.timeline-bubble.repair {
    background: rgba(242, 201, 76, 0.2);
    border-color: rgba(242, 201, 76, 0.5);
}

.timeline-bubble.timeout {
    background: rgba(255, 93, 93, 0.2);
    border-color: rgba(255, 93, 93, 0.5);
}

.timeline-empty {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: var(--faint);
}

@media (max-width: 980px) {
    .timeline-axis,
    .timeline-row {
        grid-template-columns: 1fr;
    }

    .timeline-axis-track {
        margin-top: 6px;
    }
}

.tabs {
    display: inline-flex;
    gap: 14px;
    align-items: center;
}

.tab {
    padding: 0;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.75);
    border-radius: 0;
    border-bottom: 2px solid transparent;
    padding-bottom: 6px;
}

.tab.active {
    color: rgba(255, 255, 255, 0.92);
    border-bottom-color: rgba(124, 77, 255, 0.85);
}

.tab:hover {
    color: rgba(255, 255, 255, 0.92);
}

.grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 14px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
}

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

.card-title {
    color: var(--muted);
    font-size: 16px;
    letter-spacing: 0.2px;
}

.card-value {
    font-size: 22px;
    font-weight: 800;
    margin-top: 6px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.05);
    font-size: 12px;
    color: var(--muted);
}

.pill.ok {
    border-color: rgba(35, 201, 109, 0.35);
    color: rgba(35, 201, 109, 0.95);
}

.pill.warn {
    border-color: rgba(245, 197, 66, 0.35);
    color: rgba(245, 197, 66, 0.95);
}

.pill.bad {
    border-color: rgba(255, 93, 93, 0.35);
    color: rgba(255, 93, 93, 0.95);
}

.legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
    min-width: 160px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
}

.legend-label {
    min-width: 42px;
}

.legend-value {
    margin-left: auto;
    color: rgba(255, 255, 255, 0.78);
    font-variant-numeric: tabular-nums;
}

.legend-percent {
    margin-left: 8px;
    color: var(--faint);
    font-variant-numeric: tabular-nums;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    flex: 0 0 10px;
}

.axis {
    position: relative;
    height: 14px;
    margin-top: 6px;
    color: var(--faint);
    font-size: 10px;
}

.axis-inner {
    position: relative;
    height: 14px;
}

.axis-tick {
    position: absolute;
    transform: translateX(-50%);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sparkline {
    width: 100%;
    height: 44px;
    margin-top: 10px;
    opacity: 0.95;
}

.sparkline-svg {
    width: 100%;
    height: auto;
    display: block;
}

.sparkline-axis {
    stroke: rgba(255, 255, 255, 0.12);
    stroke-width: 1;
    shape-rendering: crispEdges;
}

.sparkline-grid {
    stroke: rgba(255, 255, 255, 0.06);
    stroke-width: 1;
    shape-rendering: crispEdges;
}

.sparkline-ytext {
    fill: rgba(255, 255, 255, 0.55);
    font-size: 8px;
    font-variant-numeric: tabular-nums;
}

.sparkline-half {
    max-width: 50%;
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 900px) {
    .sparkline-half {
        max-width: 100%;
    }
}

.sparkline-hit {
    pointer-events: all;
}

.chart-tooltip {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(10, 16, 30, 0.94);
    box-shadow: var(--shadow);
    color: rgba(255, 255, 255, 0.92);
    font-size: 12px;
    line-height: 1.35;
    white-space: nowrap;
    transform: translate(-50%, -120%);
    opacity: 0;
    transition: opacity 80ms ease;
}

.chart-tooltip.visible {
    opacity: 1;
}

.chart-tooltip .tip-title {
    font-variant-numeric: tabular-nums;
}

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

.table th,
.table td {
    padding: 10px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.09);
    text-align: left;
    font-size: 13px;
    color: var(--muted);
}

.table th {
    color: rgba(255, 255, 255, 0.78);
    font-weight: 700;
    background: rgba(255, 255, 255, 0.03);
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New",
        monospace;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
}

.copyable {
    cursor: pointer;
}

.copyable .copy-icon {
    opacity: 0;
    margin-left: 6px;
    display: inline-flex;
    vertical-align: -3px;
    transition: opacity 120ms ease;
}

.copyable:hover .copy-icon {
    opacity: 0.75;
}

.copyable .copy-icon svg {
    width: 14px;
    height: 14px;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
}

.muted {
    color: var(--muted);
}

.hl {
    background: rgba(255, 205, 80, 0.2);
    color: rgba(255, 230, 160, 0.95);
    padding: 0 2px;
    border-radius: 3px;
}

.note {
    color: var(--faint);
    font-size: 12px;
    line-height: 1.5;
}

.row {
    display: flex;
    align-items: center;
    /* justify-content: space-between; */
    gap: 12px;
}

.toast {
    position: fixed;
    left: 50%;
    top: 18px;
    transform: translateX(-50%);
    z-index: 50;
    background: rgba(15, 22, 38, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: var(--shadow);
    min-width: 360px;
    max-width: min(560px, calc(100vw - 24px));
    display: none;
}

.toast.show {
    display: block;
}

.toast-title {
    font-weight: 800;
    font-size: 14px;
}
.toast-msg {
    color: var(--muted);
    font-size: 13px;
    margin-top: 4px;
    white-space: pre-wrap;
}

.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(6, 10, 20, 0.7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 60;
    padding: 24px;
}

.modal-card {
    width: min(760px, 100%);
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 18px 18px 16px;
}

.modal-header {
    font-size: 16px;
    font-weight: 700;
}

.modal-body {
    margin-top: 12px;
}

.form-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 10px 12px;
    align-items: center;
}

.form-grid label {
    color: var(--muted);
    font-size: 13px;
}

.form-grid .input,
.form-grid textarea,
.form-grid select {
    width: 100%;
}

.form-grid textarea {
    min-height: 70px;
    resize: vertical;
}

.form-hint {
    grid-column: 2 / -1;
    color: var(--faint);
    font-size: 12px;
    margin-top: -6px;
}

.form-error {
    grid-column: 1 / -1;
    color: var(--red);
    font-size: 12px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

.qty-stepper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.qty-stepper input {
    width: 120px;
}

.qty-stepper button {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 10px;
    font-weight: 700;
}

@media (max-width: 980px) {
    .container {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: sticky;
        top: 0;
        z-index: 10;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .nav {
        grid-auto-flow: column;
        grid-auto-columns: 1fr;
        overflow-x: auto;
        padding-bottom: 6px;
    }
}

.icon-note-btn, 
.icon-note-inline {
    padding: 5px;
    height: 24px;
    border-radius: 8px;
}


.icon-note-btn svg,
.icon-note-inline svg {
    width: 14px;
}

.action-note-save {
    height: 35px;
    padding: 5px 10px;
}