/* ===================================================================
   My Pie Studio — Design System
   Clean light theme, modern & investor-ready
   =================================================================== */

/* --- CSS Variables (Design Tokens) --- */
:root {
    /* Backgrounds */
    --bg-primary: #f8fafc;
    --bg-surface: #ffffff;
    --bg-elevated: #f1f5f9;
    --bg-input: #ffffff;
    --bg-hover: #f1f5f9;

    /* Borders */
    --border-default: #e2e8f0;
    --border-hover: #cbd5e1;
    --border-active: #6366f1;

    /* Text */
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --text-heading: #0f172a;

    /* Accent Colors */
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-subtle: rgba(99, 102, 241, 0.08);

    /* Semantic Colors */
    --success: #16a34a;
    --success-subtle: rgba(22, 163, 74, 0.08);
    --danger: #dc2626;
    --danger-subtle: rgba(220, 38, 38, 0.08);
    --warning: #ca8a04;
    --warning-subtle: rgba(202, 138, 4, 0.08);

    /* Spacing & Sizing */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-secondary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

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

a:hover {
    color: var(--accent-hover);
}

/* --- Typography --- */
h1,
h2,
h3,
h4 {
    color: var(--text-heading);
    font-weight: 600;
    line-height: 1.3;
}

h1 {
    font-size: 1.5rem;
}

h2 {
    font-size: 1.125rem;
}

h3 {
    font-size: 1rem;
}

/* --- Layout --- */
.container {
    max-width: 1040px;
    margin: 0 auto;
    padding: 24px 20px;
    overflow-x: hidden;
}

/* --- Topbar --- */
.topbar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-default);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.topbar-brand {
    font-family: 'Baloo 2', cursive;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-heading);
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-brand img,
.topbar-brand svg {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.topbar-nav {
    display: flex;
    gap: 4px;
    align-items: center;
}

.topbar-nav .nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.topbar-nav .nav-link:hover {
    color: var(--text-secondary);
    background: var(--bg-hover);
}

.topbar-nav .nav-link.active {
    color: var(--text-heading);
    background: var(--accent-subtle);
}

/* --- Topbar Mobile Menu Button --- */
.topbar-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--text-heading);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.topbar-menu-btn:hover {
    background: var(--bg-hover);
}

.topbar-menu-btn svg {
    width: 22px;
    height: 22px;
    display: block;
}

.topbar-menu-btn .icon-close {
    display: none;
}

.topbar-menu-btn.active .icon-open {
    display: none;
}

.topbar-menu-btn.active .icon-close {
    display: block;
}

/* --- Cards --- */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 16px;
    transition: border-color var(--transition-normal);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.card-header h2 {
    margin: 0;
}

.card-compact {
    padding: 16px 20px;
}

.card-flush {
    padding: 0;
    overflow: hidden;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    opacity: 0.85;
}

.btn-outline {
    background: transparent;
    border-color: var(--border-default);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.75rem;
}

.btn-icon {
    padding: 6px;
    width: 32px;
    height: 32px;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 16px;
}

.form-group label,
.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M3 4.5L6 8l3-3.5H3z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

/* --- Tables --- */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    text-align: left;
    padding: 10px 16px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-default);
    white-space: nowrap;
}

tbody td {
    padding: 12px 16px;
    font-size: 0.8125rem;
    border-bottom: 1px solid var(--border-default);
    color: var(--text-secondary);
    vertical-align: middle;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--bg-hover);
}

/* --- Detail Table (key-value pairs) --- */
.detail-table th {
    text-transform: none;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    width: 160px;
    letter-spacing: 0;
    text-align: left;
}

.detail-table td {
    font-size: 0.8125rem;
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-admin {
    background: var(--warning-subtle);
    color: var(--warning);
}

.badge-user {
    background: var(--accent-subtle);
    color: var(--accent);
}

/* --- Alerts / Flash --- */
/* --- Toast Notification System --- */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-width: 420px;
    width: calc(100vw - 32px);
}

