/* ==========================================================================
   EDAMA QMS Design System
   Brand Colors: Blue (#0072BC), Navy (#003B7A), Teal (#4FA89F)
   ========================================================================== */

:root {
    /* Brand palette */
    --brand-primary: #0072BC;
    --brand-secondary: #003B7A;
    --brand-navy: #003B7A;
    --brand-teal: #4FA89F;
    --brand-teal-light: #66B8B8;

    /* Neutrals */
    --bg-1: #f0f4f8;
    --bg-2: #e4edf5;
    --ink: #1a1d21;
    --ink-soft: #5a6270;
    --neutral-50: #f8fafc;
    --neutral-100: #edf2f7;
    --neutral-200: #dbe4ee;
    --neutral-400: #94a3b8;
    --neutral-500: #64748b;
    --neutral-600: #475569;
    --neutral-700: #334155;
    --neutral-900: #0f172a;
    --text-muted: #5a6270;
    --card: rgba(255, 255, 255, 0.82);
    --line: rgba(26, 29, 33, 0.12);

    /* Semantic */
    --success: #0f8a4f;
    --success-bg: #ecfdf3;
    --success-border: #6dd4a0;
    --warning: #c47f17;
    --warning-bg: #fffbeb;
    --warning-border: #f0d060;
    --danger: #c4321c;
    --danger-bg: #fef2f0;
    --danger-border: #e4938a;
    --info: #0072BC;
    --info-bg: #f0f6ff;
    --info-border: #80b3ff;

    /* Spacing scale (4px rhythm) */
    --sp-1: 0.25rem;    /* 4px */
    --sp-2: 0.5rem;     /* 8px */
    --sp-3: 0.75rem;    /* 12px */
    --sp-4: 1rem;       /* 16px */
    --sp-5: 1.25rem;    /* 20px */
    --sp-6: 1.5rem;     /* 24px */
    --sp-8: 2rem;       /* 32px */

    /* Font scale */
    --text-xs: 0.75rem;     /* 12px */
    --text-sm: 0.8125rem;   /* 13px */
    --text-base: 0.875rem;  /* 14px */
    --text-md: 0.9375rem;   /* 15px */
    --text-lg: 1.0625rem;   /* 17px */
    --text-xl: 1.25rem;     /* 20px */
    --text-2xl: 1.5rem;     /* 24px */
    --text-3xl: 2rem;       /* 32px */

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius: 10px;
    --surface: rgba(255, 255, 255, 0.9);
    --border: rgba(26, 29, 33, 0.16);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--ink);
    background: linear-gradient(150deg, var(--bg-1) 0%, var(--bg-2) 100%);
}

a {
    color: inherit;
    text-decoration: none;
}

/* Ambient shapes (brand-aligned) */
.ambient-shape {
    position: fixed;
    border-radius: 999px;
    filter: blur(50px);
    pointer-events: none;
    z-index: -1;
    opacity: 0.35;
}

.ambient-shape-a {
    width: 300px;
    height: 300px;
    background: var(--brand-teal-light);
    left: -90px;
    top: 50px;
}

.ambient-shape-b {
    width: 340px;
    height: 340px;
    background: var(--brand-primary);
    right: -100px;
    bottom: -30px;
}

/* ==========================================================================
   Header
   ========================================================================== */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-5);
    position: sticky;
    top: 0;
    backdrop-filter: blur(14px);
    background: rgba(240, 244, 248, 0.78);
    border-bottom: 1px solid var(--line);
    z-index: 10;
}

.site-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    text-decoration: none;
}

.brand-logo {
    height: 100px;
    width: auto;
    object-fit: contain;
}

.brand-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    font-size: var(--text-xs);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: #fff;
    background: linear-gradient(120deg, var(--brand-navy), var(--brand-primary));
}

/* Navigation */
.site-nav {
    display: flex;
    gap: var(--sp-1);
    align-items: center;
}

.nav-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Direct nav links (Dashboard, Analytics, Modules, Admin) */
.nav-direct {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0.4rem var(--sp-3);
    border-radius: var(--radius-sm);
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--ink);
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.nav-direct:hover {
    background: rgba(0, 114, 188, 0.08);
    color: var(--brand-secondary);
}

/* (Mega-menu CSS removed — replaced by sidebar navigation in shared_ui) */

.link-btn {
    height: 2rem;
    border-radius: 999px;
    border: 1px solid var(--brand-primary);
    background: transparent;
    color: var(--brand-primary);
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    padding: 0 var(--sp-3);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.link-btn:hover {
    background: rgba(0, 114, 188, 0.08);
}

/* ==========================================================================
   Content Area
   ========================================================================== */
.content-wrap {
    width: min(1120px, 94vw);
    margin: var(--sp-5) auto var(--sp-8);
    display: grid;
    gap: var(--sp-5);
}

/* Hero Section */
.hero {
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    padding: var(--sp-10) var(--sp-6);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.88), rgba(240, 244, 248, 0.88));
    box-shadow: 0 8px 30px rgba(0, 51, 153, 0.07);
    animation: rise 0.5s ease-out;
}

.hero.compact {
    padding: var(--sp-4) var(--sp-5);
}

.kicker {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: var(--text-xs);
    color: var(--brand-teal);
    font-weight: 600;
}

.hero h1 {
    margin: var(--sp-2) 0;
    font-family: var(--font-heading);
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    line-height: 1.08;
    color: var(--brand-navy);
}

.lead {
    margin: 0;
    color: var(--ink-soft);
    max-width: 70ch;
}

.hero-stats {
    margin-top: var(--sp-4);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: var(--sp-3);
}

.hero-stats article {
    padding: var(--sp-3);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--line);
}

.hero-stats.single {
    max-width: 240px;
}

.stat-value {
    display: block;
    font-family: var(--font-heading);
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--brand-navy);
}

.stat-label {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-soft);
}

/* Section Heads */
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
}

.section-head h2 {
    margin: 0;
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    color: var(--brand-navy);
}

.section-head a {
    font-size: var(--text-base);
    color: var(--brand-primary);
    text-decoration: underline;
}

/* ==========================================================================
   Module Cards
   ========================================================================== */
.module-grid {
    margin-top: var(--sp-3);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--sp-3);
}

.module-card {
    display: grid;
    gap: var(--sp-2);
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow-md);
    padding: var(--sp-6);
    transition: transform 220ms var(--ease), box-shadow 220ms var(--ease);
}

.module-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--glass-shadow-lg);
}

.module-card h3,
.hub-module-card h3 {
    margin: 0;
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    font-family: var(--font-heading);
}

.module-card p {
    margin: 0;
    font-size: var(--text-base);
    color: var(--ink-soft);
}

.module-meta {
    margin-top: var(--sp-1);
    display: flex;
    justify-content: space-between;
    font-size: var(--text-sm);
}

.action {
    color: var(--brand-primary);
    font-weight: 600;
}

/* ==========================================================================
   Panels & Detail
   ========================================================================== */
.detail-panel {
    background: var(--glass-bg-heavy);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow-md);
    padding: var(--sp-6);
}

.detail-panel h2 {
    margin-top: 0;
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: var(--weight-semibold);
    color: var(--brand-navy);
}

.detail-actions {
    margin-top: var(--sp-4);
    display: flex;
    gap: var(--sp-2);
    flex-wrap: wrap;
}

.panel {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow-md);
    padding: var(--sp-6);
}

.panel + .panel {
    margin-top: var(--sp-8);
}

.panel > h2 {
    font-size: var(--text-xl);
    font-weight: var(--weight-semibold);
}

.panel h3 {
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
}

/* ==========================================================================
   Dashboard Grids & Cards
   ========================================================================== */
.content-wrap { max-width: 1200px; margin: 0 auto; padding: var(--sp-4) var(--sp-6); }

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-4);
}
.dashboard-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-4);
}
@media (max-width: 768px) {
    .dashboard-grid,
    .dashboard-grid-2 { grid-template-columns: 1fr; }
    .dashboard-grid .panel[style*="grid-column:span 2"] { grid-column: span 1 !important; }
}

.stat-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow-sm);
    padding: var(--sp-6);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.stat-value { font-size: var(--text-3xl, 2rem); font-weight: 700; line-height: 1.2; display: block; }
