:root {
    --sga-bg: #f7f8fb;
    --sga-bg-soft: #eef3ff;
    --sga-card: #ffffff;
    --sga-text: #101828;
    --sga-muted: #5d6679;
    --sga-border: #dfe5f2;
    --sga-primary: #5f74ff;
    --sga-primary-dark: #4b5ee8;
    --sga-sidebar: #101828;
    --sga-success: #edfdf3;
    --sga-success-text: #1b6b3a;
    --sga-error: #fff1f2;
    --sga-error-text: #991b1b;
    --sga-info: #eef1ff;
    --sga-info-text: #3141b8;
    --sga-radius-lg: 24px;
    --sga-radius-md: 16px;
    --sga-shadow: 0 24px 70px rgba(17, 24, 39, 0.08);
}

* {
    box-sizing: border-box;
}

body.sga-body {
    margin: 0;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 270px minmax(0, 1fr);
    background: var(--sga-bg);
    color: var(--sga-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    line-height: 1.6;
}

.sga-body a {
    color: inherit;
    text-decoration: none;
}

.sga-sidebar {
    position: sticky;
    top: 0;
    min-height: 100vh;
    padding: 28px;
    background: var(--sga-sidebar);
    color: #ffffff;
}

.sga-logo {
    display: inline-flex;
    align-items: center;
    font-size: 1.18rem;
    font-weight: 900;
    letter-spacing: -0.04em;
}

.sga-nav {
    display: grid;
    gap: 8px;
    margin-top: 34px;
}

.sga-nav a {
    padding: 12px 14px;
    border-radius: 14px;
    color: rgba(255, 255, 255, 0.72);
    font-weight: 750;
}

.sga-nav a:hover,
.sga-nav a.is-active {
    background: rgba(255, 255, 255, 0.10);
    color: #ffffff;
}

.sga-lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 28px;
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.68);
    font-size: 0.82rem;
    font-weight: 900;
    letter-spacing: 0.04em;
}

.sga-lang-switch a {
    color: rgba(255, 255, 255, 0.68);
}

.sga-lang-switch a.is-active {
    color: #ffffff;
}

.sga-lang-switch span {
    color: rgba(255, 255, 255, 0.28);
}

.sga-main {
    padding: 34px;
}

.sga-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 28px;
}

.sga-kicker {
    margin: 0 0 8px;
    color: var(--sga-muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.75rem;
    font-weight: 900;
}

.sga-header h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1;
    letter-spacing: -0.06em;
}

.sga-user-pill {
    display: grid;
    justify-items: end;
    gap: 3px;
    min-width: 180px;
    padding: 12px 18px;
    border: 1px solid var(--sga-border);
    border-radius: 999px;
    background: #ffffff;
    font-weight: 900;
}

.sga-user-pill span {
    color: var(--sga-muted);
    font-size: 0.8rem;
    font-weight: 800;
}

.sga-logout-link {
    margin-top: 4px;
    color: var(--sga-primary);
    font-size: 0.78rem;
    font-weight: 900;
}

.sga-section {
    display: grid;
    gap: 24px;
}

.sga-grid {
    display: grid;
    gap: 22px;
}

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

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

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

.sga-panel,
.sga-card-form,
.sga-stat,
.sga-empty {
    background: var(--sga-card);
    border: 1px solid var(--sga-border);
    border-radius: var(--sga-radius-lg);
    box-shadow: var(--sga-shadow);
}

.sga-panel,
.sga-card-form {
    padding: 26px;
}

.sga-panel h2,
.sga-card-form h2 {
    margin: 0 0 18px;
    font-size: 1.6rem;
    line-height: 1.05;
    letter-spacing: -0.05em;
}

.sga-panel p {
    color: var(--sga-muted);
    margin: 0 0 16px;
}

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

.sga-panel-head h2 {
    margin: 0 0 6px;
}

.sga-panel-head p {
    margin: 0;
    color: var(--sga-muted);
}

.sga-stat {
    padding: 24px;
}

.sga-stat span {
    display: block;
    color: var(--sga-muted);
    font-weight: 850;
}

.sga-stat strong {
    display: block;
    margin-top: 8px;
    font-size: 2.5rem;
    line-height: 1;
    letter-spacing: -0.06em;
}

.sga-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 12px 18px;
    border: 1px solid rgba(95, 116, 255, 0.24);
    border-radius: 999px;
    background: #eef1ff;
    color: #3141b8;
    font: inherit;
    font-weight: 900;
    cursor: pointer;
    box-shadow: none;
    text-align: center;
}

.sga-button:hover {
    background: #e3e7ff;
}

.sga-button-soft {
    background: #eef1ff;
    color: #3141b8;
    box-shadow: none;
}