.alert {
    padding: 12px 40px 12px 16px;
    border-radius: var(--radius-md, 8px);
    font-size: 0.8125rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    animation: toast-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    backdrop-filter: blur(12px);
}

.alert-success {
    background: rgba(22, 163, 74, 0.12);
    border: 1px solid rgba(63, 185, 80, 0.35);
    color: var(--success, #3fb950);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(248, 81, 73, 0.35);
    color: var(--danger, #f85149);
}

.alert-info {
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(88, 166, 255, 0.35);
    color: var(--accent, #58a6ff);
}

.alert .toast-close {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: inherit;
    opacity: 0.5;
    cursor: pointer;
    padding: 2px;
    font-size: 1rem;
    line-height: 1;
    transition: opacity 0.2s;
}

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

.alert.toast-out {
    animation: toast-out 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* --- Token Display --- */
.token-display {
    display: flex;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 16px;
}

.token-value {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    flex: 1;
    word-break: break-all;
    color: var(--text-muted);
    line-height: 1.5;
    user-select: all;
}

/* --- Link Cards --- */
.link-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    margin-bottom: 10px;
    background: var(--bg-primary);
    border: 2px solid #e4e4e4;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.link-card:hover {
    border-color: var(--accent);
    background: var(--bg-elevated);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.link-card .link-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-heading);
}

.link-card .link-url {
    font-size: 0.6875rem;
    color: var(--text-muted);
    word-break: break-all;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

/* --- Actions Row --- */
.actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* --- Status dot --- */
.status-dot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

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

.status-dot.green {
    color: var(--success);
}

.status-dot.blue {
    color: var(--accent);
}

/* --- Monospace text --- */
.mono {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.text-bold {
    font-weight: 600;
}

.text-heading {
    color: var(--text-heading);
}

/* --- Auth Layout --- */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.04) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(22, 163, 74, 0.03) 0%, transparent 60%),
        var(--bg-primary);
}

.auth-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.auth-card h1 {
    font-size: 1.375rem;
    margin-bottom: 6px;
}

.auth-card .subtitle {
    color: var(--text-muted);
    margin-bottom: 24px;
    font-size: 0.875rem;
}

/* --- Utilities --- */
.flex {
    display: flex;
}

.flex-between {
    justify-content: space-between;
}

.flex-center {
    align-items: center;
}

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

.gap-8 {
    gap: 8px;
}

.gap-12 {
    gap: 12px;
}

.gap-16 {
    gap: 16px;
}

.mt-8 {
    margin-top: 8px;
}

.mt-16 {
    margin-top: 16px;
}

.mb-0 {
    margin-bottom: 0;
}

.mb-16 {
    margin-bottom: 16px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .topbar {
        padding: 0 12px;
        height: 48px;
    }

    .topbar-brand {
        font-size: 0.875rem;
    }

    .topbar-menu-btn {
        display: block;
    }

    .topbar-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-surface);
        flex-direction: column;
        padding: 12px 16px;
        gap: 4px;
        border-bottom: 1px solid var(--border-default);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
        z-index: 99;
        animation: topbar-menu-in 0.2s ease-out;
    }

    .topbar-nav.open {
        display: flex;
    }

    .topbar-nav .nav-link {
        padding: 10px 14px;
        font-size: 0.875rem;
        border-radius: var(--radius-md);
        width: 100%;
    }

    .topbar-nav .btn {
        width: 100%;
        justify-content: center;
        margin-top: 4px;
    }

    .topbar-nav form {
        width: 100%;
    }

    .topbar-nav form .btn {
        width: 100%;
        justify-content: center;
    }

    @keyframes topbar-menu-in {
        from { opacity: 0; transform: translateY(-8px); }
        to { opacity: 1; transform: translateY(0); }
    }

    .container {
        padding: 16px 12px;
    }

    .card {
        padding: 16px;
        border-radius: var(--radius-md);
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .auth-card {
        padding: 28px 20px;
    }

    .auth-header {
        margin-bottom: 28px;
    }

    .auth-logo img {
        width: 32px;
        height: 32px;
    }

    .auth-logo span {
        font-size: 1.25rem;
    }

    .token-display {
        flex-direction: column;
    }

    .token-value {
        width: 100%;
    }

    thead th,
    tbody td {
        padding: 8px 12px;
    }

    .hide-mobile {
        display: none !important;
    }

    /* Dashboard: Control Grid → single column */
    .control-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    .control-module {
        min-height: auto;
        padding: 16px;
    }

    /* Step 3 full-width override not needed in single column */
    .control-module[style*="grid-column"] {
        grid-column: auto !important;
    }

    /* Step-or-divider in single column */
    .step-or-divider {
        grid-column: auto;
        padding: 4px 0;
    }

    /* Dashboard: Status Strip → compact stat grid on mobile */
    .status-strip {
        flex-direction: column;
        gap: 10px;
        padding: 12px 0;
        align-items: stretch !important;
        justify-content: flex-start !important;
    }

    .status-strip > div:first-child {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px !important;
    }

    .status-item {
        font-size: 0.75rem;
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 2px;
        background: var(--bg-surface);
        border: 1px solid var(--border-default);
        border-radius: var(--radius-md);
        padding: 8px 4px;
        border-left: none !important;
        padding-left: 4px !important;
    }

    .status-item .item-label {
        font-size: 0.625rem;
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }

    .status-item .item-value {
        font-size: 0.9375rem;
    }

    /* Subscription status items span full width */
    .status-item[style*="border-left"] {
        grid-column: 1 / -1;
        flex-direction: row;
        align-items: center;
        text-align: left;
        padding: 10px 12px;
        gap: 8px;
    }

    .status-badge {
        align-self: flex-start;
    }

    /* Dashboard: Security Footer → stack */
    .security-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 14px 16px;
    }

    .security-footer .btn {
        width: 100%;
        justify-content: center;
    }

    .security-footer form {
        width: 100%;
    }

    .security-footer form .btn {
        width: 100%;
    }

    /* Dashboard: Team Grid → single column */
    .team-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .team-card-header {
        padding: 16px 18px;
    }

    .team-card-content {
        padding: 18px;
    }

    /* Team invite form → stack on mobile */
    .team-card-content .mb-24 > div[style*="display: flex"] {
        flex-direction: column;
    }

    .team-card-content .form-control {
        width: 100%;
    }

    .team-card-content .btn-primary {
        width: 100%;
    }

    /* Dashboard: Roster Items → stack on mobile */
    .roster-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 14px 0;
    }

    .roster-item > div:last-child,
    .roster-item > div:nth-child(2) {
        width: 100%;
        display: flex;
        gap: 8px;
    }

    .roster-item .btn {
        flex: 1;
    }

    .roster-item form {
        flex: 1;
    }

    .roster-item form .btn {
        width: 100%;
    }

    /* Dashboard: Tabs → scrollable on mobile */
    .tabs {
        margin-bottom: 16px;
    }

    .tab-list {
        gap: 0;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 16px;
    }

    .tab-list::-webkit-scrollbar {
        display: none;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 0.8125rem;
        flex-shrink: 0;
    }

    /* Broadcast console responsive */
    .broadcast-console {
        flex-direction: column;
        height: auto;
        max-height: none;
    }

    .console-label {
        border-right: none;
        border-bottom: 1px solid var(--border-default);
        min-width: unset;
        width: 100%;
        justify-content: center;
    }

    /* Grid console overflow */
    .grid-console {
        height: auto;
        min-height: 40px;
    }

    /* btn-xs */
    .btn-xs {
        padding: 4px 10px;
        font-size: 0.6875rem;
    }
}

