/* Import Inter font */
@import url('https://rsms.me/inter/inter.css');

:root {
    /* Dark theme (primary) - Pure black minimalist */
    color-scheme: dark;
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --surface: #141414;
    --surface-hover: #1a1a1a;
    --border: #262626;
    --border-strong: #404040;
    
    /* Green emerald accent */
    --primary: #10b981;
    --primary-hover: #059669;
    --primary-soft: rgba(16, 185, 129, 0.1);
    --primary-text: #000000;
    
    /* Text hierarchy */
    --text-primary: #fafafa;
    --text-secondary: #a3a3a3;
    --text-tertiary: #737373;
    
    /* Semantic colors */
    --success: #10b981;
    --success-soft: rgba(16, 185, 129, 0.1);
    --error: #ef4444;
    --error-soft: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --warning-soft: rgba(245, 158, 11, 0.1);
    --info: #06b6d4;
    --info-soft: rgba(6, 182, 212, 0.1);
    
    /* Shadows - minimal */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3);
    
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, monospace;
    --text-xs: 0.6875rem;
    --text-sm: 0.8125rem;
    --text-base: 0.875rem;
    --text-lg: 1rem;
    --text-xl: 1.125rem;
    --text-2xl: 1.25rem;
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    
    /* Spacing scale (8px base) */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-12: 3rem;
    
    /* Border radius - minimalist */
    --radius-sm: 3px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-full: 9999px;
    
    /* Layout */
    --header-height: 36px;
    --content-max-width: 1600px;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;
    
    /* Overlay */
    --overlay: rgba(0, 0, 0, 0.7);
    
    /* Legacy compatibility */
    --bg: var(--bg-primary);
    --text: var(--text-primary);
    --text-muted: var(--text-secondary);
    --text-subtle: var(--text-tertiary);
    --radius: var(--radius-lg);
    --radius-sm: var(--radius-md);
    --font: var(--font-sans);
    --shadow: var(--shadow-md);
    --input-bg: var(--bg-secondary);
    --chip-bg: var(--surface);
    --danger: var(--error);
    --danger-soft: var(--error-soft);
}

/* Light theme (optional) */
html[data-theme="light"] {
    color-scheme: light;
    --bg-primary: #ffffff;
    --bg-secondary: #fafafa;
    --surface: #f5f5f5;
    --surface-hover: #e5e5e5;
    --border: #e5e5e5;
    --border-strong: #d4d4d4;
    
    --text-primary: #0a0a0a;
    --text-secondary: #525252;
    --text-tertiary: #737373;
    
    --primary-text: #ffffff;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    
    --overlay: rgba(0, 0, 0, 0.5);
    
    --input-bg: #ffffff;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.4;
    font-size: var(--text-base);
    font-weight: var(--font-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv11', 'ss01'; /* Inter alternate glyphs */
    min-height: 100vh;
}

body.is-drawer-open {
    overflow: hidden;
}

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

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

code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    padding: 1px 6px;
    border-radius: 5px;
    color: var(--text);
    word-break: break-all;
}

/* ============ APP SHELL ============ */
.app-shell {
    display: flex;
    min-height: 100vh;
    background: var(--bg-primary);
}

/* Compact Sidebar - Icons Only */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 60px;
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow: visible;
    transition: transform var(--transition-base);
}

.sidebar-header {
    padding: var(--space-2);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: center;
}

.sidebar-logo {
    display: block;
    text-decoration: none;
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-3) 0;
    overflow: visible;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.sidebar-item {
    width: 42px;
    height: 42px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
    position: relative;
    background: transparent;
    border: none;
    cursor: pointer;
}

.sidebar-item:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.sidebar-item.active {
    background: var(--primary-soft);
    color: var(--primary);
}

.sidebar-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: var(--primary);
    border-radius: 0 2px 2px 0;
}

/* Sidebar Tooltip — immediate label to the right of the icon bar */
.sidebar-item::after {
    content: attr(aria-label);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--surface-hover);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    line-height: 1.2;
    letter-spacing: 0.01em;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    border: 1px solid var(--border-strong);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
    z-index: 2000;
    transition: opacity 0.08s ease, visibility 0.08s ease;
}

@media (hover: hover) and (pointer: fine) {
    .sidebar-item:hover::after,
    .sidebar-item:focus-visible::after {
        opacity: 1;
        visibility: visible;
    }
}

.sidebar-item:focus-visible::after {
    opacity: 1;
    visibility: visible;
}

.sidebar-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: var(--space-3) 0;
    border-top: 1px solid var(--border);
    overflow: visible;
}

/* Main Area - with top bar */
.main-area {
    flex: 1;
    margin-left: 60px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Top Bar with Tabs */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 90;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    height: 36px;
}

.top-bar-left {
    display: none; /* Hidden on desktop, shown on mobile */
    align-items: center;
    gap: var(--space-3);
    padding: 0 var(--space-4);
}

.mobile-menu-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
}

.top-bar-title {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
}

/* Tabs Bar - Browser-style */
.tabs-bar {
    flex: 1;
    display: flex;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
}

.tabs-bar::-webkit-scrollbar {
    display: none;
}

.tab-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0 var(--space-3);
    height: 36px;
    border-right: 1px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    white-space: nowrap;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    min-width: 120px;
    max-width: 200px;
}

.tab-item:hover {
    background: var(--surface);
    color: var(--text-primary);
}

.tab-item.active {
    background: var(--bg-primary);
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}

.tab-item[data-dirty="true"] .tab-title::after {
    content: ' •';
    color: var(--warning);
}