.stat-label { font-size: var(--text-sm); font-weight: var(--weight-medium); text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft, #5a6a7e); margin-top: var(--sp-1); }

.metric-link { color: inherit; text-decoration: none; }
.metric-link:hover { color: var(--brand-primary); text-decoration: underline; }

.progress-track {
    width: 100%; height: 8px; border-radius: 4px;
    background: var(--bg-2, #e4edf5); overflow: hidden;
}
.progress-fill {
    height: 100%; border-radius: 4px; transition: width 0.4s ease;
}
.progress-fill.success { background: var(--success, #2e7d32); }
.progress-fill.warning { background: var(--warning, #f59e0b); }
.progress-fill.danger  { background: var(--danger, #c62828); }

.pipeline-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }

.kpi-list { list-style: none; padding: 0; margin: 0; }
.kpi-list-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: var(--sp-2) 0;
    border-bottom: 1px solid var(--bg-2, #e4edf5);
}
.kpi-list-item:last-child { border-bottom: none; }

.period-change { font-size: var(--text-xs, 0.75rem); font-weight: 600; }
.period-change.period-up   { color: var(--danger, #c62828); }
.period-change.period-down { color: var(--success, #2e7d32); }
.period-change.period-flat { color: var(--ink-soft, #5a6a7e); }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 0.9rem;
    border-radius: var(--radius-md);
    background: var(--brand-primary);
    color: #fff;
    font-size: var(--text-base);
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    text-decoration: none;
}

.btn:hover {
    background: var(--brand-secondary);
    box-shadow: 0 2px 8px rgba(0, 114, 188, 0.2);
}

.btn.ghost {
    background: transparent;
    border: 1px solid var(--brand-primary);
    color: var(--brand-primary);
}

.btn.ghost:hover {
    background: rgba(0, 114, 188, 0.06);
    box-shadow: none;
}

.btn.danger {
    background: var(--danger);
}

.btn.danger:hover {
    background: #a52a17;
}

/* Small button variant for inline actions */
.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: var(--text-xs);
    border-radius: var(--radius-sm);
}
.btn-approve {
    background: var(--success);
    color: #fff;
}
.btn-approve:hover {
    background: #0a7a42;
}
.btn-reject {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
}
.btn-reject:hover {
    background: var(--danger-bg);
}
.approval-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    white-space: nowrap;
}

.empty {
    color: var(--ink-soft);
}

/* ==========================================================================
   Filters & Forms
   ========================================================================== */
.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--sp-2);
    align-items: center;
    margin-bottom: var(--sp-4);
}

.field-input {
    width: 100%;
    height: 2.35rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(26, 29, 33, 0.2);
    padding: var(--sp-2) var(--sp-3);
    font: inherit;
    font-size: var(--text-base);
    background: rgba(255, 255, 255, 0.92);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field-input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(0, 114, 188, 0.15);
}

textarea.field-input {
    height: auto;
    min-height: 6.25rem;
    resize: vertical;
    line-height: 1.45;
}

.field-check {
    width: 1.05rem;
    height: 1.05rem;
    accent-color: var(--brand-primary);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--sp-6);
}

.field-block {
    display: grid;
    gap: var(--sp-1);
}

.field-block label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--ink);
}

.field-block small {
    color: var(--ink-soft);
    font-size: var(--text-xs);
}

.field-error {
    color: var(--danger);
    font-size: var(--text-xs);
}

.field-required-marker {
    color: var(--danger);
    font-weight: 700;
    margin-left: 0.15rem;
}

.field-check-block {
    align-self: end;
}

.field-check-label {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-weight: 600;
}

.form-meta-note {
    margin: 0 0 var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-md);
    background: rgba(0, 114, 188, 0.08);
    color: var(--ink);
    font-size: var(--text-sm);
}

.capa-form,
.ncr-form,
.meeting-form,
.swot-form,
.project-form,
.tender-form,
.maintenance-request-form,
.service-request-form,
.audit-program-form,
.audit-form,
.kpi-form,
.kpi-result-form,
.perception-form,
.employee-form,
.training-record-form,
.performance-review-form,
.incident-form,
.access-request-form,
.backup-log-form,
.complaint-form,
.action-item-form,
.objective-module-form,
.provider-communication-form,
.asset-form,
.supplier-form,
.communication-record-form,
.tender-work-plan-form,
.maintenance-schedule-form,
.contract-review-form,
.supplier-evaluation-form,
.pestel-form,
.interested-party-form,
.seven-s-form,
.lessons-form,
.document-form,
.planning-objective-form,
.risk-form,
.audit-finding-form,
.generic-entity-form {
    display: grid;
    gap: var(--sp-4);
}

.form-section {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: var(--sp-3);
    margin: 0;
    margin-bottom: var(--sp-8);
    background: rgba(255, 255, 255, 0.9);
}

.form-section legend {
    font-family: var(--font-heading);
    color: var(--brand-navy);
    font-size: var(--text-xl);
    font-weight: var(--weight-semibold);
    padding: 0 var(--sp-1);
    margin-left: var(--sp-1);
}

.form-section-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.4rem;
    height: 1.4rem;
    margin-right: 0.4rem;
    border-radius: 999px;
    background: rgba(0, 51, 153, 0.14);
    color: var(--brand-navy);
    font-size: var(--text-xs);
}

.form-section-note {
    margin: 0 0 var(--sp-3);
    color: var(--ink-soft);
    font-size: var(--text-sm);
}

/* Progressive disclosure toggle */
.form-toggle-advanced {
    margin: var(--sp-3) 0;
    text-align: center;
    border-top: 1px dashed var(--line);
    padding-top: var(--sp-3);
}

.inline-formset-list {
    display: grid;
    gap: var(--sp-3);
}

.inline-formset-row {
    border: 1px solid rgba(0, 51, 153, 0.16);
    border-radius: var(--radius-md);
    padding: var(--sp-3);
    background: rgba(255, 255, 255, 0.92);
}

.inline-formset-row-title {
    margin: 0 0 var(--sp-2);
    font-family: var(--font-heading);
    font-size: var(--text-sm);
    color: var(--brand-navy);
}

.inline-formset-add {
    margin-top: var(--sp-2);
}

.span-2 {
    grid-column: span 2;
}

.readonly-chip {
    display: inline-flex;
    align-items: center;
    min-height: 2.35rem;
    padding: 0.35rem 0.8rem;
    border: 1px solid rgba(0, 51, 153, 0.2);
    border-radius: var(--radius-md);
    background: rgba(0, 51, 153, 0.05);
    color: var(--brand-navy);
    font-weight: 600;
}

.capa-closure-checklist {
    border: 1px solid rgba(0, 114, 188, 0.2);
    border-radius: var(--radius-md);
    background: rgba(0, 114, 188, 0.04);
    padding: var(--sp-3);
}

.capa-closure-checklist h2 {
    margin-top: 0;
    margin-bottom: var(--sp-2);
    color: var(--brand-navy);
    font-size: var(--text-base);
}

.capa-closure-checklist ul {
    margin: 0;
    padding-left: 1.2rem;
    display: grid;
    gap: 0.35rem;
}

.form-errors {
    grid-column: 1 / -1;
    padding: var(--sp-3);
    border-radius: var(--radius-md);
    border: 1px solid var(--danger-border);
    color: var(--danger);
    background: var(--danger-bg);
}

.form-errors ul {
    margin: 0;
    padding-left: 1.2rem;
}

.mention-autocomplete {
    position: absolute;
    z-index: 1200;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #fff;
    box-shadow: 0 14px 30px rgba(0, 38, 115, 0.16);
    overflow: hidden;
}

.mention-autocomplete-list {
    margin: 0;
    padding: 0;
    list-style: none;
    max-height: 260px;
    overflow-y: auto;
}

.mention-option {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    padding: 0.6rem 0.75rem;
    display: grid;
    grid-template-columns: 1.1fr 2fr auto;
    gap: 0.6rem;
    align-items: center;
    cursor: pointer;
}

.mention-option:hover,
.mention-option.active {
    background: rgba(0, 114, 188, 0.08);
}

.mention-code {
    font-family: var(--font-heading);
    color: var(--brand-navy);
    font-size: var(--text-sm);
    font-weight: 700;
}

.mention-title {
    color: var(--ink);
    font-size: var(--text-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mention-kind {
    color: var(--ink-soft);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border: 1px solid rgba(0, 51, 153, 0.2);
    border-radius: 999px;
    padding: 0.15rem 0.45rem;
}

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 680px;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: var(--sp-3) var(--sp-2);
    border-bottom: 1px solid var(--line);
    font-size: var(--text-base);
}

.data-table th {
    color: var(--ink-soft);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.data-table tbody tr:hover {
    background: rgba(0, 114, 188, 0.03);
}

.inline-link {
    color: var(--brand-primary);
    text-decoration: underline;
    font-weight: 500;
}

.inline-link:hover {
    color: var(--brand-secondary);
}

/* ==========================================================================
   DOCX Preview Hierarchy
   ========================================================================== */
.doc-preview {
    display: grid;
    gap: var(--sp-2);
}

.doc-preview-title {
    margin: var(--sp-2) 0 var(--sp-1);
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--brand-navy);
    line-height: 1.3;
}

.doc-preview-subtitle {
    margin: 0 0 var(--sp-2);
    font-size: var(--text-md);
    color: var(--ink-soft);
    font-weight: 600;
}

.doc-preview-section {
    margin: var(--sp-3) 0 var(--sp-1);
    font-size: var(--text-lg);
    color: var(--brand-navy);
    font-weight: 700;
    border-bottom: 1px solid rgba(0, 51, 153, 0.18);
    padding-bottom: var(--sp-1);
}

.doc-preview-subsection {
    margin: var(--sp-2) 0 var(--sp-1);
    font-size: var(--text-md);
    font-weight: 700;
    color: var(--brand-secondary);
}

.doc-preview-clause-heading {
    margin: var(--sp-2) 0 var(--sp-1);
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--brand-navy);
}

.doc-preview-body {
    margin: 0;
    font-size: var(--text-base);
    line-height: 1.65;
    color: var(--ink);
}

.doc-preview-list-item {
    margin: 0;
    padding-left: var(--sp-4);
    position: relative;
    line-height: 1.6;
    color: var(--ink);
}

.doc-preview-list-item::before {
    content: "\2022";
    position: absolute;
    left: 0;
    top: 0;
    color: var(--brand-primary);
}

.doc-preview-table-block {
    display: grid;
    gap: var(--sp-1);
    margin: var(--sp-2) 0;
}

.doc-table-title {
    margin: 0;
    font-family: var(--font-heading);
    font-size: var(--text-sm);
    color: var(--brand-navy);
    font-weight: 700;
    letter-spacing: 0.01em;
}

.doc-preview-table-wrap {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.95);
}

.doc-preview-table td {
    vertical-align: top;
    line-height: 1.55;
}

/* Detail hero */
.detail-hero {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.92), var(--bg-2));
}

