:root {
    --pg-orange: #FF5A00;
    --pg-orange-hover: #E04F00;
    --pg-black: #0A0A0A;
    --pg-dark-grey: #333333;
    --pg-grey: #666666;
    --pg-light-grey: #F5F5F5;
    --pg-white: #FFFFFF;
    --pg-border: #E5E5E5;
    --radius-sm: 4px;
    --radius-md: 8px;
    --shadow-subtle: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-hover: 0 4px 12px rgba(0,0,0,0.08);
    --sidebar-width: 240px;
    --topbar-height: 56px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Bricolage Grotesque', sans-serif;
    background-color: var(--pg-light-grey);
    color: var(--pg-dark-grey);
    font-size: 0.9rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    margin: 0;
}

h1, h2, h3, h4, h5, h6, .navbar-brand {
    font-family: 'Space Grotesk', sans-serif;
    color: var(--pg-black);
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin-bottom: 0.75rem;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; font-weight: 700; }
h4 { font-size: 1rem; }

p { margin-bottom: 0.75rem; }

.text-accent { color: var(--pg-orange); }
.text-muted { color: var(--pg-grey) !important; }

/* Buttons */
.btn {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    letter-spacing: 0.01em;
}

.btn-primary {
    background-color: var(--pg-orange);
    border: 1px solid var(--pg-orange);
    color: var(--pg-white);
}
.btn-primary:hover {
    background-color: var(--pg-orange-hover);
    border-color: var(--pg-orange-hover);
    color: var(--pg-white);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--pg-border);
    color: var(--pg-black);
}
.btn-outline:hover {
    background-color: var(--pg-light-grey);
    border-color: var(--pg-dark-grey);
    color: var(--pg-black);
}

.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-danger-outline {
    background: transparent;
    border: 1px solid #fca5a5;
    color: #dc2626;
}
.btn-danger-outline:hover { background: #fef2f2; }

.btn-success-outline {
    background: transparent;
    border: 1px solid #86efac;
    color: #16a34a;
}
.btn-success-outline:hover { background: #f0fdf4; }

/* Tags & Badges */
.tag-orange {
    display: inline-block;
    background: rgba(255, 90, 0, 0.1);
    color: var(--pg-orange);
    padding: 3px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 2px;
    font-family: 'Space Grotesk', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: 'Space Grotesk', sans-serif;
}
.badge-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}
.badge-active { background: #dcfce7; color: #166534; }
.badge-active::before { background: #22c55e; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-pending::before { background: #f59e0b; }
.badge-closed { background: var(--pg-light-grey); color: var(--pg-grey); }
.badge-closed::before { background: var(--pg-grey); }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-rejected::before { background: #ef4444; }
.badge-completed { background: #dbeafe; color: #1e40af; }
.badge-completed::before { background: #3b82f6; }

/* Cards */
.pg-card {
    background: var(--pg-white);
    border: 1px solid var(--pg-border);
    border-radius: var(--radius-sm);
    padding: 20px;
}
.pg-card-sm { padding: 16px; }

.stat-card {
    background: var(--pg-white);
    border: 1px solid var(--pg-border);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    height: 100%;
}
.stat-card .stat-label {
    font-size: 0.75rem;
    color: var(--pg-grey);
    font-weight: 500;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-family: 'Space Grotesk', sans-serif;
}
.stat-card .stat-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--pg-black);
    line-height: 1.2;
}
.stat-card .stat-change {
    font-size: 0.75rem;
    margin-top: 4px;
}
.stat-change.up { color: #16a34a; }
.stat-change.down { color: #dc2626; }

/* Forms */
.form-label {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--pg-black);
    margin-bottom: 6px;
}
.form-control, .form-select {
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: 0.875rem;
    border: 1px solid var(--pg-border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--pg-dark-grey);
}
.form-control:focus, .form-select:focus {
    border-color: var(--pg-orange);
    box-shadow: 0 0 0 3px rgba(255, 90, 0, 0.1);
}

/* Tables */
.pg-table-wrap {
    background: var(--pg-white);
    border: 1px solid var(--pg-border);
    border-radius: var(--radius-sm);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}
.pg-table-wrap .dataTables_wrapper {
    min-width: 0;
    overflow-x: auto;
}
.pg-table {
    width: 100%;
    margin: 0;
    font-size: 0.85rem;
}
.pg-table thead th {
    background: var(--pg-light-grey);
    border-bottom: 1px solid var(--pg-border);
    padding: 10px 16px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--pg-grey);
    white-space: nowrap;
}
.pg-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--pg-light-grey);
    vertical-align: middle;
}
.pg-table tbody tr:last-child td { border-bottom: none; }
.pg-table tbody tr:hover { background: #fafafa; }

.table-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--pg-light-grey);
    border: 1px solid var(--pg-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--pg-black);
    font-family: 'Space Grotesk', sans-serif;
}

/* Page header */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}
.page-header h1 { margin-bottom: 0; }
.page-header .breadcrumb-text {
    font-size: 0.8rem;
    color: var(--pg-grey);
    margin-top: 2px;
}

