*,
*::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: #c2410c;
    --primary-hover: #9a3412;
    --primary-soft: #fff7ed;
    --primary-soft-strong: #ffedd5;
    --primary-ring: rgba(194, 65, 12, 0.18);
    --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;
}

/* App-shell pages with a topbar use normal block flow so the bar can span full width above the container */
body:has(.topbar) {
    display: block;
}

.container {
    width: calc(100% - 40px);
    max-width: 400px;
    margin: 40px auto;
    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);
}

.brand {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 28px;
    text-decoration: none;
}

.brand:focus-visible {
    outline: 3px solid var(--primary-ring);
    outline-offset: 6px;
    border-radius: 14px;
}

.brand-lockup {
    display: block;
    width: min(100%, 160px);
    height: auto;
}

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 var(--primary-ring);
}

.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;
}

/* App-shell topbar (used on logged-in dashboards: home, admin, profile, docs) */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    background: rgba(255, 255, 255, 0.85);
    border-bottom: 1px solid var(--border);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
}

.topbar-inner {
    max-width: 800px;
    margin: 0 auto;
    padding: 10px 28px;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar-brand {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
    border-radius: 6px;
}

.topbar-brand:focus-visible {
    outline: 3px solid var(--primary-ring);
    outline-offset: 4px;
}

.topbar-mark {
    display: block;
    height: 28px;
    width: auto;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.topbar-form {
    display: contents;
}

.topbar-link {
    display: inline-flex;
    align-items: center;
    height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    background: transparent;
    border: 1px solid transparent;
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.topbar-link:hover,
.topbar-link:focus-visible {
    background: var(--bg);
    border-color: var(--border);
    color: var(--text);
}

.topbar-link:focus-visible {
    outline: 3px solid var(--primary-ring);
    outline-offset: 2px;
}

.topbar-link-muted {
    color: var(--text-muted);
}

@media (max-width: 840px) {
    .topbar-inner {
        max-width: 100%;
        padding: 8px 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .topbar-link {
        transition: none;
    }
}

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

/* Tighten container top margin when a sticky topbar is present */
body:has(.topbar) .container.wide {
    margin-top: 24px;
}

.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, var(--primary-soft), var(--primary-soft-strong));
    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;
}

.app-card-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: transparent;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    padding: 0;
}

.btn-magic {
    color: var(--primary);
}

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

/* Magic link toast */
.magic-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: 480px;
    padding: 0 16px;
}

.magic-toast-content {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
}

.magic-toast-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.magic-toast-header strong {
    font-size: 0.9rem;
}

.magic-toast-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
}

.magic-toast-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.magic-toast-url-row {
    display: flex;
    gap: 8px;
}

.magic-toast-input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.8rem;
    font-family: monospace;
    min-width: 0;
}

.magic-copy-btn {
    flex-shrink: 0;
    width: auto;
    padding: 8px 18px;
}

/* Credits widget */
.credits-widget {
    margin-bottom: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--surface);
}

.credits-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: linear-gradient(135deg, var(--primary-soft), var(--primary-soft-strong));
}

