/**
 * ProjectLayer design tokens — portal design system
 * WCAG-oriented contrast ratios throughout.
 */

/* ============================================================
   TOKENS
   ============================================================ */
:root {
    --pl-color-primary:       #3d2f7c;
    --pl-color-primary-hover: #2e2360;
    --pl-color-secondary:     #5c4fa0;
    --pl-color-accent:        #c47826;
    --pl-color-bg:            #eeedf4;
    --pl-color-surface:       #ffffff;
    --pl-color-border:        #d1ced9;
    --pl-color-border-subtle: #e5e3ec;
    --pl-color-text:          #1a1c22;
    --pl-color-text-muted:    #4a4d56;
    --pl-color-success:       #1f6b3a;
    --pl-color-warning:       #a35f0c;
    --pl-color-error:         #b42318;
    --pl-color-info:          #1d4ed8;

    --pl-font-display: "Fraunces", "Georgia", serif;
    --pl-font-body:    "Source Sans 3", system-ui, sans-serif;

    --pl-radius:    8px;
    --pl-radius-lg: 12px;
    --pl-shadow:    0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(61,47,124,0.06);
    --pl-shadow-sm: 0 1px 2px rgba(0,0,0,0.06);

    --pl-sidebar-width: 228px;
    --pl-sidebar-bg:    #3d2f7c;
}

/* ============================================================
   RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

body.pl-theme {
    margin: 0;
    font-family: var(--pl-font-body);
    font-size: 1rem;
    line-height: 1.55;
    color: var(--pl-color-text);
    background: var(--pl-color-bg);
}

/* ============================================================
   SIDEBAR LAYOUT
   ============================================================ */
.pl-layout {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.pl-sidebar {
    width: var(--pl-sidebar-width);
    flex-shrink: 0;
    background: var(--pl-sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 50;
}

.pl-sidebar-logo {
    display: flex;
    align-items: center;
    padding: 1.1rem 1.15rem;
    text-decoration: none;
    border-bottom: 1px solid rgba(255,255,255,0.10);
    flex-shrink: 0;
}

.pl-sidebar-logo img,
.pl-sidebar-logo svg {
    height: 32px;
    width: auto;
    display: block;
}

.pl-sidebar-logo img.pl-logo__custom {
    max-height: 30px;
    max-width: 140px;
    object-fit: contain;
}

.pl-sidebar-logo__text {
    font-family: var(--pl-font-display);
    font-weight: 600;
    font-size: 1.1rem;
    color: #fff;
    margin-left: 0.6rem;
    letter-spacing: -0.01em;
}

.pl-sidebar-nav {
    flex: 1;
    padding: 0.85rem 0.65rem;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.pl-nav-section {
    margin-top: 1.25rem;
}

.pl-nav-section:first-child {
    margin-top: 0;
}

.pl-nav-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: rgba(255,255,255,0.4);
    padding: 0 0.55rem;
    margin-bottom: 0.3rem;
}

.pl-nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.48rem 0.6rem;
    border-radius: 6px;
    color: rgba(255,255,255,0.72);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: background 0.12s, color 0.12s;
}

.pl-nav-item svg {
    flex-shrink: 0;
    opacity: 0.85;
}

.pl-nav-item:hover {
    background: rgba(255,255,255,0.09);
    color: #fff;
}

.pl-nav-item:hover svg { opacity: 1; }

.pl-nav-item.active,
.pl-nav-item[aria-current="page"] {
    background: rgba(255,255,255,0.14);
    color: #fff;
}

.pl-nav-item.active svg { opacity: 1; }

/* --- Sidebar footer / user area --- */
.pl-sidebar-footer {
    flex-shrink: 0;
    padding: 0.85rem 0.65rem;
    border-top: 1px solid rgba(255,255,255,0.10);
}

.pl-sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.4rem 0.55rem;
    margin-bottom: 0.35rem;
}

.pl-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.pl-sidebar-user-info {
    min-width: 0;
    flex: 1;
}

