:root {
    --bg-main: #060911;
    --bg-surface: #0c1220;
    --bg-card: #101829;
    --bg-inset: #080d18;
    --line: #1b263b;
    --line-soft: #141d2e;
    --txt: #e6edf7;
    --txt-dim: #8b9bb4;
    --txt-mute: #5a6a82;
    --amber: #f59e0b;
    --emerald: #10b981;
    --cyan: #22d3ee;
    --rose: #ef4444;
    --slate: #64748b;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg-main);
    color: var(--txt);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 12px;
    -webkit-font-smoothing: antialiased;
}

code {
    font-family: 'JetBrains Mono', monospace;
    color: var(--cyan);
    font-size: 11px;
}

/* Topbar */
.mc-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 9px 18px;
    background: #090e1a;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 40;
}

.mc-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mc-logo {
    width: 32px;
    height: 32px;
    border-radius: 7px;
    background: linear-gradient(145deg, #fde047, #facc15);
    border: 1px solid rgba(254, 240, 138, 0.5);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    box-shadow: 0 0 12px rgba(250, 204, 21, 0.22);
}

.mc-brand-text {
    display: flex;
    flex-direction: column;
}

.mc-brand-name {
    font-weight: 700;
    font-size: 13.5px;
    letter-spacing: 0.08em;
    line-height: 1.15;
}

.mc-brand-sub {
    font-size: 10px;
    color: var(--txt-mute);
}

.mc-top-stats {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
}

.mc-stat-box {
    background: var(--bg-surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 5px 10px;
    display: flex;
    align-items: baseline;
    gap: 7px;
}

.mc-stat-label {
    font-size: 9px;
    font-weight: 600;
    color: var(--txt-mute);
    letter-spacing: 0.05em;
}

.mc-stat-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12.5px;
    font-weight: 700;
}

.c-cyan { color: var(--cyan); }
.c-amber { color: var(--amber); }
.c-emerald { color: var(--emerald); }
.c-slate { color: var(--txt); }

.mc-alarm-pill {
    background: rgba(239, 68, 68, 0.14);
    border: 1px solid rgba(239, 68, 68, 0.42);
    color: #fca5a5;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 6px;
}

.mc-clock-box {
    background: var(--bg-inset);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 5px 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--txt-dim);
}

/* Main Grid */
.mc-container {
    padding: 14px 18px 24px;
}

.mc-grid {
    display: grid;
    grid-template-columns: 285px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

@media (max-width: 980px) {
    .mc-grid {
        grid-template-columns: 1fr;
    }
}

.mc-left {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.mc-right {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mc-panel {
    background: var(--bg-surface);
    border: 1px solid var(--line);
    border-radius: 9px;
    overflow: hidden;
}

.mc-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 13px;
    border-bottom: 1px solid var(--line-soft);
    font-size: 12px;
    font-weight: 600;
}

.mc-count-tag {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--txt-dim);
    background: var(--bg-inset);
    padding: 2px 7px;
    border-radius: 5px;
    border: 1px solid var(--line);
}

/* Map */
.mc-map-wrap {
    padding: 10px;
}

.mc-map-svg {
    width: 100%;
    max-height: 245px;
    height: auto;
    display: block;
    border-radius: 7px;
    border: 1px solid var(--line-soft);
}

.mc-map-legend {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 9px;
    padding-top: 8px;
    border-top: 1px solid var(--line-soft);
    font-size: 10px;
    color: var(--txt-dim);
}

.lg-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-right: 4px;
}

.lg-red { background: var(--rose); }
.lg-amber { background: var(--amber); }
.lg-green { background: var(--emerald); }
.lg-gray { background: var(--slate); }

/* Alarm Feed */
.mc-alarm-list {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    max-height: 460px;
    overflow-y: auto;
}

.mc-ev-card {
    border-radius: 6px;
    padding: 8px 10px;
    background: var(--bg-inset);
    border: 1px solid var(--line-soft);
    border-left: 3px solid var(--amber);
}

.mc-ev-card.ev-crit {
    border-left-color: var(--rose);
    background: rgba(239, 68, 68, 0.09);
    border-color: rgba(239, 68, 68, 0.28);
}

.mc-ev-card.ev-ok {
    border-left-color: var(--emerald);
}

.mc-ev-head {
    display: flex;
    justify-content: space-between;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 700;
}

.mc-ev-title {
    font-size: 11px;
    color: var(--txt);
    margin-top: 3px;
    font-weight: 500;
}

.mc-ev-sub {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9.5px;
    color: var(--txt-mute);
    margin-top: 3px;
}

