/* ============================================================
   振动分析系统 · 工业测量终端主题
   ============================================================ */

:root {
    --bg: #060a13;
    --bg-2: #0a101d;
    --panel: #0d1526;
    --panel-2: #111c30;
    --line: rgba(148, 163, 184, 0.14);
    --line-strong: rgba(148, 163, 184, 0.3);
    --text: #cbd5e1;
    --text-dim: #64748b;
    --text-bright: #f1f5f9;
    --cyan: #22d3ee;
    --blue: #38bdf8;
    --green: #34d399;
    --amber: #fbbf24;
    --red: #f87171;
    --radius: 12px;
    --mono: "Consolas", "SF Mono", "Cascadia Mono", "JetBrains Mono", "Courier New", monospace;
    --sans: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
}

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

html {
    color-scheme: dark;
}

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

/* ---------- 背景：蓝图网格 + 顶部辉光 ---------- */

.bg-grid {
    position: fixed;
    inset: 0;
    z-index: -2;
    background-image:
        linear-gradient(rgba(56, 189, 248, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(56, 189, 248, 0.05) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 30%, transparent 100%);
    -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 30%, transparent 100%);
}

.bg-glow {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(ellipse 70% 40% at 50% -10%, rgba(34, 211, 238, 0.09), transparent 60%),
        radial-gradient(ellipse 50% 30% at 90% 110%, rgba(56, 189, 248, 0.05), transparent 60%);
    pointer-events: none;
}

/* ---------- 布局 ---------- */

.container {
    max-width: 1160px;
    margin: 0 auto;
    padding: 26px 20px 40px;
}

/* ---------- 顶栏 ---------- */

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
    padding: 14px 6px 18px;
    border-bottom: 1px solid var(--line);
    animation: rise-in 0.5s ease both;
}

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

.logo {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    color: var(--cyan);
    background: linear-gradient(145deg, rgba(34, 211, 238, 0.14), rgba(56, 189, 248, 0.05));
    border: 1px solid rgba(34, 211, 238, 0.35);
    border-radius: 10px;
    box-shadow: 0 0 22px rgba(34, 211, 238, 0.18), inset 0 0 12px rgba(34, 211, 238, 0.08);
}

.brand-text h1 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-bright);
}

.brand-text p {
    font-size: 0.68rem;
    letter-spacing: 2.2px;
    color: var(--text-dim);
    font-family: var(--mono);
}

/* ---------- 状态徽章 ---------- */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--line-strong);
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-dim);
    white-space: nowrap;
}

.status-badge::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.status-idle::before {
    background: var(--text-dim);
}

.status-ready {
    color: var(--green);
    border-color: rgba(52, 211, 153, 0.35);
}

.status-running {
    color: var(--cyan);
    border-color: rgba(34, 211, 238, 0.4);
}

.status-running::before {
    animation: pulse 1.1s ease-in-out infinite;
}

.status-done {
    color: var(--green);
    border-color: rgba(52, 211, 153, 0.35);
}

.status-error {
    color: var(--red);
    border-color: rgba(248, 113, 113, 0.4);
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.5); }
    50% { opacity: 0.55; box-shadow: 0 0 0 5px rgba(34, 211, 238, 0); }
}

/* ---------- 错误提示 ---------- */

.error-toast {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%) translateY(-12px);
    z-index: 100;
    max-width: min(560px, 90vw);
    padding: 11px 18px;
    border-radius: 9px;
    border: 1px solid rgba(248, 113, 113, 0.45);
    background: rgba(30, 12, 16, 0.95);
    color: #fca5a5;
    font-size: 0.88rem;
    font-weight: 600;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.error-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---------- 面板 ---------- */

.panel {
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 18px;
    overflow: hidden;
    animation: rise-in 0.5s ease both;
}

.panel:nth-child(3) { animation-delay: 0.06s; }
.panel:nth-child(4) { animation-delay: 0.12s; }
.panel:nth-child(5) { animation-delay: 0.18s; }
.panel:nth-child(6) { animation-delay: 0.24s; }
.panel:nth-child(7) { animation-delay: 0.3s; }
.panel:nth-child(8) { animation-delay: 0.36s; }

@keyframes rise-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--line);
    background: rgba(10, 16, 29, 0.5);
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-bright);
}

