:root {
    color-scheme: light;
    --bg: #f6f8fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #637083;
    --line: #d8e0eb;
    --accent: #1f65d6;
    --accent-strong: #1555bd;
    --danger: #b42318;
    --success: #147a43;
}

* {
    box-sizing: border-box;
}

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

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

.app-header {
    margin-bottom: 20px;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 10px;
    font-size: 28px;
    line-height: 1.2;
}

.app-description {
    max-width: 760px;
    margin-bottom: 0;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.5;
}

.app-description span {
    display: block;
}

h2 {
    margin-bottom: 16px;
    font-size: 20px;
    line-height: 1.25;
}

.panel {
    margin-bottom: 16px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.tab-button {
    min-height: 40px;
    padding: 9px 14px;
    border-radius: 6px 6px 0 0;
    background: transparent;
    color: var(--muted);
}

.tab-button:hover,
.tab-button.is-active {
    background: var(--panel);
    color: var(--accent);
}

.tab-panel {
    display: none;
}

.tab-panel.is-active {
    display: block;
}

.panel-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.panel-title-row h2 {
    margin-bottom: 0;
}

.main-dashboard {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 16px;
    align-items: start;
}

.status-panel {
    position: sticky;
    top: 16px;
}

.connection-status {
    display: grid;
    grid-template-columns: 14px minmax(0, 1fr);
    gap: 10px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.connection-status:first-of-type {
    border-top: 0;
    padding-top: 0;
}

.connection-status:last-child {
    padding-bottom: 0;
}

.connection-status__indicator {
    width: 10px;
    height: 10px;
    margin-top: 4px;
    border-radius: 999px;
    background: #9aa6b2;
    box-shadow: 0 0 0 4px rgba(154, 166, 178, 0.14);
}

.connection-status.is-success .connection-status__indicator {
    background: var(--success);
    box-shadow: 0 0 0 4px rgba(20, 122, 67, 0.14);
}

.connection-status.is-error .connection-status__indicator {
    background: var(--danger);
    box-shadow: 0 0 0 4px rgba(180, 35, 24, 0.14);
}

.connection-status__content {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.connection-status__content strong {
    color: var(--text);
    font-size: 14px;
    line-height: 1.25;
}

.connection-status__content span {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.connection-status.is-success .connection-status__content span {
    color: var(--success);
}

.connection-status.is-error .connection-status__content span {
    color: var(--danger);
}

.muted {
    color: var(--muted);
    line-height: 1.45;
}

#portal-settings-info {
    white-space: pre-line;
}

.form-grid {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 14px;
}

input {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
}

input:focus {
    border-color: var(--accent);
    outline: 3px solid rgba(31, 101, 214, 0.16);
}

button {
    min-height: 42px;
    padding: 10px 16px;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: #ffffff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

button:hover {
    background: var(--accent-strong);
}

.secondary-button {
    min-height: 36px;
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--text);
}

.secondary-button:hover {
    background: #eef3fb;
}

button:disabled {
    cursor: wait;
    opacity: 0.72;
}

.status-line {
    min-height: 22px;
    margin: 14px 0 0;
    color: var(--muted);
    line-height: 1.45;
}

.status-line.is-success {
    color: var(--success);
}

.status-line.is-error {
    color: var(--danger);
}

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

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.history-table th,
.history-table td {
    padding: 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.history-table th {
    color: var(--muted);
    font-weight: 700;
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    background: #eef3fb;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.status-badge.is-success {
    background: #e8f7ef;
    color: var(--success);
}

.status-badge.is-error {
    background: #fdecea;
    color: var(--danger);
}

@media (max-width: 520px) {
    .app-shell {
        width: min(100% - 20px, 760px);
        padding: 20px 0;
    }

    .panel {
        padding: 18px;
    }

    h1 {
        font-size: 24px;
    }

    .tabs {
        overflow-x: auto;
    }

    .main-dashboard {
        grid-template-columns: 1fr;
    }

    .status-panel {
        position: static;
    }

    .panel-title-row {
        align-items: flex-start;
        flex-direction: column;
    }
}
