:root {
    --bg: #080b0e;
    --panel: #10151a;
    --panel-2: #141b21;
    --panel-3: #192128;
    --line: #28343d;
    --line-soft: #1c262d;
    --text: #e8eef2;
    --muted: #84939e;
    --accent: #4fb5d8;
    --accent-soft: rgba(79,181,216,.12);
    --good: #67c895;
    --warn: #e1ae65;
    --danger: #e56f6f;
    --radius: 7px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

body {
    overflow: hidden;
}

button,
input {
    font: inherit;
}

button {
    color: inherit;
}

button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.login-layer {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(
            circle at 50% 30%,
            rgba(79,181,216,.08),
            transparent 35%
        ),
        #080b0e;
}

.login-layer.hidden {
    display: none;
}

.login-card {
    width: min(420px, 100%);
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    box-shadow: 0 22px 70px rgba(0,0,0,.42);
}

.login-card h1 {
    margin: 28px 0 8px;
    font-size: 20px;
}

.login-brand,
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .12em;
}

.brand-name {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: .04em;
}

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

.login-field {
    display: grid;
    gap: 7px;
    margin-top: 16px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.login-field input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #0b1014;
    color: var(--text);
}

.login-button {
    width: 100%;
    margin-top: 20px;
}

.login-message {
    min-height: 20px;
    margin-top: 12px;
    color: var(--danger);
    font-size: 12px;
}

.app-shell {
    display: grid;
    grid-template-columns: 255px minmax(0, 1fr) 285px;
    grid-template-rows: 62px minmax(0, 1fr) 38px;
    grid-template-areas:
        "header header header"
        "left main right"
        "footer footer footer";
    width: 100vw;
    height: 100vh;
}

.app-shell[aria-hidden="true"] {
    visibility: hidden;
}

.topbar {
    grid-area: header;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 0 18px;
    border-bottom: 1px solid var(--line);
    background: #0d1216;
}

.system-strip {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-pill,
.authority-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 30px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: #0a0f13;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .06em;
}

.status-pill.online {
    color: var(--good);
}

.status-pill.error {
    color: var(--danger);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: currentColor;
}

.authority-pill {
    color: var(--accent);
}

.topbar-button,
.tool,
.action,
.primary {
    border: 1px solid var(--line);
    border-radius: 5px;
    background: #11181d;
    cursor: pointer;
}

.topbar-button {
    min-height: 30px;
    padding: 0 10px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
}

.sidebar {
    overflow-y: auto;
    background: var(--panel);
}

.sidebar-left {
    grid-area: left;
    border-right: 1px solid var(--line);
}

.sidebar-right {
    grid-area: right;
    border-left: 1px solid var(--line);
}

.panel-section {
    padding: 16px;
    border-bottom: 1px solid var(--line-soft);
}

.section-title {
    margin-bottom: 13px;
    color: #b3c0c8;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .11em;
    text-transform: uppercase;
}

.field {
    display: grid;
    gap: 3px;
    margin-bottom: 12px;
}

.field:last-child {
    margin-bottom: 0;
}

.field-label {
    color: var(--muted);
    font-size: 10px;
}

.metric-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px solid rgba(255,255,255,.035);
    font-size: 11px;
}

.metric-row:last-child {
    border-bottom: 0;
}

.metric-row span {
    color: var(--muted);
}

.metric-row strong {
    text-align: right;
    font-weight: 650;
}

.dimension-grid {
    display: grid;
    gap: 8px;
}

.dimension-grid label {
    display: grid;
    grid-template-columns: 18px minmax(0,1fr) 24px;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 11px;
}

.dimension-grid input {
    min-width: 0;
    height: 32px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #0b1014;
    color: var(--text);
    padding: 0 8px;
}

.small-note {
    color: var(--muted);
    font-size: 10px;
    line-height: 1.55;
}

.block {
    display: block;
    margin-top: 3px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 8px 0;
    color: #bac6cc;
    font-size: 11px;
}

.check-row input {
    accent-color: var(--accent);
}

.workspace {
    grid-area: main;
    display: grid;
    min-width: 0;
    grid-template-rows: 46px minmax(0,1fr) auto;
    background:
        radial-gradient(
            circle at center,
            #12191e,
            #090d10 68%
        );
}

.workspace-toolbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    border-bottom: 1px solid var(--line);
    background: #0d1216;
}

.workspace-toolbar .tool-group:last-child {
    justify-content: flex-end;
}

.workspace-title {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .12em;
}

.tool-group {
    display: flex;
    gap: 5px;
}

.tool {
    min-height: 28px;
    padding: 0 9px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
}

.tool:hover,
.tool.active {
    border-color: #426473;
    color: var(--accent);
    background: var(--accent-soft);
}