.sga-button-soft:hover {
    background: #e3e7ff;
}

.sga-steps {
    margin: 0;
    padding-left: 20px;
    color: var(--sga-muted);
}

.sga-steps li {
    margin: 8px 0;
}

.sga-form {
    display: grid;
    gap: 18px;
}

.sga-inline-form {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 14px;
    margin-bottom: 18px;
}

.sga-form label {
    display: grid;
    gap: 8px;
    color: var(--sga-text);
    font-size: 0.92rem;
    font-weight: 900;
}

.sga-form input,
.sga-form textarea,
.sga-form select {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border: 1px solid var(--sga-border);
    border-radius: 14px;
    background: #ffffff;
    color: var(--sga-text);
    font: inherit;
    outline: none;
}

.sga-form textarea {
    resize: vertical;
}

.sga-form input:focus,
.sga-form textarea:focus,
.sga-form select:focus {
    border-color: var(--sga-primary);
    box-shadow: 0 0 0 4px rgba(95, 116, 255, 0.12);
}

.sga-form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.sga-fieldset {
    display: grid;
    gap: 18px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.sga-fieldset:disabled {
    opacity: 0.78;
}

.sga-fieldset:disabled input,
.sga-fieldset:disabled textarea,
.sga-fieldset:disabled select,
.sga-fieldset:disabled button {
    cursor: not-allowed;
}

.sga-alert {
    padding: 14px 16px;
    border-radius: 16px;
    font-weight: 900;
}

.sga-alert-success {
    background: var(--sga-success);
    color: var(--sga-success-text);
}

.sga-alert-error {
    background: var(--sga-error);
    color: var(--sga-error-text);
}

.sga-alert-info {
    background: var(--sga-info);
    color: var(--sga-info-text);
}

.sga-readonly-badge {
    display: grid;
    gap: 2px;
    padding: 8px 12px;
    border: 1px solid rgba(95, 116, 255, 0.2);
    border-radius: 999px;
    background: #eef1ff;
    color: #3141b8;
    font-size: 0.8rem;
    font-weight: 900;
}

.sga-readonly-badge span {
    color: #667085;
    font-size: 0.72rem;
    font-weight: 700;
}

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

.sga-list-item {
    padding: 16px;
    border: 1px solid var(--sga-border);
    border-radius: var(--sga-radius-md);
    background: #ffffff;
}

.sga-list-item h3 {
    margin: 0 0 8px;
    line-height: 1.2;
    letter-spacing: -0.03em;
}

.sga-list-item p {
    margin: 6px 0;
    color: var(--sga-muted);
}

.sga-empty {
    padding: 24px;
    margin-top: 16px;
}

.sga-empty h3 {
    margin: 0 0 8px;
}

.sga-table-wrap {
    overflow-x: auto;
}

.sga-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
}

.sga-table th,
.sga-table td {
    text-align: left;
    padding: 14px;
    border-bottom: 1px solid var(--sga-border);
    vertical-align: top;
}

