body {
    margin: 0;
    padding: 40px 20px;
    font-family: Arial, sans-serif;
    background: #f5f7fb;
    color: #1f2937;
}

.wrap {
    max-width: 980px;
    margin: 0 auto;
}

.panel {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    padding: 24px;
    margin-bottom: 24px;
}

.portal-logo {
    display: block;
    max-width: 360px;
    width: 100%;
    height: auto;
}

.password-wrap {
    position: relative;
    width: 100%;
    margin-bottom: 16px;
}

.password-wrap input {
    width: 100%;
    height: 44px;
    padding: 12px 55px 12px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 15px;
    line-height: 20px;
    margin-bottom: 0;
    display: block;
    -webkit-appearance: none;
    appearance: none;
}

.password-wrap input:focus,
.password-wrap input[type="text"],
.password-wrap input[type="password"] {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    outline: none;
    box-shadow: none;
}

.toggle-password {
    position: absolute;
    right: 14px;
    top: 46%;
    transform: translateY(-50%);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #64748b;
    user-select: none;
    z-index: 2;
}

.toggle-password:hover {
    color: #0f172a;
}

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

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

label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}

input[type="email"],
input[type="password"],
input[type="text"] {
    width: 100%;
    padding: 12px;
    margin-bottom: 16px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 15px;
}

button,
.btn {
    background: #0f172a;
    color: #ffffff;
    border: 0;
    border-radius: 8px;
    padding: 12px 18px;
    font-size: 15px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    box-sizing: border-box;
}

button:hover,
.btn:hover {
    background: #1e293b;
}

.btn-secondary {
    background: #334155;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-disabled {
    background: #cbd5e1;
    color: #64748b;
    cursor: not-allowed;
    pointer-events: none;
}

.flash {
    padding: 14px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: bold;
}

.flash.success {
    background: #ecfdf3;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.flash.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.flash.info {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.muted {
    color: #64748b;
}

.status {
    margin: 12px 0 20px 0;
}

.portal-app-row {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 18px;
    margin-bottom: 26px;
}

.portal-account-row {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 8px;
}

.portal-account-row-tight {
    margin-top: 0;
}

.portal-admin-row {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 18px;
    margin-bottom: 26px;
}

.logout-form {
    margin: 0;
}

.section-label {
    font-size: 14px;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.section-label-top {
    margin-top: 24px;
}

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

.header-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.hmrc-result {
    margin-top: 16px;
    display: none;
}

.hmrc-result pre {
    margin: 10px 0 0 0;
    background: #0f172a;
    color: #e2e8f0;
    padding: 14px;
    border-radius: 8px;
    overflow: auto;
    font-size: 13px;
    line-height: 1.45;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: #e2e8f0;
    color: #334155;
}

.badge.enabled {
    background: #dcfce7;
    color: #166534;
}

.badge.expired {
    background: #fef3c7;
    color: #92400e;
}

.badge.warning {
    background: #fef3c7;
    color: #92400e;
}

.badge.admin {
    background: #ede9fe;
    color: #5b21b6;
}

.badge.reject {
    background: #fee2e2;
    color: #991b1b;
}

.badge.live {
    background: #fee2e2;
    color: #991b1b;
}

.hmrc-status-card {
    border: 1px solid #dbe3ef;
    border-radius: 12px;
    padding: 18px;
    background: #f8fafc;
    margin: 18px 0 22px 0;
}

.hmrc-status-card.status-connected {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.hmrc-status-card.status-expired {
    border-color: #fcd34d;
    background: #fffbeb;
}

.hmrc-status-card.status-neutral {
    border-color: #dbe3ef;
    background: #f8fafc;
}

.hmrc-status-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.hmrc-status-title {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}

.hmrc-status-message {
    margin: 0 0 14px 0;
    color: #334155;
    line-height: 1.5;
}

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

.hmrc-status-item {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 14px;
}

.hmrc-status-item-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    margin-bottom: 6px;
}

.hmrc-status-item-value {
    font-size: 14px;
    color: #0f172a;
    word-break: break-word;
}

.hmrc-status-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.login-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 14px;
}

.login-links a {
    color: #1d4ed8;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

.login-links a:hover {
    text-decoration: underline;
}

.login-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.remember-me-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: normal;
    font-size: 14px;
    color: #334155;
}

.remember-me-label input[type="checkbox"] {
    margin: 0;
}

.runtime-settings-card {
    border: 1px solid #dbe3ef;
    border-radius: 12px;
    padding: 18px;
    background: #f8fafc;
    margin: 0 0 22px 0;
}

.runtime-settings-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.runtime-settings-title {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}

.runtime-settings-sub {
    margin: 6px 0 0 0;
    color: #64748b;
    line-height: 1.5;
    font-size: 14px;
}

.runtime-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.runtime-setting-item {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
}

.runtime-setting-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.runtime-setting-label {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 6px 0;
}

.runtime-setting-desc {
    font-size: 13px;
    color: #64748b;
    line-height: 1.45;
    margin: 0;
}

.runtime-switch {
    position: relative;
    display: inline-block;
    width: 64px;
    height: 34px;
    flex: 0 0 auto;
}

.runtime-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.runtime-slider {
    position: absolute;
    inset: 0;
    cursor: pointer;
    background: #cbd5e1;
    transition: 0.2s ease;
    border-radius: 999px;
}

.runtime-slider:before {
    content: "";
    position: absolute;
    height: 26px;
    width: 26px;
    left: 4px;
    top: 4px;
    background: #ffffff;
    transition: 0.2s ease;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.runtime-switch input:checked + .runtime-slider {
    background: #0f172a;
}

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

.runtime-setting-state {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 12px;
}

.runtime-settings-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.runtime-settings-meta {
    color: #64748b;
    font-size: 13px;
    margin-top: 10px;
}

@media (max-width: 720px) {
    .header-row {
        flex-direction: column;
        align-items: stretch;
    }

    .header-actions {
        width: 100%;
    }

    .header-actions .btn,
    .header-actions button {
        width: 100%;
    }

    .hmrc-status-actions .btn,
    .hmrc-status-actions button {
        width: 100%;
    }

    .portal-admin-row .btn,
    .portal-account-row .btn,
    .portal-app-row .btn {
        width: 100%;
    }

    .portal-logo {
        max-width: 280px;
    }

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

    .login-actions button {
        width: 100%;
    }

    .runtime-settings-actions .btn,
    .runtime-settings-actions button {
        width: 100%;
    }
}