:root {
    color-scheme: dark;
    --bg: #10161e;
    --surface: #18212c;
    --ink: #e3eaf2;
    --muted: #a0afc0;
    --line: #303e4e;
    --accent: #8bbde5;
    --soft: #223142;
    --success: #85cbaa;
    --danger: #eea3a3;
    --warn: #dfb777;
    font-family: Inter,Segoe UI,system-ui,sans-serif;
    font-size: 14px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button,input,select {
    font: inherit;
}

button {
    cursor: pointer;
}

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

:focus-visible {
    outline: 3px solid #8bb6d2;
    outline-offset: 3px;
}

h1,h2,h3,p {
    margin: 0;
}

h1 {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -.8px;
}

h2 {
    font-size: 16px;
    font-weight: 600;
}

h3 {
    font-size: 14px;
    font-weight: 600;
}

small,.muted {
    color: var(--muted);
}

small {
    font-size: 12px;
}

.app-header {
    background: #182b3b;
    color: #fff;
}

.header-inner {
    max-width: 1440px;
    margin: auto;
    min-height: 70px;
    padding: 0 36px;
    display: flex;
    align-items: center;
    gap: 48px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
}

.brand-mark {
    display: grid;
    place-items: center;
    border: 1px solid #6a8498;
    width: 34px;
    height: 34px;
    font-size: 12px;
    letter-spacing: 1px;
}

.header-note {
    margin-left: auto;
    color: #9aafbf;
    font-size: 12px;
}

.page {
    max-width: 1440px;
    margin: auto;
    padding: 32px 36px;
}

.page.narrow {
    max-width: 1080px;
}

.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.eyebrow {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--muted);
    margin-bottom: 6px;
}

.subtitle {
    color: var(--muted);
    margin-top: 6px;
    font-size: 13px;
}

.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 8px 15px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--surface);
    color: var(--ink);
    font-weight: 500;
    font-size: 13px;
    white-space: nowrap;
}

.button:hover {
    background: var(--soft);
    text-decoration: none;
}

.button.primary {
    background: #2d638d;
    color: #fff;
    border-color: var(--accent);
}

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

.asset-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.asset-field {
    display: flex;
    align-items: center;
    gap: 16px;
}

.asset-field select {
    min-width: 240px;
}

.connection {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
}

.dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.connection[data-state=ok] {
    color: var(--success);
}

.connection[data-state=error] {
    color: var(--danger);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit,minmax(230px,1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    min-width: 0;
}

.metric-card {
    padding: 20px;
}

.metric-card h2 {
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
}

.metric-value {
    font-size: 34px;
    line-height: 1.3;
    letter-spacing: -1px;
    font-variant-numeric: tabular-nums;
    margin: 18px 0 8px;
}

.metric-unit {
    font-size: 15px;
    letter-spacing: 0;
    color: var(--muted);
    margin-left: 6px;
}

.metric-meta {
    font-size: 11px;
    color: var(--muted);
    margin-top: 8px;
}

.meter {
    height: 4px;
    background: var(--soft);
    margin-top: 16px;
    border-radius: 2px;
    overflow: hidden;
}

.meter span {
    display: block;
    height: 100%;
    background: var(--accent);
}

.status-value {
    font-size: 23px;
    letter-spacing: -.4px;
    margin: 24px 0 14px;
}

.status-value[data-state=on] {
    color: var(--success);
}

.status-value[data-state=off] {
    color: var(--warn);
}

.widget-body {
    min-height: 95px;
}

.dashboard-layout {
    display: grid;
    grid-template-columns: minmax(0,1fr) 310px;
    gap: 24px;
    align-items: start;
}

.panel-heading {
    padding: 20px 22px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.range-selector {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
}

.range-btn {
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--muted);
    padding: 7px 10px;
    font-size: 12px;
}

.range-btn:hover {
    background: var(--soft);
}

.range-btn[aria-pressed=true] {
    background: #2d638d;
    color: #fff;
}

.chart-info {
    padding: 12px 22px;
    font-size: 11px;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
}

.chart-row {
    padding: 18px 14px 4px;
    min-width: 0;
    border-bottom: 1px solid var(--line);
}

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

.chart-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 0 8px;
}

.chart-label small {
    font-variant-numeric: tabular-nums;
}

.chart-canvas {
    height: 220px;
}

.empty-state {
    padding: 44px 24px;
    text-align: center;
    color: var(--muted);
}

.empty-state h2 {
    color: var(--ink);
    margin-bottom: 8px;
}

