/* =============================================================
   PBUK Mega System — Design Tokens & Base Styles
   Purple Box UK — Internal Platform
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ------------------------------------------------------------------
   1. Design Tokens (CSS Custom Properties)
   ------------------------------------------------------------------ */
:root {
    /* Brand */
    --color-brand-50:  hsl(258, 100%, 96%);
    --color-brand-100: hsl(258, 92%,  90%);
    --color-brand-200: hsl(258, 88%,  82%);
    --color-brand-300: hsl(258, 82%,  72%);
    --color-brand-400: hsl(258, 75%,  62%);
    --color-brand-500: hsl(258, 68%,  54%);  /* primary */
    --color-brand-600: hsl(258, 65%,  46%);
    --color-brand-700: hsl(258, 62%,  38%);
    --color-brand-800: hsl(258, 58%,  28%);
    --color-brand-900: hsl(258, 55%,  18%);

    /* Neutrals */
    --color-neutral-50:  hsl(220, 20%, 97%);
    --color-neutral-100: hsl(220, 16%, 94%);
    --color-neutral-200: hsl(220, 14%, 88%);
    --color-neutral-300: hsl(220, 12%, 78%);
    --color-neutral-400: hsl(220, 10%, 60%);
    --color-neutral-500: hsl(220,  8%, 46%);
    --color-neutral-600: hsl(220,  8%, 34%);
    --color-neutral-700: hsl(220,  9%, 24%);
    --color-neutral-800: hsl(220, 10%, 16%);
    --color-neutral-900: hsl(220, 14%, 10%);

    /* Semantic colours */
    --color-success: hsl(142, 60%, 42%);
    --color-warning: hsl(38,  90%, 52%);
    --color-danger:  hsl(0,   72%, 52%);
    --color-info:    hsl(200, 80%, 50%);

    /* Surface */
    --surface-bg:       hsl(220, 20%, 97%);
    --surface-card:     #ffffff;
    --surface-sidebar:  hsl(258, 20%, 12%);
    --surface-sidebar-hover: hsl(258, 24%, 20%);
    --surface-sidebar-active: var(--color-brand-500);

    /* Text */
    --text-primary:    hsl(220, 14%, 12%);
    --text-secondary:  hsl(220,  8%, 40%);
    --text-muted:      hsl(220,  6%, 58%);
    --text-inverse:    #ffffff;
    --text-sidebar:    hsl(258, 20%, 75%);
    --text-sidebar-active: #ffffff;

    /* Border */
    --border-default:  hsl(220, 14%, 88%);
    --border-focus:    var(--color-brand-400);

    /* Spacing */
    --space-1:  0.25rem;
    --space-2:  0.5rem;
    --space-3:  0.75rem;
    --space-4:  1rem;
    --space-5:  1.25rem;
    --space-6:  1.5rem;
    --space-8:  2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;

    /* Typography */
    --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono:    'JetBrains Mono', 'Fira Code', monospace;
    --text-xs:   0.75rem;
    --text-sm:   0.875rem;
    --text-base: 1rem;
    --text-lg:   1.125rem;
    --text-xl:   1.25rem;
    --text-2xl:  1.5rem;
    --text-3xl:  1.875rem;
    --line-tight:  1.25;
    --line-normal: 1.5;
    --line-relaxed: 1.625;

    /* Radius */
    --radius-sm:  0.25rem;
    --radius-md:  0.5rem;
    --radius-lg:  0.75rem;
    --radius-xl:  1rem;
    --radius-full: 9999px;

    /* Shadow */
    --shadow-sm:   0 1px 3px hsl(220 14% 10% / 0.08), 0 1px 2px hsl(220 14% 10% / 0.04);
    --shadow-md:   0 4px 12px hsl(220 14% 10% / 0.10), 0 2px 4px hsl(220 14% 10% / 0.06);
    --shadow-lg:   0 10px 30px hsl(220 14% 10% / 0.12), 0 4px 8px hsl(220 14% 10% / 0.06);

    /* Layout */
    --sidebar-width:       240px;
    --sidebar-width-collapsed: 64px;
    --topbar-height:       60px;
    --content-max-width:   1280px;

    /* Transition */
    --transition-fast:   150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow:   400ms ease;
}

