﻿/* ============================================================
   PENTRE GROUP — MASTER THEME
   Version: 1.0  |  April 2026
   ============================================================ */

/* ============================================================
   ROOT — DESIGN TOKENS
   ============================================================ */
:root {
    --pg-red: #C93C40;
    --pg-red-dark: #A52B2E;
    --pg-red-light: #FFF0F0;
    --pg-red-text: #A52B2E;
    --pg-charcoal: #1A1C1E;
    --pg-charcoal-mid: #2E3236;
    --pg-grey-mid: #5B5A5C;
    --pg-grey-steel: #8C96A0;
    --pg-off-white: #F5F3EE;
    --pg-white: #FFFFFF;
    --pg-border: #D8DCE0;
    --pg-border-light: #F0EDE8;
    --pg-green-bg: #EEFAF4;
    --pg-green-text: #1A6B42;
    --pg-blue-bg: #EBF4FF;
    --pg-blue-text: #1A5FA8;
    --pg-amber-bg: #FFF8EC;
    --pg-amber-text: #8C5A00;
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --text-display: 28px;
    --text-h1: 22px;
    --text-h2: 18px;
    --text-h3: 16px;
    --text-body: 15px;
    --text-small: 13px;
    --text-label: 12px;
    --text-micro: 11px;
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 10px;
    --radius-xl: 12px;
    --radius-pill: 999px;
    --border-default: 0.5px solid var(--pg-border);
    --border-light: 0.5px solid var(--pg-border-light);
    --border-dark: 0.5px solid var(--pg-charcoal-mid);
    --border-red: 1.5px solid var(--pg-red);
    --border-charcoal: 1.5px solid var(--pg-charcoal);
}

/* ============================================================
   BASE RESET
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-body);
    color: var(--pg-charcoal);
    background: var(--pg-off-white);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
.pg-display {
    font-size: var(--text-display);
    font-weight: 500;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--pg-charcoal);
}

.pg-h1 {
    font-size: var(--text-h1);
    font-weight: 500;
    letter-spacing: -0.01em;
    line-height: 1.3;
    color: var(--pg-charcoal);
}

.pg-h2 {
    font-size: var(--text-h2);
    font-weight: 500;
    line-height: 1.4;
    color: var(--pg-charcoal);
}

.pg-h3 {
    font-size: var(--text-h3);
    font-weight: 500;
    line-height: 1.4;
    color: var(--pg-charcoal);
}

.pg-body {
    font-size: var(--text-body);
    font-weight: 400;
    line-height: 1.7;
    color: var(--pg-charcoal);
}

.pg-small {
    font-size: var(--text-small);
    color: var(--pg-grey-steel);
    line-height: 1.5;
}

.pg-label {
    font-size: var(--text-label);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--pg-red);
}

.pg-label-muted {
    font-size: var(--text-micro);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--pg-grey-steel);
}

.pg-mono {
    font-family: var(--font-mono);
    font-size: 0.93em;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.pg-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-xl);
}

.pg-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
}

.pg-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
}

.pg-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
}

.pg-flex {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.pg-divider {
    border: none;
    border-top: var(--border-default);
    margin: var(--space-md) 0;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.pg-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    padding: 9px 20px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.15s, transform 0.1s;
    white-space: nowrap;
}

    .pg-btn:active {
        transform: scale(0.98);
    }

.pg-btn-primary {
    background: var(--pg-red);
    color: var(--pg-white);
}

    .pg-btn-primary:hover {
        background: var(--pg-red-dark);
        color: var(--pg-white);
    }

.pg-btn-dark {
    background: var(--pg-charcoal);
    color: var(--pg-white);
}

    .pg-btn-dark:hover {
        opacity: 0.85;
    }

.pg-btn-outline {
    background: transparent;
    color: var(--pg-charcoal);
    border: var(--border-charcoal);
}

    .pg-btn-outline:hover {
        background: var(--pg-off-white);
    }

.pg-btn-outline-red {
    background: transparent;
    color: var(--pg-red);
    border: var(--border-red);
}

    .pg-btn-outline-red:hover {
        background: var(--pg-red-light);
    }

.pg-btn-ghost {
    background: transparent;
    color: var(--pg-grey-steel);
    border: var(--border-default);
}

    .pg-btn-ghost:hover {
        background: var(--pg-off-white);
        color: var(--pg-charcoal);
    }

.pg-btn:disabled {
    background: var(--pg-off-white) !important;
    color: var(--pg-border) !important;
    cursor: not-allowed;
    border-color: var(--pg-border) !important;
    transform: none !important;
}

.pg-btn-sm {
    font-size: 12px;
    padding: 6px 14px;
}

.pg-btn-lg {
    font-size: 16px;
    padding: 12px 28px;
}

/* ============================================================
   BADGES
   ============================================================ */
.pg-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
}

.pg-badge-red {
    background: var(--pg-red);
    color: var(--pg-white);
}

.pg-badge-dark {
    background: var(--pg-charcoal);
    color: var(--pg-white);
}

.pg-badge-neutral {
    background: var(--pg-off-white);
    color: var(--pg-grey-mid);
    border: var(--border-default);
}

.pg-badge-green {
    background: var(--pg-green-bg);
    color: var(--pg-green-text);
}

.pg-badge-blue {
    background: var(--pg-blue-bg);
    color: var(--pg-blue-text);
}

.pg-badge-amber {
    background: var(--pg-amber-bg);
    color: var(--pg-amber-text);
}

.pg-badge-danger {
    background: var(--pg-red-light);
    color: var(--pg-red-text);
}

/* ============================================================
   CARDS
   ============================================================ */
.pg-card {
    background: var(--pg-white);
    border: var(--border-default);
    border-radius: var(--radius-xl);
    padding: var(--space-md) 18px;
}

.pg-card-dark {
    background: var(--pg-charcoal);
    border: var(--border-dark);
    border-radius: var(--radius-xl);
    padding: var(--space-md) 18px;
}

.pg-card-surface {
    background: var(--pg-off-white);
    border-radius: var(--radius-xl);
    padding: var(--space-md) 18px;
}

.pg-stat-card {
    background: var(--pg-off-white);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
}

.pg-stat-label {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--pg-grey-steel);
    margin-bottom: 4px;
}

.pg-stat-value {
    font-size: 26px;
    font-weight: 500;
    color: var(--pg-charcoal);
}

.pg-stat-sub {
    font-size: 12px;
    margin-top: 4px;
}

/* ============================================================
   FORMS
   ============================================================ */
.pg-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.pg-label-field {
    font-size: 12px;
    font-weight: 500;
    color: var(--pg-grey-mid);
}

.pg-input, .pg-select, .pg-textarea {
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--pg-charcoal);
    background: var(--pg-white);
    border: 1px solid var(--pg-border);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    width: 100%;
    transition: border-color 0.15s;
    outline: none;
}

    .pg-input:focus, .pg-select:focus, .pg-textarea:focus {
        border-color: var(--pg-charcoal);
    }

.pg-input-mono {
    font-family: var(--font-mono);
}

.pg-input-error {
    border-color: var(--pg-red);
}

.pg-textarea {
    min-height: 90px;
    resize: vertical;
}

.pg-field-hint {
    font-size: 12px;
    color: var(--pg-grey-steel);
}

.pg-field-error {
    font-size: 12px;
    color: var(--pg-red);
}

/* ============================================================
   TABLE
   ============================================================ */
.pg-table-wrap {
    background: var(--pg-white);
    border: var(--border-default);
    border-radius: var(--radius-xl);
    overflow: hidden;
}

.pg-table {
    width: 100%;
    border-collapse: collapse;
}

    .pg-table th {
        background: var(--pg-off-white);
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: var(--pg-grey-steel);
        padding: 10px 16px;
        text-align: left;
        border-bottom: var(--border-default);
    }

    .pg-table td {
        font-size: 13px;
        padding: 11px 16px;
        border-bottom: var(--border-light);
        color: var(--pg-charcoal);
        vertical-align: middle;
    }

    .pg-table tr:last-child td {
        border-bottom: none;
    }

    .pg-table tr:nth-child(even) td {
        background: #FAFAF8;
    }

/* ============================================================
   ALERTS
   ============================================================ */
.pg-alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    border-left: 3px solid transparent;
}

.pg-alert-info {
    background: var(--pg-blue-bg);
    color: var(--pg-blue-text);
    border-left-color: var(--pg-blue-text);
}

.pg-alert-success {
    background: var(--pg-green-bg);
    color: var(--pg-green-text);
    border-left-color: var(--pg-green-text);
}

.pg-alert-warning {
    background: var(--pg-amber-bg);
    color: var(--pg-amber-text);
    border-left-color: var(--pg-amber-text);
}

.pg-alert-danger {
    background: var(--pg-red-light);
    color: var(--pg-red-text);
    border-left-color: var(--pg-red);
}

/* ============================================================
   PROGRESS
   ============================================================ */
.pg-progress {
    background: var(--pg-border);
    border-radius: var(--radius-pill);
    height: 6px;
    overflow: hidden;
}

.pg-progress-bar {
    background: var(--pg-red);
    height: 100%;
    border-radius: var(--radius-pill);
    transition: width 0.3s ease;
}

/* ============================================================
   APP SHELL — SIDEBAR LAYOUT
   ============================================================ */
.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.app-sidebar {
    width: 64px;
    min-width: 64px;
    background: var(--pg-charcoal);
    transition: width 0.22s cubic-bezier(0.4,0,0.2,1), min-width 0.22s cubic-bezier(0.4,0,0.2,1);
    display: flex;
    flex-direction: column;
    padding: 0;
    border-right: var(--border-dark);
    overflow: hidden;
}

.app-sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    min-height: 70px;
    padding: 16px 10px;
    border-bottom: 0.5px solid var(--pg-charcoal-mid);
    position: relative;
}

.app-sidebar-logo-name {
    display: none;
}

.app-sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.app-sidebar-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    width: 100%;
    height: 44px;
    padding: 0;
    color: var(--pg-grey-steel);
    font-size: 13px;
    font-weight: 400;
    text-decoration: none;
    transition: color 0.15s, background 0.15s;
    border-right: 2px solid transparent;
}

    .app-sidebar-link:hover {
        color: var(--pg-white);
        background: rgba(255,255,255,0.04);
    }

    .app-sidebar-link.active {
        color: var(--pg-white);
        border-right-color: var(--pg-red);
        background: rgba(255,255,255,0.06);
    }

.app-sidebar-link-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.app-sidebar-link-icon svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.app-sidebar-link-text,
.app-sidebar-action-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.app-sidebar-section {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--pg-grey-mid);
    padding: 16px 20px 6px;
}

.app-sidebar-footer {
    padding: 12px 8px;
    border-top: 0.5px solid var(--pg-charcoal-mid);
}

.app-sidebar-user {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.app-sidebar-user-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    flex: 1;
    min-width: 0;
}

.app-sidebar-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-pill);
    background: var(--pg-red);
    color: var(--pg-white);
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.app-sidebar-user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--pg-white);
}

.app-sidebar-user-meta,
.app-sidebar-user-role {
    display: none;
}

.app-sidebar-user-role-pill {
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 3px;
    color: #fff;
}

.app-sidebar-actions {
    display: grid;
    gap: 8px;
}

