:root {
    color-scheme: light;
    --bg: #eef2f7;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --sidebar: #172033;
    --sidebar-2: #202b42;
    --text: #172033;
    --muted: #667085;
    --muted-2: #98a2b3;
    --line: #d9e2ef;
    --line-strong: #c6d1df;
    --primary: #0f6b5f;
    --primary-dark: #0b554b;
    --primary-soft: #e7f6f3;
    --danger: #b42318;
    --danger-soft: #fff0ed;
    --warning: #9a6700;
    --warning-soft: #fff8df;
    --success: #067647;
    --success-soft: #ecfdf3;
    --shadow: 0 12px 32px rgba(16, 24, 40, 0.08);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 14px;
    letter-spacing: 0;
    line-height: 1.45;
    margin: 0;
}

button,
input,
select {
    font: inherit;
}

button {
    align-items: center;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    font-weight: 700;
    justify-content: center;
    min-height: 38px;
    padding: 8px 12px;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
    white-space: nowrap;
}

button:hover {
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

input,
select {
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--text);
    min-height: 40px;
    outline: none;
    padding: 9px 10px;
    width: 100%;
}

input:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 107, 95, 0.14);
}

input:disabled {
    background: #edf2f7;
    color: var(--muted);
    cursor: not-allowed;
}

.shell {
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    background: linear-gradient(180deg, var(--sidebar), #101828);
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 100vh;
    padding: 22px 18px;
    position: sticky;
    top: 0;
}

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

.brand-mark {
    align-items: center;
    background: #d7f4ee;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 8px;
    color: #0b554b;
    display: flex;
    flex: 0 0 42px;
    font-size: 14px;
    font-weight: 900;
    height: 42px;
    justify-content: center;
    width: 42px;
}

.brand h1,
.auth-brand h1 {
    font-size: 18px;
    line-height: 1.1;
    margin: 0;
}

.brand span,
.auth-brand p {
    color: #b9c4d3;
    display: block;
    font-size: 12px;
    margin: 4px 0 0;
}

.nav-menu {
    display: grid;
    gap: 6px;
}

.nav-menu a,
.link-button {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: #ced6e3;
    min-height: 40px;
    padding: 9px 11px;
    text-align: left;
    text-decoration: none;
    width: 100%;
}

.nav-menu a:hover,
.link-button:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    transform: none;
}

.nav-menu a.active {
    background: var(--sidebar-2);
    border-color: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-weight: 800;
}

.sidebar-footer {
    margin-top: auto;
}

.content {
    min-width: 0;
    padding: 28px;
}

.page-header {
    align-items: flex-start;
    display: flex;
    gap: 18px;
    justify-content: space-between;
    margin: 0 0 20px;
}

.page-header-stack h2 {
    font-size: 28px;
    letter-spacing: 0;
    line-height: 1.15;
    margin: 3px 0 6px;
}

.page-header p,
.panel-header p {
    color: var(--muted);
    margin: 0;
}

.eyebrow {
    color: var(--primary);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin: 0 0 18px;
    overflow: hidden;
}

.panel-header {
    align-items: flex-start;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 16px 18px;
}

.panel-header h3 {
    font-size: 17px;
    line-height: 1.25;
    margin: 0 0 4px;
}

.form-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 18px;
}

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

.field {
    display: grid;
    gap: 6px;
    min-width: 0;
}

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

.field label,
.toggle-field {
    color: #475467;
    font-size: 12px;
    font-weight: 800;
}

.domain-field {
    align-items: stretch;
    display: grid;
    grid-template-columns: minmax(90px, 1fr) auto;
    min-width: 0;
}

.domain-field input {
    border-bottom-right-radius: 0;
    border-right: 0;
    border-top-right-radius: 0;
}

