:root {
    color-scheme: light dark;

    /* Backgrounds & surfaces */
    --color-bg: #f8fafc;
    --color-bg-rgb: 248, 250, 252;
    --color-surface: #ffffff;
    --color-surface-rgb: 255, 255, 255;
    --color-surface-elevated: #f1f5f9;
    --color-surface-floating: #ffffff;

    /* Text */
    --color-text: #0f172a;
    --color-text-rgb: 15, 23, 42;
    --color-text-muted: #64748b;
    --color-text-inverted: #ffffff;

    /* Accents */
    --color-primary: #2563eb;
    --color-primary-rgb: 37, 99, 235;
    --color-primary-dark: #1d4ed8;
    --color-primary-light: #93c5fd;
    --color-secondary: #7c3aed;
    --color-secondary-rgb: 124, 58, 237;
    --color-secondary-dark: #6d28d9;
    --color-danger: #dc2626;
    --color-danger-rgb: 220, 38, 38;
    --color-danger-dark: #b91c1c;
    --color-success: #16a34a;
    --color-success-rgb: 22, 163, 74;
    --color-success-dark: #15803d;
    --color-warning: #f59e0b;
    --color-info: #06b6d4;

    /* Borders & shadows */
    --color-border: #e2e8f0;
    --color-shadow: rgb(15 23 42 / 0.08);
    --color-shadow-lg: rgb(15 23 42 / 0.12);

    /* Gradient */
    --color-gradient: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    --color-gradient-dark: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-secondary-dark) 100%);

    /* Alert tokens */
    --color-alert-info-bg: #ecfeff;
    --color-alert-info-text: #155e75;
    --color-alert-success-bg: #f0fdf4;
    --color-alert-success-text: #166534;
    --color-alert-error-bg: #fef2f2;
    --color-alert-error-text: #991b1b;
    --color-alert-warning-bg: #fffbeb;
    --color-alert-warning-text: #92400e;

    /* Font & layout */
    --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Poppins', var(--font-sans), sans-serif;
    --max-width: 1200px;
    --spacer: 1rem;
    --radius-sm: 0.375rem;
    --radius: 0.625rem;
    --radius-lg: 1rem;
    --shadow: 0 4px 16px var(--color-shadow);
    --shadow-lg: 0 12px 32px var(--color-shadow-lg);
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #0f172a;
        --color-bg-rgb: 15, 23, 42;
        --color-surface: #1e293b;
        --color-surface-rgb: 30, 41, 59;
        --color-surface-elevated: #334155;
        --color-surface-floating: #1e293b;

        --color-text: #f1f5f9;
        --color-text-rgb: 241, 245, 249;
        --color-text-muted: #94a3b8;
        --color-text-inverted: #0f172a;

        --color-border: #334155;
        --color-shadow: rgb(0 0 0 / 0.35);
        --color-shadow-lg: rgb(0 0 0 / 0.5);

        --color-alert-info-bg: #164e63;
        --color-alert-info-text: #a5f3fc;
        --color-alert-success-bg: #14532d;
        --color-alert-success-text: #bbf7d0;
        --color-alert-error-bg: #7f1d1d;
        --color-alert-error-text: #fecaca;
        --color-alert-warning-bg: #78350f;
        --color-alert-warning-text: #fde68a;
    }
}

[data-theme="dark"] {
    --color-bg: #0f172a;
    --color-bg-rgb: 15, 23, 42;
    --color-surface: #1e293b;
    --color-surface-rgb: 30, 41, 59;
    --color-surface-elevated: #334155;
    --color-surface-floating: #1e293b;

    --color-text: #f1f5f9;
    --color-text-rgb: 241, 245, 249;
    --color-text-muted: #94a3b8;
    --color-text-inverted: #0f172a;

    --color-border: #334155;
    --color-shadow: rgb(0 0 0 / 0.35);
    --color-shadow-lg: rgb(0 0 0 / 0.5);

    --color-alert-info-bg: #164e63;
    --color-alert-info-text: #a5f3fc;
    --color-alert-success-bg: #14532d;
    --color-alert-success-text: #bbf7d0;
    --color-alert-error-bg: #7f1d1d;
    --color-alert-error-text: #fecaca;
    --color-alert-warning-bg: #78350f;
    --color-alert-warning-text: #fde68a;
}