.app-sidebar-ai-btn {
    width: 100%;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: var(--radius-md);
    background: rgba(184,30,49,0.16);
    color: var(--pg-white);
    cursor: pointer;
    margin-bottom: 10px;
    transition: background 0.15s, transform 0.12s, border-color 0.15s;
}

.app-sidebar-ai-btn:hover {
    background: rgba(184,30,49,0.28);
    border-color: rgba(255,255,255,0.28);
    transform: translateY(-1px);
}

.app-sidebar-ai-btn__icon {
    font-size: 18px;
    line-height: 1;
}

.app-sidebar-action {
    width: 100%;
    height: 38px;
    justify-content: center;
    padding: 0;
    font-size: 12px;
}

.app-sidebar-action-form {
    margin: 0;
}

/* ── Sidebar collapsed state ──────────────────────────────────────────── */
.sidebar-collapsed .app-sidebar {
    width: 0;
    min-width: 0;
    overflow: hidden;
}
/* Sidebar tab pinned to the left edge: closes when open, reopens when hidden */
.pg-sidebar-expand-tab {
    display: flex;
    position: fixed; top: 50%; left: 64px;
    transform: translateY(-50%);
    z-index: 250;
    background: var(--pg-charcoal);
    color: var(--pg-white);
    border: none; border-radius: 0 6px 6px 0;
    width: 18px; height: 52px;
    cursor: pointer; font-size: 13px; font-weight: 600;
    align-items: center; justify-content: center;
    transition: left 0.22s cubic-bezier(0.4,0,0.2,1), width 0.15s;
}
.sidebar-collapsed .pg-sidebar-expand-tab { left: 0; }
.pg-sidebar-expand-tab:hover { width: 24px; }
.pg-sidebar-expand-tab__closed { display: none; }
.sidebar-collapsed .pg-sidebar-expand-tab__open { display: none; }
.sidebar-collapsed .pg-sidebar-expand-tab__closed { display: inline; }

.app-main {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-width: 0;
    background: var(--pg-off-white);
}

.app-main-header {
    background: var(--pg-white);
    border-bottom: var(--border-default);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
    min-width: 0;
}

.app-main-content {
    padding: 32px;
    min-width: 0;
}

/* ============================================================
   TABS
   ============================================================ */
.pg-tabs {
    display: flex;
    gap: 2px;
    border-bottom: var(--border-default);
    margin-bottom: var(--space-lg);
}

.pg-tab {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--pg-grey-steel);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    text-decoration: none;
    transition: color 0.15s;
}

    .pg-tab:hover {
        color: var(--pg-charcoal);
    }

    .pg-tab.active {
        color: var(--pg-red);
        border-bottom-color: var(--pg-red);
    }

/* ==========================================================
   CREATE POPOVER
   ========================================================== */

.pg-create-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--pg-white);
    border: 1px solid var(--pg-border);
    border-radius: var(--radius-xl);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 9999;
    width: 280px;
    overflow: hidden;
}

.pg-create-menu--wide {
    width: 340px;
}

/* Section dividers inside the popover */
.pg-create-menu__section {
    padding: 8px 6px;
}

    .pg-create-menu__section + .pg-create-menu__section {
        border-top: 1px solid var(--pg-border);
    }

/* Small uppercase label above each group of items */
.pg-create-menu__section-label {
    font-size: var(--text-micro);
    font-weight: 600;
    color: var(--pg-grey-steel);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px 4px;
}

/* Clickable row inside the popover */
.pg-create-menu__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    color: var(--pg-charcoal);
    text-decoration: none;
    font-size: var(--text-body);
    cursor: pointer;
    transition: background 0.1s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

    .pg-create-menu__item:hover {
        background: var(--pg-off-white);
        color: var(--pg-charcoal);
        text-decoration: none;
    }

.pg-create-menu__item-icon {
    font-size: 16px;
    flex-shrink: 0;
}

/* Location dropdown row at the top */
.pg-create-menu__location {
    padding: 10px 14px;
    border-bottom: 1px solid var(--pg-border);
}

    .pg-create-menu__location .pg-create-menu__section-label {
        padding: 0;
        margin-bottom: 6px;
    }

/* ---- Expanded form panel ---- */

.pg-create-menu__panel {
    display: none;
    padding: 14px;
}

.pg-create-menu__panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.pg-create-menu__back {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--pg-grey-steel);
    font-size: 18px;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.1s;
}

    .pg-create-menu__back:hover {
        color: var(--pg-charcoal);
    }

.pg-create-menu__panel-title {
    font-size: var(--text-body);
    font-weight: 600;
    color: var(--pg-charcoal);
}

/* Field rows inside the panel */
.pg-create-menu__field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

    .pg-create-menu__field label {
        font-size: var(--text-small);
        font-weight: 500;
        color: var(--pg-grey-mid);
    }

    .pg-create-menu__field .pg-input,
    .pg-create-menu__field .pg-select,
    .pg-create-menu__field .pg-textarea {
        font-size: var(--text-small);
        padding: 7px 10px;
    }

    .pg-create-menu__field .pg-textarea {
        min-height: 70px;
        resize: vertical;
    }

/* Footer with create button */
.pg-create-menu__footer {
    display: flex;
    gap: var(--space-xs);
    padding-top: 10px;
    border-top: 1px solid var(--pg-border);
    margin-top: 4px;
}

/* ==========================================================
   FORM PAGE LAYOUT (kept for any future standalone forms)
   ========================================================== */

.pg-form-page {
    max-width: 600px;
}

.pg-form-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--pg-border);
}

/* ==========================================================
   ALERT / TOAST MESSAGES
   ========================================================== */

.pg-alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-size: var(--text-small);
    margin-bottom: var(--space-md);
}

.pg-alert-success {
    background: var(--pg-green-bg);
    border: 1px solid #86efac;
    color: var(--pg-green-text);
}

.pg-alert-error {
    background: var(--pg-red-light);
    border: 1px solid var(--pg-red);
    color: var(--pg-red-text);
}

/* ==========================================================
   CONTEXT MENU (3-line button + floating menu)
   ========================================================== */

.pg-row-actions {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.pg-context-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    color: var(--pg-grey-steel);
    font-size: 16px;
    line-height: 1;
    transition: background 0.1s, color 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .pg-context-btn:hover {
        background: var(--pg-off-white);
        color: var(--pg-charcoal);
    }

.pg-context-menu {
    display: none;
    position: fixed;
    background: var(--pg-white);
    border: 1px solid var(--pg-border);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10);
    z-index: 9999;
    min-width: 160px;
    overflow: hidden;
    padding: 4px;
}

.pg-context-menu__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: var(--text-small);
    color: var(--pg-charcoal);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    transition: background 0.1s;
}

    .pg-context-menu__item:hover {
        background: var(--pg-off-white);
    }

.pg-context-menu__item--danger {
    color: var(--pg-red);
}

    .pg-context-menu__item--danger:hover {
        background: var(--pg-red-light);
    }

.pg-context-menu__divider {
    height: 1px;
    background: var(--pg-border);
    margin: 4px 0;
}

/* ==========================================================
   UNDO TOAST
   ========================================================== */

.pg-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--pg-charcoal);
    color: var(--pg-white);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: var(--text-small);
    z-index: 99999;
    animation: pg-toast-in 0.2s ease;
    white-space: nowrap;
}

/* ============================================================
   APP TOAST STACK (window.pgToast — distinct from undo toast above)
   ============================================================ */

.pg-app-toast-stack {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-width: 360px;
}

.pg-app-toast {
    pointer-events: auto;
    background: var(--pg-charcoal);
    color: var(--pg-white);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    font-size: 13px;
    line-height: 1.4;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.pg-app-toast--shown {
    opacity: 1;
    transform: translateX(0);
}

.pg-app-toast--success { background: #14532d; }
.pg-app-toast--error   { background: var(--pg-red); }
.pg-app-toast--info    { background: var(--pg-charcoal); }

.pg-confirm-overlay {
    align-items: center;
    justify-content: center;
}

.pg-toast__message {
    color: var(--pg-white);
}

.pg-toast__undo {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: var(--pg-white);
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: var(--text-small);
    cursor: pointer;
    transition: background 0.1s;
    font-family: var(--font-sans);
}

    .pg-toast__undo:hover {
        background: rgba(255, 255, 255, 0.15);
    }

.pg-toast__close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0 0 0 4px;
    transition: color 0.1s;
}

    .pg-toast__close:hover {
        color: var(--pg-white);
    }

@keyframes pg-toast-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ==========================================================
   DRAG HANDLE (used in Step 2.3 for reordering)
   ========================================================== */

.pg-drag-handle {
    cursor: grab;
    color: var(--pg-grey-steel);
    padding: 4px 6px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.15s;
    display: flex;
    align-items: center;
}

    .pg-drag-handle:active {
        cursor: grabbing;
    }

tr:hover .pg-drag-handle,
.pg-card:hover .pg-drag-handle {
    opacity: 1;
}

.pg-drag-ghost {
    opacity: 0.4;
    background: var(--pg-off-white);
}

/* ==========================================================
   STAR / FAVOURITE BUTTON
   ========================================================== */

.pg-star-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: #D1D5DB;
    padding: 0 6px;
    transition: color 0.15s, transform 0.1s;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

    .pg-star-btn:hover {
        color: #FCD34D;
        transform: scale(1.2);
    }

.pg-star-btn--active {
    color: #FCD34D;
}

/* ============================================================
   SHEET TOOLBAR
   ============================================================ */

.pg-sheet-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--pg-white);
    border: var(--border-default);
    border-radius: 6px;
    padding: 4px 8px;
    margin-bottom: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    min-height: 38px;
}

.pg-sheet-toolbar > * {
    flex-shrink: 0;
}

.pg-sheet-toolbar::-webkit-scrollbar {
    height: 4px;
}

.pg-sheet-toolbar::-webkit-scrollbar-thumb {
    background: var(--pg-border);
    border-radius: 2px;
}

.pg-tb-group {
    display: flex;
    align-items: center;
    gap: 1px;
}

.pg-toolbar-menu-wrap {
    position: relative;
    display: inline-flex;
}

.pg-tb-divider {
    width: 1px;
    height: 20px;
    background: var(--pg-border);
    margin: 0 6px;
    flex-shrink: 0;
}

.pg-tb-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 7px;
    border: none;
    background: transparent;
    border-radius: 4px;
    color: var(--pg-charcoal);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s;
    min-width: 26px;
    height: 26px;
    justify-content: center;
}

.pg-tb-btn:hover:not(:disabled) {
    background: var(--pg-off-white);
}

.pg-tb-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.pg-tb-btn--active {
    background: var(--pg-off-white);
    color: var(--pg-charcoal);
    font-weight: 500;
}

.pg-tb-btn--fmt {
    font-size: 13px;
    min-width: 26px;
}

/* View toggle buttons look slightly more tab-like */
.pg-tb-view-toggle .pg-tb-btn {
    padding: 3px 10px;
    gap: 5px;
    font-size: 12px;
}

.pg-tb-view-toggle .pg-tb-btn--active {
    background: var(--pg-off-white);
    border: var(--border-default);
}

/* Font selects */
.pg-tb-select {
    height: 26px;
    border: var(--border-default);
    border-radius: 4px;
    background: var(--pg-white);
    color: var(--pg-charcoal);
    font-size: 12px;
    font-family: inherit;
    padding: 0 4px;
    cursor: pointer;
    outline: none;
}