/* ------------------------------------------------------------------
   2. Reset & Base
   ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--line-normal);
    color: var(--text-primary);
    background: var(--surface-bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--color-brand-500); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--color-brand-600); }

img, svg { display: block; max-width: 100%; }

/* ------------------------------------------------------------------
   3. App Shell Layout
   ------------------------------------------------------------------ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--surface-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid hsl(258 20% 20%);
    min-height: var(--topbar-height);
    flex-shrink: 0;
}

.sidebar-brand-logo {
    width: 32px; height: 32px;
    border-radius: var(--radius-md);
    background: var(--color-brand-500);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-weight: 700;
    color: white;
    font-size: var(--text-sm);
}

.sidebar-brand-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-inverse);
    white-space: nowrap;
}

.sidebar-brand-sub {
    font-size: var(--text-xs);
    color: var(--text-sidebar);
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4) 0;
    scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.sidebar-section { margin-bottom: var(--space-6); }

.sidebar-section-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: hsl(258 20% 45%);
    padding: 0 var(--space-4) var(--space-2);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-4);
    margin: 1px var(--space-2);
    border-radius: var(--radius-md);
    color: var(--text-sidebar);
    font-size: var(--text-sm);
    font-weight: 450;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    white-space: nowrap;
    overflow: hidden;
    text-decoration: none;
}

.nav-item:hover { background: var(--surface-sidebar-hover); color: var(--text-inverse); }
.nav-item.active { background: var(--surface-sidebar-active); color: var(--text-sidebar-active); font-weight: 500; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
    padding: var(--space-4) var(--space-2);
    border-top: 1px solid hsl(258 20% 20%);
    flex-shrink: 0;
}

.main-area {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: var(--surface-card);
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-8);
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.topbar-title { font-size: var(--text-lg); font-weight: 600; color: var(--text-primary); }

.topbar-right { display: flex; align-items: center; gap: var(--space-4); }

.user-menu {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
    position: relative;
}
.user-menu:hover { background: var(--color-neutral-100); }

.user-avatar {
    width: 34px; height: 34px;
    border-radius: var(--radius-full);
    background: var(--color-brand-500);
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: var(--text-xs);
    font-weight: 600;
    flex-shrink: 0;
}

.user-name { font-size: var(--text-sm); font-weight: 500; color: var(--text-primary); line-height: 1.2; }
.user-role { font-size: var(--text-xs); color: var(--text-muted); text-transform: capitalize; }

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    padding: var(--space-2) 0;
    display: none;
    z-index: 200;
}
.user-dropdown.open { display: block; }

.dropdown-item {
    display: block;
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    color: var(--text-primary);
    transition: background var(--transition-fast);
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-sans);
}
.dropdown-item:hover { background: var(--color-neutral-50); }
.dropdown-item.danger { color: var(--color-danger); }
.dropdown-divider { height: 1px; background: var(--border-default); margin: var(--space-2) 0; }

.page-content {
    flex: 1;
    padding: var(--space-8);
    max-width: var(--content-max-width);
    width: 100%;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-8);
}

.page-title { font-size: var(--text-2xl); font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; }
.page-subtitle { font-size: var(--text-sm); color: var(--text-secondary); margin-top: var(--space-1); }

/* ------------------------------------------------------------------
   4. Cards
   ------------------------------------------------------------------ */
.card { background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--radius-xl); box-shadow: var(--shadow-sm); }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-5) var(--space-6); border-bottom: 1px solid var(--border-default); }
.card-title { font-size: var(--text-base); font-weight: 600; color: var(--text-primary); }
.card-body { padding: var(--space-6); }

/* ------------------------------------------------------------------
   5. Stats cards
   ------------------------------------------------------------------ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-5);
    margin-bottom: var(--space-8);
}

.stat-card {
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-icon {
    width: 40px; height: 40px;
    border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: var(--space-4);
}
.stat-icon svg { width: 20px; height: 20px; }
.stat-icon.purple { background: var(--color-brand-50); color: var(--color-brand-500); }
.stat-icon.green  { background: hsl(142 60% 94%); color: var(--color-success); }
.stat-icon.amber  { background: hsl(38  90% 94%); color: var(--color-warning); }
.stat-icon.red    { background: hsl(0   72% 94%); color: var(--color-danger); }

.stat-label { font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); margin-bottom: var(--space-2); }
.stat-value { font-size: var(--text-3xl); font-weight: 700; color: var(--text-primary); letter-spacing: -0.03em; line-height: 1; }

/* ------------------------------------------------------------------
   6. Buttons
   ------------------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 500;
    font-family: var(--font-sans);
    line-height: 1;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
}
.btn:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.btn-primary { background: var(--color-brand-500); color: white; border-color: var(--color-brand-500); }
.btn-primary:hover { background: var(--color-brand-600); border-color: var(--color-brand-600); color: white; }
.btn-secondary { background: var(--surface-card); color: var(--text-primary); border-color: var(--border-default); }
.btn-secondary:hover { background: var(--color-neutral-50); }
.btn-danger { background: var(--color-danger); color: white; }
.btn-danger:hover { background: hsl(0 72% 44%); color: white; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: var(--text-xs); }
.btn-lg { padding: 0.75rem 1.5rem; font-size: var(--text-base); }
.w-full  { width: 100%; justify-content: center; }

/* ------------------------------------------------------------------
   7. Forms
   ------------------------------------------------------------------ */