/* Filter bar */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}
.filter-pill {
    padding: 5px 14px;
    border: 1px solid var(--pg-border);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    background: var(--pg-white);
    color: var(--pg-dark-grey);
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}
.filter-pill:hover, .filter-pill.active {
    background: var(--pg-black);
    color: var(--pg-white);
    border-color: var(--pg-black);
}

/* App Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
    overflow: hidden;
    max-width: 100vw;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--pg-white);
    border-right: 1px solid var(--pg-border);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease;
}
.sidebar-brand {
    padding: 16px 20px;
    border-bottom: 1px solid var(--pg-border);
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--pg-black);
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
}
.sidebar-brand:hover { color: var(--pg-black); }
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}
.sidebar-section {
    padding: 8px 20px 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--pg-grey);
    font-family: 'Space Grotesk', sans-serif;
}
.sidebar-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 20px;
    color: var(--pg-dark-grey);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.15s;
    border-left: 2px solid transparent;
}
.sidebar-link-label {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.nav-badge {
    flex-shrink: 0;
    background: #ef4444;
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.sidebar-link i { width: 16px; text-align: center; font-size: 0.8rem; color: var(--pg-grey); }
.sidebar-link:hover { background: var(--pg-light-grey); color: var(--pg-black); }
.sidebar-link.active {
    background: rgba(255, 90, 0, 0.06);
    color: var(--pg-orange);
    border-left-color: var(--pg-orange);
    font-weight: 600;
}
.sidebar-link.active i { color: var(--pg-orange); }
.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--pg-border);
}

/* Main content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow: hidden;
    max-width: 100%;
}

.page-content {
    padding: 24px;
    flex: 1;
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 0;
}

.topbar {
    height: var(--topbar-height);
    background: var(--pg-white);
    border-bottom: 1px solid var(--pg-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 1030;
}
.topbar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--pg-light-grey);
    border: 1px solid var(--pg-border);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    width: 280px;
    max-width: 100%;
}
.topbar-search input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.85rem;
    width: 100%;
    font-family: 'Bricolage Grotesque', sans-serif;
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-icon-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--pg-border);
    border-radius: var(--radius-sm);
    background: var(--pg-white);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--pg-dark-grey);
    cursor: pointer;
    position: relative;
    text-decoration: none;
}
.topbar-icon-btn:hover { background: var(--pg-light-grey); }
.topbar-icon-btn .notif-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 7px;
    height: 7px;
    background: var(--pg-orange);
    border-radius: 50%;
}

/* User dropdown */
.user-dropdown .user-menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px solid var(--pg-border);
    border-radius: var(--radius-sm);
    padding: 4px 10px 4px 4px;
    cursor: pointer;
    transition: background 0.15s;
}
.user-dropdown .user-menu-btn:hover,
.user-dropdown .user-menu-btn.show {
    background: var(--pg-light-grey);
}
.user-dropdown .user-menu-btn::after {
    font-size: 0.65rem;
    margin-left: 2px;
    color: var(--pg-grey);
}
.user-dropdown .dropdown-menu {
    border: 1px solid var(--pg-border);
    border-radius: var(--radius-sm);
    padding: 6px;
    min-width: 200px;
}
.user-dropdown .dropdown-item {
    font-size: 0.85rem;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
}
.user-dropdown .dropdown-item:hover {
    background: var(--pg-light-grey);
}