[data-theme="light"] {
    --color-bg: #f8fafc;
    --color-bg-rgb: 248, 250, 252;
    --color-surface: #ffffff;
    --color-surface-rgb: 255, 255, 255;
    --color-surface-elevated: #f1f5f9;
    --color-surface-floating: #ffffff;

    --color-text: #0f172a;
    --color-text-rgb: 15, 23, 42;
    --color-text-muted: #64748b;
    --color-text-inverted: #ffffff;

    --color-border: #e2e8f0;
    --color-shadow: rgb(15 23 42 / 0.08);
    --color-shadow-lg: rgb(15 23 42 / 0.12);

    --color-alert-info-bg: #ecfeff;
    --color-alert-info-text: #155e75;
    --color-alert-success-bg: #f0fdf4;
    --color-alert-success-text: #166534;
    --color-alert-error-bg: #fef2f2;
    --color-alert-error-text: #991b1b;
    --color-alert-warning-bg: #fffbeb;
    --color-alert-warning-text: #92400e;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.2;
    margin: 2rem 0 1rem 0;
    color: var(--color-text);
}

/*
 * A heading that opens its own container (page title, card title, modal
 * title, etc.) does not need extra breathing room above it — the
 * container's own padding/margin already separates it from whatever came
 * before. Only headings that follow other content within the same
 * container need the top margin, so they read as "belonging" to the
 * section below them rather than the content above.
 */
h1:first-child,
h2:first-child,
h3:first-child,
h4:first-child {
    margin-top: 0;
}

p {
    margin: 0 0 1rem 0;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex="0"]:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

img {
    max-width: 100%;
    height: auto;
}

/* Navigation */
.s3-nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem calc(var(--spacer) * 2);
    min-height: 4rem;
    background: rgba(var(--color-surface-rgb), 0.9);
    backdrop-filter: blur(8px) saturate(150%);
    -webkit-backdrop-filter: blur(8px) saturate(150%);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow);
}

.s3-brand,
a.s3-brand,
a.s3-brand:hover,
a.s3-brand:focus {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.3rem;
    color: var(--color-text);
    text-decoration: none;
    border-bottom: none;
}

.s3-brand img {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: block;
    vertical-align: middle;
}

.s3-brand-text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.4rem;
    letter-spacing: -0.02em;
    line-height: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: none;
}

.s3-nav-list {
    display: flex;
    gap: var(--spacer);
    list-style: none;
    margin: 0;
    padding: 0;
    align-items: center;
    justify-content: center;
}

@media (min-width: 769px) {
    .s3-nav-list {
        margin-left: auto;
        margin-right: 0.75rem;
    }
}

.s3-nav-list li {
    position: relative;
}

.s3-nav-list a,
.s3-nav-list .s3-logout-form button {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 0.8rem;
    color: var(--color-text);
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s;
}

.s3-nav-list a:hover,
.s3-nav-list .s3-logout-form button:hover {
    color: var(--color-primary);
    background: var(--color-surface-elevated);
    text-decoration: none;
}

.s3-nav-list a > .s3-nav-icon-left,
.s3-nav-list a > .s3-nav-icon-right,
.s3-nav-list .s3-logout-form button > .s3-nav-icon-left,
.s3-nav-list .s3-logout-form button > .s3-nav-icon-right {
    display: inline-block;
}

.s3-nav-list a > .s3-nav-icon-left,
.s3-nav-list .s3-logout-form button > .s3-nav-icon-left {
    margin-right: 0.4rem;
}

.s3-nav-list a > .s3-nav-icon-right,
.s3-nav-list .s3-logout-form button > .s3-nav-icon-right {
    margin-left: 0.4rem;
}

.s3-nav-list li > a:after,
.s3-nav-user > a:after {
    content: '\25BC';
    font-size: 0.6rem;
    margin-left: 0.4rem;
    display: none;
    vertical-align: middle;
}

.s3-nav-list li.s3-has-submenu > a:after,
.s3-nav-user > a:after {
    display: inline;
}