.credits-balance-area {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.credits-label {
    font-size: 0.78rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.credits-amount {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.credits-buy-btn {
    width: auto;
    padding: 8px 20px;
}

.credits-history {
    border-top: 1px solid var(--border);
    padding: 12px 24px 16px;
}

.credits-history-title {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.credits-tx {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
}

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

.credits-tx-desc {
    font-size: 0.85rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.credits-tx-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.credits-tx-amount {
    font-size: 0.9rem;
    font-weight: 600;
    flex-shrink: 0;
    margin-left: 12px;
}

.credits-tx-plus {
    color: #16a34a;
}

.credits-tx-minus {
    color: var(--text);
}

/* 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, var(--primary-soft), var(--primary-soft-strong));
    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(249, 115, 22, 0.12);
}

.eco-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary-soft), var(--primary-soft-strong));
    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) {
    .container {
        width: calc(100% - 32px);
        margin: 16px auto;
        padding: 32px 24px;
    }

    .brand {
        margin-bottom: 24px;
    }

    .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%;
    }
}

/* ---- Developer docs (/docs) ---- */
.container.wide.docs {
    max-width: 860px;
    padding: 32px 28px 48px;
}

.docs-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 14px;
    margin: 8px 0 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.82rem;
}

.docs-toolbar-label {
    color: var(--text-muted);
    font-weight: 500;
}

.docs-toolbar-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.docs-toolbar-links .badge {
    text-decoration: none;
    cursor: pointer;
}

.docs-toolbar-links .badge:hover {
    background: var(--surface-hover);
    border-color: var(--text-muted);
}

.docs-article {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px 40px;
    line-height: 1.65;
    color: var(--text);
}

.docs-article h1,
.docs-article h2,
.docs-article h3,
.docs-article h4 {
    line-height: 1.25;
    color: var(--text);
    margin: 28px 0 12px;
    font-weight: 600;
}

.docs-article h1 { font-size: 1.85rem; margin-top: 4px; }
.docs-article h2 {
    font-size: 1.35rem;
    border-top: 1px solid var(--border);
    padding-top: 24px;
    margin-top: 36px;
}
.docs-article h3 { font-size: 1.08rem; }
.docs-article h4 { font-size: 0.95rem; }

.docs-article p,
.docs-article ul,
.docs-article ol,
.docs-article blockquote,
.docs-article table {
    margin: 0 0 14px;
}

.docs-article ul,
.docs-article ol {
    padding-left: 24px;
}

.docs-article li { margin-bottom: 4px; }

.docs-article blockquote {
    border-left: 3px solid var(--primary);
    background: var(--surface-hover);
    padding: 10px 14px;
    color: var(--text-muted);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.docs-article a {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px dashed transparent;
}
.docs-article a:hover {
    border-bottom-color: var(--primary);
}

.docs-article code {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.85em;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
}

.docs-article pre {
    background: #0f1115;
    color: #e6e7ec;
    border-radius: var(--radius);
    padding: 16px 18px;
    overflow-x: auto;
    margin: 0 0 18px;
    font-size: 0.82rem;
    line-height: 1.55;
}

.docs-article pre code {
    background: transparent;
    border: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

.docs-article table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.docs-article th,
.docs-article td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
    vertical-align: top;
}

.docs-article th {
    background: var(--surface-hover);
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--text-muted);
}

.docs-article hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 28px 0;
}

.docs-article ul.task-list,
.docs-article ul[class~="contains-task-list"] {
    list-style: none;
    padding-left: 4px;
}

.docs-footer {
    display: flex;
    justify-content: center;
    margin-top: 24px;
}

@media (max-width: 720px) {
    .container.wide.docs { padding: 18px 14px 32px; }
    .docs-article { padding: 22px 18px; }
    .docs-article h1 { font-size: 1.5rem; }
    .docs-article h2 { font-size: 1.18rem; }
    .docs-article pre { font-size: 0.78rem; }
}

/* ---- Admin panel (/admin) ---- */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 4px 0 18px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
}

.admin-header h1 {
    font-size: 1.6rem;
    margin: 0 0 4px;
}

.admin-subtitle {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin: 0;
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.admin-stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.admin-stat-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.admin-stat-value {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text);
}

.badge-admin {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fcd34d;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.hub-edit-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.hub-admin-btn {
    background: #fef3c7;
    color: #b45309;
    border-color: #fcd34d;
}

.hub-admin-btn:hover {
    background: #fde68a;
    border-color: #f59e0b;
}

/* ===================================================================
   ADMIN SHELL  — scoped under .adm-* and body.adm-body ONLY; nothing
   here touches base.html / .container / .topbar / .dev-table base rules.
   Reuses existing tokens.
   =================================================================== */

/* The admin shell is a standalone document; reset the centered-card body. */
body.adm-body {
    display: block;
    align-items: stretch;
    justify-content: flex-start;
}

.adm-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-rows: auto 1fr;
    min-height: 100vh;
}

/* ---- Sidebar (desktop) ---- */
.adm-sidebar {
    grid-row: 1 / -1;
    grid-column: 1;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 18px 0;
    display: flex;
    flex-direction: column;
}
.adm-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px 16px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
}
.adm-sidebar-brand img { width: 26px; height: 26px; }
.adm-sidebar-brand span { font-weight: 600; font-size: 0.95rem; }
.adm-nav { display: flex; flex-direction: column; gap: 2px; padding: 12px 10px; }
.adm-nav-section {
    font-size: 0.68rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--text-muted);
    padding: 14px 12px 6px;
}
.adm-nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 12px; border-radius: var(--radius);
    color: var(--text-muted); text-decoration: none;
    font-size: 0.9rem; font-weight: 500;
    border: 1px solid transparent;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.adm-nav-item:hover { background: var(--surface-hover); color: var(--text); }
