* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #d40009;
    --primary-dark: #a00007;
    --secondary-color: #13017c;
    --text-color: #333;
    --text-light: #666;
    --bg-color: #f5f5f5;
    --card-bg: #ffffff;
    --border-color: #ddd;
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #ffffff;
    min-height: 100vh;
    color: var(--text-color);
}

button,
input {
    font-family: inherit;
}

body:has(#loginScreen.active),
body:has(#forgotScreen.active),
body:has(#accountScreen.active) {
    background: linear-gradient(to left, #d40009 0%, #13017c 100%);
}

.container {
    max-width: 100%;
    margin: 0;
    position: relative;
    z-index: 1;
}

.screen {
    display: none;
}

.screen.active {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

.login-wrapper {
    max-width: 400px;
    width: 100%;
    background: #ffffff;
    border-radius: 4px;
    box-shadow: 0px 2px 1px -1px rgba(0, 0, 0, 0.2), 0px 1px 1px 0px rgba(0, 0, 0, 0.14), 0px 1px 3px 0px rgba(0, 0, 0, 0.12);
    padding: 2rem;
}

.login-logo-img {
    max-width: 200px;
    height: auto;
    max-height: 80px;
    margin-bottom: 0.3rem;
}

.brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.brand-lockup {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: max-content;
    max-width: 100%;
}

.login-main-title {
    font-size: 1.955rem;
    font-weight: 300;
    color: rgba(0, 0, 0, 0.87);
    margin: 0;
    text-align: center;
    line-height: 1.15;
    letter-spacing: 0.00735em;
    white-space: nowrap;
}

.portal-name {
    margin: 0.12rem 0 0;
    font-size: 1.32rem;
    font-weight: 600;
    color: rgba(0, 0, 0, 0.6);
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
}

.brand-rule {
    width: 100%;
    height: 1px;
    background-color: rgba(0, 0, 0, 0.12);
    margin: 1rem 0 1.25rem;
}

.page-title {
    margin: 0 0 0.35rem;
    font-size: 1.35rem;
    font-weight: 400;
    text-align: center;
    color: rgba(0, 0, 0, 0.87);
    line-height: 1.3;
}

.page-lead {
    margin: 0 0 1.25rem;
    text-align: center;
    color: rgba(0, 0, 0, 0.6);
    font-size: 1rem;
    line-height: 1.5;
    white-space: pre-line;
}

.reset-note {
    margin: 0 0 1.25rem;
    text-align: left;
    color: #666666;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.45;
    white-space: pre-line;
}

.login-form {
    width: 100%;
    max-width: 400px;
}

.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 400;
    color: #666666;
    font-size: 14px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 12px;
    color: #999;
    pointer-events: none;
    z-index: 1;
}

.password-toggle {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

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

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 12px 15px 12px 45px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    background: #ffffff;
    color: rgba(0, 0, 0, 0.87);
}

input[type="password"] {
    padding-right: 45px;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(212, 0, 9, 0.1);
}

.lang-switch {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 5;
    display: flex;
    gap: 4px;
}

.lang-switch button {
    min-width: 40px;
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    background: transparent;
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.lang-switch button[aria-pressed="true"] {
    background: #ffffff;
    color: #13017c;
    border-color: #ffffff;
}

.btn-login {
    width: 100%;
    padding: 14px 20px;
    background: rgba(27, 122, 58, 0.25);
    color: #123d22;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 12px;
}

.btn-login:hover:not(:disabled) {
    background: rgba(27, 122, 58, 0.4);
    color: #123d22;
}

.btn-login:disabled {
    background: #e5e5e5;
    color: #666666;
    cursor: default;
}

.btn-forgot {
    width: 100%;
    margin-top: 14px;
    padding: 14px 16px;
    background: #ffffff;
    color: #13017c;
    border: 2px solid #13017c;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.35;
    text-align: center;
    white-space: normal;
    cursor: pointer;
}

.btn-forgot:hover {
    background: #13017c;
    color: #ffffff;
}

.btn-forgot .forgot-link {
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 600;
}

.login-hint {
    text-align: center;
    font-size: 14px;
    color: #666666;
    margin-top: 18px;
    margin-bottom: 0;
}

.login-doc-link {
    text-align: center;
    font-size: 13px;
    margin-top: 12px;
    margin-bottom: 0;
}

.login-doc-link button {
    background: none;
    border: none;
    padding: 0;
    color: var(--secondary-color);
    text-decoration: underline;
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
}

.login-doc-link button:hover {
    color: var(--primary-color);
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 12px 15px;
    border-radius: 6px;
    margin: 15px 0 0 0;
    display: none;
    font-size: 14px;
    text-align: center;
}

.error-message.show {
    display: block;
}

.error-message.ok {
    background: #d4edda;
    color: #155724;
}

.error-message.pending {
    background: #d1ecf1;
    color: #0c5460;
}

.rules {
    list-style: none;
    margin: 0 0 4px;
    padding: 0;
    color: #666666;
    font-size: 13px;
    line-height: 1.45;
}

.rules li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 4px;
}

.rule-mark {
    flex: 0 0 1em;
    font-weight: 700;
}

.rules li.met {
    color: #1b7f3b;
}

.rules li.fail {
    color: #b42318;
}

.hp {
    position: absolute;
    left: -10000px;
    height: 0;
    overflow: hidden;
}

#accountScreen.active {
    align-items: flex-start;
    padding: 72px 16px 48px;
    background: transparent;
}

.account-board {
    width: min(100%, 1040px);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.account-head {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 28px 24px 8px;
}

.status-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.status-tile,
.text-tile {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: rgba(0, 0, 0, 0.87);
    box-shadow: var(--shadow-lg);
    min-width: 0;
}

.status-tile.ok {
    border: 2px solid #1b7a3a;
}

.status-tile.soon {
    border: 2px solid #c49212;
}

.status-tile.over {
    border: 2px solid #d40009;
}

.status-tile {
    border-radius: 12px;
    padding: 10px 12px 9px;
}

.text-tile {
    border-radius: 16px;
    padding: 16px 16px 12px;
}

.status-title,
.tile-title {
    margin: 0;
    font-weight: 500;
    line-height: 1.25;
    color: rgba(0, 0, 0, 0.87);
}

.status-title {
    font-size: 0.84rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tile-title {
    font-size: 1.05rem;
}

.status-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
}

.status-figure {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
    margin: 0;
}

.status-value {
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: rgba(0, 0, 0, 0.87);
}

.status-value.is-mail {
    font-size: 0.92rem;
    font-weight: 500;
    letter-spacing: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.status-unit,
.tile-lead {
    color: #666666;
}

.status-unit {
    margin: 0;
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tile-lead {
    margin: 6px 0 0;
    font-size: 0.95rem;
    min-height: 1.2rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin: 0;
    padding: 3px 8px 3px 6px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid transparent;
    flex: 0 0 auto;
    white-space: nowrap;
}

.status-badge svg {
    width: 13px;
    height: 13px;
    flex: 0 0 auto;
}

.status-badge.ok {
    color: #14612d;
    background: rgba(27, 122, 58, 0.12);
    border-color: #1b7a3a;
}

.status-badge.soon {
    color: #8a6408;
    background: rgba(196, 146, 18, 0.14);
    border-color: #c49212;
}

.status-badge.over {
    color: #a00007;
    background: rgba(212, 0, 9, 0.1);
    border-color: #d40009;
}

.text-grid {
    display: grid;
    grid-template-columns: 1.25fr 0.9fr;
    gap: 16px;
    align-items: start;
}

.tile-lead:empty {
    display: none;
}

.text-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 11px 0;
    border-top: 1px solid rgba(0, 0, 0, 0.12);
    font-size: 14px;
}

.text-row span:first-child {
    color: #666666;
}

.text-row span:last-child {
    color: rgba(0, 0, 0, 0.87);
    text-align: right;
    overflow-wrap: anywhere;
}

#accountScreen .tile-title {
    margin-bottom: 12px;
}

#accountScreen .btn-primary {
    background: rgba(27, 122, 58, 0.25);
    color: #123d22;
    border-radius: 8px;
    font-weight: 500;
}

#accountScreen .btn-primary:hover {
    background: rgba(27, 122, 58, 0.4);
    color: #123d22;
    box-shadow: none;
}

#accountScreen .btn-secondary {
    background: #ffffff;
    color: #13017c;
    border: 2px solid #13017c;
    border-radius: 8px;
}