.s3-nav-submenu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 160px;
    max-width: min(280px, calc(100vw - 2rem));
    background: var(--color-surface-floating);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    list-style: none;
    margin: 0;
    padding: 0.5rem 0;
    box-shadow: var(--shadow);
    z-index: 100;
}

/* Align submenus to the right edge of the parent when near the viewport edge */
.s3-nav-submenu.s3-nav-submenu--right,
.s3-nav-list > li:last-child > .s3-nav-submenu,
.s3-nav-user > .s3-nav-submenu {
    left: auto;
    right: 0;
}

/* Fly nested submenus to the left so they do not overflow the viewport */
.s3-nav-submenu .s3-nav-submenu {
    top: 0;
    left: auto;
    right: 100%;
}

.s3-nav-list li:hover > .s3-nav-submenu,
.s3-nav-user:hover > .s3-nav-submenu,
.s3-has-submenu.is-open > .s3-nav-submenu {
    display: block;
}

.s3-nav-submenu li {
    width: 100%;
}

.s3-nav-submenu a,
.s3-nav-submenu .s3-logout-form button {
    padding: 0.5rem 1rem;
    white-space: normal;
    overflow-wrap: break-word;
    width: 100%;
    text-align: left;
    color: var(--color-text);
}

.s3-nav-submenu a:hover,
.s3-nav-submenu .s3-logout-form button:hover {
    background: var(--color-surface-elevated);
    text-decoration: none;
}

.s3-nav-user > a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.s3-user-name {
    font-weight: 600;
}

/* Mobile hamburger */
.s3-nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0.25rem;
    background: var(--color-surface-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    gap: 0.35rem;
}

.s3-nav-toggle:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.s3-nav-toggle span {
    display: block;
    width: 100%;
    height: 3px;
    background: var(--color-text);
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}

.s3-nav-toggle.is-open span:nth-child(1) {
    transform: translateY(8.5px) rotate(45deg);
}

.s3-nav-toggle.is-open span:nth-child(2) {
    opacity: 0;
}

.s3-nav-toggle.is-open span:nth-child(3) {
    transform: translateY(-8.5px) rotate(-45deg);
}

@media (max-width: 768px) {
    .s3-nav {
        flex-wrap: wrap;
    }

    .s3-nav-toggle {
        display: flex;
        margin-left: auto;
    }

    .s3-nav-list {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding-top: 1rem;
    }

    .s3-nav-list.is-open {
        display: flex;
    }

    .s3-nav-list li {
        width: 100%;
        border-bottom: 1px solid var(--color-border);
    }

    .s3-nav-list li:last-child {
        border-bottom: none;
    }

    .s3-nav-list a,
    .s3-nav-list .s3-logout-form button {
        padding: 0.75rem 0.5rem;
    }

    .s3-nav-list li > a:after,
    .s3-nav-user > a:after {
        display: none;
    }

    .s3-nav-submenu {
        display: block;
        position: static;
        width: 100%;
        max-width: none;
        box-shadow: none;
        border: none;
        border-top: 1px solid var(--color-border);
        border-bottom: 1px solid var(--color-border);
        padding: 0;
        background: var(--color-surface-elevated);
        border-radius: 0;
    }

    .s3-has-submenu.is-open > .s3-nav-submenu,
    .s3-nav-list .s3-nav-submenu .s3-nav-submenu {
        display: block;
    }

    .s3-nav-submenu a,
    .s3-nav-submenu .s3-logout-form button {
        padding-left: 1.5rem;
    }

    .s3-nav-submenu .s3-nav-submenu a,
    .s3-nav-submenu .s3-nav-submenu .s3-logout-form button {
        padding-left: 2.5rem;
    }
}

/* Main layout */
.s3-main {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--spacer) calc(var(--spacer) * 2);
}

.s3-main--full {
    max-width: none;
    padding: 0;
}

.s3-container {
    background: var(--color-surface);
    padding: calc(var(--spacer) * 1.5);
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow);
}

.s3-container--full {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
}

@media (max-width: 768px) {
    .s3-main {
        padding: var(--spacer);
    }

    .s3-main--full {
        padding: 0;
    }

    .s3-container {
        padding: var(--spacer);
    }

    .s3-container--full {
        padding: 0;
    }
}