.adm-nav-item.is-active {
    background: var(--primary-soft); color: var(--primary);
    border-color: var(--primary-soft-strong); font-weight: 600;
}
.adm-nav-item svg { width: 19px; height: 19px; flex-shrink: 0; }
.adm-nav-item:focus-visible { outline: 3px solid var(--primary-ring); outline-offset: 2px; }
.adm-sidebar-account {
    margin-top: auto; padding: 14px 14px 4px; border-top: 1px solid var(--border);
}
.adm-account-email {
    font-size: 0.82rem; font-weight: 500; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.adm-account-role { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 8px; }

/* ---- Main column ---- */
.adm-main { grid-column: 2; grid-row: 1 / -1; overflow-y: auto; }
.adm-page { max-width: 1200px; margin: 0 auto; padding: 32px 40px; }
.adm-page-header {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 16px; flex-wrap: wrap; margin-bottom: 28px;
}
.adm-page-title { font-size: 1.6rem; font-weight: 600; color: var(--text); }
.adm-page-sub { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }
.adm-page-actions { display: flex; gap: 8px; align-items: center; }
.adm-muted { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 12px; }
.adm-metric-note { font-size: 0.8rem; line-height: 1.5; margin-top: 12px; margin-bottom: 0; }
.adm-metric-note strong { color: var(--text); font-weight: 600; }

/* ---- KPI cards ---- */
.adm-kpis {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px; margin-bottom: 28px;
}
.adm-kpi {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px 18px;
    display: flex; flex-direction: column; gap: 6px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.adm-kpi:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(194,65,12,0.07); }
.adm-kpi-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; }
.adm-kpi-value { font-size: 1.7rem; font-weight: 700; color: var(--primary); line-height: 1; font-variant-numeric: tabular-nums; }

/* ---- Section + table-scroll (THE overflow fix) ---- */
.adm-section { margin-bottom: 32px; }
.adm-section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.adm-section-head h2 { font-size: 1.05rem; font-weight: 600; margin: 0; }
.adm-table-scroll {
    width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.adm-table-scroll .dev-table { margin: 0; min-width: 640px; }   /* scroll, don't break out */
.adm-table-scroll::-webkit-scrollbar { height: 7px; }
.adm-table-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.adm-table-scroll .dev-table th { padding-left: 12px; padding-right: 12px; }
.adm-table-scroll .dev-table td { padding-left: 12px; padding-right: 12px; }
.dev-table tbody tr { transition: background 0.12s; }
.dev-table tbody tr:hover { background: var(--surface-hover); }
.adm-mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; color: var(--text-muted); white-space: nowrap; }
.adm-cell-wrap { font-size: 0.75rem; word-break: break-all; max-width: 260px; }

/* ---- Sortable headers (aria-sort driven) ---- */
.dev-table th a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 5px; }
.dev-table th a:hover { color: var(--text); text-decoration: underline; }
.dev-table th a:focus-visible { outline: 3px solid var(--primary-ring); outline-offset: 2px; border-radius: 4px; }
.dev-table th[aria-sort="ascending"] a,
.dev-table th[aria-sort="descending"] a { color: var(--primary); }
.adm-sort-caret { display: inline-flex; }
.adm-sort-caret svg { width: 13px; height: 13px; opacity: 0.7; }

/* ---- Search / filter bar ---- */
.adm-filters {
    display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 18px;
}
.adm-filter { display: flex; flex-direction: column; gap: 5px; }
.adm-filter.grow { flex: 1; min-width: 220px; }
.adm-filter label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.adm-filter input, .adm-filter select {
    padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); color: var(--text); font-size: 0.9rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.adm-filter input:focus, .adm-filter select:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring);
}
.adm-filter-actions { display: flex; gap: 8px; }

/* ---- Pagination ---- */
.adm-pagination {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); flex-wrap: wrap;
}
.adm-pagination-info { font-size: 0.85rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.adm-pagination-nav { display: flex; gap: 8px; align-items: center; }
.adm-pagination-page { font-size: 0.85rem; color: var(--text); font-variant-numeric: tabular-nums; }
.adm-pagination .btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }

/* ---- Quick links ---- */
.adm-quicklinks { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- Empty state ---- */
.adm-empty {
    text-align: center; padding: 48px 24px; color: var(--text-muted);
    background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}
.adm-empty svg { width: 42px; height: 42px; opacity: 0.5; margin-bottom: 12px; }
.adm-empty strong { display: block; color: var(--text); font-size: 0.98rem; margin-bottom: 6px; }
.adm-empty p { margin: 0 0 14px; font-size: 0.88rem; }

/* ---- Badge contrast (WCAG AA); applies app-wide, intentional ---- */
.badge-google { color: #1a5fc9; border-color: #c4d7f5; }
.badge-tg { color: #0078d4; border-color: #b3e0f7; }
.badge-admin { color: #7a3600; }

/* ---- Mobile topbar + drawer (hidden on desktop) ---- */
.adm-topbar, .adm-drawer, .adm-backdrop { display: none; }
.adm-topbar {
    grid-column: 1 / -1; grid-row: 1; position: sticky; top: 0; z-index: 40;
    height: 56px; align-items: center; justify-content: space-between; padding: 0 16px;
    background: rgba(255,255,255,0.88); border-bottom: 1px solid var(--border);
    backdrop-filter: saturate(180%) blur(10px); -webkit-backdrop-filter: saturate(180%) blur(10px);
}
.adm-topbar-brand { display: flex; align-items: center; gap: 8px; font-weight: 600; text-decoration: none; color: var(--text); }
.adm-topbar-brand img { width: 24px; height: 24px; }
.adm-iconbtn {
    background: none; border: 1px solid transparent; cursor: pointer; padding: 8px;
    display: inline-flex; color: var(--text); border-radius: var(--radius);
}
.adm-iconbtn:hover { background: var(--surface-hover); }
.adm-iconbtn:focus-visible { outline: 3px solid var(--primary-ring); outline-offset: 2px; }
.adm-iconbtn svg { width: 22px; height: 22px; }

@media (max-width: 1023px) {
    .adm-shell { grid-template-columns: 1fr; grid-template-rows: 56px 1fr; }
    .adm-sidebar { display: none; }
    .adm-topbar { display: flex; }
    .adm-main { grid-column: 1; grid-row: 2; }
    .adm-page { padding: 22px 16px; }
    .adm-drawer {
        display: flex; flex-direction: column; position: fixed; left: 0; top: 0;
        width: 270px; height: 100vh; z-index: 60; background: var(--surface);
        border-right: 1px solid var(--border); padding: 16px 10px;
        transform: translateX(-100%); transition: transform 0.25s ease; overflow-y: auto;
    }
    .adm-drawer.is-open { transform: translateX(0); }
    .adm-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,0.4); }
    .adm-backdrop.is-open { display: block; }
    .adm-page-header { flex-direction: column; align-items: stretch; }
    .adm-page-actions, .adm-page-actions .btn { width: 100%; }
}

/* ---- Card-collapse for data tables on small screens ---- */
@media (max-width: 768px) {
    .adm-filters { flex-direction: column; align-items: stretch; }
    .adm-filter.grow, .adm-filter { min-width: 0; width: 100%; }
    .adm-table-scroll { border: none; overflow-x: visible; }
    .adm-table-scroll .dev-table { min-width: 0; }
    .dev-table thead { display: none; }
    .dev-table tbody { display: flex; flex-direction: column; gap: 12px; }
    .dev-table tbody tr {
        display: grid; gap: 0; border: 1px solid var(--border);
        border-radius: var(--radius); padding: 12px; background: var(--surface);
    }
    .dev-table td {
        display: grid; grid-template-columns: 96px 1fr; gap: 10px;
        padding: 6px 0; border: none; align-items: start;
    }
    .dev-table td::before {
        content: attr(data-label); font-size: 0.72rem; font-weight: 600;
        text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted);
    }
    .adm-cell-wrap { max-width: none; }
    .btn-sm { padding: 11px 18px; }   /* larger touch target */
}

@media (prefers-reduced-motion: reduce) {
    .adm-nav-item, .adm-drawer, .dev-table tbody tr, .adm-kpi,
    .adm-filter input, .adm-filter select { transition: none !important; }
}

/* Make the OAuth-clients KPI card a link to /admin/clients */
.adm-kpi-link { text-decoration: none; color: inherit; cursor: pointer; }

/* ===================================================================
   ADMIN FORM COMPONENT SYSTEM (.adm-form) — client management forms.
   Comfortable >=44px controls, labels, helper text, fieldsets, error
   summary, danger zone. Scoped under .adm-* ; reuses tokens.
   =================================================================== */

/* Form card — capped width, surface chrome, consistent spacing */
.adm-form {
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
    max-width: 680px;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 20px;
}

/* Error summary banner — top of form, alert role */
.adm-form-error {
    padding: 12px 14px;
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius);
    color: var(--danger);
    font-size: 0.9rem;
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.adm-form-error strong { font-weight: 700; flex-shrink: 0; }

/* Field group — label + control + helper */
.adm-form-field { display: flex; flex-direction: column; gap: 6px; }

.adm-form-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: baseline;
    gap: 4px;
}
.adm-form-label-required::after {
    content: "*";
    color: var(--danger);
    font-weight: 700;
    font-size: 1.05rem;
    margin-left: 2px;
}