.domain-suffix {
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    border-bottom-right-radius: 6px;
    border-left: 0;
    border-top-right-radius: 6px;
    color: var(--muted);
    display: flex;
    font-size: 13px;
    max-width: 230px;
    overflow: hidden;
    padding: 0 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toggle-field {
    align-items: center;
    align-self: end;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    display: flex;
    gap: 9px;
    min-height: 40px;
    padding: 9px 10px;
}

.toggle-field input {
    accent-color: var(--primary);
    flex: 0 0 auto;
    min-height: 16px;
    width: 16px;
}

.section-divider {
    border-top: 1px solid var(--line);
    margin: 0 18px;
    padding-top: 14px;
}

.section-divider h4 {
    font-size: 13px;
    margin: 0;
    text-transform: uppercase;
}

.form-actions {
    align-items: center;
    border-top: 1px solid var(--line);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 14px 18px;
}

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

.primary-button:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.secondary-button {
    background: #fff;
    border: 1px solid var(--line-strong);
    color: #344054;
}

.secondary-button:hover {
    background: var(--surface-2);
}

.danger-button {
    background: #fff;
    border: 1px solid #f4b8b2;
    color: var(--danger);
}

.danger-button:hover {
    background: var(--danger-soft);
}

.large-button {
    min-height: 44px;
    padding-left: 16px;
    padding-right: 16px;
}

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

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

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

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

th {
    background: var(--surface-2);
    color: #667085;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.actions-column {
    text-align: right;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.row-actions button {
    min-height: 34px;
    padding: 6px 10px;
}

.mono {
    font-family: Consolas, "Courier New", monospace;
    font-size: 13px;
}

.muted-line {
    color: var(--muted);
    display: block;
    font-size: 12px;
    margin-top: 3px;
}

.status-pill,
.protocol-pill {
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 900;
    line-height: 1;
    padding: 6px 9px;
    white-space: nowrap;
}

.status-pill.enabled {
    background: var(--success-soft);
    color: var(--success);
}

.status-pill.disabled {
    background: #f2f4f7;
    color: #667085;
}

.protocol-pill {
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.notice {
    border-radius: var(--radius);
    margin: 0 0 18px;
    padding: 12px 14px;
}

.notice.success {
    background: var(--success-soft);
    border: 1px solid #abefc6;
    color: var(--success);
}

.notice.warning {
    background: var(--warning-soft);
    border: 1px solid #f6d470;
    color: var(--warning);
}

.notice.danger {
    background: var(--danger-soft);
    border: 1px solid #f4b8b2;
    color: var(--danger);
}

.apply-panel {
    max-width: 720px;
}

.apply-panel .primary-button {
    margin: 0 18px 18px;
}

.result-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 16px 18px 18px 36px;
}

.auth-shell {
    align-items: center;
    background: var(--bg);
    display: flex;
    min-height: 100vh;
    padding: 24px;
}

.auth-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin: 0 auto;
    max-width: 420px;
    padding: 24px;
    width: 100%;
}

.auth-brand {
    margin-bottom: 22px;
}

.auth-brand .brand-mark {
    background: var(--primary);
    color: #fff;
}

.auth-brand h1 {
    color: var(--text);
}

.auth-brand p {
    color: var(--muted);
}

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

@media (max-width: 1100px) {
    .form-grid,
    .settings-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

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

    .sidebar {
        min-height: auto;
        position: static;
    }

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

    .content {
        padding: 18px;
    }

    .page-header {
        display: grid;
    }

    .page-header .primary-button {
        justify-self: start;
    }

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

    .field-wide {
        grid-column: auto;
    }

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

    .domain-field input {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        border-right: 1px solid var(--line-strong);
        border-top-right-radius: 6px;
    }

    .domain-suffix {
        border-left: 1px solid var(--line-strong);
        border-top: 0;
        border-top-right-radius: 0;
        max-width: none;
        min-height: 38px;
    }

    .table-wrap {
        overflow: visible;
    }

    table {
        min-width: 0;
    }

    thead {
        display: none;
    }

    tbody,
    tr,
    td {
        display: block;
        width: 100%;
    }

    tr {
        border-bottom: 1px solid var(--line);
        padding: 10px 0;
    }

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

    td {
        align-items: flex-start;
        border-bottom: 0;
        display: grid;
        gap: 10px;
        grid-template-columns: 104px minmax(0, 1fr);
        padding: 7px 14px;
    }

    td::before {
        color: var(--muted);
        content: attr(data-label);
        font-size: 12px;
        font-weight: 900;
        text-transform: uppercase;
    }

    .row-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 520px) {
    .content {
        padding: 14px;
    }

    .nav-menu {
        grid-template-columns: 1fr;
    }

    .page-header-stack h2 {
        font-size: 24px;
    }

    .panel-header,
    .form-grid,
    .form-actions {
        padding-left: 14px;
        padding-right: 14px;
    }

    .form-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .form-actions button,
    .page-header .primary-button,
    .apply-panel .primary-button {
        width: 100%;
    }

    td {
        grid-template-columns: 1fr;
    }

    .row-actions button {
        flex: 1 1 auto;
    }
}