/* Auth layout */
.auth-layout {
    min-height: 100vh;
    display: flex;
}
.auth-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 48px;
    background: var(--pg-white);
}
.auth-right {
    flex: 1;
    background: var(--pg-black);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}
.auth-brand {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--pg-black);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 40px;
}
.auth-form-wrap { max-width: 400px; width: 100%; }
.auth-form-wrap h1 { font-size: 1.75rem; margin-bottom: 8px; }

/* Chart placeholder */
.chart-placeholder {
    background: var(--pg-light-grey);
    border-radius: var(--radius-sm);
    height: 200px;
    display: flex;
    align-items: flex-end;
    padding: 16px;
    gap: 8px;
}
.chart-bar {
    flex: 1;
    background: var(--pg-orange);
    border-radius: 2px 2px 0 0;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.chart-bar:hover { opacity: 1; }

/* Chat UI */
.chat-thread {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 500px;
    overflow-y: auto;
    padding: 16px;
}
.chat-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
}
.chat-bubble.user {
    align-self: flex-start;
    background: var(--pg-light-grey);
    border: 1px solid var(--pg-border);
}
.chat-bubble.agent {
    align-self: flex-end;
    background: var(--pg-black);
    color: var(--pg-white);
}
.chat-meta {
    font-size: 0.7rem;
    color: var(--pg-grey);
    margin-bottom: 4px;
}
.workflow-event {
    align-self: center;
    background: rgba(255, 90, 0, 0.08);
    border: 1px dashed rgba(255, 90, 0, 0.3);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--pg-orange);
    font-family: 'Space Grotesk', sans-serif;
}

/* Widget Studio — chat widget customizer */
.widget-studio {
    display: grid;
    grid-template-columns: minmax(300px, 420px) 1fr;
    gap: 16px;
    align-items: start;
    min-height: 0;
}
.widget-studio-controls {
    background: var(--pg-white);
    border: 1px solid var(--pg-border);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - var(--topbar-height) - 100px);
    overflow: hidden;
}
.widget-studio-mobile-tabs {
    display: none;
    border-bottom: 1px solid var(--pg-border);
    padding: 0 12px;
    background: var(--pg-white);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    margin-bottom: -1px;
}
.widget-studio-mobile-tabs .ws-mobile-tab {
    flex: 1;
    text-align: center;
    padding: 10px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--pg-grey);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
}
.widget-studio-mobile-tabs .ws-mobile-tab.active {
    color: var(--pg-orange);
    border-bottom-color: var(--pg-orange);
}
.widget-studio-settings-only {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    min-width: 0;
}
.widget-studio-settings-only h4 {
    font-size: 0.9rem;
    margin-bottom: 12px;
    font-family: 'Space Grotesk', sans-serif;
}
.widget-studio-preview-only {
    display: block;
}
.widget-studio-preview-only .widget-studio-preview {
    position: static;
    max-height: none;
}
.widget-studio-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--pg-border);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    background: var(--pg-white);
}

