:root {
    color-scheme: light;
    --bg: #f7f9fc;
    --surface: #ffffff;
    --surface-muted: #f1f4f8;
    --text: #1f2937;
    --muted: #667085;
    --line: #d8dee8;
    --accent: #1a73e8;
    --accent-dark: #1558b0;
    --success: #137333;
    --warning: #b06000;
    --danger: #b42318;
    --shadow: 0 18px 50px rgba(17, 24, 39, 0.14);
}

html.dark,
html.system.dark {
    color-scheme: dark;
    --bg: #101418;
    --surface: #171d24;
    --surface-muted: #222a33;
    --text: #eef2f6;
    --muted: #aab4c0;
    --line: #33404d;
    --accent: #6aa6ff;
    --accent-dark: #9cc5ff;
    --success: #74d99f;
    --warning: #f4c061;
    --danger: #ff8a80;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
}

* {
    box-sizing: border-box;
}

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

a {
    color: inherit;
}

.shell {
    display: block;
    min-height: 100vh;
}

.mobile-bar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    align-items: center;
    gap: 10px;
    min-height: 58px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    padding: 8px 14px;
}

.mobile-bar strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: min(82vw, 286px);
    transform: translateX(-102%);
    border-right: 1px solid var(--line);
    background: var(--surface);
    padding: 18px 14px;
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
    overflow-y: auto;
}

body.menu-open .sidebar {
    transform: translateX(0);
}

body.menu-open::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.34);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 8px 10px;
    color: var(--text);
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.78rem;
}

nav {
    display: grid;
    gap: 3px;
    margin-top: 20px;
}

.nav-item,
.service-nav-item {
    border-radius: 6px;
    text-decoration: none;
    font-weight: 700;
}

.nav-item {
    min-height: 40px;
    padding: 10px 12px;
    color: var(--text);
}

.nav-item:hover,
.nav-item.active {
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    color: var(--accent-dark);
}

.services-menu summary {
    list-style: none;
    cursor: pointer;
}

.services-menu summary::-webkit-details-marker {
    display: none;
}

.services-menu summary::after {
    content: "▾";
    float: right;
    transition: transform 120ms ease;
}

.services-menu:not([open]) summary::after {
    transform: rotate(-90deg);
}

.service-nav {
    display: grid;
    gap: 3px;
    margin: 3px 0 6px 14px;
    padding-left: 10px;
    border-left: 1px solid var(--line);
}

.service-nav-item {
    min-height: 34px;
    padding: 8px 10px;
    color: var(--text);
    font-size: 0.92rem;
}

.service-nav-item:hover,
.service-nav-item.active {
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    color: var(--accent-dark);
}

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

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.profile-signin {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 12px;
    color: var(--accent-dark);
    font-weight: 800;
    text-decoration: none;
}

.user-profile-menu {
    position: relative;
}

.user-profile-menu summary {
    display: block;
    cursor: pointer;
    list-style: none;
}

.user-profile-menu summary::-webkit-details-marker {
    display: none;
}

.avatar {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 900;
}

.avatar.large {
    width: 48px;
    height: 48px;
}

.profile-popover {
    position: absolute;
    top: 46px;
    right: 0;
    z-index: 80;
    width: min(320px, calc(100vw - 28px));
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 14px;
}

.profile-head {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
}

.profile-head strong,
.profile-head span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-head span {
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.86rem;
}

.profile-apps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 14px;
}

.profile-apps a,
.profile-actions a {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 9px;
    text-align: center;
    text-decoration: none;
    font-weight: 800;
}

