:root {
    color-scheme: light;
    --bg: #f6f7f9;
    --panel: #ffffff;
    --line: #d9dee7;
    --text: #17202c;
    --muted: #647084;
    --accent: #116466;
    --accent-strong: #0a4f51;
    --danger: #b42318;
    --danger-bg: #fff1f0;
    --success: #147d4f;
    --success-bg: #edfdf5;
    --warn-bg: #fff7df;
    --shadow: 0 10px 24px rgba(23, 32, 44, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

a:hover {
    text-decoration: underline;
}

.topbar {
    align-items: center;
    background: #ffffff;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 18px clamp(16px, 4vw, 42px);
}

.topbar h1,
.topbar p,
.panel h2,
.login-panel h1 {
    margin: 0;
}

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

.topbar nav {
    display: flex;
    gap: 14px;
    white-space: nowrap;
}

.topbar nav a {
    border-radius: 6px;
    color: var(--muted);
    font-weight: 700;
    padding: 7px 9px;
}

.topbar nav a.active {
    background: #e8f3f2;
    color: var(--accent-strong);
}

.layout {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.8fr);
    padding: 22px clamp(16px, 4vw, 42px) 42px;
}

.layout.single {
    grid-template-columns: minmax(0, 1fr);
}

.panel,
.login-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 20px;
}

.wide {
    grid-row: span 2;
}

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

.auth-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 20px;
}

.login-panel {
    max-width: 420px;
    width: 100%;
}

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

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

.full,
.form-actions {
    grid-column: 1 / -1;
}

label {
    display: grid;
    gap: 6px;
    font-weight: 650;
}

label span {
    font-size: 13px;
}

input,
select,
textarea {
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    min-width: 0;
    padding: 10px 11px;
    width: 100%;
}

textarea {
    resize: vertical;
}

.check {
    align-items: center;
    display: flex;
    gap: 8px;
    padding-top: 24px;
}

.check input {
    width: auto;
}

.field-with-button {
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) auto;
}

.field-with-button button {
    white-space: nowrap;
}

button,
.button {
    align-items: center;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 6px;
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 700;
    justify-content: center;
    min-height: 40px;
    padding: 8px 13px;
    text-decoration: none;
}

button:hover,
.button:hover {
    background: var(--accent-strong);
    text-decoration: none;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.secondary {
    background: #ffffff;
    border-color: var(--line);
    color: var(--text);
}

.secondary:hover {
    background: #eef2f5;
}

.danger {
    background: var(--danger);
    border-color: var(--danger);
}

.small {
    font-size: 13px;
    min-height: 32px;
    padding: 5px 9px;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.notice {
    border: 1px solid var(--line);
    border-radius: 6px;
    margin: 12px 0;
    padding: 10px 12px;
}

.notice.success {
    background: var(--success-bg);
    border-color: #a8e8cc;
}

.notice.danger {
    background: var(--danger-bg);
    border-color: #ffcdc8;
    color: var(--danger);
}

.table-wrap {
    overflow-x: auto;
}

.mobile-proxy-list {
    display: none;
}

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

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

th {
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0;
    text-transform: uppercase;
}

td small {
    display: block;
    margin-top: 3px;
}

.actions {
    min-width: 210px;
    white-space: nowrap;
}

td.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.status {
    border-radius: 999px;
    display: inline-flex;
    font-size: 13px;
    font-weight: 700;
    padding: 3px 9px;
}

.status.online {
    background: var(--success-bg);
    color: var(--success);
}

.status.offline,
.status.error {
    background: var(--danger-bg);
    color: var(--danger);
}

.status.disabled {
    background: #edf0f4;
    color: var(--muted);
}

.empty {
    background: #f9fafb;
    border: 1px dashed var(--line);
    border-radius: 6px;
    color: var(--muted);
    padding: 18px;
    text-align: center;
}

.pending-list {
    display: grid;
    gap: 8px;
    list-style: none;
    margin: 14px 0 0;
    padding: 0;
}

.pending-list li {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    display: flex;
    gap: 10px;
    justify-content: space-between;
    padding: 9px 10px;
}

.pending-list form {
    margin: 0;
}

.helper-state {
    align-items: center;
    border-top: 1px solid var(--line);
    display: flex;
    gap: 10px;
    justify-content: space-between;
    margin-top: 14px;
    padding-top: 14px;
}

.helper-log {
    margin-top: 12px;
}

.helper-log summary {
    color: var(--accent-strong);
    cursor: pointer;
    font-weight: 700;
}

.helper-log pre {
    background: #101828;
    border-radius: 6px;
    color: #f8fafc;
    font-size: 12px;
    line-height: 1.45;
    max-height: 260px;
    overflow: auto;
    padding: 12px;
    white-space: pre-wrap;
}

.network-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.network-link {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    display: flex;
    gap: 14px;
    justify-content: space-between;
    min-height: 92px;
    padding: 15px;
    text-decoration: none;
}

.network-link:hover {
    border-color: #94c7c2;
    box-shadow: 0 8px 18px rgba(17, 100, 102, 0.1);
    text-decoration: none;
}

.network-link span {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.network-link small,
.proxy-card small {
    overflow-wrap: anywhere;
}

.proxy-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 12px;
    padding: 14px;
}

.proxy-card-head,
.card-actions {
    align-items: flex-start;
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.proxy-card-head > div {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.proxy-card dl {
    display: grid;
    gap: 8px;
    margin: 0;
}

.proxy-card dl div {
    display: grid;
    gap: 2px;
}

.proxy-card dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.proxy-card dd,
.proxy-card p {
    margin: 0;
    overflow-wrap: anywhere;
}

.card-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
}

code {
    background: #eef2f5;
    border-radius: 4px;
    padding: 1px 4px;
}

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

    .wide {
        grid-row: auto;
    }
}

@media (max-width: 620px) {
    .topbar,
    .section-head {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar nav {
        display: grid;
        gap: 8px;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        white-space: normal;
    }

    .topbar nav a {
        text-align: center;
    }

    .grid-form {
        grid-template-columns: 1fr;
    }

    .field-with-button {
        grid-template-columns: 1fr;
    }

    .table-wrap {
        display: none;
    }

    .mobile-proxy-list {
        display: grid;
        gap: 12px;
    }

    .actions {
        min-width: 0;
    }

    .network-grid {
        grid-template-columns: 1fr;
    }

    .network-link {
        align-items: stretch;
        flex-direction: column;
    }

    .pending-list li,
    .helper-state {
        align-items: stretch;
        flex-direction: column;
    }
}
