:root {
    --bg: #1a1e24;
    --panel: #41485b;
    --text: #e9edf1;
    --muted: #9aa3ad;
    --accent: #3aa6ff;
    --ok: #56d364;
    --warn: #ffcc00;
    --err: #ff6e6e;
    --grid: #3b4357;
    --edge: #ff7a59;
    --center: #00e0b8;
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.wrap {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 16px;
    min-height: 100vh;
}

.left {
    background: var(--panel);
    padding: 16px 18px;
    border-right: 1px solid #222939;
}

.right {
    padding: 16px;
    overflow: auto;
}

h1 {
    font-size: 18px;
    margin: 8px 0 16px;
    color: var(--text);
}

h2 {
    font-size: 14px;
    margin: 18px 0 8px;
    color: var(--muted);
    font-weight: 600;
}

.row {
    display: grid;
    grid-template-columns: 1fr 120px;
    gap: 8px;
    margin: 8px 0;
    align-items: center;
}

.row label {
    font-size: 13px;
    color: var(--text);
}

.row input,
.row select {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #2a3142;
    background: #101522;
    color: var(--text);
    font-size: 13px;
}

.row input[type="range"] {
    padding: 0;
}

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

.btns {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

button {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #2a3142;
    background: #101522;
    color: var(--text);
    cursor: pointer;
}

button.primary {
    background: var(--accent);
    color: #00223a;
    border: none;
}

.kpi {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 12px;
}

.kpi .card {
    background: #101522;
    border: 1px solid #2a3142;
    border-radius: 8px;
    padding: 10px;
}

.kpi .card .val {
    font-size: 16px;
    font-weight: 700;
}

.warn {
    color: var(--warn);
    font-size: 12px;
}

.err {
    color: var(--err);
    font-size: 12px;
}

.svg-host {
    background: #0b0e16;
    border: 1px dashed #2a3142;
    border-radius: 10px;
    padding: 8px;
    min-height: 300px;
}

.legend {
    margin-top: 8px;
    font-size: 12px;
    color: var(--muted);
}

.small {
    font-size: 11px;
    color: var(--muted);
}

.hr {
    height: 1px;
    background: #1e2434;
    margin: 12px 0;
}

.code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.grid-label {
    fill: #7c8596;
    font-size: 11px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    user-select: none;
}

.three-host {
    background: #0b0e16;
    border: 1px dashed #2a3142;
    border-radius: 10px;
    padding: 0;
    min-height: 420px;
    margin-top: 12px;
    position: relative;
}

.three-host .hint {
    position: absolute;
    left: 8px;
    top: 8px;
    font-size: 11px;
    color: var(--muted);
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 6px;
    border-radius: 4px;
    z-index: 10;
}

.three-host canvas {
    border-radius: 10px;
}

.right-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.column {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.svg-host {
    flex: 1;
}

.three-host {
    flex: 1;
    margin-top: 0;
}

.offset-table {
    background: #0b0e16;
    border: 1px dashed #2a3142;
    border-radius: 10px;
    padding: 16px;
    margin-top: 12px;
}

.offset-table h3 {
    margin: 0 0 12px 0;
    font-size: 16px;
    color: var(--text);
}

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

.table-controls label {
    font-size: 13px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.table-controls select {
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #2a3142;
    background: #101522;
    color: var(--text);
    font-size: 12px;
}

.table-controls button {
    font-size: 12px;
    padding: 6px 10px;
}

.table-wrapper {
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

.offset-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.offset-table th,
.offset-table td {
    padding: 6px 10px;
    text-align: right;
    border: 1px solid #2a3142;
}

.offset-table th {
    background: #151924;
    color: var(--muted);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
}

.offset-table td {
    background: #101522;
    color: var(--text);
}

.offset-table tr:nth-child(even) td {
    background: #0f1419;
}

.offset-table tr:hover td {
    background: #1a1f2a;
}

/* Выделение специальных строк */
.offset-table tr.highlight td {
    background: rgba(58, 166, 255, 0.1);
    border-color: rgba(58, 166, 255, 0.3);
}

.offset-table .zero-line td {
    background: rgba(0, 224, 184, 0.1);
    border-color: rgba(0, 224, 184, 0.3);
}

.offset-table .base-line td {
    background: rgba(255, 122, 89, 0.1);
    border-color: rgba(255, 122, 89, 0.3);
}

/* Адаптивные стили */
@media (max-width: 1200px) {
    .wrap {
        grid-template-columns: 300px 1fr;
    }
    .left {
        padding: 12px;
    }
    .right {
        padding: 12px;
    }
}

@media (max-width: 992px) {
    .wrap {
        grid-template-columns: 1fr;
    }
    .left {
        border-right: none;
        border-bottom: 1px solid #222939;
    }
    .right-columns {
        grid-template-columns: 1fr;
    }
    .three-host {
        height: 300px;
    }
}

@media (max-width: 768px) {
    .row {
        grid-template-columns: 1fr;
    }
    .btns {
        flex-direction: column;
    }
    .kpi {
        grid-template-columns: 1fr;
    }
    .table-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 16px;
    }
    h2 {
        font-size: 13px;
    }
    .row label {
        font-size: 12px;
    }
    .row input,
    .row select {
        font-size: 12px;
        padding: 6px 8px;
    }
    button {
        font-size: 12px;
        padding: 6px 10px;
    }
    .kpi .card .val {
        font-size: 14px;
    }
    .offset-table h3 {
        font-size: 14px;
    }
    .offset-table th,
    .offset-table td {
        font-size: 11px;
        padding: 4px 8px;
    }
}