/* Buttons */
.s3-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    background: var(--color-gradient);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 4px 14px rgb(var(--color-primary-rgb) / 0.25);
    transition: background 0.25s ease, transform 0.15s ease, box-shadow 0.25s ease;
}

.s3-btn:hover {
    background: var(--color-gradient-dark);
    color: #fff;
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgb(var(--color-primary-rgb) / 0.32);
}

.s3-btn:active {
    transform: translateY(0);
}

.s3-btn-secondary {
    background: var(--color-surface-elevated);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow);
}

.s3-btn-secondary:hover {
    background: var(--color-bg);
    color: var(--color-text);
    box-shadow: var(--shadow-lg);
}

.s3-btn-danger {
    background: linear-gradient(135deg, var(--color-danger) 0%, var(--color-danger-dark) 100%);
    box-shadow: 0 4px 14px rgb(var(--color-danger-rgb) / 0.25);
}

.s3-btn-danger:hover {
    background: linear-gradient(135deg, var(--color-danger-dark) 0%, #991b1b 100%);
    box-shadow: 0 6px 20px rgb(var(--color-danger-rgb) / 0.32);
}

.s3-btn-success {
    background: linear-gradient(135deg, var(--color-success) 0%, var(--color-success-dark) 100%);
    box-shadow: 0 4px 14px rgb(var(--color-success-rgb) / 0.25);
}

.s3-btn-success:hover {
    background: linear-gradient(135deg, var(--color-success-dark) 0%, #166534 100%);
    box-shadow: 0 6px 20px rgb(var(--color-success-rgb) / 0.32);
}

.s3-btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.s3-btn--large {
    padding: 0.85rem 1.75rem;
    font-size: 1.05rem;
}

/* Page layouts */
.s3-page {
    max-width: 900px;
    margin: 0 auto;
}

.s3-page h1,
.s3-page .s3-page-title {
    margin: 0 0 1.5rem 0;
    font-size: 1.75rem;
}

.s3-page-header {
    text-align: center;
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

.s3-page-header h1 {
    font-size: clamp(2rem, 4vw, 2.75rem);
    margin-bottom: 0.75rem;
}

.s3-page-header .s3-page-meta {
    font-size: 1.15rem;
    max-width: 640px;
    margin: 0 auto;
}

.s3-page-header .s3-btn-small {
    margin-top: 1rem;
}

.s3-page p {
    margin: 0 0 1rem 0;
}

.s3-hero {
    text-align: center;
    padding: 4rem 1rem;
}

.s3-hero h1 {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 3.25rem);
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 1rem;
}

.s3-hero p {
    font-size: clamp(1rem, 2vw, 1.25rem);
    color: var(--color-text-muted);
    max-width: 680px;
    margin: 0 auto 1.5rem auto;
}

/* Scale hero and stat typography down on phones */
@media (max-width: 600px) {
    .s3-hero {
        padding: 3rem 1rem;
    }

    .s3-dashboard-hero h1 {
        font-size: 1.5rem;
    }

    .s3-stat-number {
        font-size: 1.6rem;
    }
}

.s3-page-error {
    text-align: center;
    padding: 3rem 1rem;
}

.s3-page-error p {
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
}

.s3-access-options {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.s3-404 {
    text-align: center;
    padding: 4rem 1rem;
}

.s3-404 h1 {
    font-size: 4rem;
    margin-bottom: 0.5rem;
}

.s3-auth {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 4rem);
    padding: 4rem 1rem;
    background:
        linear-gradient(rgb(15 23 42 / 0.55), rgb(15 23 42 / 0.55)),
        url('/img/home-hero.jpg') center/cover no-repeat;
}

.s3-auth-card {
    width: 100%;
    max-width: 460px;
    padding: 2.5rem;
    background: var(--color-surface-floating);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.s3-auth-card h1 {
    margin: 0 0 0.5rem 0;
    font-size: 1.75rem;
    text-align: center;
}

.s3-auth-card .s3-alert {
    margin-bottom: 1.25rem;
}

.s3-auth-card form {
    display: grid;
    gap: 1.25rem;
    margin-bottom: 1rem;
}

.s3-auth-card > p {
    text-align: center;
    margin-bottom: 0.75rem;
    color: var(--color-text-muted);
}

.s3-auth-card > p a {
    color: var(--color-primary);
    font-weight: 600;
}

.s3-auth-card > p a:hover {
    color: var(--color-primary-dark);
}

.s3-dashboard {
    text-align: center;
}

.s3-dashboard p {
    font-size: 1.1rem;
}

.s3-dashboard-section-title {
    margin: 2rem 0 1rem 0;
    font-size: 1.25rem;
    color: var(--color-text);
}

.s3-dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.s3-dashboard-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.s3-dashboard-link {
    flex: 1 1 120px;
    min-width: 120px;
}

.s3-dashboard-hero {
    padding: 2rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.s3-dashboard-hero h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.s3-dashboard-hero p {
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
}

.s3-quick-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
}

a.s3-quick-link,
.s3-quick-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.25rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    text-decoration: none;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

a.s3-quick-link:hover,
.s3-quick-link:hover {
    text-decoration: none;
    border-color: var(--color-primary);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.s3-quick-link--primary,
a.s3-quick-link--primary {
    background: var(--color-gradient);
    color: #fff;
    border-color: transparent;
}

.s3-quick-link--primary:hover,
a.s3-quick-link--primary:hover {
    background: var(--color-gradient-dark);
    color: #fff;
    border-color: transparent;
}

.s3-quick-link--primary .s3-icon,
a.s3-quick-link--primary .s3-icon {
    color: #fff;
}

.s3-quick-link .s3-icon {
    font-size: 1.5rem;
    color: var(--color-primary);
}

.s3-quick-link .s3-label {
    font-weight: 600;
    font-size: 0.95rem;
}

.s3-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
    text-align: left;
}

.s3-empty-state {
    padding: 2.5rem 1.5rem;
    background: var(--color-surface);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text-muted);
    text-align: center;
}

.s3-empty-state .s3-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    color: var(--color-text-muted);
}

.s3-empty-state h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.15rem;
    color: var(--color-text);
}