.empty-state .button {
    margin-top: 18px;
}

.notice {
    padding: 12px 16px;
    background: var(--soft);
    color: var(--accent);
    border-radius: 4px;
    font-size: 13px;
}

.notice.error {
    color: var(--danger);
    background: #35252c;
}

.notice.success {
    color: var(--success);
    background: #20372f;
}

.hidden,[hidden] {
    display: none!important;
}

.events-list {
    max-height: 630px;
    overflow: auto;
}

.event {
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}

.event:last-child {
    border: 0;
}

.event-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 10px;
    color: var(--muted);
    margin-bottom: 6px;
}

.event-level {
    font-weight: 600;
}

.event-level.warn {
    color: var(--warn);
}

.event-level.error {
    color: var(--danger);
}

.event p {
    font-size: 12px;
    overflow-wrap: anywhere;
}

.page-footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 28px;
    font-size: 11px;
    color: var(--muted);
}

.form-section {
    padding: 26px;
    border-bottom: 1px solid var(--line);
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 22px;
}

.section-heading p {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
}

label {
    font-size: 12px;
    font-weight: 500;
}

input,select {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface);
    padding: 8px 10px;
    color: var(--ink);
}

input::placeholder {
    color: #8b97a4;
}

.field small {
    font-size: 11px;
}

.widget-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.widget-item {
    display: grid;
    grid-template-columns: 1.1fr 1fr 1fr auto;
    align-items: end;
    gap: 12px;
    padding: 16px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 4px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px 26px;
}

.form-feedback {
    margin-bottom: 18px;
}

.full-width {
    grid-column: 1/-1;
}

.sim-layout {
    display: grid;
    gap: 20px;
}

.var-item {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--bg);
}

.var-fields {
    display: grid;
    grid-template-columns: 1fr 1fr .65fr 1.2fr auto;
    gap: 12px;
    align-items: end;
}

.param-inputs {
    display: flex;
    gap: 6px;
}

.param-inputs input {
    min-width: 0;
}

.sim-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.log-output {
    background: #182b3b;
    color: #cfdae3;
    font-family: Consolas,monospace;
    font-size: 12px;
    height: 240px;
    overflow: auto;
    padding: 18px;
    border-radius: 0 0 5px 5px;
    overflow-wrap: anywhere;
}

.log-output>div {
    padding: 3px 0;
}

.text-red-400 {
    color: #f1a9a0;
}

.text-emerald-400 {
    color: #a3d4bc;
}

.text-yellow-400 {
    color: #e7c78d;
}

.text-indigo-400 {
    color: #a9c6e1;
}

.badge {
    font-size: 11px;
    padding: 4px 9px;
    background: var(--soft);
    color: var(--muted);
    border-radius: 4px;
}

.badge.running {
    color: var(--success);
    background: #20372f;
}

@media(max-width:1100px) {
    .dashboard-layout {
        grid-template-columns: minmax(0,1fr);
    }
    .events-list {
        max-height: 300px;
    }
    .var-fields {
        grid-template-columns: 1fr 1fr;
    }
    .header-note {
        display: none;
    }
}

@media(max-width:700px) {
    .header-inner {
        padding: 16px 20px;
        gap: 12px;
        flex-wrap: wrap;
    }
    .page {
        padding: 24px 16px;
    }
    .page-heading {
        align-items: flex-start;
        gap: 14px;
    }
    h1 {
        font-size: 23px;
    }
    .asset-bar,.asset-field {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }
    .asset-field select {
        min-width: 0;
    }
    .metrics-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    .metric-card {
        padding: 15px;
    }
    .metric-value {
        font-size: 27px;
    }
    .panel-heading {
        align-items: flex-start;
        flex-direction: column;
        padding: 18px;
    }
    .form-section {
        padding: 20px;
    }
    .fields,.widget-item,.var-fields {
        grid-template-columns: 1fr;
    }
    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }
    .widget-item>.button {
        justify-self: end;
    }
    .page-footer {
        flex-direction: column;
        gap: 5px;
    }
    .status-value {
        font-size: 18px;
    }
    .chart-label {
        align-items: flex-start;
        flex-direction: column;
        gap: 3px;
    }
}

@media(max-width:380px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    .page-heading {
        flex-direction: column;
    }
}

@media(prefers-reduced-motion:reduce) {
    * {
        scroll-behavior: auto!important;
        animation: none!important;
        transition: none!important;
    }
}