/* Live preview (right) */
.widget-studio-preview {
    background: var(--pg-white);
    border: 1px solid var(--pg-border);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: calc(var(--topbar-height) + 16px);
    max-height: calc(100vh - var(--topbar-height) - 100px);
    min-height: 480px;
}
.widget-preview-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--pg-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--pg-light-grey);
    flex-shrink: 0;
}
.widget-preview-header h4 {
    font-size: 0.85rem;
    margin: 0;
    font-family: 'Space Grotesk', sans-serif;
}
.widget-preview-device {
    display: flex;
    gap: 4px;
}
.widget-preview-device button {
    padding: 4px 10px;
    font-size: 0.7rem;
    border: 1px solid var(--pg-border);
    background: var(--pg-white);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: 'Space Grotesk', sans-serif;
}
.widget-preview-device button.active {
    background: var(--pg-black);
    color: var(--pg-white);
    border-color: var(--pg-black);
}
.widget-preview-canvas {
    flex: 1;
    background: #e8e8e8;
    padding: 20px;
    overflow: auto;
    position: relative;
    min-height: 400px;
}
.widget-preview-canvas.device-mobile {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 24px 16px;
}
.widget-preview-site {
    background: var(--pg-white);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-hover);
    width: 100%;
    min-height: 360px;
    position: relative;
    overflow: hidden;
}
.widget-preview-canvas.device-mobile .widget-preview-site {
    max-width: 375px;
    min-height: 520px;
    border-radius: 20px;
    border: 6px solid var(--pg-black);
}
.widget-preview-site-bar {
    height: 28px;
    background: var(--pg-light-grey);
    border-bottom: 1px solid var(--pg-border);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 5px;
}
.widget-preview-site-bar span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--pg-border);
}
.widget-preview-site-body {
    padding: 24px;
    min-height: 280px;
}
.widget-preview-site-body .mock-block {
    height: 12px;
    background: var(--pg-light-grey);
    border-radius: 2px;
    margin-bottom: 10px;
}
.widget-preview-site-body .mock-block.w-75 { width: 75%; }
.widget-preview-site-body .mock-block.w-50 { width: 50%; }

/* Chat widget in preview */
#widget-preview-root {
    --ws-primary: #FF5A00;
    --ws-font: 'Bricolage Grotesque', sans-serif;
}
.widget-preview-chat {
    position: absolute;
    width: 340px;
    max-width: calc(100% - 24px);
    background: var(--pg-white);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    border: 1px solid var(--pg-border);
    overflow: hidden;
    z-index: 10;
    font-family: var(--ws-font);
}
.widget-preview-chat.pos-bottom-right { bottom: 16px; right: 16px; }
.widget-preview-chat.pos-bottom-left { bottom: 16px; left: 16px; }
.widget-preview-chat.pos-top-right { top: 16px; right: 16px; bottom: auto; }
.widget-preview-chat.pos-top-left { top: 16px; left: 16px; bottom: auto; }
.widget-preview-site-chrome {
    padding: 8px 16px;
    border-bottom: 1px solid var(--pg-border);
    background: var(--pg-white);
}
.widget-preview-url {
    font-size: 0.7rem;
    color: var(--pg-grey);
    font-family: 'Space Grotesk', sans-serif;
}
.widget-preview-site-body .mock-hero {
    height: 48px;
    background: linear-gradient(90deg, var(--pg-light-grey) 0%, #f0f0f0 100%);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}
.widget-preview-site-body .mock-block.w-60 { width: 60%; }
.widget-preview-chat-header {
    background: var(--ws-primary);
    color: var(--pg-white);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.widget-preview-close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--pg-white);
    opacity: 0.85;
    cursor: pointer;
    padding: 4px 6px;
    font-size: 0.9rem;
    line-height: 1;
}
.widget-preview-close:hover { opacity: 1; }
.widget-preview-chat-header .ws-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}
.widget-preview-chat-tabs {
    display: flex;
    border-bottom: 1px solid var(--pg-border);
    background: var(--pg-light-grey);
}
.widget-preview-chat-tabs button {
    flex: 1;
    padding: 8px;
    font-size: 0.7rem;
    font-weight: 600;
    border: none;
    background: transparent;
    color: var(--pg-grey);
    font-family: 'Space Grotesk', sans-serif;
    cursor: default;
}
.widget-preview-chat-tabs button.active {
    background: var(--pg-white);
    color: var(--pg-black);
    border-bottom: 2px solid var(--ws-primary);
    margin-bottom: -1px;
}
.widget-preview-chat-body { padding: 14px; max-height: 220px; overflow-y: auto; }
.widget-preview-welcome {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--pg-black);
    margin-bottom: 4px;
}
.widget-preview-sub {
    font-size: 0.75rem;
    color: var(--pg-grey);
    margin-bottom: 12px;
}
.widget-preview-starters {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.widget-preview-starter {
    padding: 8px 12px;
    border: 1px solid var(--pg-border);
    border-radius: 20px;
    font-size: 0.75rem;
    text-align: left;
    background: var(--pg-white);
    color: var(--pg-dark-grey);
    cursor: default;
}
.widget-preview-starter:hover { border-color: var(--ws-primary); color: var(--ws-primary); }
.widget-preview-chat-input {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--pg-border);
}
.widget-preview-chat-input input {
    flex: 1;
    border: 1px solid var(--pg-border);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 0.75rem;
    outline: none;
}
.widget-preview-chat-input button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--ws-primary);
    color: white;
    font-size: 0.75rem;
}
.widget-preview-launcher {
    position: absolute;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--ws-primary);
    color: white;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    z-index: 9;
    border: none;
    cursor: pointer;
    transition: transform 0.15s;
}
.widget-preview-launcher:hover { transform: scale(1.05); }
.widget-preview-launcher.pos-bottom-right { bottom: 16px; right: 16px; }
.widget-preview-launcher.pos-bottom-left { bottom: 16px; left: 16px; }
.widget-preview-launcher.pos-top-right { top: 16px; right: 16px; bottom: auto; }
.widget-preview-launcher.pos-top-left { top: 16px; left: 16px; bottom: auto; }
.widget-preview-launcher.show { display: flex; }