.pl-sidebar-user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pl-sidebar-user-email {
    font-size: 0.73rem;
    color: rgba(255,255,255,0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Content area --- */
.pl-content {
    margin-left: var(--pl-sidebar-width);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.pl-main {
    flex: 1;
    max-width: 68rem;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 2.25rem;
}

/* ============================================================
   AUTH LAYOUT  (login / register — no sidebar)
   ============================================================ */
.pl-auth-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: var(--pl-color-bg);
}

.pl-auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.75rem;
    text-decoration: none;
    color: var(--pl-color-primary);
    font-family: var(--pl-font-display);
    font-weight: 600;
    font-size: 1.3rem;
}

.pl-auth-logo img {
    height: 36px;
    width: auto;
}

.pl-auth-card {
    background: var(--pl-color-surface);
    border: 1px solid var(--pl-color-border);
    border-radius: var(--pl-radius-lg);
    box-shadow: var(--pl-shadow);
    padding: 2rem 2.25rem;
    width: 100%;
    max-width: 26rem;
}

.pl-auth-heading,
.pl-auth-card h1 {
    margin: 0 0 0.25rem;
    font-family: var(--pl-font-display);
    font-size: 1.35rem;
    font-weight: 600;
}

.pl-auth-divider {
    border: none;
    border-top: 1px solid var(--pl-color-border-subtle);
    margin: 1.5rem 0;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.pl-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.pl-page-header-left { flex: 1; min-width: 0; }

.pl-page-title {
    margin: 0;
    font-family: var(--pl-font-display);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--pl-color-text);
    letter-spacing: -0.01em;
}

.pl-page-subtitle {
    margin: 0.25rem 0 0;
    color: var(--pl-color-text-muted);
    font-size: 0.9rem;
}

/* ============================================================
   SURFACES / CARDS
   ============================================================ */
.pl-surface {
    background: var(--pl-color-surface);
    border: 1px solid var(--pl-color-border);
    border-radius: var(--pl-radius);
    box-shadow: var(--pl-shadow-sm);
}

.pl-card {
    background: var(--pl-color-surface);
    border: 1px solid var(--pl-color-border);
    border-radius: var(--pl-radius);
    box-shadow: var(--pl-shadow-sm);
    padding: 1.25rem;
}

/* When card uses structured children, remove the card's own padding */
.pl-card:has(> .pl-card-header),
.pl-card:has(> .pl-card-body),
.pl-card:has(> table),
.pl-card:has(> .pl-card-header) + .pl-card:has(> .pl-card-body) {
    padding: 0;
}

.pl-card-header {
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--pl-color-border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.pl-card-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--pl-color-text);
    margin: 0;
}

.pl-card-body {
    padding: 1.25rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.pl-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.52rem 1.05rem;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: var(--pl-radius);
    border: 1px solid transparent;
    cursor: pointer;
    background: var(--pl-color-primary);
    color: #fff;
    line-height: 1.3;
    transition: background 0.12s;
    white-space: nowrap;
}

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

.pl-btn-secondary {
    background: var(--pl-color-secondary);
}
.pl-btn-secondary:hover { background: #4a3f88; }

.pl-btn-ghost {
    background: transparent;
    color: var(--pl-color-text);
    border-color: var(--pl-color-border);
}
.pl-btn-ghost:hover { background: var(--pl-color-bg); }

.pl-btn-danger {
    background: #b42318;
    color: #fff;
}
.pl-btn-danger:hover { background: #9b1d13; }

.pl-btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
}

/* ============================================================
   BADGES
   ============================================================ */
.pl-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.6rem;
    border-radius: 99px;
    font-size: 0.76rem;
    font-weight: 600;
    white-space: nowrap;
    background: var(--pl-color-border-subtle);
    color: var(--pl-color-text-muted);
}

