:root
{
    --bg0: #1a1d22;
    --bg1: #14161a;
    --card: rgba(18, 20, 24, 0.78);
    --card2: rgba(14, 16, 19, 0.90);
    --border: rgba(255, 255, 255, 0.09);
    --border2: rgba(255, 255, 255, 0.14);

    --text: #e6e8ea;
    --muted: rgba(230, 232, 234, 0.60);
    --muted2: rgba(230, 232, 234, 0.42);

    --accent: rgba(255, 255, 255, 0.22);
    --glow: rgba(255, 255, 255, 0.08);

    --ok: #44d07b;
    --warn: #f0b35e;
    --err: #ff5a5a;

    --radius: 14px;
    --shadow: 0 12px 40px rgba(0,0,0,0.55);
}

* { box-sizing: border-box; }

body
{
    margin: 0;
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background:
        radial-gradient(1000px 600px at 15% 10%, rgba(255,255,255,0.06), transparent 60%),
        radial-gradient(900px 500px at 85% 25%, rgba(255,255,255,0.04), transparent 55%),
        linear-gradient(180deg, var(--bg0), var(--bg1));
}

.app
{
    max-width: 1200px;
    margin: 0 auto;
    padding: 22px 26px 40px 26px;
}

/* ------------------------------ */
/* Header */
/* ------------------------------ */

.header
{
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 14px;
}

.header-left
{
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.header-title
{
    margin: 0;
    font-size: 24px;
    font-weight: 650;
    letter-spacing: 0.2px;
}

.header-sub
{
    color: var(--muted);
    font-size: 12px;
}

.logo
{
    height: 64px;
    margin-left: auto;
    display: block;
    filter: drop-shadow(0 10px 25px rgba(0,0,0,0.5));
    opacity: 0.95;
}

/* ------------------------------ */
/* Cards / sections */
/* ------------------------------ */

.card
{
    background: linear-gradient(180deg, var(--card), var(--card2));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.section
{
    padding: 14px 16px 10px 16px;
}

.section-title
{
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--muted);
    margin-bottom: 10px;
}

/* ------------------------------ */
/* Top bar */
/* ------------------------------ */

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

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

.pps-label
{
    font-size: 13px;
    color: var(--muted);
    letter-spacing: 0.3px;
}

.topbar-conn
{
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

/* ------------------------------ */
/* Buttons */
/* ------------------------------ */

button
{
    padding: 8px 14px;
    background: rgba(255,255,255,0.04);
    color: var(--text);
    border: 1px solid var(--border2);
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    letter-spacing: 0.2px;
    transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

button:hover
{
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.24);
    box-shadow: 0 0 12px rgba(255,255,255,0.04);
}

button:active
{
    transform: translateY(1px);
    background: rgba(255,255,255,0.10);
}

button:disabled
{
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
}

/* ------------------------------ */
/* Status chip */
/* ------------------------------ */

.status
{
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--border2);
    background: rgba(0,0,0,0.25);
    font-weight: 600;
    letter-spacing: 0.2px;
}

.ok   { color: var(--ok); }
.warn { color: var(--warn); }

/* ------------------------------ */
/* Diagnostics */
/* ------------------------------ */

.err
{
    margin-top: 10px;
    padding: 12px 14px;
    color: var(--err);
    white-space: pre-wrap;
    border: 1px solid rgba(255,90,90,0.25);
    background: rgba(255,90,90,0.05);
}

/* ------------------------------ */
/* Layout grid */
/* ------------------------------ */

.grid
{
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: stretch;
}

.plot-card
{
    grid-column: 1 / -1;
}

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

/* ------------------------------ */
/* Telemetry table (compact) */
/* ------------------------------ */

.telem-table
{
    width: 100%;
    border-collapse: collapse;
    margin-top: 2px;
    font-size: 13px;
}

.telem-table thead th
{
    padding: 4px 8px;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--muted2);
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.10);
}

.telem-table thead th:first-child
{
    width: 30%;
}