.s3-empty-state p {
    margin: 0 auto 1rem auto;
    max-width: 500px;
}

.s3-search {
    max-width: 800px;
    margin: 0 auto;
}

.s3-search-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.s3-search-form input {
    flex: 1;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font: inherit;
    background: var(--color-surface);
    color: var(--color-text);
}

.s3-search-form button {
    padding: 0.6rem 1rem;
}

.s3-search-count {
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
}

.s3-search-result {
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.s3-search-result:last-child {
    border-bottom: none;
}

.s3-search-result h2 {
    margin: 0 0 0.25rem 0;
}

.s3-search-result p {
    margin: 0;
}

/* Forms */
.s3-form-group {
    display: grid;
    gap: 0.4rem;
}

.s3-form-group label {
    font-weight: 600;
    font-size: 0.95rem;
}

.s3-form-group input[type="text"],
.s3-form-group input[type="email"],
.s3-form-group input[type="password"],
.s3-form-group input[type="number"],
.s3-form-group input[type="search"],
.s3-form-group input[type="url"],
.s3-form-group input[type="tel"],
.s3-form-group select,
.s3-form-group textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.s3-form-group input:focus,
.s3-form-group select:focus,
.s3-form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.s3-form-group input::placeholder,
.s3-form-group textarea::placeholder {
    color: var(--color-text-muted);
}

.s3-form-group select option {
    background: var(--color-surface);
    color: var(--color-text);
}

.s3-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-top: 0.5rem;
}

.s3-form-message {
    margin-top: 0.5rem;
}

.s3-form-error {
    color: var(--color-danger);
    font-size: 0.9rem;
    margin: 0.25rem 0 0 0;
}

.s3-form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem 0;
    font-weight: normal;
    cursor: pointer;
}

.s3-form-check input[type="checkbox"],
.s3-form-check input[type="radio"] {
    width: 1.1rem;
    height: 1.1rem;
    margin: 0;
}

/* Frontend form renderer */
.s3-form-frontend {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1rem;
    align-items: start;
}

