/* ═══════════════════════════════════════════════════════════════════════════
   Tunedin Assignment Checker — ZeroToTrust Edition
   Palette: Sky Blue → Purple → Magenta (from logo gradient)
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    /* Primary palette — purple center of the shield gradient */
    --primary:        #7C3AED;
    --primary-light:  #A78BFA;
    --primary-lighter: #C4B5FD;
    --primary-pale:   #EDE9FE;
    --primary-dark:   #6D28D9;
    --primary-darker: #5B21B6;

    /* Accent — magenta from the bottom of the shield */
    --accent:         #D946EF;
    --accent-light:   #E879F9;

    /* Secondary — sky blue from the top of the shield */
    --secondary:      #38BDF8;
    --secondary-dark: #0EA5E9;

    /* Neutrals */
    --bg:             #F5F3FF;
    --surface:        #ffffff;
    --surface-hover:  #FAF5FF;
    --border:         #E5E1F0;
    --border-light:   #EDE9FE;
    --text:           #1E1B2E;
    --text-secondary: #6B6F82;
    --text-muted:     #9EA2B3;

    /* Semantic */
    --include-bg:     #E6F9ED;
    --include-text:   #1A7A3A;
    --exclude-bg:     #FDE8E8;
    --exclude-text:   #B52A2A;

    /* Layout */
    --sidebar-width:  340px;
    --header-height:  60px;
    --radius:         10px;
    --radius-sm:      6px;

    /* Shadows */
    --shadow-sm:      0 1px 3px rgba(124, 58, 237, 0.06);
    --shadow-md:      0 4px 12px rgba(124, 58, 237, 0.10);
    --shadow-lg:      0 8px 30px rgba(124, 58, 237, 0.14);

    /* Header gradient — matches ZeroToTrust shield */
    --header-gradient: linear-gradient(135deg, #38BDF8 0%, #818CF8 40%, #A855F7 70%, #D946EF 100%);

    /* Focus ring */
    --focus-ring:     rgba(124, 58, 237, 0.12);
}

/* ── Dark Mode ──────────────────────────────────────────────────────────── */

[data-theme="dark"] {
    --bg:             #0F0D1A;
    --surface:        #1A1726;
    --surface-hover:  #231F33;
    --border:         #2E2A40;
    --border-light:   #37325A;
    --text:           #F1F0F7;
    --text-secondary: #A09CB3;
    --text-muted:     #706C85;

    --primary-pale:   #2D2250;
    --primary-lighter: #6D5EAD;

    --include-bg:     #0D2818;
    --include-text:   #4ADE80;
    --exclude-bg:     #2D0F0F;
    --exclude-text:   #FCA5A5;

    --shadow-sm:      0 1px 3px rgba(0, 0, 0, 0.30);
    --shadow-md:      0 4px 12px rgba(0, 0, 0, 0.40);
    --shadow-lg:      0 8px 30px rgba(0, 0, 0, 0.50);

    --focus-ring:     rgba(167, 139, 250, 0.20);
}

/* ── Reset & Base ────────────────────────────────────────────────────────── */

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    transition: background 0.3s, color 0.3s;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: var(--header-gradient);
    color: #fff;
    box-shadow: 0 2px 16px rgba(124, 58, 237, 0.30);
}

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

.app-header h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.connection-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    backdrop-filter: blur(4px);
}

/* Header pill buttons (shared style for dark mode toggle, logout) */
.btn-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 20px;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: background 0.2s, border-color 0.2s;
}

.btn-header:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.40);
}

.btn-header.active {
    background: rgba(255, 255, 255, 0.28);
    border-color: rgba(255, 255, 255, 0.50);
}

.btn-header:not(.active) {
    opacity: 0.55;
}

.btn-header svg {
    flex-shrink: 0;
}

.badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #facc15;
    animation: pulse-dot 1.8s infinite;
}

.badge-dot.connected {
    background: #4ade80;
    animation: none;
}

