:root {
    color-scheme: dark;
    --bg: #0d1117;
    --panel: #161b22;
    --panel-border: #30363d;
    --text: #f0f6fc;
    --muted: #8b949e;
    --green: #238636;
    --green-hover: #2ea043;
    --green-soft: rgba(35, 134, 54, 0.18);
    --red: #da3633;
    --red-soft: rgba(218, 54, 51, 0.18);
    --amber: #9e6a03;
    --amber-soft: rgba(158, 106, 3, 0.2);
    --blue: #1f6feb;
    --blue-soft: rgba(31, 111, 235, 0.16);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at 20% 0%, rgba(31, 111, 235, 0.1), transparent 34rem),
        var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Arial, Helvetica, sans-serif;
}

button,
input {
    font: inherit;
}

button {
    touch-action: manipulation;
}

.page-shell {
    width: min(1100px, 100%);
    margin: 0 auto;
    padding: 32px 22px 56px;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.brand {
    margin-bottom: 3px;
    color: #79c0ff;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.18em;
}

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

h1 {
    margin-bottom: 0;
    font-size: clamp(2rem, 5vw, 3rem);
    line-height: 1;
}

h2 {
    margin-bottom: 7px;
    font-size: 1.35rem;
}

.identity {
    display: grid;
    gap: 3px;
    
    text-align: right;
    overflow-wrap: anywhere;
}

.identity-label {
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.card {
    border: 1px solid var(--panel-border);
    border-radius: 18px;
    background: rgba(22, 27, 34, 0.96);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.24);
}

.control-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    gap: 18px;
}

.open-card,
.mode-card {
    min-height: 230px;
    padding: 22px;
}

.open-card {
    display: grid;
    align-content: center;
}

.open-button {
    width: 100%;
    min-height: 145px;
    border: 0;
    border-radius: 15px;
    background: var(--green);
    color: white;
    font-size: clamp(2rem, 5vw, 2.8rem);
    font-weight: 850;
    letter-spacing: 0.01em;
    cursor: pointer;
    box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.18);
    transition: transform 0.08s ease, background 0.15s ease, opacity 0.15s ease;
}

.open-button:hover:not(:disabled) {
    background: var(--green-hover);
}

.open-button:active:not(:disabled),
.secondary-button:active:not(:disabled),
.refresh-button:active:not(:disabled) {
    transform: translateY(1px) scale(0.995);
}

button:disabled,
input:disabled + .slider {
    cursor: not-allowed;
    opacity: 0.55;
}

.helper-text {
    margin-bottom: 0;
    color: var(--muted);
    line-height: 1.45;
}

.open-card > .helper-text {
    margin-top: 13px;
    text-align: center;
}

.switch-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.switch {
    position: relative;
    flex: 0 0 auto;
    width: 78px;
    height: 44px;
    margin-top: 3px;
}

.switch input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.slider {
    position: absolute;
    inset: 0;
    border: 1px solid #484f58;
    border-radius: 999px;
    background: #30363d;
    cursor: pointer;
    transition: 0.18s ease;
}

.slider::before {
    content: "";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.35);
    transition: 0.18s ease;
}

.switch input:checked + .slider {
    border-color: var(--red);
    background: var(--red);
}

.switch input:checked + .slider::before {
    transform: translateX(34px);
}

.switch input:focus-visible + .slider {
    outline: 3px solid rgba(121, 192, 255, 0.75);
    outline-offset: 3px;
}

.mode-badge {
    margin-top: 25px;
    padding: 15px;
    border: 1px solid;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 850;
    text-align: center;
    letter-spacing: 0.05em;
}

.mode-badge.normal {
    border-color: var(--green);
    background: var(--green-soft);
    color: #7ee787;
}

.mode-badge.forced {
    border-color: var(--red);
    background: var(--red-soft);
    color: #ffb3ad;
}

.mode-badge.unknown {
    border-color: var(--amber);
    background: var(--amber-soft);
    color: #e3b341;
}

.secondary-button,
.refresh-button {
    border: 1px solid #8b949e;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    font-weight: 750;
    cursor: pointer;
}

.secondary-button {
    display: none;
    width: 100%;
    min-height: 48px;
    margin-top: 14px;
}

.secondary-button:hover:not(:disabled),
.refresh-button:hover:not(:disabled) {
    background: #21262d;
}

.admin-note {
    margin: 15px 0 0;
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.45;
}

.message {
    min-height: 54px;
    margin: 18px 0;
    padding: 15px 18px;
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    background: rgba(13, 17, 23, 0.88);
    color: #c9d1d9;
    line-height: 1.4;
    text-align: center;
}

.message:empty {
    visibility: hidden;
}

.message.success {
    border-color: var(--green);
    background: var(--green-soft);
    color: #7ee787;
}

.message.error {
    border-color: var(--red);
    background: var(--red-soft);
    color: #ffb3ad;
}

.message.working {
    border-color: var(--blue);
    background: var(--blue-soft);
    color: #79c0ff;
}

.activity-card {
    padding: 20px;
}

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

.activity-heading h2 {
    margin-bottom: 3px;
}

.refresh-button {
    min-height: 40px;
    padding: 0 17px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--panel-border);
    border-radius: 12px;
}

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

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