@media (max-width: 480px) {
    .topbar {
        padding: 0 10px;
    }

    .topbar-nav .nav-link {
        padding: 4px 6px;
        font-size: 0.75rem;
    }

    .container {
        padding: 12px 10px;
    }

    .card {
        padding: 14px;
    }

    .btn {
        padding: 7px 12px;
        font-size: 0.75rem;
    }

    h1 {
        font-size: 1.25rem;
    }

    h2 {
        font-size: 1rem;
    }

    .auth-card {
        padding: 24px 16px;
        border-radius: var(--radius-lg);
    }

    .auth-wrapper {
        padding: 16px 12px;
    }

    /* Status items already handled at 768px, just refine */
    .status-strip > div:first-child {
        gap: 6px !important;
    }

    .status-item {
        padding: 6px 4px;
    }

    .status-item .item-label {
        font-size: 0.5625rem;
    }

    .status-item .item-value {
        font-size: 0.8125rem;
    }

    /* Control module tweaks */
    .control-module {
        padding: 14px;
    }

    .module-header {
        margin-bottom: 10px;
    }

    .module-desc {
        font-size: 0.75rem;
        margin-bottom: 10px;
    }

    .btn-launch-grid {
        height: 44px;
        font-size: 0.8125rem;
    }

    /* Team card compact */
    .team-card-header {
        padding: 14px 16px;
    }

    .team-card-content {
        padding: 14px;
    }

    /* Roster info truncation */
    .roster-item > div:first-child {
        width: 100%;
        min-width: 0;
    }

    /* Setup guide */
    .setup-guide-content {
        padding: 12px;
    }

    .setup-guide-toggle {
        font-size: 0.75rem;
    }

    /* OBS drag compact */
    .obs-drag-compact {
        padding: 10px 14px;
    }

    .obs-drag-compact-text {
        font-size: 0.75rem;
    }

    /* Security footer compact */
    .security-footer {
        padding: 12px 14px;
    }

    .security-footer-icon {
        width: 28px;
        height: 28px;
    }

    .security-footer-title {
        font-size: 0.75rem;
    }

    .security-footer-desc {
        font-size: 0.6875rem;
    }
}