.sga-table th {
    color: var(--sga-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
}

.sga-table-link {
    color: var(--sga-primary);
    font-weight: 900;
}

/* Auth pages: login/register */

html,
body.sga-auth-body {
    min-height: 100%;
}

body.sga-auth-body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
    background:
        radial-gradient(circle at top right, rgba(52, 88, 255, 0.16), transparent 34rem),
        var(--sga-bg);
    color: var(--sga-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    line-height: 1.6;
}

.sga-auth-shell {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
}

.sga-auth-card {
    width: 100%;
    padding: 34px;
    border: 1px solid var(--sga-border);
    border-radius: var(--sga-radius-lg);
    background: #ffffff;
    box-shadow: var(--sga-shadow);
}

.sga-auth-logo {
    display: inline-flex;
    margin-bottom: 28px;
    color: var(--sga-text);
    font-size: 1.2rem;
    font-weight: 900;
    letter-spacing: -0.04em;
    text-decoration: none;
}

.sga-auth-card h1 {
    margin: 0 0 12px;
    color: var(--sga-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-size: clamp(2rem, 5vw, 3rem);
    line-height: 1;
    letter-spacing: -0.06em;
}

.sga-auth-intro {
    margin: 0 0 24px;
    color: var(--sga-muted);
}

.sga-auth-card .sga-form {
    display: grid;
    gap: 18px;
}

.sga-auth-card .sga-button {
    width: 100%;
}

.sga-auth-footnote {
    margin: 22px 0 0;
    color: var(--sga-muted);
    text-align: center;
}

.sga-auth-footnote a {
    color: var(--sga-primary);
    font-weight: 900;
}

.sga-auth-lang {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 22px;
    padding: 8px 10px;
    border: 1px solid var(--sga-border);
    border-radius: 999px;
    color: var(--sga-muted);
    font-size: 0.82rem;
    font-weight: 900;
}

.sga-auth-lang a {
    color: var(--sga-muted);
    text-decoration: none;
}

.sga-auth-lang a.is-active {
    color: var(--sga-primary);
}

/* Demo mode */

.sga-auth-demo {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--sga-border);
    text-align: center;
}

.sga-auth-demo p {
    margin: 10px 0 0;
    color: var(--sga-muted);
    font-size: 0.92rem;
}

@media (max-width: 1080px) {
    body.sga-body {
        grid-template-columns: 1fr;
    }

    .sga-sidebar {
        position: relative;
        min-height: auto;
    }

    .sga-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sga-grid-2,
    .sga-grid-3,
    .sga-grid-4 {
        grid-template-columns: 1fr;
    }

    .sga-header {
        display: grid;
    }

    .sga-user-pill {
        justify-items: start;
        border-radius: 18px;
    }
}

@media (max-width: 760px) {
    .sga-panel-head {
        display: grid;
    }

    .sga-inline-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .sga-main,
    .sga-sidebar {
        padding: 22px;
    }

    .sga-nav,
    .sga-form-row {
        grid-template-columns: 1fr;
    }

    .sga-auth-card {
        padding: 26px;
    }
}
.sga-form input,
.sga-form textarea,
.sga-form select {
    font-weight: 400;
}

.sga-form input::placeholder,
.sga-form textarea::placeholder {
    font-weight: 400;
}
.sga-main h1,
.sga-panel h2,
.sga-card-form h2,
.sga-list-item h3 {
    color: #3730a3;
}
.sga-form label {
    color: #3730a3;
}
.sga-form-section {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid #e5e7eb;
}

.sga-form-section:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.sga-form-section h3 {
    margin: 0 0 14px;
    color: #3730a3;
    font-size: 1rem;
}
.sga-form-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 22px;
    padding: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    background: #f9fafb;
}

.sga-form-tabs a {
    display: inline-flex;
    align-items: center;
    padding: 7px 13px;
    border-radius: 999px;
    color: #3730a3;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

.sga-form-tabs a:hover,
.sga-form-tabs a:focus {
    background: #eef2ff;
    color: #312e81;
}
/* SeasonGen Admin — episode CTA fields */
.sga-episode-cta-field {
    display: block;
    width: 100%;
    max-width: 100%;
    clear: both;
    margin: 16px 0 0;
}

.sga-episode-cta-field .sga-field-label {
    display: block;
    margin: 0 0 8px;
    font-weight: 700;
}

.sga-episode-cta-field .sga-episode-cta-input {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
    box-sizing: border-box;
}

.sga-episode-cta-field input[type="text"],
.sga-episode-cta-field input[type="url"] {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
}

/* SeasonGen Admin — manual export copy textarea */
#manual_export_copy_text {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    box-sizing: border-box;
    margin-top: 8px;
    padding: 14px 16px;
    border: 1px solid #d6dbe6;
    border-radius: 12px;
    background: #f8fafc;
    color: #1f2937;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 14px;
    line-height: 1.55;
    resize: vertical;
    white-space: pre-wrap;
}

#manual_export_copy_text:focus {
    outline: none;
    border-color: #94a3b8;
    box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.18);
}

label[for="manual_export_copy_text"] {
    display: block;
    margin-top: 18px;
    margin-bottom: 8px;
    font-weight: 700;
}

/* SeasonGen Admin — manual export copy textarea */
#manual_export_copy_text {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    box-sizing: border-box;
    margin-top: 8px;
    padding: 14px 16px;
    border: 1px solid #d6dbe6;
    border-radius: 12px;
    background: #f8fafc;
    color: #1f2937;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 14px;
    line-height: 1.55;
    resize: vertical;
    white-space: pre-wrap;
}

#manual_export_copy_text:focus {
    outline: none;
    border-color: #94a3b8;
    box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.18);
}

label[for="manual_export_copy_text"] {
    display: block;
    margin-top: 18px;
    margin-bottom: 8px;
    font-weight: 700;
}

/* SeasonGen Admin — episode CTA fields */
.sga-episode-cta-field {
    display: block;
    width: 100%;
    max-width: 100%;
    clear: both;
    margin: 16px 0 0;
}

.sga-episode-cta-field .sga-field-label {
    display: block;
    margin: 0 0 8px;
    font-weight: 700;
}

.sga-episode-cta-field .sga-episode-cta-input,
.sga-episode-cta-field input[type="text"],
.sga-episode-cta-field input[type="url"] {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
    box-sizing: border-box;
}