#accountScreen .btn-secondary:hover {
    background: #13017c;
    color: #ffffff;
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    max-width: 880px;
    width: 100%;
    margin: 0 auto;
}

.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.header h1 {
    font-size: 2em;
    font-weight: 400;
    margin-bottom: 10px;
    letter-spacing: 0.00735em;
}

.header p {
    font-size: 1em;
    opacity: 0.9;
}

.card-body {
    padding: 30px;
}

.user-info {
    margin: 0 0 8px;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.info-item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
}

.info-item:last-child {
    border-bottom: none;
}

.info-item .label {
    font-weight: 500;
    min-width: 180px;
    color: rgba(0, 0, 0, 0.87);
    font-size: 14px;
    letter-spacing: 0.00938em;
    margin-right: 12px;
}

.info-item .value {
    flex: 1;
    color: rgba(0, 0, 0, 0.6);
    font-size: 14px;
    letter-spacing: 0.00938em;
    overflow-wrap: anywhere;
}

.section-heading {
    font-size: 1.05rem;
    font-weight: 600;
    color: rgba(0, 0, 0, 0.87);
    margin: 28px 0 12px;
}

.events {
    list-style: none;
    margin: 0;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
}

.events li {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
    color: rgba(0, 0, 0, 0.6);
    font-size: 14px;
}