.starter-input-row {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}
.starter-input-row input { flex: 1; }

@media (max-width: 1199px) {
    .widget-studio {
        grid-template-columns: 1fr;
    }
    .widget-studio-preview {
        position: static;
        max-height: none;
        min-height: 420px;
    }
    .widget-studio-controls {
        max-height: none;
    }
}

@media (max-width: 767px) {
    .widget-studio-mobile-tabs {
        display: flex;
    }
    .widget-studio {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    .widget-studio-settings-only {
        max-height: 50vh;
        overflow-y: auto;
    }
    .widget-preview-chat {
        width: calc(100% - 24px);
        max-width: none;
    }
    .widget-preview-chat.pos-bottom-right,
    .widget-preview-chat.pos-bottom-left {
        left: 12px !important;
        right: 12px !important;
        transform: none !important;
    }
}

.code-editor {
    background: var(--pg-black);
    color: #D4D4D4;
    font-family: monospace;
    font-size: 0.8rem;
    padding: 16px;
    border-radius: var(--radius-sm);
    min-height: 300px;
    line-height: 1.6;
    overflow: auto;
}

/* Info banner */
.info-banner {
    background: rgba(255, 90, 0, 0.06);
    border: 1px solid rgba(255, 90, 0, 0.2);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
}
.info-banner i { color: var(--pg-orange); margin-top: 2px; }

/* Tabs */
.pg-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--pg-border);
    margin-bottom: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
}
.pg-tab {
    padding: 10px 18px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--pg-grey);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}
.pg-tab:hover { color: var(--pg-black); }
.pg-tab.active {
    color: var(--pg-orange);
    border-bottom-color: var(--pg-orange);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--pg-grey);
}
.empty-state i { font-size: 2rem; margin-bottom: 12px; opacity: 0.4; }

