:root {
    --bg: #f4f7fb;
    --bg-accent: #eef3fb;
    --surface: rgba(255, 255, 255, 0.94);
    --surface-strong: #ffffff;
    --surface-muted: #f6f8fc;
    --text: #0f172a;
    --muted: #5f6b80;
    --line: #d7dfea;
    --line-strong: #c5d1e2;
    --primary: #0f5bd8;
    --primary-strong: #0a45a6;
    --success: #13854b;
    --danger: #c0353f;
    --warning: #b37211;
    --ring: rgba(15, 91, 216, 0.18);
    --shadow-soft: 0 18px 36px rgba(15, 23, 42, 0.08);
    --shadow-strong: 0 26px 52px rgba(15, 23, 42, 0.14);
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --section-gap: 14px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
}

body {
    color: var(--text);
    font-family: "Avenir Next", "IBM Plex Sans", "Segoe UI", sans-serif;
    background:
        radial-gradient(1100px 620px at -12% -10%, rgba(14, 100, 216, 0.12) 0%, rgba(14, 100, 216, 0) 55%),
        radial-gradient(720px 420px at 112% -4%, rgba(16, 185, 129, 0.08) 0%, rgba(16, 185, 129, 0) 52%),
        linear-gradient(180deg, #f8fafc 0%, var(--bg) 100%);
}

a {
    color: inherit;
}

img {
    display: block;
    max-width: 100%;
}

.app {
    width: min(100%, 520px);
    margin: 0 auto;
    padding: 24px 16px 36px;
}

.app-profile {
    width: min(100%, 740px);
}

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-shell .app {
    width: min(100%, 460px);
}

.brand-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text);
}

.brand-lockup.compact {
    gap: 10px;
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.brand-lockup.compact .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 12px;
}

.brand-copy {
    min-width: 0;
}

.brand-wordmark {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.brand-meta {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--muted);
}

.page-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
    color: #30435f;
    font-size: 12px;
    font-weight: 700;
}

.page-header {
    margin-bottom: 18px;
}

.page-header h1,
.page-header h2 {
    margin: 0;
    font-size: 28px;
    letter-spacing: -0.03em;
}

.page-header p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.45;
}

.card {
    background: var(--surface);
    border: 1px solid rgba(195, 207, 225, 0.82);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-soft);
    padding: 22px;
    margin-bottom: 16px;
    backdrop-filter: blur(10px);
}

.auth-card {
    padding: 24px;
}

.section-title {
    margin: 0;
    font-size: 20px;
    letter-spacing: -0.02em;
}

.section-subtitle {
    margin: 6px 0 0;
    font-size: 14px;
    color: var(--muted);
    line-height: 1.45;
}

.form-grid {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}

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

label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    font-weight: 600;
}

input {
    width: 100%;
    padding: 14px 15px;
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    background: var(--surface-strong);
    color: var(--text);
    font-size: 15px;
    transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

input::placeholder {
    color: #94a0b3;
}

input:focus,
input:focus-visible {
    outline: none;
    border-color: #8fb2ef;
    box-shadow: 0 0 0 4px var(--ring);
}

.action-stack {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.inline-actions .primary-btn,
.inline-actions .ghost-btn,
.inline-actions .danger-btn {
    width: auto;
    min-width: 180px;
}

.primary-btn,
.ghost-btn,
.danger-btn {
    width: 100%;
    min-height: 48px;
    border-radius: var(--radius-md);
    border: none;
    padding: 13px 16px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease, background 120ms ease;
}

.primary-btn {
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-strong) 100%);
    color: #ffffff;
    box-shadow: 0 12px 26px rgba(15, 91, 216, 0.24);
}

.primary-btn.secondary,
.ghost-btn {
    background: var(--surface-muted);
    color: #20324e;
    border: 1px solid var(--line);
    box-shadow: none;
}

.primary-btn.confirm {
    background: linear-gradient(180deg, #1ca35b 0%, #127745 100%);
}

.primary-btn.reject,
.danger-btn {
    background: linear-gradient(180deg, #df5963 0%, #b4313d 100%);
    color: #ffffff;
}

.primary-btn:hover,
.ghost-btn:hover,
.danger-btn:hover {
    filter: brightness(1.02);
}

.primary-btn:active,
.ghost-btn:active,
.danger-btn:active {
    transform: translateY(1px);
}

.primary-btn:disabled,
.ghost-btn:disabled,
.danger-btn:disabled {
    opacity: 0.62;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    filter: none;
}

.primary-btn:focus-visible,
.ghost-btn:focus-visible,
.danger-btn:focus-visible,
.menu-toggle:focus-visible,
.copy-btn:focus-visible,
.confirm-close:focus-visible,
.inline-link:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--ring);
}

.error,
.status,
.info,
.result {
    margin-top: 14px;
    min-height: 18px;
    font-size: 14px;
    line-height: 1.45;
}

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

.status.ok,
.info.ok {
    color: var(--success);
}

.info.loading {
    color: var(--primary);
}

.footer-note {
    text-align: center;
    font-size: 13px;
    color: var(--muted);
    margin-top: 12px;
    line-height: 1.45;
}