.pg-tb-font-family { width: 152px; }
.pg-tb-font-size   { width: 52px; }

.pg-tb-select:focus {
    border-color: var(--pg-grey-steel);
}

/* Colour picker buttons */
.pg-tb-colour-btn {
    cursor: pointer;
    padding: 3px 6px;
}

.pg-tb-colour-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

.pg-tb-colour-swatch {
    display: block;
    width: 13px;
    height: 3px;
    border-radius: 1px;
}

.pg-tb-colour-swatch--none {
    background:
        linear-gradient(45deg, transparent 45%, #b81e31 46%, #b81e31 54%, transparent 55%),
        linear-gradient(135deg, #fff 25%, #e5e7eb 25%, #e5e7eb 50%, #fff 50%, #fff 75%, #e5e7eb 75%);
    background-size: 100% 100%, 6px 6px;
}

.pg-colour-menu {
    position: fixed;
    z-index: 900;
    min-width: 210px;
    padding: 9px;
    background: var(--pg-white);
    border: var(--border-default);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.14);
}

.pg-colour-menu__title {
    margin: 0 0 7px;
    font-size: 11px;
    font-weight: 600;
    color: var(--pg-grey-steel);
}

.pg-colour-menu__grid {
    display: grid;
    grid-template-columns: repeat(5, 28px);
    gap: 6px;
}

.pg-colour-swatch-btn {
    width: 28px;
    height: 24px;
    border: 1px solid var(--pg-grey-border);
    border-radius: 4px;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.45);
}

.pg-colour-swatch-btn:hover {
    outline: 2px solid rgba(184,30,49,0.28);
    outline-offset: 1px;
}

.pg-colour-swatch-btn--none {
    background:
        linear-gradient(45deg, transparent 45%, #b81e31 46%, #b81e31 54%, transparent 55%),
        linear-gradient(135deg, #fff 25%, #e5e7eb 25%, #e5e7eb 50%, #fff 50%, #fff 75%, #e5e7eb 75%) !important;
    background-size: 100% 100%, 8px 8px !important;
}

.pg-colour-menu__custom {
    margin-top: 8px;
    width: 100%;
    padding: 7px 9px;
    border: var(--border-default);
    border-radius: 4px;
    background: var(--pg-white);
    color: var(--pg-charcoal);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    text-align: left;
}

.pg-colour-menu__custom:hover {
    background: var(--pg-off-white);
}

.pg-tb-zoom-group .pg-tb-btn {
    min-width: 28px;
}

.pg-tb-zoom-value {
    min-width: 46px;
    font-variant-numeric: tabular-nums;
}

/* Export button — slightly distinct */
.pg-tb-export-btn {
    padding: 3px 10px;
    gap: 5px;
    color: var(--pg-grey-mid);
    font-size: 12px;
}

.pg-tb-export-btn:hover {
    background: var(--pg-off-white);
    color: var(--pg-charcoal);
}

/* ============================================================
   CREATE JOB BUTTON + MENU
   ============================================================ */

.pg-create-job-wrap {
    position: relative;
}

.pg-create-job-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.pg-create-job-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 260px;
    background: var(--pg-white);
    border: var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    z-index: 200;
    overflow: hidden;
}

.pg-create-job-menu__item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    background: none;
    border: none;
    font-size: 13px;
    color: var(--pg-charcoal);
    cursor: pointer;
    text-align: left;
    text-decoration: none;
}

.pg-create-job-menu__item:hover {
    background: var(--pg-off-white);
}

.pg-create-job-menu__item--subtle {
    color: var(--pg-grey-steel);
    font-size: 12px;
}

.pg-create-job-menu__divider {
    height: 1px;
    background: var(--pg-off-white);
    margin: 2px 0;
}

.pg-create-job-menu__item-row {
    display: flex;
    align-items: stretch;
}
.pg-create-job-menu__item-main {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pg-create-job-menu__item-edit {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    background: none;
    border: none;
    border-left: var(--border-default);
    color: var(--pg-grey-steel);
    cursor: pointer;
    flex-shrink: 0;
}
.pg-create-job-menu__item-edit:hover {
    background: var(--pg-off-white);
    color: var(--pg-charcoal);
}

/* ============================================================
   CREATE JOB MODAL
   ============================================================ */

.pg-create-job-modal {
    width: 680px;
    max-width: 95vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.pg-create-job-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    padding: 10px 14px;
    background: #fffbeb;
    border: 1px solid #f59e0b;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: #92400e;
}

.pg-create-job-fields {
    flex: 1;
    overflow-y: auto;
    padding: 4px 20px;
}

.pg-create-job-field {
    display: grid;
    grid-template-columns: 140px 1fr;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--pg-off-white);
}

.pg-create-job-field:last-child {
    border-bottom: none;
}

.pg-create-job-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--pg-charcoal);
}

.pg-create-job-input {
    width: 100%;
}

.pg-create-job-checkbox {
    width: auto !important;
    height: 16px;
    accent-color: var(--pg-charcoal);
}

/* New row highlight animation */
@keyframes pg-row-highlight {
    0%   { background: rgba(184,30,49,0.12); }
    100% { background: transparent; }
}
.pg-new-row-highlight td {
    animation: pg-row-highlight 2s ease forwards;
}

/* ============================================================
   CONFIGURE FORM PANEL
   ============================================================ */

.pg-configure-form-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 440px;
    background: var(--pg-white);
    transform: translateX(100%);
    transition: transform 0.22s ease;
    z-index: 300;
    box-shadow: -4px 0 24px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
}

.pg-configure-form-panel.open {
    transform: translateX(0);
}

.pg-configure-form-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.pg-configure-form-item {
    display: grid;
    grid-template-columns: 28px 40px 1fr 160px;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    border-bottom: 1px solid var(--pg-off-white);
    cursor: grab;
    background: var(--pg-white);
}

.pg-configure-form-item:last-child { border-bottom: none; }
.pg-configure-dragging { opacity: 0.4; }
.pg-configure-drag-over { background: var(--pg-off-white); }

.pg-configure-form-item__drag {
    color: var(--pg-grey-steel);
    font-size: 14px;
    cursor: grab;
}