.form-group { margin-bottom: var(--space-5); }
.form-label { display: block; font-size: var(--text-sm); font-weight: 500; color: var(--text-primary); margin-bottom: var(--space-2); }
.form-label.required::after { content: ' *'; color: var(--color-danger); }

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.5625rem 0.875rem;
    font-size: var(--text-sm);
    font-family: var(--font-sans);
    color: var(--text-primary);
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    line-height: var(--line-normal);
    appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px hsl(258 68% 54% / 0.12);
}
.form-input.error, .form-select.error, .form-textarea.error { border-color: var(--color-danger); }
.form-textarea { resize: vertical; min-height: 120px; }
.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.25em 1.25em;
    padding-right: 2.5rem;
    cursor: pointer;
}
.form-error { margin-top: var(--space-1); font-size: var(--text-xs); color: var(--color-danger); }
.form-hint  { margin-top: var(--space-1); font-size: var(--text-xs); color: var(--text-muted); }

/* ------------------------------------------------------------------
   8. Alerts
   ------------------------------------------------------------------ */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    margin-bottom: var(--space-5);
    border-left: 3px solid transparent;
}
.alert-success { background: hsl(142 60% 94%); color: hsl(142 60% 25%); border-left-color: var(--color-success); }
.alert-error   { background: hsl(0   72% 94%); color: hsl(0   72% 30%); border-left-color: var(--color-danger); }
.alert-warning { background: hsl(38  90% 94%); color: hsl(38  90% 25%); border-left-color: var(--color-warning); }
.alert-info    { background: hsl(200 80% 94%); color: hsl(200 80% 25%); border-left-color: var(--color-info); }

/* ------------------------------------------------------------------
   9. Tables
   ------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; border-radius: var(--radius-xl); border: 1px solid var(--border-default); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; background: var(--surface-card); }
thead { background: var(--color-neutral-50); border-bottom: 1px solid var(--border-default); }
th { padding: var(--space-3) var(--space-5); text-align: left; font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; }
td { padding: var(--space-4) var(--space-5); font-size: var(--text-sm); color: var(--text-primary); border-bottom: 1px solid var(--border-default); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition-fast); }
tbody tr:hover { background: var(--color-neutral-50); }

/* ------------------------------------------------------------------
   10. Badges
   ------------------------------------------------------------------ */
.badge { display: inline-flex; align-items: center; padding: 0.2rem 0.65rem; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; }

.badge-open            { background: hsl(200 80% 90%); color: hsl(200 80% 28%); }
.badge-pending         { background: hsl(38  90% 90%); color: hsl(38  90% 30%); }
.badge-pending_client  { background: hsl(38  90% 90%); color: hsl(38  90% 30%); }
.badge-on_hold         { background: hsl(220 14% 88%); color: hsl(220 14% 30%); }
.badge-resolved        { background: hsl(142 60% 90%); color: hsl(142 60% 25%); }
.badge-closed          { background: hsl(220 14% 88%); color: hsl(220 14% 40%); }
.badge-critical { background: hsl(0   72% 90%); color: hsl(0   72% 28%); }
.badge-high     { background: hsl(25  85% 90%); color: hsl(25  85% 30%); }
.badge-medium   { background: hsl(38  90% 90%); color: hsl(38  90% 30%); }
.badge-low      { background: hsl(142 60% 90%); color: hsl(142 60% 25%); }

/* ------------------------------------------------------------------
   11. Auth
   ------------------------------------------------------------------ */
.auth-page {
    min-height: 100vh;
    background: linear-gradient(135deg, hsl(258 30% 8%), hsl(258 20% 14%));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
}

.auth-card {
    background: var(--surface-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: var(--space-10);
}

.auth-logo { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-8); }

.auth-logo-mark {
    width: 42px; height: 42px;
    background: var(--color-brand-500);
    border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    color: white;
    font-size: var(--text-lg);
}

.auth-logo-text { font-size: var(--text-lg); font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; line-height: 1.1; }
.auth-logo-sub  { font-size: var(--text-xs); color: var(--text-muted); }
.auth-title     { font-size: var(--text-2xl); font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; margin-bottom: var(--space-2); }
.auth-subtitle  { font-size: var(--text-sm); color: var(--text-secondary); margin-bottom: var(--space-8); }