.tab-title {
    user-select: none;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tab-close {
    width: 18px;
    height: 18px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.tab-item:hover .tab-close {
    opacity: 1;
}

.tab-close:hover {
    background: var(--error-soft);
    color: var(--error);
}

.tab-new {
    width: 32px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-right: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.tab-new:hover {
    background: var(--surface);
    color: var(--primary);
}

/* Tab Context Menu */
.tab-context-menu {
    position: fixed;
    min-width: 168px;
    width: max-content;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    padding: 4px;
    z-index: 9999;
}

.context-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--space-2);
    padding: 5px 8px;
    min-height: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: var(--font-medium);
    text-align: left;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.context-menu-item span {
    text-align: left;
}

.context-menu-item:hover {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: transparent;
}

.context-menu-item svg {
    flex-shrink: 0;
    color: var(--text-secondary);
}

.context-menu-item:hover svg {
    color: var(--primary);
}

.top-bar-actions {
    display: flex;
    align-items: center;
    padding: 0 var(--space-3);
}

.theme-toggle-top {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.theme-toggle-top:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

/* Mobile overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
}

.sidebar-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

/* Main content area */
.app-main {
    flex: 1;
    min-width: 0;
}

.content-wrapper {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 12px 16px;
}

/* Page header (inside content) */
.page-header {
    margin-bottom: var(--space-8);
}

.page-title {
    margin: 0 0 var(--space-2);
    font-size: var(--text-2xl);
    font-weight: var(--font-semibold);
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.page-subtitle {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-weight: var(--font-normal);
}

/* Legacy topbar styles (for compatibility) */
.page-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.page-topbar__left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
    flex: 1;
}

.page-topbar__titles {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
}

.project-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.project-meta__item {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    margin: 0;
    height: 22px;
    padding: 0 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    line-height: 20px;
    max-width: 100%;
}

.project-meta dt {
    margin: 0;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-tertiary);
}

.project-meta dd {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-meta__ok {
    color: var(--success);
}

.project-empty {
    margin-top: 8px;
    padding: 16px 14px;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
}

.project-empty p {
    margin: 0 0 10px;
    font-size: 13px;
    color: var(--text-secondary);
}

.page-topbar__title {
    margin: 0;
    font-size: var(--text-xl);
    font-weight: var(--font-semibold);
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.page-topbar__subtitle {
    margin: var(--space-1) 0 0;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-weight: var(--font-normal);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
}

.page-topbar__subtitle:has(.project-meta) {
    margin: 0;
}

.page-topbar__subtitle code {
    font-size: 0.9em;
    font-family: var(--font-mono);
    background: var(--surface);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

.page-topbar__actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.page-topbar__actions a.secondary,
.page-topbar__actions a.primary,
.page-topbar__actions button.secondary,
.page-topbar__actions button.primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    text-decoration: none;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.page-topbar__actions a.secondary,
.page-topbar__actions button.secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.page-topbar__actions a.secondary:hover,
.page-topbar__actions button.secondary:hover {
    background: var(--surface-hover);
}

.page-topbar__actions a.primary,
.page-topbar__actions button.primary {
    background: var(--primary);
    color: var(--primary-text);
    border: 1px solid var(--primary);
}

.page-topbar__actions a.primary:hover,
.page-topbar__actions button.primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* Legacy container */
.container {
    width: 100%;
    margin: 0;
}

/* ============ FLOATING TASK PANEL ============ */
.task-panel {
    position: fixed;
    right: var(--space-4);
    bottom: var(--space-4);
    width: 36px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    overflow: hidden;
}

.task-panel:hover,
.task-panel:focus-within,
.task-panel.is-open {
    width: 248px;
}

.task-panel-body {
    display: none;
    max-height: 280px;
    overflow-y: auto;
    border-top: 1px solid var(--border);
}

.task-panel:hover .task-panel-body,
.task-panel:focus-within .task-panel-body,
.task-panel.is-open .task-panel-body {
    display: block;
}

.task-panel-header {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0;
    cursor: default;
    user-select: none;
}

.task-panel:hover .task-panel-header,
.task-panel:focus-within .task-panel-header,
.task-panel.is-open .task-panel-header {
    justify-content: flex-start;
    padding: 0 10px;
}

.task-panel-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: var(--font-medium);
    color: var(--text-secondary);
}

.task-panel-title span:not(.task-count) {
    display: none;
}

.task-panel:hover .task-panel-title span:not(.task-count),
.task-panel:focus-within .task-panel-title span:not(.task-count),
.task-panel.is-open .task-panel-title span:not(.task-count) {
    display: inline;
}

.task-panel-title svg {
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.task-panel.has-tasks .task-panel-title svg {
    color: var(--primary);
}

.task-count {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    background: var(--primary);
    color: var(--primary-text);
    border-radius: var(--radius-full);
    font-size: 9px;
    font-weight: var(--font-semibold);
    line-height: 1;
}

.task-panel.has-tasks .task-count {
    display: inline-flex;
    position: absolute;
    top: 4px;
    right: 4px;
}

.task-panel.has-tasks:hover .task-count,
.task-panel.has-tasks:focus-within .task-count,
.task-panel.has-tasks.is-open .task-count {
    position: static;
}

.task-list {
    display: flex;
    flex-direction: column;
}

.task-item {
    display: block;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

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

.task-item:hover {
    background: var(--surface-hover);
}

.task-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.task-item-title {
    flex: 1;
    min-width: 0;
}

.task-item-name {
    display: block;
    font-size: 12px;
    font-weight: var(--font-medium);
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-item-project {
    display: block;
    font-size: 10px;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-item-status {
    flex-shrink: 0;
}

.task-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: var(--font-medium);
    color: var(--text-tertiary);
}

.task-status-badge--running {
    color: var(--info);
}

.task-status-badge--running::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s infinite;
}

.task-status-badge--queued {
    color: var(--text-tertiary);
}

.task-status-badge--paused,
.task-status-badge--stopping {
    color: var(--warning, var(--text-secondary));
}

.task-status-badge--success {
    color: var(--success);
}

.task-status-badge--error {
    color: var(--error);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.task-item-progress {
    margin-top: 6px;
}

.task-progress-bar {
    height: 2px;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.task-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

.task-item-meta {
    margin-top: 4px;
    font-size: 10px;
    color: var(--text-tertiary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-item-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: var(--font-medium);
}

.task-item-link:hover {
    text-decoration: underline;
}

.task-empty {
    padding: 10px;
    font-size: 12px;
    color: var(--text-tertiary);
}

/* Touch: keep a tap target; hover devices open instantly */
@media (hover: none) {
    .task-panel.is-open {
        width: 248px;
    }
}

@media (max-width: 640px) {
    .task-panel,
    .task-panel:hover,
    .task-panel:focus-within,
    .task-panel.is-open {
        right: var(--space-3);
        bottom: var(--space-3);
    }

    .task-panel.is-open {
        left: var(--space-3);
        width: auto;
    }
}


/* ============ FLASH ============ */
.flash-stack {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.flash {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 10px;
}

.flash::before {
    font-size: 1rem;
    line-height: 1;
}

.flash-success {
    background: var(--success-soft);
    color: var(--success);
    border-color: rgba(4, 120, 87, 0.2);
}

.flash-success::before {
    content: "✓";
}

.flash-error {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: rgba(185, 28, 28, 0.2);
}

.flash-error::before {
    content: "!";
    font-weight: 700;
}

.flash-warning {
    background: var(--warning-soft);
    color: var(--warning);
    border-color: rgba(146, 64, 14, 0.2);
}

.flash-warning::before {
    content: "!";
    font-weight: 700;
}

.flash-info {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: rgba(37, 99, 235, 0.2);
}

.flash-info::before {
    content: "i";
    font-weight: 700;
    font-style: italic;
}

/* ============ PANEL ============ */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    margin-bottom: 10px;
}

.panel + .panel {
    margin-top: 0;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-3);
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.panel-header h2 {
    margin: 0;
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.panel-header .hint {
    margin: var(--space-1) 0 0;
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: var(--font-normal);
}

.panel h3 {
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    margin: var(--space-6) 0 var(--space-3);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

/* ============ FORM ============ */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--space-4);
}

label {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-weight: var(--font-medium);
}

label.checkbox,
label.inline {
    flex-direction: row;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-primary);
    font-weight: var(--font-normal);
    cursor: pointer;
    user-select: none;
}

input[type="text"],
input[type="url"],
input[type="number"],
input[type="file"],
input[type="password"],
select,
textarea {
    font: inherit;
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: var(--text-sm);
    transition: all var(--transition-fast);
}

input[type="text"]:hover,
input[type="url"]:hover,
input[type="number"]:hover,
input[type="password"]:hover,
select:hover,
textarea:hover {
    border-color: var(--border-strong);
}

input[type="text"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

input[readonly] {
    background: var(--surface);
    color: var(--text-tertiary);
    cursor: not-allowed;
    opacity: 0.6;
}

textarea {
    resize: vertical;
    min-height: 88px;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    line-height: 1.45;
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

button {
    font: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 4px 10px;
    min-height: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    line-height: 1.4;
    transition: all var(--transition-fast);
}

button:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
}

button:active {
    transform: scale(0.98);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button.primary {
    background: var(--primary);
    color: var(--primary-text);
    border-color: var(--primary);
}

button.primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

button.secondary {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: transparent;
}

button.secondary:hover {
    background: var(--primary-soft);
    filter: brightness(1.2);
}

button.danger {
    background: transparent;
    color: var(--error);
    border-color: var(--border);
}

button.danger:hover {
    background: var(--error-soft);
    border-color: var(--error);
}

button.ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}

button.ghost:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

/* Compact controls */
.ui-num__btn,
.img-lightbox__close,
.img-lightbox__nav,
.gl-cell,
.page-img-tile {
    min-height: 0;
    letter-spacing: normal;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-top: 12px;
    flex-wrap: wrap;
}

.form-actions .spacer {
    flex: 1;
}

/* ============ MOBILE RESPONSIVE ============ */
@media (max-width: 900px) {
    /* Hide sidebar by default on mobile */
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    /* Show overlay when sidebar is open */
    .sidebar-overlay {
        display: block;
    }
    
    /* Show mobile header elements */
    .top-bar-left {
        display: flex;
    }
    
    /* Remove left margin from main area */
    .main-area {
        margin-left: 0;
    }
    
    /* Hide theme toggle in sidebar on mobile (use top bar one) */
    .sidebar-footer {
        display: none;
    }
    
    /* Adjust content padding */
    .content-wrapper {
        padding: var(--space-6) var(--space-4);
    }
    
    .page-topbar {
        padding-left: 0;
        padding-right: 0;
    }
    
    .page-topbar__title {
        font-size: var(--text-lg);
    }
    
    /* Make tabs scrollable on mobile */
    .tabs-bar {
        flex: 1;
        min-width: 0;
    }
}

@media (max-width: 640px) {
    /* Further adjustments for small screens */
    .content-wrapper {
        padding: var(--space-4) var(--space-3);
    }
    
    .page-title {
        font-size: var(--text-xl);
    }
    
    /* Smaller tab items */
    .tab-item {
        padding: 0 var(--space-3);
        font-size: var(--text-xs);
    }
}

/* ============ TABLES ============ */
.table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow-x: auto;
    background: var(--surface);
}

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

table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

thead {
    background: var(--bg-secondary);
}

th {
    text-align: left;
    padding: var(--space-3) var(--space-4);
    font-weight: var(--font-semibold);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text-primary);
    font-size: var(--text-sm);
}

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

tbody tr:hover > td {
    background: var(--surface-hover);
}

td input[type="text"],
td input[type="url"],
td input[type="number"],
td select {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    border-radius: var(--radius-sm);
}

td input[type="number"] {
    width: 84px;
}

/* path input with fixed leading slash */
.path-input {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    overflow: hidden;
    transition: all var(--transition-fast);
    min-width: 160px;
}

.path-input:hover {
    border-color: var(--border-strong);
}

.path-input:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.path-input__prefix {
    display: inline-flex;
    align-items: center;
    padding: 0 var(--space-2);
    background: var(--surface);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    border-right: 1px solid var(--border);
    user-select: none;
}

.path-input .path-slug {
    border: 0;
    border-radius: 0;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    width: 100%;
    background: transparent;
    font-family: var(--font-mono);
}

.path-input .path-slug:focus {
    outline: none;
    box-shadow: none;
    border: 0;
}

.path-input--home .path-input__prefix {
    color: var(--text-primary);
    font-weight: var(--font-medium);
}

.path-input--home .path-slug {
    background: var(--surface);
    color: var(--text-tertiary);
}

td .cell-action {
    display: flex;
    justify-content: center;
}

td button.danger {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
}

/* ============ STATUS BADGES ============ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
    border-radius: var(--radius-md);
    font-weight: var(--font-medium);
    border: 1px solid var(--border);
    background: var(--surface);
    line-height: 1.4;
    text-transform: lowercase;
}

.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge--success {
    background: var(--success-soft);
    color: var(--success);
    border-color: var(--success);
}

.badge--error,
.badge--partial_error {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: rgba(185, 28, 28, 0.2);
}

.badge--ok {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: rgba(37, 99, 235, 0.2);
}

.badge--neutral {
    background: var(--surface-muted);
    color: var(--text-muted);
    border-color: var(--border);
}

/* ============ RESULT META ============ */
.kv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin: 0 0 14px;
}

.kv {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.kv .kv-label {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-subtle);
    margin-bottom: 4px;
    font-weight: 600;
}

.kv .kv-value {
    font-size: 0.92rem;
    color: var(--text);
    word-break: break-all;
}

.list-clean {
    margin: 0;
    padding: 0 0 0 18px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.list-clean li {
    margin-bottom: 4px;
}

.empty-state {
    padding: 36px 16px;
    text-align: center;
    color: var(--text-subtle);
    background: var(--surface-muted);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
}

/* ============ PROGRESS BAR ============ */
.progress {
    width: 100%;
    height: 10px;
    background: var(--surface-muted);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.progress__bar {
    height: 100%;
    width: 0%;
    background: var(--primary);
    transition: width 0.25s ease;
}

.progress__meta {
    margin: 8px 0 14px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

tr.row-error td {
    background: #fef2f2;
}

tr.row-error td:first-child {
    box-shadow: inset 3px 0 0 var(--danger);
}

.retry-btn {
    padding: 6px 12px;
    font-size: 0.82rem;
}

/* ============ HINT / META TEXT ============ */
.hint {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin: 0;
}

details.payload-help {
    margin-top: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
}

details.payload-help[open] {
    background: var(--surface);
}

details.payload-help summary {
    cursor: pointer;
    padding: 10px 14px;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.88rem;
    list-style: none;
}

details.payload-help summary::-webkit-details-marker {
    display: none;
}

details.payload-help summary::before {
    content: "▸";
    margin-right: 8px;
    transition: transform 0.15s ease;
    display: inline-block;
}

details.payload-help[open] summary::before {
    transform: rotate(90deg);
}

details.payload-help pre {
    margin: 0;
    padding: 0 14px 14px;
    overflow-x: auto;
    font-size: 0.82rem;
    color: var(--text);
}

details.payload-help.paste-helper {
    margin: 0 0 14px;
}

details.payload-help.paste-helper .paste-helper__body {
    padding: 0 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

details.payload-help.paste-helper textarea {
    margin: 0;
    min-height: 110px;
}

/* ============ SITE CARDS ============ */
.site-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.site-card + .site-card {
    margin-top: 16px;
}

.site-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    gap: 12px;
}

.site-card__title {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 600;
    color: var(--text);
}

.site-card h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-subtle);
    margin: 20px 0 8px;
    font-weight: 600;
}

/* ============ QUEUE ============ */
.site-queue {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.site-queue__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.site-queue__index {
    font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, monospace;
    font-size: 0.82rem;
    color: var(--text-subtle);
    min-width: 32px;
}

.site-queue__name {
    flex: 1;
    font-weight: 500;
    color: var(--text);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 720px) {
    .panel {
        padding: 16px;
    }
}

/* ============ HISTORY ============ */
.history-details-row td {
    padding-top: 0;
    border-top: none;
}

.history-run-details {
    margin: 0;
}

.history-run-details__body {
    padding: 0 14px 14px;
}

.history-run-details__body code {
    font-size: 0.82rem;
    word-break: break-all;
}

.hint--inline {
    display: inline-block;
    font-size: 0.82rem;
}

.cell-url {
    max-width: 280px;
    word-break: break-all;
}

.inline-form {
    display: inline;
    margin: 0;
}

/* ============ TEMPLATE MIX ============ */
.template-mix {
    margin-top: 20px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-muted);
}

.template-mix h3 {
    margin-top: 0;
}

.template-mix__body {
    margin-top: 12px;
}

.template-mix__rows {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.template-mix__row {
    display: grid;
    grid-template-columns: 1fr 120px auto;
    gap: 12px;
    align-items: end;
}

.template-mix__row .template-mix-remove {
    margin-bottom: 2px;
}

.template-mix__actions {
    margin-top: 12px;
}

.template-mix__total {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--success);
}

.template-mix__total--bad {
    color: var(--danger);
}

.template-mix__preview {
    margin: 10px 0 0;
}

.template-mix__error {
    margin: 8px 0 0;
    color: var(--danger);
}

label.is-disabled {
    opacity: 0.65;
}

.site-queue__tpl {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.site-queue__tpl code {
    font-size: 0.78rem;
}

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

/* ── History: блок действий и кнопка preview ── */
.history-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-preview {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 4px 9px;
    min-height: 28px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    text-decoration: none;
    border-radius: 7px;
    background: var(--primary);
    color: #fff;
    border: 1px solid transparent;
    box-shadow: 0 1px 2px rgba(16, 185, 129, 0.22);
    transition: background 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
}

.btn-preview:hover {
    background: var(--primary-hover);
    color: #fff;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.25);
}

/* ── Projects: создание проекта ── */
.project-create {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1.5rem;
}

.project-create .inline-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.field-project-name {
    flex: 1 1 260px;
    min-width: 200px;
}

/* ── Projects: поиск по домену в хедере ── */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.domain-search {
    position: relative;
    width: min(260px, 42vw);
    flex: 0 1 260px;
}

.domain-search__field {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 8px 0 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.domain-search.is-open .domain-search__field,
.domain-search__field:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.domain-search__icon {
    flex: 0 0 auto;
    color: var(--text-subtle);
}

.domain-search__input {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    border: 0 !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
}

.domain-search__input::placeholder {
    color: var(--text-subtle);
    font-weight: 450;
}

.domain-search__input::-webkit-search-decoration,
.domain-search__input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

.domain-search__clear {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--surface-muted);
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

.domain-search__clear:hover {
    color: var(--text);
    background: color-mix(in srgb, var(--text) 10%, transparent);
}

.domain-search__dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    left: auto;
    width: max(280px, 100%);
    max-width: min(360px, 92vw);
    max-height: min(360px, 60vh);
    overflow: auto;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow);
    z-index: 50;
}

.domain-search__empty {
    padding: 10px 12px;
    font-size: 0.8rem;
    color: var(--text-subtle);
}

.domain-search__item {
    display: flex;
    align-items: stretch;
    border-radius: 8px;
}

.domain-search__item.is-active,
.domain-search__item:hover {
    background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.domain-search__link {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    text-decoration: none;
    color: var(--text);
}

.domain-search__domain {
    font-size: 0.82rem;
    font-weight: 650;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.domain-search__domain mark {
    background: color-mix(in srgb, var(--primary) 28%, transparent);
    color: inherit;
    border-radius: 3px;
    padding: 0 1px;
}

.domain-search__meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.domain-search__meta strong {
    color: var(--text);
    font-weight: 650;
}

.domain-search__preview {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    color: var(--primary);
    text-decoration: none;
    font-size: 0.85rem;
    opacity: 0.75;
}

.domain-search__preview:hover {
    opacity: 1;
}

.project-card-wrap.is-search-hit .project-card {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.project-card-wrap.is-search-dim {
    opacity: 0.35;
}

/* ── Projects: доска + готовые ── */
.projects-board {
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

.projects-zone__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.4rem 1rem;
    margin-bottom: 0.75rem;
}

.projects-zone__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.projects-zone__hint {
    font-size: 0.8rem;
    color: var(--text-subtle);
}

.projects-zone__empty {
    margin: 0.75rem 0 0;
    font-size: 0.85rem;
    color: var(--text-subtle);
    font-style: italic;
}

.projects-zone--ready {
    padding: 1rem 1.1rem 1.15rem;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 88%, var(--bg));
}

.projects-drop {
    min-height: 4.5rem;
}

.projects-drop.is-drop-target,
.projects-zone.is-drop-target {
    outline: 2px dashed var(--primary);
    outline-offset: 4px;
    border-radius: var(--radius);
}

.projects-zone.is-drop-target {
    outline-offset: 2px;
}

.projects-board.is-dnd .project-card {
    cursor: grabbing;
}

.project-card-wrap {
    cursor: grab;
}

.project-card-wrap.is-dragging {
    opacity: 0.45;
    cursor: grabbing;
}

.project-card-wrap.is-dragging .project-card {
    transform: none;
    box-shadow: var(--shadow-sm);
}

/* ── Projects: сетка карточек ── */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.project-card-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.project-card {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 1.1rem 1.2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
    flex: 1;
    text-decoration: none;
}

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

.project-card__delete {
    position: absolute;
    top: 10px;
    right: 10px;
    margin: 0;
    z-index: 2;
}

.project-card__delete .btn-xs,
.project-card__delete button {
    padding: 4px 10px;
    font-size: 0.75rem;
}

.project-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

.project-card__name {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
    word-break: break-all;
}

.project-card__path {
    font-size: 0.74rem;
    color: var(--text-subtle);
    word-break: break-all;
}

.project-card__sites {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.project-card__sites li {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.project-card__sites .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--border-strong);
    flex-shrink: 0;
}

.project-card__sites .muted {
    color: var(--text-subtle);
    font-style: italic;
}

.project-card__open {
    margin-top: auto;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
}

/* ── Template card (non-link variant) ── */
.project-card--notlink {
    cursor: default;
    text-decoration: none;
}
.project-card--notlink:hover {
    transform: none;
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}

.template-card__actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: auto;
    padding-top: 0.5rem;
    flex-wrap: wrap;
}

.template-card__slug {
    font-size: 0.72rem;
    color: var(--text-subtle);
    word-break: break-all;
}

/* ── Project detail: действия ── */
.project-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    padding: 0 0 10px;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    margin-bottom: 10px;
}

.project-path {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

.project-path code {
    font-size: 0.8rem;
    color: var(--text-muted);
    word-break: break-all;
}

.project-path__template {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.project-actions__buttons {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

/* Выбор набора карточек рейтинга казино (zerkalo-games, zerkalo-bonus). */
.project-actions__buttons > .inline-form:has(.casino-set-pick) {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.casino-set-pick {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.casino-set-pick select {
    min-height: 28px;
    padding: 2px 6px;
    font-size: 0.82rem;
}

/* ═══ UI Switch + Number stepper ═════════════════════════════════════ */
.ui-switch {
    --sw-w: 32px;
    --sw-h: 18px;
    --sw-pad: 2px;
    --sw-on: var(--primary);
    --sw-off: var(--border-strong);
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    line-height: 1.2;
}

.ui-switch input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.ui-switch__track {
    position: relative;
    z-index: 1;
    width: var(--sw-w);
    height: var(--sw-h);
    flex: 0 0 auto;
    border-radius: 999px;
    background: var(--sw-off);
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.06);
    transition: background 0.18s ease, box-shadow 0.18s ease;
    pointer-events: none;
}

.ui-switch__thumb {
    position: absolute;
    top: var(--sw-pad);
    left: var(--sw-pad);
    width: calc(var(--sw-h) - var(--sw-pad) * 2);
    height: calc(var(--sw-h) - var(--sw-pad) * 2);
    border-radius: 50%;
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.2), 0 0 0 1px rgba(15, 23, 42, 0.04);
    transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.ui-switch input:checked + .ui-switch__track {
    background: var(--sw-on);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 25%, transparent);
}

.ui-switch input:checked + .ui-switch__track .ui-switch__thumb {
    transform: translateX(calc(var(--sw-w) - var(--sw-h)));
}

.ui-switch input:focus-visible + .ui-switch__track {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.ui-switch:hover .ui-switch__track {
    filter: brightness(0.97);
}

.ui-switch__text {
    position: relative;
    z-index: 1;
    pointer-events: none;
    color: var(--text);
    font-weight: 600;
}

.ui-switch--danger {
    --sw-on: var(--danger);
}

.ui-switch--danger .ui-switch__text {
    color: var(--text-muted);
}

.ui-switch--danger input:checked ~ .ui-switch__text {
    color: var(--danger);
    font-weight: 700;
}

.ui-switch--compact {
    min-height: 28px;
    align-items: center;
    padding-bottom: 0;
}

.ui-switch--compact .ui-switch__text {
    font-size: 0.8rem;
}

.ui-num {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    cursor: default;
}

.ui-num__label {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    text-transform: uppercase;
}

.ui-num__control {
    display: inline-flex;
    align-items: stretch;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    box-shadow: none;
    overflow: hidden;
}

.ui-num__btn {
    width: 26px;
    border: none;
    border-radius: 0;
    background: var(--bg-secondary);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    min-height: 0;
    transition: background 0.12s ease, color 0.12s ease;
}

.ui-num__control > .ui-num__btn:first-child {
    border-radius: 5px 0 0 5px;
}

.ui-num__control > .ui-num__btn:last-child {
    border-radius: 0 5px 5px 0;
}

.ui-num__btn:hover {
    background: var(--primary-soft);
    color: var(--primary);
}

.ui-num__btn:active {
    background: var(--primary-soft);
}

.ui-num__control input[type="number"] {
    width: 2.6rem;
    border: none;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    border-radius: 0;
    text-align: center;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-size: 0.92rem;
    color: var(--text);
    background: var(--surface);
    padding: 0 2px;
    -moz-appearance: textfield;
    box-shadow: none;
}

.ui-num__control input[type="number"]:focus {
    outline: none;
    background: var(--primary-soft);
}

.ui-num__control input[type="number"]::-webkit-outer-spin-button,
.ui-num__control input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* legacy alias */
.del-files-label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    cursor: pointer;
}

.btn-copy {
    padding: 4px 8px;
    min-height: 28px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0;
    border-radius: var(--radius-md);
    background: var(--primary-soft);
    color: var(--primary);
    border: 1px solid transparent;
    box-shadow: none;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}

.btn-copy:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
    filter: brightness(1.15);
}

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

.panel-header__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-header__actions a.secondary {
    display: inline-flex;
    align-items: center;
    padding: 6px 11px;
    min-height: 32px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    text-decoration: none;
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
}

.panel-header__actions a.secondary:hover {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: rgba(37, 99, 235, 0.28);
}

/* ── History: ссылка-бейдж проекта ── */
.badge-link {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    font-size: 0.76rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
    border: 1px solid var(--border);
    color: var(--primary);
}

.badge-link:hover {
    background: var(--primary-soft);
    color: var(--primary-hover);
}

.cell-path {
    font-size: 0.76rem;
    color: var(--text-subtle);
    word-break: break-all;
}

/* ═══ AI PIPELINE (Client compact) ═══════════════════════════════════ */
.app-main:has(.pipeline-layout) {
    width: min(1480px, 100%);
}

.pipeline-layout {
    display: block;
    margin: 8px 0 12px;
}

.ai-pipeline {
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    width: 100%;
    min-width: 0;
    overflow: visible;
}

.ai-pipeline__head {
    margin-bottom: 10px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.ai-pipeline__head h3,
.ai-pipeline__title {
    margin: 0;
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    letter-spacing: 0.05em;
    flex: 0 0 auto;
}

.ai-pipeline__intro {
    min-width: 0;
    flex: 1 1 22rem;
    max-width: 42rem;
}

.ai-pipeline__intro h3 {
    margin: 0 0 4px;
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    letter-spacing: 0.05em;
}

.ai-pipeline__intro .hint {
    margin: 0;
    max-width: 42rem;
    line-height: 1.35;
    font-size: 12px;
}

.pipe-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    flex: 1 1 auto;
    min-width: 0;
}

.pipe-toolbar > .primary,
.pipe-toolbar > .danger {
    min-height: 28px;
    padding: 0 14px;
}

.pipe-toolbar__warn {
    color: var(--danger, #c44);
    font-size: 11px;
    max-width: 14rem;
}

.pipe-budget {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    margin-left: auto;
    padding: 7px 12px 7px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    flex: 0 0 auto;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.pipe-budget:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.pipe-budget__label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.pipe-budget:hover .pipe-budget__label {
    color: var(--primary);
}

.pipe-budget__value {
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.pipe-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    margin: 8px 0 0;
    padding: 0;
    list-style: none;
    font-size: 11px;
    color: var(--text-tertiary);
}

.pipe-legend li {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.pipe-legend__mark {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
}

.pipe-legend__mark--ok {
    background: var(--success);
    border-color: var(--success);
}

.pipe-legend__mark--run {
    background: var(--primary);
    border-color: var(--primary);
}

.pipe-legend__mark--err {
    background: var(--error);
    border-color: var(--error);
}

.pipe-legend__mark--skip {
    background: transparent;
    border-color: var(--text-tertiary);
}

.pipe-legend__mark--wait {
    background: var(--bg-secondary);
}

.model-stats {
    flex: 1 1 34rem;
    min-width: 22rem;
    max-width: 52rem;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    font-size: 12px;
}

.model-stats__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.model-stats__title {
    font-weight: 600;
    color: var(--text);
}

.model-stats__total {
    margin-left: auto;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-size: 0.84rem;
    color: var(--text);
    white-space: nowrap;
}

.model-stats__reset {
    border: 0;
    background: transparent;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.model-stats__reset:hover {
    color: var(--text);
}

.model-stats__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem 0.75rem;
    max-height: 16rem;
    overflow: auto;
}

.model-stats__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    gap: 0.15rem 0.45rem;
    align-items: baseline;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    min-width: 0;
}

.model-stats__row:first-child {
    border-top: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
    padding-top: 0.35rem;
}

.model-stats__model {
    font-size: 0.72rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-stats__cost {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    white-space: nowrap;
    font-size: 0.74rem;
}

.model-stats__ok {
    color: var(--success);
    white-space: nowrap;
}

.model-stats__err {
    color: var(--text-tertiary);
    white-space: nowrap;
}

.model-stats__row.is-err .model-stats__err {
    color: var(--error);
    font-weight: 600;
}

.model-stats__tokens {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 0.68rem;
    line-height: 1.35;
    font-variant-numeric: tabular-nums;
}

.model-stats__empty {
    margin: 0;
    padding: 0.15rem 0;
    grid-column: 1 / -1;
}

@media (max-width: 900px) {
    .ai-pipeline__intro,
    .pipe-toolbar {
        flex: 1 1 100%;
        max-width: none;
    }

    .pipe-budget {
        margin-left: 0;
    }

    .model-stats__list {
        grid-template-columns: 1fr;
    }
}

.ai-pipeline__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px 16px;
    margin-bottom: 10px;
    padding: 8px 0 10px;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
}

.pipe-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    padding: 0;
}

.pipe-group + .pipe-group {
    border-left: 1px solid var(--border);
    padding-left: 12px;
}

.pipe-group__title {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    line-height: 1;
}

.pipe-group__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    min-height: 28px;
}

.pipe-group--actions .pipe-group__row {
    align-items: center;
}

.pipe-group--actions .pipe-group__row > button {
    min-height: 32px;
    padding: 0 14px;
}

.ai-pipeline__toolbar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.ai-pipeline__toolbar > button,
.project-actions__buttons > .inline-form > button,
.project-actions__buttons > button,
.img-gen__toolbar > button,
.pipe-group--actions > .pipe-group__row > button {
    min-height: 28px;
    white-space: nowrap;
}

.docs-regen {
    margin: 0 0 12px;
}

.docs-regen .pipeline-progress {
    margin-top: 0;
}

.docs-regen__stats {
    margin-top: 4px;
    font-size: 12px;
}

.pipe-model {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    max-width: 15rem;
    flex: 1 1 8.5rem;
}

.pipe-model__label {
    flex: 0 0 auto;
    width: 1.1rem;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    text-align: center;
}

.pipe-model select {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 28px;
    padding: 0 8px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text);
    font-size: 12px;
}

.pipe-model select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.ai-pipeline__stages {
    padding: 8px 0 4px;
    background: transparent;
    border: 0;
    border-radius: 0;
    overflow: visible;
}

.ai-pipeline__stages-label {
    margin: 0 0 8px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.pipe-board.gl-pipeline {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    gap: 10px;
    width: 100%;
    min-width: 0;
    list-style: none;
    margin: 0;
    padding: 0;
}

.pipe-card.gl-pipeline__item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    min-width: 0;
    flex: none;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.pipe-card:has(.gl-job--group.gl-job--success) {
    border-color: rgba(16, 185, 129, 0.4);
}

.pipe-card:has(.gl-job--group.gl-job--running) {
    border-color: var(--primary);
}

.pipe-card:has(.gl-job--group.gl-job--failed) {
    border-color: var(--error);
}

.pipe-card__head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.pipe-card__n {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 14px;
    font-weight: 650;
    letter-spacing: -0.02em;
}

.pipe-card__copy {
    flex: 1 1 auto;
    min-width: 0;
}

.pipe-card__title {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    line-height: 1.25;
}

.pipe-card__hint {
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-secondary);
}

.pipe-card__run {
    flex: 0 0 auto;
    margin-left: auto;
}

.pipe-card .gl-job--group {
    height: 26px;
    min-height: 26px;
    padding: 0 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-soft);
    border-color: transparent;
}

.pipe-card__jobs.gl-step-stack {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
    background: transparent;
    border: 0;
    border-radius: 0;
    overflow: visible;
}

@media (max-width: 1100px) {
    .pipe-board.gl-pipeline {
        grid-template-columns: 1fr;
    }
}

.img-gen__controls .ui-switch,
.img-gen__controls .ui-num {
    align-self: center;
    min-height: 0;
    padding-bottom: 0;
}

.img-gen__controls .ui-switch {
    padding-bottom: 0;
}

.gl-pipeline {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 0;
    width: 100%;
    min-width: 0;
}

.gl-pipeline__item {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 0 0 auto;
}

.gl-pipeline__line,
.gl-stack__rail {
    display: none;
}

.gl-step {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
    flex: 0 0 auto;
    width: auto;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.gl-step--img {
    border: none;
    background: transparent;
}

.gl-step-stack {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    width: auto;
    min-width: 0;
    padding: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: visible;
}

.gl-step-stack > .gl-step {
    width: auto;
    overflow: visible;
}

.gl-pipeline__item--group {
    min-width: 0;
    align-items: center;
    overflow: visible;
    z-index: 1;
}

.gl-pipeline__item--group[data-stage-group="template_fill"],
.gl-pipeline__item--group[data-stage-group="pictures"] {
    min-width: 0;
}

.gl-pipeline__item--group .gl-step__help {
    flex: 0 0 auto;
}

.gl-step--running,
.gl-step--success,
.gl-step--failed {
    border: none;
    background: transparent;
}

.gl-step:hover,
.gl-step:focus-within {
    border: none;
    box-shadow: none;
}

.gl-step .gl-job {
    flex: 0 0 auto;
    min-width: 0;
    width: auto;
    padding: 0 8px;
}

.gl-job__count {
    flex: 0 0 auto;
    margin-right: 0;
    padding: 0 5px;
    height: 16px;
    border-radius: 3px;
    background: var(--warning-soft);
    color: var(--warning);
    font-size: 10px;
    font-weight: 600;
    line-height: 16px;
    letter-spacing: 0;
    white-space: nowrap;
}

.gl-job__count.is-done {
    background: var(--success-soft);
    color: var(--success);
}

.gl-job__remain-tip {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%) translateY(4px);
    z-index: 20;
    width: min(240px, 72vw);
    padding: 8px 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-md);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s;
}

.gl-job__remain-tip strong {
    display: block;
    margin: 0 0 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
}

.gl-job__remain-tip p {
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-secondary);
}

.gl-step:has(.gl-job__remain-tip):hover,
.gl-step:has(.gl-job__remain-tip):focus-within {
    z-index: 6;
    overflow: visible;
}

.gl-step:hover > .gl-job__remain-tip,
.gl-step:focus-within > .gl-job__remain-tip,
.gl-job:hover ~ .gl-job__remain-tip,
.gl-job:focus-visible ~ .gl-job__remain-tip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.gl-step__help {
    position: relative;
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    display: inline-grid;
    place-items: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-tertiary);
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    cursor: help;
    user-select: none;
    z-index: 2;
}

.gl-step__help:hover,
.gl-step__help:focus-visible {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
    outline: none;
    z-index: 5;
}

.gl-pipeline__item:hover,
.gl-pipeline__item:focus-within {
    z-index: 3;
}

.gl-step__help-mark {
    pointer-events: none;
}

.gl-step__tip {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%) translateY(4px);
    width: min(260px, 70vw);
    padding: 8px 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-md);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s;
    z-index: 40;
    text-align: left;
}

.gl-step__tip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--surface);
}