.telem-table td
{
    padding: 4px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

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

.telem-table td:first-child
{
    color: var(--muted);
    width: 30%;
}

.telem-table td.mono
{
    font-size: 16px;
    font-weight: 400;
    letter-spacing: 0.6px;
}

.telem-table td.muted-val
{
    font-size: 12px;
    color: var(--muted2);
    letter-spacing: 0.3px;
}

/* ------------------------------ */
/* Control layout                  */
/* ------------------------------ */

.control-card
{
    display: flex;
    flex-direction: column;
}

.control-layout
{
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0;
    align-items: stretch;
    margin-top: 8px;
    flex: 1;
}

.control-divider
{
    display: none;
}

/* ---- Left panel: stacked instrument rows ---- */

.control-panel
{
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(0,0,0,0.22);
    overflow: hidden;
}

.ctrl-row
{
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    gap: 12px;
    min-height: 42px;
    transition: background 0.12s ease;
}

.ctrl-row:last-child
{
    border-bottom: none;
}

.ctrl-row--highlight
{
    background: rgba(255,255,255,0.025);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.ctrl-label
{
    font-size: 11px;
    letter-spacing: 0.9px;
    text-transform: uppercase;
    color: var(--muted2);
    flex-shrink: 0;
}

.ctrl-value
{
    font-size: 13px;
    color: var(--text);
    letter-spacing: 0.5px;
    text-align: right;
}

.ctrl-value--large
{
    font-size: 28px;
    font-weight: 300;
    letter-spacing: -0.5px;
    color: #fff;
    text-shadow: 0 0 20px rgba(255,255,255,0.08);
}

.ctrl-select
{
    padding: 5px 10px;
    background: rgba(255,255,255,0.04);
    color: var(--text);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 0;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    min-width: 90px;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.ctrl-select:hover
{
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.22);
}

.ctrl-select:focus
{
    border-color: rgba(255,255,255,0.28);
}

.ctrl-select option
{
    background: #0b0d10;
    color: var(--text);
}

/* Toggle switch */
.ctrl-toggle
{
    display: flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

.ctrl-toggle input[type="checkbox"]
{
    display: none;
}

.ctrl-toggle-track
{
    display: inline-block;
    width: 36px;
    height: 18px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    position: relative;
    transition: background 0.2s ease, border-color 0.2s ease;
    flex-shrink: 0;
}

.ctrl-toggle-track::after
{
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    background: rgba(255,255,255,0.35);
    transition: left 0.2s ease, background 0.2s ease;
}

.ctrl-toggle input[type="checkbox"]:checked + .ctrl-toggle-track
{
    background: rgba(68, 208, 123, 0.18);
    border-color: rgba(68, 208, 123, 0.45);
}

.ctrl-toggle input[type="checkbox"]:checked + .ctrl-toggle-track::after
{
    left: 20px;
    background: var(--ok);
}

/* ---- Right panel: buttons + slider rail ---- */

.control-right
{
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 0;
    padding: 0;
    border-left: 1px solid rgba(255,255,255,0.06);
}

.control-buttons-vertical
{
    display: flex;
    flex-direction: column;
    justify-content: stretch;
}

.control-buttons-vertical button
{
    flex: 1;
    width: 68px;
    padding: 0;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.3px;
    border-radius: 0 !important;
    border: none;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.02);
    color: var(--muted);
    transition: background 0.12s ease, color 0.12s ease;
}

.control-buttons-vertical button:last-child
{
    border-bottom: none;
}

.control-buttons-vertical button:hover:not(:disabled)
{
    background: rgba(255,255,255,0.06);
    color: var(--text);
    box-shadow: none;
}

.control-buttons-vertical button:active:not(:disabled)
{
    background: rgba(255,255,255,0.10);
    transform: none;
}

/* Slider rail */

.slider-rail
{
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 10px;
    background:
        linear-gradient(180deg,
            rgba(255,255,255,0.02) 0%,
            rgba(0,0,0,0.10) 100%);
    border-left: 1px solid rgba(255,255,255,0.06);
    min-width: 38px;
}

#throttleSlider
{
    -webkit-appearance: slider-vertical;
    appearance: slider-vertical;
    writing-mode: bt-lr;
    width: 6px;
    height: 100%;
    min-height: 180px;
    flex-shrink: 0;
    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.08);
    outline: none;
    border-radius: 0 !important;
}

#throttleSlider::-webkit-slider-thumb
{
    appearance: none;
    width: 22px;
    height: 10px;
    background: rgba(255,255,255,0.85);
    border: 1px solid rgba(0,0,0,0.40);
    box-shadow: 0 2px 8px rgba(0,0,0,0.50);
    cursor: pointer;
    border-radius: 0;
}

#throttleSlider::-moz-range-thumb
{
    width: 22px;
    height: 10px;
    background: rgba(255,255,255,0.85);
    border: 1px solid rgba(0,0,0,0.40);
    box-shadow: 0 2px 8px rgba(0,0,0,0.50);
    cursor: pointer;
    border-radius: 0;
}

/* General range (horizontal fallback) */
input[type="range"]
{
    height: 10px;
    appearance: none;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(255,255,255,0.22), rgba(255,255,255,0.06));
    border: 1px solid rgba(255,255,255,0.12);
    outline: none;
}

input[type="range"]::-webkit-slider-thumb
{
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(255,255,255,0.85);
    border: 1px solid rgba(0,0,0,0.35);
    box-shadow: 0 6px 18px rgba(0,0,0,0.55);
}

/* ------------------------------ */
/* Plot */
/* ------------------------------ */

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

.plot-actions-right
{
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.plot-wrap
{
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.10);
    background: rgba(0,0,0,0.18);
}

.plot-scroll
{
    overflow-x: auto;
    overflow-y: hidden;
}

#telemPlot
{
    width: 100%;
    display: block;
}

.plot-hint
{
    margin-top: 10px;
    font-size: 12px;
}

/* ------------------------------ */
/* Toggles / mono */
/* ------------------------------ */

.toggle
{
    display: inline-flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

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

input[type="checkbox"]
{
    accent-color: #bfbfbf;
}

.mono
{
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.subtle
{
    color: var(--muted2);
}

/* =============================== */
/* HARD EDGE MODE – no rounding    */
/* =============================== */

:root
{
    --radius: 0px;
}

.card,
button,
.status,
.slider-readout,
.plot-wrap,
input[type="range"],
input[type="range"]::-webkit-slider-thumb
{
    border-radius: 0 !important;
}
