:root {
    --bg-color: #f3f5fb;
    --card-bg: #ffffff;
    --accent: #4a6cf7;
    --accent-dark: #394fcd;
    --accent-muted: rgba(74, 108, 247, 0.12);
    --text-color: #1c2536;
    --subtle-text: #5f6b7c;
    --danger: #e94d4d;
    --success: #2eaf74;
    --warning: #f59e0b;
    --border-radius: 18px;
    --shadow: 0 24px 50px rgba(28, 37, 54, 0.12);
    --transition: all 0.18s ease;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: radial-gradient(circle at top, #eef3ff 0%, #f5f7fb 55%);
    color: var(--text-color);
}

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

.main-container {
    max-width: 1260px;
    margin: 40px auto 64px;
    padding: 0 24px;
}

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

.dashboard-header h1 {
    margin: 0 0 8px;
    font-size: 34px;
    font-weight: 700;
    letter-spacing: 0.015em;
}

.dashboard-header p {
    margin: 0;
    color: var(--subtle-text);
    font-size: 16px;
    line-height: 1.6;
}

.header-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 28px;
}

.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.card-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.card-heading h2 {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 600;
}

.card-heading p {
    margin: 0;
    color: var(--subtle-text);
    font-size: 14px;
}

button {
    appearance: none;
    border: none;
    border-radius: 999px;
    padding: 12px 26px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.01em;
    background: linear-gradient(135deg, var(--accent), #5d7dfb);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 14px 26px rgba(74, 108, 247, 0.25);
    transition: var(--transition);
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 18px 34px rgba(74, 108, 247, 0.28);
}

button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 12px 26px rgba(74, 108, 247, 0.24);
}

button:disabled {
    cursor: not-allowed;
    background: var(--accent-muted);
    color: var(--subtle-text);
    box-shadow: none;
}

button.ghost {
    background: transparent;
    color: var(--accent);
    border: 1px solid rgba(74, 108, 247, 0.35);
    box-shadow: none;
}

button.ghost:hover:not(:disabled) {
    background: rgba(74, 108, 247, 0.08);
    transform: translateY(-1px);
}

button.control {
    border-radius: 14px;
    padding: 14px 0;
    box-shadow: 0 8px 20px rgba(74, 108, 247, 0.16);
}

button.control.danger {
    background: linear-gradient(135deg, #f87171, #ef4444);
    box-shadow: 0 12px 24px rgba(239, 68, 68, 0.24);
}

button.control.danger:hover:not(:disabled) {
    box-shadow: 0 16px 28px rgba(239, 68, 68, 0.28);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(46, 175, 116, 0.15);
    color: var(--success);
    font-size: 13px;
    border-radius: 999px;
    letter-spacing: 0.01em;
    transition: var(--transition);
    white-space: nowrap;
}

.status-pill.alert {
    background: rgba(233, 77, 77, 0.16);
    color: var(--danger);
}

.status-pill.warn {
    background: rgba(245, 158, 11, 0.16);
    color: var(--warning);
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.button-row.compact {
    gap: 10px;
}

.range-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.range-row label {
    font-weight: 600;
    font-size: 14px;
}

.range-row input[type='range'] {
    flex: 1;
    accent-color: var(--accent);
}

.badge {
    background: rgba(74, 108, 247, 0.12);
    color: var(--accent);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
}

.hint {
    margin: 0;
    color: var(--subtle-text);
    font-size: 13px;
}

.driver-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 60px);
    gap: 12px;
}

.driver-pad .control {
    font-size: 20px;
}

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

.camera-frame {
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(28, 37, 54, 0.08);
}

.camera-frame img {
    width: 100%;
    display: block;
    background: #000;
}

.camera-placeholder {
    padding: 40px 24px;
    text-align: center;
    color: var(--subtle-text);
    background: rgba(8, 16, 32, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    font-size: 14px;
}

.camera-placeholder[hidden] {
    display: none;
}

.camera-frame img[hidden] {
    display: none;
}

.chart-wrap h3 {
    margin: 0 0 12px;
    font-size: 16px;
    color: var(--subtle-text);
    font-weight: 600;
}

.chart-container {
    background: rgba(255, 255, 255, 0.82);
    border-radius: var(--border-radius);
    box-shadow: inset 0 0 0 1px rgba(28, 37, 54, 0.05);
    padding: 20px;
    height: 280px;
}

#frequencyChart {
    width: 100%;
    height: 100%;
}

.slider-readout {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.big-number {
    font-size: 42px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.meta {
    color: var(--subtle-text);
    font-size: 13px;
}

.absolute-move {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.absolute-move input {
    flex: 1 1 160px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(28, 37, 54, 0.12);
    font-size: 15px;
}

.absolute-move input:focus {
    outline: none;
    border-color: rgba(74, 108, 247, 0.6);
    box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.15);
}

.ghost-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 999px;
    border: 1px solid rgba(28, 37, 54, 0.12);
    background: rgba(255, 255, 255, 0.4);
    font-weight: 600;
    font-size: 14px;
    color: var(--subtle-text);
    transition: var(--transition);
}

.ghost-button:hover {
    border-color: rgba(74, 108, 247, 0.35);
    color: var(--accent);
}

@media (max-width: 960px) {
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .card {
        padding: 24px;
    }

    .driver-pad {
        grid-template-rows: repeat(3, 54px);
        gap: 10px;
    }

    .chart-container {
        height: 240px;
    }

    button,
    .ghost-button {
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    .button-row {
        flex-direction: column;
        align-items: stretch;
    }
}