.gl-step__tip strong {
    display: block;
    margin: 0 0 4px;
    font-size: 12px;
    color: var(--text);
}

.gl-step__tip p {
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
    font-weight: 400;
    color: var(--text-secondary);
}

.gl-step__help:hover .gl-step__tip,
.gl-step__help:focus-visible .gl-step__tip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.gl-pipeline__item:first-child .gl-step__tip {
    left: 0;
    transform: translateX(0) translateY(4px);
}

.gl-pipeline__item:first-child .gl-step__help:hover .gl-step__tip,
.gl-pipeline__item:first-child .gl-step__help:focus-visible .gl-step__tip {
    transform: translateX(0) translateY(0);
}

.gl-pipeline__item:first-child .gl-step__tip::after {
    left: 10px;
    transform: none;
}

.gl-pipeline__item:last-child .gl-step__tip {
    left: auto;
    right: 0;
    transform: translateX(0) translateY(4px);
}

.gl-pipeline__item:last-child .gl-step__help:hover .gl-step__tip,
.gl-pipeline__item:last-child .gl-step__help:focus-visible .gl-step__tip {
    transform: translateX(0) translateY(0);
}

.gl-pipeline__item:last-child .gl-step__tip::after {
    left: auto;
    right: 8px;
    transform: none;
}

