:root {
    --bg: #eef2f6;
    --surface: #ffffff;
    --surface-soft: #f7f9fb;
    --line: #d7dee8;
    --text: #1d2430;
    --muted: #637083;
    --accent: #1f7a68;
    --accent-strong: #155f52;
    --warning: #b87900;
    --danger: #a83b3b;
    --shadow: 0 18px 44px rgba(28, 42, 59, 0.16);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background: var(--bg);
    font-family: Arial, Helvetica, sans-serif;
    letter-spacing: 0;
}

button {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font: inherit;
    min-height: 34px;
    padding: 0 12px;
}

button:hover {
    border-color: #9eb3c9;
}

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

.workbench-shell {
    display: grid;
    grid-template-columns: 220px 1fr;
    grid-template-rows: 58px 1fr 30px;
    min-height: 100vh;
}

.topbar {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    border-bottom: 1px solid #c8d3df;
    background: #f9fbfd;
}

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

.brand-mark {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border-radius: 8px;
    background: #20313f;
    color: #fff;
    font-weight: 700;
}

.brand span:last-child {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.topbar-actions,
.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-button,
.window-tool {
    width: 34px;
    padding: 0;
}

.modulebar {
    padding: 14px 10px;
    border-right: 1px solid #c8d3df;
    background: #243241;
}

.module-button {
    width: 100%;
    justify-content: flex-start;
    margin-bottom: 8px;
    border-color: transparent;
    background: transparent;
    color: #dce5ef;
    text-align: left;
}

.module-button:hover,
.module-button.active {
    background: #32485b;
    color: #fff;
}

.desktop {
    position: relative;
    overflow: auto;
    padding: 18px;
    background:
        linear-gradient(rgba(255, 255, 255, 0.34) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.34) 1px, transparent 1px),
        var(--bg);
    background-size: 24px 24px;
}

.window {
    display: none;
    max-width: 1180px;
    min-height: 460px;
    border: 1px solid #b9c7d6;
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.window.active {
    display: block;
}

.window-large {
    max-width: 1280px;
}

.window-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 44px;
    padding: 0 10px 0 14px;
    border-bottom: 1px solid var(--line);
    border-radius: 8px 8px 0 0;
    background: #edf3f8;
}

.window-titlebar h1 {
    margin: 0;
    font-size: 15px;
}

.window-body {
    padding: 16px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(140px, 1fr));
    gap: 14px;
}

.metric,
.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    padding: 14px;
}

.metric span,
.metric small {
    color: var(--muted);
    display: block;
    font-size: 12px;
}

.metric strong {
    display: block;
    font-size: 30px;
    margin: 8px 0 2px;
}

.span-2 {
    grid-column: span 2;
}

.panel h2 {
    margin: 0 0 10px;
    font-size: 15px;
}

.panel p {
    color: var(--muted);
    line-height: 1.5;
    margin: 0;
}

.event-list {
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
    line-height: 1.7;
}

.toolbar {
    margin-bottom: 12px;
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
    text-align: left;
    white-space: nowrap;
}

th {
    background: #f2f5f8;
    color: #3c4858;
    font-size: 12px;
    text-transform: uppercase;
}

td {
    color: #2b3440;
    font-size: 14px;
}

.product-thumb {
    display: block;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    object-fit: contain;
    background: #fff;
}

tr:last-child td {
    border-bottom: 0;
}

.split-view {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.status-list {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 8px 16px;
    margin: 0;
}

.status-list dt {
    color: var(--muted);
}

.status-list dd {
    margin: 0;
    font-weight: 700;
}

.action-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 18px;
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
}

.switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.switch span {
    position: relative;
    width: 42px;
    height: 24px;
    border: 1px solid #aebccd;
    border-radius: 999px;
    background: #dce4ed;
}

.switch span::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(20, 30, 40, 0.28);
    transition: transform 0.16s ease;
}

.switch input:checked + span {
    border-color: var(--accent);
    background: var(--accent);
}

.switch input:checked + span::after {
    transform: translateX(18px);
}

.connection-result {
    min-height: 22px;
    margin-top: 14px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.connection-result.success {
    color: var(--accent-strong);
}

.connection-result.error {
    color: var(--danger);
}

.statusbar {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    border-top: 1px solid #c8d3df;
    background: #f8fafc;
    color: var(--muted);
    font-size: 12px;
}

@media (max-width: 860px) {
    .workbench-shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr 30px;
    }

    .topbar {
        gap: 12px;
        min-height: 58px;
        flex-wrap: wrap;
        padding: 10px 12px;
    }

    .modulebar {
        display: flex;
        overflow-x: auto;
        gap: 8px;
        padding: 10px;
        border-right: 0;
    }

    .module-button {
        width: auto;
        min-width: max-content;
        margin-bottom: 0;
    }

    .desktop {
        padding: 10px;
    }

    .dashboard-grid,
    .split-view {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: auto;
    }

    .window {
        min-height: 0;
    }

    .statusbar {
        gap: 8px;
        overflow: hidden;
    }
}