.panel-title svg {
    color: var(--cyan);
}

.panel-title em {
    font-style: normal;
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 1.8px;
    color: var(--text-dim);
    padding-left: 9px;
    border-left: 1px solid var(--line);
}

.panel-tag {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--text-dim);
    letter-spacing: 0.3px;
}

.panel-body {
    padding: 18px;
}

/* ---------- 视频舞台 (HUD) ---------- */

.stage {
    position: relative;
    aspect-ratio: 16 / 9;
    background:
        radial-gradient(ellipse 60% 60% at 50% 40%, rgba(34, 211, 238, 0.05), transparent 70%),
        #070c16;
    border-bottom: 1px solid var(--line);
    overflow: hidden;
}

/* 四角括号 */
.stage::before,
.stage::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    z-index: 6;
    pointer-events: none;
}

.stage::before {
    top: 12px;
    left: 12px;
    border-top: 2px solid rgba(34, 211, 238, 0.45);
    border-left: 2px solid rgba(34, 211, 238, 0.45);
}

.stage::after {
    bottom: 12px;
    right: 12px;
    border-bottom: 2px solid rgba(34, 211, 238, 0.45);
    border-right: 2px solid rgba(34, 211, 238, 0.45);
}

/* 扫描线 */
.scanline {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    z-index: 4;
    background: linear-gradient(90deg, transparent, rgba(34, 211, 238, 0.28), transparent);
    animation: scan 6s linear infinite;
    pointer-events: none;
}

@keyframes scan {
    0% { top: 3%; }
    100% { top: 96%; }
}

.upload-area {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 2px dashed rgba(148, 163, 184, 0.25);
    border-radius: 0;
    transition: border-color 0.25s ease, background 0.25s ease;
    z-index: 2;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: rgba(34, 211, 238, 0.65);
    background: rgba(34, 211, 238, 0.04);
}

.upload-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 24px;
    text-align: center;
}

.upload-icon {
    color: var(--cyan);
    opacity: 0.85;
    margin-bottom: 4px;
    transition: transform 0.25s ease;
}

.upload-area:hover .upload-icon {
    transform: translateY(-3px);
}

.upload-text {
    font-size: 1.02rem;
    font-weight: 600;
    color: var(--text-bright);
}

.upload-hint {
    font-size: 0.78rem;
    font-family: var(--mono);
    color: var(--text-dim);
    letter-spacing: 0.4px;
}

.video-preview,
.detection-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: none;
    object-fit: contain;
    background: #000;
}

.detection-canvas {
    z-index: 3;
    pointer-events: none;
}

/* ---------- 按钮 ---------- */

.btn-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 9px;
    border: 1px solid transparent;
    font-family: var(--sans);
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: 0.4px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #06b6d4, #38bdf8);
    color: #06121f;
    box-shadow: 0 2px 14px rgba(34, 211, 238, 0.25);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 4px 22px rgba(34, 211, 238, 0.4);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    border-color: var(--line-strong);
    color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
    border-color: rgba(34, 211, 238, 0.55);
    color: var(--text-bright);
    background: rgba(34, 211, 238, 0.05);
}

.btn-outline {
    background: transparent;
    border-color: rgba(52, 211, 153, 0.4);
    color: var(--green);
}

.btn-outline:hover:not(:disabled) {
    background: rgba(52, 211, 153, 0.08);
    box-shadow: 0 0 16px rgba(52, 211, 153, 0.2);
}

.btn-sm {
    padding: 7px 16px;
    font-size: 0.85rem;
}

.mode-select {
    padding: 9px 12px;
    border-radius: 9px;
    border: 1px solid var(--line-strong);
    background: var(--bg-2);
    color: var(--text);
    font-family: var(--sans);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s ease;
}

.mode-select:focus {
    border-color: rgba(34, 211, 238, 0.6);
}

/* ---------- 进度条 ---------- */

.progress-container {
    margin-bottom: 18px;
}

.progress-track {
    height: 6px;
    background: rgba(148, 163, 184, 0.12);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 7px;
}

.progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 3px;
    background: linear-gradient(90deg, #0891b2, #22d3ee, #7dd3fc);
    box-shadow: 0 0 10px rgba(34, 211, 238, 0.5);
    transition: width 0.25s ease;
}