@media (max-width: 360px) {
    .auth-card {
        padding: 20px 14px;
    }

    .topbar-nav .nav-link {
        padding: 3px 5px;
        font-size: 0.6875rem;
    }

    .tab-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    .btn-launch-grid {
        height: 40px;
        font-size: 0.75rem;
    }
}

/* --- Breadcrumbs --- */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    color: var(--text-muted);
    padding: 12px 0 0;
}

.breadcrumbs a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.breadcrumbs a:hover {
    color: var(--accent);
}

.breadcrumbs .separator {
    color: var(--border-hover);
    font-size: 0.75rem;
}

.breadcrumbs .current {
    color: var(--text-heading);
    font-weight: 500;
}

/* --- Status Badges --- */
.badge-pending {
    background: var(--warning-subtle);
    color: var(--warning);
}

.badge-accepted {
    background: var(--success-subtle);
    color: var(--success);
}

.badge-revoked {
    background: var(--danger-subtle);
    color: var(--danger);
}

/* --- Tabs --- */
.tabs {
    margin-bottom: 24px;
}

.tab-list {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-default);
    margin-bottom: 24px;
    padding-bottom: 0;
    overflow-x: auto;
}

.tab-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text-heading);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
    animation: fadeIn var(--transition-fast);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Section Title --- */
.section-title {
    margin-bottom: 20px;
}