.s3-form-field {
    grid-column: span 12;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.s3-form-field-help {
    margin: 0;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.s3-field-label {
    font-weight: 600;
    font-size: 0.95rem;
}

.s3-form-field input[type="text"],
.s3-form-field input[type="email"],
.s3-form-field input[type="url"],
.s3-form-field input[type="tel"],
.s3-form-field input[type="number"],
.s3-form-field input[type="file"],
.s3-form-field input[type="password"],
.s3-form-field textarea,
.s3-form-field select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
}

.s3-form-field input:focus,
.s3-form-field textarea:focus,
.s3-form-field select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.s3-form-field textarea {
    min-height: 100px;
    resize: vertical;
}

.s3-form-field .s3-field-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: normal;
}

.s3-form-field-submit {
    margin-top: 0.5rem;
}

.s3-form-col-half    { grid-column: span 6; }
.s3-form-col-third   { grid-column: span 4; }
.s3-form-col-quarter { grid-column: span 3; }
.s3-form-col-full    { grid-column: span 12; }

.s3-honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

@media (max-width: 768px) {
    .s3-form-col-half,
    .s3-form-col-third,
    .s3-form-col-quarter,
    .s3-form-col-full {
        grid-column: span 12;
    }
}

/* Admin form (legacy) */
.s3-admin-form {
    display: grid;
    gap: 0.75rem;
    max-width: 600px;
    margin-bottom: 2rem;
}

.s3-admin-form label {
    font-weight: 600;
}

.s3-admin-form input,
.s3-admin-form select,
.s3-admin-form textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font: inherit;
    background: var(--color-surface);
    color: var(--color-text);
}

.s3-admin-form input:focus,
.s3-admin-form select:focus,
.s3-admin-form textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.s3-admin-form label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal;
}

.s3-admin-form input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    margin: 0;
}

/* Tables */
.s3-table,
.s3-admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.5rem;
}

.s3-table th,
.s3-table td,
.s3-admin-table th,
.s3-admin-table td {
    border: 1px solid var(--color-border);
    padding: 0.5rem;
    text-align: left;
    vertical-align: top;
}

.s3-table th,
.s3-admin-table th {
    background: var(--color-surface-elevated);
    font-weight: 600;
}

.s3-table tbody tr:nth-child(even),
.s3-admin-table tbody tr:nth-child(even) {
    background: var(--color-bg);
}

.s3-table tbody tr:hover,
.s3-admin-table tbody tr:hover {
    background: var(--color-surface-elevated);
}

/* Horizontal scroll wrapper so wide tables stay usable on phones and tablets */
.s3-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

.s3-table-scroll .s3-table,
.s3-table-scroll .s3-admin-table {
    min-width: 640px;
}

@media (max-width: 768px) {
    .s3-table th,
    .s3-table td,
    .s3-admin-table th,
    .s3-admin-table td {
        padding: 0.4rem;
        font-size: 0.9rem;
    }
}

/* Pagination */
.s3-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.s3-pagination-ellipsis {
    padding: 0 0.25rem;
    color: var(--color-text-muted);
}

.s3-pagination-info {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin: 0 0 0 auto;
}

/* Alerts */
.s3-alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: var(--radius);
}

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

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

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

.s3-alert-warning {
    background: var(--color-alert-warning-bg);
    color: var(--color-alert-warning-text);
}

.s3-onboarding-banner {
    border-left: 4px solid var(--color-primary);
    padding-left: 1rem;
}

/* Badges */
.s3-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: var(--color-surface-elevated);
    color: var(--color-text-muted);
}

.s3-badge-success {
    background: var(--color-success);
    color: var(--color-surface);
}

.s3-badge-warning {
    background: var(--color-warning);
    color: var(--color-text);
}

.s3-badge-danger {
    background: var(--color-danger);
    color: var(--color-text-inverted);
}

.s3-list-unstyled {
    list-style: none;
    padding: 0;
    margin: 0;
}

.s3-list-unstyled li {
    margin-bottom: 0.5rem;
}

.s3-list-unstyled li:last-child {
    margin-bottom: 0;
}

.s3-list-numbered {
    padding-left: 1.25rem;
    margin: 0 0 1.5rem 0;
    color: var(--color-text-muted);
}

.s3-list-numbered li {
    margin-bottom: 0.75rem;
    padding-left: 0.5rem;
}