.badge-dot.error {
    background: #f87171;
    animation: none;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ── Layout ──────────────────────────────────────────────────────────────── */

.app-layout {
    display: flex;
    height: calc(100vh - var(--header-height));
    margin-top: var(--header-height);
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: background 0.3s, border-color 0.3s;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 0;
}

.sidebar-header h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.group-count {
    font-size: 11px;
    font-weight: 600;
    background: var(--primary-pale);
    color: var(--primary-light);
    padding: 2px 8px;
    border-radius: 10px;
}

.btn-filter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-filter:hover {
    border-color: var(--primary-lighter);
    color: var(--primary-light);
    background: var(--surface-hover);
}

.btn-filter.active {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.search-box {
    position: relative;
    padding: 14px 20px;
}

.search-icon {
    position: absolute;
    left: 32px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 9px 12px 9px 36px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.3s;
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

/* Group list */
.group-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    padding: 0 12px 12px;
}

.group-list::-webkit-scrollbar {
    width: 5px;
}

.group-list::-webkit-scrollbar-thumb {
    background: var(--primary-lighter);
    border-radius: 10px;
}

.group-item {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1.5px solid transparent;
    margin-bottom: 2px;
}

.group-item:hover {
    background: var(--surface-hover);
    border-color: var(--border-light);
}

.group-item.active {
    background: var(--primary-pale);
    border-color: var(--primary-lighter);
}

.group-item-header {
    display: flex;
    align-items: center;
    gap: 2px;
}

.group-item-header .group-item-copy {
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.2s;
}

.group-item:hover .group-item-header .group-item-copy {
    opacity: 1;
}

.group-item-header .btn-copy {
    width: 22px;
    height: 22px;
}

.group-item-name {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.group-item.active .group-item-name {
    color: var(--primary-light);
    font-weight: 600;
}

.group-item-desc {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Synthetic group items (All Devices / All Users) */
.group-item-synthetic {
    background: var(--primary-pale);
    border-color: var(--border-light);
}

.group-item-synthetic .group-item-name {
    display: flex;
    align-items: center;
    gap: 6px;
}

.group-item-synthetic .group-item-name svg {
    flex-shrink: 0;
    color: var(--primary-light);
}

.group-item-synthetic.active {
    background: var(--primary);
    border-color: var(--primary-dark);
}

.group-item-synthetic.active .group-item-name {
    color: #fff;
}

.group-item-synthetic.active .group-item-name svg {
    color: #fff;
}

.group-item-synthetic.active .group-item-desc {
    color: rgba(255, 255, 255, 0.7);
}

.group-list-separator {
    height: 1px;
    background: var(--border);
    margin: 8px 4px;
    list-style: none;
}

.group-item-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.group-item-type {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--primary-pale);
    color: var(--primary-light);
}

.group-item-count {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--include-bg);
    color: var(--include-text);
}

/* Count filter */
.count-filter {
    padding: 0 20px 8px;
}

.btn-count-filter {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 7px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-count-filter:hover {
    border-color: var(--primary-lighter);
    color: var(--primary-light);
}

.btn-count-filter.active {
    border-color: var(--primary);
    background: var(--primary-pale);
    color: var(--primary);
}

.count-filter-panel {
    margin-top: 8px;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.count-filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.count-filter-row label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.count-filter-row input {
    width: 70px;
    padding: 5px 8px;
    border: 1.5px solid var(--border);
    border-radius: 4px;
    font-size: 12px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: border-color 0.2s;
}

.count-filter-row input:focus {
    border-color: var(--primary);
}

.count-filter-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.btn-count-apply, .btn-count-clear {
    padding: 5px 14px;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-count-apply:hover {
    background: var(--primary-dark);
}

.btn-count-clear {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-count-clear:hover {
    background: var(--surface-hover);
}

/* Sidebar loading / error */
.sidebar-loading, .sidebar-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 12px;
    color: var(--text-muted);
    font-size: 13px;
    padding: 20px;
    text-align: center;
}

.sidebar-error svg {
    color: #f87171;
}

.btn-retry {
    padding: 6px 16px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
}

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

/* ── Main Content ────────────────────────────────────────────────────────── */

.content {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
    transition: background 0.3s;
}

.content::-webkit-scrollbar {
    width: 6px;
}

.content::-webkit-scrollbar-thumb {
    background: var(--primary-lighter);
    border-radius: 10px;
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-muted);
}

.empty-icon {
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-pale);
    border-radius: 50%;
    margin-bottom: 20px;
    color: var(--primary-lighter);
}

.empty-state h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 14px;
    max-width: 320px;
}

/* Content loading */
.content-loading, .content-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 16px;
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
}

.content-error svg {
    color: #f87171;
}

/* ── Spinner ─────────────────────────────────────────────────────────────── */

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--primary-pale);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.spinner.large {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Assignments Header ──────────────────────────────────────────────────── */

.assignments-header {
    margin-bottom: 20px;
}

.assignments-header-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.assignments-header h2 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    display: inline;
}

.assignments-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Copy button */
.btn-copy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    vertical-align: middle;
}

.btn-copy:hover {
    background: var(--surface-hover);
    border-color: var(--border);
    color: var(--text-secondary);
}

.btn-copy.copied {
    color: var(--success);
}

/* Copy buttons in assignment header */
.btn-copy-name,
.btn-copy-desc {
    margin-left: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.assignments-header-top:hover .btn-copy-name,
.assignments-header-top:hover .btn-copy-desc,
.btn-copy-name.copied,
.btn-copy-desc.copied {
    opacity: 1;
}

/* Dynamic membership rule */
.membership-rule {
    margin-top: 8px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    flex-wrap: wrap;
}

.membership-rule-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 3px 6px;
    background: var(--surface-hover);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    line-height: 1.4;
}

.membership-rule-query {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    word-break: break-all;
    line-height: 1.5;
    flex: 1;
    min-width: 0;
}

.membership-rule .btn-copy {
    margin-top: 1px;
}

/* Copy button in card */
.card-actions .btn-copy {
    opacity: 0;
    transition: opacity 0.2s;
}

.assignment-card:hover .card-actions .btn-copy {
    opacity: 1;
}