.section-title h1 {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.section-title p {
    color: var(--text-muted);
    font-size: 0.875rem;
}
/* --- OBS Setup UI --- */
.obs-setup-container {
    padding: 8px 0;
}

.obs-tabs {
    display: flex;
    gap: 20px;
    border-bottom: 1px solid var(--border-default);
    margin-bottom: 24px;
}

.obs-tab-btn {
    background: transparent;
    border: none;
    padding: 12px 4px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
}

.obs-tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.obs-pane {
    display: none;
    animation: fadeIn var(--transition-fast);
}

.obs-pane.active {
    display: block;
}

.obs-drag-container {
    border: 2px dashed var(--accent);
    background: var(--accent-subtle);
    border-radius: var(--radius-lg);
    padding: 40px 24px;
    text-align: center;
    transition: all var(--transition-normal);
    cursor: grab;
    user-select: none;
    text-decoration: none;
    display: block;
}

.obs-drag-container:hover {
    background: rgba(99, 102, 241, 0.12);
    border-color: var(--accent-hover);
    transform: translateY(-2px);
}

.obs-drag-container:active {
    cursor: grabbing;
}

.obs-drag-icon {
    font-size: 2rem;
    margin-bottom: 12px;
    display: block;
}

.obs-drag-text {
    font-weight: 600;
    color: var(--accent);
    font-size: 1rem;
}

.instruction-step {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.step-number {
    width: 24px;
    height: 24px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.step-content {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.obs-warning {
    background: var(--warning-subtle);
    border: 1px solid rgba(202, 138, 4, 0.2);
    color: var(--warning);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    margin-top: 24px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.obs-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 40px 0;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.obs-divider::before,
.obs-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px dashed var(--border-default);
}

.obs-divider::before {
    margin-right: 16px;
}

.obs-divider::after {
    margin-left: 16px;
}

/* --- Auth Header & Brand --- */
.auth-header {
    text-align: center;
    margin-bottom: 40px;
    animation: fadeInDown 0.6s ease-out;
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-decoration: none;
    transition: transform var(--transition-normal);
}

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

.auth-logo img {
    width: 52px;
    height: 52px;
    filter: drop-shadow(0 4px 6px rgba(99, 102, 241, 0.2));
}

.auth-logo span {
    font-family: 'Baloo 2', cursive;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-heading);
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--accent), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dashboard Redesign - Control Center */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-default);
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.status-badge.live {
  color: var(--success);
  border-color: rgba(34, 197, 94, 0.2);
}

.status-badge .pulse-dot {
  width: 8px;
  height: 8px;
  background: currentColor;
  border-radius: 50%;
}

.status-badge.live .pulse-dot {
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-tile {
  padding: 14px 18px;
  background: var(--bg-default);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}

.stat-tile .tile-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: block;
}

.stat-tile .tile-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-heading);
}

.control-center-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
}

@media (max-width: 992px) {
  .control-center-grid { grid-template-columns: 1fr; }
}

.action-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 24px;
  background: linear-gradient(135deg, var(--accent) 0%, #4338ca 100%);
  border-radius: var(--radius-lg);
  color: white;
  text-decoration: none;
  transition: transform var(--transition-base), box-shadow var(--transition-base);
  min-height: 130px;
}

.action-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px -8px rgba(99, 102, 241, 0.5);
}

.action-card:hover p {
  opacity: 1;
}

.action-card h3 {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 4px;
  color: white;
}

.action-card p {
  font-size: 0.875rem;
  opacity: 0.8;
  line-height: 1.4;
  transition: opacity var(--transition-fast);
}

.action-card .arrow-icon {
  align-self: flex-end;
  background: rgba(255, 255, 255, 0.2);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.team-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 992px) {
  .team-grid { grid-template-columns: 1fr; }
}

.team-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
}

.team-card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-default);
}

.team-card-content {
  padding: 24px;
  flex: 1;
}

.roster-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-default);
}

.roster-item:last-child {
  border-bottom: none;
}

.integration-card {
  padding: 24px;
  background: var(--bg-default);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
}

/* OBS Link Expansion */
.obs-link-container {
  max-height: 24px;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  margin-bottom: 16px;
}

.obs-link-container.expanded {
  max-height: 200px;
}

.obs-link-value {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-heading);
  word-break: break-all;
  line-height: 1.5;
}

/* Broadcast Station - Premium Controls */
.broadcast-console {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
  height: 48px;
}