.gl-job {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    width: auto;
    min-width: 0;
    height: 28px;
    min-height: 28px;
    padding: 0 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.gl-job--group {
    text-transform: none;
    letter-spacing: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    height: 28px;
    min-height: 28px;
    background: var(--surface);
}

.gl-job--img {
    border-style: dashed;
}

.gl-job--running {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
}

.gl-job--success {
    border-color: transparent;
    background: var(--success-soft);
    color: var(--success);
}

.gl-job--failed {
    border-color: transparent;
    background: var(--error-soft);
    color: var(--error);
}

.gl-job--skipped,
.gl-job--partial {
    color: var(--text-tertiary);
}

.gl-job__label {
    display: inline-flex;
    align-items: baseline;
    gap: 0.28em;
    min-width: 0;
    overflow: visible;
    white-space: nowrap;
}

.gl-job__name {
    min-width: 0;
    overflow: visible;
}

.gl-job__n {
    display: none;
}

.gl-job__icon,
.gl-job__icon::before,
.gl-job__icon::after {
    content: none;
    border: none;
    box-shadow: none;
    animation: none;
    transform: none;
    width: auto;
    height: auto;
    margin: 0;
    background: transparent;
}

.gl-job__icon {
    content: "";
    display: block;
    width: 6px;
    height: 6px;
    flex: 0 0 6px;
    border-radius: 50%;
    background: var(--text-tertiary);
    overflow: visible;
    font-size: 0;
    line-height: 0;
    position: relative;
}

.gl-job--pending .gl-job__icon {
    background: var(--text-tertiary);
    opacity: 0.45;
}

.gl-job--running .gl-job__icon {
    background: var(--primary);
    opacity: 1;
    animation: gl-pulse 1s ease-in-out infinite;
}

.gl-job--success .gl-job__icon {
    background: var(--success);
    opacity: 1;
}

.gl-job--failed .gl-job__icon {
    background: var(--error);
    opacity: 1;
}

.gl-job--skipped .gl-job__icon,
.gl-job--partial .gl-job__icon {
    background: var(--text-tertiary);
    opacity: 0.55;
}

.gl-job:hover:not(:disabled) {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
    box-shadow: none;
}

.gl-job--group:hover:not(:disabled) {
    color: var(--primary);
}

.gl-job:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.gl-job:disabled,
.gl-job--locked {
    opacity: 0.42;
    cursor: not-allowed;
    filter: grayscale(0.35);
}

.gl-job--locked:hover {
    color: inherit;
}

.gl-cell--locked {
    opacity: 0.35;
    cursor: not-allowed;
    filter: grayscale(0.4);
}

.gl-cell--locked .gl-cell__mark {
    opacity: 0.35;
}

@keyframes gl-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.7; }
}

@media (max-width: 1180px) {
    .ai-pipeline__controls {
        grid-template-columns: 1fr 1fr;
    }
    .pipe-group--actions {
        grid-column: 1 / -1;
        border-left: none;
        padding-left: 0;
        border-top: 1px solid var(--border);
        padding-top: 8px;
    }
    .pipe-group + .pipe-group--actions {
        border-left: none;
    }
}

@media (max-width: 820px) {
    .ai-pipeline__controls {
        grid-template-columns: 1fr;
    }
    .pipe-group + .pipe-group {
        border-left: none;
        padding-left: 0;
        border-top: 1px solid var(--border);
        padding-top: 8px;
    }
}

.pipeline-progress {
    margin: 8px 0;
}

.pipeline-progress__meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.pipeline-progress__track {
    height: 4px;
    border-radius: 2px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    overflow: hidden;
}

.pipeline-progress__bar {
    height: 100%;
    width: 0%;
    background: var(--primary);
    transition: width 0.25s ease;
}

.pipeline-run-stats {
    margin-top: 6px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
}

.pipeline-run-stats__counts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    align-items: center;
}

.pipeline-run-stats__pill {
    display: inline-flex;
    align-items: baseline;
    gap: 0.3rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
}

.pipeline-run-stats__pill strong {
    font-variant-numeric: tabular-nums;
    font-size: 0.92rem;
    color: var(--text);
}

.pipeline-run-stats__pill--ok strong { color: var(--success); }
.pipeline-run-stats__pill--err strong { color: var(--danger); }
.pipeline-run-stats__pill--run strong { color: var(--primary); }

.pipeline-error-box {
    margin: 0 0 10px;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    background: var(--error-soft);
    border: 1px solid color-mix(in srgb, var(--error) 35%, var(--border));
    color: var(--error);
    font-size: 12px;
    font-weight: 600;
    white-space: pre-wrap;
    word-break: break-word;
}

.seo-err-slot:not([hidden]) {
    display: inline-flex;
}

.seo-err-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 26px;
    padding: 2px 8px 2px 6px;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border));
    background: var(--danger-soft, #fef2f2);
    color: var(--danger);
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: none;
    line-height: 1;
}

.seo-err-btn:hover {
    border-color: var(--danger);
    background: #fee2e2;
}

.seo-err-btn__icon {
    display: inline-grid;
    place-items: center;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: var(--danger);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 800;
}

.seo-err-btn__count {
    font-variant-numeric: tabular-nums;
}

.site-pages-table td.is-seo-bad {
    background: #fef2f2;
    color: var(--danger);
    font-weight: 600;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 28%, transparent);
}

.site-pages-table .seo-missing {
    color: var(--danger);
    font-weight: 700;
    font-size: 0.78rem;
}

.site-pages-table tr.has-seo-err > td:first-child code {
    color: var(--danger);
}

.img-gen {
    margin: 0 0 12px;
    padding: 10px 0 0;
    border: 0;
    border-top: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
}

.img-gen__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px 12px;
    margin: 0 0 10px;
}

.img-gen__field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
}

.img-gen__field select,
.img-gen__field input[type="number"] {
    min-width: 12rem;
    font-weight: 500;
}

.img-gen__field input[type="number"] {
    min-width: 5rem;
    max-width: 6rem;
}

.img-gen__check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.86rem;
    font-weight: 500;
    color: var(--text);
    padding-bottom: 6px;
}

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

.img-gen__stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.img-gen__stats strong {
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

#img-stat-current {
    margin-left: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.78rem;
}

.pipeline-events {
    list-style: none;
    margin: 0;
    padding: 0.5rem 0.7rem;
    max-height: 320px;
    overflow-y: auto;
    font-size: 0.8rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

#pipeline-log {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    padding: 10px 12px 12px;
}

#pipeline-log .pipeline-events {
    max-height: 280px;
}

#pipeline-log .pipeline-events--modal {
    flex: 1 1 auto;
    max-height: none;
    min-height: 120px;
}

.pipeline-live {
    border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border));
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--primary-soft) 55%, var(--surface));
    overflow: hidden;
}

.pipeline-live__head {
    padding: 6px 10px 4px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--primary);
}

/* Высота = по числу текущих строк (без фиксированного max-height). */
.pipeline-events--live,
#pipeline-log .pipeline-events--live {
    max-height: none;
    height: auto;
    overflow: visible;
    border: none;
    border-radius: 0;
    background: transparent;
    padding-top: 2px;
    padding-bottom: 4px;
}

.pipeline-event {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 0.22rem 0;
    border-bottom: 1px solid var(--border);
    word-break: break-word;
}

.pipeline-event__time {
    color: var(--text-muted);
    opacity: 0.85;
    margin-right: 0;
    white-space: nowrap;
    flex: 0 0 auto;
}

.pipeline-event__body,
.pipeline-event__main {
    min-width: 0;
    flex: 1 1 auto;
}

.pipeline-event__title {
    display: block;
    color: var(--text);
    font-weight: 600;
}

.pipeline-event__status {
    display: block;
    margin-top: 1px;
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 500;
}

.pipeline-event__spin {
    flex: 0 0 auto;
    width: 0.85rem;
    height: 0.85rem;
    margin-top: 0.2rem;
    border: 2px solid color-mix(in srgb, var(--primary) 28%, transparent);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: pipeline-spin 0.7s linear infinite;
}

.pipeline-event__mark {
    flex: 0 0 auto;
    width: 0.85rem;
    height: 0.85rem;
    margin-top: 0.15rem;
    display: inline-grid;
    place-items: center;
    border-radius: 50%;
    font-size: 0.62rem;
    font-weight: 800;
    line-height: 1;
}

.pipeline-event__mark--ok {
    background: color-mix(in srgb, var(--success) 18%, var(--surface));
    color: var(--success);
}

.pipeline-event__mark--err {
    background: color-mix(in srgb, var(--danger) 18%, var(--surface));
    color: var(--danger);
}

.pipeline-event__mark--skip {
    background: var(--bg-secondary);
    color: var(--text-tertiary);
}

.pipeline-event--live {
    border-bottom-color: color-mix(in srgb, var(--primary) 18%, var(--border));
}

.pipeline-event--live .pipeline-event__title {
    color: var(--text);
}

.pipeline-event--reply .pipeline-event__status {
    color: var(--primary);
    font-weight: 600;
}

.pipeline-event--settled {
    opacity: 0.95;
}

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

.pipeline-event:last-child { border-bottom: none; }
.pipeline-event--ok { color: var(--success); }
.pipeline-event--ok .pipeline-event__title { color: var(--success); }
.pipeline-event--err { color: var(--danger); }
.pipeline-event--err .pipeline-event__title { color: var(--danger); }
.pipeline-event--running { color: var(--text-muted); }
.pipeline-event--skip { color: var(--text-tertiary); }
.pipeline-event--info { color: var(--text-muted); }
.pipeline-event--stage {
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.4rem;
    margin-top: 0.35rem;
    border-bottom: none;
}

.site-docs-status {
    display: inline-block;
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
    font-size: 0.72rem;
}

.site-docs-status--running {
    color: var(--primary);
}

.site-docs-status--ok {
    color: var(--success);
}

.site-docs-status--err {
    color: var(--error);
}

.site-docs-status--skip {
    color: var(--text-tertiary);
}

.matrix-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin: 10px 0 8px;
}

.matrix-toolbar .hint {
    margin: 0;
}

.matrix-selection {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    margin-left: auto;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--primary-soft);
}

.matrix-selection__count {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--primary);
}

.pipeline-matrix thead th {
    padding: 6px 8px;
    font-size: 10px;
}

.pipeline-matrix td {
    padding: 6px 8px;
}

.pipeline-matrix .col-select {
    width: 32px;
    text-align: center;
    vertical-align: middle;
}

.pipeline-matrix .col-select input {
    width: 15px;
    height: 15px;
    margin: 0;
    cursor: pointer;
    vertical-align: middle;
}

.pipeline-matrix .col-select input:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

.site-row--selected > td {
    background: var(--primary-soft);
}

.site-row--selected.site-row--paused > td {
    background: transparent;
}

.pipeline-matrix .col-stage {
    text-align: center;
    width: 72px;
    max-width: 96px;
    padding: 6px 4px;
    font-size: 11px;
    letter-spacing: 0;
    text-transform: none;
    white-space: normal;
    word-break: break-word;
    line-height: 1.25;
    vertical-align: middle;
    font-weight: 500;
}

.pipeline-matrix .col-offer {
    width: 48px;
    text-align: center;
    vertical-align: middle;
}

.pipeline-matrix .offer-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    font-weight: 700;
    font-size: 0.85rem;
    line-height: 1;
}

.pipeline-matrix .offer-mark--yes {
    color: var(--success);
}

.pipeline-matrix .offer-mark--no {
    color: var(--text-tertiary);
    font-weight: 500;
    opacity: 0.7;
}

.site-pages-panel__offer {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.6rem;
    padding: 0;
    border: none;
    font-size: 0.85rem;
}

.site-pages-panel__offer-label {
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 0.72rem;
}

.site-pages-panel__offer-link {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8rem;
    color: var(--primary);
    word-break: break-all;
    text-decoration: none;
}

.site-pages-panel__offer-link:hover {
    text-decoration: underline;
}

.site-rating-pick {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
}

.site-rating-pick__copy {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 140px;
}

.site-rating-pick__label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text);
}