/* Landing page extras */
.section-padding { padding: 80px 0; }
.bg-light-grey { background-color: var(--pg-light-grey); }
.bg-black { background-color: var(--pg-black); color: var(--pg-white); }
.footer { background: var(--pg-black); color: var(--pg-white); padding: 60px 0 30px; }
.footer-heading { font-family: 'Space Grotesk', sans-serif; font-size: 0.9rem; font-weight: 600; color: var(--pg-grey); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 20px; }
.footer-link { display: block; color: #A0A0A0; text-decoration: none; margin-bottom: 10px; font-size: 0.9rem; }
.footer-link:hover { color: var(--pg-white); }

/* Mobile sidebar */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.1rem;
    color: var(--pg-black);
    cursor: pointer;
    padding: 4px 8px;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1035;
}

@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    .sidebar-toggle { display: block; }
    .main-content { margin-left: 0; }
    .auth-right { display: none; }
    .auth-left { padding: 32px 24px; }
}

@media (max-width: 576px) {
    .page-content { padding: 16px; }
    .topbar { padding: 0 16px; }
    .topbar-search { display: none; }
    .kpi-value { font-size: 1.25rem !important; }
    .page-header h1 { font-size: 1.35rem; }
}

/* KPI Cards with edge-to-edge sparklines */
.kpi-card {
    background: var(--pg-white);
    border: 1px solid var(--pg-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
}
.kpi-card-inner {
    padding: 16px 16px 10px;
    flex: 1;
}
.kpi-label {
    font-size: 0.7rem;
    color: var(--pg-grey);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-family: 'Space Grotesk', sans-serif;
    margin-bottom: 6px;
}
.kpi-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--pg-black);
    line-height: 1.15;
    margin-bottom: 8px;
}
.kpi-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.kpi-change {
    font-size: 0.72rem;
    font-weight: 600;
    font-family: 'Space Grotesk', sans-serif;
}
.kpi-change.up { color: #16a34a; }
.kpi-change.down { color: #dc2626; }
.kpi-prev {
    font-size: 0.68rem;
    color: var(--pg-grey);
    line-height: 1.3;
}
.kpi-sparkline {
    height: 44px;
    width: 100%;
    margin-top: auto;
    line-height: 0;
}
.kpi-sparkline .apexcharts-canvas { margin: 0 !important; }
.kpi-sparkline svg { display: block; width: 100% !important; }

/* Apex chart cards */
.chart-card {
    padding: 0;
    overflow: hidden;
}
.chart-card-header {
    padding: 16px 20px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.chart-card-header h4 {
    font-size: 0.9rem;
    margin: 0;
    font-family: 'Space Grotesk', sans-serif;
}
.apex-chart {
    padding: 0 12px 12px;
    min-height: 240px;
    width: 100%;
}
.apex-chart > div {
    min-height: 240px;
}

/* DataTables */
.pg-table-wrap { overflow-x: auto; }
table.dataTable { margin: 0 !important; width: 100% !important; min-width: 560px; }
table.dataTable thead th {
    background: var(--pg-light-grey);
    border-bottom: 1px solid var(--pg-border) !important;
    padding: 10px 14px !important;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--pg-grey);
    white-space: nowrap;
}
table.dataTable tbody td {
    padding: 11px 14px !important;
    font-size: 0.85rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--pg-light-grey);
}
table.dataTable tbody tr:hover { background: #fafafa; }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--pg-border);
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    font-size: 0.8rem;
    font-family: 'Bricolage Grotesque', sans-serif;
}
.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--pg-orange);
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 90, 0, 0.1);
}
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    font-size: 0.78rem;
    color: var(--pg-grey);
    padding: 12px 16px;
}
.dataTables_wrapper .dataTables_paginate { padding: 8px 16px 12px; }
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: var(--radius-sm) !important;
    font-size: 0.78rem !important;
    padding: 4px 10px !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--pg-black) !important;
    color: var(--pg-white) !important;
    border-color: var(--pg-black) !important;
}
.dataTables_wrapper .row:first-child,
.dataTables_wrapper .row:last-child {
    margin: 0;
    background: var(--pg-white);
    border-top: 1px solid var(--pg-light-grey);
}
.dataTables_wrapper .row:first-child { border-top: none; border-bottom: 1px solid var(--pg-light-grey); }
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before {
    background-color: var(--pg-orange);
    box-shadow: none;
    border: none;
}