/* ------------------------------------------------------------------
   12. Responsive
   ------------------------------------------------------------------ */
@media (max-width: 1024px) {
    .sidebar { width: var(--sidebar-width-collapsed); }
    .sidebar-brand-name, .sidebar-brand-sub, .sidebar-section-label, .nav-item span { display: none; }
    .sidebar-brand { justify-content: center; padding: var(--space-4); }
    .nav-item { justify-content: center; padding: var(--space-3); }
    .main-area { margin-left: var(--sidebar-width-collapsed); }
    .page-content { padding: var(--space-6) var(--space-4); }
}

@media (max-width: 640px) {
    .sidebar { display: none; }
    .main-area { margin-left: 0; padding-bottom: 64px; }
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        background: var(--surface-card);
        border-top: 1px solid var(--border-default);
        height: 64px;
        z-index: 100;
        box-shadow: 0 -4px 12px hsl(220 14% 10% / 0.08);
    }
    .bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        color: var(--text-muted);
        font-size: 10px;
        font-weight: 500;
        text-decoration: none;
        transition: color var(--transition-fast);
    }
    .bottom-nav-item svg { width: 22px; height: 22px; }
    .bottom-nav-item.active { color: var(--color-brand-500); }
}

@media (min-width: 641px) { .bottom-nav { display: none; } }

/* ------------------------------------------------------------------
   13. Utilities
   ------------------------------------------------------------------ */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border-width: 0; }
.text-muted    { color: var(--text-muted); }
.text-sm       { font-size: var(--text-sm); }
.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.mt-4  { margin-top: var(--space-4); }
.mt-6  { margin-top: var(--space-6); }
.mb-4  { margin-bottom: var(--space-4); }
.mb-6  { margin-bottom: var(--space-6); }
.flex  { display: flex; }
.items-center   { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.w-full { width: 100%; }
.grid  { display: grid; }
.col-2 { grid-template-columns: 1fr 1fr; gap: var(--space-5); }

/* ------------------------------------------------------------------
   Phase 2 additions
   ------------------------------------------------------------------ */

/* Data table (used in client/team list views) */
.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.data-table thead { background: var(--color-neutral-50); border-bottom: 1px solid var(--border-subtle); }
.data-table th { padding: var(--space-3) var(--space-4); text-align: left; font-weight: 600; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.data-table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-subtle); color: var(--text-primary); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--color-neutral-50); }

/* Rich text area (HTMLPurifier output) */
.rich-text h2 { font-size: var(--text-lg); font-weight: 600; margin: 1em 0 0.5em; }
.rich-text h3 { font-size: var(--text-base); font-weight: 600; margin: 1em 0 0.5em; }
.rich-text p  { margin: 0 0 0.75em; }
.rich-text ul, .rich-text ol { margin: 0 0 0.75em 1.5em; }
.rich-text li { margin-bottom: 0.25em; }
.rich-text blockquote { border-left: 3px solid var(--border-subtle); padding-left: var(--space-4); margin: 0 0 0.75em; color: var(--text-muted); }
.rich-text pre { background: var(--color-neutral-100); padding: var(--space-3); border-radius: var(--radius-md); overflow-x: auto; font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.85em; margin: 0 0 0.75em; }
.rich-text code { background: var(--color-neutral-100); padding: 2px 5px; border-radius: 3px; font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.85em; }
.rich-text pre code { background: none; padding: 0; }
.rich-text a { color: var(--color-brand-600); text-decoration: underline; }
.rich-text table { width: 100%; border-collapse: collapse; margin-bottom: 0.75em; font-size: var(--text-sm); }
.rich-text th, .rich-text td { border: 1px solid var(--border-subtle); padding: var(--space-2) var(--space-3); }
.rich-text th { background: var(--color-neutral-50); font-weight: 600; }

/* Priority badges */
.badge-critical { background: hsl(0, 80%, 94%); color: hsl(0, 65%, 38%); }
.badge-high     { background: hsl(24, 90%, 93%); color: hsl(24, 70%, 36%); }
.badge-medium   { background: hsl(38, 90%, 92%); color: hsl(38, 65%, 34%); }
.badge-low      { background: hsl(142, 40%, 92%); color: hsl(142, 45%, 30%); }

/* Amber tones (internal note highlight) and SLA breach colour */
:root {
    --color-amber-400: hsl(38, 90%, 56%);
    --color-amber-600: hsl(38, 80%, 40%);
    --color-red-600: hsl(0, 65%, 42%);
}

