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

:root {
    --bg: #f5f5f7;
    --surface: #ffffff;
    --surface-hover: #f9f9fb;
    --border: #e4e4e7;
    --text: #18181b;
    --text-muted: #71717a;
    --primary: #6d5dfc;
    --primary-hover: #5b4de0;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #22c55e;
    --google-bg: #fff;
    --google-text: #1f1f1f;
    --telegram-bg: #2aabee;
    --radius: 10px;
    --radius-lg: 16px;
}

html {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-font-smoothing: antialiased;
}

body:has(.container.wide) {
    align-items: flex-start;
}

.container {
    width: 100%;
    max-width: 400px;
    margin: 40px 20px;
    padding: 40px 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 6px 16px rgba(0, 0, 0, 0.04);
}

.logo {
    text-align: center;
    margin-bottom: 8px;
    font-size: 0.8rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-muted);
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 28px;
    text-align: center;
    color: var(--text);
}

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

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.form-group input {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.95rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(109, 93, 252, 0.15);
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

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

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-google {
    background: var(--google-bg);
    color: var(--google-text);
    font-weight: 500;
    margin-top: 10px;
}

.btn-google:hover {
    background: #f3f3f3;
}

.btn-google svg {
    width: 18px;
    height: 18px;
}

.btn-telegram {
    background: var(--telegram-bg);
    color: #fff;
    margin-top: 10px;
}

.btn-telegram:hover {
    background: #229ed9;
}

.divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.divider::before,
.divider::after {
    content: "";
    flex: 1;
    border-bottom: 1px solid var(--border);
}

.divider span {
    padding: 0 14px;
}

.link {
    text-align: center;
    margin-top: 20px;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.link a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

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

.error {
    background: #fef2f2;
    color: #dc2626;
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 18px;
    font-size: 0.875rem;
    border: 1px solid #fecaca;
}

.success {
    background: #f0fdf4;
    color: #16a34a;
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 18px;
    font-size: 0.875rem;
    border: 1px solid #bbf7d0;
}

/* Profile page */
.profile-section {
    margin-bottom: 28px;
}

.profile-section h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.profile-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    margin-bottom: 14px;
    border: 2px solid var(--border);
}

.profile-field {
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.profile-field strong {
    color: var(--text-muted);
    font-weight: 500;
    display: inline-block;
    min-width: 80px;
}

.connected-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

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

.badge {
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.badge-connected {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-sm {
    width: auto;
    padding: 7px 18px;
    font-size: 0.8rem;
}

.btn-outline {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.btn-warn {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
}

.btn-warn:hover {
    background: #fef3c7;
}

.actions-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

/* Consent page */
.consent-scopes {
    list-style: none;
    margin: 16px 0;
}

.consent-scopes li {
    padding: 8px 0;
    font-size: 0.9rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

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

.consent-scopes li::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    margin-right: 10px;
    vertical-align: middle;
}

.consent-app-name {
    color: var(--primary);
    font-weight: 600;
}

/* Dev dashboard */
.container.wide {
    max-width: 800px;
    padding: 32px 28px;
    margin: 40px auto;
}

.container.wide .dev-links {
    display: flex;
    flex-direction: row;
}

@media (max-width: 840px) {
    .container.wide {
        max-width: calc(100vw - 32px);
        margin: 16px auto;
        padding: 24px 16px;
    }

    .dev-table {
        font-size: 0.78rem;
    }

    .dev-table th,
    .dev-table td {
        padding: 8px 6px;
    }
}

.dev-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.dev-table th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    padding: 8px 10px;
    border-bottom: 2px solid var(--border);
}

.dev-table td {
    padding: 10px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.dev-table code {
    font-size: 0.8rem;
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--primary);
}

.badge-provider {
    background: var(--bg);
    color: var(--text-muted);
    border: 1px solid var(--border);
    margin-right: 4px;
}

.badge-google {
    color: #4285f4;
    border-color: #c4d7f5;
}

.badge-tg {
    color: #2aabee;
    border-color: #b3e0f7;
}

.badge-muted {
    background: var(--bg);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.badge-get {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
    font-family: monospace;
    font-size: 0.7rem;
}

.badge-post {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
    font-family: monospace;
    font-size: 0.7rem;
}

.dev-links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.dev-flow-diagram {
    margin-top: 16px;
}

.flow-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    font-size: 0.85rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

.flow-step:last-child {
    border-bottom: none;
}

.flow-num {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.flow-step code {
    font-size: 0.8rem;
    background: var(--bg);
    padding: 1px 5px;
    border-radius: 4px;
    color: var(--primary);
}

/* Integration guide */
.guide-step {
    margin-bottom: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.guide-step-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.guide-step-body {
    padding: 0;
}

.code-block {
    margin: 0;
    padding: 16px;
    background: #1e1e2e;
    color: #cdd6f4;
    font-size: 0.8rem;
    line-height: 1.6;
    overflow-x: auto;
    border-radius: 0;
}

.code-block code {
    font-family: "SF Mono", "Fira Code", "JetBrains Mono", monospace;
    background: none;
    padding: 0;
    color: inherit;
}

.guide-extras {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.guide-extra-item {
    display: flex;
    gap: 12px;
    padding: 10px 16px;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
    align-items: baseline;
}

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

.guide-extra-item strong {
    flex-shrink: 0;
    min-width: 120px;
    color: var(--text);
    font-size: 0.8rem;
}

.guide-extra-item span {
    color: var(--text-muted);
}

.guide-extra-item code {
    font-size: 0.78rem;
    background: var(--bg);
    padding: 1px 5px;
    border-radius: 4px;
    color: var(--primary);
}

.guide-extra-item a {
    color: var(--primary);
    text-decoration: none;
}

.guide-extra-item a:hover {
    text-decoration: underline;
}

/* ========== Hub — Authenticated Home ========== */

.hub-identity {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 28px;
}

.hub-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

.hub-avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    font-size: 1.5rem;
    font-weight: 600;
}

.hub-user-info {
    flex: 1;
    min-width: 0;
}

.hub-name {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0;
    text-align: left;
}

.hub-email {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 2px 0 8px;
}

.hub-verified-icon {
    color: var(--primary);
    flex-shrink: 0;
}

.hub-providers {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.hub-provider-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
}

.hub-edit-btn {
    flex-shrink: 0;
    align-self: flex-start;
    margin-top: 4px;
}

.hub-section {
    margin-bottom: 28px;
}

.hub-section-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
}

.hub-section-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.app-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
}

.app-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.app-card:hover {
    border-color: #c4c4cc;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.app-card-top {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 14px;
}

.app-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: linear-gradient(135deg, #ede9fe, #e0e7ff);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.app-card-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.app-name-link {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

a.app-name-link:hover {
    color: var(--primary);
}

.app-external-icon {
    opacity: 0.4;
    transition: opacity 0.15s;
}

a.app-name-link:hover .app-external-icon {
    opacity: 1;
}

.app-url {
    font-size: 0.78rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-card-scopes {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.app-scope-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
}

.app-scope-badge svg {
    opacity: 0.5;
}

.app-card-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.app-authorized-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn-revoke {
    color: var(--text-muted);
    background: transparent;
    border: 1px solid var(--border);
    font-size: 0.78rem;
    padding: 5px 14px;
}

.btn-revoke:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: #fef2f2;
}

/* Discover cards */
.discover-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, background 0.15s;
}

.discover-card:hover {
    border-color: var(--primary);
    border-style: solid;
    background: var(--surface);
}

.discover-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: linear-gradient(135deg, #f0f0f5, #e8e8ee);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
}

.discover-card:hover .discover-icon {
    background: linear-gradient(135deg, #ede9fe, #e0e7ff);
    color: var(--primary);
}

.discover-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.discover-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.discover-url {
    font-size: 0.78rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.discover-arrow {
    flex-shrink: 0;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.15s, transform 0.15s;
}

.discover-card:hover .discover-arrow {
    opacity: 1;
    transform: translateX(2px);
}

/* Ecosystem cards (guest page) */
.eco-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.eco-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.eco-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 12px rgba(109, 93, 252, 0.08);
}

.eco-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, #ede9fe, #e0e7ff);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s;
}

.eco-card:hover .eco-card-icon {
    transform: scale(1.05);
}

.eco-card-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.eco-card-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.eco-card-url {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.eco-card-arrow {
    flex-shrink: 0;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.15s, transform 0.15s;
}

.eco-card:hover .eco-card-arrow {
    opacity: 1;
    transform: translateX(3px);
}

.hub-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
    background: var(--bg);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.hub-empty p {
    margin: 0;
}

.hub-empty-hint {
    font-size: 0.85rem;
    margin-top: 4px;
}

.hub-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

.hub-dev-link {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
}

.hub-dev-link:hover {
    color: var(--primary);
}

/* ========== Guest Landing ========== */

.guest-hero {
    text-align: center;
    padding: 20px 0 32px;
}

.guest-title {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 12px;
    color: var(--text);
}

.guest-subtitle {
    font-size: 1rem;
    color: var(--text-muted);
    max-width: 400px;
    margin: 0 auto 24px;
    line-height: 1.5;
}

.guest-cta {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.guest-cta .btn {
    width: auto;
    padding: 12px 32px;
}

.service-card-guest {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.guest-features {
    margin: 28px 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.guest-feature {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.guest-feature:last-child {
    border-bottom: none;
}

.guest-feature svg {
    flex-shrink: 0;
    color: var(--primary);
    margin-top: 2px;
}

.guest-feature strong {
    display: block;
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 2px;
}

.guest-feature span {
    font-size: 0.82rem;
    color: var(--text-muted);
}

@media (max-width: 500px) {
    .hub-identity {
        flex-direction: column;
        text-align: center;
    }

    .hub-name {
        text-align: center;
    }

    .hub-email {
        justify-content: center;
    }

    .hub-providers {
        justify-content: center;
    }

    .hub-edit-btn {
        align-self: center;
    }

    .hub-services-grid {
        grid-template-columns: 1fr;
    }

    .guest-cta {
        flex-direction: column;
    }

    .guest-cta .btn {
        width: 100%;
    }
}