/* Filter toolbar */
.filter-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.filter-toolbar .filter-bar { margin-bottom: 0; flex: 1; }
.filter-extra {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.filter-extra select {
    font-size: 0.8rem;
    padding: 5px 10px;
    border: 1px solid var(--pg-border);
    border-radius: var(--radius-sm);
    background: var(--pg-white);
}

/* Payment split layout */
.payment-split {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 16px;
    align-items: start;
}
.payment-chat-panel {
    background: var(--pg-white);
    border: 1px solid var(--pg-border);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 180px);
    position: sticky;
    top: calc(var(--topbar-height) + 16px);
}
.payment-chat-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--pg-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.payment-chat-body { flex: 1; overflow-y: auto; padding: 12px; }
.payment-chat-footer {
    padding: 12px;
    border-top: 1px solid var(--pg-border);
}
.payment-row-active { background: rgba(255, 90, 0, 0.06) !important; }
tr.payment-row { cursor: pointer; }

/* Settings tabs */
.settings-tab-panel { display: none; }
.settings-tab-panel.active { display: block; }

/* Plan modal */
.plan-modal-card {
    border: 1px solid var(--pg-border);
    border-radius: var(--radius-sm);
    padding: 20px;
    height: 100%;
    transition: all 0.2s;
    cursor: pointer;
}
.plan-modal-card:hover { border-color: var(--pg-orange); box-shadow: var(--shadow-hover); }
.plan-modal-card.current { border: 2px solid var(--pg-black); }
.plan-modal-card .plan-price {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
}

/* Modals */
.modal-content {
    border: 1px solid var(--pg-border);
    border-radius: var(--radius-md);
    font-family: 'Bricolage Grotesque', sans-serif;
}
.modal-header {
    border-bottom: 1px solid var(--pg-border);
    padding: 16px 20px;
}
.modal-header .modal-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 1rem;
}
.modal-body { padding: 20px; }
.modal-footer {
    border-top: 1px solid var(--pg-border);
    padding: 12px 20px;
}

@media (max-width: 1199px) {
    .payment-split { grid-template-columns: 1fr; }
    .payment-chat-panel {
        position: static;
        max-height: 480px;
    }
}

@media (max-width: 767px) {
    .filter-toolbar { flex-direction: column; align-items: stretch; }
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter { text-align: left !important; }
    .dataTables_wrapper .dataTables_filter input { width: 100% !important; margin-left: 0 !important; }
}

/* Flash alerts & form feedback */
.pg-alert {
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    border: 1px solid transparent;
    animation: pgSlideIn 0.3s ease;
}
.pg-alert-success { background: #f0fdf4; border-color: #86efac; color: #166534; }
.pg-alert-error { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.pg-alert-warning { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
.pg-alert-info { background: #eff6ff; border-color: #93c5fd; color: #1e40af; }

@keyframes pgSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.pg-toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.pg-toast {
    background: var(--pg-black);
    color: var(--pg-white);
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    box-shadow: var(--shadow-hover);
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.3s ease;
}
.pg-toast.show { opacity: 1; transform: translateX(0); }
.pg-toast-success { border-left: 3px solid #22c55e; }
.pg-toast-error { border-left: 3px solid #ef4444; }

.btn.pg-loading { pointer-events: none; opacity: 0.85; }

.was-validated .form-control:invalid {
    border-color: #ef4444;
    animation: pgShake 0.3s ease;
}
@keyframes pgShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.input-group-password { position: relative; }
.input-group-password .toggle-pw {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--pg-grey);
    cursor: pointer;
    z-index: 5;
}