.pg-configure-form-item__toggle {
    position: relative;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.pg-configure-form-item__toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.pg-configure-toggle-track {
    width: 32px;
    height: 18px;
    background: var(--pg-grey-light, #e2e5e8);
    border-radius: 9px;
    transition: background 0.18s;
    position: relative;
    display: block;
}

.pg-configure-form-item__toggle input:checked + .pg-configure-toggle-track {
    background: var(--pg-charcoal);
}

.pg-configure-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    transition: left 0.18s;
}

.pg-configure-form-item__toggle input:checked + .pg-configure-toggle-track .pg-configure-toggle-thumb {
    left: 16px;
}

.pg-configure-form-item__name {
    font-size: 13px;
    font-weight: 500;
    color: var(--pg-charcoal);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pg-configure-form-footer {
    padding: 14px 20px;
    border-top: var(--border-default);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Grid spacing modes */
#sheet-grid.pg-grid--comfortable tbody tr td,
#sheet-grid.pg-grid--comfortable tbody tr th {
    padding-top: 10px;
    padding-bottom: 10px;
}

/* ============================================================
   CARD VIEW
   ============================================================ */

.pg-card-view {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    align-items: flex-start;
    padding: 4px 2px 16px;
    min-height: 160px;
}

.pg-card-group {
    flex-shrink: 0;
    width: 248px;
    background: var(--pg-off-white);
    border: var(--border-default);
    border-radius: 8px;
    overflow: hidden;
}

.pg-card-group__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 12px;
    background: var(--pg-white);
    border-bottom: var(--border-default);
}

.pg-card-group__title {
    font-size: 13px;
    font-weight: 600;
    color: var(--pg-charcoal);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pg-card-group__count {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 500;
    color: var(--pg-grey-steel);
    background: var(--pg-border);
    border-radius: 10px;
    padding: 1px 7px;
}

.pg-card-group__body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
}

.pg-card-item {
    background: var(--pg-white);
    border: var(--border-default);
    border-radius: 6px;
    padding: 10px 12px;
    cursor: pointer;
    transition: border-color 0.12s, box-shadow 0.12s;
}

.pg-card-item:hover {
    border-color: var(--pg-grey-steel);
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.pg-card-item__num {
    font-size: 11px;
    font-weight: 500;
    color: var(--pg-grey-steel);
    margin-bottom: 7px;
}

.pg-card-item__fields {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pg-card-item__field {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 12px;
    line-height: 1.4;
}

.pg-card-item__label {
    flex-shrink: 0;
    width: 68px;
    color: var(--pg-grey-steel);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
}

.pg-card-item__value {
    flex: 1;
    color: var(--pg-charcoal);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pg-card-item__footer {
    display: flex;
    gap: 10px;
    margin-top: 9px;
    padding-top: 8px;
    border-top: var(--border-light);
}

.pg-card-item__indicator {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: var(--pg-grey-steel);
}

.pg-card-empty {
    font-size: 12px;
    color: var(--pg-grey-steel);
    text-align: center;
    padding: 12px 0;
}

/* ============================================================
   SHEET GRID
   ============================================================ */

.pg-sheet-grid-wrap {
    --sheet-zoom: 1;
    --indicator-width: 68px;
    --row-number-width: 48px;
    overflow: auto;
    overscroll-behavior: contain;
    max-width: 100%;
    max-height: calc(100vh - 230px);
    min-height: 360px;
    background: var(--pg-white);
    border: var(--border-default);
    border-radius: var(--radius-lg);
}

.pg-sheet-grid {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    zoom: var(--sheet-zoom);
}

.pg-virtual-spacer td {
    padding: 0;
    border: 0;
    background: transparent;
}

.pg-sheet-grid__col-header {
    background: var(--pg-off-white);
    border: var(--border-default);
    padding: 0;
    min-width: 60px;
    position: relative;
    overflow: hidden;
}

.pg-sheet-grid thead th {
    position: sticky;
    top: 0;
    z-index: 30;
}

.pg-sheet-grid .pg-row-indicator-th,
.pg-sheet-grid .pg-row-indicator {
    position: sticky;
    left: var(--row-number-width);
    z-index: 25;
    background: var(--pg-off-white);
    background-clip: padding-box;
    box-shadow: 1px 0 0 var(--pg-border);
}

.pg-sheet-grid .pg-row-indicator-th {
    z-index: 45;
}

.pg-sheet-grid .pg-sheet-grid__row-num {
    position: sticky;
    left: 0;
    z-index: 24;
    background: var(--pg-off-white);
    background-clip: padding-box;
    box-shadow: 1px 0 0 var(--pg-border);
}

.pg-sheet-grid thead .pg-sheet-grid__row-num {
    z-index: 44;
}

.pg-sheet-grid .pg-sheet-grid__row-num::after,
.pg-sheet-grid .pg-row-indicator::after,
.pg-sheet-grid .pg-row-indicator-th::after {
    content: "";
    position: absolute;
    top: 0;
    right: -1px;
    width: 1px;
    height: 100%;
    background: var(--pg-border);
    pointer-events: none;
}

.pg-col-header-inner {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    height: 100%;
    position: relative;
}

.pg-col-header-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 2px 4px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.12s ease, opacity 0.1s ease;
    flex-shrink: 0;
}

.pg-sheet-grid__col-header:hover .pg-col-header-controls,
.pg-sheet-grid__col-header--selected .pg-col-header-controls {
    max-height: 28px;
    overflow: visible;
    opacity: 1;
}

.pg-sheet-grid__col-header--selected {
    outline: 2px solid var(--pg-primary, #4f6ef7);
    outline-offset: -2px;
}

.pg-col-header-name {
    display: block;
    padding: 5px 10px;
    font-size: var(--text-small);
    font-weight: 500;
    color: var(--pg-charcoal);
    cursor: pointer;
    word-break: break-word;
    white-space: normal;
    flex: 1;
    min-height: 26px;
}

.pg-col-header-name--readonly {
    cursor: default;
}

.pg-col-header-name--editing {
    border-bottom: 1.5px solid var(--pg-charcoal);
}

.pg-col-rename-input {
    width: 100%;
    border: none;
    background: transparent;
    font-family: var(--font-sans);
    font-size: var(--text-small);
    font-weight: 500;
    color: var(--pg-charcoal);
    outline: none;
    padding: 0;
}

.pg-col-drag-handle {
    cursor: grab;
    color: var(--pg-grey-steel);
    font-size: 14px;
    user-select: none;
    padding: 0 2px;
    flex-shrink: 0;
    margin-right: auto;
}

.pg-col-resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 1;
    flex-shrink: 0;
}

.pg-col-resize-handle:hover,
.pg-col-resize-handle:active {
    background: var(--pg-primary, #4f6ef7);
    opacity: 0.4;
}

.pg-row-resize-handle,
.pg-header-resize-handle {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 5px;
    cursor: row-resize;
    z-index: 2;
}

.pg-row-resize-handle:hover,
.pg-row-resize-handle:active,
.pg-header-resize-handle:hover,
.pg-header-resize-handle:active {
    background: var(--pg-primary, #4f6ef7);
    opacity: 0.4;
}

/* Wrap mode: let cells grow to fit content */
.pg-sheet--wrap .pg-cell {
    height: auto;
}

.pg-sheet--wrap .pg-cell-checkbox-wrap {
    height: auto;
    min-height: 36px;
}

.pg-sheet--wrap .pg-cell-input {
    height: auto;
    min-height: 36px;
}

.pg-col-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--pg-grey-steel);
    padding: 0 2px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    flex-shrink: 0;
}

.pg-sheet-grid__col-header:hover .pg-col-delete-btn {
    opacity: 1;
}

.pg-col-delete-btn:hover {
    color: var(--pg-red);
}

.pg-sheet-grid__row-num {
    width: 48px;
    min-width: 48px;
    background: var(--pg-off-white);
    border: var(--border-default);
    position: relative;
    text-align: center;
    cursor: pointer;
    user-select: none;
}

.pg-sheet-grid__row-num:hover {
    background: color-mix(in srgb, var(--pg-off-white) 70%, var(--pg-charcoal) 30%);
}

.pg-sheet-row--row-selected .pg-sheet-grid__row-num {
    background: #dbeafe;
}

.pg-sheet-row--row-selected td,
.pg-sheet-row--row-selected .pg-row-indicator,
.pg-sheet-row--row-selected .pg-sheet-grid__row-num {
    background: #dbeafe !important;
}

.pg-sheet-row--row-selected td.pg-cell {
    outline: 1px solid #3b82f6;
    outline-offset: -1px;
}

.pg-sheet-row--active .pg-row-indicator,
.pg-sheet-row--active .pg-sheet-grid__row-num {
    background: #edf5ff !important;
}

.pg-sheet-row--active .pg-row-indicator,
.pg-sheet-row--active .pg-sheet-grid__row-num {
    box-shadow: inset 0 0 0 9999px rgba(59, 130, 246, 0.10);
}

.pg-sheet-row--row-selected .pg-row-indicator,
.pg-sheet-row--row-selected .pg-sheet-grid__row-num {
    box-shadow: inset 0 0 0 9999px rgba(59, 130, 246, 0.16);
}

/* ── Archived rows ──────────────────────────────────────────────────────────── */

.pg-sheet-row--archived td {
    opacity: 0.55;
    font-style: italic;
}

.pg-sheet-row--archived .pg-sheet-grid__row-num::before {
    content: '●';
    font-size: 7px;
    color: var(--pg-grey-steel);
    display: block;
    line-height: 1;
    margin-bottom: 2px;
}

/* ── Status bar ─────────────────────────────────────────────────────────────── */

.pg-status-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 12px;
    background: var(--pg-off-white);
    border-top: var(--border-default);
    font-size: 11px;
    color: var(--pg-grey-steel);
    min-height: 26px;
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.pg-status-bar__item {
    white-space: nowrap;
}

.pg-status-bar__sep {
    color: var(--pg-grey-border);
}

.pg-status-bar__archived {
    color: var(--pg-grey-steel);
    cursor: pointer;
    text-decoration: underline dotted;
}

.pg-status-bar__stats {
    color: var(--pg-charcoal);
    font-weight: 500;
}

.pg-status-bar__busy {
    margin-left: auto;
    align-items: center;
    gap: 6px;
    color: var(--pg-grey-steel);
}

.pg-inline-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(92, 99, 112, 0.22);
    border-top-color: var(--pg-red);
    border-radius: 50%;
    animation: pg-spin .7s linear infinite;
}

@keyframes pg-spin {
    to { transform: rotate(360deg); }
}

.pg-row-num-label {
    font-size: 11px;
    color: var(--pg-grey-steel);
    display: inline-block;
    transition: opacity 0.15s;
}

.pg-row-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--pg-grey-steel);
    padding: 0 2px;
    line-height: 1;
    opacity: 0;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: opacity 0.15s, color 0.15s;
}

.pg-sheet-row:hover .pg-row-num-label {
    opacity: 0;
}

.pg-sheet-row:hover .pg-row-delete-btn {
    opacity: 1;
}

.pg-row-delete-btn:hover {
    color: var(--pg-red);
}

.pg-cell {
    border: var(--border-default);
    padding: 0;
    vertical-align: middle;
    min-width: 140px;
    height: 36px;
    background: inherit;
    position: relative;
    font-family: var(--font-sans);
    font-size: var(--text-small);
    color: var(--pg-charcoal);
}

.pg-cell--editable {
    cursor: pointer;
}

.pg-cell--editable:hover {
    background: var(--pg-off-white);
}

.pg-tb-btn--danger-subtle {
    color: var(--pg-red);
}

.pg-tb-btn--danger-subtle:hover {
    background: rgba(184, 30, 49, 0.08);
}

/* Active row: faint tint across every cell in the row using a pointer-events-none overlay */
.pg-sheet-row--active td.pg-cell::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(59, 130, 246, 0.09);
    pointer-events: none;
    z-index: 1;
}

.pg-sheet-row--row-selected td.pg-cell::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(59, 130, 246, 0.14);
    pointer-events: none;
    z-index: 1;
}

/* Active column: same faint tint */
td.pg-cell.pg-cell--col-active::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(59, 130, 246, 0.09);
    pointer-events: none;
    z-index: 1;
}

/* When both row and column are active (intersection), slightly stronger tint */
.pg-sheet-row--active td.pg-cell.pg-cell--col-active::after {
    background: rgba(59, 130, 246, 0.12);
}

.pg-cell--selected {
    outline: 2px solid var(--pg-red);
    outline-offset: -2px;
    background: rgba(184,30,49,0.04) !important;
}

.pg-cell--editing {
    outline: 2px solid var(--pg-charcoal);
    outline-offset: -2px;
    background: var(--pg-white) !important;
    cursor: text;
    padding: 0;
}

.pg-cell--stale {
    outline: 2px solid #C99700;
    outline-offset: -2px;
}

.pg-cell-display {
    display: block;
    padding: 8px 10px;
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    font-style: inherit;
    color: inherit;
    text-align: inherit;
    min-height: 36px;
    line-height: 20px;
    white-space: pre-wrap;
    word-break: break-word;
}

.pg-cell-input {
    display: block;
    width: 100%;
    height: 36px;
    border: none;
    outline: none;
    background: transparent;
    padding: 8px 10px;
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    font-style: inherit;
    color: inherit;
    text-align: inherit;
    line-height: 20px;
}

.pg-cell-input[type="date"] {
    cursor: pointer;
    min-width: 0;
    font-size: inherit !important;
    line-height: 20px !important;
    appearance: none;
    -webkit-appearance: none;
}

.pg-cell-input[type="date"]::-webkit-datetime-edit {
    font: inherit;
    font-size: inherit;
    line-height: 20px;
    padding: 0;
}

.pg-cell-input[type="date"]::-webkit-datetime-edit-fields-wrapper,
.pg-cell-input[type="date"]::-webkit-datetime-edit-text,
.pg-cell-input[type="date"]::-webkit-datetime-edit-day-field,
.pg-cell-input[type="date"]::-webkit-datetime-edit-month-field,
.pg-cell-input[type="date"]::-webkit-datetime-edit-year-field {
    font: inherit;
    font-size: inherit;
    line-height: 20px;
}

.pg-cell--date .pg-cell-display,
.pg-cell--date .pg-cell-input {
    font-size: inherit !important;
}

.pg-cell-checkbox-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
}

.pg-cell-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--pg-charcoal);
}

.pg-cell-select {
    display: block;
    width: 100%;
    height: 36px;
    border: none;
    outline: none;
    background: transparent;
    padding: 0 10px;
    font-family: var(--font-sans);
    font-size: var(--text-small);
    color: var(--pg-charcoal);
    cursor: pointer;
    appearance: auto;
}

.pg-sheet-grid__add-col-th {
    background: var(--pg-off-white);
    border: var(--border-default);
    padding: 0;
    min-width: 110px;
    vertical-align: middle;
}

.pg-add-col-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: var(--text-small);
    font-weight: 500;
    color: var(--pg-grey-steel);
    padding: 7px 12px;
    width: 100%;
    text-align: left;
    transition: color 0.15s, background 0.15s;
}

.pg-add-col-btn:hover {
    color: var(--pg-charcoal);
    background: var(--pg-border-light);
}

.pg-add-col-popover {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 30;
    background: var(--pg-white);
    border: var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    min-width: 260px;
}

/* Column edit button */
.pg-col-edit-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    color: var(--pg-grey-steel);
    padding: 0 2px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    flex-shrink: 0;
}

.pg-sheet-grid__col-header:hover .pg-col-edit-btn {
    opacity: 1;
}

.pg-col-edit-btn:hover {
    color: var(--pg-charcoal);
}

/* ============================================================
   MODAL OVERLAY
   ============================================================ */

.pg-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26, 28, 30, 0.45);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
}

.pg-modal-card {
    background: var(--pg-white);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 60px rgba(0,0,0,0.22);
    width: 460px;
    max-width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.pg-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 16px;
    border-bottom: var(--border-default);
    flex-shrink: 0;
}

.pg-modal-body {
    padding: 20px;
    flex: 1;
}

.pg-modal-footer {
    display: flex;
    gap: 8px;
    padding: 16px 20px;
    border-top: var(--border-default);
    flex-shrink: 0;
}

.pg-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--pg-grey-steel);
    padding: 2px 6px;
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
}

.pg-modal-close:hover {
    color: var(--pg-charcoal);
    background: var(--pg-off-white);
}