.footer-links {
    display: grid;
    gap: 8px;
    margin-top: 18px;
}

.footer-links.compact {
    gap: 6px;
}

.inline-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.inline-link:hover {
    text-decoration: underline;
}

.profile-nav {
    position: sticky;
    top: 0;
    z-index: 20;
    margin-bottom: 18px;
}

.profile-topbar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 20px;
    border: 1px solid rgba(195, 207, 225, 0.92);
    background: rgba(255, 255, 255, 0.88);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(12px);
}

.profile-topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    order: 2;
}

.profile-topbar > .av-lang-switcher {
    order: 3;
    margin-left: auto;
}

.menu-toggle {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: var(--surface-strong);
    color: #20324e;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.menu-toggle svg {
    width: 18px;
    height: 18px;
}

.menu-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    width: min(300px, calc(100vw - 32px));
    z-index: 1100;
    background: var(--surface-strong);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow-strong);
    padding: 8px;
    display: grid;
    gap: 6px;
}

.menu-dropdown[hidden] {
    display: none !important;
}

.menu-item {
    border: none;
    background: transparent;
    text-align: left;
    padding: 11px 12px;
    border-radius: 12px;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
}

.menu-item:hover {
    background: var(--surface-muted);
}

.menu-item.danger {
    color: var(--danger);
}

.profile-hero {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1.2fr) minmax(220px, 0.8fr);
    align-items: start;
}

.profile-identity {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.profile-name {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.profile-stage-card {
    padding: 22px;
}

.profile-info {
    display: grid;
    gap: 16px;
}

.profile-summary {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    min-width: 0;
}

.profile-avatar {
    flex: 0 0 auto;
    width: 70px;
    height: 70px;
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, #e6f0ff 0%, #f5f9ff 100%);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 0 1px rgba(143, 178, 239, 0.32);
}

.profile-avatar svg {
    width: 30px;
    height: 30px;
    display: block;
}

.profile-summary-copy {
    display: grid;
    gap: 10px;
    min-width: 0;
    padding-top: 2px;
}

.profile-name {
    font-size: 17px;
    font-weight: 600;
    line-height: 1.3;
}

.profile-verification-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    justify-content: flex-start;
}

.profile-inline-action {
    width: auto;
    min-width: 0;
    min-height: 36px;
    padding: 0 12px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 999px;
}

.profile-section-card {
    display: grid;
    gap: 18px;
}

.token-action-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 4px;
}

.token-action-card {
    width: auto;
    min-width: 0;
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.86);
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease, opacity 120ms ease;
}

.token-action-card.primary {
    background: rgba(231, 241, 255, 0.95);
    border-color: #c5d7f5;
    color: #123f88;
}

.token-action-card.secondary {
    border-color: var(--line);
    background: rgba(255, 255, 255, 0.9);
}

.token-action-card:hover {
    border-color: #bdd0ee;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.token-action-card:disabled {
    opacity: 0.64;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.token-action-card:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--ring);
}

.token-action-label {
    display: block;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.token-action-icon {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.24);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.48);
}

.token-action-icon svg {
    width: 22px;
    height: 22px;
    display: block;
}

.token-action-card.primary .token-action-icon {
    background: rgba(255, 255, 255, 0.78);
    border-color: rgba(15, 75, 154, 0.14);
}

.token-action-card.secondary .token-action-icon {
    background: rgba(246, 249, 252, 0.96);
}

.token-state-panel {
    display: grid;
    gap: 10px;
    margin-top: 8px;
    padding: 14px 0 0;
    border-radius: var(--radius-lg);
    border: none;
    border-top: 1px solid rgba(199, 210, 225, 0.72);
    background: transparent;
}

.token-state-panel[hidden] {
    display: none !important;
}

.token-state-panel[data-state="active_access"],
.token-state-panel[data-state="active_registration"] {
    border-top-color: #c8daf7;
}

.token-state-panel[data-state="pending"] {
    border-top-color: #ecd4ab;
}

.token-state-panel[data-state="working"],
.token-state-panel[data-state="resolving"] {
    border-top-color: #d5deeb;
}

.token-state-panel[data-state="error"],
.token-state-panel[data-state="rejected"] {
    border-top-color: #f1c6cb;
}

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

.token-state-title {
    margin: 0;
    font-size: 16px;
    line-height: 1.2;
    letter-spacing: -0.02em;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.token-state-hint {
    margin: 0;
    font-size: 12px;
    line-height: 1.5;
    color: var(--muted);
}

.countdown-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(15, 91, 216, 0.08);
    border: 1px solid rgba(15, 91, 216, 0.14);
    color: #0f4b9a;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
}

.token-output-wrap {
    padding-top: 2px;
    border-top: none;
}

.token-output-wrap[hidden] {
    display: none !important;
}

.token-message {
    font-size: 14px;
    line-height: 1.5;
}

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

.token-copy-hint {
    margin-top: 8px;
    font-size: 12px;
    color: var(--muted);
}