.pl-badge-open        { background: #d1fae5; color: #065f46; }
.pl-badge-in_progress { background: #dbeafe; color: #1e40af; }
.pl-badge-on_hold     { background: #fef3c7; color: #92400e; }
.pl-badge-with_client { background: #ede9fe; color: #5b21b6; }
.pl-badge-closed      { background: #f1f0ec; color: var(--pl-color-text-muted); }
.pl-badge-pending     { background: #fef3c7; color: #92400e; }
.pl-badge-resolved    { background: #dbeafe; color: #1e40af; }
.pl-badge-urgent      { background: #fee2e2; color: #991b1b; }
/* Task statuses */
.pl-badge-done        { background: #d1fae5; color: #065f46; }

/* Task priorities */
.pl-badge-low         { background: #f1f0ec; color: var(--pl-color-text-muted); }
.pl-badge-medium      { background: #dbeafe; color: #1e40af; }
.pl-badge-high        { background: #fef3c7; color: #92400e; }
.pl-badge-critical    { background: #fee2e2; color: #991b1b; }

/* Project statuses */
.pl-badge-active      { background: #d1fae5; color: #065f46; }
.pl-badge-completed   { background: #dbeafe; color: #1e40af; }
.pl-badge-archived    { background: #f1f0ec; color: var(--pl-color-text-muted); }

/* Backlog statuses */
.pl-badge-accepted    { background: #d1fae5; color: #065f46; }
.pl-badge-rejected    { background: #fee2e2; color: #991b1b; }
.pl-badge-converted   { background: #ede9fe; color: #5b21b6; }

/* Semantic */
.pl-badge-success     { background: #d1fae5; color: #065f46; }
.pl-badge-warning     { background: #fef3c7; color: #92400e; }
.pl-badge-error       { background: #fee2e2; color: #991b1b; }

/* ============================================================
   TYPOGRAPHY UTILITIES
   ============================================================ */
.pl-link {
    color: var(--pl-color-primary);
    font-weight: 600;
    text-decoration: none;
}
.pl-link:hover { text-decoration: underline; }

.pl-muted {
    color: var(--pl-color-text-muted);
    font-size: 0.9rem;
}

.pl-text-sm { font-size: 0.85rem; }
.pl-text-danger { color: #b42318; }

/* ============================================================
   FLASH MESSAGES
   ============================================================ */
.pl-flash {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.8rem 1rem;
    border-radius: var(--pl-radius);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.pl-flash-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.pl-flash-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.pl-flash-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.pl-flash-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* ============================================================
   SECTION HEADERS (within pages)
   ============================================================ */
.pl-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--pl-color-text);
    margin: 0 0 0.5rem;
}

.pl-divider {
    border: none;
    border-top: 1px solid var(--pl-color-border-subtle);
    margin: 1.75rem 0;
}

/* ============================================================
   TABLES
   ============================================================ */
table.pl-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--pl-color-surface);
    border: 1px solid var(--pl-color-border);
    border-radius: var(--pl-radius);
    overflow: hidden;
    box-shadow: var(--pl-shadow-sm);
    font-size: 0.9rem;
}

table.pl-table thead {
    background: var(--pl-color-bg);
    border-bottom: 1px solid var(--pl-color-border);
}

table.pl-table th {
    padding: 0.65rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--pl-color-text-muted);
    white-space: nowrap;
}

table.pl-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--pl-color-border-subtle);
    vertical-align: middle;
}

table.pl-table tr:last-child td { border-bottom: none; }

table.pl-table tbody tr {
    transition: background 0.1s;
}

table.pl-table tbody tr:hover {
    background: #faf9f7;
}

table.pl-table .pl-table-actions {
    text-align: right;
    white-space: nowrap;
}

/* ============================================================
   FORMS
   ============================================================ */
.pl-form-group {
    margin-bottom: 1rem;
}

.pl-label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--pl-color-text);
    margin-bottom: 0.3rem;
}

.pl-input {
    width: 100%;
    max-width: 32rem;
    padding: 0.52rem 0.75rem;
    border: 1px solid var(--pl-color-border);
    border-radius: 6px;
    font: inherit;
    font-size: 0.9rem;
    background: var(--pl-color-surface);
    color: var(--pl-color-text);
    transition: border-color 0.12s, box-shadow 0.12s;
}

.pl-input:focus {
    outline: none;
    border-color: var(--pl-color-primary);
    box-shadow: 0 0 0 3px rgba(61,47,124,0.12);
}

textarea.pl-input { min-height: 6rem; resize: vertical; }

select.pl-input { cursor: pointer; }

.pl-form-section {
    margin-bottom: 1.75rem;
}

.pl-form-section-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--pl-color-text);
    margin: 0 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--pl-color-border-subtle);
}

label {
    display: block;
    margin-top: 1rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--pl-color-text);
}

label:first-child { margin-top: 0; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
    width: 100%;
    max-width: 32rem;
    margin-top: 0.3rem;
    padding: 0.52rem 0.75rem;
    border: 1px solid var(--pl-color-border);
    border-radius: 6px;
    font: inherit;
    font-size: 0.9rem;
    background: var(--pl-color-surface);
    color: var(--pl-color-text);
    transition: border-color 0.12s, box-shadow 0.12s;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--pl-color-primary);
    box-shadow: 0 0 0 3px rgba(61,47,124,0.12);
}

textarea { min-height: 6rem; resize: vertical; }

/* Compact inline select — fits inside meta strips and toolbars */
.pl-inline-select {
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0.25rem 1.6rem 0.25rem 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
    border: 1px solid var(--pl-color-border);
    border-radius: 5px;
    background: var(--pl-color-surface);
    color: var(--pl-color-text);
    cursor: pointer;
    transition: border-color 0.12s, box-shadow 0.12s;
}
.pl-inline-select:focus {
    outline: none;
    border-color: var(--pl-color-primary);
    box-shadow: 0 0 0 3px rgba(61,47,124,0.12);
}
.pl-inline-select:hover {
    border-color: var(--pl-color-primary);
}

/* Tag pills */
.pl-tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35em 0.65em;
    font-size: 0.75em;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 50rem;
    background-color: var(--pl-color-primary);
    color: #fff;
    border: none;
}
.pl-tag-pill-remove {
    all: unset;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.1em;
    height: 1.1em;
    margin-left: 0.1em;
    margin-right: -0.25em;
    border-radius: 50%;
    font-size: 1.05em;
    line-height: 1;
    opacity: 0.7;
    color: inherit;
    transition: opacity 0.15s, background 0.15s;
}
.pl-tag-pill-remove:hover {
    opacity: 1;
    background: rgba(255,255,255,0.25);
}
.pl-tag-add-btn {
    all: unset;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    border: 1px dashed var(--pl-color-border);
    font-size: 1rem;
    line-height: 1;
    color: var(--pl-color-muted);
    transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.pl-tag-add-btn:hover {
    border-color: var(--pl-color-primary);
    color: var(--pl-color-primary);
    background: rgba(61,47,124,0.06);
}
.pl-tag-picker {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    z-index: 100;
    min-width: 12rem;
    max-height: 16rem;
    overflow-y: auto;
    background: var(--pl-color-surface);
    border: 1px solid var(--pl-color-border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    padding: 0.3rem;
}
.pl-tag-picker-item {
    all: unset;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
    padding: 0.4rem 0.6rem;
    font-size: 0.82rem;
    border-radius: 5px;
    box-sizing: border-box;
    transition: background 0.1s;
}
.pl-tag-picker-item:hover {
    background: var(--pl-color-bg);
}
.pl-tag-picker-dot {
    display: inline-block;
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Audit log timeline */
.pl-audit-log {
    position: relative;
    padding-left: 1.4rem;
    border-left: 2px solid var(--pl-color-border-subtle);
    margin-left: 0.5rem;
}
.pl-audit-entry {
    position: relative;
    padding: 0.45rem 0 0.45rem 0.75rem;
}
.pl-audit-dot {
    position: absolute;
    left: -1.4rem;
    top: 0.7rem;
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: var(--pl-color-border);
    border: 2px solid var(--pl-color-bg);
    transform: translateX(-50%);
}
.pl-audit-content {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.3rem 0.5rem;
    font-size: 0.82rem;
    line-height: 1.5;
}
.pl-audit-actor {
    font-weight: 700;
    color: var(--pl-color-text);
}
.pl-audit-action {
    color: var(--pl-color-text-muted);
}
.pl-audit-action strong {
    color: var(--pl-color-text);
    font-weight: 600;
}
.pl-audit-time {
    color: var(--pl-color-text-muted);
    font-size: 0.75rem;
    opacity: 0.7;
    margin-left: auto;
}

/* Checkbox / radio row */
input[type="checkbox"],
input[type="radio"] {
    width: auto;
    margin-top: 0;
    max-width: none;
    accent-color: var(--pl-color-primary);
}

/* ============================================================
   STAT / INFO CARDS  (dashboard)
   ============================================================ */
.pl-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.pl-stat-card {
    background: var(--pl-color-surface);
    border: 1px solid var(--pl-color-border);
    border-radius: var(--pl-radius);
    padding: 1.2rem 1.4rem;
    box-shadow: var(--pl-shadow-sm);
}

.pl-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    font-family: var(--pl-font-display);
    color: var(--pl-color-primary);
    line-height: 1.1;
}

.pl-stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--pl-color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.3rem;
}

/* Quick-link cards */
.pl-action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: 1rem;
}

.pl-action-card {
    display: flex;
    flex-direction: column;
    background: var(--pl-color-surface);
    border: 1px solid var(--pl-color-border);
    border-radius: var(--pl-radius);
    padding: 1.25rem 1.4rem;
    text-decoration: none;
    color: var(--pl-color-text);
    box-shadow: var(--pl-shadow-sm);
    transition: border-color 0.12s, box-shadow 0.12s;
}

.pl-action-card:hover {
    border-color: var(--pl-color-primary);
    box-shadow: 0 0 0 3px rgba(61,47,124,0.08);
}

.pl-action-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(61,47,124,0.08);
    color: var(--pl-color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.85rem;
    flex-shrink: 0;
}

.pl-action-card-title {
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
}

.pl-action-card-desc {
    font-size: 0.82rem;
    color: var(--pl-color-text-muted);
    flex: 1;
}

/* ============================================================
   MESSAGE THREAD  (ticket show)
   ============================================================ */
.pl-thread {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin: 1rem 0;
}

.pl-message {
    background: var(--pl-color-surface);
    border: 1px solid var(--pl-color-border);
    border-radius: var(--pl-radius);
    box-shadow: var(--pl-shadow-sm);
    overflow: hidden;
}

.pl-message-internal {
    border-left: 3px solid var(--pl-color-warning);
    background: #fffbf2;
}

.pl-message-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    background: var(--pl-color-bg);
    border-bottom: 1px solid var(--pl-color-border-subtle);
    font-size: 0.82rem;
}

.pl-message-author {
    font-weight: 700;
    color: var(--pl-color-text);
}

.pl-message-meta {
    color: var(--pl-color-text-muted);
    flex: 1;
}

.pl-message-body {
    padding: 0.9rem 1rem;
    white-space: pre-wrap;
    font-size: 0.9rem;
    line-height: 1.6;
}

/* ============================================================
   TICKET META ROW
   ============================================================ */
.pl-ticket-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    padding: 0.85rem 1.1rem;
    background: var(--pl-color-surface);
    border: 1px solid var(--pl-color-border);
    border-radius: var(--pl-radius);
    margin-bottom: 1.25rem;
    font-size: 0.85rem;
    box-shadow: var(--pl-shadow-sm);
}

.pl-ticket-meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.pl-ticket-meta-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--pl-color-text-muted);
}

.pl-ticket-meta-value {
    font-weight: 600;
    color: var(--pl-color-text);
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.pl-empty {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--pl-color-text-muted);
}

.pl-empty-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    opacity: 0.35;
    color: var(--pl-color-primary);
}

.pl-empty-title {
    font-weight: 700;
    color: var(--pl-color-text);
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
}

/* ============================================================
   ORGANIZATION PICKER
   ============================================================ */
.pl-org-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.pl-org-item {
    background: var(--pl-color-surface);
    border: 1px solid var(--pl-color-border);
    border-radius: var(--pl-radius);
    box-shadow: var(--pl-shadow-sm);
    transition: border-color 0.12s;
}

.pl-org-item:hover { border-color: var(--pl-color-primary); }

.pl-org-item form {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
}

/* ============================================================
   LEGACY HEADER  (kept for compatibility — not used in new layout)
   ============================================================ */
.pl-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1.5rem;
    background: var(--pl-color-surface);
    border-bottom: 1px solid var(--pl-color-border);
}

.pl-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--pl-color-text);
    font-family: var(--pl-font-display);
    font-weight: 600;
    font-size: 1.2rem;
}

.pl-logo img, .pl-logo svg { height: 34px; width: auto; }

/* ============================================================
   CURRENCY SELECTOR  (portal account / marketing)
   ============================================================ */
.portal-ccy-wrap { margin: 0.75rem 0 1.25rem; }

.mk-ccy-selector {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    padding: 0.65rem 0.85rem;
    background: var(--pl-color-surface);
    border: 1px solid var(--pl-color-border);
    border-radius: var(--pl-radius);
    box-shadow: var(--pl-shadow-sm);
}

.mk-ccy-selector__label {
    margin: 0;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    color: var(--pl-color-text-muted);
}

.mk-ccy-selector__field {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.mk-ccy-selector__select {
    width: auto;
    min-width: min(100%, 16rem);
    max-width: 20rem;
    margin-top: 0;
}

.mk-ccy-selector__apply { margin-top: 0; flex-shrink: 0; }

/* ============================================================
   SIDEBAR NAV BADGE
   ============================================================ */
.pl-nav-badge {
    margin-left: auto;
    min-width: 1.4rem;
    height: 1.4rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: rgba(255,255,255,0.25);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ============================================================
   DASHBOARD STAT GRID
   ============================================================ */
.pl-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.pl-stat-grid--wide {
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
}

.pl-stat-card {
    background: var(--pl-color-surface);
    border: 1px solid var(--pl-color-border);
    border-radius: var(--pl-radius);
    box-shadow: var(--pl-shadow-sm);
    padding: 1.15rem 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.12s, box-shadow 0.12s;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

a.pl-stat-card:hover {
    border-color: var(--pl-color-primary);
    box-shadow: var(--pl-shadow);
}

.pl-stat-card--danger {
    border-color: #f5c6c3;
    background: #fff5f5;
}

.pl-stat-card--warning {
    border-color: #f5d07a;
    background: #fffdf0;
}

.pl-stat-card--ok {
    border-color: #b7e4c7;
    background: #f0faf4;
}
.pl-stat-card--muted {
    border-color: var(--pl-color-border-subtle);
    background: var(--pl-color-bg);
}

.pl-stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--pl-color-text);
    font-family: var(--pl-font-display);
}

.pl-stat-card--danger .pl-stat-value { color: var(--pl-color-error); }
.pl-stat-card--warning .pl-stat-value { color: var(--pl-color-warning); }
.pl-stat-card--ok .pl-stat-value { color: var(--pl-color-success); }
.pl-stat-card--muted .pl-stat-value { color: var(--pl-color-text-muted); }

.pl-stat-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--pl-color-text-muted);
}


