:root {
    --shell: #f4f9fd;
    --sidebar: #f0f7fc;
    --panel: #ffffff;
    --panel-strong: #f8fcff;
    --surface-alt: #eaf5fb;
    --stroke: #d0e2ee;
    --stroke-strong: #a8c7da;
    --accent: #0e97d6;
    --accent-soft: rgba(14, 151, 214, 0.08);
    --success: #0a8d55;
    --success-soft: rgba(10, 141, 85, 0.08);
    --warning: #c88400;
    --warning-soft: rgba(255, 200, 87, 0.08);
    --danger: #d84c58;
    --danger-soft: rgba(255, 107, 107, 0.08);
    --text: #16354c;
    --muted: #70879b;
    --shadow-panel: 0 0 18px rgba(16, 40, 64, 0.2);
    --shadow-card: 0 0 14px rgba(16, 40, 64, 0.15);
}

* {
    box-sizing: border-box;
}

html,
body,
#app {
    min-height: 100%;
    margin: 0;
}

body {
    overflow: hidden;
    background: var(--shell);
    color: var(--text);
    font-family: Roboto, "Segoe UI", Arial, sans-serif;
    font-size: 14px;
    font-weight: 500;
}

button {
    font: inherit;
    cursor: pointer;
}

.wpf-window {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    width: 100vw;
    height: 100vh;
    background: var(--shell);
}

.wpf-sidebar {
    position: relative;
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    width: 248px;
    margin: 12px 0 12px 12px;
    overflow: hidden;
    border: 1px solid var(--stroke);
    border-radius: 24px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.22), transparent 140px),
        linear-gradient(135deg, rgba(255, 255, 255, 0.12), transparent 52%),
        var(--sidebar);
    box-shadow: var(--shadow-panel);
}

.sidebar-logo {
    display: grid;
    width: 56px;
    height: 56px;
    place-items: center;
    margin: 14px 0 0 14px;
    border: 1px solid var(--stroke-strong);
    border-radius: 14px;
    background: var(--accent);
    color: white;
    font-size: 20px;
    font-weight: 800;
}

.sidebar-toggle {
    display: grid;
    width: 52px;
    height: 52px;
    place-items: center;
    gap: 4px;
    margin: 18px 0 0 14px;
    border: 1px solid var(--stroke);
    border-radius: 14px;
    background: var(--panel);
}

.sidebar-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text);
}

.sidebar-title {
    position: absolute;
    top: 92px;
    left: 84px;
    font-size: 17px;
}

.rail-menu,
.language-menu {
    display: grid;
    align-content: start;
    gap: 10px;
    padding: 24px 10px;
}

.rail-item,
.language-menu button {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    align-items: center;
    height: 64px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: transparent;
    color: var(--text);
    text-decoration: none;
    font-size: 17px;
    font-weight: 700;
    text-align: left;
}

.rail-item.active,
.rail-item:hover,
.language-menu button:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.rail-icon {
    color: var(--accent);
    text-align: center;
    font-size: 22px;
}

.language-menu {
    padding-bottom: 12px;
}

.language-menu button {
    height: 56px;
}