/* ── Row Indicator Column ────────────────────────────────────────────── */
.pg-row-indicator-th {
    width: 68px; min-width: 68px;
    background: var(--pg-off-white);
    border-right: 2px solid var(--pg-border);
    text-align: center; padding: 0 !important;
}
.pg-indicator-toggle {
    background: none; border: none; cursor: pointer;
    color: var(--pg-grey-steel); font-size: 13px;
    padding: 4px 8px; border-radius: var(--radius-sm);
    transition: color 0.12s, background 0.12s;
    width: 100%;
}
.pg-indicator-toggle:hover { color: var(--pg-charcoal); background: rgba(0,0,0,0.04); }
.pg-row-indicator {
    width: 68px; min-width: 68px;
    background: var(--pg-off-white);
    border-right: 2px solid var(--pg-border);
    padding: 0 !important; vertical-align: middle;
    transition: width 0.18s, min-width 0.18s;
}
.pg-indicator-wrap { display: flex; gap: 2px; align-items: center; justify-content: center; padding: 2px; }
.pg-indicator-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 2px;
    background: none; border: none; cursor: pointer;
    color: var(--pg-grey-steel);
    padding: 5px 6px; border-radius: var(--radius-sm);
    transition: background 0.12s, color 0.12s;
    position: relative;
}
.pg-indicator-btn:hover { background: rgba(0,0,0,0.06); color: var(--pg-charcoal); }
.pg-indicator-badge {
    position: absolute; top: 0; right: 0;
    font-size: 9px; font-weight: 700;
    background: var(--pg-red); color: #fff;
    border-radius: 8px; padding: 0 3px; min-width: 13px; height: 13px;
    display: inline-flex; align-items: center; justify-content: center;
    line-height: 1;
}
/* Collapsed state */
.pg-indicator-collapsed { --indicator-width: 28px; }
.pg-indicator-collapsed .pg-row-indicator-th { width: 28px; min-width: 28px; }
.pg-indicator-collapsed .pg-row-indicator { width: 28px; min-width: 28px; }
.pg-indicator-collapsed .pg-indicator-wrap { display: none; }

/* ── Row Sidebar ─────────────────────────────────────────────────────── */
.pg-row-sidebar {
    position: fixed; top: 0; right: 0; height: 100vh;
    width: 440px; background: var(--pg-white);
    transform: translateX(100%);
    transition: transform 0.22s cubic-bezier(.4,0,.2,1);
    z-index: 300;
    box-shadow: -6px 0 32px rgba(0,0,0,0.14);
    display: flex; flex-direction: column;
}
.pg-row-sidebar.open { transform: translateX(0); }

.pg-row-sidebar__header {
    display: flex; align-items: flex-start; justify-content: space-between;
    padding: 16px 18px 14px;
    border-bottom: var(--border-default);
    background: var(--pg-off-white);
    flex-shrink: 0;
}
.pg-row-sidebar__title-wrap { flex: 1; min-width: 0; }
.pg-row-sidebar__sheet-name {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--pg-grey-steel); margin-bottom: 3px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pg-row-sidebar__row-label { display: flex; align-items: center; gap: 2px; }