/* Section divider (from DOCX 1x1 tables) */
.doc-section-divider {
    margin: var(--sp-4) 0 var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    background: linear-gradient(135deg, var(--brand-navy), var(--brand-secondary));
    color: #fff;
    border-radius: var(--radius-md);
}
.doc-section-divider h4 {
    margin: 0;
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    font-weight: 700;
    color: inherit;
    letter-spacing: 0.02em;
}
.doc-section-divider a { color: #fff; text-decoration: underline; }
.doc-section-divider[data-collapsible] {
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}
.doc-section-toggle {
    display: inline-block;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-left: var(--sp-2);
    transition: transform 0.25s ease;
}
.doc-section-toggle::before {
    content: '';
    display: block;
    width: 10px;
    height: 10px;
    margin: 4px auto;
    border-right: 2.5px solid #fff;
    border-bottom: 2.5px solid #fff;
    transform: rotate(45deg);
    transition: transform 0.25s ease;
}
.doc-section-divider.collapsed .doc-section-toggle::before {
    transform: rotate(-45deg);
}
.doc-section-body {
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.doc-section-body.collapsed {
    max-height: 0 !important;
}

/* TOC actions (expand/collapse all) */
.doc-toc-actions {
    display: flex;
    gap: var(--sp-2);
    margin-bottom: var(--sp-2);
}
.btn-link {
    background: none;
    border: none;
    color: var(--brand-primary);
    cursor: pointer;
    font-size: var(--text-sm);
    padding: 0;
    text-decoration: underline;
}
.btn-link:hover { color: var(--brand-navy); }

/* Table header styling */
.doc-preview-table th {
    background: var(--bg-2);
    font-weight: 700;
    font-size: var(--text-sm);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--brand-navy);
    border-bottom: 2px solid var(--brand-primary);
    padding: var(--sp-2) var(--sp-3);
    text-align: left;
    vertical-align: top;
}

/* Semantic list styling */
.doc-preview-list {
    margin: var(--sp-1) 0;
    padding-left: var(--sp-6);
    list-style: disc;
    color: var(--ink);
    line-height: 1.65;
}
.doc-preview-list li {
    margin-bottom: var(--sp-1);
}
.doc-preview-list li::marker {
    color: var(--brand-primary);
}

/* Table of contents */
.doc-toc {
    margin: var(--sp-2) 0 var(--sp-4);
    padding: var(--sp-4);
    background: var(--neutral-50);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}
.doc-toc-title {
    margin: 0 0 var(--sp-2);
    font-weight: 700;
    font-size: var(--text-md);
    color: var(--brand-navy);
}
.doc-toc-list {
    margin: 0;
    padding-left: var(--sp-6);
}
.doc-toc-list li {
    margin-bottom: var(--sp-1);
}
.doc-toc-list a {
    color: var(--brand-primary);
    text-decoration: none;
}
.doc-toc-list a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   KV Grid (Detail pages)
   ========================================================================== */
.kv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--sp-2);
}

.kv-grid strong {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Tabular numbers for data values */
.stat-value,
.count-value,
.data-table td {
    font-feature-settings: var(--font-tabular);
}

/* ==========================================================================
   Pagination
   ========================================================================== */
.pager {
    margin-top: var(--sp-4);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
}

.pager-actions {
    display: flex;
    gap: var(--sp-2);
}

/* ==========================================================================
   Mini List
   ========================================================================== */
.mini-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: var(--sp-2);
}

.mini-list li {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.72);
    padding: var(--sp-3);
    display: grid;
    gap: var(--sp-1);
}

/* History Diff (field-level changes) */
.history-diff-list {
    margin: var(--sp-2) 0 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 2px;
}
.history-diff-item {
    font-size: var(--text-xs);
    color: var(--ink-soft);
    display: flex;
    align-items: baseline;
    gap: var(--sp-1);
    flex-wrap: wrap;
}
.diff-field {
    font-weight: 600;
    color: var(--ink);
}
.diff-old {
    text-decoration: line-through;
    color: var(--danger);
    background: var(--danger-bg);
    padding: 0 3px;
    border-radius: 3px;
}
.diff-arrow {
    color: var(--ink-soft);
    font-size: var(--text-xs);
}
.diff-new {
    color: var(--success);
    background: var(--success-bg);
    padding: 0 3px;
    border-radius: 3px;
}

/* ==========================================================================
   Messages
   ========================================================================== */
.message-stack {
    display: grid;
    gap: var(--sp-2);
}

.message {
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.88);
    font-size: var(--text-base);
}

.message.success {
    border-color: var(--success-border);
    background: var(--success-bg);
    color: var(--success);
}

.message.error {
    border-color: var(--danger-border);
    background: var(--danger-bg);
    color: var(--danger);
}

.message.warning {
    border-color: var(--warning-border);
    background: var(--warning-bg);
    color: var(--warning);
}

.message.info {
    border-color: var(--info-border);
    background: var(--info-bg);
    color: var(--info);
}

/* ==========================================================================
   Status Badges
   ========================================================================== */
.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 600;
    background: var(--line);
}

.badge-alert {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger-border);
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid var(--info-border);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid var(--warning-border);
}

/* Status Badge System */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1.6;
  white-space: nowrap;
  vertical-align: middle;
}

.status-badge--draft,
.status-draft { background: #f1f5f9; color: #475569; }
.status-badge--open,
.status-open { background: #eff6ff; color: #1d4ed8; }
.status-badge--open::before,
.status-open::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #0072BC; }
.status-badge--in-review,
.status-badge--under-review,
.status-badge--pending,
.status-in-review { background: #fffbeb; color: #92400e; }
.status-badge--in-review::before,
.status-badge--under-review::before,
.status-badge--pending::before,
.status-in-review::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #f59e0b; }
.status-badge--approved,
.status-approved { background: #f0fdf4; color: #15803d; }
.status-badge--approved::before,
.status-approved::before { content: '\2713'; font-size: 10px; }
.status-badge--published,
.status-published { background: #dcfce7; color: #166534; }
.status-badge--published::before,
.status-published::before { content: '\2713\2713'; font-size: 9px; letter-spacing: -2px; }
.status-badge--rejected,
.status-rejected { background: #fef2f2; color: #b91c1c; }
.status-badge--rejected::before,
.status-rejected::before { content: '\2715'; font-size: 10px; }
.status-badge--closed,
.status-closed { background: #f1f5f9; color: #64748b; }
.status-badge--obsolete,
.status-obsolete { background: #fee2e2; color: #991b1b; text-decoration: line-through; }
.status-badge--overdue,
.status-overdue {
  background: #ef4444; color: #fff;
  animation: pulse-overdue 2s ease-in-out infinite;
}
.status-badge--overdue::before,
.status-overdue::before { content: '!'; font-weight: 700; }

.tag {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 500;
    background: #e9eef4;
    color: var(--ink-soft);
}

/* ==========================================================================
   Dashboard Panels
   ========================================================================== */
.stat-alert {
    color: var(--danger);
}

.alert-panel {
    border-color: var(--danger-border);
    background: var(--danger-bg);
}

.action-panel {
    border-color: var(--info-border);
    background: var(--info-bg);
}

/* Urgency badges for "Needs Your Action" */
.urgency-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 600;
    white-space: nowrap;
}
.urgency-overdue {
    background: var(--danger);
    color: #fff;
}
.urgency-approval {
    background: var(--brand-primary);
    color: #fff;
}
.urgency-due-soon {
    background: var(--warning);
    color: #fff;
}

.overdue-days {
    color: var(--danger);
    font-weight: 600;
}

.row-overdue {
    background: #fef8f8;
}

.docs-review-panel {
    border-color: var(--warning-border);
    background: var(--warning-bg);
}

.dist-title {
    margin: 0 0 var(--sp-2);
    font-size: var(--text-md);
    font-family: var(--font-heading);
    color: var(--brand-navy);
}

.dist-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: var(--sp-1);
}

.dist-list li {
    display: flex;
    justify-content: space-between;
    padding: var(--sp-2) 0;
    border-bottom: 1px solid var(--line);
    font-size: var(--text-base);
}

.dist-list li:last-child {
    border-bottom: none;
}

.dist-count {
    font-weight: 700;
    font-family: var(--font-heading);
    color: var(--brand-navy);
}

/* ==========================================================================
   Accent Colors for Module Cards
   ========================================================================== */
.accent-amber { border-top: 4px solid #d18a1f; }
.accent-teal { border-top: 4px solid var(--brand-teal); }
.accent-copper { border-top: 4px solid #9a5d39; }
.accent-coral { border-top: 4px solid #e05a4d; }
.accent-indigo { border-top: 4px solid var(--brand-primary); }
.accent-mint { border-top: 4px solid var(--brand-teal-light); }
.accent-sun { border-top: 4px solid #d4960e; }
.accent-violet { border-top: 4px solid #6b5abf; }
.accent-steel { border-top: 4px solid #567282; }
.accent-rose { border-top: 4px solid #c0537a; }
.accent-ocean { border-top: 4px solid var(--brand-secondary); }
.accent-lime { border-top: 4px solid #6a9a2e; }
.accent-ink { border-top: 4px solid var(--brand-navy); }
.accent-sand { border-top: 4px solid #9e7b53; }
.accent-plum { border-top: 4px solid #7c52a0; }

/* ==========================================================================
   Global Search
   ========================================================================== */
.global-search-form {
    display: flex;
    align-items: center;
    gap: 0;
    margin-right: var(--sp-2);
}
.global-search-input {
    width: 11rem;
    height: 2rem;
    padding: 0 var(--sp-2);
    border: 1px solid rgba(0, 114, 188, 0.18);
    border-right: none;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    background: rgba(255, 255, 255, 0.7);
    font-size: var(--text-sm);
    font-family: inherit;
    color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.global-search-input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px rgba(0, 114, 188, 0.12);
    width: 16rem;
}
.global-search-input::placeholder { color: var(--muted); }
.global-search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 2rem;
    width: 2rem;
    border: 1px solid rgba(0, 114, 188, 0.18);
    border-left: none;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    background: rgba(0, 114, 188, 0.06);
    color: var(--brand-primary);
    cursor: pointer;
    transition: background 0.15s;
}
.global-search-btn:hover { background: rgba(0, 114, 188, 0.14); }

/* Instant search dropdown */
.instant-search-dropdown:empty { display: none; }
.instant-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: #fff;
    border: 1px solid var(--bg-2, #e4edf5);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 200;
    max-height: 400px;
    overflow-y: auto;
    min-width: 320px;
}
.instant-search-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.instant-search-item a {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    text-decoration: none;
    color: var(--ink);
    font-size: var(--text-sm);
    transition: background 0.1s;
}
.instant-search-item a:hover {
    background: var(--bg-1);
}
.search-item-code {
    font-weight: 600;
    color: var(--brand-primary);
    min-width: 60px;
}
.search-item-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.search-summary,
.search-empty,
.search-more {
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--text-xs);
    color: var(--ink-soft);
    margin: 0;
}
.search-more a {
    color: var(--brand-primary);
    font-weight: 600;
}

/* Search results page */
.search-page-form {
    display: flex;
    gap: var(--sp-3);
    margin-bottom: var(--sp-6);
    max-width: 36rem;
}
.search-page-input {
    flex: 1;
    height: 2.5rem;
    padding: 0 var(--sp-3);
    border: 1px solid rgba(0, 114, 188, 0.18);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-family: inherit;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.7);
}
.search-page-input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px rgba(0, 114, 188, 0.12);
}
.search-summary {
    margin-bottom: var(--sp-4);
    font-size: var(--text-sm);
    color: var(--muted);
}
.search-note {
    margin-top: var(--sp-3);
    font-size: var(--text-sm);
    color: var(--muted);
    font-style: italic;
}
.badge--module {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    background: rgba(0, 114, 188, 0.08);
    color: var(--brand-primary);
    font-size: var(--text-xs);
    font-weight: 600;
    white-space: nowrap;
}

/* ==========================================================================
   Notifications
   ========================================================================== */
.notification-bell {
    position: relative;
    font-size: var(--text-base);
    color: var(--ink);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s;
}

.notification-bell:hover {
    color: var(--brand-primary);
}

.notification-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.2rem;
    height: 1.2rem;
    padding: 0 0.3rem;
    border-radius: 50%;
    background: var(--danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: 0.2rem;
    vertical-align: super;
}

.notification-unread {
    border-color: var(--brand-primary);
    background: var(--info-bg);
}

.notification-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--sp-3);
}

.notification-message {
    margin: var(--sp-1) 0 0;
    font-size: var(--text-base);
    color: var(--ink-soft);
}

.notification-time {
    font-size: var(--text-xs);
    color: var(--ink-soft);
}

.notification-actions {
    flex-shrink: 0;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   Breadcrumbs
   ========================================================================== */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--text-sm);
    color: var(--ink-soft);
    flex-wrap: wrap;
}

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

.breadcrumbs a:hover {
    color: var(--brand-secondary);
    text-decoration: underline;
}

.breadcrumb-sep {
    color: var(--ink-soft);
    opacity: 0.5;
    user-select: none;
}

.breadcrumb-current {
    color: var(--ink);
    font-weight: 600;
}

/* ==========================================================================
   Skip Navigation (Accessibility)
   ========================================================================== */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--brand-navy);
    color: #fff;
    padding: var(--sp-2) var(--sp-4);
    z-index: 100;
    font-size: var(--text-base);
    font-weight: 600;
    border-radius: 0 0 var(--radius-md) 0;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 0;
}

/* ==========================================================================
   Hamburger Menu (Mobile)
   ========================================================================== */
.menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: var(--sp-2);
    cursor: pointer;
    color: var(--ink);
    font: inherit;
    font-size: var(--text-base);
    font-weight: 600;
    align-items: center;
    gap: var(--sp-2);
}

.menu-toggle-bar {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--ink);
    border-radius: 1px;
}

.menu-toggle-bar + .menu-toggle-bar {
    margin-top: 4px;
}

/* ==========================================================================
   Focus States (Accessibility)
   ========================================================================== */
.btn:focus-visible,
.link-btn:focus-visible,
.nav-direct:focus-visible,
.inline-link:focus-visible,
.notification-bell:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

/* ==========================================================================
   Danger Button
   ========================================================================== */
.btn.danger {
    background: var(--danger);
    color: #fff;
    border: 1px solid var(--danger-border);
}

.btn.danger:hover {
    background: #a02a18;
}

/* ==========================================================================
   Active Filters
   ========================================================================== */
.active-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-3) 0;
    border-bottom: 1px solid var(--line);
}

.filter-label {
    font-size: var(--text-sm);
    color: var(--ink-soft);
    font-weight: 500;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: var(--sp-1) var(--sp-3);
    background: var(--info-bg);
    border: 1px solid var(--info-border);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    color: var(--brand-secondary);
}

.filter-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--brand-primary);
    color: #fff;
    font-size: 12px;
    line-height: 1;
    text-decoration: none;
    font-weight: 700;
}

.filter-remove:hover {
    background: var(--danger);
}

/* ==========================================================================
   List Meta & Result Count
   ========================================================================== */
.list-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-2) 0;
}

