:root {
    color-scheme: light;
    --bg: #eef2f6;
    --bg-soft: #f7f9fb;
    --surface: #ffffff;
    --surface-subtle: #f8fafc;
    --surface-tint: #f3f6fb;
    --line: #d9e1ea;
    --line-strong: #c8d2de;
    --text: #0f172a;
    --text-muted: #475569;
    --text-soft: #64748b;
    --brand: #1d4ed8;
    --brand-dark: #1e3a8a;
    --brand-soft: #dbeafe;
    --success: #0f766e;
    --success-soft: #ccfbf1;
    --warning: #b45309;
    --warning-soft: #ffedd5;
    --danger: #b91c1c;
    --danger-soft: #fee2e2;
    --trial: #5b21b6;
    --trial-soft: #ede9fe;
    --shadow-lg: 0 18px 40px rgba(15, 23, 42, 0.08);
    --shadow-sm: 0 8px 20px rgba(15, 23, 42, 0.05);
    --radius-xl: 20px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 10px;
}

* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(180deg, #f8fafc 0%, var(--bg) 100%);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.portal-page,
body.admin-page {
    padding: 20px 0 28px;
}

a {
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

code {
    font-family: "SFMono-Regular", SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
}

.hidden {
    display: none !important;
}

.page-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
}

.page-shell--portal,
.page-shell--admin {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.masthead,
.hero-card,
.section-card,
.stat-card,
.user-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.masthead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 22px;
}

.brand-suite {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.brand-suite__group {
    height: 42px;
    width: auto;
    object-fit: contain;
}

.brand-suite__divider {
    width: 1px;
    align-self: stretch;
    background: var(--line-strong);
}

.brand-suite__product {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

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

.brand-suite__product-logo {
    width: 46px;
    height: 46px;
    object-fit: contain;
    border-radius: 12px;
    background: var(--surface-tint);
    border: 1px solid var(--line);
    padding: 6px;
}

.brand-suite__product-logo--compact {
    width: 40px;
    height: 40px;
}

.brand-suite__title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
}

.brand-suite__subtitle {
    margin-top: 3px;
    color: var(--text-soft);
    font-size: 0.84rem;
}

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

.identity-pill {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface-tint);
    color: var(--text-muted);
    font-size: 0.86rem;
    font-weight: 600;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.portal-main,
.admin-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.auth-main {
    display: flex;
    justify-content: center;
}

.hero-card,
.section-card {
    padding: 26px;
}

.hero-card {
    background: linear-gradient(180deg, #fdfefe 0%, #f4f7fb 100%);
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--brand-soft);
    border: 1px solid #bfdbfe;
    color: var(--brand-dark);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.eyebrow::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.hero-title,
.section-title {
    margin: 0;
    line-height: 1.06;
    letter-spacing: -0.04em;
}

.hero-title {
    margin-top: 16px;
    max-width: 16ch;
    font-size: clamp(2.2rem, 4vw, 3.5rem);
}

.section-title {
    font-size: clamp(1.6rem, 3vw, 2.3rem);
}

.section-title--small {
    font-size: 1.4rem;
}

.hero-text,
.section-text,
.detail-copy,
.field-hint,
.field-note,
.link-row,
.user-card__meta,
.user-card__section-text,
.user-empty {
    color: var(--text-muted);
    line-height: 1.66;
}

.hero-text {
    max-width: 70ch;
    margin: 16px 0 0;
    font-size: 1rem;
}

.hero-actions {
    display: flex;
    gap: 12px;
    margin-top: 22px;
    flex-wrap: wrap;
}

.section-text {
    margin: 10px 0 0;
}

.summary-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 24px;
}

.summary-item {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.summary-label,
.detail-label,
.status-label,
.stat-label,
.user-card__section-label,
.field-label {
    display: block;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-soft);
}

.summary-value,
.status-title,
.stat-value {
    display: block;
    margin-top: 10px;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.section-header,
.status-meta {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 22px;
}

.feature-card {
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface-subtle);
    box-shadow: var(--shadow-sm);
}

.feature-card--accent {
    background: var(--brand-soft);
    border-color: #bfdbfe;
}

.feature-card__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.35;
}

.feature-card__text {
    margin: 10px 0 0;
    color: var(--text-muted);
    line-height: 1.62;
}

.account-shell {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.auth-card {
    width: min(640px, 100%);
}

.account-shell__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.auth-page .account-shell__header {
    margin-bottom: 10px;
}

.auth-page .section-card,
.admin-page .section-card {
    padding: 22px;
}

.auth-page .section-title {
    font-size: clamp(1.55rem, 2.8vw, 2.1rem);
    line-height: 1.12;
    letter-spacing: -0.03em;
}

.admin-page .section-title {
    font-size: clamp(1.35rem, 2.2vw, 1.85rem);
    line-height: 1.14;
    letter-spacing: -0.02em;
}

.auth-page .section-text,
.admin-page .section-text {
    margin-top: 4px;
    line-height: 1.5;
    max-width: 64ch;
}

.auth-page .account-shell {
    gap: 14px;
}

.auth-page .dashboard-grid {
    gap: 12px;
}

.auth-page .status-card,
.auth-page .detail-card {
    padding: 16px;
}

.admin-page .admin-login-card {
    width: min(640px, 100%);
    margin: 0 auto;
}

.auth-page .status-text,
.auth-page .detail-copy,
.auth-page .field-hint,
.auth-page .link-row,
.admin-page .section-text,
.admin-page .user-card__meta,
.admin-page .user-card__section-text {
    line-height: 1.5;
}

.auth-page .status-text,
.auth-page .detail-copy {
    margin-top: 10px;
}

.auth-page .stack {
    gap: 12px;
    margin-top: 2px;
}

.auth-page .field {
    gap: 6px;
}

.auth-page .field + .field {
    margin-top: 2px;
}

.auth-page .field-hint {
    margin: 2px 0 0;
}

.auth-page .link-row {
    margin-top: 6px;
}

.subdomain-card .segment {
    margin-top: 8px;
}

.subdomain-card .button {
    margin-top: 10px;
}

.auth-page .token-value {
    padding: 12px;
}

.auth-page .detail-label,
.auth-page .status-label,
.auth-page .field-label,
.admin-page .stat-label,
.admin-page .user-card__section-label,
.admin-page .field-label {
    letter-spacing: 0.06em;
}

.admin-page .admin-main {
    gap: 16px;
}

.admin-page .stats-grid {
    gap: 12px;
}

.admin-page .stat-card {
    padding: 16px;
}

.admin-page .stat-value {
    margin-top: 6px;
    font-size: 1.55rem;
}

.admin-page .user-list {
    gap: 12px;
}

.admin-page .user-card {
    padding: 16px;
}

.admin-page .user-card__sections {
    margin-bottom: 12px;
    gap: 12px;
}

.admin-page .action-row {
    gap: 8px;
}

.alert {
    display: none;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-size: 0.94rem;
    line-height: 1.5;
}

.alert.is-visible {
    display: block;
}

.alert.is-error {
    background: var(--danger-soft);
    border-color: #fca5a5;
    color: #991b1b;
}

.alert.is-success {
    background: var(--success-soft);
    border-color: #99f6e4;
    color: #115e59;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input,
.segment-input {
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--line-strong);
    background: var(--surface-subtle);
    color: var(--text);
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.input:focus,
.segment-input:focus {
    outline: none;
    border-color: #93c5fd;
    background: var(--surface);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.segment {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
}

.segment-input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.segment-suffix {
    display: inline-flex;
    align-items: center;
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    border-left: 0;
    border-top-right-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
    background: var(--surface-tint);
    color: var(--text-soft);
    white-space: nowrap;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 16px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-size: 0.92rem;
    font-weight: 700;
    white-space: nowrap;
    transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease, opacity 0.16s ease;
}

.button:hover:not(:disabled) {
    transform: translateY(-1px);
}

.button:disabled {
    opacity: 0.72;
    cursor: not-allowed;
}

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

.button-primary:hover:not(:disabled) {
    background: #1e40af;
}

.button-secondary {
    background: var(--surface);
    border-color: var(--line-strong);
    color: var(--text);
}

.button-secondary:hover:not(:disabled) {
    background: var(--bg-soft);
}

.button-warning {
    background: var(--warning);
    color: #fff;
}

.button-warning:hover:not(:disabled) {
    background: #92400e;
}

.button-small {
    min-height: 38px;
    padding: 0 12px;
    font-size: 0.82rem;
}

.button-full {
    width: 100%;
}

.link-row {
    margin: 0;
    text-align: center;
    font-size: 0.92rem;
}

.link-inline {
    color: var(--brand-dark);
    font-weight: 700;
    text-decoration: none;
}

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

.dashboard-grid,
.detail-grid,
.stats-grid,
.user-card__sections {
    display: grid;
    gap: 16px;
}

.detail-grid,
.stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.detail-grid {
    grid-template-columns: 1fr;
}

.dashboard-grid {
    grid-template-columns: 1fr;
}

.status-card,
.detail-card,
.stat-card,
.admin-login-card,
.admin-intro-card,
.user-section,
.user-card {
    background: var(--surface-subtle);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.status-card,
.detail-card,
.stat-card,
.admin-login-card,
.admin-intro-card,
.user-section {
    padding: 20px;
}

.status-card--pending {
    background: #fff8ee;
    border-color: #f5d0a7;
}

.status-card--active {
    background: #f1fbfa;
    border-color: #99f6e4;
}

.status-card--attention {
    background: #fff3f2;
    border-color: #fecaca;
}

.status-title {
    margin-top: 6px;
}

.status-text {
    margin: 14px 0 0;
    color: var(--text-muted);
    line-height: 1.62;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--line);
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    white-space: nowrap;
}

.status-badge::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.status-badge--pending {
    color: var(--warning);
}

.status-badge--trial {
    color: var(--trial);
}

.status-badge--active {
    color: var(--success);
}

.status-badge--attention {
    color: var(--danger);
}

.status-reveal {
    border: 0;
    background: transparent;
    padding: 0;
}

.status-reveal .status-badge {
    cursor: pointer;
}

.token-value {
    display: block;
    width: 100%;
    padding: 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    background: var(--surface);
    word-break: break-all;
}

.domain-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
    word-break: break-word;
}

.domain-link--live {
    color: var(--brand-dark);
}

.domain-link--live::after {
    content: "Open";
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-soft);
}

.domain-link--disabled {
    color: var(--text-soft);
    pointer-events: none;
}

.domain-link--disabled::after {
    content: "Pending";
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.admin-dashboard {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-value {
    font-size: 1.8rem;
}

.user-section {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.user-list {
    display: grid;
    gap: 14px;
}

.user-card {
    padding: 18px;
}

.user-card__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.user-card__identity {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.user-card__name {
    font-size: 1rem;
    font-weight: 700;
    word-break: break-word;
}

.user-card__meta,
.user-card__section-text,
.detail-copy,
.field-hint,
.field-note,
.user-empty {
    font-size: 0.88rem;
}

.user-card__sections {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 16px;
}

.user-card__section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.user-empty {
    padding: 18px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-lg);
    background: var(--surface-subtle);
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
}

.modal__panel {
    position: relative;
    z-index: 1;
    width: min(560px, 100%);
    padding: 24px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.18);
}

.modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

@media (max-width: 1100px) {
    .summary-strip,
    .stats-grid,
    .user-card__sections,
    .feature-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 820px) {
    .summary-strip,
    .stats-grid,
    .user-card__sections,
    .feature-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    body.portal-page,
    body.admin-page {
        padding: 10px 0 18px;
    }

    .page-shell {
        width: min(100%, calc(100% - 18px));
    }

    .masthead,
    .hero-card,
    .section-card,
    .stat-card,
    .user-card,
    .status-card,
    .detail-card,
    .admin-login-card,
    .admin-intro-card,
    .user-section {
        padding: 18px;
    }

    .masthead,
    .brand-suite,
    .masthead-actions,
    .section-header,
    .status-meta,
    .user-card__top,
    .modal__header {
        flex-direction: column;
        align-items: flex-start;
    }

    .brand-suite {
        gap: 10px;
    }

    .brand-suite__divider {
        display: none;
    }

    .hero-title,
    .section-title {
        max-width: none;
    }

    .button,
    .button-small {
        width: 100%;
    }

    .hero-actions {
        flex-direction: column;
    }

    .action-row {
        flex-direction: column;
    }
}