.pg-row-sidebar__tabs {
    display: flex; border-bottom: var(--border-default);
    flex-shrink: 0; background: var(--pg-white);
}
.pg-sidebar-tab {
    flex: 1; padding: 11px 0; font-size: 12px; font-weight: 600;
    background: none; border: none; cursor: pointer;
    color: var(--pg-grey-steel);
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    display: flex; align-items: center; justify-content: center;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.pg-sidebar-tab--active, .pg-sidebar-tab.active {
    color: var(--pg-red);
    border-bottom-color: var(--pg-red);
}
.pg-sidebar-tab:hover { color: var(--pg-charcoal); }

.pg-sidebar-trash-btn {
    display: inline-flex; align-items: center;
    padding: 5px 10px; font-size: 12px; font-weight: 500;
    background: transparent; border: var(--border-default);
    border-radius: var(--radius-md); cursor: pointer;
    color: var(--pg-grey-steel); font-family: inherit;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.pg-sidebar-trash-btn:hover {
    background: var(--pg-off-white); color: var(--pg-charcoal);
}
.pg-sidebar-trash-btn--active {
    background: #fef2f2; color: var(--pg-red); border-color: var(--pg-red);
}

.pg-row-sidebar__body {
    flex: 1; overflow-y: auto; padding: 16px 18px;
}

/* ── Comments Tab ────────────────────────────────────────────────────── */
.pg-comments-wrap { display: flex; flex-direction: column; gap: 0; }
.pg-comment-list { margin-bottom: 16px; }
.pg-comment {
    display: flex; gap: 10px; padding: 12px 0;
    border-bottom: var(--border-light);
}
.pg-comment:last-child { border-bottom: none; }
.pg-comment--deleted { opacity: 0.5; }
.pg-comment__avatar {
    width: 30px; height: 30px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
    margin-top: 1px;
}
.pg-comment__content { flex: 1; min-width: 0; }
.pg-comment__meta {
    display: flex; align-items: center; gap: 6px;
    margin-bottom: 5px;
}
.pg-comment__author { font-size: 12px; font-weight: 600; color: var(--pg-charcoal); }
.pg-comment__time { font-size: 11px; color: #9ca3af; }
.pg-comment__deleted-label {
    font-size: 10px; padding: 1px 5px; border-radius: 3px;
    background: #f3f4f6; color: #9ca3af; font-style: italic;
}
.pg-comment__body {
    font-size: 13px; color: var(--pg-charcoal); line-height: 1.55;
    word-break: break-word;
}
.pg-comment__actions { margin-top: 5px; display: flex; gap: 8px; }
.pg-comment__action-btn {
    font-size: 11px; color: #9ca3af;
    background: none; border: none; cursor: pointer; padding: 0;
    transition: color 0.12s;
}
.pg-comment__action-btn:hover { color: var(--pg-red); }
.pg-comment__action-btn--restore:hover { color: #3B82F6; }

.pg-comment-compose {
    border: var(--border-default); border-radius: var(--radius-md);
    overflow: hidden; background: var(--pg-white);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.pg-comment-textarea {
    width: 100%; resize: none; min-height: 80px;
    font-size: 13px; padding: 10px 12px;
    border: none; outline: none;
    font-family: inherit; line-height: 1.55;
    background: transparent;
    box-sizing: border-box; display: block;
}
.pg-comment-compose__footer {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 10px;
    border-top: var(--border-light);
    background: var(--pg-off-white);
}
.pg-comment-compose__hint { font-size: 11px; color: #9ca3af; }

/* ── @Mention Picker — position:fixed set by JS to escape overflow clipping ── */
.pg-mention-picker {
    background: #fff; border: var(--border-default);
    border-radius: var(--radius-md); box-shadow: 0 6px 20px rgba(0,0,0,0.14);
    min-width: 210px; max-height: 220px; overflow-y: auto;
}
.pg-mention-item {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 12px; font-size: 13px; cursor: pointer;
    transition: background 0.12s;
}
.pg-mention-item:hover, .pg-mention-item.selected { background: var(--pg-off-white); }
.pg-mention-avatar {
    width: 22px; height: 22px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 9px; font-weight: 700; color: #fff; flex-shrink: 0;
}

/* ── Files Tab ───────────────────────────────────────────────────────── */
.pg-files-wrap { display: flex; flex-direction: column; gap: 0; }
.pg-file-list { display: flex; flex-direction: column; gap: 8px; }
.pg-file-row {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 12px 14px;
    background: var(--pg-white);
    border: var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    transition: box-shadow 0.15s;
}
.pg-file-row:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.09); }
.pg-file-row--deleted {
    opacity: 0.55;
    background: var(--pg-off-white);
    box-shadow: none;
}
.pg-file-icon { font-size: 24px; flex-shrink: 0; margin-top: 1px; }
.pg-file-info { flex: 1; min-width: 0; }
.pg-file-name {
    font-size: 13px; font-weight: 600;
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.pg-file-meta { font-size: 11px; color: var(--pg-grey-steel); margin-top: 3px; }
.pg-file-revisions-btn {
    font-size: 11px; color: var(--pg-grey-steel); margin-top: 5px;
    display: inline-flex; align-items: center; gap: 3px;
    background: none; border: none; cursor: pointer;
    padding: 2px 6px; border-radius: var(--radius-sm);
    font-family: inherit; transition: color 0.12s, background 0.12s;
}
.pg-file-revisions-btn:hover { color: var(--pg-charcoal); background: var(--pg-off-white); }
.pg-file-actions { flex-shrink: 0; display: flex; flex-direction: column; gap: 4px; padding-top: 2px; }
.pg-file-action-btn {
    background: none; border: none; cursor: pointer;
    font-size: 17px; color: var(--pg-grey-steel);
    padding: 5px 6px; border-radius: var(--radius-sm);
    transition: color 0.12s, background 0.12s;
    line-height: 1; display: flex; align-items: center; justify-content: center;
}
.pg-file-action-btn:hover { background: var(--pg-off-white); color: var(--pg-charcoal); }
.pg-file-action-btn--danger:hover { color: var(--pg-red); background: #fef2f2; }

/* ── Drop Zone ───────────────────────────────────────────────────────── */
.pg-drop-zone {
    border: 2px dashed var(--pg-border);
    border-radius: var(--radius-lg);
    padding: 20px 16px 14px;
    text-align: center;
    transition: border-color 0.15s, background 0.15s;
    background: var(--pg-off-white);
    cursor: default;
}
.pg-drop-zone--over {
    border-color: var(--pg-red);
    background: #fff5f5;
}
.pg-drop-zone--uploading {
    opacity: 0.6; pointer-events: none;
}
.pg-drop-zone__icon { font-size: 26px; display: block; margin-bottom: 6px; }
.pg-drop-zone__label { font-size: 13px; font-weight: 500; color: var(--pg-charcoal); margin: 0 0 4px; }
.pg-drop-zone__or { font-size: 11px; color: #9ca3af; margin: 0 0 8px; }
.pg-drop-zone__note { font-size: 11px; color: #9ca3af; margin: 8px 0 0; }
.pg-upload-status { font-size: 11px; color: var(--pg-grey-steel); display: block; margin-top: 6px; }

.pg-deleted-files-section {
    margin-top: 16px;
    border-top: var(--border-default); padding-top: 12px;
}
.pg-deleted-files-toggle {
    font-size: 12px; color: var(--pg-grey-steel); cursor: pointer;
    list-style: none; user-select: none;
}
.pg-deleted-files-toggle::-webkit-details-marker { display: none; }
.pg-deleted-file-list { margin-top: 8px; }

/* ── Sidebar Trash Tab ───────────────────────────────────────────────── */
.pg-trash-section-title {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--pg-grey-steel);
    margin: 16px 0 8px;
}
.pg-trash-section-title:first-child { margin-top: 0; }
.pg-trash-item {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 10px 12px;
    border: var(--border-default);
    border-radius: var(--radius-md);
    margin-bottom: 6px;
    background: var(--pg-off-white);
}
.pg-trash-item__body { flex: 1; min-width: 0; }
.pg-trash-item__meta { font-size: 11px; color: var(--pg-grey-steel); margin-top: 2px; }
.pg-trash-item__text { font-size: 13px; color: var(--pg-charcoal); word-break: break-word; }
.pg-trash-empty { font-size: 13px; color: var(--pg-grey-steel); padding: 20px 0; text-align: center; }

/* ── Revision History ────────────────────────────────────────────────── */
.pg-revisions-table {
    width: 100%; border-collapse: collapse; font-size: 13px;
}
.pg-revisions-table th {
    padding: 6px 8px; text-align: left;
    color: var(--pg-grey-steel); border-bottom: var(--border-default);
    font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
}
.pg-revisions-table td { padding: 8px 8px; border-bottom: var(--border-light); }
.pg-revisions-table tr:last-child td { border-bottom: none; }
.pg-rev-row--latest td { font-weight: 600; }
.pg-rev-row--deleted td { color: #9ca3af; }

/* ── Badges ──────────────────────────────────────────────────────────── */
.pg-badge {
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 600; border-radius: 4px;
    padding: 1px 5px; line-height: 14px; white-space: nowrap;
}
.pg-badge--grey { background: #f3f4f6; color: #6b7280; }
.pg-badge--green { background: #d1fae5; color: #065f46; }
.pg-badge--red { background: #fee2e2; color: #991b1b; }
.pg-badge--blue { background: #dbeafe; color: #1d4ed8; }

/* ── Notification Bell icon button ───────────────────────────────────── */
.pg-notif-bell-icon-btn {
    background: var(--pg-white);
    border: var(--border-default);
    cursor: pointer;
    color: var(--pg-charcoal);
    padding: 0;
    border-radius: var(--radius-md);
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.12);
    transition: color 0.15s, background 0.15s, transform 0.12s, box-shadow 0.15s;
    margin-left: 0;
    flex-shrink: 0;
}
.pg-global-notif-dock {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 260;
}
.pg-notif-bell-icon-btn:hover {
    color: var(--pg-red);
    transform: translateY(-1px);
    box-shadow: 0 14px 34px rgba(0,0,0,0.16);
}

.pg-notif-badge {
    position: absolute; top: -5px; right: -5px;
    display: inline-flex; align-items: center; justify-content: center;
    background: #ef4444; color: #fff;
    font-size: 9px; font-weight: 700;
    border-radius: 8px; padding: 0 3px; min-width: 14px; height: 14px;
    border: 2px solid var(--pg-white);
    line-height: 1;
}

/* ── Notification Popover (side panel next to bell, not centred) ─────── */
.pg-notif-overlay {
    position: fixed; inset: 0; z-index: 490;
    background: rgba(0,0,0,0.06);
}
.pg-notif-panel {
    position: fixed;
    left: 50%; top: 62px;
    transform: translateX(-50%);
    width: 340px; max-height: 75vh;
    background: var(--pg-white);
    border-radius: var(--radius-lg);
    box-shadow: 0 18px 42px rgba(0,0,0,0.18);
    border: var(--border-default);
    z-index: 491;
    flex-direction: column;
    overflow: hidden;
    animation: notifSlideIn 0.18s ease;
}
@keyframes notifSlideIn {
    from { transform: translate(-50%, -8px); opacity: 0; }
    to   { transform: translate(-50%, 0);    opacity: 1; }
}
.sidebar-collapsed .pg-notif-panel { left: 50%; border-radius: var(--radius-lg); }

.pg-notif-banner-host {
    position: fixed;
    top: 62px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    width: min(520px, calc(100vw - 28px));
    pointer-events: none;
}

.pg-notif-banner {
    width: 100%;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border: 1px solid rgba(184,30,49,0.28);
    border-radius: var(--radius-lg);
    background: var(--pg-white);
    color: var(--pg-charcoal);
    box-shadow: 0 16px 40px rgba(0,0,0,0.18);
    padding: 12px 14px;
    cursor: pointer;
    text-align: left;
    pointer-events: auto;
    animation: pgNotifBannerIn 0.18s ease-out;
}

.pg-notif-banner__icon {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-pill);
    background: var(--pg-red);
    color: var(--pg-white);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.pg-notif-banner__text {
    min-width: 0;
    display: grid;
    gap: 2px;
    font-size: 13px;
    line-height: 1.35;
}

.pg-notif-banner__text strong {
    font-size: 14px;
}

.pg-notif-banner__text span {
    color: var(--pg-grey-mid);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

@keyframes pgNotifBannerIn {
    from { transform: translateY(-8px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.pg-notif-panel__header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px 10px;
    border-bottom: var(--border-default);
    background: var(--pg-off-white);
    flex-shrink: 0;
}
.pg-notif-panel__title { font-size: 13px; font-weight: 600; color: var(--pg-charcoal); }
.pg-notif-list { flex: 1; overflow-y: auto; }
.pg-notif-item {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 11px 16px; border-bottom: var(--border-light);
    cursor: pointer; transition: background 0.12s;
}
.pg-notif-item:hover { background: var(--pg-off-white); }
.pg-notif-item:last-child { border-bottom: none; }
.pg-notif-item--read { opacity: 0.5; }
.pg-notif-unread-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--pg-red); flex-shrink: 0; margin-top: 5px;
}
.pg-notif-item__content { flex: 1; min-width: 0; }
.pg-notif-item__title { font-size: 13px; font-weight: 600; color: var(--pg-charcoal); margin-bottom: 2px; }
.pg-notif-item--read .pg-notif-item__title { font-weight: 400; }
.pg-notif-item__body { font-size: 12px; color: var(--pg-grey-steel); margin-bottom: 3px; line-height: 1.4; }
.pg-notif-item__meta { font-size: 11px; color: #9ca3af; }

/* ── Misc helpers ────────────────────────────────────────────────────── */
.pg-link-btn {
    background: none; border: none; padding: 0; cursor: pointer;
    color: #3B82F6; font-size: inherit;
    text-decoration: underline; font-family: inherit;
}
.pg-link-btn:hover { opacity: 0.8; }
.pg-danger-link { color: var(--pg-red) !important; }
.pg-empty-state-msg {
    padding: 24px 0; text-align: center;
    color: var(--pg-grey-steel); font-size: 13px;
}

/* ============================================================
   USER COLUMN TYPE
   ============================================================ */

.pg-user-avatar-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 9px;
    font-weight: 700;
    color: #fff;
    vertical-align: middle;
    margin-right: 5px;
    flex-shrink: 0;
    letter-spacing: 0;
}

.pg-cell-user-select {
    width: 100%;
}

/* ============================================================
   FILTER BAR
   ============================================================ */

.pg-filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0 8px;
    min-height: 36px;
}

.pg-filter-bar__left { display: flex; align-items: center; gap: 8px; }
.pg-filter-bar__chips { display: flex; flex-wrap: wrap; gap: 6px; }

.pg-filter-wrap { position: relative; }

.pg-filter-toggle-btn { gap: 5px; }
.pg-filter-toggle-btn--active {
    background: rgba(184,30,49,0.1) !important;
    color: var(--pg-red) !important;
    border-color: rgba(184,30,49,0.3) !important;
    font-weight: 600;
}

.pg-filter-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 240px;
    background: var(--pg-white);
    border: var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    z-index: 200;
    overflow: hidden;
}

.pg-filter-menu__item {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    padding: 9px 14px;
    background: none;
    border: none;
    font-size: 13px;
    color: var(--pg-charcoal);
    cursor: pointer;
    text-align: left;
}
.pg-filter-menu__item:hover { background: var(--pg-off-white); }
.pg-filter-menu__item--active { font-weight: 600; color: var(--pg-red); }
.pg-filter-menu__item--clear { color: var(--pg-grey-steel); font-size: 12px; }

.pg-filter-menu__divider { height: 1px; background: var(--pg-off-white); margin: 2px 0; }

.pg-filter-menu__item-row { display: flex; align-items: stretch; }
.pg-filter-menu__item-main { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-filter-menu__item-edit {
    display: flex; align-items: center; justify-content: center;
    padding: 0 10px; background: none; border: none;
    border-left: var(--border-default); color: var(--pg-grey-steel); cursor: pointer; flex-shrink: 0;
}
.pg-filter-menu__item-edit:hover { background: var(--pg-off-white); color: var(--pg-charcoal); }

.pg-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px 3px 10px;
    background: rgba(184,30,49,0.08);
    border: 1px solid rgba(184,30,49,0.25);
    border-radius: 99px;
    font-size: 12px;
    color: var(--pg-red);
    font-weight: 500;
}
.pg-filter-chip__clear {
    background: none; border: none; cursor: pointer;
    color: var(--pg-red); font-size: 14px; line-height: 1;
    padding: 0 2px; opacity: 0.7;
}
.pg-filter-chip__clear:hover { opacity: 1; }

.pg-filter-modal {
    width: 760px;
    max-width: 95vw;
}

/* "Show rows that match [all conditions ▾]" — explicit width so the longest
   option ("all conditions") never clips, regardless of browser select sizing. */
.pg-filter-match-sel {
    width: auto;
    min-width: 160px;
    padding: 6px 30px 6px 12px;
    font-size: 13px;
}

/* Flexbox row so the value column collapses cleanly when the operator
   has no value (e.g. "is checked", "is empty"). */
.pg-filter-condition-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
}

.pg-filter-condition-row > .pg-filter-field-sel { flex: 1 1 180px; min-width: 0; }
.pg-filter-condition-row > .pg-filter-op-sel    { flex: 1 1 160px; min-width: 0; }
.pg-filter-condition-row > .pg-filter-val-wrap  { flex: 2 1 200px; min-width: 0; }
.pg-filter-condition-row > .pg-filter-condition-remove { flex: 0 0 28px; }

/* When the operator has no value input, the wrap is empty — collapse it so
   the remove button sits flush against the operator. */
.pg-filter-val-wrap:empty { flex: 0 0 0; padding: 0; margin: 0; }

.pg-filter-val-wrap { display: flex; }
.pg-filter-val-input { width: 100%; min-width: 0; }

.pg-filter-multi {
    position: relative;
}

.pg-filter-multi__button {
    width: 100%;
    min-height: 34px;
    padding: 6px 30px 6px 10px;
    border: var(--border-default);
    border-radius: var(--radius-md);
    background: var(--pg-white);
    color: var(--pg-charcoal);
    font: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    position: relative;
}

.pg-filter-multi__button::after {
    content: 'v';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--pg-grey-steel);
    font-size: 11px;
}

.pg-filter-multi__menu {
    display: none;
    position: absolute;
    z-index: 920;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 210px;
    overflow: auto;
    padding: 6px;
    border: var(--border-default);
    border-radius: var(--radius-md);
    background: var(--pg-white);
    box-shadow: 0 8px 24px rgba(0,0,0,0.14);
}

.pg-filter-multi--open .pg-filter-multi__menu {
    display: grid;
    gap: 4px;
}

.pg-filter-multi__item {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 24px;
    padding: 2px 4px;
    border-radius: 4px;
    color: var(--pg-charcoal);
    font-size: 12px;
    cursor: pointer;
}

.pg-filter-multi__item:hover {
    background: var(--pg-off-white);
}

.pg-filter-multi__item input {
    accent-color: var(--pg-red);
}

.pg-filter-multi__item span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pg-filter-multi__empty {
    padding: 4px;
    color: var(--pg-grey-steel);
    font-size: 12px;
}

@media (max-width: 640px) {
    .pg-filter-condition-row > .pg-filter-field-sel,
    .pg-filter-condition-row > .pg-filter-op-sel,
    .pg-filter-condition-row > .pg-filter-val-wrap { flex: 1 1 100%; }
}

.pg-filter-condition-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--pg-grey-steel);
    font-size: 16px;
    line-height: 1;
    padding: 0;
    text-align: center;
}
.pg-filter-condition-remove:hover { color: var(--pg-red); }

/* ============================================================
   CARD VIEW
   ============================================================ */

.pg-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 4px 0 24px;
}

.pg-card-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin: 0 0 10px;
    min-height: 38px;
    overflow: visible;
}

.pg-card-toolbar__group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--pg-grey-steel);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.pg-card-group-select {
    min-width: 260px;
    height: 34px;
    font-size: 12px;
    padding-right: 32px;
}

.pg-card-grid--grouped {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding-bottom: 18px;
}

.pg-card-lane {
    flex: 0 0 300px;
    max-width: 320px;
    background: var(--pg-off-white);
    border: var(--border-default);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.pg-card-lane__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 11px;
    background: var(--pg-white);
    border-bottom: var(--border-default);
    color: var(--pg-charcoal);
    font-size: 13px;
    font-weight: 600;
}

.pg-card-lane__header span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pg-card-lane__header span:last-child {
    color: var(--pg-grey-steel);
    font-size: 11px;
    font-weight: 600;
}

.pg-card-lane__body {
    display: grid;
    gap: 8px;
    padding: 8px;
}

.pg-card {
    background: var(--pg-white);
    border: var(--border-default);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    transition: box-shadow 0.15s;
    overflow: hidden;
}

.pg-card:hover {
    box-shadow: 0 3px 12px rgba(0,0,0,0.1);
}

.pg-card__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--pg-charcoal);
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: var(--border-default);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pg-card__fields {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pg-card__row {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 8px;
    align-items: baseline;
    font-size: 12px;
}

.pg-card__label {
    color: var(--pg-grey-steel);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pg-card__value {
    color: var(--pg-charcoal);
    word-break: break-word;
}

.pg-card-empty {
    grid-column: 1 / -1;
    padding: 48px;
    text-align: center;
    color: var(--pg-grey-steel);
    font-size: 13px;
}

/* ── AUTOMATIONS ─────────────────────────────────────────────────────────── */

.pg-automations-btn {
    background: linear-gradient(135deg, #B81E31 0%, #8c1525 100%);
    color: #fff !important;
    border: none;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 5px;
    gap: 5px;
    display: flex;
    align-items: center;
}
.pg-automations-btn:hover { opacity: 0.9; }

/* Automations toolbar dropdown menu */
.pg-auto-menu-wrap { position: relative; }

.pg-auto-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 220px;
    background: #fff;
    border: 1px solid var(--pg-grey-border);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    z-index: 500;
    padding: 6px 0;
    display: flex;
    flex-direction: column;
}

.pg-auto-menu__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    font-size: 13px;
    color: var(--pg-text);
    background: none;
    border: none;
    text-decoration: none;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s;
    width: 100%;
}
.pg-auto-menu__item:hover:not(:disabled) { background: #f4f5f6; }
.pg-auto-menu__item--disabled { color: var(--pg-grey-steel); cursor: default; }

.pg-auto-menu__badge {
    margin-left: auto;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    background: #f0f0f0;
    color: var(--pg-grey-steel);
    letter-spacing: 0.03em;
}

.pg-auto-menu__divider {
    height: 1px;
    background: var(--pg-grey-border);
    margin: 4px 0;
}

/* ── Automation template gallery page ────────────────────────────────── */

.pg-auto-gallery-page {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 24px 60px;
}

.pg-auto-gallery-header {
    margin-bottom: 36px;
}

.pg-auto-gallery-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--pg-grey-steel);
    text-decoration: none;
    margin-bottom: 20px;
    transition: color 0.15s;
}
.pg-auto-gallery-back:hover { color: var(--pg-red); }

.pg-auto-gallery-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--pg-text);
    margin: 0 0 8px;
}

