:root {
    --bg: #f6f7fb;
    --surface: rgba(255, 255, 255, 0.92);
    --surface-strong: #ffffff;
    --surface-soft: #f8fafc;
    --border: #d9e1ec;
    --border-strong: #c8d4e3;
    --text: #132238;
    --muted: #5b6b80;
    --accent: #157fcb;
    --accent-soft: #e6f4ff;
    --success: #13795b;
    --success-soft: #e7f7f1;
    --warning: #9a6700;
    --warning-soft: #fff5d8;
    --danger: #c2410c;
    --danger-soft: #fff1eb;
    --shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

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

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: "Space Grotesk", system-ui, sans-serif;
    line-height: 1.5;
}

a {
    color: inherit;
}

button,
input {
    font: inherit;
}

.app-body {
    position: relative;
}

.app-background {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at top left, rgba(21, 127, 203, 0.12), transparent 28%),
        radial-gradient(circle at bottom right, rgba(244, 114, 32, 0.08), transparent 26%);
}

.app-shell {
    position: relative;
    max-width: 1160px;
    min-height: 100vh;
    margin: 0 auto;
    padding: 24px 18px 36px;
}

.center-shell {
    min-height: calc(100vh - 60px);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.dashboard-grid,
.admin-grid {
    display: grid;
    gap: 24px;
}

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.page-header,
.section-card,
.auth-card {
    padding: 28px;
}

.auth-card {
    width: 100%;
    max-width: 460px;
}

.eyebrow {
    margin: 0;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.page-title,
.section-title,
.subsection-title {
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.page-title {
    margin-top: 12px;
    font-size: clamp(2rem, 4vw, 2.75rem);
}

.section-title {
    margin-top: 10px;
    font-size: 1.7rem;
}

.subsection-title {
    font-size: 1.1rem;
}

.intro-text,
.helper-text,
.muted-text,
.meta-text,
.history-host,
.history-url {
    color: var(--muted);
}

.intro-text {
    margin: 12px 0 0;
    font-size: 0.98rem;
}

.intro-text-wide {
    max-width: 760px;
}

.helper-text {
    margin: 24px 0 0;
    font-size: 0.95rem;
}

.text-link {
    color: var(--accent);
    font-weight: 600;
}

.header-actions,
.section-head,
.history-main,
.latest-code-block,
.rep-top,
.rep-actions {
    display: flex;
    gap: 16px;
}

.header-actions,
.section-head,
.rep-actions {
    align-items: center;
    justify-content: space-between;
}

.header-actions {
    flex-wrap: wrap;
}

.signed-in-box {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(248, 250, 252, 0.85);
    color: var(--muted);
    font-size: 0.95rem;
}

.pill {
    padding: 8px 14px;
    border: 1px solid #cce8fb;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    white-space: nowrap;
}

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-top: 28px;
}

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

.field-label {
    color: #304154;
    font-size: 0.94rem;
    font-weight: 600;
}

.text-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(248, 250, 252, 0.9);
    color: var(--text);
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.text-input:focus {
    outline: none;
    border-color: #8cc8f1;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(21, 127, 203, 0.12);
}

.text-input-code {
    text-align: center;
    font-family: "IBM Plex Mono", monospace;
    font-size: 2.25rem;
    letter-spacing: 0.45em;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 700;
    text-decoration: none;
    transition: transform 0.12s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

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

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

.button-primary:hover {
    background: #0f6cad;
}

.button-secondary {
    border-color: var(--border);
    background: #fff;
    color: var(--text);
}

.button-secondary:hover {
    background: #f8fafc;
}

.button-danger {
    border-color: #f7c9b4;
    background: var(--danger-soft);
    color: var(--danger);
}

.button-danger:hover {
    background: #ffe5d8;
}

.button-block {
    width: 100%;
}

.form-error {
    margin: 0;
    color: #d9485f;
    font-size: 0.88rem;
}

.notice {
    margin-top: 20px;
    padding: 16px 18px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-size: 0.95rem;
}

.notice-info {
    border-color: #cce8fb;
    background: rgba(230, 244, 255, 0.85);
}

.notice-success {
    border-color: #cfeadd;
    background: var(--success-soft);
    color: var(--success);
}

.notice-warning {
    border-color: #f1df9f;
    background: var(--warning-soft);
    color: var(--warning);
}

.integration-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-top: 22px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: rgba(248, 250, 252, 0.9);
}

.integration-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.integration-copy {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.93rem;
}

.integration-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: flex-end;
}

.latest-code-block {
    margin-top: 16px;
    align-items: flex-end;
    justify-content: space-between;
}

.code-display,
.history-code {
    margin: 0;
    font-family: "IBM Plex Mono", monospace;
    font-weight: 700;
    letter-spacing: 0.28em;
}

.code-display {
    font-size: clamp(2.5rem, 5vw, 3.6rem);
}

.notice-copy {
    max-width: 340px;
    margin: 0;
    color: #304154;
    font-size: 0.95rem;
}

.latest-code-side {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
}

.empty-state {
    margin-top: 28px;
    padding: 28px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
    background: rgba(248, 250, 252, 0.9);
    color: var(--muted);
    text-align: center;
}

.history-list,
.rep-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 28px;
}

.history-card,
.rep-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: rgba(248, 250, 252, 0.9);
}

.history-card {
    padding: 20px;
}

.rep-card {
    padding: 22px;
}

.history-main {
    align-items: flex-start;
    justify-content: space-between;
}

.history-code-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.history-code {
    font-size: 2rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.status-badge-active {
    background: var(--accent-soft);
    color: var(--accent);
}

.status-badge-muted {
    background: #e7edf4;
    color: #607286;
}

.history-host {
    margin: 14px 0 0;
    font-size: 0.94rem;
}

.history-url {
    margin: 4px 0 0;
    font-size: 0.9rem;
    word-break: break-word;
}

.history-meta {
    display: grid;
    gap: 10px;
    min-width: 220px;
    color: var(--muted);
    font-size: 0.92rem;
    text-align: right;
    justify-items: end;
}

.history-join-button {
    margin-top: 4px;
}

.rep-top {
    align-items: flex-start;
    justify-content: space-between;
}

.rep-name {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 700;
}

.rep-email {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.95rem;
    word-break: break-word;
}

.rep-stats {
    display: grid;
    gap: 14px;
    min-width: 360px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.rep-stat-box {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-strong);
}

.rep-stat-label {
    margin: 0;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.rep-stat-value {
    margin: 10px 0 0;
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 700;
}

.rep-actions {
    margin-top: 18px;
    justify-content: flex-end;
}

@media (min-width: 960px) {
    .dashboard-grid {
        grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
    }

    .admin-grid {
        grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    }
}

@media (max-width: 959px) {
    .page-header,
    .section-card,
    .auth-card {
        padding: 22px;
    }

    .section-head,
    .header-actions,
    .history-main,
    .latest-code-block,
    .rep-top,
    .integration-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .history-meta {
        min-width: 0;
        text-align: left;
        justify-items: start;
    }

    .rep-stats {
        width: 100%;
        min-width: 0;
        grid-template-columns: 1fr;
    }

    .integration-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 640px) {
    .app-shell {
        padding: 16px 12px 28px;
    }

    .text-input-code {
        font-size: 1.8rem;
        letter-spacing: 0.28em;
    }
}