.events li:last-child {
    border-bottom: none;
}

.btn {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    margin-top: 20px;
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(212, 0, 9, 0.3);
}

.btn-secondary {
    background: var(--text-light);
    color: white;
}

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

.gen-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
    margin: 2px 0 8px;
}

.btn-generate {
    flex: 1;
    width: auto;
    margin: 0;
    background: #ffffff;
    color: #13017c;
    border: 1px solid rgba(19, 1, 124, 0.25);
    font-size: 14px;
    letter-spacing: 0.01em;
    overflow-wrap: anywhere;
}

.btn-generate.has-password {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 650;
}

.btn-copy {
    flex: 0 0 auto;
    width: auto;
    margin: 0;
    padding: 0 14px;
    background: #ffffff;
    color: #13017c;
    border: 1px solid #13017c;
    font-size: 14px;
    font-weight: 650;
}

.btn-copy:disabled {
    color: #8d8d96;
    border-color: rgba(19, 1, 124, 0.2);
    cursor: default;
}

.status-modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(8, 10, 28, 0.46);
}

.status-modal.is-open {
    display: flex;
}

.status-modal__card {
    width: min(100%, 440px);
    padding: 22px 22px 18px;
    border-radius: 12px;
    background: #ffffff;
    color: #333333;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.status-modal__title {
    margin: 0 0 10px;
    color: #13017c;
    font-size: 1.15rem;
}

.status-modal__text {
    margin: 0;
    line-height: 1.45;
}

.status-modal__card.is-fail .status-modal__text {
    color: #9b1c1c;
}

.status-modal__remember {
    margin: 12px 0 0;
    color: #123d22;
    font-weight: 700;
    line-height: 1.4;
}

.status-modal__card .btn {
    margin-top: 16px;
}

.gen-help-wrap {
    position: relative;
    flex: 0 0 40px;
}

.gen-help {
    width: 40px;
    height: 100%;
    min-height: 40px;
    border-radius: 8px;
    border: 1px solid rgba(19, 1, 124, 0.25);
    background: #ffffff;
    color: #13017c;
    font-weight: 700;
    cursor: help;
}

.gen-help-tip {
    display: none;
    position: absolute;
    z-index: 20;
    top: calc(100% + 6px);
    right: 0;
    width: 260px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #111114;
    color: #f4f4f5;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;
    text-align: left;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.gen-help-wrap:hover .gen-help-tip,
.gen-help-wrap:focus-within .gen-help-tip {
    display: block;
}

.gen-hint {
    margin: 0 0 10px;
    min-height: 0;
    text-align: left;
    color: #1b7f3b;
    font-size: 13px;
    line-height: 1.4;
}

.gen-hint:empty {
    display: none;
}

.footer-actions {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.change-block {
    width: min(100%, 420px);
    margin: 0 auto;
}

.change-block .tile-title {
    text-align: center;
}

#accountScreen .change-block .login-form {
    max-width: none;
}

.detail-stack {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-items: start;
}

.detail-tile {
    padding: 0;
}

.detail-tile > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    list-style: none;
    color: rgba(0, 0, 0, 0.87);
    font-size: 1.05rem;
    font-weight: 500;
}

.detail-tile > summary::-webkit-details-marker {
    display: none;
}

.detail-tile > summary::after {
    content: "▾";
    color: #666666;
    font-size: 0.8rem;
}

.detail-tile[open] > summary::after {
    content: "▴";
}

.detail-body {
    padding: 0 16px 14px;
}

#accountScreen .events {
    border: none;
    border-radius: 0;
}

#accountScreen .events li {
    padding: 11px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
    color: rgba(0, 0, 0, 0.6);
}

#accountScreen .events li:first-child {
    border-top: 1px solid rgba(0, 0, 0, 0.12);
}

#accountScreen .events li.is-extra {
    display: none;
}

#accountScreen .events.show-extra li.is-extra {
    display: block;
}

.events-more {
    display: inline-block;
    margin: 4px 0 0;
    padding: 0;
    border: none;
    background: none;
    color: #13017c;
    font-size: 14px;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.events-more[hidden] {
    display: none;
}

#accountScreen .events li:last-child,
#accountScreen .events:not(.show-extra) li:nth-child(10) {
    border-bottom: none;
}

@media (max-width: 768px) {
    .screen.active {
        padding: 1rem;
    }

    .login-wrapper {
        padding: 1.5rem;
    }

    .login-main-title {
        font-size: 1.67rem;
    }

    .card-body {
        padding: 20px;
    }

    .info-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .info-item .label {
        min-width: 0;
    }

    .header h1 {
        font-size: 1.5em;
    }

    .status-row,
    .text-grid,
    .detail-stack {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    input[type="text"],
    input[type="password"] {
        font-size: 16px;
    }
}
