:root {
    --bg: #111214;
    --panel: #181a1f;
    --panel-2: #1f2229;
    --line: #2d313a;
    --line-soft: #242832;
    --text: #f3f4f6;
    --muted: #a3a7b0;
    --green: #21c063;
    --red: #ef4444;
    --amber: #f59e0b;
    --cyan: #38bdf8;
    --white: #ffffff;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

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

button,
input {
    font: inherit;
}

button {
    border: 0;
}

.app-shell {
    width: min(1500px, calc(100% - 32px));
    margin: 0 auto;
    padding: 20px 0 28px;
}

.topbar {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.brand-block,
.top-actions,
.panel-toolbar,
.global-chat,
.filter-tabs,
.row-chat {
    display: flex;
    align-items: center;
}

.brand-block {
    gap: 12px;
    min-width: 260px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #23272f;
    border: 1px solid var(--line);
    color: var(--cyan);
    font-weight: 900;
    font-size: 1.15rem;
}

h1 {
    margin: 0;
    font-size: clamp(1.18rem, 1.5vw, 1.55rem);
    line-height: 1.1;
    font-weight: 850;
}

.connection-state {
    margin-top: 5px;
    font-size: 0.78rem;
    color: var(--amber);
}

.connection-state.connected {
    color: var(--green);
}

.connection-state.disconnected {
    color: var(--red);
}

.top-actions {
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.global-state {
    min-width: 148px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-2);
    text-align: center;
    font-weight: 800;
    font-size: 0.88rem;
}

.state-off {
    color: var(--red);
}

.state-live {
    color: var(--green);
}

.state-warn {
    color: var(--amber);
}

.btn {
    min-height: 40px;
    padding: 0 14px;
    border-radius: 8px;
    color: var(--white);
    font-weight: 800;
    cursor: pointer;
    transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.btn:hover,
.row-action:hover,
.mini-btn:hover,
.tab:hover {
    transform: translateY(-1px);
}
button:disabled,
button:disabled:hover {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.btn-start {
    background: #168947;
}

.btn-stop {
    background: #b42332;
}

.btn-neutral {
    background: #334155;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin: 12px 0;
}

.metric {
    min-height: 78px;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.metric strong {
    display: block;
    margin-top: 8px;
    font-size: 1.65rem;
    line-height: 1;
}

.metric-online strong {
    color: var(--green);
}

.metric-queue strong {
    color: var(--amber);
}

.metric-offline strong {
    color: var(--red);
}

.metric-keys strong {
    color: var(--cyan);
}

.manager-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    overflow: hidden;
}

.panel-toolbar {
    gap: 10px;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 12px;
    border-bottom: 1px solid var(--line);
    background: #15171b;
}

.search-wrap {
    flex: 1 1 230px;
}

input {
    width: 100%;
    min-height: 38px;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    outline: none;
    background: #101114;
    color: var(--text);
}

input:focus {
    border-color: var(--cyan);
}

.filter-tabs {
    gap: 6px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #101114;
}

.tab {
    min-height: 30px;
    padding: 0 10px;
    border-radius: 6px;
    color: var(--muted);
    background: transparent;
    font-weight: 800;
    cursor: pointer;
}

.tab.active {
    color: var(--white);
    background: #30343d;
}

.global-chat {
    gap: 8px;
    flex: 1 1 300px;
    justify-content: flex-end;
}

.global-chat input {
    max-width: 280px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.bot-table {
    width: 100%;
    min-width: 1080px;
    border-collapse: collapse;
}

.bot-table th,
.bot-table td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line-soft);
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

.bot-table th {
    color: var(--muted);
    background: #17191e;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0;
}

.bot-table tr:hover td {
    background: #1b1e25;
}
.empty-row td {
    padding: 28px 12px;
    color: var(--muted);
    text-align: center;
}

.account-name {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 850;
}

.account-sub {
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.76rem;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 88px;
    padding: 6px 9px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #111318;
    font-size: 0.78rem;
    font-weight: 850;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

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

.status-offline {
    color: var(--red);
}

.status-queue {
    color: var(--amber);
}

.cell-activity {
    max-width: 230px;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #d5d8df;
}

.cell-coords,
.cell-log,
.cell-keys {
    font-variant-numeric: tabular-nums;
}

.cell-coords {
    color: #d7b56d;
}

.cell-keys {
    color: var(--cyan);
    font-weight: 850;
}

.cell-log {
    color: var(--muted);
}

.row-chat {
    gap: 6px;
}

.row-chat input {
    width: 132px;
    min-height: 32px;
}

.mini-btn,
.row-action {
    min-height: 32px;
    padding: 0 10px;
    border-radius: 8px;
    color: var(--white);
    font-weight: 850;
    cursor: pointer;
}

.mini-btn {
    background: #334155;
}

.row-action {
    min-width: 70px;
}

.row-start {
    background: #168947;
}

.row-stop {
    background: #b42332;
}

@media (max-width: 900px) {
    .app-shell {
        width: min(100% - 20px, 1500px);
        padding-top: 10px;
    }

    .topbar,
    .panel-toolbar {
        align-items: stretch;
    }

    .topbar,
    .top-actions,
    .global-chat {
        flex-direction: column;
    }

    .top-actions,
    .global-chat,
    .global-chat input {
        width: 100%;
        max-width: none;
    }

    .metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metric-total {
        grid-column: span 1;
    }
}

@media (max-width: 560px) {
    .metrics {
        grid-template-columns: 1fr;
    }

    .filter-tabs {
        width: 100%;
        overflow-x: auto;
    }
}