.viewport-shell {
    position: relative;
    min-height: 0;
    overflow: hidden;
}

#viewport {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.viewport-overlay {
    position: absolute;
    z-index: 2;
    display: grid;
    gap: 3px;
    pointer-events: none;
    color: var(--muted);
    font-size: 9px;
    letter-spacing: .03em;
}

.viewport-overlay strong {
    color: #c6d1d6;
    font-size: 9px;
    letter-spacing: .08em;
}

.top-left {
    top: 14px;
    left: 14px;
}

.top-right {
    top: 14px;
    right: 14px;
    text-align: right;
}

.bottom-left {
    bottom: 14px;
    left: 14px;
}

.bottom-right {
    right: 14px;
    bottom: 14px;
    text-align: right;
}

.axis {
    position: absolute;
    z-index: 3;
    bottom: 42px;
    font-size: 9px;
    font-weight: 800;
}

.axis-x {
    left: 22px;
    color: #db7777;
}

.axis-y {
    left: 38px;
    color: #75c78f;
}

.axis-z {
    left: 54px;
    color: #75a8d7;
}

.action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding: 10px 12px;
    border-top: 1px solid var(--line);
    background: #0d1216;
}

.action,
.primary {
    min-height: 34px;
    padding: 0 13px;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .04em;
}

.action.primary,
.primary {
    border-color: #3f7185;
    background: #14313d;
    color: #8bd2eb;
}

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

.action.danger {
    border-color: #63393b;
    color: var(--danger);
}

button:disabled {
    opacity: .42;
    cursor: not-allowed;
}

.job-state {
    padding: 9px;
    margin-bottom: 8px;
    border: 1px solid var(--line);
    border-radius: 5px;
    color: var(--muted);
    background: #0b1014;
    font-size: 10px;
    font-weight: 700;
}

.job-state.queued,
.job-state.processing {
    color: var(--warn);
}

.job-state.completed {
    color: var(--good);
}

.job-state.failed {
    color: var(--danger);
}

.result-message {
    margin-top: 8px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.5;
}

.export-result {
    display: grid;
    gap: 4px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line-soft);
}

.export-result strong {
    font-size: 10px;
}

.export-result span {
    overflow-wrap: anywhere;
    color: var(--muted);
    font-family:
        ui-monospace,
        SFMono-Regular,
        Menlo,
        Consolas,
        monospace;
    font-size: 9px;
    line-height: 1.45;
}

.machine-card {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 9px 0;
    border-bottom: 1px solid var(--line-soft);
    font-size: 11px;
}

.machine-type {
    min-width: 38px;
    padding: 3px 4px;
    border: 1px solid var(--line);
    border-radius: 3px;
    color: var(--accent);
    text-align: center;
    font-size: 8px;
    font-weight: 800;
}

.danger-text {
    color: var(--danger);
}

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

.compact-value {
    max-width: 150px;
    overflow-wrap: anywhere;
    font-size: 9px;
}

.footer {
    grid-area: footer;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 14px;
    border-top: 1px solid var(--line);
    background: #0b1014;
    color: var(--muted);
    font-size: 9px;
}

.footer > div {
    display: flex;
    align-items: center;
    gap: 7px;
}

.footer-label {
    color: #63737d;
}

.footer strong {
    color: #aebbc3;
    font-size: 9px;
}

.footer .locked {
    margin-left: auto;
    color: var(--danger);
    font-weight: 800;
    letter-spacing: .07em;
}

@media (max-width: 1000px) {
    body {
        overflow: auto;
    }

    .app-shell {
        width: 100%;
        min-height: 100vh;
        height: auto;
        grid-template-columns: 220px minmax(0,1fr);
        grid-template-rows: 62px minmax(540px,70vh) auto auto 38px;
        grid-template-areas:
            "header header"
            "main main"
            "left right"
            "left right"
            "footer footer";
    }

    .sidebar {
        overflow: visible;
    }
}

@media (max-width: 700px) {
    .app-shell {
        display: block;
    }

    .topbar {
        min-height: 72px;
        flex-wrap: wrap;
        padding-top: 8px;
        padding-bottom: 8px;
    }

    .system-strip {
        flex-wrap: wrap;
    }

    .sidebar {
        border: 0;
        border-bottom: 1px solid var(--line);
    }

    .workspace {
        min-height: 620px;
    }

    .workspace-toolbar {
        grid-template-columns: 1fr;
        padding: 8px;
    }

    .workspace-title {
        display: none;
    }

    .workspace-toolbar .tool-group:last-child {
        justify-content: flex-start;
    }

    .viewport-shell {
        min-height: 430px;
    }

    .footer {
        flex-wrap: wrap;
        min-height: 52px;
        padding: 8px 12px;
    }

    .footer .locked {
        margin-left: 0;
    }
}