.result-count {
    font-size: var(--text-sm);
    color: var(--ink-soft);
    font-weight: 500;
}

/* ==========================================================================
   Filters Row Enhancement
   ========================================================================== */
.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
}

.filters select.field-input {
    max-width: 200px;
}

/* ==========================================================================
   Delete Confirmation Card
   ========================================================================== */
.confirm-delete-card {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    border-radius: var(--radius-md);
    padding: var(--sp-6);
}

.confirm-delete-card h2 {
    color: var(--danger);
    margin-bottom: var(--sp-4);
}

.confirm-delete-actions {
    display: flex;
    gap: var(--sp-3);
    margin-top: var(--sp-6);
}

/* ==========================================================================
   Confirm Modal Overlay
   ========================================================================== */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirm-dialog {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: var(--sp-8);
    max-width: 440px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.confirm-dialog h3 {
    margin-bottom: var(--sp-2);
    font-size: var(--text-lg);
}

.confirm-dialog p {
    margin-bottom: var(--sp-6);
    color: var(--ink-soft);
}

.confirm-actions {
    display: flex;
    gap: var(--sp-3);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
    text-align: center;
    padding: var(--sp-8) var(--sp-4);
    margin-top: var(--sp-8);
    border-top: 1px solid var(--line);
    color: var(--ink-soft);
    font-size: var(--text-sm);
}

/* Accent for danger hero */
.accent-danger {
    --accent: var(--danger);
}

.hero.accent-danger {
    background: var(--danger-bg);
    border-bottom: 2px solid var(--danger-border);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 760px) {
    .menu-toggle {
        display: inline-flex;
    }

    .site-header {
        flex-wrap: wrap;
        gap: var(--sp-2);
    }

    .site-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .site-nav {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 0;
        padding: var(--sp-2) 0;
        border-top: 1px solid var(--line);
    }

    .site-nav.open {
        display: flex;
    }

    /* Direct nav links on mobile */
    .nav-direct {
        padding: var(--sp-3);
        min-height: 44px;
        border-radius: 0;
        border-bottom: 1px solid rgba(0,0,0,0.04);
    }

    .global-search-form { order: 10; width: 100%; margin: var(--sp-2) 0 0; }
    .global-search-input { flex: 1; width: auto; }

    .hero {
        padding: var(--sp-4);
    }

    .content-wrap {
        margin-top: var(--sp-3);
    }

    .detail-actions {
        flex-direction: column;
    }

    .detail-actions .btn {
        text-align: center;
        min-height: 44px;
    }

    .span-2 {
        grid-column: 1 / -1;
    }

    .breadcrumbs {
        font-size: var(--text-xs);
    }

    /* Table responsiveness improvements */
    .data-table {
        min-width: 0;
    }

    .data-table th,
    .data-table td {
        padding: var(--sp-2) var(--sp-1);
        font-size: var(--text-sm);
    }
}

/* ==========================================================================
   Analytics & Charts (Phase E)
   ========================================================================== */

/* Chart containers */
.chart-container {
    position: relative;
    width: 100%;
    max-height: 400px;
    padding: var(--sp-4) 0;
}

.chart-container.chart-sm {
    max-height: 280px;
}

.chart-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--sp-4);
}

.chart-panel {
    text-align: center;
}

.chart-panel h3 {
    font-size: var(--text-base);
    margin-bottom: var(--sp-2);
}

/* Risk Heat Map */
.heat-map-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--sp-4) 0;
    gap: var(--sp-2);
}

.heat-map-y-label,
.heat-map-x-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--neutral-600);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.heat-map-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 3px;
    width: 100%;
    max-width: 400px;
}

.heat-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
    font-weight: 700;
    border-radius: var(--radius-sm);
    background: var(--neutral-100);
    color: var(--neutral-400);
    min-width: 48px;
    min-height: 48px;
}

.heat-cell.heat-low {
    background: #d1fae5;
    color: #065f46;
}

.heat-cell.heat-med {
    background: #fef3c7;
    color: #92400e;
}

.heat-cell.heat-high {
    background: #fee2e2;
    color: #991b1b;
}

/* KPI metric cards */
.kpi-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--sp-3);
    padding: var(--sp-3) 0;
}

.kpi-card {
    text-align: center;
    padding: var(--sp-3);
    background: var(--neutral-50);
    border-radius: var(--radius-md);
    border: 1px solid var(--neutral-200);
}

.kpi-card.accent-green {
    border-color: var(--success);
    background: var(--success-bg);
}

.kpi-card.accent-amber {
    border-color: var(--warning);
    background: var(--warning-bg);
}

.kpi-card.accent-coral {
    border-color: var(--danger);
    background: var(--danger-bg);
}

.kpi-card.accent-teal {
    border-color: var(--brand-teal);
    background: rgba(79, 168, 159, 0.08);
}

.kpi-card.accent-indigo {
    border-color: var(--brand-primary);
    background: rgba(0, 114, 188, 0.06);
}

.kpi-value {
    display: block;
    font-family: var(--font-heading);
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--neutral-900);
}

.kpi-label {
    display: block;
    font-size: var(--text-xs);
    color: var(--neutral-500);
    margin-top: var(--sp-1);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Comprehensive Analytics Dashboard ── */
.analytics-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    background: var(--neutral-50);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-md);
    margin-bottom: var(--sp-4);
}

.analytics-filter-group {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
}

.analytics-filter-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--neutral-600);
    white-space: nowrap;
}

.analytics-filter-preset {
    padding: var(--sp-1) var(--sp-3);
    font-size: var(--text-sm);
    font-weight: 500;
    border: 1px solid var(--neutral-300);
    border-radius: 9999px;
    background: var(--white);
    color: var(--neutral-600);
    cursor: pointer;
    transition: all 0.15s ease;
}

.analytics-filter-preset:hover {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

.analytics-filter-preset.active {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: var(--white);
}

.analytics-filter-select {
    padding: var(--sp-1) var(--sp-3);
    font-size: var(--text-sm);
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--neutral-700);
    min-width: 160px;
}

.analytics-tabs {
    display: flex;
    gap: var(--sp-1);
    border-bottom: 2px solid var(--neutral-200);
    margin-bottom: var(--sp-4);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

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

.analytics-tab {
    padding: var(--sp-2) var(--sp-4);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--neutral-500);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.analytics-tab:hover {
    color: var(--brand-primary);
}

.analytics-tab.active {
    color: var(--brand-primary);
    border-bottom-color: var(--brand-primary);
}

.analytics-tab-content {
    min-height: 200px;
}

.analytics-tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--sp-4);
}