.console-label {
  padding: 0 12px;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  border-right: 1px solid var(--border-default);
  height: 24px;
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.console-field {
  flex: 1;
  padding: 0 12px;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.console-actions {
  display: flex;
  gap: 2px;
}

.btn-console {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-console:hover {
  background: var(--bg-elevated);
  color: var(--accent);
}

.btn-launch-studio {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  height: 48px;
  background: linear-gradient(90deg, var(--accent) 0%, #4f46e5 100%);
  color: white;
  border-radius: var(--radius-md);
  font-weight: 700;
  text-decoration: none;
  transition: all var(--transition-normal);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.btn-launch-studio:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
  color: white;
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-default);
  margin-bottom: 20px;
  overflow: hidden;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
}

.status-item .item-label {
  color: var(--text-muted);
  font-weight: 500;
}

.status-item .item-value {
  color: var(--text-heading);
  font-weight: 700;
}

/* No-Jump Console Field */
.console-field {
  flex: 1;
  padding: 0 12px;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-heading);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none; /* Firefox */
  display: flex;
  align-items: center;
}

.console-field::-webkit-scrollbar {
  display: none; /* Safari and Chrome */
}

/* Ensure broadcast-console does not grow */
.broadcast-console {
  max-height: 48px;
  overflow: hidden;
}

/* Setup Guide Accordion */
.setup-guide {
  margin-top: 16px;
  border-top: 1px solid var(--border-default);
  padding-top: 16px;
}

.setup-guide-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  transition: opacity var(--transition-fast);
}

.setup-guide-toggle:hover {
  opacity: 0.8;
}

.setup-guide-content {
  display: none;
  margin-top: 12px;
  padding: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  animation: slideDown 0.2s ease-out;
}

.setup-guide-content.active {
  display: block;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Compact Drag Helper */
.obs-drag-compact {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin-top: 4px;
  background: var(--bg-elevated);
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.obs-drag-compact:hover {
  border-color: var(--accent);
  background: var(--bg-surface);
  transform: translateY(-1px);
}

.obs-drag-compact-icon { font-size: 1.25rem; }
.obs-drag-compact-text { font-size: 0.8125rem; font-weight: 600; color: var(--text-heading); }

/* Rack-Mount Control Panel */
.control-rack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 600px; /* More compact width for better focus */
}

.rack-row {
  height: 48px;
  display: flex;
  align-items: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  overflow: hidden;
  transition: all var(--transition-fast);
}

.rack-row:hover {
  border-color: var(--accent);
}

.rack-label {
  height: 100%;
  padding: 0 16px;
  display: flex;
  align-items: center;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-primary);
  border-right: 1px solid var(--border-default);
  min-width: 120px;
}

.rack-content {
  flex: 1;
  padding: 0 16px;
  height: 100%;
  display: flex;
  align-items: center;
  font-size: 0.8125rem;
}

.rack-actions {
  display: flex;
  gap: 0;
  height: 100%;
  border-left: 1px solid var(--border-default);
}

.btn-rack {
  width: 48px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-left: 1px solid var(--border-default);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-rack:first-child { border-left: none; }

.btn-rack:hover {
  background: var(--bg-elevated);
  color: var(--accent);
}

.rack-row-launch {
  background: linear-gradient(90deg, #6366f1 0%, #4f46e5 100%);
  border: none;
  justify-content: center;
  color: white;
  text-decoration: none;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.rack-row-launch:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(99, 102, 241, 0.3);
  color: white;
}

/* 2x2 Command Grid */
.control-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  width: 100%;
  min-width: 0;
}

.control-module {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 140px;
  min-width: 0;
  overflow: hidden;
  transition: all var(--transition-fast);
}

.control-module:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.module-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.module-title {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.module-body {
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
  overflow: hidden;
}

.module-footer {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Specific Module Overrides */
.module-launch {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(79, 70, 229, 0.05) 100%);
  border-color: rgba(99, 102, 241, 0.2);
}

.btn-launch-grid {
  width: 100%;
  height: 48px;
  background: linear-gradient(90deg, #6366f1 0%, #4f46e5 100%);
  color: white;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 16px;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  transition: all var(--transition-bounce);
}

.btn-launch-grid:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
  color: white;
}

/* Compact Console for Grid */
.grid-console {
  display: flex;
  background: var(--bg-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 40px;
}

/* --- Step-Based Dashboard Modules --- */
.step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 7px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.25);
}

.module-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-top: 4px;
}

/* "or" divider between alternative modules */
.step-or-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    grid-column: 1 / -1;
    gap: 12px;
    padding: 2px 0;
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.step-or-divider::before,
.step-or-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-default);
}