.progress-text {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--text-dim);
    letter-spacing: 0.3px;
}

/* ---------- 步骤指示 ---------- */

.step-indicator {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.step {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 13px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-dim);
    background: rgba(148, 163, 184, 0.07);
    border: 1px solid transparent;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.step-link {
    flex: 0 0 14px;
    height: 1px;
    background: var(--line-strong);
}

.step.active {
    color: var(--cyan);
    background: rgba(34, 211, 238, 0.1);
    border-color: rgba(34, 211, 238, 0.45);
    box-shadow: 0 0 12px rgba(34, 211, 238, 0.15);
}

.step.done {
    color: var(--green);
    background: rgba(52, 211, 153, 0.1);
    border-color: rgba(52, 211, 153, 0.35);
}

.step.done::before {
    content: "✓";
    font-size: 0.72rem;
}

/* ---------- 数据卡片 ---------- */

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

.data-card {
    position: relative;
    background: rgba(10, 16, 29, 0.55);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 14px 12px;
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.data-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--cyan), transparent);
    opacity: 0.65;
}

.data-card:hover {
    border-color: rgba(34, 211, 238, 0.35);
}

.data-label {
    font-size: 0.74rem;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.data-value {
    font-family: var(--mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-bright);
    letter-spacing: 0.5px;
    line-height: 1.2;
    text-shadow: 0 0 18px rgba(34, 211, 238, 0.25);
}

/* ---------- 时间查询 ---------- */

.query-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(10, 16, 29, 0.4);
}

.query-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
}

.query-row input {
    padding: 8px 12px;
    width: 150px;
    font-family: var(--mono);
    font-size: 0.9rem;
    color: var(--text-bright);
    background: var(--bg-2);
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    outline: none;
    transition: border-color 0.2s ease;
}

.query-row input:focus {
    border-color: rgba(34, 211, 238, 0.6);
}

.query-row input:disabled {
    opacity: 0.4;
}

.query-row input::placeholder {
    color: var(--text-dim);
}

.query-result {
    font-family: var(--mono);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--cyan);
    margin-left: auto;
}

/* ---------- 图表 ---------- */

.chart-toolbar {
    display: flex;
    gap: 8px;
}

.chart-btn {
    padding: 5px 12px;
    border-radius: 7px;
    border: 1px solid var(--line-strong);
    background: transparent;
    color: var(--text-dim);
    font-family: var(--sans);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chart-btn:hover:not(:disabled) {
    color: var(--cyan);
    border-color: rgba(34, 211, 238, 0.5);
}

.chart-btn.active {
    color: var(--cyan);
    border-color: rgba(34, 211, 238, 0.5);
    background: rgba(34, 211, 238, 0.08);
}

.chart-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.chart-box {
    height: 340px;
    padding: 14px 14px 6px;
    position: relative;
}

/* ---------- 日志 ---------- */

.log-container {
    height: 170px;
    overflow-y: auto;
    padding: 12px 16px;
    background: #05080f;
    font-family: var(--mono);
    font-size: 0.78rem;
    line-height: 1.7;
}

.log-container::-webkit-scrollbar {
    width: 8px;
}

.log-container::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.2);
    border-radius: 4px;
}

.log-entry {
    margin-bottom: 2px;
    white-space: nowrap;
}

.log-info { color: #7dd3fc; }
.log-success { color: var(--green); }
.log-warning { color: var(--amber); }
.log-error { color: var(--red); }

/* ---------- 页脚 ---------- */

.footer {
    text-align: center;
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 1px;
    color: var(--text-dim);
    padding: 10px 0 4px;
}

/* ---------- 移动端 ---------- */

@media (max-width: 768px) {
    .container {
        padding: 16px 12px 32px;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .brand-text h1 {
        font-size: 1.15rem;
    }

    .btn-row {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .chart-box {
        height: 250px;
    }

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

    .query-result {
        width: 100%;
        margin-left: 0;
    }

    .step-indicator {
        gap: 4px;
    }

    .step {
        padding: 4px 10px;
        font-size: 0.74rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .scanline,
    .status-running::before {
        animation: none;
    }

    .panel,
    .header {
        animation: none;
    }
}