.adm-form-help { font-size: 0.82rem; color: var(--text-muted); line-height: 1.45; margin: 0 0 2px; }
.adm-form-help code {
    background: var(--bg); padding: 2px 5px; border-radius: 3px;
    font-family: monospace; font-size: 0.75rem; color: var(--primary);
}

/* Inputs / textarea / select — consistent, >=44px */
.adm-form-input,
.adm-form-textarea,
.adm-form-select {
    width: 100%;
    min-height: 44px;
    padding: 11px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.adm-form-input::placeholder,
.adm-form-textarea::placeholder { color: var(--text-muted); }
.adm-form-input:focus,
.adm-form-textarea:focus,
.adm-form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}
.adm-form-input:disabled,
.adm-form-textarea:disabled,
.adm-form-select:disabled {
    background: var(--bg); color: var(--text-muted); cursor: not-allowed;
}

.adm-form-textarea {
    resize: vertical;
    min-height: 84px;
    line-height: 1.5;
}

/* Monospace variant for technical fields (client_id, URIs, backchannel) */
.adm-form-input-mono,
.adm-form-textarea-mono {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.84rem;
    letter-spacing: 0.01em;
}

/* Select — custom chevron, hide native */
.adm-form-select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 38px;
    cursor: pointer;
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
.adm-form-select::-ms-expand { display: none; }

/* Fieldset (scopes) */
.adm-form-fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.adm-form-fieldset-legend { font-size: 0.9rem; font-weight: 600; color: var(--text); padding: 0; }
.adm-form-fieldset-legend strong { font-weight: 600; }
.adm-form-fieldset-help { font-size: 0.8rem; color: var(--text-muted); margin: 0; line-height: 1.45; }

/* Checkbox grid */
.adm-form-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 4px 10px;
    margin-top: 4px;
}
.adm-form-checkbox-group { display: flex; align-items: center; gap: 9px; min-height: 40px; }
.adm-form-checkbox-group input[type="checkbox"] {
    width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); flex-shrink: 0;
}
.adm-form-checkbox-group input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--primary); outline-offset: 2px;
}
.adm-form-checkbox-group label { cursor: pointer; user-select: none; font-size: 0.9rem; }
.adm-form-checkbox-group label code {
    background: var(--bg); padding: 2px 6px; border-radius: 3px;
    font-family: monospace; font-size: 0.78rem; color: var(--primary);
}

/* Actions */
.adm-form-actions { display: flex; gap: 10px; align-items: center; margin-top: 4px; }

/* Secondary card (secret rotate) */
.adm-form-secondary {
    max-width: 680px;
    margin-bottom: 20px;
    padding: 22px 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.adm-form-secondary h3 { font-size: 1rem; font-weight: 600; color: var(--text); margin: 0; }
.adm-form-secondary p { font-size: 0.85rem; color: var(--text-muted); line-height: 1.55; margin: 0; }

/* Danger card (delete) */
.adm-form-danger {
    max-width: 680px;
    margin-bottom: 20px;
    padding: 22px 24px;
    border: 1px solid var(--danger);
    border-radius: var(--radius-lg);
    background: rgba(239, 68, 68, 0.03);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.adm-form-danger h3 { font-size: 1rem; font-weight: 600; color: var(--danger); margin: 0; }
.adm-form-danger p { font-size: 0.85rem; color: var(--text-muted); line-height: 1.55; margin: 0; }
.adm-form-danger .adm-form-input { max-width: 360px; }
.adm-form-danger-actions { display: flex; gap: 10px; align-items: center; }
.adm-form-danger-actions .btn { background: var(--danger); color: #fff; border-color: var(--danger); }
.adm-form-danger-actions .btn:hover { background: var(--danger-hover); border-color: var(--danger-hover); }

@media (max-width: 640px) {
    .adm-form, .adm-form-secondary, .adm-form-danger { padding: 20px 16px; }
    .adm-form-checkbox-grid { grid-template-columns: 1fr; }
    .adm-form-actions { flex-direction: column; align-items: stretch; }
    .adm-form-actions .btn { width: 100%; }
    /* 16px prevents iOS Safari from auto-zooming on focus */
    .adm-form-input, .adm-form-textarea, .adm-form-select { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .adm-form-input, .adm-form-textarea, .adm-form-select { transition: none; }
}