/* Security footer — de-emphasized, below the grid */
.security-footer {
    margin-top: 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    transition: all var(--transition-fast);
}

.security-footer:hover {
    border-color: var(--border-default);
}

.security-footer-info {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.security-footer-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(239, 68, 68, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--danger, #f85149);
}

.security-footer-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.security-footer-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-heading);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.security-footer-desc {
    font-size: 0.6875rem;
    color: var(--text-muted);
    line-height: 1.4;
}


/* --- Sorting & Pagination --- */
.sort-link {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: color var(--transition-fast);
}

.sort-link:hover {
  color: var(--accent);
}

.sort-link.active {
  color: var(--text-heading);
  font-weight: 700;
}

/* Pagy Pagination Styles */
.pagy {
  /* PagyWand Generated Variables */
  --B: 1;
  --H: 214.83;
  --S: 40%;
  --L: 70%;
  --A: 1;
  --spacing: 0.125rem;
  --padding: 0.75rem;
  --rounding: 1.125rem;
  --border-width: 0rem;
  --font-size: 0.875rem;
  --font-weight: 450;
  --line-height: 1.75;

  /* Calculated Color Variables */
  --text:               hsl(var(--H) var(--S) calc(var(--L) - (25% * var(--B))) / var(--A));
  --text-hover:         hsl(var(--H) var(--S) calc(var(--L) - (30% * var(--B))) / var(--A));
  --text-current:       hsl(var(--H) var(--S) calc(100% * (var(--B) + 1)) / var(--A));
  --background:         hsl(var(--H) var(--S) calc(var(--L) + (30% * var(--B))) / var(--A));
  --background-hover:   hsl(var(--H) var(--S) calc(var(--L) + (20% * var(--B))) / var(--A));
  --background-current: hsl(var(--H) var(--S) var(--L) / var(--A));
  --background-input:   hsl(var(--H) var(--S) calc(var(--L) + (45% * var(--B))) / var(--A));

  /* Base Properties */
  color: var(--text);
  font-size: var(--font-size);
  line-height: var(--line-height);
  font-weight: var(--font-weight);
  display: flex;
}

/* Element Rules */

.pagy > :not([hidden]) ~ :not([hidden]) {
  margin-inline-start: var(--spacing);
}

.pagy a:not([role="separator"]) { /* all but gaps */
  display: block;
  text-decoration: none;
  background-color: var(--background);
  padding: calc(var(--padding) / 3) var(--padding);
  border: var(--border-width) solid var(--background-current);
  border-radius: var(--rounding);
  color: inherit;
}

.pagy a[href]:hover { /* all links on hover */
  background-color: var(--background-hover);
  color: var(--text-hover)
}

.pagy a:not([href]) { /* all but links */
  cursor: default;
}

.pagy a[role="link"]:not([aria-current]) { /* disabled links */
  opacity: .6;
}

.pagy a[aria-current] {  /* current page */
  background-color: var(--background-current);
  color: var(--text-current);
  border-color: var(--text);
}

.pagy label {
  white-space: nowrap;
  display: inline-block;
  border: var(--border-width) solid var(--background-current);
  border-radius: var(--rounding);
  background-color: var(--background);
  padding: calc((var(--padding) / 3) - var(--border-width)) var(--padding);
}

.pagy label input {
  all: unset;
  border: var(--border-width) solid var(--background-current);
  border-radius: calc(var(--rounding) / 2) !important;
  background-color: var(--background-input);
}