.flag {
    display: block;
    width: 40px;
    height: 40px;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.flag.it {
    background: linear-gradient(90deg, #009246 0 33%, #fff 33% 66%, #ce2b37 66%);
}

.flag.ru {
    background: linear-gradient(#fff 0 33%, #0039a6 33% 66%, #d52b1e 66%);
}

.flag.en {
    background:
        linear-gradient(90deg, transparent 42%, #fff 42% 58%, transparent 58%),
        linear-gradient(transparent 36%, #fff 36% 64%, transparent 64%),
        linear-gradient(90deg, transparent 46%, #c8102e 46% 54%, transparent 54%),
        linear-gradient(transparent 42%, #c8102e 42% 58%, transparent 58%),
        #012169;
}

.wpf-main {
    display: grid;
    grid-template-rows: 92px minmax(0, 1fr);
    gap: 12px;
    min-width: 0;
    margin: 12px;
}

.wpf-header,
.wpf-panel {
    border: 1px solid var(--stroke);
    background: var(--panel-strong);
    box-shadow: var(--shadow-card);
}

.wpf-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    padding: 16px 22px;
    border-radius: 24px;
}

.wpf-header span {
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
}

.wpf-header h1 {
    margin: 2px 0 0;
    color: var(--text);
    font-size: 24px;
    line-height: 1;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-pill,
.theme-picker,
.icon-action,
.logs-pill {
    min-height: 46px;
    border: 1px solid var(--stroke);
    border-radius: 14px;
    background: var(--surface-alt);
    color: var(--text);
    font-weight: 700;
}

.header-pill,
.logs-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    color: var(--accent);
}

.theme-picker {
    min-width: 190px;
    padding: 4px 12px;
}

.icon-action {
    width: 46px;
    color: var(--accent);
}

.logs-pill {
    background: var(--success-soft);
    color: var(--success);
}

.wpf-panel {
    min-height: 0;
    padding: 12px;
    border-radius: 28px;
    background: var(--panel);
    box-shadow: var(--shadow-panel);
}

.machine-page {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    height: 100%;
    overflow: hidden;
    background: var(--shell);
}

.machine-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    transform-origin: left top;
}

.cpu-card,
.metric-card,
.metric-mini,
.event-feed,
.alarm-bell,
.status-pill {
    border: 1px solid var(--stroke);
    background: var(--panel-strong);
    box-shadow: 0 0 0 transparent;
}

.cpu-card {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 84px;
    padding: 14px;
    border-radius: 20px;
}

.cpu-card span,
.metric-card span,
.metric-mini span {
    display: block;
    color: var(--muted);
    font-size: 11px;
}

.cpu-card strong,
.metric-card strong,
.metric-mini strong {
    display: block;
    margin-top: 3px;
    font-weight: 800;
}

.chip-icon {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 14px;
    background: var(--accent-soft);
    color: var(--accent);
}

.alarm-bell {
    width: 54px;
    height: 54px;
    border-radius: 10px;
    background: var(--warning-soft);
    color: var(--warning);
    opacity: 0.8;
}

.metric-card {
    width: 158px;
    height: 64px;
    padding: 10px 16px;
    border-radius: 20px;
}

.metric-card.wide {
    width: 220px;
}

.metric-card.wide strong {
    font-family: Consolas, monospace;
    font-size: 26px;
}

.metric-mini {
    width: 92px;
    height: 64px;
    padding: 10px 12px;
    border-radius: 14px;
}

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

.warning strong {
    color: var(--warning);
}

.ok,
.success {
    color: var(--success);
}

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

.event-feed {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    width: 236px;
    height: 58px;
    padding: 10px 16px;
    border-radius: 12px;
    background: var(--accent-soft);
    text-align: left;
}

.event-feed span:first-child {
    color: var(--accent);
}

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

.toolbar-rule {
    height: 1px;
    margin: 12px 0;
    background: var(--accent);
    opacity: 0.8;
}

.machine-stage {
    min-height: 0;
    overflow: hidden;
    background: var(--shell);
}

.machine-viewport {
    width: 100%;
    height: 100%;
    overflow: auto;
    border-radius: 18px;
    background: #fbfbfb;
}

.machine-canvas {
    position: relative;
    width: 1920px;
    height: 760px;
    overflow: hidden;
    background: #fbfbfb;
    transform: none;
}

.machine-canvas > img {
    position: absolute;
    left: 0;
    top: 0;
    width: 1880px;
    height: 655px;
    object-fit: fill;
}

.canvas-alerts {
    position: absolute;
    left: 1340px;
    top: 14px;
    display: flex;
    gap: 8px;
    padding: 14px 10px;
    border: 1px solid var(--stroke);
    border-radius: 20px;
    background: var(--panel-strong);
    box-shadow: var(--shadow-card);
}

.status-pill {
    min-width: 112px;
    padding: 10px 12px;
    border-radius: 14px;
    font-weight: 800;
}

.status-pill strong {
    margin-left: 6px;
}

.status-pill.ok {
    background: var(--success-soft);
    color: var(--success);
}

.status-pill.warning {
    background: var(--warning-soft);
    color: var(--warning);
}

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

.station-box {
    position: absolute;
    z-index: 2;
    font-family: "Segoe UI", Arial, sans-serif;
}

.station-title {
    display: grid;
    width: 100%;
    height: 29px;
    place-items: center;
    background: #00aff0;
    color: white;
    font-size: 10px;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.station-body {
    position: relative;
    min-height: calc(100% - 29px);
    background: rgba(128, 128, 128, 0.7);
}

.station-box.compact .station-body {
    display: grid;
    place-items: center;
}

.station-box.compact button {
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 50%;
    background: #00aff0;
    color: white;
    font-size: 23px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.station-box.wide .station-title {
    width: 100px;
}

.station-box.wide .station-body {
    position: absolute;
    left: 100px;
    top: 0;
    width: 178px;
    height: 74px;
    background: rgba(245, 245, 220, 0.7);
    box-shadow: 2px 2px 50px lightsteelblue;
}

.station-box.wide::after {
    content: "";
    position: absolute;
    left: 0;
    top: 29px;
    width: 100px;
    height: 48px;
    background: rgba(128, 128, 128, 0.7);
}

.station-box.wide dl {
    display: grid;
    grid-template-columns: 105px 70px;
    row-gap: 0;
    margin: 0;
    padding: 2px 0 0 5px;
    font-size: 14px;
}

.station-box.wide dt {
    text-align: right;
    font-weight: 500;
}

.station-box.wide dd {
    margin: 0 0 0 2px;
}

.bottom-menu {
    position: absolute;
    left: -58px;
    top: 608px;
    width: 300px;
    display: flex;
    justify-content: center;
    gap: 8px;
}

.bottom-menu button {
    height: 36px;
    border: 1px solid var(--stroke);
    border-radius: 10px;
    background: var(--panel-strong);
    color: var(--text);
    font-weight: 800;
}

.log-panel {
    position: absolute;
    left: 146px;
    top: 408px;
    width: 1120px;
    height: 314px;
    padding: 14px;
    border: 1px solid var(--stroke-strong);
    border-radius: 28px;
    background: var(--panel-strong);
    box-shadow: var(--shadow-card);
}

.log-panel header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 44px;
}

.log-title {
    display: grid;
    width: 132px;
    height: 44px;
    place-items: center;
    border: 1px solid var(--stroke);
    border-radius: 10px;
    background: var(--surface-alt);
    color: var(--text);
    font-size: 20px;
    font-weight: 800;
}

.log-buttons {
    display: flex;
    gap: 10px;
}

.log-buttons button {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    border: 1px solid var(--stroke);
    color: var(--text);
    font-weight: 900;
}

.log-buttons .fault {
    background: var(--danger-soft);
    border-color: rgba(255, 107, 107, 0.27);
}

.log-buttons .alarm {
    background: rgba(255, 159, 67, 0.08);
    border-color: rgba(255, 159, 67, 0.27);
}

.log-buttons .warn {
    background: var(--warning-soft);
    border-color: rgba(255, 200, 87, 0.27);
}

.reset-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}

.reset-row button {
    height: 40px;
    border: 0;
    color: white;
    font-size: 14px;
    font-weight: 800;
}

.reset-fault {
    background: var(--danger);
}

.reset-alarm {
    background: var(--warning);
}

.reset-warning {
    background: #f3d36b;
    color: var(--text) !important;
}

.log-table {
    width: 100%;
    margin-top: 8px;
    border-collapse: collapse;
    overflow: hidden;
    border: 1px solid var(--stroke);
    background: var(--panel);
    font-size: 12px;
}

.log-table th {
    height: 36px;
    border-right: 1px solid var(--stroke);
    border-bottom: 1px solid var(--stroke);
    background: var(--surface-alt);
    font-weight: 800;
    text-align: center;
}

.log-table td {
    height: 36px;
    border-bottom: 1px solid var(--stroke);
    padding: 0 8px;
    text-align: center;
}

.log-table td:last-child {
    text-align: left;
}

.log-type {
    display: inline-flex;
    min-width: 76px;
    justify-content: center;
    border-radius: 6px;
    padding: 3px 10px;
    font-weight: 800;
}

.log-type.fault {
    background: var(--danger);
    color: white;
}

.log-type.alarm {
    background: #fbc02d;
    color: white;
}

.log-type.warning {
    background: #f3d36b;
    color: var(--text);
}

.read-button {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: white;
}

#blazor-error-ui {
    position: fixed;
    right: 16px;
    bottom: 16px;
    display: none;
    z-index: 1000;
    border-radius: 10px;
    padding: 12px 16px;
    background: #b42318;
    color: white;
}

#blazor-error-ui a {
    color: white;
    font-weight: 800;
}

#blazor-error-ui .dismiss {
    margin-left: 12px;
    cursor: pointer;
}

.loading-progress,
.loading-progress-text {
    display: none;
}

@media (max-width: 1100px) {
    .wpf-sidebar {
        width: 84px;
    }

    .sidebar-title,
    .rail-item span:last-child,
    .language-menu button span:last-child,
    .theme-picker,
    .header-pill {
        display: none;
    }

    .wpf-main {
        margin-left: 10px;
    }

    .machine-canvas {
        transform: none;
    }
}