.pg-auto-gallery-sub {
    font-size: 14px;
    color: var(--pg-grey-steel);
    margin: 0;
}

.pg-auto-gallery-group {
    margin-bottom: 40px;
}

.pg-auto-gallery-group-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--pg-grey-steel);
    margin: 0 0 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--pg-grey-border);
}

.pg-auto-template-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pg-auto-template-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    background: #fff;
    border: 1.5px solid var(--pg-grey-border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.pg-auto-template-card:hover {
    border-color: var(--pg-red);
    box-shadow: 0 3px 12px rgba(184,30,49,0.1);
    transform: translateY(-1px);
}

.pg-auto-template-card__icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #fde8eb 0%, #fce4e8 100%);
    border-radius: 10px;
    color: var(--pg-red);
}
.pg-auto-template-card__icon svg { width: 22px; height: 22px; }

.pg-auto-template-card__body { flex: 1; min-width: 0; }

.pg-auto-template-card__name {
    font-size: 14px;
    font-weight: 600;
    color: var(--pg-text);
    margin-bottom: 3px;
}

.pg-auto-template-card__desc {
    font-size: 12px;
    color: var(--pg-grey-steel);
    line-height: 1.4;
}

.pg-auto-template-card__arrow {
    flex-shrink: 0;
    color: var(--pg-grey-steel);
    transition: color 0.15s, transform 0.15s;
}
.pg-auto-template-card:hover .pg-auto-template-card__arrow {
    color: var(--pg-red);
    transform: translateX(3px);
}

.pg-auto-gallery-empty {
    text-align: center;
    padding: 80px 20px;
    color: var(--pg-grey-steel);
    font-size: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Configure modal */
.pg-auto-config-modal { width: 520px; max-width: 95vw; }

/* Side panel */
.pg-auto-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 400px;
    background: #fff;
    transform: translateX(100%);
    transition: transform 0.22s ease;
    z-index: 400;
    box-shadow: -4px 0 24px rgba(0,0,0,0.14);
    display: flex;
    flex-direction: column;
}
.pg-auto-panel.open { transform: translateX(0); }

.pg-auto-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: var(--border-default);
    flex-shrink: 0;
}

.pg-auto-panel__list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.pg-auto-panel__footer {
    padding: 12px 20px;
    border-top: var(--border-default);
    display: flex;
    justify-content: flex-end;
}

/* Automation list item */
.pg-auto-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--pg-grey-border);
    gap: 12px;
}
.pg-auto-item:last-child { border-bottom: none; }

.pg-auto-item__info { flex: 1; min-width: 0; }
.pg-auto-item__name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-auto-item__sub  { font-size: 11px; color: var(--pg-grey-steel); margin-top: 2px; }

.pg-auto-item__actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Toggle switch */
.pg-auto-toggle { position: relative; display: inline-block; width: 34px; height: 18px; cursor: pointer; }
.pg-auto-toggle input { opacity: 0; width: 0; height: 0; }
.pg-auto-toggle__slider {
    position: absolute; inset: 0;
    background: #ccc; border-radius: 18px;
    transition: background 0.2s;
}
.pg-auto-toggle__slider::before {
    content: '';
    position: absolute;
    width: 14px; height: 14px;
    left: 2px; top: 2px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}
.pg-auto-toggle input:checked + .pg-auto-toggle__slider { background: var(--pg-red); }
.pg-auto-toggle input:checked + .pg-auto-toggle__slider::before { transform: translateX(16px); }