/* Tabs */
.mc-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.mc-tab {
    background: var(--bg-surface);
    color: var(--txt-dim);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 6px 13px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.mc-tab:hover {
    color: var(--txt);
    border-color: #2b3b58;
}

.mc-tab.is-active {
    background: rgba(245, 158, 11, 0.15);
    color: var(--amber);
    border-color: rgba(245, 158, 11, 0.45);
}

/* Site Block */
.mc-sites-wrap {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.mc-site-card {
    background: var(--bg-surface);
    border: 1px solid #2b3548;
    border-radius: 10px;
    padding: 15px 16px;
}

.mc-site-top {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}

.mc-site-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mc-site-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--emerald);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.55);
}

.mc-site-dot.is-alarm {
    background: var(--rose);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.55);
}

.mc-site-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--txt);
}

.mc-spec-pill {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--txt-dim);
    background: #141d30;
    border: 1px solid #24314a;
    padding: 2px 7px;
    border-radius: 4px;
}

.mc-site-meta {
    font-size: 11px;
    color: var(--txt-dim);
    margin-top: 3px;
    padding-left: 17px;
}

.mc-site-metrics {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 18px;
}

.mc-smetric {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mc-smetric-lbl {
    font-size: 10px;
    color: var(--txt-mute);
}

.mc-smetric-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 15px;
    font-weight: 700;
    color: var(--txt);
}

.mc-smetric-val small {
    font-size: 11px;
    color: var(--txt-dim);
    font-weight: 500;
}

.mc-site-status-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 11px;
    color: var(--txt-dim);
}

.mc-site-progress {
    height: 4px;
    background: #172136;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 14px;
}

.mc-site-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #34d399);
    border-radius: 999px;
    transition: width 0.3s ease;
}

/* 24h Bar Chart */
.mc-chart-box {
    background: var(--bg-inset);
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    padding: 11px 13px;
    margin-bottom: 14px;
}

.mc-chart-label {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--txt);
    margin-bottom: 8px;
}

.mc-chart-extrema {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    font-weight: 500;
    color: var(--txt-dim);
}

.mc-chart-cap-line {
    display: flex;
    justify-content: flex-end;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9.5px;
    color: var(--cyan);
    border-bottom: 1px dashed rgba(34, 211, 238, 0.35);
    padding-bottom: 2px;
    margin-bottom: 6px;
}

.mc-bars {
    display: grid;
    grid-template-columns: repeat(24, minmax(0, 1fr));
    gap: 4px;
    align-items: end;
    height: 62px;
}

.mc-bar {
    border-radius: 2px 2px 0 0;
    min-height: 4px;
    background: #1b2538;
    transition: height 0.25s ease, opacity 0.15s ease;
}

.mc-bar:hover {
    opacity: 0.85;
}

