:root {
    --base-bg: radial-gradient(circle at top, rgba(98, 184, 150, 0.12), transparent 36%), linear-gradient(180deg, #0b1220 0%, #101a2b 48%, #0d1626 100%);
    --surface: rgba(14, 23, 38, 0.84);
    --surface-strong: rgba(10, 18, 32, 0.94);
    --surface-border: rgba(148, 163, 184, 0.14);
    --text-main: #edf3ff;
    --text-muted: #9aaccc;
    --accent: #79c6a4;
    --accent-strong: #4fa07f;
    --danger: #f28c8c;
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
    background: var(--base-bg);
    color: var(--text-main);
}

body.setup-page {
    background: linear-gradient(180deg, #f8fbff 0%, #f3f7fb 42%, #eef3f7 100%);
    color: #183247;
}

body.dashboard-page {
    background: linear-gradient(180deg, #f8fbff 0%, #f3f7fb 42%, #eef3f7 100%);
    color: #183247;
}

body.auth-page {
    background: linear-gradient(180deg, #f8fbff 0%, #f3f7fb 42%, #eef3f7 100%);
    color: #183247;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

main {
    max-width: 1180px;
    margin: 0 auto;
    padding: 40px 24px 56px;
}

h1,
h2,
h3 {
    margin: 0;
    line-height: 1.05;
}

p {
    line-height: 1.6;
}

ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

label {
    display: block;
}

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

input,
select,
textarea {
    width: 100%;
    padding: 13px 14px;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(8, 15, 28, 0.82);
    color: var(--text-main);
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(121, 198, 164, 0.4);
    border-color: rgba(121, 198, 164, 0.55);
}

button {
    border: 0;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(16px); }
    to   { opacity: 1; transform: none; }
}

@keyframes toast-out {
    from { opacity: 1; transform: none; }
    to   { opacity: 0; transform: translateX(16px); }
}

.flash-stack {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    display: grid;
    gap: 10px;
    width: max-content;
    max-width: min(360px, calc(100vw - 32px));
    list-style: none;
    margin: 0;
    padding: 0;
}

.flash-message {
    position: relative;
    padding: 14px 40px 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(121, 198, 164, 0.24);
    background: rgba(12, 23, 34, 0.94);
    box-shadow: var(--shadow);
    animation: toast-in 0.2s ease;
    font-size: 0.94rem;
    line-height: 1.4;
}

.flash-message--dismissing {
    animation: toast-out 0.2s ease forwards;
}

.flash-message--error {
    border-color: rgba(242, 140, 140, 0.45);
    background: rgba(60, 10, 10, 0.94);
}

.flash-message--success {
    border-color: rgba(121, 198, 164, 0.45);
    background: rgba(8, 30, 22, 0.94);
}

.flash-message--warning {
    border-color: rgba(234, 179, 8, 0.4);
    background: rgba(40, 28, 0, 0.94);
}

body.setup-page .flash-message,
body.auth-page .flash-message,
body.dashboard-page .flash-message {
    background: rgba(255, 255, 255, 0.97);
    color: #183247;
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.1);
}

body.setup-page .flash-message--error,
body.auth-page .flash-message--error,
body.dashboard-page .flash-message--error {
    border-color: rgba(198, 82, 82, 0.4);
    background: rgba(255, 245, 245, 0.98);
    color: #7a1c1c;
}

body.setup-page .flash-message--success,
body.auth-page .flash-message--success,
body.dashboard-page .flash-message--success {
    border-color: rgba(61, 146, 115, 0.4);
    background: rgba(240, 250, 245, 0.98);
    color: #1a4d38;
}

body.setup-page .flash-message--warning,
body.auth-page .flash-message--warning,
body.dashboard-page .flash-message--warning {
    border-color: rgba(180, 120, 0, 0.35);
    background: rgba(255, 250, 235, 0.98);
    color: #7a4f00;
}

.toast-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    opacity: 0.5;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-close:hover {
    opacity: 1;
}

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

.lead,
.section-copy {
    color: var(--text-muted);
}

.auth-shell {
    display: grid;
    min-height: calc(100vh - 96px);
    align-items: center;
}

.auth-shell .hero-card,
.auth-shell .form-card,
.auth-shell .callout-item {
    background: rgba(255, 255, 255, 0.96);
    border-color: rgba(148, 163, 184, 0.24);
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.08);
}

.auth-shell .hero-copy,
.auth-shell .form-card,
.auth-shell h1,
.auth-shell h2,
.auth-shell h3 {
    color: #183247;
}

.auth-shell .lead,
.auth-shell .section-copy,
.auth-shell .stack-form label,
.auth-shell .callout-item {
    color: #64748b;
}

.auth-shell input,
.auth-shell select,
.auth-shell textarea {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(148, 163, 184, 0.32);
    color: #183247;
}

.auth-shell input::placeholder,
.auth-shell textarea::placeholder {
    color: #94a3b8;
}

.auth-shell .secondary-button {
    background: rgba(255, 255, 255, 0.88);
    color: #183247;
    border: 1px solid rgba(148, 163, 184, 0.24);
}

.auth-shell .primary-button {
    color: #ffffff;
}

.auth-shell .oauth-button {
    border-color: rgba(148, 163, 184, 0.24);
    color: #183247;
}

.auth-shell .oauth-button-google {
    background: linear-gradient(135deg, rgba(66, 133, 244, 0.12), rgba(234, 67, 53, 0.08)), rgba(255, 255, 255, 0.96);
}

.auth-shell .oauth-mark {
    background: rgba(24, 50, 71, 0.08);
}

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

.hero-card {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, 440px);
    gap: 24px;
    padding: 28px;
    border-radius: 32px;
}

.hero-card-compact {
    grid-template-columns: minmax(0, 640px);
    justify-content: center;
}

.hero-copy {
    padding: 12px;
}

.hero-copy h1 {
    font-size: clamp(2.4rem, 4vw, 4rem);
    margin-bottom: 16px;
}

.callout-list {
    display: grid;
    gap: 12px;
    margin-top: 28px;
}

.callout-item,
.empty-card {
    padding: 16px 18px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(148, 163, 184, 0.12);
}

.form-card,
.surface-card {
    padding: 24px;
    border-radius: 28px;
}

.form-card {
    background: var(--surface-strong);
}

.form-card-wide {
    max-width: 680px;
    width: 100%;
    margin: 0 auto;
}

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

.stack-form p {
    margin: 0;
}

.stack-form label {
    margin-bottom: 6px;
    color: var(--text-muted);
}

.stack-form ul {
    padding-left: 18px;
    list-style: disc;
    color: var(--danger);
}

.primary-button,
.secondary-button,
.danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 12px 18px;
    border-radius: 14px;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.oauth-stack {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.oauth-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 50px;
    width: 100%;
    padding: 12px 18px;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    font-weight: 700;
}

.oauth-button:hover {
    text-decoration: none;
    transform: translateY(-1px);
}

.oauth-button-google {
    background: linear-gradient(135deg, rgba(66, 133, 244, 0.2), rgba(234, 67, 53, 0.14));
}

.oauth-button-microsoft {
    background: linear-gradient(135deg, rgba(0, 120, 212, 0.22), rgba(16, 110, 190, 0.14));
}

.oauth-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    font-size: 0.92rem;
    font-weight: 800;
}