.s3-list-numbered li:last-child {
    margin-bottom: 0;
}

.s3-badge-muted {
    background: var(--color-surface-elevated);
    color: var(--color-text-muted);
}

/* Cards */
.s3-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

a.s3-stat-card,
.s3-stat-card {
    display: block;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

a.s3-stat-card:hover {
    text-decoration: none;
    border-color: var(--color-primary);
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.s3-stat-number {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.s3-stat-label {
    display: block;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.s3-dashboard-link {
    display: block;
    padding: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    text-align: center;
    font-weight: 600;
    text-decoration: none;
    color: var(--color-text);
    transition: background 0.2s, transform 0.1s;
}

.s3-dashboard-link:hover {
    background: var(--color-surface-elevated);
    text-decoration: none;
    transform: translateY(-2px);
}

/* Modals */
.s3-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.s3-modal.is-open {
    display: flex;
}

.s3-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.s3-modal-box {
    position: relative;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    width: min(900px, 95vw);
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
}

.s3-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    position: sticky;
    top: -1.5rem;
    background: var(--color-surface);
    padding: 1rem 0;
    z-index: 10;
}

.s3-modal-header h2 {
    margin: 0;
    font-size: 1.4rem;
}

.s3-modal-close {
    background: transparent;
    border: none;
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    color: var(--color-text-muted);
}

.s3-modal-close:hover {
    color: var(--color-text);
}

/* Toolbar */
.s3-admin-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.s3-modal .s3-admin-form {
    max-width: none;
    margin-bottom: 0;
}

.s3-modal .s3-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

@media (max-width: 600px) {
    .s3-modal .s3-form-row {
        grid-template-columns: 1fr;
    }
}

/* Admin nav links */
.s3-admin nav a {
    display: inline-block;
    margin-right: 1rem;
}

/* Inline forms */
.s3-inline-form {
    display: inline;
    margin: 0;
}

/* Logout form */
.s3-logout-form {
    display: inline;
    margin: 0;
}

.s3-logout-form button {
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    font: inherit;
    padding: 0;
}

.s3-logout-form button:hover {
    text-decoration: underline;
}

/* Content page extras */
.s3-page-meta {
    color: var(--color-text-muted);
    font-style: italic;
    margin-bottom: 1.5rem;
}

.s3-page-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
}

.s3-page-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.s3-page-content th,
.s3-page-content td {
    border: 1px solid var(--color-border);
    padding: 0.5rem;
    text-align: left;
}

.s3-page-content th {
    background: var(--color-surface-elevated);
}

/* Gutenberg block output */
.s3-page-content .wp-block-paragraph {
    margin-bottom: 1rem;
}

.s3-page-content .wp-block-heading {
    margin: 1.5rem 0 0.75rem 0;
}

.s3-page-content .wp-block-image {
    margin: 1rem 0;
}

.s3-page-content .wp-block-image img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
}

.s3-page-content .wp-block-columns {
    display: grid;
    grid-template-columns: repeat(var(--wp-columns, 1), 1fr);
    gap: 1rem;
    margin: 1rem 0;
}

.s3-page-content .wp-block-column > *:last-child {
    margin-bottom: 0;
}

@media (max-width: 768px) {
    .s3-page-content .wp-block-columns {
        grid-template-columns: 1fr !important;
    }
}

/* Profile */
.s3-profile {
    max-width: 560px;
    margin: 0 auto;
}

.s3-profile h1 {
    margin-bottom: 1.5rem;
}

.s3-profile-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

.s3-profile-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    flex-shrink: 0;
    font-size: 1.75rem;
    font-weight: 700;
    color: #fff;
    background: var(--color-primary);
    border-radius: 50%;
}

.s3-profile-info {
    line-height: 1.4;
}

.s3-profile-name {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}

.s3-profile-email {
    margin: 0.25rem 0 0.5rem 0;
    color: var(--color-text-muted);
    word-break: break-word;
}

.s3-profile-role {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #fff;
    background: var(--color-success);
    border-radius: var(--radius-sm);
}

.s3-profile-form {
    display: grid;
    gap: 1.25rem;
}