/* Small button */
.btn-sm { padding: var(--space-1) var(--space-3); font-size: var(--text-xs); }

/* Required field asterisk */
.required-asterisk { color: var(--color-danger); margin-left: 2px; }

/* ------------------------------------------------------------------
   Dropzone
   ------------------------------------------------------------------ */
.dropzone {
    border: 2px dashed var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-8) var(--space-6);
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
    background: var(--color-neutral-50);
    user-select: none;
    outline: none;
}

.dropzone:hover,
.dropzone:focus-visible {
    border-color: var(--color-brand-400);
    background: var(--color-brand-50);
}

.dropzone.drag-over {
    border-color: var(--color-brand-500);
    background: var(--color-brand-50);
    box-shadow: 0 0 0 3px hsl(258 68% 54% / 0.15);
}

.dropzone.has-error {
    border-color: var(--color-danger);
    background: hsl(0 72% 97%);
}

.dropzone-icon {
    color: var(--color-brand-400);
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-3);
}

.dropzone-label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}

.dropzone-browse {
    color: var(--color-brand-500);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.dropzone-hint {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.dropzone-error {
    font-size: var(--text-xs);
    color: var(--color-danger);
    margin-top: var(--space-2);
    text-align: left;
}

/* File pills */
.dropzone-files {
    list-style: none;
    margin-top: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.dropzone-file {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
}

.dropzone-file-icon {
    color: var(--color-brand-500);
    flex-shrink: 0;
}

.dropzone-file-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
    font-weight: 500;
}

.dropzone-file-size {
    font-size: var(--text-xs);
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.dropzone-file-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 2px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: color var(--transition-fast);
    line-height: 1;
}

.dropzone-file-remove:hover { color: var(--color-danger); }

/* =============================================================
   Notification Bell + Dropdown
   ============================================================= */

.notif-bell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background var(--transition-fast), color var(--transition-fast);
    margin-right: var(--space-2);
    flex-shrink: 0;
}
.notif-bell:hover { background: var(--surface-bg); color: var(--text-primary); }
.notif-bell svg   { width: 20px; height: 20px; }

.notif-badge {
    position: absolute;
    top: 3px;
    right: 3px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: hsl(0, 75%, 55%);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
}
.notif-badge[data-count="0"] { display: none; }

/* Wrapper needed for dropdown positioning */
.notif-bell-wrap {
    position: relative;
}

.notif-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 340px;
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0,0,0,.16);
    z-index: 1000;
    overflow: hidden;
}
.notif-dropdown.open { display: block; }

.notif-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-default);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
}
.notif-dropdown-header button {
    font-size: 11px;
    font-weight: 500;
    color: var(--color-brand-500);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}
.notif-dropdown-header button:hover { text-decoration: underline; }

.notif-list {
    max-height: 360px;
    overflow-y: auto;
}

.notif-item {
    display: flex;
    gap: var(--space-3);
    align-items: flex-start;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-default);
    text-decoration: none;
    color: var(--text-primary);
    background: var(--surface-card);
    transition: background var(--transition-fast);
    cursor: pointer;
    box-sizing: border-box;
    width: 100%;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-bg); }
.notif-item.unread { background: hsl(258, 100%, 98%); }
.notif-item.unread:hover { background: hsl(258, 100%, 95%); }

.notif-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-brand-500);
    flex-shrink: 0;
    margin-top: 5px;
}
.notif-item:not(.unread) .notif-dot { background: transparent; }

.notif-item-body { flex: 1; min-width: 0; }
.notif-item-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.notif-item-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.notif-item-time {
    font-size: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-top: 3px;
}

.notif-empty {
    padding: var(--space-8) var(--space-4);
    text-align: center;
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.notif-loading {
    padding: var(--space-6) var(--space-4);
    text-align: center;
    font-size: var(--text-sm);
    color: var(--text-muted);
}

/* =============================================================
   Toast Notifications (slide-in, top-right)
   ============================================================= */

#toast-container {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--color-brand-500);
    border-radius: var(--radius-lg);
    padding: var(--space-3) var(--space-4);
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    min-width: 280px;
    max-width: 360px;
    pointer-events: all;
    cursor: pointer;
    animation: toastSlideIn .25s ease-out;
    transition: opacity .3s, transform .3s;
}
.toast.toast-hiding {
    opacity: 0;
    transform: translateX(20px);
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--color-brand-500);
    margin-top: 1px;
}

.toast-body { flex: 1; min-width: 0; }
.toast-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
}
.toast-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    line-height: 1;
    font-size: 16px;
    flex-shrink: 0;
}
.toast-close:hover { color: var(--text-primary); }