.section-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0 4px;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.section-divider::before,
.section-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: rgba(148, 163, 184, 0.16);
}

.primary-button:hover,
.secondary-button:hover,
.danger-button:hover {
    transform: translateY(-1px);
}

.primary-button {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
    color: #072119;
    font-weight: 700;
}

.secondary-button {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid rgba(148, 163, 184, 0.16);
}

.danger-button {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.danger-button:hover {
    background: rgba(var(--danger-rgb, 242, 140, 140), 0.08);
}

.setup-shell {
    display: grid;
    gap: 22px;
}

.setup-shell .surface-card,
.setup-shell .provider-card,
.setup-shell .connector-card,
.setup-shell .empty-card {
    background: rgba(255, 255, 255, 0.96);
    border-color: rgba(148, 163, 184, 0.24);
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.08);
}

.setup-shell h1,
.setup-shell h2,
.setup-shell h3 {
    color: #183247;
}

.setup-shell .lead,
.setup-shell .provider-card p,
.setup-shell .connector-card p,
.setup-shell .empty-card p {
    color: #64748b;
}

.setup-shell .provider-icon {
    background: rgba(61, 146, 115, 0.12);
    color: #2e785d;
}

.setup-shell .secondary-button {
    background: rgba(255, 255, 255, 0.88);
    color: #183247;
    border: 1px solid rgba(148, 163, 184, 0.24);
}

.setup-shell .type-badge {
    background: rgba(61, 146, 115, 0.1);
    color: #2e785d;
}

.setup-shell .status-chip {
    background: rgba(241, 245, 249, 0.9);
}

.setup-shell .status-chip.ready {
    color: #3d9273;
}

.setup-shell .status-chip.failed {
    color: #c65252;
}

.setup-shell .oauth-button {
    border-color: rgba(148, 163, 184, 0.24);
    color: #183247;
}

.setup-shell .oauth-button-google {
    background: linear-gradient(135deg, rgba(66, 133, 244, 0.12), rgba(234, 67, 53, 0.08)), rgba(255, 255, 255, 0.96);
}

.setup-shell .oauth-button-microsoft {
    background: linear-gradient(135deg, rgba(0, 120, 212, 0.14), rgba(16, 110, 190, 0.08)), rgba(255, 255, 255, 0.96);
}

.setup-shell .oauth-mark {
    background: rgba(24, 50, 71, 0.08);
}

.setup-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.setup-header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.setup-header h1 {
    font-size: clamp(2rem, 3vw, 3.1rem);
    margin-bottom: 10px;
}

.setup-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
    gap: 20px;
}

.provider-grid,
.connector-list {
    display: grid;
    gap: 14px;
}

.provider-card,
.connector-card {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    padding: 18px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(148, 163, 184, 0.12);
}

.provider-card {
    align-items: center;
}

.provider-card .oauth-button {
    width: auto;
    min-width: 220px;
}

.provider-card h3,
.connector-card h3 {
    margin-bottom: 6px;
}

.provider-card p,
.connector-card p {
    margin: 0;
    color: var(--text-muted);
}

.provider-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: rgba(121, 198, 164, 0.14);
    color: var(--accent);
    font-size: 1.3rem;
    font-weight: 700;
    flex: 0 0 auto;
}

.connector-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.type-badge,
.status-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.84rem;
}

.type-badge {
    background: rgba(121, 198, 164, 0.14);
    color: var(--accent);
}

.status-chip {
    background: rgba(255, 255, 255, 0.06);
}

.status-chip.ready {
    color: var(--accent);
}

.status-chip.failed {
    color: var(--danger);
}

@media (max-width: 980px) {
    .hero-card,
    .setup-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    main {
        padding: 24px 16px 40px;
    }

.setup-header,
    .provider-card,
    .connector-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .setup-header-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }
}