th {
    background: #0d1117;
    color: #c9d1d9;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

td {
    color: #d0d7de;
    font-size: 0.91rem;
}

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

tbody tr:hover td {
    background: rgba(110, 118, 129, 0.08);
}

.result-pill {
    display: inline-flex;
    align-items: center;
    min-width: 66px;
    justify-content: center;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
}

.result-pill.success {
    background: var(--green-soft);
    color: #7ee787;
}

.result-pill.failed {
    background: var(--red-soft);
    color: #ffb3ad;
}

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

.hidden-form {
    display: none;
}

@media (max-width: 780px) {
    .page-shell {
        padding: 22px 14px 38px;
    }

    .page-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    .identity {
        max-width: 100%;
        text-align: left;
    }

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

    .open-card,
    .mode-card {
        min-height: 0;
    }
}

@media (max-width: 480px) {
    .open-card,
    .mode-card,
    .activity-card {
        padding: 17px;
        border-radius: 15px;
    }

    .open-button {
        min-height: 125px;
    }

    .switch-row {
        align-items: center;
    }

    .activity-heading {
        align-items: flex-start;
    }
}

/* Authentication and login */
.identity-panel {
    display: flex;
    align-items: flex-end;
    gap: 14px;
}

.logout-button {
    min-height: 36px;
    padding: 0 13px;
    border: 1px solid #8b949e;
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
}

.logout-button:hover {
    background: #21262d;
}

.login-body {
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-shell {
    width: min(430px, 100%);
}

.login-card {
    padding: 30px;
}

.login-card h1 {
    margin-top: 3px;
    font-size: 2.2rem;
}

.login-intro {
    margin: 14px 0 24px;
    color: var(--muted);
    line-height: 1.5;
}

.login-form {
    display: grid;
    gap: 9px;
}

.login-form label {
    margin-top: 7px;
    color: #c9d1d9;
    font-size: 0.9rem;
    font-weight: 750;
}

.login-form input {
    width: 100%;
    min-height: 48px;
    padding: 0 13px;
    border: 1px solid #484f58;
    border-radius: 10px;
    outline: none;
    background: #0d1117;
    color: var(--text);
}

.login-form input:focus {
    border-color: #58a6ff;
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.25);
}

.login-button,
.windows-login-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 50px;
    border-radius: 10px;
    font-weight: 800;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.login-button {
    margin-top: 14px;
    border: 0;
    background: var(--green);
    color: #fff;
}

.login-button:hover {
    background: var(--green-hover);
}

.windows-login-button {
    border: 1px solid #8b949e;
    background: transparent;
    color: var(--text);
}

.windows-login-button:hover {
    background: #21262d;
}

.link-button {
    margin-top: 20px;
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 19px 0;
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.login-divider::before,
.login-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--panel-border);
}

.login-note {
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.45;
    text-align: center;
}

.validation-summary,
.field-error {
    color: #ff7b72;
    font-size: 0.84rem;
}

.validation-summary:empty,
.field-error:empty {
    display: none;
}

.validation-summary ul {
    margin: 0;
    padding-left: 18px;
}

@media (max-width: 780px) {
    .identity-panel {
        width: 100%;
        align-items: flex-start;
        justify-content: space-between;
    }

    .login-card {
        padding: 23px;
    }
}

/* Simplified v4 login emphasis */
.windows-login-button.primary-login {
    border-color: var(--blue);
    background: var(--blue);
    color: #fff;
}

.windows-login-button.primary-login:hover {
    background: #388bfd;
}

.windows-login-note,
.login-session-note {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.45;
    text-align: center;
}

.login-session-note {
    margin-top: 20px;
}

/* Automatic Windows sign-in (v5) */
.is-hidden {
    display: none !important;
}

.windows-auto-status {
    padding: 30px 8px 18px;
    color: #c9d1d9;
    text-align: center;
}

.windows-auto-status p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.login-spinner {
    width: 42px;
    height: 42px;
    margin: 0 auto 18px;
    border: 4px solid #30363d;
    border-top-color: #58a6ff;
    border-radius: 50%;
    animation: gate-login-spin 0.8s linear infinite;
}

@keyframes gate-login-spin {
    to {
        transform: rotate(360deg);
    }
}

.windows-failure {
    margin: 0 0 18px;
    padding: 12px 14px;
    border: 1px solid var(--amber);
    border-radius: 9px;
    background: var(--amber-soft);
    color: #e3b341;
    font-size: 0.86rem;
    line-height: 1.45;
}

.windows-retry-button {
    width: 100%;
    min-height: 42px;
    margin-top: 14px;
    border: 1px solid #484f58;
    border-radius: 9px;
    background: transparent;
    color: #c9d1d9;
    font-weight: 700;
    cursor: pointer;
}

.windows-retry-button:hover {
    background: #21262d;
}

.login-server-error {
    margin-bottom: 16px;
}

.login-noscript {
    margin-top: 18px;
}


/* PWA / installed app */
.install-button {
    min-height: 36px;
    padding: 0 13px;
    border: 1px solid #58a6ff;
    border-radius: 9px;
    background: rgba(31, 111, 235, 0.14);
    color: #79c0ff;
    font-weight: 750;
    cursor: pointer;
}

.install-button:hover {
    background: rgba(31, 111, 235, 0.24);
}

@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-right: env(safe-area-inset-right);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
    }

    .install-button {
        display: none !important;
    }
}