.site-rating-pick__hint {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.site-rating-pick select {
    flex: 1 1 240px;
    min-width: 200px;
    max-width: 420px;
    font: inherit;
    font-size: 0.84rem;
    padding: 0.35rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg, #fff);
    color: var(--text);
}

.site-rating-pick__empty {
    margin: 0;
}

.site-pages-panel__offer-edit {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 0;
}

html[data-theme="night"] .pipeline-matrix .offer-mark--yes {
    color: #4ade80;
}

html[data-theme="night"] .site-pages-panel__offer {
    border-bottom-color: var(--border);
}

html[data-theme="night"] .site-rating-pick {
    background: transparent;
}

.gl-cell {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    cursor: pointer;
    display: inline-grid;
    place-items: center;
    padding: 0;
    vertical-align: middle;
    box-shadow: none;
}

.gl-cell:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.gl-cell:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.gl-cell--img {
    border-style: dashed;
}

.gl-cell__mark,
.gl-cell__mark::before,
.gl-cell__mark::after {
    content: none;
    border: none;
    background: transparent;
    width: auto;
    height: auto;
    margin: 0;
    transform: none;
    position: static;
    animation: none;
}

.gl-cell__mark {
    content: "";
    display: block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-tertiary);
    opacity: 0.45;
}

.gl-cell--pending .gl-cell__mark {
    background: var(--text-tertiary);
    opacity: 0.4;
}

.gl-cell--running {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.gl-cell--running .gl-cell__mark {
    background: var(--primary);
    opacity: 1;
    animation: gl-pulse 1s ease-in-out infinite;
}

.gl-cell--success {
    border-color: transparent;
    background: var(--success-soft);
}

.gl-cell--success .gl-cell__mark {
    background: var(--success);
    opacity: 1;
}

.gl-cell--failed {
    border-color: transparent;
    background: var(--error-soft);
}

.gl-cell--failed .gl-cell__mark {
    background: var(--error);
    opacity: 1;
}

.gl-cell--skipped {
    border-color: var(--border);
    background: var(--bg-secondary);
}

.gl-cell--skipped .gl-cell__mark {
    background: var(--text-tertiary);
    opacity: 0.5;
}

.cell-actions__inner {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.cell-actions .inline-form {
    display: flex;
    margin: 0;
}

.btn-xs {
    padding: 3px 8px;
    min-height: 26px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0;
    border-radius: var(--radius-md);
    box-shadow: none;
}

.site-row {
    cursor: pointer;
}

.site-row--paused {
    opacity: 0.72;
}

.site-row--paused > td {
    background: var(--bg-secondary);
}

.site-row__paused-badge {
    display: inline-flex;
    align-items: center;
    height: 18px;
    padding: 0 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--warning);
    background: var(--warning-soft);
    border: 1px solid transparent;
    flex-shrink: 0;
}

.site-pause-switch {
    margin-right: 0.15rem;
}

.site-row--paused .gl-cell {
    cursor: not-allowed;
}

.site-row > td {
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
    padding-top: 6px;
    padding-bottom: 6px;
}

.site-row:hover {
    background: var(--surface-hover);
}

.site-row.is-open {
    background: var(--primary-soft);
}

.site-row__name-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    min-height: 24px;
}

.site-row__chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    color: var(--text-tertiary);
    transition: transform 0.15s ease, color 0.15s ease;
}

.site-row__chevron::before {
    content: "";
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 4px 0 4px 6px;
    border-color: transparent transparent transparent currentColor;
    margin-left: 1px;
}

.site-row.is-open .site-row__chevron {
    transform: rotate(90deg);
    color: var(--primary);
}

.site-row:hover .site-row__chevron {
    color: var(--primary);
}

.site-row__brand {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    height: 20px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-soft);
    border: 1px solid transparent;
    border-radius: 3px;
    letter-spacing: 0;
    max-width: 16rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 20px;
}

.site-row__brand[hidden] {
    display: none !important;
}

.site-row__brand-geo {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-tertiary);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.site-row__meta {
    font-size: 11px;
    white-space: nowrap;
}

.site-row-detail > td {
    padding: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.pipeline-matrix tbody tr.site-row-detail:hover > td {
    background: var(--surface);
}

.site-pages-panel {
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
}

.site-pages-panel__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    margin: 0;
    padding: 10px 14px 8px;
}

.site-pages-panel__head-copy {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 12px;
}

.site-pages-panel__head strong {
    font-size: 0.88rem;
}

.btn-add-page {
    margin-left: auto;
}

.add-page-lead {
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.45;
}

.add-page-lead strong {
    color: var(--text-primary);
    font-weight: 650;
}

.add-page-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.add-page-field__label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-subtle);
}

.add-page-slug {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--input-bg, var(--bg-secondary));
    overflow: hidden;
}

.add-page-slug:focus-within {
    border-color: var(--primary);
}

.add-page-slug__prefix {
    display: flex;
    align-items: center;
    padding: 0 10px;
    background: var(--chip-bg, var(--surface-hover));
    color: var(--text-tertiary);
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 0.88rem;
    border-right: 1px solid var(--border);
}

.add-page-slug input[type="text"].add-page-slug__input {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    font: inherit;
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 8px 10px;
    border-radius: 0;
}

.add-page-slug input[type="text"].add-page-slug__input:hover,
.add-page-slug input[type="text"].add-page-slug__input:focus {
    outline: none;
    border: 0;
    box-shadow: none;
}

.add-page-url {
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 0.75rem;
    color: var(--primary);
    word-break: break-all;
}

.add-page-prompt {
    width: 100%;
    min-height: 220px;
    max-height: 42vh;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 400;
    color: var(--text);
    line-height: 1.5;
    resize: vertical;
    padding: 10px 12px;
}

.add-page-prompt__bar {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

.add-page-prompt__count {
    flex: 0 0 auto;
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-tertiary);
}

.add-page-error {
    margin: 0;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    background: var(--error-soft);
    color: var(--error);
    font-size: 0.8rem;
}

.modal.modal--add-page {
    width: min(560px, 94vw);
    max-width: 560px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
}

.modal--add-page form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1 1 auto;
}

.modal.modal--add-page .modal--add-page__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px 18px;
}

.modal--add-page .modal-footer {
    flex: 0 0 auto;
}
.site-pages-panel__tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    margin: 0;
    padding: 8px 14px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.site-pages-panel__tools:not(:has(.site-rating-pick, .site-pages-panel__offers-hint, .site-pages-panel__offer:not([hidden]), .site-brand-assets)) {
    display: none;
}

.brand-assets {
    margin: 14px 0 0;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface, var(--bg-elevated, transparent));
}

.legal-pages {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px 20px;
    margin: 0 0 12px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface, var(--bg-elevated, transparent));
}
.legal-pages__copy {
    flex: 1 1 220px;
    min-width: 0;
}
.legal-pages__title {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 650;
}
.legal-pages__hint {
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-secondary, var(--text-muted));
}
.legal-pages__switches {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    flex: 1 1 320px;
}
.legal-pages__status {
    flex: 1 1 100%;
    margin: 0;
}
.legal-pages__status.is-error {
    color: var(--danger, #c44);
}
.brand-assets__head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px 16px;
    margin-bottom: 12px;
}
.brand-assets__copy { flex: 1 1 280px; min-width: 0; }
.brand-assets__title {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 650;
}
.brand-assets__hint {
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-secondary, var(--text-muted));
}
.brand-assets__slots {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 18px;
}
.brand-asset {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 220px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg, transparent);
}
.brand-asset--sm { min-width: 200px; padding: 6px; }
.brand-asset__preview {
    width: 56px;
    height: 56px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background:
        linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
        linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
        linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
    background-size: 12px 12px;
    background-position: 0 0, 0 6px, 6px -6px, -6px 0;
    overflow: hidden;
}
.brand-asset--sm .brand-asset__preview { width: 44px; height: 44px; }
.brand-asset__preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.brand-asset__empty {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    padding: 4px;
}
.brand-asset__meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1 1 auto;
}
.brand-asset__meta strong { font-size: 12px; }
.brand-asset__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.brand-asset__file { position: relative; cursor: pointer; margin: 0; overflow: hidden; }
.brand-asset__file input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    font-size: 0;
}
.brand-assets__status { margin: 10px 0 0; }
.site-brand-assets {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px 12px;
    width: 100%;
}
.site-brand-assets__copy {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 120px;
}
.site-brand-assets__label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text);
}
html[data-theme="night"] .brand-asset__preview {
    background:
        linear-gradient(45deg, #1f2937 25%, transparent 25%),
        linear-gradient(-45deg, #1f2937 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #1f2937 75%),
        linear-gradient(-45deg, transparent 75%, #1f2937 75%);
    background-size: 12px 12px;
    background-position: 0 0, 0 6px, 6px -6px, -6px 0;
}
.page-brief-missing {
    margin-left: 6px;
    font-size: 0.68rem;
    color: var(--danger, #ef4444);
    vertical-align: middle;
}
.page-row.is-missing-prompt code {
    color: var(--danger, #ef4444);
}
.page-detail-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0;
}
.page-prompt-editor {
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
}
.page-prompt-editor__label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
}
.page-prompt-editor__text {
    width: 100%;
    min-height: 10rem;
    font: inherit;
    font-weight: 400;
    color: var(--text);
    line-height: 1.5;
    resize: vertical;
    padding: 0.5rem 0.65rem;
}
.page-prompt-editor__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}
.page-ctx-menu__btn--danger {
    color: var(--danger, #ef4444);
}
.page-ctx-menu__btn--danger:hover {
    background: color-mix(in srgb, var(--danger, #ef4444) 12%, transparent);
    border-color: color-mix(in srgb, var(--danger, #ef4444) 35%, var(--border));
}
.pipe-prompts-hint {
    margin: 0 0 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid color-mix(in srgb, var(--warning, #f59e0b) 35%, var(--border));
    background: color-mix(in srgb, var(--warning, #f59e0b) 10%, transparent);
    color: var(--text);
    font-size: 0.8rem;
    line-height: 1.4;
}

.site-pages-panel__table-wrap,
.site-pages-panel .table-wrap {
    margin: 0;
    overflow-x: auto;
    border: none;
    border-radius: 0;
    background: transparent;
}

.site-pages-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.site-pages-table .col-check {
    width: 28px;
    text-align: center;
    vertical-align: middle;
}
.site-pages-table .col-check.col-models {
    width: 7.5rem;
    min-width: 6.5rem;
    text-align: left;
    white-space: nowrap;
}
.site-pages-table .page-models {
    display: inline-block;
    max-width: 8.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-muted);
    line-height: 1.25;
}
.site-pages-table .col-check input {
    margin: 0;
    cursor: pointer;
}

.page-ctx-menu {
    position: fixed;
    z-index: 9000;
    min-width: 12.5rem;
    padding: 0.4rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface, #0f172a);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.page-ctx-menu[hidden] { display: none !important; }
.page-ctx-menu__title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-subtle);
    padding: 0.2rem 0.35rem 0.15rem;
    letter-spacing: 0.02em;
}
.page-ctx-menu__model {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0.15rem 0.35rem 0.35rem;
}
.page-ctx-menu__model select {
    font: inherit;
    font-size: 0.78rem;
    padding: 0.3rem 0.4rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg, #020617);
    color: var(--text);
}
.page-ctx-menu__btn {
    font: inherit;
    font-size: 0.82rem;
    text-align: left;
    padding: 0.4rem 0.55rem;
    border-radius: 7px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    cursor: pointer;
}
.page-ctx-menu__btn:hover {
    background: rgba(56, 189, 248, 0.12);
    border-color: var(--border);
}
.page-ctx-menu__btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    filter: grayscale(0.25);
}
.page-ctx-menu__btn:disabled:hover {
    background: transparent;
    border-color: transparent;
}

.btn-legal-write {
    font: inherit;
    font-size: 0.78rem;
    padding: 0.18rem 0.55rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface, #0f172a);
    color: var(--text);
    cursor: pointer;
}
.btn-legal-write:hover {
    border-color: var(--accent, #38bdf8);
}
.legal-write-hint {
    font-weight: normal;
    opacity: 0.85;
}

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

.site-pages-table th {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text);
    z-index: 1;
    border-bottom: 2px solid var(--border);
}

.site-pages-table td:nth-child(4),
.site-pages-table td:nth-child(5),
.site-pages-table td:nth-child(6) {
    max-width: 240px;
    word-break: break-word;
}

.site-pages-table .col-num {
    width: 42px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text-muted);
}

.site-pages-table .col-vol {
    width: 88px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    font-size: 0.82rem;
    white-space: nowrap;
    color: var(--text-muted);
}

.site-pages-table .col-vol.is-thin {
    color: #b45309;
    font-weight: 700;
}

.site-pages-table .col-faq {
    width: 48px;
    text-align: center;
}

.site-pages-table .col-docs {
    width: 72px;
    white-space: nowrap;
}

.site-pages-table .col-page-preview {
    width: 118px;
    white-space: nowrap;
    vertical-align: middle;
}

.site-preview-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.btn-page-preview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    min-height: 28px;
    padding: 0 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    color: var(--primary);
    background: var(--primary-soft);
    border: 1px solid color-mix(in srgb, var(--primary) 28%, transparent);
    white-space: nowrap;
}

.btn-page-preview:hover {
    background: var(--primary);
    color: var(--primary-text);
}

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

.faq-dot {
    display: inline-block;
    font-size: 0.95rem;
    line-height: 1;
}

.faq-dot--yes {
    color: var(--success);
}

.faq-dot--no {
    color: var(--danger);
}

.btn-docs {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--primary-soft);
    border: 1px solid color-mix(in srgb, var(--primary) 28%, transparent);
}

.btn-docs:hover {
    color: var(--primary-hover);
    background: var(--primary-soft);
}

.site-pages-table__section td {
    padding: 10px 12px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-subtle);
    background: var(--chip-bg);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.site-pages-table tbody tr.site-pages-table__section:hover > td {
    background: var(--chip-bg);
}

.site-pages-table tbody tr.page-row:hover > td {
    background: var(--surface-hover);
}

.site-pages-table tbody tr.page-row-detail:hover > td {
    background: var(--bg-secondary);
}

.site-pages-table tr.is-legal td,
.site-pages-table tr.is-author td {
    color: var(--text-muted);
}

.page-kind-mark {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 650;
    letter-spacing: 0.01em;
    color: var(--text-subtle);
    background: var(--chip-bg);
    border: 1px solid var(--border);
    vertical-align: middle;
    white-space: nowrap;
}

@media (max-width: 800px) {
    .gl-pipeline__line { width: 14px; }
    .pipeline-matrix .col-stage { width: 48px; }
    .site-pages-table td:nth-child(4),
    .site-pages-table td:nth-child(5),
    .site-pages-table td:nth-child(6) {
        max-width: 140px;
    }
}

.page-row {
    cursor: pointer;
}

.page-row:hover {
    background: transparent;
}

.page-row.is-open {
    background: var(--surface-hover);
}

.page-brief-mark {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.05rem;
    height: 1.05rem;
    margin-left: 6px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 0.62rem;
    cursor: help;
    vertical-align: middle;
}

.page-brief-mark__icon {
    pointer-events: none;
}

.page-brief-tip {
    position: absolute;
    z-index: 40;
    left: 0;
    top: calc(100% + 8px);
    width: 420px;
    max-width: min(420px, 80vw);
    max-height: 340px;
    overflow-y: auto;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
    color: var(--text);
    font-size: 0.76rem;
    line-height: 1.5;
    white-space: pre-wrap;
    text-align: left;
    text-transform: none;
    letter-spacing: normal;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.12s ease, transform 0.12s ease, visibility 0.12s ease;
    pointer-events: none;
}

.page-brief-mark:hover .page-brief-tip,
.page-brief-mark:focus-visible .page-brief-tip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.page-row-detail > td {
    padding: 10px 14px 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.page-images-panel {
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
}

.page-images-panel__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px 12px;
    margin-bottom: 10px;
}

.page-images-panel__head strong {
    font-size: 0.82rem;
}

.page-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    gap: 10px;
}

.page-images-empty {
    margin: 0;
    grid-column: 1 / -1;
}

/* ═══ Project gallery ═══════════════════════════════════════════════ */
.project-gallery {
    margin-top: 16px;
}

body.is-gallery-open {
    overflow: hidden;
}

.gallery-fs {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.gallery-fs[hidden] {
    display: none !important;
}

.gallery-fs__chrome {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px 20px;
    padding: 16px 20px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.gallery-fs__title h2 {
    margin: 0 0 4px;
    font-size: 1.125rem;
    color: var(--text-primary);
}

.gallery-fs__title .hint {
    color: var(--text-secondary);
}

.gallery-fs__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
}

.gallery-fs__toolbar .img-gen__field {
    color: var(--text-secondary);
}

.gallery-fs__toolbar select {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border);
}

.gallery-fs__toolbar .ui-switch__text {
    color: var(--text-secondary);
}

.gallery-fs__scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 18px 20px 28px;
}

.project-gallery__grid,
.gallery-fs__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.gallery-fs__grid .gallery-card {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text-primary);
}

.gallery-fs__grid .gallery-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.gallery-fs__grid .page-img-tile__media {
    aspect-ratio: 16 / 9;
    background: var(--bg-secondary);
}

.gallery-fs__grid .page-img-tile__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-fs__grid .page-img-tile__empty {
    color: var(--text-tertiary);
}

.gallery-card__meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 10px 12px 12px;
    min-width: 0;
}

.gallery-card__meta code {
    font-size: 0.82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.gallery-card__site {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (min-width: 1700px) {
    .gallery-fs__grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 22px;
    }
}

@media (max-width: 1100px) {
    .gallery-fs__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 820px) {
    .gallery-fs__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px;
    }
}

@media (max-width: 520px) {
    .gallery-fs__grid {
        grid-template-columns: 1fr;
    }
}

.page-img-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-muted);
    overflow: hidden;
    cursor: pointer;
    text-align: left;
    font: inherit;
    color: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.page-img-tile:hover {
    border-color: var(--primary);
    box-shadow: none;
    transform: none;
}