.analytics-tab-header h2 {
    font-size: var(--text-xl);
    font-weight: 700;
    margin: 0;
}

.tab-export-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: var(--sp-1) var(--sp-3);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--brand-primary);
    border: 1px solid var(--brand-primary);
    border-radius: var(--radius-sm);
    background: var(--white);
    text-decoration: none;
    transition: all 0.15s ease;
}

.tab-export-btn:hover {
    background: var(--brand-primary);
    color: var(--white);
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--neutral-200);
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

@media (max-width: 768px) {
    .analytics-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .analytics-tabs {
        gap: 0;
    }
    .analytics-tab {
        padding: var(--sp-2) var(--sp-3);
        font-size: var(--text-xs);
    }
}

/* ── Phase F: Activity feed ── */
.activity-feed {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.activity-entry {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-2) 0;
    border-bottom: 1px solid var(--neutral-100);
}

.activity-entry:last-child {
    border-bottom: none;
}

.activity-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-sm);
    background: var(--neutral-100);
    color: var(--neutral-600);
}

.activity-body {
    font-size: var(--text-sm);
    line-height: 1.5;
}

.activity-action {
    color: var(--neutral-500);
}

.activity-model {
    font-weight: 600;
    color: var(--brand-primary);
}

.activity-id {
    color: var(--neutral-400);
    font-size: var(--text-xs);
}

.activity-time {
    display: block;
    font-size: var(--text-xs);
    color: var(--neutral-400);
    margin-top: 2px;
}

/* ── Phase F: Comments ── */
.comments-panel {
    margin-top: var(--sp-4);
}

.comment-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
}

.comment-item {
    padding: var(--sp-3);
    background: var(--neutral-50);
    border-radius: var(--radius-md);
    border: 1px solid var(--neutral-100);
}

.comment-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--sp-1);
    font-size: var(--text-sm);
}

.comment-meta time {
    color: var(--neutral-400);
    font-size: var(--text-xs);
}

.comment-body {
    font-size: var(--text-sm);
    line-height: 1.6;
    color: var(--neutral-700);
}

.comment-form {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    margin-top: var(--sp-3);
}

.comment-form textarea {
    resize: vertical;
    min-height: 72px;
}

/* ── Phase F: Profile page ── */
.profile-section {
    margin-bottom: var(--sp-4);
}

.role-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    margin-top: var(--sp-2);
}

/* ── Phase F: Approval queue ── */
.approval-actions {
    display: flex;
    gap: var(--sp-2);
    flex-wrap: wrap;
}

/* ── Strategic Analysis: Shared Reference Blocks ── */
.strategy-mini-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    margin-bottom: var(--sp-3);
}

.strategy-mini-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    border: 1px solid rgba(0, 51, 153, 0.2);
    background: rgba(0, 51, 153, 0.08);
    color: var(--brand-navy);
    font-size: var(--text-xs);
    font-weight: 700;
}

.strategy-framework {
    border: 1px solid rgba(0, 51, 153, 0.18);
    border-radius: var(--radius-md);
    background: linear-gradient(145deg, rgba(240, 246, 255, 0.78), rgba(255, 255, 255, 0.95));
    padding: var(--sp-3);
    display: grid;
    gap: var(--sp-2);
}

.framework-title {
    margin: 0;
    font-family: var(--font-heading);
    font-size: var(--text-md);
    color: var(--brand-navy);
}

.framework-note {
    margin: 0;
    color: var(--ink-soft);
    font-size: var(--text-sm);
}

.framework-grid {
    display: grid;
    gap: var(--sp-2);
}

.framework-grid-6 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 860px) {
    .framework-grid-6 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .framework-grid-6 {
        grid-template-columns: 1fr;
    }
}

.framework-pill {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.9);
    padding: var(--sp-2);
    display: grid;
    gap: var(--sp-1);
}

.framework-abbr {
    display: inline-flex;
    width: 1.55rem;
    height: 1.55rem;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-family: var(--font-heading);
    font-size: var(--text-xs);
    font-weight: 700;
    border: 1px solid currentColor;
}

.framework-pill h3 {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--ink);
}

.framework-pill p {
    margin: 0;
    color: var(--ink-soft);
    font-size: var(--text-xs);
    line-height: 1.45;
}

.framework-checklist {
    margin-top: var(--sp-1);
    border-top: 1px dashed rgba(0, 51, 153, 0.18);
    padding-top: var(--sp-2);
}

.framework-checklist h3 {
    margin: 0 0 var(--sp-1);
    font-size: var(--text-sm);
    color: var(--brand-navy);
}

.framework-checklist ul {
    margin: 0;
    padding-left: 1.1rem;
    display: grid;
    gap: 0.2rem;
    color: var(--ink-soft);
    font-size: var(--text-xs);
}