@media (max-width: 600px) {
    .s3-profile-header {
        flex-direction: column;
        text-align: center;
    }

    .s3-form-actions {
        flex-direction: column;
    }

    .s3-form-actions .s3-btn,
    .s3-form-actions .s3-btn-secondary {
        width: 100%;
        text-align: center;
    }
}

/* Marketing sections */
.s3-section {
    padding: 5rem 1rem;
}

.s3-section--alt {
    background: var(--color-surface-elevated);
}

.s3-section-inner {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
}

.s3-section-title {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 3vw, 2.25rem);
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.75rem;
}

.s3-section-lead {
    font-size: 1.1rem;
    color: var(--color-text-muted);
    text-align: center;
    max-width: 640px;
    margin: 0 auto 2.5rem auto;
}

.s3-feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
}

.s3-feature-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    padding: 2rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.s3-feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-primary-light);
}

.s3-feature-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    font-size: 1.5rem;
    color: #fff;
    background: var(--color-gradient);
    border-radius: var(--radius);
    box-shadow: 0 6px 16px rgb(var(--color-primary-rgb) / 0.25);
}

.s3-feature-icon--secondary {
    background: linear-gradient(135deg, var(--color-secondary) 0%, var(--color-secondary-dark) 100%);
    box-shadow: 0 6px 16px rgb(var(--color-secondary-rgb) / 0.25);
}

.s3-feature-icon--success {
    background: linear-gradient(135deg, var(--color-success) 0%, var(--color-success-dark) 100%);
    box-shadow: 0 6px 16px rgb(var(--color-success-rgb) / 0.25);
}

.s3-feature-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

.s3-feature-text {
    color: var(--color-text-muted);
    margin: 0;
    line-height: 1.6;
}

.s3-cta {
    padding: 5rem 1rem;
    text-align: center;
    color: #fff;
    background: var(--color-gradient);
}

.s3-cta h2 {
    color: #fff;
    font-size: clamp(1.6rem, 3vw, 2.25rem);
    margin-bottom: 0.75rem;
}

.s3-cta p {
    color: rgba(255, 255, 255, 0.9);
    max-width: 600px;
    margin: 0 auto 1.5rem auto;
}

.s3-cta .s3-btn {
    background: #fff;
    color: var(--color-primary);
    box-shadow: var(--shadow-lg);
}

.s3-cta .s3-btn:hover {
    background: var(--color-surface-elevated);
    color: var(--color-primary-dark);
}

.s3-step-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 2rem;
    counter-reset: step;
}

.s3-step {
    position: relative;
    text-align: center;
    padding: 1.5rem;
}

.s3-step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    margin-bottom: 1rem;
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    background: var(--color-gradient);
    border-radius: 50%;
    box-shadow: var(--shadow);
}

.s3-step h3 {
    font-size: 1.15rem;
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.s3-step p {
    color: var(--color-text-muted);
    margin: 0;
}

@media (max-width: 768px) {
    .s3-section {
        padding: 3.5rem 1rem;
    }

    .s3-cta {
        padding: 3.5rem 1rem;
    }

    .s3-feature-grid {
        grid-template-columns: 1fr;
    }
}

/* Utility helpers */
.s3-text-center { text-align: center; }
.s3-text-muted { color: var(--color-text-muted); }
.s3-icon { font-size: inherit; }
.s3-image {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

/* Footer */
.s3-footer {
    margin-top: auto;
    padding: 2rem 1rem;
    border-top: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 0.9rem;
    text-align: center;
}

.s3-footer-content {
    margin: 0;
}

.s3-footer-content p:last-child {
    margin-bottom: 0;
}

.s3-container--full .s3-footer {
    padding: 3rem calc(var(--spacer) * 2);
}

/* Wrap icon transforms so rotate + flip can combine */
.s3-icon-wrap {
    display: inline-block;
    line-height: 1;
}

/* Theme toggle */
.s3-theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s, color 0.2s;
}

.s3-theme-toggle:hover,
.s3-theme-toggle:focus-visible {
    background: var(--color-surface-elevated);
    color: var(--color-primary);
}

.s3-theme-toggle > span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.s3-theme-toggle [hidden] {
    display: none;
}

@media (max-width: 768px) {
    .s3-theme-toggle {
        margin-left: 0.5rem;
    }
}