.page-img-tile.is-missing,
.page-img-tile.is-placeholder {
    border-style: dashed;
}

.page-img-tile.is-busy {
    pointer-events: none;
    opacity: 0.72;
}

.page-img-tile__media {
    display: block;
    aspect-ratio: 1;
    background: #0f172a0d;
    overflow: hidden;
}

.page-img-tile__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #e2e8f0;
    transition: opacity 0.2s ease;
}

.page-img-tile__media img.is-loaded {
    opacity: 1;
    background: transparent;
}

.page-img-tile__media img:not(.is-loaded) {
    opacity: 0.35;
}

.page-img-tile__empty {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 118px;
    font-size: 0.72rem;
    color: var(--text-subtle);
    text-align: center;
    padding: 8px;
}

.page-img-tile__label {
    display: block;
    padding: 0 8px 8px;
    font-size: 0.72rem;
}

.page-img-tile__label code {
    font-size: 0.72rem;
}

.page-img-tile__spin {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.page-img-tile.is-busy .page-img-tile__spin {
    display: flex;
}

.page-img-tile__spin::after {
    content: "";
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid rgba(37, 99, 235, 0.25);
    border-top-color: var(--primary);
    animation: page-img-spin 0.7s linear infinite;
}

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

body.is-lightbox-open {
    overflow: hidden;
}

.img-lightbox {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
}

.img-lightbox[hidden] {
    display: none !important;
}

.img-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.88);
    backdrop-filter: blur(4px);
}

.img-lightbox__dialog {
    position: relative;
    z-index: 1;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    border-radius: 0;
    box-shadow: none;
    border: none;
    color: var(--text-primary);
}

.img-lightbox__nav {
    position: absolute;
    top: 50%;
    z-index: 3;
    transform: translateY(-50%);
    width: 48px;
    height: 72px;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.12);
    color: #f8fafc;
    font-size: 1.85rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.img-lightbox__nav:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.22);
}

.img-lightbox__nav:disabled {
    opacity: 0.35;
    cursor: default;
}

.img-lightbox__nav--prev {
    left: 16px;
}

.img-lightbox__nav--next {
    right: 16px;
}

.img-lightbox__close {
    position: absolute;
    top: 14px;
    right: 16px;
    z-index: 2;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    color: #f8fafc;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.img-lightbox__close:hover {
    background: rgba(255, 255, 255, 0.22);
}

.img-lightbox__layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
    gap: 0;
    flex: 1;
    min-height: 0;
    height: 100%;
}

.img-lightbox__preview {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #020617;
    min-height: 0;
    height: 100%;
    padding: 28px 64px;
}

.img-lightbox__preview img {
    max-width: 100%;
    max-height: calc(100vh - 48px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.img-lightbox__counter {
    position: absolute;
    left: 18px;
    bottom: 16px;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.7);
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}

.img-lightbox__missing {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.95rem;
}

.img-lightbox__side {
    padding: 20px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    overflow: auto;
}

.img-lightbox__title {
    margin: 0 36px 0 0;
    font-size: 1.05rem;
    line-height: 1.3;
    color: var(--text-primary);
}

.img-lightbox__meta {
    margin: 0;
    color: var(--text-secondary);
}

.img-lightbox__prompt-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.img-lightbox__prompt {
    margin: 0;
    flex: 1;
    min-height: 160px;
    max-height: none;
    overflow: auto;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.img-lightbox__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    margin-top: 4px;
}

.img-lightbox__actions .hint {
    color: rgba(226, 232, 240, 0.65);
}

@media (max-width: 900px) {
    .img-lightbox__layout {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(45vh, 1fr) auto;
        overflow: auto;
    }
    .img-lightbox__preview {
        padding: 20px 52px;
        min-height: 45vh;
        height: auto;
    }
    .img-lightbox__preview img {
        max-height: min(58vh, 560px);
    }
    .img-lightbox__side {
        border-left: none;
        border-top: 1px solid rgba(148, 163, 184, 0.2);
        max-height: 42vh;
    }
    .img-lightbox__nav {
        width: 40px;
        height: 52px;
        font-size: 1.45rem;
    }
    .img-lightbox__nav--prev { left: 8px; }
    .img-lightbox__nav--next { right: 8px; }
}

/* ═══ SETTINGS ═══════════════════════════════════════════════════════ */
.form-stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 640px;
}

.form-stack--full {
    max-width: none;
}

.settings-hero {
    background:
        radial-gradient(ellipse 80% 120% at 100% 0%, rgba(37, 99, 235, 0.12), transparent 55%),
        linear-gradient(180deg, var(--surface) 0%, var(--chip-bg) 100%);
}

.settings-kicker {
    margin: 0 0 4px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--primary);
}

.settings-hero__status {
    display: flex;
    align-items: flex-start;
}

.settings-pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--surface-muted);
    color: var(--text-muted);
}

.settings-pill--ok {
    background: var(--success-soft);
    border-color: #86efac;
    color: var(--success);
}

.settings-pill--warn {
    background: var(--warning-soft);
    border-color: #fcd34d;
    color: var(--warning);
}

.settings-layout {
    display: grid;
    grid-template-columns: 1.2fr 0.9fr;
    gap: 18px;
    align-items: start;
}

.settings-layout > .settings-card:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}

.settings-layout > .settings-card:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
}

.settings-layout > .settings-card--endpoints {
    grid-column: 2;
    grid-row: 1 / span 2;
}

.settings-layout > .settings-actions {
    grid-column: 1 / -1;
}

.settings-card__head {
    margin-bottom: 16px;
}

.settings-card__head h3 {
    margin: 0 0 4px;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    text-transform: none;
    color: var(--text);
}

.settings-card__head .hint {
    margin: 0;
}

.provider-box {
    display: grid;
    gap: 0.65rem;
    padding: 0.85rem 0.95rem;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--surface-muted);
    margin-bottom: 0.35rem;
}

.provider-box__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.provider-status--ok {
    color: var(--success, #15803d);
}

.provider-status--err {
    color: var(--danger, #b91c1c);
}

.model-picker {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.model-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    padding: 14px 14px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.model-card:hover {
    border-color: var(--border-strong);
    background: var(--surface);
}

.model-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.model-card__vendor {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-subtle);
}

.model-card__name {
    font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, monospace;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    word-break: break-all;
}

.model-card__price {
    margin-top: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted, #64748b);
    letter-spacing: 0.01em;
}

.model-card__badge {
    display: none;
    margin-top: 6px;
    align-self: flex-start;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: var(--primary-soft);
    color: var(--primary);
}

.model-prices {
    margin: 0.85rem 0 1rem;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-muted, var(--chip-bg));
}

.model-prices__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.75rem;
    margin-bottom: 0.45rem;
}

.model-prices__head strong {
    font-size: 0.84rem;
}

.model-prices__table-wrap {
    overflow-x: auto;
}

.model-prices__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}

.model-prices__table th,
.model-prices__table td {
    padding: 0.35rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
}

.model-prices__table th {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-subtle, #8a94a6);
}

.model-prices__table td:not(:first-child) {
    white-space: nowrap;
}

.model-card.is-selected {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.model-card.is-selected .model-card__badge {
    display: inline-flex;
}

.model-card__test-hint {
    display: none;
    margin-top: 6px;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-subtle);
    letter-spacing: 0.02em;
}

.model-card:hover .model-card__test-hint {
    display: block;
}

.model-ctx-menu {
    position: fixed;
    z-index: 1000;
    min-width: 160px;
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.model-ctx-menu__item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 9px 12px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--text);
    font-weight: 600;
    font-size: 0.88rem;
}

.model-ctx-menu__item:hover {
    background: var(--primary-soft);
    color: var(--primary);
}

#model-test-result {
    margin-top: 12px;
}

.settings-models-edit textarea {
    min-height: 110px;
    font-size: 0.86rem;
}

.endpoint-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.endpoint-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
}

.endpoint-row--active {
    background: var(--surface);
    border-color: #bfdbfe;
    box-shadow: inset 3px 0 0 var(--primary);
}

.endpoint-method {
    flex: 0 0 auto;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 750;
    letter-spacing: 0.04em;
    background: #0f172a;
    color: #fff;
}

.endpoint-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.endpoint-vendor {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-subtle);
}

.endpoint-path {
    font-size: 0.9rem;
    background: transparent;
    border: none;
    padding: 0;
    color: var(--text);
}

.endpoint-used {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
}

.settings-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.settings-actions .test-result {
    margin-top: 0;
    flex: 1 1 100%;
}

@media (max-width: 900px) {
    .settings-layout {
        grid-template-columns: 1fr;
    }

    .settings-layout > .settings-card:nth-child(1),
    .settings-layout > .settings-card:nth-child(2),
    .settings-layout > .settings-card--endpoints,
    .settings-layout > .settings-actions {
        grid-column: 1;
        grid-row: auto;
    }

    .model-picker {
        grid-template-columns: 1fr;
    }
}

.test-result {
    margin-top: 1rem;
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
}

.test-result--ok {
    background: var(--success-soft);
    color: var(--success);
    border: 1px solid var(--success);
}

.test-result--err {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.test-result--loading {
    background: var(--primary-soft);
    color: var(--primary);
    border: 1px solid var(--primary);
}

/* ═══ PROMPTS editor ═════════════════════════════════════════════════ */
.prompt-pipe {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.prompt-pipe__group {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.1rem 0.85rem;
    background: var(--surface);
}

.prompt-pipe__head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 6px;
    min-height: 1.85rem;
}

.prompt-geo {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.1rem 0.95rem;
    background: var(--surface);
}

.prompt-geo__label {
    margin: 0.85rem 0 0.5rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary, var(--text-muted));
}

.prompt-geo__label:first-of-type {
    margin-top: 0.35rem;
}

.prompt-geo__grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
}

.prompt-geo__chip {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
        "code name lang"
        "note note note";
    align-items: center;
    column-gap: 8px;
    row-gap: 2px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary, var(--surface-hover));
}

.prompt-geo__chip--partial {
    opacity: 0.92;
}

.prompt-geo__code {
    grid-area: code;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.1rem;
    height: 1.35rem;
    padding: 0 6px;
    border-radius: 6px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.prompt-geo__name {
    grid-area: name;
    font-size: 0.84rem;
    font-weight: 650;
    color: var(--text-primary, var(--text));
}

.prompt-geo__lang {
    grid-area: lang;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-tertiary, var(--text-muted));
    font-variant-numeric: tabular-nums;
}