.assignments-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.btn-export {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-export:hover {
    border-color: var(--primary-lighter);
    background: var(--primary-pale);
    color: var(--primary);
}

/* ── Category Tabs ───────────────────────────────────────────────────────── */

.category-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 24px;
    padding-bottom: 2px;
    overflow-x: auto;
    flex-wrap: wrap;
}

.tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tab:hover {
    border-color: var(--primary-lighter);
    color: var(--primary-light);
    background: var(--surface-hover);
}

.tab.active {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-md);
}

.tab.active svg {
    stroke: #fff;
}

.tab-count {
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    background: var(--primary-pale);
    color: var(--primary-light);
}

.tab.active .tab-count {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

/* ── Card Grid ───────────────────────────────────────────────────────────── */

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 14px;
}

/* ── Assignment Card ─────────────────────────────────────────────────────── */

.assignment-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.assignment-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--secondary) 0%, var(--primary) 50%, var(--accent) 100%);
    border-radius: 4px 0 0 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.assignment-card:hover {
    border-color: var(--primary-lighter);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.assignment-card:hover::before {
    opacity: 1;
}

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

.card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
    line-height: 1.4;
}

.card-name a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
}

.card-name a:hover {
    color: var(--primary-light);
}

.card-name a .link-icon {
    display: inline;
    margin-left: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    vertical-align: middle;
}

.assignment-card:hover .card-name a .link-icon {
    opacity: 0.6;
}

.card-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.btn-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-hover);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-preview:hover {
    background: var(--primary-pale);
    border-color: var(--primary-lighter);
    color: var(--primary);
}

.card-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 5px;
    letter-spacing: 0.02em;
}

.badge-include {
    background: var(--include-bg);
    color: var(--include-text);
}

.badge-exclude {
    background: var(--exclude-bg);
    color: var(--exclude-text);
}

.badge-intent {
    background: var(--primary-pale);
    color: var(--primary-light);
}

.badge-filter {
    background: #fef3c7;
    color: #92400e;
}

[data-theme="dark"] .badge-filter {
    background: #422006;
    color: #FCD34D;
}

/* Category error banner */
.category-error-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: var(--exclude-bg);
    color: var(--exclude-text);
    border: 1px solid currentColor;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.4;
}

.category-error-banner svg {
    flex-shrink: 0;
}

/* Category empty */
.category-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
    gap: 12px;
}

.category-empty svg {
    color: var(--primary-lighter);
}

/* ── Script Preview Modal ───────────────────────────────────────────────── */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(15, 13, 26, 0.6);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.modal-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 8px;
    font-weight: 400;
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn-copy-script {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-hover);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-copy-script:hover {
    background: var(--primary-pale);
    border-color: var(--primary-lighter);
    color: var(--primary);
}

.btn-copy-script.copied {
    background: var(--primary-pale);
    border-color: var(--primary-lighter);
    color: var(--primary);
}

.btn-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}

.btn-modal-close:hover {
    background: var(--primary-pale);
    color: var(--text);
}

.modal-body {
    overflow-y: auto;
    padding: 16px 20px;
    flex: 1;
}

.modal-body pre {
    font-family: 'Cascadia Code', 'Fira Code', 'SF Mono', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 16px;
    border: 1px solid var(--border);
}

.modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
    gap: 12px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
    :root {
        --sidebar-width: 260px;
    }

    .app-header h1 {
        font-size: 15px;
    }

    .content {
        padding: 20px 18px;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        min-width: 100%;
        max-height: 45vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .content {
        flex: 1;
        min-height: 0;
    }

    .category-tabs {
        flex-wrap: nowrap;
    }
}

/* ── Setup Screen (SPA mode) ─────────────────────────────────────────────── */

.setup-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background: var(--bg);
}

.setup-card {
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 36px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.setup-logo {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-pale);
    border-radius: 50%;
    margin: 0 auto 20px;
}

.setup-card h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.setup-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 28px;
}

.setup-form {
    text-align: left;
}

.setup-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.setup-input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    margin-bottom: 16px;
}

.setup-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.setup-input::placeholder {
    color: var(--text-muted);
}

.setup-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--header-gradient);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: opacity 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-md);
    margin-top: 4px;
}

.setup-btn:hover {
    opacity: 0.92;
    box-shadow: var(--shadow-lg);
}

.setup-hint {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 14px;
    line-height: 1.5;
}

.setup-help {
    text-align: left;
    margin-top: 24px;
    border-top: 1px solid var(--border);
    padding-top: 20px;
}

.setup-help summary {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-light);
    cursor: pointer;
    padding: 4px 0;
    transition: color 0.2s;
}

.setup-help summary:hover {
    color: var(--primary);
}

.setup-help ol {
    margin-top: 12px;
    padding-left: 20px;
    font-size: 12.5px;
    color: var(--text-secondary);
    line-height: 1.8;
}

.setup-help ul {
    margin-top: 4px;
    padding-left: 18px;
    font-size: 12px;
    color: var(--text-muted);
}

.setup-help code {
    font-size: 11.5px;
    background: var(--primary-pale);
    color: var(--primary-light);
    padding: 1px 5px;
    border-radius: 3px;
    word-break: break-all;
}