.mc-bar.b-run { background: #10b981; }
.mc-bar.b-cyan { background: #38bdf8; }
.mc-bar.b-peak { background: #f59e0b; }

.mc-bar-axis {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    margin-top: 5px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9.5px;
    color: var(--txt-mute);
}

.mc-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 8px;
    padding-top: 7px;
    border-top: 1px solid var(--line-soft);
    font-size: 10px;
    color: var(--txt-dim);
}

.mc-lg-sq {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    margin-right: 4px;
    vertical-align: middle;
}

/* Unit Cards Grid */
.mc-units {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px;
}

.mc-unit {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.mc-unit.is-alarm {
    border-color: rgba(239, 68, 68, 0.6);
    box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.14);
}

.mc-unit-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.mc-unit-title {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.mc-unit-gcode {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 700;
    color: var(--txt);
}

.mc-unit-sn {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    color: var(--txt-mute);
}

.mc-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    flex-shrink: 0;
}

.bg-run { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.bg-max { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.bg-std { background: rgba(100, 116, 139, 0.18); color: #94a3b8; border: 1px solid rgba(100, 116, 139, 0.3); }
.bg-alm { background: rgba(239, 68, 68, 0.16); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.35); }

.mc-unit-power-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.mc-unit-power {
    font-family: 'JetBrains Mono', monospace;
    font-size: 25px;
    font-weight: 700;
    line-height: 1;
    color: var(--txt);
}

.mc-unit-power small {
    font-size: 11px;
    color: var(--txt-dim);
    font-weight: 500;
}

.mc-unit-pct {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 700;
}

.mc-unit-bar {
    height: 4px;
    background: #172136;
    border-radius: 999px;
    overflow: hidden;
}

.mc-unit-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.3s ease;
}

.mc-mini-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px 6px;
    padding-top: 8px;
    border-top: 1px solid var(--line-soft);
}

.mc-mini span {
    display: block;
    font-size: 9.5px;
    color: var(--txt-mute);
}

.mc-mini strong {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--txt);
}

.mc-mini strong small {
    font-size: 9.5px;
    color: var(--txt-dim);
    font-weight: 400;
}

.mc-unit-subchart {
    border-top: 1px solid var(--line-soft);
    padding-top: 7px;
}

.mc-subchart-head {
    display: flex;
    justify-content: space-between;
    font-size: 9.5px;
    color: var(--txt-dim);
    margin-bottom: 5px;
}

.mc-subchart-head span:last-child {
    font-family: 'JetBrains Mono', monospace;
    color: var(--txt-mute);
}

.mc-unit-bars {
    display: grid;
    grid-template-columns: repeat(24, minmax(0, 1fr));
    gap: 2px;
    align-items: end;
    height: 28px;
}

.mc-ubar {
    min-height: 2px;
    border-radius: 1px 1px 0 0;
    background: #1b2538;
}

.mc-ubar.u-run { background: #10b981; }
.mc-ubar.u-peak { background: #f59e0b; }

.mc-unit-axis {
    display: flex;
    justify-content: space-between;
    font-family: 'JetBrains Mono', monospace;
    font-size: 8.5px;
    color: var(--txt-mute);
    margin-top: 3px;
}

.mc-unit-extrema {
    display: flex;
    justify-content: space-between;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    margin-top: 3px;
}

.mc-unit-alarm-bar {
    background: rgba(239, 68, 68, 0.14);
    border: 1px solid rgba(239, 68, 68, 0.38);
    color: #fca5a5;
    font-size: 10.5px;
    font-weight: 600;
    padding: 6px 8px;
    border-radius: 6px;
}

/* 24h Bar Chart */
.mc-chart-box {
    background: var(--bg-inset);
    border: 1px solid var(--line-soft);
    border-radius: 7px;
    padding: 10px 12px;
    margin-bottom: 14px;
}

.mc-chart-label {
    display: flex;
    justify-content: space-between;
    font-size: 10.5px;
    color: var(--txt-dim);
    margin-bottom: 8px;
}

.mc-bars {
    display: grid;
    grid-template-columns: repeat(24, minmax(0, 1fr));
    gap: 4px;
    align-items: end;
    height: 54px;
}

.mc-bar {
    border-radius: 2px 2px 0 0;
    min-height: 4px;
    background: #152035;
    transition: opacity 0.15s ease;
}

.mc-bar:hover {
    opacity: 0.85;
}

.mc-bar.b-run { background: #10b981; }
.mc-bar.b-cyan { background: #22d3ee; }
.mc-bar.b-peak { background: #f59e0b; }

/* Unit Cards Grid */
.mc-units {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.mc-unit {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.mc-unit.is-alarm {
    border-color: rgba(239, 68, 68, 0.55);
}

.mc-unit-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.mc-unit-id {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.3;
    word-break: break-word;
}

.mc-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    flex-shrink: 0;
}

.bg-run { background: rgba(16, 185, 129, 0.16); color: #34d399; }
.bg-std { background: rgba(245, 158, 11, 0.16); color: #fbbf24; }
.bg-alm { background: rgba(239, 68, 68, 0.18); color: #f87171; }

.mc-unit-power {
    font-family: 'JetBrains Mono', monospace;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
}

.mc-unit-power small {
    font-size: 11px;
    color: var(--txt-dim);
    font-weight: 500;
}

.mc-mini-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px 6px;
    padding-top: 8px;
    border-top: 1px solid var(--line-soft);
}

.mc-mini span {
    display: block;
    font-size: 8.5px;
    color: var(--txt-mute);
    letter-spacing: 0.03em;
}

.mc-mini strong {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    color: var(--txt);
}

.mc-spark-wrap {
    height: 26px;
    background: var(--bg-inset);
    border-radius: 5px;
    padding: 3px 5px;
    border: 1px solid var(--line-soft);
}

.mc-spark {
    width: 100%;
    height: 100%;
    display: block;
}

.mc-unit-alarm-bar {
    background: rgba(239, 68, 68, 0.14);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    padding: 4px 7px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mc-empty {
    padding: 18px;
    text-align: center;
    color: var(--txt-dim);
    font-size: 11.5px;
}

.mc-footer {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 9px 18px;
    border-top: 1px solid var(--line);
    background: #090e1a;
    color: var(--txt-mute);
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
}

/* Alarm Feed */
.mc-alarm-list,
#mc-alarm-list {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}

#mc-alarm-list::-webkit-scrollbar {
    width: 6px;
}

#mc-alarm-list::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 999px;
}

.mc-ev-card {
    border-radius: 6px;
    padding: 7px 9px;
    background: var(--bg-inset);
    border: 1px solid var(--line-soft);
    border-left: 3px solid var(--amber);
}

.mc-ev-title {
    font-size: 11px;
    color: var(--txt);
    margin-top: 2px;
    font-weight: 500;
    line-height: 1.35;
    overflow-wrap: anywhere;
    word-break: break-word;
}