.profile-actions {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.topbar p {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

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

h1 {
    margin-bottom: 0;
    font-size: 1.75rem;
    line-height: 1.2;
}

h2 {
    font-size: 1.15rem;
}

p {
    color: var(--muted);
    line-height: 1.55;
}

.domain-pill,
.status {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    border-radius: 999px;
    padding: 0 10px;
    white-space: nowrap;
    font-size: 0.82rem;
    font-weight: 800;
}

.domain-pill {
    background: var(--surface);
    border: 1px solid var(--line);
}

.status {
    background: var(--surface-muted);
    color: var(--muted);
}

.status.active {
    background: #e6f4ea;
    color: var(--success);
}

.status.reachable {
    background: #e6f4ea;
    color: var(--success);
}

.status.unreachable {
    background: #fce8e6;
    color: var(--danger);
}

.status.missing {
    background: #fef7e0;
    color: var(--warning);
}

.view {
    max-width: 1180px;
}

.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.shortcut-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.shortcut-card {
    display: grid;
    gap: 4px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-muted);
    padding: 16px;
    text-decoration: none;
}

.shortcut-card:hover {
    border-color: #bad3fb;
    background: #e8f0fe;
}

.shortcut-card span {
    color: var(--muted);
    font-size: 0.9rem;
}

.panel,
.service-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.panel {
    padding: 20px;
}

.metric {
    min-height: 132px;
}

.metric strong {
    display: block;
    margin-top: 14px;
    font-size: 2rem;
}

.service-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.service-card {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    padding: 14px;
}

.service-card .status,
.service-card a {
    grid-column: 2;
    justify-self: start;
}

.service-card h3 {
    margin-bottom: 3px;
    font-size: 1rem;
}

.service-card p {
    margin-bottom: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.service-card a,
button {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--accent-dark);
    min-height: 34px;
    padding: 7px 11px;
    text-decoration: none;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.icon-button {
    display: inline-grid;
    width: 42px;
    height: 42px;
    min-height: 42px;
    place-items: center;
    padding: 0;
}

.icon-button svg {
    width: 20px;
    height: 20px;
}

.theme-toggle {
    color: var(--text);
}

.service-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: var(--surface-muted);
    color: var(--accent-dark);
    font-weight: 900;
}

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

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

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

th {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
}

code {
    border-radius: 6px;
    background: var(--surface-muted);
    padding: 3px 6px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.site-create-form {
    display: grid;
    grid-template-columns: 1fr;
    align-items: end;
    gap: 12px;
    margin-top: 16px;
}

.site-create-form label {
    display: grid;
    gap: 6px;
}

.site-create-form label > span {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 700;
}

.site-create-form .message {
    grid-column: 1 / -1;
}

.field {
    display: grid;
    gap: 7px;
}

label {
    font-size: 0.9rem;
    font-weight: 800;
}

input,
select {
    min-height: 42px;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 9px 11px;
    font: inherit;
    background: var(--surface);
    color: var(--text);
}

input:focus,
select:focus {
    outline: 3px solid rgba(26, 115, 232, 0.16);
    border-color: var(--accent);
}

.path-input {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.path-input span {
    flex: 0 0 auto;
    color: var(--muted);
    font-weight: 800;
}

.path-input input {
    flex: 1 1 auto;
    min-width: 0;
}

.primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.danger-button {
    border-color: #f3b8b2;
    color: var(--danger);
}

.danger-button:hover {
    background: color-mix(in srgb, var(--danger) 14%, transparent);
}

.message {
    margin-top: 12px;
    font-weight: 800;
}

.message.error {
    color: var(--danger);
}

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

    .service-card {
        grid-template-columns: 42px minmax(0, 1fr) auto auto;
    }

    .service-card .status,
    .service-card a {
        grid-column: auto;
    }
}

@media (min-width: 861px) {
    .shell {
        display: grid;
        grid-template-columns: 256px minmax(0, 1fr);
    }

    .mobile-bar {
        display: none;
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 1;
        width: auto;
        height: 100vh;
        transform: none;
        box-shadow: none;
    }

    body.menu-open::after {
        display: none;
    }

    .content {
        padding: 24px;
    }

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

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

    .site-create-form {
        grid-template-columns: minmax(150px, 180px) minmax(220px, 1fr) minmax(180px, 260px) auto;
    }
}

@media (max-width: 520px) {
    .topbar {
        flex-direction: column;
    }

    .topbar-actions {
        width: 100%;
        justify-content: space-between;
    }

    .topbar-actions .theme-toggle {
        display: none;
    }
}