.framework-pill.political { color: #1e3a5f; }
.framework-pill.economic { color: #166534; }
.framework-pill.social { color: #c2410c; }
.framework-pill.technological { color: #1d4ed8; }
.framework-pill.environmental { color: #0f766e; }
.framework-pill.legal { color: #6d28d9; }

.seven-s-guide-groups {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-2);
}

@media (max-width: 700px) {
    .seven-s-guide-groups {
        grid-template-columns: 1fr;
    }
}

.seven-s-guide-group {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.93);
    padding: var(--sp-2);
}

.seven-s-guide-group h3 {
    margin: 0 0 var(--sp-1);
    font-size: var(--text-sm);
}

.seven-s-guide-group ul {
    margin: 0;
    padding-left: 1rem;
    display: grid;
    gap: 0.2rem;
    color: var(--ink-soft);
    font-size: var(--text-xs);
}

.seven-s-guide-group.hard h3 { color: #1d4ed8; }
.seven-s-guide-group.soft h3 { color: #0f766e; }

/* ── Strategic Analysis: PESTEL Grid ── */
.pestel-legend-strip {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: var(--sp-2);
    margin-bottom: var(--sp-3);
}

@media (max-width: 960px) {
    .pestel-legend-strip {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .pestel-legend-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.pestel-legend-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    border-radius: var(--radius-sm);
    border: 1px solid currentColor;
    background: rgba(255, 255, 255, 0.86);
    padding: 0.3rem 0.45rem;
    font-size: var(--text-xs);
    font-weight: 700;
}

.pestel-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: var(--sp-3);
}

@media (max-width: 960px) { .pestel-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 600px) { .pestel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.pestel-column {
    border-radius: var(--radius);
    padding: var(--sp-3);
    background: var(--surface);
    border: 1px solid var(--line);
}

.pestel-column-title {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--text-sm);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0;
    padding-bottom: var(--sp-1);
    border-bottom: 3px solid currentColor;
}

.pestel-abbr {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.45rem;
    height: 1.45rem;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-size: var(--text-xs);
    font-weight: 700;
}

.pestel-column-note {
    margin: var(--sp-1) 0 var(--sp-2);
    color: var(--ink-soft);
    font-size: var(--text-xs);
    line-height: 1.45;
}

.pestel-political,
.pestel-legend-chip.political { color: #1e3a5f; }
.pestel-economic,
.pestel-legend-chip.economic { color: #166534; }
.pestel-social,
.pestel-legend-chip.social { color: #c2410c; }
.pestel-technological,
.pestel-legend-chip.technological { color: #1d4ed8; }
.pestel-environmental,
.pestel-legend-chip.environmental { color: #0f766e; }
.pestel-legal,
.pestel-legend-chip.legal { color: #6d28d9; }

.pestel-card {
    background: #fff;
    border-radius: var(--radius);
    padding: var(--sp-2);
    margin-bottom: var(--sp-2);
    border: 1px solid var(--border);
}

.pestel-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1);
    margin-top: var(--sp-1);
    font-size: 0.8rem;
    color: var(--ink-soft);
    align-items: center;
}

.pestel-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1);
    margin-top: var(--sp-1);
    font-size: 0.8rem;
    align-items: center;
}

.pestel-trend {
    display: inline-flex;
    align-items: center;
    gap: 0.2em;
    font-weight: 600;
    font-size: 0.8rem;
}

.pestel-trend-increasing { color: #dc2626; }
.pestel-trend-decreasing { color: #16a34a; }
.pestel-trend-stable     { color: #6b7280; }
.pestel-trend-uncertain  { color: #d97706; }

/* ── Strategic Analysis: McKinsey 7S Hub ── */
.seven-s-legend-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--sp-2);
    margin-bottom: var(--sp-3);
}

@media (max-width: 960px) {
    .seven-s-legend-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .seven-s-legend-strip {
        grid-template-columns: 1fr;
    }
}

.seven-s-legend-chip {
    border: 1px solid currentColor;
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.45rem;
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    background: rgba(255, 255, 255, 0.9);
    font-size: var(--text-xs);
    font-weight: 700;
}

.seven-s-legend-chip.hard { color: #1d4ed8; }
.seven-s-legend-chip.soft { color: #0f766e; }
.seven-s-legend-chip.core { color: #0e7490; }

.seven-s-hub {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-4);
}

.seven-s-center {
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    border: 2px solid #7dd3fc;
    border-radius: 50%;
    width: 220px;
    height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--sp-3);
}

.seven-s-center h3 {
    font-size: 1rem;
    margin-bottom: var(--sp-1);
    color: #0c4a6e;
}

.seven-s-ring {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-3);
    width: 100%;
}

@media (max-width: 760px) {
    .seven-s-ring {
        grid-template-columns: 1fr;
    }
}

.seven-s-group h4 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--sp-2);
}

.seven-s-element-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: var(--sp-3);
    margin-bottom: var(--sp-2);
    border: 1px solid var(--line);
    border-left: 4px solid transparent;
}

.seven-s-element-card.hard { border-left-color: #0072BC; }
.seven-s-element-card.soft { border-left-color: #14b8a6; }

.seven-s-element-card h5 {
    margin: 0 0 var(--sp-1);
}

.seven-s-element-tag {
    margin: 0 0 var(--sp-1);
    font-size: var(--text-xs);
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Progress bars for alignment */
.progress-track {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    margin-top: var(--sp-1);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ef4444, #f59e0b, #22c55e);
    border-radius: 4px;
    transition: width 0.4s ease;
}

/* ── Strategic Analysis: SWOT Quadrant Grid ── */
.swot-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-3);
}
@media (max-width: 600px) { .swot-grid { grid-template-columns: 1fr; } }

.swot-cell {
    border-radius: var(--radius);
    padding: var(--sp-3);
    min-height: 160px;
}
.swot-cell h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--sp-2);
}
.swot-strength    { background: #f0fdf4; border: 1px solid #86efac; }
.swot-strength h3 { color: #166534; }
.swot-weakness    { background: #fef2f2; border: 1px solid #fca5a5; }
.swot-weakness h3 { color: #991b1b; }
.swot-opportunity { background: #eff6ff; border: 1px solid #93c5fd; }
.swot-opportunity h3 { color: #1e40af; }
.swot-threat      { background: #fffbeb; border: 1px solid #fcd34d; }
.swot-threat h3   { color: #92400e; }

.swot-item-card {
    background: #fff;
    border-radius: var(--radius);
    padding: var(--sp-2);
    margin-bottom: var(--sp-2);
    border: 1px solid var(--border);
}
.swot-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1);
    margin-top: var(--sp-1);
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ── SWOT Weighted Priority Matrix ── */
.panel-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: var(--sp-3);
}
.swot-priority-card {
    padding: var(--sp-2) var(--sp-3);
}
.swot-priority-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--sp-2);
    margin-bottom: var(--sp-1);
}
.swot-priority-desc {
    font-size: 0.88rem;
    line-height: 1.4;
    flex: 1;
}
.swot-priority-badge {
    flex-shrink: 0;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.swot-score-row {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin-top: var(--sp-1);
}
.swot-score-formula {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 110px;
}
.swot-score-formula strong {
    color: var(--text);
    font-size: 0.9rem;
}
.swot-score-bar-track {
    flex: 1;
    height: 8px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 4px;
    overflow: hidden;
}
.swot-score-bar {
    height: 100%;
    border-radius: 4px;
    min-width: 4px;
    transition: width 0.4s ease;
}
.swot-bar-strength    { background: #22c55e; }
.swot-bar-weakness    { background: #ef4444; }
.swot-bar-opportunity { background: #0072BC; }
.swot-bar-threat      { background: #f59e0b; }
.swot-evidence-excerpt {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: var(--sp-1);
    margin-bottom: 0;
    padding-left: var(--sp-2);
    border-left: 2px solid var(--border);
    line-height: 1.4;
}

/* ── Strategic Analysis: TOWS Matrix ── */
.tows-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-3);
}
@media (max-width: 600px) { .tows-grid { grid-template-columns: 1fr; } }

.tows-cell {
    border-radius: var(--radius);
    padding: var(--sp-3);
    min-height: 120px;
}
.tows-cell h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--sp-2);
}
.tows-so { background: #f0fdf4; border: 1px solid #86efac; }
.tows-so h3 { color: #166534; }
.tows-wo { background: #eff6ff; border: 1px solid #93c5fd; }
.tows-wo h3 { color: #1e40af; }
.tows-st { background: #fffbeb; border: 1px solid #fcd34d; }
.tows-st h3 { color: #92400e; }
.tows-wt { background: #fef2f2; border: 1px solid #fca5a5; }
.tows-wt h3 { color: #991b1b; }

/* ── Badges ── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-positive { background: #dcfce7; color: #166534; }
.badge-negative { background: #fee2e2; color: #991b1b; }
.badge-neutral  { background: #f3f4f6; color: #374151; }
.badge-source   { background: #e0e7ff; color: #3730a3; }

/* ── Stakeholder Quadrant ── */
.stakeholder-quadrant {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-3);
}
.sq-cell {
    border-radius: var(--radius);
    padding: var(--sp-3);
    min-height: 120px;
}
.sq-manage   { background: #fef2f2; border: 1px solid #fca5a5; }
.sq-satisfy  { background: #fffbeb; border: 1px solid #fcd34d; }
.sq-informed { background: #eff6ff; border: 1px solid #93c5fd; }
.sq-monitor  { background: #f3f4f6; border: 1px solid #d1d5db; }

/* ==========================================================================
   Phase 5: Domain-Specific Styling
   ========================================================================== */

/* ── Risk Heat Map ── */
.heat-cell {
    display: inline-block;
    min-width: 2.5rem;
    text-align: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
    font-size: var(--text-sm);
    color: #fff;
}
.heat-low       { background: #22c55e; }          /* 1-4   green  */
.heat-medium    { background: #f59e0b; }          /* 5-9   amber  */
.heat-high      { background: #ef4444; }          /* 10-16 red    */
.heat-critical  { background: #7f1d1d; }          /* 17-25 dark   */

.heat-l, .heat-i {
    display: inline-block;
    min-width: 1.6rem;
    text-align: center;
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 600;
    font-size: var(--text-xs);
}
.heat-l-1, .heat-i-1 { background: #dcfce7; color: #166534; }
.heat-l-2, .heat-i-2 { background: #fef9c3; color: #854d0e; }
.heat-l-3, .heat-i-3 { background: #fed7aa; color: #9a3412; }
.heat-l-4, .heat-i-4 { background: #fecaca; color: #991b1b; }
.heat-l-5, .heat-i-5 { background: #991b1b; color: #fff; }

/* ── CAPA Overdue Badges ── */
.capa-due {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: var(--text-xs);
    font-weight: 600;
    white-space: nowrap;
}
.capa-due-ok      { background: #dcfce7; color: #166534; }
.capa-due-soon    { background: #fef9c3; color: #854d0e; }
.capa-due-overdue {
    background: #fee2e2;
    color: #991b1b;
    animation: pulse-overdue 2s ease-in-out infinite;
}
@keyframes pulse-overdue {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50%      { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}
.capa-due-closed  { background: #f3f4f6; color: #6b7280; }

/* ── Objective Progress Bars ── */
.progress-mini {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 120px;
}
.progress-mini-track {
    flex: 1;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}
.progress-mini-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}
.progress-mini-label {
    font-size: var(--text-xs);
    font-weight: 600;
    min-width: 2.5rem;
    text-align: right;
}
.progress-fill-low    { background: #ef4444; }    /* 0-25%  */
.progress-fill-mid    { background: #f59e0b; }    /* 26-50% */
.progress-fill-good   { background: #0072BC; }    /* 51-75% */
.progress-fill-done   { background: #22c55e; }    /* 76-100% */

/* ── KPI Variance Indicators ── */
.kpi-variance {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-weight: 600;
    font-size: var(--text-sm);
}
.kpi-variance-positive { color: #166534; }
.kpi-variance-neutral  { color: #6b7280; }
.kpi-variance-negative { color: #991b1b; }
.kpi-arrow {
    font-size: 0.9em;
}

/* ── Consistent Status Badges (additional statuses) ── */
.status-badge--in-progress,
.status-in-progress { background: #fffbeb; color: #854d0e; }
.status-in-progress::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #f59e0b; }
.status-badge--completed,
.status-completed   { background: #f1f5f9; color: #64748b; }
.status-badge--cancelled,
.status-cancelled   { background: #f1f5f9; color: #9ca3af; }
.status-badge--suspended,
.status-suspended   { background: #fffbeb; color: #92400e; }
.status-badge--disqualified,
.status-disqualified { background: #fef2f2; color: #b91c1c; }

/* Auto-generated code display */
.auto-code-display {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    padding: 0.35rem 0.75rem;
    background: var(--neutral-100, #f3f4f6);
    border: 1px solid var(--neutral-200, #e5e7eb);
    border-radius: 4px;
    color: var(--neutral-700, #374151);
    letter-spacing: 0.025em;
}

/* (Mega-menu cascade CSS removed — replaced by sidebar navigation) */

/* ==========================================================================
   Language Switcher – Modern Dropdown
   ========================================================================== */
.lang-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.lang-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid rgba(0, 114, 188, 0.15);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
}
.lang-toggle-btn:hover {
    background: rgba(0, 114, 188, 0.06);
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}
.lang-globe {
    flex-shrink: 0;
    opacity: 0.7;
}
.lang-toggle-btn:hover .lang-globe { opacity: 1; }
.lang-toggle-label {
    font-weight: 600;
    letter-spacing: 0.02em;
}
.lang-chevron {
    flex-shrink: 0;
    opacity: 0.5;
    transition: transform 0.2s ease;
}
.lang-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 160px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    z-index: 9999;
    overflow: hidden;
}
.lang-dropdown form {
    display: flex;
    flex-direction: column;
}
.lang-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: var(--text-sm);
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
    color: var(--text-secondary);
    line-height: 1.4;
}
.lang-option:hover {
    background: rgba(0, 114, 188, 0.04);
}
.lang-option--active {
    background: rgba(0, 114, 188, 0.06);
    color: var(--brand-primary);
    font-weight: 600;
}
.lang-option--active::after {
    content: "\2713";
    font-size: 0.75rem;
    color: var(--brand-primary);
    margin-left: 8px;
}
.lang-option + .lang-option {
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.lang-option-name {
    flex: 1;
}
.lang-option-native {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.5;
    margin-left: 12px;
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */
#toast-container {
    position: fixed;
    top: calc(var(--header-height, 56px) + var(--sp-3));
    right: var(--sp-4);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    pointer-events: none;
    max-width: 24rem;
}
.toast {
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 500;
    pointer-events: auto;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: opacity 0.3s, transform 0.3s;
    animation: toast-slide-in 0.3s ease-out;
}
@keyframes toast-slide-in {
    from { opacity: 0; transform: translateX(1rem); }
    to { opacity: 1; transform: translateX(0); }
}
.toast--success {
    background: #059669;
    color: #fff;
}
.toast--error {
    background: #dc2626;
    color: #fff;
}
.toast--warning {
    background: #d97706;
    color: #fff;
}
.toast--info, .toast-- {
    background: var(--brand-primary);
    color: #fff;
}
.toast-enter { opacity: 0; transform: translateX(1rem); }
.toast-leave { opacity: 0; transform: translateX(1rem); }

/* ==========================================================================
   Sortable Table Headers
   ========================================================================== */
.sortable-th { white-space: nowrap; }
.sort-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: inherit;
    text-decoration: none;
    font-weight: 600;
}
.sort-link:hover { color: var(--brand-primary); }
.sort-indicator { font-size: 0.65em; line-height: 1; }
.sort-indicator--inactive { opacity: 0.25; font-size: 0.5em; letter-spacing: -0.15em; }
.sorted { color: var(--brand-primary); }
.row-actions { white-space: nowrap; text-align: right; }

/* Alpine.js cloak */
[x-cloak] { display: none !important; }
.fade-enter { opacity: 0; }
.fade-leave { opacity: 0; }

/* HTMX loading indicator */
.htmx-indicator {
    display: none;
}
.htmx-request .htmx-indicator {
    display: inline-block;
}
.htmx-request.htmx-indicator {
    display: inline-block;
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* Focus-visible: visible ring only for keyboard users */
:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}
:focus:not(:focus-visible) {
    outline: none;
}

/* Minimum 44px touch targets (WCAG 2.2 AAA) */
.btn, .link-btn, .lang-btn, .nav-direct,
.global-search-btn, .notification-bell,
.filter-remove, .sort-link, .inline-link, .pager-actions a {
    min-height: 2.75rem;
    min-width: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Skip link improvement */
.skip-link:focus {
    position: fixed;
    top: var(--sp-2);
    left: var(--sp-2);
    z-index: 100000;
    padding: var(--sp-2) var(--sp-4);
    background: var(--brand-primary);
    color: #fff;
    border-radius: var(--radius-md);
    font-weight: 600;
    text-decoration: none;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (forced-colors: active) {
    .btn { border: 1px solid ButtonText; }
    .status-badge { border: 1px solid ButtonText; }
    .notification-badge { border: 1px solid ButtonText; }
}

/* ==========================================================================
   RTL Support – Comprehensive
   NOTE: direction: rtl on <html> auto-reverses flex-direction: row containers,
   inline flow, and CSS Grid column order. We do NOT add flex-direction:
   row-reverse — that would double-reverse back to LTR layout.
   We only override: margin/padding/border L↔R swaps, positioning L↔R swaps,
   text-align where the base CSS sets it explicitly, and border-radius swaps.
   ========================================================================== */

/* ── Base ── */
html[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

/* ── Typography ── */
html[dir="rtl"] body {
    font-family: 'IBM Plex Sans Arabic', 'Space Grotesk', 'Inter', 'Segoe UI', sans-serif;
}

/* ── Ambient shapes (decorative blobs — swap left/right) ── */
html[dir="rtl"] .ambient-shape-a { left: auto; right: -90px; }
html[dir="rtl"] .ambient-shape-b { right: auto; left: -100px; }

/* ── Header & Navigation ── */
/* No flex-direction overrides — direction: rtl reverses row flex automatically */
html[dir="rtl"] .notification-badge { right: auto; left: -6px; margin-left: 0; margin-right: 0.2rem; }

/* (RTL mega-menu rules removed — replaced by sidebar navigation) */

/* ── Breadcrumbs ── */
html[dir="rtl"] .breadcrumbs li + li::before { content: "\\"; margin: 0 var(--sp-2); }

/* ── Page Header ── */
html[dir="rtl"] .page-header .page-actions { margin-left: 0; margin-right: auto; }

/* ── Search ── */
html[dir="rtl"] .global-search-form { margin-right: 0; margin-left: var(--sp-2); }
html[dir="rtl"] .global-search-input {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    border-right: 1px solid rgba(0, 114, 188, 0.18);
    border-left: none;
}
html[dir="rtl"] .global-search-btn {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    border-left: 1px solid rgba(0, 114, 188, 0.18);
    border-right: none;
}

/* ── Filter Bar ── */
html[dir="rtl"] .filter-remove { margin-left: 0; margin-right: var(--sp-1); }

/* ── Tables ── */
html[dir="rtl"] .data-table th,
html[dir="rtl"] .data-table td { text-align: right; }
html[dir="rtl"] .data-table th:last-child,
html[dir="rtl"] .data-table td:last-child { text-align: left; }
html[dir="rtl"] .row-actions { text-align: left; }
html[dir="rtl"] .doc-preview-table th { text-align: right; }

/* ── Forms ── */
html[dir="rtl"] .form-group input[type="text"],
html[dir="rtl"] .form-group input[type="email"],
html[dir="rtl"] .form-group input[type="number"],
html[dir="rtl"] .form-group input[type="url"],
html[dir="rtl"] .form-group input[type="tel"],
html[dir="rtl"] .form-group input[type="password"],
html[dir="rtl"] .form-group input[type="search"],
html[dir="rtl"] .form-group input[type="date"],
html[dir="rtl"] .form-group textarea,
html[dir="rtl"] .form-group select { text-align: right; }
html[dir="rtl"] .required-marker { margin-left: 0; margin-right: 2px; }
html[dir="rtl"] .field-required-marker { margin-left: 0; margin-right: 0.15rem; }
html[dir="rtl"] .form-actions .btn + .btn { margin-left: 0; margin-right: var(--sp-2); }
html[dir="rtl"] .fieldset { border-left: none; border-right: 3px solid var(--brand-primary); padding-left: 0; padding-right: var(--sp-4); }
html[dir="rtl"] .form-section legend { margin-left: 0; margin-right: var(--sp-1); }
html[dir="rtl"] .form-section-index { margin-right: 0; margin-left: 0.4rem; }
html[dir="rtl"] .checklist-item svg { margin-right: 0; margin-left: var(--sp-2); }
html[dir="rtl"] .errorlist { padding-left: 0; padding-right: var(--sp-4); }
html[dir="rtl"] .form-errors ul { padding-left: 0; padding-right: 1.2rem; }
html[dir="rtl"] .capa-closure-checklist ul { padding-left: 0; padding-right: 1.2rem; }
html[dir="rtl"] .mention-option { text-align: right; }

/* ── Cards & Detail panels ── */
html[dir="rtl"] .card { text-align: right; }

/* ── Status badges ── */
html[dir="rtl"] .status-badge { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .overdue-badge { margin-left: 0; margin-right: var(--sp-1); }
html[dir="rtl"] .due-badge { margin-left: 0; margin-right: var(--sp-1); }

/* ── Buttons & Actions ── */
html[dir="rtl"] .btn svg { margin-right: 0; margin-left: var(--sp-1); }
html[dir="rtl"] .btn i { margin-right: 0; margin-left: var(--sp-1); }
html[dir="rtl"] .workflow-actions .btn + .btn { margin-left: 0; margin-right: var(--sp-2); }
html[dir="rtl"] .inline-link svg { margin-right: 0; margin-left: 4px; }

/* ── Sidebar & Layout ── */
html[dir="rtl"] .sidebar { border-left: none; border-right: 1px solid var(--line); padding-left: 0; padding-right: var(--sp-6); }

/* ── Dashboard widgets ── */
html[dir="rtl"] .stat-icon { margin-right: 0; margin-left: var(--sp-3); }

/* ── Pagination ── */
html[dir="rtl"] .pagination .prev::before { content: "\203A"; }
html[dir="rtl"] .pagination .next::before { content: "\2039"; }

/* ── Alerts & Messages ── */
html[dir="rtl"] .message { padding-left: var(--sp-3); padding-right: var(--sp-4); }

/* ── Toast notifications ── */
html[dir="rtl"] #toast-container { right: auto; left: var(--sp-4); }
html[dir="rtl"] .toast-enter { transform: translateX(-1rem); }
html[dir="rtl"] .toast-leave { transform: translateX(-1rem); }

/* ── DOCX Preview ── */
html[dir="rtl"] .doc-preview-list-item { padding-left: 0; padding-right: var(--sp-4); }
html[dir="rtl"] .doc-preview-list-item::before { left: auto; right: 0; }
html[dir="rtl"] .doc-preview-list { padding-left: 0; padding-right: var(--sp-6); }
html[dir="rtl"] .doc-toc-list { padding-left: 0; padding-right: var(--sp-6); }
html[dir="rtl"] .doc-section-toggle { margin-left: 0; margin-right: var(--sp-2); }
html[dir="rtl"] .doc-section-toggle::before { border-right: none; border-left: 2.5px solid #fff; }

/* ── History panel ── */
html[dir="rtl"] .history-entry { border-left: none; border-right: 2px solid var(--line); padding-left: 0; padding-right: var(--sp-4); }

/* ── Language switcher ── */
html[dir="rtl"] .lang-dropdown { right: auto; left: 0; }
html[dir="rtl"] .lang-option { text-align: right; }
html[dir="rtl"] .lang-option--active::after { margin-left: 0; margin-right: 8px; }
html[dir="rtl"] .lang-option-native { margin-left: 0; margin-right: 12px; }

/* ── Directional icons ── */
html[dir="rtl"] .bi-arrow-right::before { content: "\f12f"; }
html[dir="rtl"] .bi-chevron-right::before { content: "\f141"; }

/* ── Notifications list ── */
html[dir="rtl"] .notification-item .timestamp { text-align: left; }

/* ── Strategic Analysis ── */
html[dir="rtl"] .seven-s-element-card { border-left: none; border-right: 4px solid transparent; }
html[dir="rtl"] .seven-s-element-card.hard { border-right-color: #0072BC; }
html[dir="rtl"] .seven-s-element-card.soft { border-right-color: #14b8a6; }
html[dir="rtl"] .framework-checklist ul { padding-left: 0; padding-right: 1.1rem; }
html[dir="rtl"] .seven-s-guide-group ul { padding-left: 0; padding-right: 1rem; }
html[dir="rtl"] .progress-mini-label { text-align: left; }

/* ── Confirm modal ── */
html[dir="rtl"] .confirm-modal-body { text-align: right; }

/* ── Skip link ── */
html[dir="rtl"] .skip-link { left: auto; right: -9999px; }
html[dir="rtl"] .skip-link:focus { right: var(--sp-2); left: auto; }

/* ==========================================================================
   Kanban Task Board
   ========================================================================== */

.kanban-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--sp-4);
    margin-top: var(--sp-4);
}

.kanban-column {
    background: var(--neutral-50);
    border-radius: var(--radius-md);
    min-height: 300px;
    display: flex;
    flex-direction: column;
}

.kanban-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    background: var(--card);
}

.kanban-column-title {
    font-weight: 600;
    font-size: var(--text-md);
    color: var(--ink);
}

.kanban-column-body {
    padding: var(--sp-3);
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.kanban-card {
    display: block;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: var(--sp-3);
    text-decoration: none;
    color: var(--ink);
    transition: box-shadow 0.15s ease, transform 0.1s ease;
}

.kanban-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.kanban-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-2);
}

.kanban-card-code {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--brand-primary);
    font-family: var(--font-mono);
}

.kanban-card-desc {
    font-size: var(--text-sm);
    color: var(--ink-soft);
    margin: 0 0 var(--sp-2) 0;
    line-height: 1.4;
}

.kanban-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.kanban-card-assignee {
    font-weight: 500;
}

.kanban-card-due {
    font-weight: 500;
}

.kanban-card-overdue {
    color: var(--danger);
    font-weight: 600;
}

.kanban-card-hours {
    display: flex;
    gap: var(--sp-3);
    margin-top: var(--sp-2);
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.kanban-empty {
    font-size: var(--text-sm);
    color: var(--neutral-400);
    text-align: center;
    padding: var(--sp-6) var(--sp-4);
    margin: 0;
}

/* Responsive: stack columns on smaller screens */
@media (max-width: 1024px) {
    .kanban-board {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

/* RTL support for kanban */
html[dir="rtl"] .kanban-card-header { flex-direction: row-reverse; }
html[dir="rtl"] .kanban-card-meta { flex-direction: row-reverse; }
html[dir="rtl"] .kanban-card-hours { flex-direction: row-reverse; }

/* ==========================================================================
   View Toggles (Table / Kanban)
   ========================================================================== */

.view-toggles {
    display: flex;
    gap: 0.25rem;
}

.list-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.view-toggle-btn {
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--line, #ddd);
    background: var(--card, #fff);
    cursor: pointer;
    border-radius: var(--radius-sm, 0.375rem);
    color: var(--ink-soft, #5a6a7e);
    font-size: var(--text-sm, 0.875rem);
    line-height: 1;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.view-toggle-btn:hover {
    background: var(--bg-1, #f0f4f8);
}

.view-toggle-btn.active {
    background: var(--brand-primary, #0072BC);
    color: #fff;
    border-color: var(--brand-primary, #0072BC);
}

/* Entity list kanban variant: auto-fit columns */
.kanban-board--entity-list {
    display: flex;
    gap: var(--sp-4, 1rem);
    overflow-x: auto;
    padding-bottom: var(--sp-3, 0.75rem);
    margin-top: var(--sp-4, 1rem);
}

.kanban-board--entity-list .kanban-column {
    min-width: 240px;
    max-width: 320px;
    flex: 1 0 240px;
}

.kanban-count {
    background: var(--card, #fff);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-full, 1rem);
    font-size: var(--text-xs, 0.75rem);
    font-weight: 600;
    color: var(--ink-soft, #5a6a7e);
}

/* Responsive: stack entity list kanban on small screens */
@media (max-width: 640px) {
    .kanban-board--entity-list {
        flex-direction: column;
    }
    .kanban-board--entity-list .kanban-column {
        max-width: none;
        flex: none;
    }
}

/* ==========================================================================
   Nav Badges (ISO / OPS)
   ========================================================================== */

.nav-badge {
    display: inline-block;
    font-size: var(--text-xs, 0.6875rem);
    font-weight: 600;
    padding: 0.1em 0.4em;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    vertical-align: middle;
    margin-inline-start: 0.35em;
    line-height: 1;
}

.nav-badge--iso {
    background: color-mix(in srgb, var(--brand-primary) 14%, transparent);
    color: var(--brand-primary);
}

.nav-badge--ops {
    background: color-mix(in srgb, var(--brand-teal) 14%, transparent);
    color: var(--brand-teal);
}

/* (Nav-pillar and mega-panel nav-badge CSS removed — replaced by sidebar navigation) */

/* ==========================================================================
   Page Content Entrance Animation
   ========================================================================== */
.main-content {
    animation: fade-up 300ms var(--ease, cubic-bezier(0.4, 0, 0.2, 1)) both;
}

/* ==========================================================================
   Mobile Responsive Polish (< 768px)
   ========================================================================== */
@media (max-width: 768px) {
    /* Full-width main content */
    .main-content {
        margin-left: 0 !important;
        padding: var(--sp-3);
    }

    /* Hero section compact on mobile */
    .hero {
        padding: var(--sp-4) var(--sp-3);
    }
    .hero h1 {
        font-size: var(--text-xl);
    }
    .hero-stats {
        gap: var(--sp-2);
        flex-wrap: wrap;
    }
    .hero-stats article {
        min-width: 0;
        flex: 1 1 auto;
    }

    /* Tables scroll horizontally */
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Form grids become single-column */
    .form-grid {
        grid-template-columns: 1fr !important;
    }
    .form-grid .span-2 {
        grid-column: span 1;
    }

    /* Module grid: single column */
    .module-grid {
        grid-template-columns: 1fr;
    }

    /* Touch-friendly spacing on interactive elements */
    .btn {
        min-height: 44px;
        padding: var(--sp-3) var(--sp-4);
    }
    .inline-link {
        padding: var(--sp-2) 0;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* Instant search dropdown full width */
    .instant-search-dropdown {
        position: fixed;
        top: var(--header-height, 56px);
        left: 0;
        right: 0;
        min-width: 0;
        border-radius: 0;
        max-height: 50vh;
    }

    /* Data table: reduce padding for mobile */
    .data-table th,
    .data-table td {
        padding: var(--sp-2);
        font-size: var(--text-xs);
    }

    /* Approval actions stack vertically on mobile */
    .approval-actions {
        flex-direction: column;
        gap: var(--sp-1);
    }

    /* Section heads */
    .section-head {
        flex-direction: column;
        gap: var(--sp-2);
        align-items: flex-start;
    }

    /* Detail actions */
    .detail-actions {
        flex-direction: column;
    }
    .detail-actions .btn {
        width: 100%;
        text-align: center;
    }

    /* Footer compact */
    .site-footer {
        margin-left: 0 !important;
        padding: var(--sp-3);
    }

    /* Toast notifications */
    #toast-container {
        left: var(--sp-2);
        right: var(--sp-2);
        max-width: none;
    }
}

/* ==========================================================================
   Empty States
   ========================================================================== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--ink-soft);
}
.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}
.empty-state h3 {
    font-size: 1.125rem;
    color: var(--ink);
    margin-bottom: 0.5rem;
}
.empty-state p {
    margin-bottom: 1.5rem;
    max-width: 28rem;
    margin-left: auto;
    margin-right: auto;
}

/* ==========================================================================
   Inline Form Validation
   ========================================================================== */
.field-input.is-valid {
    border-color: var(--success-border, #6dd4a0) !important;
    box-shadow: 0 0 0 1px var(--success-border, #6dd4a0);
}
.field-input.is-invalid {
    border-color: var(--danger-border, #e4938a) !important;
    box-shadow: 0 0 0 1px var(--danger-border, #e4938a);
}
/* Keep focus ring visible on top of validation state */
.field-input.is-valid:focus {
    box-shadow: 0 0 0 3px rgba(15, 138, 79, 0.15);
}
.field-input.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(196, 50, 28, 0.15);
}

/* ==========================================================================
   Dashboard Metric Drill-Down Links
   ========================================================================== */
.metric-link {
    text-decoration: none;
    color: inherit;
    transition: opacity 0.15s ease;
}
.metric-link:hover {
    text-decoration: underline;
    opacity: 0.8;
}
.metric-link:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* ==========================================================================
   Period-over-Period Comparison Indicators
   ========================================================================== */
.period-change {
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.25rem;
    white-space: nowrap;
}
.period-up {
    color: #ef4444;  /* red — increasing problems */
}
.period-down {
    color: #10b981;  /* green — decreasing problems */
}
.period-flat {
    color: #6b7280;  /* neutral grey */
}

/* ── Theme Toggle Button ── */
.theme-toggle {
    background: none;
    border: 1px solid var(--bg-2, #e4edf5);
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--ink-soft, #5a6270);
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius-sm, 6px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2rem;
    min-width: 2rem;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    line-height: 1;
}
.theme-toggle:hover {
    background: rgba(0, 114, 188, 0.08);
    color: var(--brand-primary, #0072BC);
    border-color: var(--brand-primary, #0072BC);
}

/* === Mobile Responsive Tables === */
@media (max-width: 768px) {
    .data-table thead {
        display: none;
    }
    .data-table tbody tr {
        display: block;
        margin-bottom: var(--sp-4, 16px);
        border: 1px solid var(--line, rgba(0,0,0,0.12));
        border-radius: var(--radius-md, 10px);
        padding: var(--sp-3, 12px);
        background: var(--glass-bg, rgba(255,255,255,0.72));
    }
    .data-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: var(--sp-2, 8px) 0;
        border-bottom: 1px solid var(--bg-2, #e4edf5);
        text-align: right;
    }
    [dir="rtl"] .data-table tbody td {
        text-align: left;
    }
    .data-table tbody td:last-child {
        border-bottom: none;
    }
    .data-table tbody td::before {
        content: attr(data-label);
        font-weight: var(--weight-semibold, 600);
        font-size: var(--text-sm, 0.8125rem);
        color: var(--ink-soft, #5a6270);
        text-align: left;
        flex-shrink: 0;
        margin-right: var(--sp-3, 12px);
    }
    [dir="rtl"] .data-table tbody td::before {
        text-align: right;
        margin-right: 0;
        margin-left: var(--sp-3, 12px);
    }
    .data-table .row-actions {
        justify-content: flex-end;
    }
    .data-table .row-actions::before {
        display: none;
    }

    /* Single-column forms on mobile */
    .form-grid {
        grid-template-columns: 1fr;
    }

    /* Full-width buttons */
    .detail-actions {
        flex-wrap: wrap;
    }
    .detail-actions .btn {
        flex: 1 1 auto;
        min-width: 120px;
        text-align: center;
    }

    /* Card view single column */
    .card-view-grid {
        grid-template-columns: 1fr;
    }

    /* Pager stacking */
    .pager {
        flex-direction: column;
        gap: var(--sp-3, 12px);
    }
}