/* Builder modal */
.pg-auto-builder { width: 680px; max-width: 96vw; max-height: 88vh; display: flex; flex-direction: column; }
.pg-auto-builder__body { overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.pg-auto-section { display: flex; flex-direction: column; gap: 6px; }
.pg-auto-label { font-size: 12px; font-weight: 600; color: var(--pg-grey-steel); text-transform: uppercase; letter-spacing: 0.04em; }

/* Workflow blocks */
.pg-auto-block {
    border: 1.5px solid var(--pg-grey-border);
    border-radius: 8px;
    overflow: hidden;
}
.pg-auto-block--trigger { border-left: 4px solid #4A90D9; }
.pg-auto-block--condition { border-left: 4px solid #F5A623; }
.pg-auto-block--action { border-left: 4px solid #27AE60; }

.pg-auto-block__badge {
    padding: 6px 16px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    background: #f4f5f6;
    color: var(--pg-grey-steel);
    border-bottom: 1px solid var(--pg-grey-border);
}
.pg-auto-block--trigger .pg-auto-block__badge   { color: #4A90D9; }
.pg-auto-block--condition .pg-auto-block__badge { color: #c47d00; }
.pg-auto-block--action .pg-auto-block__badge    { color: #27AE60; }

.pg-auto-block__body { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }

/* Condition & action rows */
.pg-auto-cond-row,
.pg-auto-action-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 0;
    border-bottom: 1px solid var(--pg-grey-border);
}
.pg-auto-cond-row:last-child,
.pg-auto-action-row:last-child { border-bottom: none; }

.pg-auto-col-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.pg-auto-col-check {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    cursor: pointer;
    padding: 3px 8px;
    border: 1px solid var(--pg-grey-border);
    border-radius: 4px;
    background: #fafafa;
}
.pg-auto-col-check:hover { background: #f0f0f0; }
.pg-auto-col-check input { margin: 0; }

/* Danger button variant — outline by default, solid on hover/active. Sized
   to match the rest of the .pg-btn ladder so it composes with .pg-btn-sm /
   .pg-btn-lg instead of overriding their padding. */
.pg-btn-danger {
    background: transparent;
    color: var(--pg-red);
    border: 1px solid var(--pg-red);
}
.pg-btn-danger:hover { background: var(--pg-red); color: var(--pg-white); }
.pg-btn-danger:active { background: var(--pg-red-dark); border-color: var(--pg-red-dark); }

.pg-btn-icon { width: 26px; height: 26px; padding: 0; display: flex; align-items: center; justify-content: center; font-size: 16px; }

/* Row background colour applied by automations */
.pg-sheet-grid tbody tr[data-row-bg] {
    background-color: attr(data-row-bg color, transparent);
}

/* Manage automations page */
.pg-auto-manage-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    background: #fff;
    border: 1.5px solid var(--pg-grey-border);
    border-radius: 10px;
    flex-wrap: wrap;
}
.pg-auto-manage-row__info { flex: 1; min-width: 0; }
.pg-auto-manage-row__name { font-size: 14px; font-weight: 600; color: var(--pg-text); }
.pg-auto-manage-row__sub  { font-size: 12px; color: var(--pg-grey-steel); margin-top: 3px; }
.pg-auto-manage-row__actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.pg-status--active   { font-size: 12px; font-weight: 600; color: #27AE60; }
.pg-status--inactive { font-size: 12px; font-weight: 600; color: var(--pg-grey-steel); }

.pg-user-presence {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex: 0 0 8px;
}

.pg-user-presence--online { background: #10B981; box-shadow: 0 0 0 3px rgba(16,185,129,.12); }
.pg-user-presence--recent { background: #F59E0B; }
.pg-user-presence--offline { background: #9CA3AF; }

.pg-cell-choice-display {
    display: block;
    min-height: 18px;
    cursor: pointer;
}

/* ============================================================
   MOBILE RESPONSIVE OVERRIDES
   - Phones (≤640px): toolbar scrolls horizontally instead of wrapping to 4 rows,
     touch targets bumped to 32px+, sidebar/modals fill the screen, modal selects
     stack vertically (already handled per-modal but reinforced here).
   - Tablets (641–960px): toolbar still wraps but each row is tighter.
   ============================================================ */

@media (max-width: 640px) {
    /* Toolbar: horizontal scroll keeps every control reachable without growing
       the toolbar to multiple rows that push the grid below the fold. */
    .pg-sheet-toolbar {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
        padding: 6px 8px;
    }
    .pg-sheet-toolbar > * { flex-shrink: 0; }
    .pg-sheet-toolbar::-webkit-scrollbar { height: 4px; }
    .pg-sheet-toolbar::-webkit-scrollbar-thumb { background: var(--pg-border); border-radius: 2px; }

    /* Bigger taps for thumbs — keep visual size but expand the hit area. */
    .pg-tb-btn { height: 32px; min-width: 32px; }
    .pg-indicator-btn { width: 32px; height: 32px; }

    /* Row sidebar fills the viewport on phones; backdrop already handles dismissal. */
    .pg-row-sidebar { width: 100vw !important; max-width: 100vw; }
    .pg-configure-form-panel { width: 100vw !important; max-width: 100vw; }

    /* Modal cards: ensure 8px margin on each side and scrollable bodies. */
    .pg-modal-card { width: calc(100vw - 16px) !important; max-width: calc(100vw - 16px); }
    .pg-modal-body { max-height: 70vh; overflow-y: auto; }

    /* Row-number cell × button is touch-only on mobile — always visible since hover doesn't exist. */
    .pg-row-delete-btn { opacity: 1 !important; }

    /* Filter chips group: vertical stack on phones so each chip is easy to read. */
    .pg-filter-bar__chips { flex-direction: column; align-items: stretch; }
}

@media (max-width: 960px) and (min-width: 641px) {
    /* Tablets: keep the wrap, just tighten spacing so it doesn't sprawl. */
    .pg-tb-divider { margin: 0 3px; }
    .pg-tb-btn { padding: 3px 5px; }
}

/* ================================================================
   UI POLISH PASS — Stage 6
   Adds the missing design-token glue: focus rings, hover polish,
   unified empty-state, transition consistency. Everything below
   layers on top of existing rules so legacy markup keeps working.
   ================================================================ */

/* ---- Design tokens additions ---- */
:root {
    /* Focus-ring colour mirrors the brand red at low opacity so it works on
       both light and dark backgrounds; falls back gracefully on older browsers. */
    --pg-focus-ring: 0 0 0 3px rgba(201, 60, 64, 0.22);
    --pg-focus-ring-dark: 0 0 0 3px rgba(26, 28, 30, 0.18);

    /* Elevation scale used by cards / dropdowns / modals. Three steps lets
       Z-aware components stay visually distinct without bespoke shadows. */
    --shadow-1: 0 1px 2px rgba(26, 28, 30, 0.06);
    --shadow-2: 0 4px 12px rgba(26, 28, 30, 0.10);
    --shadow-3: 0 12px 36px rgba(26, 28, 30, 0.16);

    /* Single timing for all standard transitions — avoids the "every element
       eases differently" feel. */
    --motion-fast: 120ms ease;
    --motion-normal: 180ms ease;
}

/* ---- Focus indicators: visible only via keyboard, never on mouse-click ---- */
.pg-btn:focus-visible,
.pg-btn-danger:focus-visible,
.pg-tb-btn:focus-visible,
.pg-indicator-btn:focus-visible,
.pg-filter-menu__item:focus-visible,
.pg-modal-close:focus-visible,
.pg-row-num-label:focus-visible,
.pg-row-delete-btn:focus-visible,
a.pg-link-btn:focus-visible,
[role="button"]:focus-visible {
    outline: none;
    box-shadow: var(--pg-focus-ring);
}

.pg-input:focus-visible,
.pg-select:focus-visible,
.pg-textarea:focus-visible {
    outline: none;
    border-color: var(--pg-red);
    box-shadow: var(--pg-focus-ring);
}

/* ---- Button polish: smoother transitions + consistent disabled state ---- */
.pg-btn {
    transition: background var(--motion-fast), color var(--motion-fast),
                border-color var(--motion-fast), opacity var(--motion-fast),
                transform 0.08s ease, box-shadow var(--motion-fast);
}

.pg-btn[disabled],
.pg-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ---- Inputs: gentle hover so users can see they're interactable ---- */
.pg-input:hover:not(:focus):not(:disabled),
.pg-select:hover:not(:focus):not(:disabled),
.pg-textarea:hover:not(:focus):not(:disabled) {
    border-color: var(--pg-charcoal-mid);
}

.pg-input[disabled],
.pg-select[disabled],
.pg-textarea[disabled] {
    background: var(--pg-off-white);
    color: var(--pg-grey-steel);
    cursor: not-allowed;
}

/* ---- Unified empty-state component ---- */
.pg-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-2xl) var(--space-md);
    color: var(--pg-grey-steel);
    background: var(--pg-white);
    border: var(--border-default);
    border-radius: var(--radius-lg);
    min-height: 220px;
}
.pg-empty-state__icon {
    width: 48px;
    height: 48px;
    color: var(--pg-border);
    margin-bottom: var(--space-md);
}
.pg-empty-state__title {
    font-size: var(--text-h3);
    font-weight: 500;
    color: var(--pg-charcoal);
    margin-bottom: 4px;
}
.pg-empty-state__hint {
    font-size: var(--text-small);
    color: var(--pg-grey-steel);
    max-width: 440px;
    line-height: 1.5;
}
.pg-empty-state__action { margin-top: var(--space-md); }

/* ---- Modal consistency: header / body / footer rhythm ---- */
.pg-modal-overlay {
    background: rgba(26, 28, 30, 0.36);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pg-modal-card {
    box-shadow: var(--shadow-3);
}
.pg-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: var(--border-default);
    gap: var(--space-md);
}
.pg-modal-title {
    font-size: var(--text-h3);
    font-weight: 600;
    color: var(--pg-charcoal);
    margin: 0;
}
.pg-modal-close {
    background: transparent;
    border: none;
    color: var(--pg-grey-steel);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background var(--motion-fast), color var(--motion-fast);
}
.pg-modal-close:hover { background: var(--pg-off-white); color: var(--pg-charcoal); }
.pg-modal-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: var(--border-default);
    background: var(--pg-off-white);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ---- Form labels: consistent rhythm between label / input / hint ---- */
.pg-form-label {
    display: block;
    font-size: var(--text-small);
    font-weight: 500;
    color: var(--pg-charcoal);
    margin-bottom: 6px;
}
.pg-form-label__required {
    color: var(--pg-red);
    margin-left: 2px;
}
.pg-form-hint {
    display: block;
    font-size: var(--text-micro);
    color: var(--pg-grey-steel);
    margin-top: 4px;
    line-height: 1.4;
}

/* ---- Card surface — used by workspace tiles, sheet rows, filter cards ---- */
.pg-surface {
    background: var(--pg-white);
    border: var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-1);
    transition: box-shadow var(--motion-normal), border-color var(--motion-fast);
}
.pg-surface:hover { box-shadow: var(--shadow-2); border-color: var(--pg-charcoal-mid); }

/* ---- Loading skeleton primitive for async content ---- */
@keyframes pg-skeleton-shimmer {
    0%   { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}
.pg-skeleton {
    display: inline-block;
    background: linear-gradient(90deg, var(--pg-off-white) 0%, var(--pg-border-light) 50%, var(--pg-off-white) 100%);
    background-size: 200% 100%;
    animation: pg-skeleton-shimmer 1.2s linear infinite;
    border-radius: var(--radius-sm);
    height: 14px;
    width: 100%;
}
.pg-skeleton--lg { height: 24px; }
.pg-skeleton--sm { height: 10px; }

/* ---- Floating sheet assistant ---- */
.pg-ai-panel {
    position: fixed;
    left: 76px;
    bottom: 18px;
    width: min(420px, calc(100vw - 96px));
    max-height: min(620px, calc(100vh - 36px));
    background: var(--pg-white);
    border: var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
    z-index: 520;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-collapsed .pg-ai-panel {
    left: 18px;
}

.pg-ai-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: var(--pg-charcoal);
    color: #fff;
}

.pg-ai-panel__title {
    font-size: 14px;
    font-weight: 600;
}

.pg-ai-panel__scope {
    margin-top: 1px;
    color: rgba(255, 255, 255, 0.68);
    font-size: 11px;
}

.pg-ai-panel__body {
    display: grid;
    gap: 10px;
    padding: 12px;
    overflow-y: auto;
}

.pg-ai-scope-toggle {
    display: flex;
    gap: 4px;
    padding: 3px;
    background: var(--pg-off-white);
    border-radius: var(--radius-md);
}

.pg-ai-scope-toggle__btn {
    flex: 1;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--pg-grey-mid);
    cursor: pointer;
    font-size: 12px;
    padding: 6px 8px;
}

.pg-ai-scope-toggle__btn--active {
    background: var(--pg-white);
    color: var(--pg-charcoal);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.pg-ai-scope-toggle__btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.pg-ai-log {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 360px;
    overflow-y: auto;
    padding-right: 2px;
}

.pg-ai-message {
    border-radius: var(--radius-md);
    font-size: 13px;
    line-height: 1.45;
    padding: 9px 10px;
}

.pg-ai-message--assistant {
    background: var(--pg-off-white);
    color: var(--pg-charcoal);
}

.pg-ai-message--user {
    justify-self: end;
    max-width: 90%;
    background: var(--pg-charcoal);
    color: var(--pg-white);
}

.pg-ai-results {
    display: grid;
    gap: 7px;
    margin-top: 8px;
}

.pg-ai-results__label {
    color: var(--pg-grey-steel);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.pg-ai-result {
    display: grid;
    gap: 2px;
    padding: 8px 9px;
    border: var(--border-default);
    border-radius: var(--radius-md);
    background: var(--pg-white);
    color: var(--pg-charcoal);
    text-decoration: none;
}

.pg-ai-result:hover {
    border-color: var(--pg-charcoal);
}

.pg-ai-result__type {
    width: max-content;
    color: var(--pg-red);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.pg-ai-result strong {
    font-size: 13px;
}

.pg-ai-result span:last-child {
    overflow: hidden;
    color: var(--pg-grey-steel);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pg-ai-panel__footer {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 10px 12px 12px;
    border-top: var(--border-default);
    background: var(--pg-white);
}

.pg-ai-input {
    min-height: 42px;
    max-height: 96px;
    padding: 8px 10px;
    border: 1px solid var(--pg-border);
    border-radius: var(--radius-md);
    font: inherit;
    font-size: 13px;
    outline: none;
    resize: none;
}

.pg-ai-input:focus {
    border-color: var(--pg-charcoal);
}

.pg-ai-send {
    align-self: end;
    height: 38px;
}

@media (max-width: 720px) {
    .pg-ai-panel {
        right: 8px;
        bottom: 8px;
        left: 8px;
        width: auto;
        max-height: calc(100vh - 16px);
    }

    .pg-ai-panel__footer {
        grid-template-columns: 1fr;
    }
}

/* ---- Reduced-motion: respect users who prefer fewer animations ---- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---- High-contrast focus mode for forced-colors / Windows High Contrast ---- */
@media (forced-colors: active) {
    .pg-btn:focus-visible,
    .pg-input:focus-visible,
    .pg-select:focus-visible {
        outline: 2px solid Highlight;
        box-shadow: none;
    }
}