.profile-detail-list {
    display: flex;
    flex-wrap: wrap;
    gap: 18px 24px;
    padding-top: 14px;
    border-top: 1px solid rgba(199, 210, 225, 0.72);
}

.profile-detail-list[hidden] {
    display: none !important;
}

.detail-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 0;
    border: none;
    background: transparent;
}

.detail-label {
    font-size: 13px;
    color: var(--muted);
}

.detail-value {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-align: right;
    overflow-wrap: anywhere;
}

.status-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 18px;
}

.status-panel {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface-muted);
}

.status-panel-label {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 6px;
}

.status-panel-value {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    overflow-wrap: anywhere;
}

.status-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.status-label {
    color: var(--muted);
    font-size: 13px;
}

.status-value {
    font-size: 14px;
    font-weight: 600;
}

.state-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    padding: 0 12px;
}

.state-badge.verified {
    background: #dcf4e6;
    color: #17653a;
}

.state-badge.unverified {
    background: #fde5e7;
    color: #9a2330;
}

.token-actions {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.countdown-box {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #ebf3ff;
    border: 1px solid #d3e2fb;
    color: #0f4b9a;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
}

.token-row {
    display: grid;
    grid-template-columns: 1fr 48px;
    gap: 10px;
    align-items: center;
    margin-top: 4px;
}

.token-box {
    padding: 18px 16px;
    border-radius: var(--radius-lg);
    background: var(--surface-strong);
    border: 1px solid #d8e3f5;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
    font-size: 24px;
    text-align: center;
    font-weight: 700;
    letter-spacing: 4px;
    cursor: pointer;
    user-select: all;
}

.copy-btn {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #1a2f4e;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
}

.copy-btn svg {
    width: 20px;
    height: 20px;
}

.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.54);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.confirm-overlay.visible {
    display: flex;
}

.confirm-card {
    position: relative;
    width: min(100%, 420px);
    background: var(--surface-strong);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow-strong);
    padding: 24px;
    text-align: left;
}

.confirm-card h3 {
    margin: 0 0 8px;
    font-size: 22px;
}

.confirm-card p {
    margin: 0 0 18px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.45;
}

.compact-modal {
    width: min(100%, 360px);
    padding: 20px;
    border-radius: 20px;
}

.compact-modal h3 {
    font-size: 20px;
    margin-right: 28px;
}

.modal-actions {
    display: grid;
    gap: 10px;
}

.provider-button-list {
    display: grid;
    gap: 10px;
}

.provider-button-list .primary-btn.secondary {
    justify-content: flex-start;
    text-align: left;
}

.confirm-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-strong);
    color: #334763;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.confirm-close svg {
    width: 16px;
    height: 16px;
}

.copy-toast {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    background: #0f172a;
    color: #f8fafc;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
    z-index: 1200;
}

.copy-toast.visible {
    opacity: 1;
}

.status:empty,
.error:empty,
.info:empty,
.result:empty,
[data-auto-hide-empty]:empty {
    display: none !important;
}

input, button {
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 760px) {
    .app-profile {
        width: min(100%, 100%);
    }

    .profile-hero,
    .status-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 520px) {
    .app {
        padding: 18px 12px 28px;
    }

    .brand-bar {
        margin-bottom: 18px;
    }

    .card,
    .auth-card,
    .confirm-card {
        padding: 18px;
        border-radius: 20px;
    }

    .page-header h1,
    .page-header h2 {
        font-size: 24px;
    }

    .primary-btn,
    .ghost-btn,
    .danger-btn {
        min-height: 46px;
        font-size: 14px;
    }

    .menu-dropdown {
        right: 0;
        width: min(100%, calc(100vw - 24px));
    }

    .profile-topbar {
        padding: 12px 14px;
    }

    .profile-stage-card,
    .profile-section-card {
        gap: 14px;
    }

    .profile-summary {
        gap: 12px;
        align-items: center;
    }

    .profile-avatar {
        width: 58px;
        height: 58px;
        border-radius: var(--radius-lg);
    }

    .profile-avatar svg {
        width: 26px;
        height: 26px;
    }

    .profile-summary-copy {
        gap: 8px;
        padding-top: 0;
    }

    .profile-name {
        font-size: 16px;
    }

    .profile-verification-row {
        flex-wrap: nowrap;
        gap: 6px;
        align-items: center;
    }

    .profile-verification-row .state-badge,
    .profile-inline-action.ghost-btn {
        min-height: 32px;
        padding: 0 10px;
        font-size: 11px;
        line-height: 1;
        white-space: nowrap;
    }

    .token-action-grid {
        display: grid;
        grid-template-columns: 1fr;
    }

    .token-action-card {
        width: 100%;
        justify-content: flex-start;
        text-align: left;
    }

    .token-state-head {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .countdown-pill {
        flex: 0 0 auto;
    }

    .token-state-title {
        font-size: 15px;
    }

    .token-state-panel {
        margin-top: 6px;
        padding-top: 12px;
    }

    .detail-item {
        align-items: flex-start;
        flex-direction: column;
    }

    .detail-value {
        text-align: left;
    }
}