/* ============================================================
   TICKET LIST ROW COLOURS
   ============================================================ */
.pl-row-danger td { background: #fff5f5; }
.pl-row-warning td { background: #fffdf0; }

/* ============================================================
   TAB BAR
   ============================================================ */
.pl-tab-bar {
    display: flex;
    gap: 0.35rem;
    border-bottom: 2px solid var(--pl-color-border-subtle);
    padding: 0 0.15rem;
}
.pl-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 1.1rem;
    font-size: 0.84rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--pl-color-text-muted);
    text-decoration: none;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 7px 7px 0 0;
    margin-bottom: -2px;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.pl-tab svg {
    opacity: 0.55;
    transition: opacity 0.15s;
}
.pl-tab:hover {
    color: var(--pl-color-text);
    background: var(--pl-color-border-subtle);
}
.pl-tab:hover svg {
    opacity: 0.75;
}
.pl-tab-active {
    color: var(--pl-color-primary);
    background: var(--pl-color-surface);
    border-color: var(--pl-color-border-subtle);
    border-bottom: 2px solid var(--pl-color-surface);
    box-shadow: 0 -2px 6px rgba(0,0,0,0.04);
}
.pl-tab-active svg {
    opacity: 1;
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.pl-filter-toolbar {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-bottom: 0.85rem;
}

.pl-filter-toolbar .pl-filter-search {
    position: relative;
    flex: 0 0 180px;
}

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

.pl-filter-toolbar .pl-filter-search-input {
    width: 100%;
    max-width: none;
    padding: 0.35rem 0.65rem 0.35rem 1.85rem;
    font-size: 0.83rem;
    margin: 0;
    height: auto;
}

.pl-filter-chip {
    flex-shrink: 0;
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0.35rem 0.55rem;
    font-size: 0.82rem;
    border: 1px solid var(--pl-color-border);
    border-radius: var(--pl-radius);
    background: var(--pl-color-surface);
    color: var(--pl-color-text);
    cursor: pointer;
    height: auto;
    line-height: 1.4;
}

.pl-filter-chip:focus {
    outline: 2px solid var(--pl-color-primary);
    outline-offset: 1px;
    box-shadow: none;
}

.pl-filter-clear {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
    color: var(--pl-color-text-muted);
    text-decoration: none;
    padding: 0.35rem 0.5rem;
    border-radius: var(--pl-radius);
    margin-left: 0.1rem;
}

.pl-filter-clear:hover {
    color: var(--pl-color-text);
    background: var(--pl-color-bg);
}

/* ============================================================
   BULK ACTION BAR
   ============================================================ */
.pl-bulk-bar {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
    padding: 0.55rem 0.85rem;
    background: var(--pl-color-primary);
    border-radius: var(--pl-radius);
    margin-bottom: 0.75rem;
    color: #fff;
    font-size: 0.85rem;
}

.pl-bulk-count {
    font-weight: 700;
    white-space: nowrap;
}

.pl-bulk-bar .pl-filter-select {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border-color: rgba(255,255,255,0.3);
}

.pl-bulk-bar .pl-filter-select option { color: var(--pl-color-text); background: #fff; }


/* ============================================================
   REPORTS BAR CHART
   ============================================================ */
.pl-bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 120px;
    padding-bottom: 1.5rem;
    position: relative;
}

.pl-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    position: relative;
}

.pl-bar {
    width: 100%;
    min-height: 2px;
    background: var(--pl-color-primary);
    border-radius: 3px 3px 0 0;
    opacity: 0.8;
    transition: opacity 0.1s;
}

.pl-bar-col:hover .pl-bar { opacity: 1; }

.pl-bar-label {
    position: absolute;
    bottom: -1.4rem;
    font-size: 0.65rem;
    color: var(--pl-color-text-muted);
    white-space: nowrap;
}

/* ============================================================
   CARD INFO VARIANT
   ============================================================ */
.pl-card--info {
    border-color: #bfdbfe;
    background: #eff6ff;
}

/* ============================================================
   SECTION TITLE
   ============================================================ */
.pl-section-title {
    font-family: var(--pl-font-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--pl-color-text);
    margin: 0 0 0.75rem;
}

/* ============================================================
   RESPONSIVE  (narrow viewports)
   ============================================================ */
@media (max-width: 700px) {
    :root { --pl-sidebar-width: 0px; }
    .pl-sidebar { display: none; }
    .pl-content { margin-left: 0; }
    .pl-main { padding: 1.25rem 1rem; }
    .pl-page-header { flex-direction: column; align-items: flex-start; }
    .pl-stat-grid { grid-template-columns: 1fr 1fr; }
    .pl-action-grid { grid-template-columns: 1fr; }
    .pl-filter-toolbar .pl-filter-search { flex: 1 1 100%; }
    .pl-filter-chip { flex: 1 1 auto; }
}
