:root {
    color-scheme: light;
    --bg: #f7f8fb;
    --panel: #ffffff;
    --ink: #172033;
    --muted: #748094;
    --line: #e6eaf1;
    --soft-line: #f0f3f8;
    --primary: #2f6df6;
    --primary-dark: #2459d6;
    --dark: #202938;
    --success-bg: #ecfdf3;
    --success-text: #118044;
    --fail-bg: #fff1f2;
    --fail-text: #c0263a;
    --idle-bg: #f3f6ff;
    --idle-text: #4250b5;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    background:
        linear-gradient(180deg, #ffffff 0, var(--bg) 280px),
        var(--bg);
    color: var(--ink);
    font-size: 15px;
}

a {
    color: inherit;
    text-decoration: none;
}

input,
textarea,
button {
    font: inherit;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(180deg, #ffffff 0%, #f7f8fb 100%);
}

.public-shell {
    min-height: 100vh;
    padding: 24px;
}

.public-topbar {
    width: min(1120px, 100%);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.quick-card {
    width: min(820px, 100%);
    margin: 110px auto 0;
    padding: 30px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 28px rgba(23, 32, 51, 0.04);
}

.public-title {
    margin-bottom: 20px;
    font-size: clamp(25px, 4vw, 34px);
}

.quick-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 12px;
}

.quick-result,
.quick-inline {
    margin-top: 16px;
    display: grid;
    gap: 14px;
    align-items: center;
}

.quick-result {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding-top: 16px;
    border-top: 1px solid var(--soft-line);
}

.quick-message {
    grid-column: 1 / -1;
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.quick-inline {
    grid-template-columns: repeat(4, max-content);
    color: var(--muted);
    font-size: 14px;
}

.login-panel,
.panel,
.table-wrap {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 28px rgba(23, 32, 51, 0.04);
}

.login-panel {
    width: min(390px, 100%);
    padding: 30px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.08;
    font-weight: 650;
}

.login-title {
    font-size: clamp(20px, 5vw, 26px);
    font-weight: 700;
    text-align: center;
}

.page-title {
    font-size: clamp(22px, 3vw, 28px);
}

.muted,
.hint {
    color: var(--muted);
}

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

label {
    display: grid;
    gap: 8px;
    color: #334155;
    font-size: 13px;
    font-weight: 600;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
    padding: 10px 12px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea {
    resize: vertical;
}

input:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(47, 109, 246, 0.11);
}

.button,
.icon-button {
    border: 0;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
}

.button {
    min-height: 40px;
    border-radius: 7px;
    padding: 0 16px;
    color: #fff;
    font-size: 14px;
    font-weight: 650;
}

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

.button-primary {
    background: var(--primary);
    box-shadow: 0 6px 16px rgba(47, 109, 246, 0.18);
}

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

.button-dark {
    background: var(--dark);
}

.button-light {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f2f5fa;
    color: var(--ink);
}

.button-light:hover {
    background: #e9eef6;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px clamp(18px, 5vw, 56px);
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(16px);
}

.brand {
    font-size: 17px;
    font-weight: 750;
}

nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

nav a {
    border-radius: 7px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 650;
    padding: 8px 11px;
}

nav a.active,
nav a:hover {
    background: #f0f5ff;
    color: var(--primary);
}

.container {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 64px;
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.panel {
    padding: 18px;
}

.add-panel {
    margin-bottom: 20px;
}

.add-form {
    grid-template-columns: minmax(220px, 1fr) 160px auto;
    align-items: end;
}

.quick-admin-panel {
    margin-bottom: 20px;
}

.proxy-editor {
    display: grid;
    gap: 14px;
}

.proxy-editor-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
}

.proxy-row {
    display: grid;
    grid-template-columns: 86px minmax(140px, 0.34fr) minmax(0, 1fr);
    gap: 14px;
    align-items: end;
}

.proxy-toggle {
    min-height: 40px;
    align-content: center;
    justify-items: start;
    gap: 4px;
    font-size: 11px;
    color: var(--muted);
    cursor: pointer;
}

.proxy-toggle input[type="checkbox"] {
    appearance: none;
    position: relative;
    width: 34px;
    height: 20px;
    margin: 0;
    padding: 0;
    border: 1px solid #b4becc;
    border-radius: 20px;
    background: #dce2eb;
    cursor: pointer;
}

.proxy-toggle input[type="checkbox"]::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.15s;
}

.proxy-toggle input[type="checkbox"]:checked {
    background: var(--primary);
    border-color: var(--primary);
}

.proxy-toggle input[type="checkbox"]:checked::after {
    transform: translateX(14px);
}

.checkbox-row {
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.checkbox-row input {
    width: 18px;
    height: 18px;
}

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

.wide {
    grid-column: 1 / -1;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
}

.alert {
    border-radius: 7px;
    margin-bottom: 18px;
    padding: 11px 13px;
    font-size: 14px;
    font-weight: 650;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
}

.alert-error {
    background: var(--fail-bg);
    color: var(--fail-text);
}

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

.list-toolbar,
.list-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.list-toolbar {
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 12px;
}

.list-control {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    font-size: 13px;
    text-align: center;
}

.list-control:hover,
.list-control.is-active {
    color: var(--primary-dark);
    background: #f0f5ff;
    border-color: #b9cffb;
}

.list-control:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

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

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

th {
    background: #fbfcfe;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

tbody tr {
    transition: background 0.18s;
}

tbody tr:hover,
.site-row:hover {
    background: #fbfcff;
}

.site-row {
    cursor: pointer;
}

.domain-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.back-link {
    display: inline-block;
    margin-bottom: 20px;
    color: var(--muted);
    font-size: 14px;
}

.domain-heading .page-title {
    font-size: 28px;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.domain-heading > div {
    min-width: 0;
}

.domain-heading form {
    flex-shrink: 0;
}

.domain-metrics,
.certificate-info {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px 24px;
    margin: 0;
}

.domain-metrics {
    padding: 24px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.domain-metrics dt,
.certificate-info dt {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 12px;
}

.domain-metrics dd,
.certificate-info dd {
    margin: 0;
    min-height: 26px;
    overflow-wrap: anywhere;
}

.domain-section {
    padding: 26px 0;
    border-bottom: 1px solid var(--line);
}

.domain-section h2 {
    margin: 0 0 18px;
    font-size: 18px;
    font-weight: 600;
}

.domain-section .section-heading h2 {
    margin-bottom: 0;
}

.domain-message,
.tls-result .hint {
    overflow-wrap: anywhere;
}

.tls-results {
    margin-top: 20px;
}

.tls-result,
.child-site {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
    padding: 14px 0;
    border-top: 1px solid var(--soft-line);
}

.child-site:first-of-type {
    margin-top: 16px;
}

.child-site a {
    overflow-wrap: anywhere;
}

.domain-log-table {
    box-shadow: none;
}

.domain-log-table td {
    font-size: 13px;
    overflow-wrap: anywhere;
}

.domain-log-table table {
    min-width: 1040px;
}

.domain-delete {
    margin-top: 24px;
}

.domain-delete button {
    color: var(--fail-text);
}

.subdomain-row > td {
    padding-top: 2px;
    padding-bottom: 2px;
}

.site-row .domain-cell {
    padding-left: calc(16px + var(--site-depth, 0) * 24px);
}

.subdomain-editor {
    margin-top: 10px;
    min-width: 220px;
    max-width: 320px;
    cursor: default;
}

.subdomain-editor summary {
    width: fit-content;
    color: var(--primary);
    font-size: 12px;
    cursor: pointer;
}

.subdomain-editor form {
    margin-top: 12px;
}

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

.subline {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
}

.status {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 999px;
    padding: 0 9px;
    font-size: 12px;
    font-weight: 650;
}

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

.status-fail {
    background: var(--fail-bg);
    color: var(--fail-text);
}

.status-never {
    background: var(--idle-bg);
    color: var(--idle-text);
}

.row-actions {
    display: flex;
    gap: 8px;
}

.icon-button {
    width: 34px;
    height: 34px;
    border-radius: 7px;
    background: #f2f5f9;
    color: #0f172a;
    font-size: 18px;
    font-weight: 650;
}

.icon-button.danger {
    background: #fff1f2;
    color: #be123c;
}

.empty {
    color: var(--muted);
    padding: 34px;
    text-align: center;
}

.details-row {
    display: none;
    background: #fbfcff;
}

.details-row.is-open {
    display: table-row;
}

.details-row td {
    padding: 18px;
}

.details-grid {
    display: grid;
    grid-template-columns: minmax(260px, 0.35fr) minmax(360px, 1fr);
    gap: 20px;
}

.edit-site-form {
    display: grid;
    align-content: start;
    gap: 12px;
}

.logs {
    display: grid;
    gap: 10px;
}

.log-row {
    display: grid;
    grid-template-columns: 140px 82px 72px 120px 120px minmax(180px, 1fr);
    gap: 10px;
    align-items: center;
    padding: 10px 0;
    border-top: 1px solid var(--soft-line);
    color: var(--muted);
    font-size: 13px;
}

.log-message {
    color: var(--ink);
}

@media (max-width: 760px) {
    .domain-metrics,
    .certificate-info {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .domain-heading .page-title {
        font-size: 24px;
    }

    .topbar,
    .section-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .container {
        width: min(100% - 24px, 1180px);
        margin-top: 24px;
    }

    .login-panel {
        padding: 24px;
    }

    .add-form,
    .form-grid,
    .quick-form,
    .quick-result,
    .quick-inline,
    .details-grid,
    .log-row {
        grid-template-columns: 1fr;
    }

    .proxy-row {
        grid-template-columns: 72px minmax(0, 1fr);
    }

    .proxy-row .proxy-toggle {
        grid-column: 1;
        grid-row: 1 / span 2;
        align-self: start;
        margin-top: 22px;
    }

    .proxy-row > label:not(.proxy-toggle) {
        grid-column: 2;
    }

    .quick-card {
        margin-top: 56px;
        padding: 22px;
    }

    .form-actions {
        justify-content: stretch;
    }

    .form-actions .button,
    .section-heading .button,
    .add-form .button {
        width: 100%;
    }
}