.prompt-geo__note {
    grid-area: note;
    font-size: 0.72rem;
    color: var(--text-secondary, var(--text-muted));
    line-height: 1.35;
}

.prompt-geo__no {
    margin: 0.9rem 0 0;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--warning-soft, rgba(245, 158, 11, 0.08));
    color: var(--text-primary, var(--text));
    font-size: 0.82rem;
    line-height: 1.45;
}

.prompt-geo__legal {
    margin: 0.65rem 0 0;
}

.prompt-pipe__n {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.85rem;
    height: 1.85rem;
    padding: 0 0.45rem;
    border-radius: 8px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.panel .prompt-pipe__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-transform: none;
    color: var(--text-primary, var(--text));
    line-height: 1.2;
}

.prompt-pipe__hint {
    margin: 0 0 0.85rem;
    padding-left: calc(1.85rem + 10px);
}

.prompt-pipe__aside,
.prompt-pipe__sub {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0 0 0.75rem;
}

.prompt-pipe__aside {
    padding-left: calc(1.85rem + 10px);
}

.prompt-pipe__sub {
    font-weight: 700;
    color: var(--text);
    margin-top: 0.6rem;
}

.prompt-pipe__legal {
    margin: 0 0 0.85rem;
    padding: 0.55rem 0.65rem 0.2rem;
    border: 1px dashed var(--border);
    border-radius: 10px;
}

.prompt-pipe__legal-title {
    margin: 0 0 0.4rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-subtle);
}

.prompt-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.6rem;
}

.prompt-card > summary {
    padding: 0.7rem 1rem;
    cursor: pointer;
    font-weight: 600;
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem 0.7rem;
    align-items: center;
}

.prompt-card > summary::-webkit-details-marker {
    display: none;
}

.prompt-card__n {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.4rem;
    height: 1.35rem;
    padding: 0 0.4rem;
    border-radius: 6px;
    background: var(--bg-secondary, var(--surface-hover));
    font-variant-numeric: tabular-nums;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text-secondary, var(--text-subtle));
}

.prompt-card__name {
    color: var(--primary);
    line-height: 1.25;
}

.prompt-card__desc {
    font-weight: 400;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.prompt-form {
    padding: 0 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.prompt-field-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.prompt-textarea {
    width: 100%;
    min-height: 240px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.8rem;
    line-height: 1.5;
}

.prompt-textarea--user {
    min-height: 150px;
}

.placeholder-ref {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
    margin: 0.3rem 0 0.8rem;
}

.placeholder-ref code {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.05rem 0.35rem;
    font-size: 0.76rem;
    color: var(--primary);
}

.prompt-save-status {
    font-size: 0.82rem;
    font-weight: 600;
}

/* ═══ BRANDS ═════════════════════════════════════════════════════════ */
.btn-sm {
    padding: 0.25rem 0.6rem;
    font-size: 0.78rem;
}

.brand-geos {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    margin-bottom: 1rem;
}

.badge--active {
    background: var(--primary);
    color: #fff;
}

.brand-data {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.8rem;
    font-size: 0.78rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    max-height: 360px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}


/* ═══ Accessibility: focus ring + skip link ═══════════════════════════ */
button:focus-visible,
a:focus-visible,
.gl-job:focus-visible,
.gl-cell:focus-visible,
.btn-copy:focus-visible,
.btn-preview:focus-visible,
.project-card:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 1000;
    background: var(--primary);
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    text-decoration: none;
}

.skip-link:focus {
    left: 0;
}

/* ═══ Theme toggle + night surface overrides ═══════════════════════════ */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: 0 0 10px;
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    color: var(--sidebar-text);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover {
    background: var(--sidebar-hover);
    border-color: rgba(255, 255, 255, 0.16);
}

.theme-toggle__icon {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
}

.theme-toggle__text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-shell.is-sidebar-collapsed .theme-toggle {
    justify-content: center;
    padding: 10px;
}

.app-shell.is-sidebar-collapsed .theme-toggle__text {
    display: none;
}

html[data-theme="night"] .theme-toggle .theme-toggle__icon--moon,
html:not([data-theme="night"]) .theme-toggle .theme-toggle__icon--sun {
    display: none;
}

/* Подтянуть хардкод поверхностей под night */
html[data-theme="night"] .panel,
html[data-theme="night"] .project-card,
html[data-theme="night"] .projects-zone--ready,
html[data-theme="night"] .domain-search__dropdown,
html[data-theme="night"] .domain-search__field,
html[data-theme="night"] .page-topbar,
html[data-theme="night"] .pipeline-events,
html[data-theme="night"] .docs-regen,
html[data-theme="night"] .gallery-fs,
html[data-theme="night"] .lightbox,
html[data-theme="night"] .matrix-selection,
html[data-theme="night"] .gl-step__help,
html[data-theme="night"] .gl-step__tip,
html[data-theme="night"] .ui-num__control,
html[data-theme="night"] .pipeline-progress,
html[data-theme="night"] .table-wrap,
html[data-theme="night"] .site-table,
html[data-theme="night"] .project-create,
html[data-theme="night"] .model-card,
html[data-theme="night"] .model-ctx-menu,
html[data-theme="night"] input:not([type="checkbox"]):not([type="radio"]),
html[data-theme="night"] select,
html[data-theme="night"] textarea,
html[data-theme="night"] button:not(.primary):not(.danger):not(.theme-toggle):not(.gl-job):not(.gl-cell) {
    background: var(--surface);
    color: var(--text);
}

html[data-theme="night"] .ai-pipeline,
html[data-theme="night"] .ai-pipeline__controls,
html[data-theme="night"] .ai-pipeline__stages,
html[data-theme="night"] .img-gen,
html[data-theme="night"] .project-actions,
html[data-theme="night"] .gl-step,
html[data-theme="night"] .gl-step--img {
    background: transparent;
}

html[data-theme="night"] .gl-job--pending .gl-job__icon {
    background: var(--text-tertiary);
}

html[data-theme="night"] input:not([type="checkbox"]):not([type="radio"]),
html[data-theme="night"] select,
html[data-theme="night"] textarea,
html[data-theme="night"] .ui-num__control input[type="number"] {
    background: var(--input-bg);
    border-color: var(--border);
    color: var(--text);
}

html[data-theme="night"] .page-topbar__menu,
html[data-theme="night"] .page-topbar__actions a.secondary,
html[data-theme="night"] button.secondary,
html[data-theme="night"] .btn-xs.secondary,
html[data-theme="night"] .btn-docs,
html[data-theme="night"] .ui-num__btn {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--border);
    filter: none;
}

html[data-theme="night"] button.secondary {
    background: var(--primary-soft);
    color: var(--primary);
}

html[data-theme="night"] button.danger {
    background: var(--surface);
    color: var(--danger);
}

html[data-theme="night"] button.primary {
    background: var(--primary);
    color: var(--primary-text);
}

html[data-theme="night"] code {
    background: var(--surface-muted);
    border-color: var(--border);
    color: var(--text);
}

html[data-theme="night"] .site-table th,
html[data-theme="night"] .site-pages-table__section td {
    background: var(--chip-bg);
    color: var(--text-muted);
}

html[data-theme="night"] .site-pages-table thead th {
    background: var(--bg-secondary);
    color: var(--text);
    font-weight: 800;
}

html[data-theme="night"] .pipeline-matrix tbody tr.site-row-detail:hover > td {
    background: var(--surface);
}

html[data-theme="night"] .site-pages-table tbody tr.site-pages-table__section:hover > td {
    background: var(--chip-bg);
}

html[data-theme="night"] .site-pages-panel,
html[data-theme="night"] .site-pages-panel .table-wrap,
html[data-theme="night"] .page-prompt-editor,
html[data-theme="night"] .page-images-panel {
    background: transparent;
    border-color: transparent;
}

html[data-theme="night"] .site-table td,
html[data-theme="night"] .site-pages-table td {
    border-color: var(--border);
    color: var(--text);
}

html[data-theme="night"] .ptab-table .ptab-url {
    background: var(--input-bg);
    color: var(--text);
    border-color: var(--border);
}

html[data-theme="night"] .site-row:hover,
html[data-theme="night"] .page-row:hover {
    background: var(--surface-hover);
}

html[data-theme="night"] .site-row--selected > td {
    background: var(--primary-soft);
}

html[data-theme="night"] .pipeline-event--skip,
html[data-theme="night"] .empty-state,
html[data-theme="night"] .hint,
html[data-theme="night"] .pipe-group__title,
html[data-theme="night"] .ai-pipeline__stages-label,
html[data-theme="night"] .pipe-model__label,
html[data-theme="night"] .ui-num__label {
    color: var(--text-muted);
}

html[data-theme="night"] .flash-error,
html[data-theme="night"] .pipeline-error-box {
    background: var(--danger-soft);
    color: #fecaca;
    border-color: rgba(248, 113, 113, 0.35);
}

html[data-theme="night"] .flash-success {
    background: var(--success-soft);
    color: #a7f3d0;
}

html[data-theme="night"] .pipeline-progress__track {
    background: var(--surface-muted);
}

html[data-theme="night"] .ui-switch__track {
    background: var(--border-strong);
}

html[data-theme="night"] .ui-switch__thumb {
    background: #fff;
}

html[data-theme="night"] ::selection {
    background: var(--primary-soft);
}

/* ═══ CRAWLER ═══ */
.crawler-form {
    display: grid;
    gap: 1rem;
}

.crawler-form__domains textarea {
    width: 100%;
    min-height: 12rem;
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 0.85rem;
    line-height: 1.45;
    resize: vertical;
}

.crawler-form__row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.85rem;
}

@media (max-width: 900px) {
    .crawler-form__row {
        grid-template-columns: 1fr 1fr;
    }
}

.crawler-stat--ok { color: var(--success, #16a34a); font-weight: 600; }
.crawler-stat--err { color: var(--danger, #dc2626); font-weight: 600; }

.crawler-table-wrap {
    overflow-x: auto;
    margin-top: 0.5rem;
}

.crawler-table {
    width: 100%;
    min-width: 960px;
}

.crawler-table th.col-status,
.crawler-table td.col-status { width: 5.5rem; white-space: nowrap; vertical-align: top; }

.crawler-table th.col-domain,
.crawler-table td.col-domain { width: 14rem; vertical-align: top; }

.crawler-table th.col-ms,
.crawler-table td.col-ms { width: 3.5rem; text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.crawler-cell {
    max-width: 22rem;
    white-space: normal;
    word-break: break-word;
    font-size: 0.88rem;
    line-height: 1.35;
}

.crawler-cell--muted { color: var(--text-muted); }

.crawler-url {
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 0.8rem;
    word-break: break-all;
}

.crawler-err {
    margin-top: 0.35rem;
    font-size: 0.72rem;
    color: var(--danger, #dc2626);
    max-width: 8rem;
    white-space: normal;
    word-break: break-word;
}

.crawler-row--err > td {
    background: color-mix(in srgb, var(--danger-soft, #fef2f2) 55%, transparent);
}

html[data-theme="night"] .crawler-row--err > td {
    background: rgba(248, 113, 113, 0.06);
}

/* Compact overrides for spacious inline layouts */
.projects-grid-modern {
    gap: 10px !important;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)) !important;
}

.project-card-modern {
    border-radius: 8px !important;
}

.project-card-modern .project-card-link {
    padding: 12px 14px !important;
}

.project-card-modern .project-card-header {
    gap: 10px !important;
    margin-bottom: 10px !important;
}

.project-card-modern .project-card-icon {
    width: 32px !important;
    height: 32px !important;
    border-radius: 6px !important;
}

.project-card-modern .project-card-icon svg {
    width: 16px !important;
    height: 16px !important;
}

.project-card-modern .project-card-title {
    font-size: 14px !important;
    margin: 0 0 2px !important;
}

.project-card-modern .project-card-stats {
    gap: 8px !important;
    margin-bottom: 10px !important;
}

.project-card-modern .stat-badge,
.project-card-modern .stat-item {
    padding: 6px 8px !important;
    border-radius: 6px !important;
}

.project-card-modern .stat-value {
    font-size: 15px !important;
}

.project-card-modern .site-chip {
    padding: 2px 8px !important;
}

.project-card-modern .project-card-footer {
    padding-top: 8px !important;
}

.project-card-modern .btn-delete-project {
    width: 28px !important;
    height: 28px !important;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-overlay[hidden] {
    display: none;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 480px;
}

.modal--create {
    max-width: 560px;
}

.modal--log {
    max-width: min(920px, 96vw);
    width: 96vw;
    height: min(82vh, 920px);
    display: flex;
    flex-direction: column;
}

.modal--log .modal-header {
    flex: 0 0 auto;
    align-items: flex-start;
    gap: 12px;
}

.modal--log__sub {
    margin: 4px 0 0;
    font-size: 0.78rem;
}

.modal--log__body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0;
    overflow: hidden;
}

.modal--log .modal-footer {
    flex: 0 0 auto;
    justify-content: space-between;
}

.modal.modal--page {
    width: min(800px, 94vw);
    max-width: 800px;
    height: 94vh;
    display: flex;
    flex-direction: column;
}

.modal--page .modal-header {
    flex: 0 0 auto;
    align-items: flex-start;
    gap: 12px;
}

.modal--page__sub {
    margin: 4px 0 0;
    font-size: 0.78rem;
}

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

.modal--page__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 0 32px 28px;
}

.page-view-tabs {
    display: flex;
    gap: 2px;
    padding: 0 32px;
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
}

.page-view-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    min-height: 0;
    padding: 8px 12px;
    color: var(--text-secondary);
    font-size: 0.84rem;
    font-weight: 650;
    cursor: pointer;
}

.page-view-tab:hover {
    background: transparent;
    color: var(--text-primary);
}

.page-view-tab.is-active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.page-view-pane {
    padding-top: 16px;
}

.page-preview__seo {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0 0 18px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
}

.page-preview__seo-row span {
    display: block;
    margin-bottom: 2px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-subtle);
}

.page-preview__seo-row p,
.page-preview__seo-row strong {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--text-primary);
    font-weight: 550;
}

.page-view-pane[data-page-pane="article"] {
    max-width: 1120px;
    margin: 0 auto;
}

.page-preview {
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.62;
}

.page-preview h1 {
    margin: 0 0 12px;
    font-size: 1.55rem;
    font-weight: 750;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.page-preview h2 {
    margin: 28px 0 12px;
    font-size: 1.22rem;
    font-weight: 720;
    line-height: 1.3;
}

.page-preview h3 {
    margin: 22px 0 10px;
    font-size: 1.05rem;
    font-weight: 680;
}

.page-preview p {
    margin: 0 0 12px;
    color: var(--text-secondary);
}

.page-preview ul,
.page-preview ol {
    margin: 0 0 14px;
    padding-left: 1.35em;
    color: var(--text-secondary);
}

.page-preview li {
    margin: 5px 0;
}

.page-preview strong {
    color: var(--text-primary);
}

.page-preview img,
.page-preview .content-image,
.page-preview .zk-content-image {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.page-preview-figure,
.page-preview .zk-figure {
    max-width: 720px;
    margin: 22px auto 20px;
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    background: var(--bg-secondary);
}

.page-preview p:has(> img:only-child),
.page-preview p:has(> .content-image:only-child),
.page-preview p:has(> .zk-content-image:only-child) {
    max-width: 720px;
    margin: 22px auto 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    background: var(--bg-secondary);
}

.page-preview-table {
    margin: 16px 0;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.page-preview-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}

.page-preview-table th,
.page-preview-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
    color: var(--text-secondary);
    background: transparent;
}

.page-preview-table th {
    background: var(--chip-bg);
    color: var(--text-primary);
    font-weight: 650;
}

.page-preview-table tbody tr:last-child td {
    border-bottom: 0;
}

.page-preview-table tbody tr:hover > td {
    background: var(--surface-hover);
}

.page-preview-faq {
    margin-top: 28px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.page-view-pane .page-prompt-editor__text {
    min-height: min(52vh, 520px);
    width: 100%;
}

.page-view-pane .page-prompt-editor__actions {
    margin-top: 10px;
}

.pipe-log-badge {
    display: inline-block;
    min-width: 1.25em;
    padding: 0 0.38em;
    margin-left: 0.3em;
    border-radius: 999px;
    font-size: 0.72em;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    background: var(--primary-soft, color-mix(in srgb, var(--primary) 18%, transparent));
    color: var(--primary);
    vertical-align: middle;
}

.pipe-log-badge[hidden] {
    display: none;
}

.pipeline-log-more {
    align-self: center;
    font-size: 0.78rem;
    padding: 4px 10px;
}

#pipeline-log-empty {
    margin: 0;
    padding: 8px 12px;
}

#pipeline-log-empty[hidden] {
    display: none;
}

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

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
}

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

.modal-body {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal--create .modal-body label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modal--create input[type="text"],
.modal--create select {
    padding: 6px 8px;
}

.modal--create textarea {
    min-height: 110px;
    padding: 8px 10px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.45;
}

.create-project-row {
    display: grid;
    grid-template-columns: 1.5fr 0.8fr 0.7fr;
    gap: 8px;
}

.modal--create .hint {
    font-size: 12px;
    color: var(--text-tertiary);
}

.add-site-project {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.add-site-project strong {
    color: var(--text-primary);
    font-weight: 600;
    font-family: var(--font-mono);
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

@media (max-width: 640px) {
    .create-project-row {
        grid-template-columns: 1fr;
    }
}

.page-topbar__actions .secondary,
.page-topbar__actions .primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

label {
    gap: 4px;
}

.tab-close,
.tab-new,
.modal-close,
.theme-toggle-top,
.mobile-menu-btn,
.sidebar-item,
.btn-delete-project {
    min-height: 0;
}

.tab-close,
.modal-close {
    padding: 0;
}


/* Project tabs */
.project-tabs {
    display: flex;
    gap: 2px;
    margin: 4px 0 18px;
    padding: 0 2px;
    border-bottom: 1px solid var(--border);
}

.project-tab {
    background: none;
    border: none;
    padding: 9px 14px 10px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: var(--font-medium);
    letter-spacing: -0.01em;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.project-tab:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.project-tab.is-active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: transparent;
}

.project-tab-panel {
    display: none;
    width: 100%;
    min-width: 0;
}

.project-tab-panel.is-active {
    display: block;
}

.project-tab-panel.is-active.ptab {
    display: flex;
}

.project-tab-panel[hidden] {
    display: none !important;
}

.ptab {
    flex-direction: column;
    gap: 14px;
}

.ptab__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.ptab__head h2 {
    margin: 0 0 4px;
    font-size: 1.05rem;
    font-weight: 650;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.ptab__head .hint {
    margin: 0;
    max-width: 42rem;
    line-height: 1.4;
}

.ptab__badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ptab__badge:empty {
    display: none;
}

.ptab-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.ptab-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    min-width: 0;
}

.ptab-card .ptab-card__head h3 {
    margin: 0 0 3px;
    font-size: 13px;
    font-weight: 650;
    letter-spacing: -0.01em;
    text-transform: none;
    color: var(--text-primary);
}

.ptab-card__head .hint {
    margin: 0;
    line-height: 1.35;
}

.ptab-card__head--row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.ptab-card__foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 2px;
}

.ptab-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.ptab-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.ptab-field--grow {
    flex: 1 1 16rem;
}

.ptab-field--compact {
    min-width: 7rem;
}

.ptab-field > span {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.ptab-field input,
.ptab-field select {
    min-height: 32px;
}

.ptab-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.ptab-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    padding: 5px 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--surface);
    font-size: 12px;
}

.ptab-chip code {
    color: var(--primary);
}

.ptab-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
    max-width: 22rem;
}

.ptab-chip .is-muted {
    color: var(--text-tertiary);
}

.ptab-table {
    margin: 0 -16px;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
}

.ptab-table th:last-child,
.ptab-table td:last-child {
    width: 1%;
    white-space: nowrap;
}

.ptab-site {
    font-size: 12.5px;
}

.ptab-url {
    width: 100%;
    min-width: 0;
}

.ptab-preview {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-mono);
}

.ptab-preview:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.ptab-set-hint {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 11px;
}
.ptab-brand-name {
    padding-left: 28px;
    color: var(--text-secondary);
    font-size: 13px;
}
.ptab-table .ptab-url {
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.site-pages-panel__offers-hint {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 0;
    margin-left: auto;
}

.ptab-empty {
    margin: 0;
    padding: 28px 16px;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 13px;
}

.ptab-empty strong {
    display: block;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.ptab-empty p {
    margin: 0;
}

.ptab-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.ptab-kpi {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    min-width: 0;
}

.ptab-kpi__label {
    display: block;
    margin-bottom: 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.ptab-kpi__value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    line-height: 1.15;
}

.ptab-kpi__value--sm {
    font-size: 1.05rem;
}

.ptab-kpi--ok .ptab-kpi__value {
    color: var(--success);
}

.ptab-kpi--err .ptab-kpi__value {
    color: var(--error);
}

.ptab-stats {
    padding-bottom: 12px;
}

.ptab-stats .model-stats__list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    max-height: none;
    overflow: visible;
}

.ptab-stats .model-stats__row {
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    gap: 4px 10px;
    padding: 10px 12px;
    background: var(--surface);
}

.ptab-stats .model-stats__row:first-child {
    padding-top: 10px;
}

.ptab-stats .model-stats__model {
    font-size: 12.5px;
}

.ptab-stats .model-stats__cost {
    font-size: 13px;
}

.ptab-stats .model-stats__tokens {
    font-size: 11px;
}

.ptab-stats .model-stats__empty {
    padding: 18px 8px;
    text-align: center;
}

.ptab-log {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: min(68vh, 740px);
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
}

.ptab-log__bar {
    display: flex;
    justify-content: flex-start;
}

.ptab-log__bar:not(:has(button:not([hidden]))) {
    display: none;
}

.ptab-empty--log {
    padding: 16px;
}

.ptab-log:has(#pipeline-log-empty-tab:not([hidden])) {
    min-height: 0;
}

.ptab-log:has(#pipeline-log-empty-tab:not([hidden])) .pipeline-events--page {
    display: none;
}

.ptab-log .pipeline-events--page {
    flex: 1 1 auto;
    max-height: none;
    min-height: 360px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border-color: var(--border);
}

.ptab-log .pipeline-event {
    padding: 6px 0;
}

.ptab-log .pipeline-event__time {
    flex: 0 0 5.6rem;
    font-size: 11px;
}

@media (max-width: 900px) {
    .ptab-grid,
    .ptab-kpis,
    .ptab-stats .model-stats__list {
        grid-template-columns: 1fr;
    }

    .ptab-kpi__value {
        font-size: 1.1rem;
    }
}

/* ============ UTILITY CLASSES ============ */
.hint--flush {
    margin-top: 0 !important;
}

.panel-title--flush {
    margin: 0 !important;
}

/* ============ CASINO RATING: COMPACT STYLES ============ */
/* Секции формы с визуальными заголовками */
.form-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.form-section__title {
    margin: 0 0 var(--space-2);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

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

/* Компактная сетка для формы рейтинга */
.casino-grid--compact {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--space-2);
}

/* Короткие поля (рейтинг, акцент) */
.casino-grid--compact .field-short {
    grid-column: span 1;
    min-width: 140px;
}

/* Широкие поля (название, бонус, слаг) */
.casino-grid--compact .field-wide {
    grid-column: span 2;
    min-width: 280px;
}

@media (max-width: 640px) {
    .casino-grid--compact .field-short,
    .casino-grid--compact .field-wide {
        grid-column: span 1;
        min-width: 0;
    }
}

.spend-panel {
    margin-bottom: 16px;
}

.spend-kpis {
    margin-bottom: 16px;
}

.spend-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px 12px;
}

.spend-pills {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-secondary);
}

.spend-pill {
    display: inline-flex;
    align-items: center;
    height: 30px;
    padding: 0 12px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.spend-pill:hover {
    color: var(--text-primary);
}

.spend-pill.is-active {
    background: var(--surface);
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.spend-dates {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.spend-dates input {
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
}

.spend-meta {
    margin: 12px 0 0;
}

.spend-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.spend-table th,
.spend-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.spend-table th {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.spend-num {
    font-variant-numeric: tabular-nums;
}

.spend-muted {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.spend-gone {
    margin-left: 8px;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.spend-proj__head {
    cursor: pointer;
}

.spend-proj__head:hover {
    background: var(--surface-hover, var(--bg-secondary));
}

.spend-proj__head:focus-visible {
    outline: 2px solid var(--accent, #4f7cff);
    outline-offset: -2px;
}

.spend-chevron {
    display: inline-block;
    width: 0;
    height: 0;
    margin-right: 8px;
    border-style: solid;
    border-width: 5px 0 5px 7px;
    border-color: transparent transparent transparent var(--text-muted);
    vertical-align: middle;
    transition: transform 0.15s ease;
}

.spend-proj.is-open .spend-chevron {
    transform: rotate(90deg);
}

.spend-proj__name {
    font-weight: 600;
}

.spend-proj__open {
    margin-left: 8px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
}

.spend-proj__open:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

.spend-proj__models {
    display: none;
}

.spend-proj.is-open .spend-proj__models {
    display: table-row;
}

.spend-proj__models > td {
    padding: 0 10px 12px 34px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.spend-table--nested {
    margin: 8px 0 4px;
    background: var(--surface, var(--bg));
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.spend-table--nested th,
.spend-table--nested td {
    padding: 6px 10px;
}

.spend-table--nested tr:last-child td {
    border-bottom: 0;
}

.spend-model {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.82rem;
}

@media (max-width: 720px) {
    .spend-kpis.ptab-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.badge--warning {
    background: var(--warning-soft);
    color: var(--warning);
    border-color: var(--warning);
}

.sidebar-logout {
    margin: 0;
}

.sidebar-logout .sidebar-item {
    width: 100%;
}

.top-user {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-right: 6px;
    padding: 2px 8px 2px 2px;
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
}

.top-user:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.top-user-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 11px;
    font-weight: 700;
}

.top-user-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.top-logout {
    margin: 0;
}

.top-logout-btn {
    min-height: 28px;
    padding: 2px 8px;
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

/* ============ LOGIN  ============ */
.login-body {
    min-height: 100vh;
    margin: 0;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
}

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    position: relative;
}

.login-theme {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-secondary);
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 28px 28px 24px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--bg-secondary);
    box-shadow: var(--shadow-lg);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.login-kicker {
    margin: 0 0 2px;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.login-brand h1 {
    margin: 0;
    font-size: 1.25rem;
    letter-spacing: -0.03em;
}

.login-lead {
    margin: 0 0 18px;
    color: var(--text-secondary);
    font-size: var(--text-sm);
    line-height: 1.5;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-submit {
    margin-top: 6px;
    min-height: 40px;
    width: 100%;
}

/* ============ USERS  ============ */
.users-secret {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.users-secret-grid {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 12px;
    align-items: end;
}

.users-secret-label {
    display: block;
    margin-bottom: 6px;
    font-size: 11px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.users-secret-value {
    display: block;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    word-break: break-all;
}

.users-create-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    align-items: end;
}

.users-create-actions {
    display: flex;
    align-items: end;
}

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

.users-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.users-table th,
.users-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.users-table th {
    font-size: 11px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.users-table tr.is-disabled td {
    opacity: 0.65;
}

.users-who {
    display: flex;
    align-items: center;
    gap: 10px;
}

.users-who strong {
    display: block;
}

.users-who code {
    display: inline-block;
    margin-right: 6px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.users-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 700;
    flex-shrink: 0;
}

.users-muted {
    color: var(--text-tertiary);
    white-space: nowrap;
}

.users-col-status {
    width: 7.5rem;
    white-space: nowrap;
}

.users-col-actions {
    width: 1%;
}

.users-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.users-actions form {
    display: inline-flex;
    margin: 0;
}

.users-actions button {
    white-space: nowrap;
    flex: 0 0 auto;
}

@media (max-width: 720px) {
    .top-user-name {
        display: none;
    }

    .users-secret-grid {
        grid-template-columns: 1fr;
    }
}
