/* 
  GPO CAPA Dashboard Premium Style Sheets - 2026
  Aesthetic: Premium, Dark Glassmorphism, Neon Highlights, Outstanding UX
  Fully compliant with UI/UX Pro Max Design Principles
*/

:root {
    --border-radius-base: 8px;
    --spacing-md: 1rem;
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.05);
    /* Color Palette - HSL (Hue, Saturation, Lightness) */
    --bg-dark: 210, 20%, 95%;        /* #eef2f6 - Softer light gray background to completely eliminate stark white glare */
    --bg-surface: 0, 0%, 100%;       /* #ffffff - Pure white surface */
    --bg-card: 0, 0%, 100%, 0.95;     /* High-contrast solid card background */
    --glass-bg: 0, 0%, 100%, 0.98;    /* Extremely clean white glass overlay for ultimate contrast */
    --glass-border: 214, 32%, 91%;    /* #e5e7eb - Subtle clean slate border lines */
    
    --primary: 221, 83%, 53%;       /* Royal Blue #2563eb for premium look */
    --primary-hover: 224, 89%, 43%;
    --primary-rgb: 37, 99, 235;
    
    --success: 142, 72%, 29%;       /* Deep Forest Green #15803d for supreme text contrast */
    --success-bg: 142, 70%, 45%, 0.12;
    
    --danger: 0, 84%, 44%;          /* Deep Red #b91c1c for readability */
    --danger-bg: 0, 84%, 60%, 0.12;
    
    --warning: 38, 92%, 35%;        /* Deep Amber #b45309 */
    --warning-bg: 38, 92%, 50%, 0.12;
    
    --purple: 262, 83%, 45%;        /* Violet #6d28d9 */
    --purple-bg: 262, 83%, 58%, 0.12;
    
    --cyan: 187, 92%, 30%;          /* Teal/Cyan #0f766e */
    --cyan-bg: 187, 92%, 45%, 0.12;
    
    --text-primary: 224, 71%, 4%;     /* #020617 - Deep Off-Black for absolute highest legibility */
    --text-secondary: 215, 25%, 27%; /* #334155 - Slate-700 for clear secondary reading */
    --text-muted: 215, 16%, 47%;     /* #64748b - Slate-500 for captions and dates */
    
    --font-outfit: 'Outfit', 'Sarabun', sans-serif;
    --font-sarabun: 'Sarabun', 'Outfit', sans-serif;
    
    /* Design Engineering Emil Kowalski Easings */
    --ease-out-smooth: cubic-bezier(0.32, 0.72, 0, 1);
    --ease-out-snappy: cubic-bezier(0.2, 0.9, 0.1, 1);
    --ease-in-smooth: cubic-bezier(0.8, 0, 0.2, 1);
    --ease-apple-morph: cubic-bezier(0.4, 0, 0, 1);
    --ease-elastic: cubic-bezier(0.68, -0.6, 0.32, 1.6);
    
    --transition-fast: 150ms var(--ease-out-snappy);
    --transition-normal: 250ms var(--ease-out-smooth);
    --transition-slow: 400ms var(--ease-out-smooth);
    --transition-spring: 400ms var(--ease-elastic);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: hsl(var(--bg-dark));
    font-family: var(--font-sarabun);
    color: hsl(var(--text-primary));
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Background blob gradients */
.background-blobs {
    position: fixed;
    width: 100vw;
    height: 100vh;
    top: 0;
    left: 0;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(140px);
    opacity: 0.1;
    animation: float-blob 28s infinite alternate ease-in-out;
}

.blob-1 {
    width: 550px;
    height: 550px;
    background: radial-gradient(circle, #0ea5e9 0%, rgba(14,165,233,0) 70%);
    top: -120px;
    right: -100px;
}

.blob-2 {
    width: 650px;
    height: 650px;
    background: radial-gradient(circle, #6366f1 0%, rgba(99,102,241,0) 70%);
    bottom: -180px;
    left: -150px;
    animation-delay: -6s;
}

.blob-3 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #db2777 0%, rgba(219,39,119,0) 70%);
    top: 35%;
    left: 45%;
    animation-duration: 35s;
    animation-delay: -12s;
}

@keyframes float-blob {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(80px, -50px) scale(1.15); }
    100% { transform: translate(-50px, 70px) scale(0.9); }
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 40px;
    background: rgba(255, 255, 255, 0.95); /* Pure white glass background */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid #e2e8f0; /* Crisp soft slate divider line */
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-logo {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    background: linear-gradient(135deg, hsl(var(--primary)) 0%, #4f46e5 100%);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(14, 165, 233, 0.3);
    color: #fff;
}

.logo-icon svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.navbar-logo h1 {
    font-family: var(--font-outfit);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, hsl(var(--text-primary)), hsl(var(--primary)));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.navbar-logo p {
    font-size: 12px;
    color: hsl(var(--text-secondary));
    margin-top: 2px;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 20px;
    min-width: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.navbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #f1f5f9; /* Soft clean gray */
    border-radius: 50%;
    border: 1px solid #e2e8f0;
    color: hsl(var(--text-secondary));
}

.user-avatar svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
}

.badge-role {
    font-size: 10px;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0.5px;
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 2px;
}

.role-auditor {
    background: rgba(14, 165, 233, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(14, 165, 233, 0.3);
}

.role-auditee {
    background: rgba(163, 163, 163, 0.15);
    color: #d4d4d4;
    border: 1px solid rgba(163, 163, 163, 0.3);
}

.card-glass {
    background: hsl(var(--glass-bg)); /* Fix invalid rgba to standard hsl */
    border: 1px solid hsl(var(--glass-border));
    border-radius: var(--border-radius-base);
    box-shadow: var(--shadow-soft); /* Beautiful clean shadow */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

/* Main Layout Grid */
.main-content {
    width: calc(100% - 32px);
    max-width: none;
    margin: 24px auto;
    padding: 0 16px 50px 16px; /* Moved bottom padding here to prevent sidebar bottom gaps */
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0;
}

.data-view-area {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Stats Cards Grid */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 20px;
}

.stat-card {
    position: relative;
    padding: var(--spacing-md);
    background: hsl(var(--bg-card));
    border: 1px solid #e2e8f0; /* Crisp soft slate border */
    border-radius: var(--border-radius-base);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-soft); /* Extremely soft, premium shadow */
}

.stat-card:hover {
    transform: translateY(-5px) scale(1.02);
    border-color: #cbd5e1; /* Slightly darker gray border on hover */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.stat-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    background: rgba(255, 255, 255, 0.1);
}

.stat-card.blue::before { background: hsl(var(--primary)); }
.stat-card.green::before { background: hsl(var(--success)); }
.stat-card.red::before { background: hsl(var(--danger)); }
.stat-card.yellow::before { background: hsl(var(--warning)); }
.stat-card.purple::before { background: hsl(var(--purple)); }
.stat-card.cyan::before { background: hsl(var(--cyan)); }

.stat-icon {
    position: absolute;
    right: 20px;
    top: 20px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    color: hsl(var(--text-secondary));
    transition: all var(--transition-normal);
}

.stat-icon svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.stat-card:hover .stat-icon {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    transform: rotate(5deg) scale(1.08);
}

.stat-card.blue:hover .stat-icon { color: hsl(var(--primary)); background: rgba(14, 165, 233, 0.1); }
.stat-card.green:hover .stat-icon { color: hsl(var(--success)); background: rgba(16, 185, 129, 0.1); }
.stat-card.red:hover .stat-icon { color: hsl(var(--danger)); background: rgba(239, 68, 68, 0.1); }
.stat-card.yellow:hover .stat-icon { color: hsl(var(--warning)); background: rgba(217, 119, 6, 0.1); }
.stat-card.purple:hover .stat-icon { color: hsl(var(--purple)); background: rgba(124, 58, 237, 0.1); }
.stat-card.cyan:hover .stat-icon { color: hsl(var(--cyan)); background: rgba(6, 182, 212, 0.1); }

.dashboard-widget {
    min-width: 0;
    position: relative;
}
.dashboard-widget.chart-widget,
.dashboard-widget.table-widget {
    grid-column: span 2;
    min-height: 280px;
    padding: 18px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: rgba(255,255,255,.92);
    box-shadow: 0 4px 14px rgba(15,23,42,.06);
}
.dashboard-widget-header { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin-bottom:14px; }
.dashboard-widget-title { color:#0f172a; font-weight:700; font-size:14px; }
.dashboard-widget-meta { color:#64748b; font-size:11px; margin-top:4px; }
.dashboard-widget-actions { display:flex; gap:4px; }
.dashboard-widget-actions button { border:0; background:transparent; color:#64748b; cursor:pointer; padding:3px 5px; }
.dashboard-widget-actions button:hover { color:#2563eb; }
.widget-chart-area { height:210px; position:relative; }
.widget-chart-svg { width:100%; height:100%; overflow:visible; }
.widget-chart-label { fill:#64748b; font-size:10px; }
.widget-chart-grid { stroke:#e2e8f0; stroke-dasharray:3 3; }
.widget-empty-state { padding:36px 12px; color:#94a3b8; text-align:center; font-size:12px; }
.widget-pie-layout { display:flex; align-items:center; justify-content:center; gap:24px; height:210px; }
.widget-pie { width:150px; height:150px; border-radius:50%; display:grid; place-items:center; flex:0 0 auto; }
.widget-pie-hole { width:70px; height:70px; border-radius:50%; background:#fff; }
.widget-pie:not(.doughnut) .widget-pie-hole { display:none; }
.widget-pie-legend { display:flex; flex-direction:column; gap:6px; max-height:180px; overflow:auto; font-size:11px; color:#475569; }
.widget-pie-legend span { display:flex; align-items:center; gap:6px; }
.widget-pie-legend i { width:9px; height:9px; border-radius:50%; display:inline-block; }
.widget-pie-legend b { color:#0f172a; margin-left:3px; }
.widget-table-wrap { overflow:auto; max-height:220px; }
.widget-summary-table { width:100%; border-collapse:collapse; font-size:12px; }
.widget-summary-table th,.widget-summary-table td { padding:8px 10px; border-bottom:1px solid #e2e8f0; text-align:left; }
.widget-summary-table th { color:#64748b; font-size:11px; }
.widget-manager-card { max-width:980px; }
.widget-manager-layout { display:grid; grid-template-columns:minmax(0,1.45fr) minmax(240px,.8fr); gap:18px; padding:18px; }
.widget-form-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.widget-form-grid .form-group { display:flex; flex-direction:column; gap:5px; }
.widget-form-grid label,.widget-filter-editor label { color:#475569; font-size:12px; font-weight:700; }
.widget-form-grid input,.widget-form-grid select,.widget-filter-row input,.widget-filter-row select { border:1px solid #dbe3ef; border-radius:8px; padding:9px 10px; background:#fff; color:#334155; font:inherit; font-size:12px; min-width:0; }
.widget-filter-editor { margin-top:16px; padding-top:14px; border-top:1px solid #e2e8f0; }
.widget-filter-editor-header,.widget-existing-header { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:8px; }
.widget-filter-row { display:grid; grid-template-columns:1fr 1fr 1fr auto; gap:7px; margin-top:7px; }
.widget-filter-remove { border:0; background:#fff1f2; color:#dc2626; border-radius:8px; cursor:pointer; padding:0 9px; }
.widget-form-footer { padding:16px 0 0; border-top:0; }
.widget-form-error { flex:1; }
.widget-existing-panel { border-left:1px solid #e2e8f0; padding-left:18px; min-width:0; }
.widget-existing-list { display:flex; flex-direction:column; gap:8px; max-height:420px; overflow:auto; }
.widget-existing-item { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:10px; border:1px solid #e2e8f0; border-radius:9px; background:#f8fafc; }
.widget-existing-item strong { display:block; color:#1e293b; font-size:12px; }
.widget-existing-item small { color:#64748b; font-size:10px; }
.widget-existing-actions { display:flex; gap:4px; }
.widget-existing-actions button { border:0; background:transparent; color:#2563eb; cursor:pointer; font-size:11px; }
.widget-existing-actions button.danger { color:#dc2626; }
@media (max-width: 800px) {
    .dashboard-widget.chart-widget,.dashboard-widget.table-widget { grid-column: span 1; }
    .widget-manager-layout { grid-template-columns:1fr; }
    .widget-existing-panel { border-left:0; border-top:1px solid #e2e8f0; padding-left:0; padding-top:16px; }
}
@media (max-width: 560px) {
    .widget-form-grid { grid-template-columns:1fr; }
    .widget-filter-row { grid-template-columns:1fr; }
}

.stat-data {
    display: flex;
    flex-direction: column;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 13px;
    font-weight: 600;
    color: hsl(var(--text-secondary));
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-val {
    font-size: 32px;
    font-weight: 700;
    font-family: var(--font-outfit);
    color: hsl(var(--text-primary)); /* Supreme dark slate contrast */
    margin-top: 4px;
}

.stat-desc {
    font-size: 11px;
    color: hsl(var(--text-muted));
}

.warning-blink {
    color: #f87171;
    font-weight: 600;
    animation: text-pulsate 1.5s infinite;
}

@keyframes text-pulsate {
    0%, 100% { opacity: 1; text-shadow: 0 0 4px rgba(239,68,68,0.2); }
    50% { opacity: 0.6; text-shadow: none; }
}

.progress-bar-mini {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 12px;
}

.progress-bar-mini-fill {
    height: 100%;
    background: hsl(var(--cyan));
    border-radius: 3px;
    transition: width var(--transition-normal);
}

.controls-panel {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1.5rem;
    align-items: center;
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    margin-bottom: 0;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: #ffffff; /* Clean white background */
    border: 1px solid #e2e8f0; /* Crisp slate gray border */
    border-radius: var(--border-radius-base);
    width: 100%;
    max-width: 450px;
    height: 42px; /* Standard uniform height */
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-box:focus-within {
    border-color: hsl(var(--primary));
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

.search-icon {
    position: absolute;
    left: 14px;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: hsl(var(--text-muted));
}

.search-icon svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.search-box input[type="text"] {
    width: 100%;
    padding: 12px 14px 12px 42px !important; /* Force left padding to prevent overlapping with the magnifying glass icon */
    background: transparent;
    border: none;
    outline: none;
    color: hsl(var(--text-primary)); /* High contrast dark text */
    font-family: inherit;
    font-size: 14px;
}

.filters-group {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.filter-item {
    display: flex;
    flex-direction: row; /* Inline label to ensure all controls have the exact same height and plane */
    align-items: center;
    gap: 8px;
}

.filter-item label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: hsl(var(--text-secondary));
}

.saved-view-controls {
    flex-wrap: wrap;
}

.saved-view-controls .btn {
    padding: 9px 12px;
}

select, input[type="text"], input[type="email"], input[type="number"], input[type="date"], textarea {
    padding: 10px 16px;
    background: #ffffff; /* Clean white background */
    border: 1px solid #e2e8f0; /* Crisp slate border */
    border-radius: 10px;
    color: hsl(var(--text-primary)); /* Dark text color for supreme legibility */
    font-family: inherit;
    font-size: 13px;
    height: 42px; /* Standard uniform height */
    outline: none;
    transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

select:focus, input:focus, textarea:focus {
    border-color: hsl(var(--primary));
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.action-buttons {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

/* General Buttons System */
.btn {
    padding: 11px 20px;
    border-radius: var(--border-radius-base);
    font-weight: 600;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    will-change: transform;
}

.btn svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
}

.btn:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: hsl(var(--primary));
    color: #ffffff !important; /* High-contrast white text */
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.15);
}

.btn-primary:hover {
    background: hsl(var(--primary-hover));
    color: #ffffff !important;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
}

.btn-success {
    background: #e6f4ea; /* Soft pastel green */
    border: 1px solid #c2e7cd; /* Crisp soft border */
    color: #137333 !important; /* Deep readable green */
}

.btn-success:hover {
    background: #137333;
    color: #ffffff !important;
    border-color: #137333;
    box-shadow: 0 4px 12px rgba(19, 115, 51, 0.2);
}

.btn-danger {
    background: #fce8e6; /* Soft pastel red */
    border: 1px solid #fad2cf;
    color: #c5221f !important; /* Deep readable red */
}

.btn-danger:hover {
    background: #c5221f;
    color: #ffffff !important;
    border-color: #c5221f;
    box-shadow: 0 4px 12px rgba(197, 34, 31, 0.2);
}

.btn-danger-outline {
    background: rgba(var(--danger), 0.1);
    border: 1px solid rgba(var(--danger), 0.2);
    color: #f87171;
}

.btn-danger-outline:hover {
    background: hsl(var(--danger));
    color: #020617;
}

.btn-light {
    background: #ffffff;
    border: 1px solid #dbe3ef;
    color: #334155 !important;
}

.btn-light:hover {
    background: #f1f5f9;
    color: #1d4ed8 !important;
}

.btn-logout {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #f87171;
    padding: 8px 16px;
    font-size: 12px;
}

.btn-logout:hover {
    background: hsl(var(--danger));
    color: #020617;
}

.btn-download {
    background: #e4f7fb; /* Soft pastel cyan */
    border: 1px solid #c1edf6;
    color: #007b83 !important; /* Deep readable teal/cyan */
    text-decoration: none;
}

.btn-download:hover {
    background: #007b83;
    color: #ffffff !important;
    border-color: #007b83;
    box-shadow: 0 4px 12px rgba(0, 123, 131, 0.2);
}

.btn-upload {
    background: #fef7e0; /* Soft pastel amber */
    border: 1px solid #feecb3;
    color: #b06000 !important; /* Deep readable amber */
}

.btn-upload:hover {
    background: #b06000;
    color: #ffffff !important;
    border-color: #b06000;
    box-shadow: 0 4px 12px rgba(176, 96, 0, 0.2);
}


.btn-action-circle {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 8px;
    font-size: 13px;
}

/* Table Card Container */
.table-container {
    min-width: 0;
    overflow: hidden;
    padding: 16px;
}

.table-responsive {
    width: 100%;
    max-width: 100%;
    overflow: auto;
    max-height: min(68vh, 720px);
    overscroll-behavior: contain;
    border-radius: 12px;
    border: 1px solid #e2e8f0; /* Crisp outer gray border */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02); /* Soft clean modern shadow */
}

table {
    width: max-content;
    min-width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    text-align: left;
}

/* Make table columns responsive and prevent horizontal overflow/slicing */
table th, table td {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Sticky First Column for Anchor Context when scrolling horizontally */
thead th:first-child,
tbody td:first-child {
    position: sticky;
    left: 0;
    z-index: 5;
}

thead th:first-child {
    z-index: 15;
    background: #f1f5f9 !important;
}

tbody td:first-child {
    background: #ffffff !important;
}

/* Update first cell background on row hover */
tr:hover td:first-child {
    background-color: #f1f7ff !important;
}

/* Subtle right border shadow for sticky column separation */
thead th:first-child::after,
tbody td:first-child::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 6px;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0));
    pointer-events: none;
}

/* Default Column Widths & Min-Widths to Prevent Squeezing */
th[data-col-key="code"] {
    min-width: 90px;
    width: 100px;
}
th[data-col-key="department_name"] {
    min-width: 180px;
    width: 220px;
}
th[data-col-key="team"] {
    min-width: 65px;
    width: 70px;
}
th[data-col-key="plan_month"] {
    min-width: 90px;
    width: 100px;
}
th[data-col-key="actual_audit_date"],
th[data-col-key="due_capa_date"],
th[data-col-key="received_capa_date"],
th[data-col-key="effective_date"],
th[data-col-key="next_review"],
th[data-col-key="exp_date"],
th[data-col-key="start_date"],
th[data-col-key="end_date"] {
    min-width: 110px;
    width: 120px;
}
th[data-col-key="check_today"] {
    min-width: 150px;
    width: 170px;
}
th[data-col-key="status"],
th[data-col-key="status2"],
th[data-col-key="lifecycle"] {
    min-width: 110px;
    width: 120px;
}
th[data-col-key="notes_remark"] {
    min-width: 200px;
    width: 260px;
}
th[data-col-key="doc_name"] {
    min-width: 200px;
    width: 260px;
}
th[data-col-key="rev_no"] {
    min-width: 80px;
    width: 85px;
}
th[data-col-key="validity_period"] {
    min-width: 115px;
    width: 130px;
}
th[data-col-key="doc_type"] {
    min-width: 100px;
    width: 120px;
}
th[data-col-key="logbook_name"] {
    min-width: 200px;
    width: 260px;
}
th[data-col-key="location"] {
    min-width: 150px;
    width: 180px;
}
th[data-col-key="username"] {
    min-width: 150px;
    width: 180px;
}
th[data-col-key="role"] {
    min-width: 100px;
    width: 120px;
}
th[data-col-key="created_at"] {
    min-width: 120px;
    width: 140px;
}
th[data-col-key="actions"] {
    min-width: 90px;
    width: 100px;
}

/* Column Resizing Handle */
th {
    position: relative;
}

.resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    user-select: none;
    z-index: 20;
    transition: background-color var(--transition-fast);
}

.resize-handle:hover,
.resize-handle.resizing {
    background-color: hsl(var(--primary));
}

/* Allow the department name and highlight details to wrap nicely */
table td:nth-child(2), 
table th:nth-child(2) {
    white-space: normal !important;
    min-width: 180px;
    max-width: 260px;
}

/* Allow notes and remarks to wrap properly to save horizontal space */
table td:nth-child(10),
table th:nth-child(10) {
    white-space: normal !important;
    min-width: 150px;
    max-width: 250px;
}

thead th {
    position: sticky;
    top: 0;
    background: #f1f5f9; /* Premium light slate header background */
    color: hsl(var(--text-primary)); /* High-contrast dark text */
    font-weight: 700;
    font-size: 12px;
    text-transform: none;
    letter-spacing: 0.5px;
    padding: 14px 10px;
    border-bottom: 2px solid #e2e8f0; /* Crisp gray border separator */
    user-select: none;
    z-index: 10;
    /* Defensive Layout default column sizing */
    width: 120px;
    min-width: 100px;
}

thead th.sortable {
    cursor: pointer;
    transition: all var(--transition-fast);
}

thead th.sortable:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.04);
}

.sort-icon {
    font-size: 11px;
    opacity: 0.4;
    margin-left: 4px;
}

td {
    padding: 12px 8px;
    border-bottom: 1px solid #e2e8f0; /* Crisp light gray border separators between rows */
    font-size: 13px;
    vertical-align: middle;
    color: hsl(var(--text-secondary));
}

tr {
    transition: all var(--transition-fast);
}

tr:hover {
    background-color: rgba(37, 99, 235, 0.04); /* Beautiful soft royal blue hover indicator */
    box-shadow: inset 3px 0 0 0 hsl(var(--primary));
}

.text-center { text-align: center; }
.py-4 { padding-top: 24px; padding-bottom: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mr-auto { margin-right: auto; }
.justify-center { justify-content: center; }

/* Status Badges */
.badge-status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    display: inline-block;
}

.bg-done {
    background: rgba(16, 185, 129, 0.1);
    color: #047857;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.bg-warn {
    background: rgba(245, 158, 11, 0.1);
    color: #b45309;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.bg-danger-badge {
    background: rgba(239, 68, 68, 0.1);
    color: #b91c1c;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.bg-plan-badge {
    background: rgba(14, 165, 233, 0.1);
    color: #0369a1;
    border: 1px solid rgba(14, 165, 233, 0.2);
}

.bg-purple-badge {
    background: rgba(139, 92, 246, 0.1);
    color: #6d28d9;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.bg-capa-badge {
    background: #e6f5ff;
    color: #0ea5e9;
    border: 1px solid #b9e6fb;
    box-shadow: 0 1px 2px rgba(14, 165, 233, 0.08);
    font-weight: 800;
}

.bg-no-capa-badge {
    background: #e4f8f3;
    color: #14b8a6;
    border: 1px solid #b8eadf;
    box-shadow: 0 1px 2px rgba(20, 184, 166, 0.08);
    font-weight: 800;
}

.bg-grey-badge {
    background: rgba(163, 163, 163, 0.1);
    color: #475569;
    border: 1px solid rgba(163, 163, 163, 0.2);
}

/* Overdue Warning highlight text */
.overdue-pulse {
    color: #f87171;
    font-weight: 700;
    font-size: 11px;
    animation: soft-pulse-warning 1.8s infinite;
}

@keyframes soft-pulse-warning {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.65; transform: scale(0.98); }
}

.progress-track {
    width: 90px;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 5px;
}

.progress-fill {
    height: 100%;
    background: hsl(var(--primary));
    transition: width 0.3s;
}

/* Modals Architecture */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px) brightness(0.8);
    -webkit-backdrop-filter: blur(10px) brightness(0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-card {
    background: hsl(var(--bg-surface));
    border: 1px solid hsl(var(--glass-border));
    width: 95%;
    max-width: 800px;
    border-radius: var(--border-radius-base);
    box-shadow: 0 25px 60px rgba(0,0,0,0.5);
    overflow: hidden;
    transform: scale(0.95);
    opacity: 0;
    transition: transform var(--transition-slow), opacity var(--transition-slow);
}

.modal-card.modal-sm {
    max-width: 480px;
}

.modal-overlay.active .modal-card {
    transform: scale(1);
    opacity: 1;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.btn-close-modal {
    background: transparent;
    border: none;
    color: hsl(var(--text-secondary));
    font-size: 20px;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.btn-close-modal:hover {
    color: #fff;
}

.modal-body {
    padding: 30px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    padding: 20px 30px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc; /* Beautiful soft slate gray footer background */
}

/* Modal Internal Tabs */
.modal-tabs {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 24px;
    gap: 12px;
}

.modal-tab-btn {
    background: transparent;
    border: none;
    color: hsl(var(--text-secondary));
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 16px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
}

.modal-tab-btn.active {
    color: hsl(var(--primary));
    border-bottom-color: hsl(var(--primary));
}

.modal-tab-content {
    display: none;
}

.modal-tab-content.active {
    display: block;
}

/* Modal Form Grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: hsl(var(--text-secondary));
}

.col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

/* Locked visual styles */
.bg-locked {
    background: #f1f5f9 !important;
    color: #94a3b8 !important;
    border-color: #e2e8f0 !important;
    cursor: not-allowed;
}

.help-text {
    font-size: 11px;
    color: hsl(var(--text-muted));
    margin-top: 2px;
}

.alert-info-glass {
    background: rgba(14, 165, 233, 0.08);
    border: 1px solid rgba(14, 165, 233, 0.15);
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.6;
    color: #cbd5e1;
}

.range-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.range-wrapper input[type="number"] {
    width: 70px;
    text-align: center;
}

.range-wrapper input[type="range"] {
    flex: 1;
    height: 6px;
    background: rgba(255,255,255,0.1);
    outline: none;
    border-radius: 3px;
}

/* Delete modal highlights */
.delete-warning-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.toast {
    position: fixed;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid hsl(var(--glass-border));
    padding: 12px 28px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    z-index: 2000;
    transition: bottom 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.active {
    bottom: 30px;
}

/* Actions cell alignment */
.td-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

.btn-edit {
    background: rgba(14, 165, 233, 0.1);
    color: #0369a1;
    border: 1px solid rgba(14, 165, 233, 0.2);
}

.btn-edit:hover {
    background: hsl(var(--primary));
    color: #020617;
    box-shadow: 0 4px 10px rgba(14, 165, 233, 0.2);
}

.btn-delete {
    background: rgba(239, 68, 68, 0.1);
    color: #b91c1c;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-delete:hover {
    background: hsl(var(--danger));
    color: #020617;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.2);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #ffffff;
    border-left: 1px solid #e2e8f0;
    border-top: 1px solid #e2e8f0;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 5px;
    border: 2px solid #ffffff;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* PDF Print Custom Styling Rules */
@media print {
    body {
        background: #fff !important;
        color: #000 !important;
        font-size: 11px !important;
        padding-bottom: 0 !important;
    }
    
    .navbar, 
    .controls-panel, 
    .modal-overlay, 
    .toast, 
    .background-blobs,
    .td-actions,
    .actions-header {
        display: none !important;
    }
    
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
        gap: 16px !important;
    }
    
    .stats-container {
        grid-template-columns: repeat(6, 1fr) !important;
        gap: 8px !important;
    }
    
    .stat-card {
        background: #fff !important;
        border: 1px solid #ccc !important;
        padding: 8px 12px !important;
        border-radius: 6px !important;
        color: #000 !important;
        box-shadow: none !important;
        height: auto !important;
    }
    
    .stat-card::before {
        display: none !important;
    }
    
    .stat-val {
        color: #000 !important;
        font-size: 20px !important;
    }
    
    .stat-icon {
        display: none !important;
    }
    
    .table-container {
        padding: 0 !important;
        background: none !important;
        border: none !important;
        box-shadow: none !important;
    }
    
    .table-responsive {
        overflow: visible !important;
        max-height: none !important;
        border: none !important;
    }
    
    table {
        width: 100% !important;
        border-collapse: collapse !important;
    }
    
    thead th {
        background: #f1f5f9 !important;
        color: #000 !important;
        border: 1px solid #94a3b8 !important;
        padding: 8px 10px !important;
    }
    
    td {
        border: 1px solid #cbd5e1 !important;
        padding: 6px 10px !important;
        color: #000 !important;
        background: #fff !important;
    }
    
    tr:hover {
        background: none !important;
    }
    
    .badge-status {
        border: 1px solid #444 !important;
        background: #fff !important;
        color: #000 !important;
        padding: 2px 6px !important;
        border-radius: 4px !important;
    }

    .overdue-pulse {
        animation: none !important;
        color: #ef4444 !important;
    }
    
    /* Display simple percentage printouts instead of track fills */
    .progress-track {
        border: 1px solid #ccc !important;
        background: #fff !important;
    }
    .progress-fill {
        background: #000 !important;
    }
}

/* ==========================================================================
   SIDEBAR LAYOUT & MULTI-MODULE NAVIGATION
   ========================================================================== */

.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100vw;
    position: relative;
    overflow-x: hidden;
}

.sidebar {
    width: 280px;
    min-width: 280px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: margin-left var(--transition-normal), transform var(--transition-normal);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid #e2e8f0;
}

.sidebar-logo .logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, hsl(var(--primary)) 0%, #4f46e5 100%);
    border-radius: 12px;
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.sidebar-logo .logo-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.sidebar-logo h1 {
    font-family: var(--font-outfit);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, hsl(var(--text-primary)), hsl(var(--primary)));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-logo p {
    font-size: 11px;
    color: hsl(var(--text-muted));
    margin-top: 1px;
}

.sidebar-menu {
    list-style: none;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    flex-grow: 1;
}

.menu-section {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 12px;
}

.menu-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: hsl(var(--text-muted));
    padding: 10px 12px 4px;
    font-weight: 700;
}

.menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    color: hsl(var(--text-secondary));
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.menu-item-link {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-item-chevron {
    font-size: 10px;
    transition: transform var(--transition-fast);
}

.menu-section.expanded .menu-item-chevron {
    transform: rotate(90deg);
}

.menu-item:hover {
    background: rgba(37, 99, 235, 0.05);
    color: hsl(var(--primary));
}

.sidebar-workspace-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 12px 2px 32px;
}

.sidebar-folder-group {
    list-style: none;
    margin: 5px 8px 8px;
    padding: 0;
}

.sidebar-folder-group-label {
    padding: 5px 12px 3px;
    color: #94a3b8;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .02em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-folder-group .submenu-item {
    min-width: 0;
}

.sidebar-table-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-table-actions {
    display: flex;
    gap: 4px;
    flex: 0 0 auto;
}

.sidebar-table-actions button {
    border: 0;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    font-size: 10px;
    padding: 2px 3px;
}

.sidebar-table-actions button:hover { color: #2563eb; }
.sidebar-table-actions button.danger:hover { color: #dc2626; }

.sidebar-action-btn {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #fff;
    color: hsl(var(--primary));
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    transition: var(--transition-fast);
}

.sidebar-action-btn:hover {
    border-color: #93c5fd;
    background: #eff6ff;
    transform: translateX(2px);
}

.sidebar-action-btn-accent {
    border-color: #a7f3d0;
    background: #ecfdf5;
    color: #047857;
}

.menu-item.active {
    background: linear-gradient(135deg, hsl(var(--primary)) 0%, #4f46e5 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.submenu {
    list-style: none;
    padding-left: 20px;
    display: none;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
}

.menu-section.expanded .submenu {
    display: flex;
}

.submenu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    color: hsl(var(--text-secondary));
    text-decoration: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.submenu-item:hover {
    color: hsl(var(--primary));
    background: rgba(37, 99, 235, 0.04);
}

.submenu-item.active {
    color: hsl(var(--primary));
    font-weight: 700;
    background: rgba(37, 99, 235, 0.08);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.main-wrapper {
    margin-left: 280px;
    transition: margin-left var(--transition-normal);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-layout.sidebar-collapsed .main-wrapper {
    margin-left: 0;
}

.form-group-module {
    display: none;
}
.form-group-module.show {
    display: block;
}

/* Print optimizations to hide sidebar */
@media print {
    .sidebar {
        display: none !important;
    }
    .app-layout {
        display: block !important;
    }
}

/* Sidebar Toggle Trigger Button & Transitions */
.btn-sidebar-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: hsl(var(--text-primary));
    transition: var(--transition-fast);
    margin-right: 14px;
}

.btn-sidebar-toggle:hover {
    background: rgba(37, 99, 235, 0.08);
    color: hsl(var(--primary));
}

.btn-sidebar-toggle svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
}

.sidebar {
    transition: margin-left var(--transition-normal), transform var(--transition-normal);
}

/* Collapsed state on desktop */
.app-layout.sidebar-collapsed .sidebar {
    margin-left: -280px;
}

/* Mobile responsive drawer styling & Layout Improvements */
@media (max-width: 1024px) {
    .navbar {
        align-items: flex-start;
        gap: 12px;
    }

    .navbar-user {
        flex: 1 1 auto;
        gap: 8px;
    }

    .navbar-actions {
        flex: 1 1 100%;
        justify-content: flex-start;
    }

    .navbar-actions .btn {
        flex: 0 1 auto;
    }

    .main-wrapper {
        margin-left: 0 !important;
    }
    
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        height: 100vh;
        z-index: 1000;
        margin-left: -280px; /* Hidden by default */
        box-shadow: 0 0 25px rgba(0, 0, 0, 0.15);
    }
    
    .app-layout.sidebar-expanded .sidebar {
        margin-left: 0;
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(15, 23, 42, 0.35);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 999;
        animation: fadeIn 0.2s ease;
    }
    
    .app-layout.sidebar-expanded .sidebar-overlay {
        display: block;
    }

    /* Controls Panel responsiveness */
    .controls-panel {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        padding: 16px;
    }

    .search-box {
        max-width: 100%;
        width: 100%;
    }

    .filters-group {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
        width: 100%;
    }

    .filter-item {
        flex: 1 1 140px;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .filter-item label {
        font-size: 10px;
        margin-bottom: 2px;
    }

    .filter-item select {
        width: 100%;
    }

    .action-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        align-items: center;
        width: 100%;
        margin-top: 4px;
    }

    .action-buttons .btn {
        flex: 1 1 auto;
        padding: 10px 16px;
    }

    /* Modal Grid reflow to single column on mobile/tablet */
    .form-grid {
        display: flex;
        flex-direction: column;
        gap: 14px;
    }

    .form-grid .col-4,
    .form-grid .col-6,
    .form-grid .col-8,
    .form-grid .col-12 {
        grid-column: span 12;
        width: 100% !important;
    }
}

/* Tiny Mobile screens styling (iPhone) */
@media (max-width: 768px) {
    .navbar {
        padding: 12px 16px;
    }

    .navbar-actions {
        width: 100%;
        justify-content: stretch;
    }

    .navbar-actions .btn {
        flex: 1 1 140px;
        min-width: 0;
        padding: 9px 12px;
    }

    .navbar span {
        display: none; /* Hide system version string to save space */
    }

    .main-content {
        padding: 0 8px 40px 8px;
        margin: 16px auto;
        gap: 16px;
    }

    /* Stats Container layout */
    .stats-container {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 10px;
    }

    .stat-card {
        padding: 12px;
        height: auto;
        min-height: 95px;
        border-radius: 12px;
    }

    .stat-icon {
        width: 28px;
        height: 28px;
        right: 10px;
        top: 10px;
        border-radius: 8px;
    }

    .stat-icon svg {
        width: 16px;
        height: 16px;
    }

    .stat-label {
        font-size: 11px;
    }

    .stat-val {
        font-size: 22px;
        margin-top: 2px;
    }

    .stat-desc {
        font-size: 9px;
    }

    .progress-bar-mini {
        margin-top: 8px;
    }

    /* Table Container padding reduction */
    .table-container {
        padding: 12px;
        border-radius: 12px;
    }

    .table-responsive {
        max-height: 50vh;
    }

    /* Modal styling for mobile */
    .modal-card {
        width: 98%;
        max-height: 90vh;
        border-radius: 16px;
    }

    .modal-header {
        padding: 16px 20px;
    }

    .modal-body {
        padding: 20px;
        max-height: 65vh;
    }

    .modal-footer {
        padding: 16px 20px;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ==================== NOTION STYLE COMPONENTS ==================== */

/* Side-Peek Panel Styling */
.side-peek-panel {
    position: fixed;
    top: 0;
    right: -450px; /* Initially hidden */
    width: 450px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-left: 1px solid #cbd5e1;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.08);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: right 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.side-peek-panel.active {
    right: 0;
}

.side-peek-header {
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.side-peek-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: hsl(var(--text-primary));
}

.btn-close-peek {
    border: none;
    background: none;
    font-size: 18px;
    cursor: pointer;
    color: hsl(var(--text-muted));
    transition: color 0.2s;
}

.btn-close-peek:hover {
    color: hsl(var(--danger));
}

.side-peek-tabs {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.peek-tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: hsl(var(--text-secondary));
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.peek-tab-btn:hover {
    background: rgba(0,0,0,0.02);
}

.peek-tab-btn.active {
    color: hsl(var(--primary));
    border-bottom-color: hsl(var(--primary));
}

.side-peek-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.peek-tab-content {
    display: none;
    height: 100%;
}

.peek-tab-content.active {
    display: block;
}

.peek-details-item {
    margin-bottom: 16px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 8px;
}

.peek-details-label {
    font-size: 11px;
    font-weight: 600;
    color: hsl(var(--text-muted));
    text-transform: uppercase;
}

.peek-details-value {
    font-size: 14px;
    color: hsl(var(--text-primary));
    margin-top: 4px;
    word-break: break-all;
}

.peek-history-item {
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
}

.peek-comment-item {
    padding: 10px;
    background: #f8fafc;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid #e2e8f0;
}

/* Kanban Board Styling */
.kanban-board {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding: 10px 0;
}

.kanban-column {
    flex: 1;
    min-width: 300px;
    background: rgba(248, 250, 252, 0.6);
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.kanban-column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-weight: 700;
    color: hsl(var(--text-primary));
    border-bottom: 2px solid hsl(var(--primary));
    padding-bottom: 6px;
}

.kanban-cards {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 350px;
}

.kanban-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.kanban-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.05);
}

/* Calendar Widget */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.calendar-day-header {
    text-align: center;
    font-weight: 600;
    color: hsl(var(--text-secondary));
    padding: 8px;
    background: #f1f5f9;
    border-radius: 4px;
}

.calendar-cell {
    min-height: 120px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px;
    background: #fff;
    display: flex;
    flex-direction: column;
}

.calendar-day-number {
    font-weight: 600;
    color: hsl(var(--text-muted));
    font-size: 12px;
    margin-bottom: 6px;
}

.calendar-event {
    font-size: 11px;
    background: rgba(37, 99, 235, 0.08);
    color: hsl(var(--primary));
    padding: 4px 8px;
    border-radius: 4px;
    margin-top: 4px;
    border-left: 3px solid hsl(var(--primary));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

/* Timeline View Widget */
.timeline-gantt {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.timeline-row {
    display: flex;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
    padding: 8px 0;
}

.timeline-label {
    width: 150px;
    font-weight: 600;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timeline-bar-wrapper {
    flex: 1;
    background: #f1f5f9;
    height: 24px;
    border-radius: 12px;
    position: relative;
}

.timeline-bar {
    position: absolute;
    height: 100%;
    border-radius: 12px;
    background: linear-gradient(135deg, hsl(var(--primary)) 0%, #6366f1 100%);
    color: white;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 700;
}

/* Timeline bars use a dedicated high-contrast palette. The table badges use
   intentionally pale fills, which become unreadable when reused here with
   white text. */
.gantt-bar {
    box-sizing: border-box;
    min-width: 0;
    color: #fff !important;
    border: 1px solid rgba(255, 255, 255, 0.32);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.16);
}

.gantt-bar-label {
    display: block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gantt-bar:hover,
.gantt-bar:focus-visible {
    z-index: 2;
    outline: 2px solid rgba(15, 23, 42, 0.28);
    outline-offset: 1px;
}

.gantt-bar.timeline-bar-done {
    background: #047857 !important;
}

.gantt-bar.timeline-bar-progress {
    background: #0369a1 !important;
}

.gantt-bar.timeline-bar-pending {
    background: #b45309 !important;
}

.gantt-bar.timeline-bar-danger {
    background: #b91c1c !important;
}

.gantt-bar.timeline-bar-muted {
    background: #475569 !important;
}

.gantt-bar.timeline-bar-default {
    background: #334155 !important;
}

/* ==================== NOTION DATABASE EXPERIENCE ==================== */
.database-view {
    min-width: 0;
    animation: fadeIn 180ms ease-out;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.notion-view-switcher {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
}

.view-switch-btn {
    border: 0;
    background: transparent;
    color: #64748b;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    padding: 7px 10px;
    border-radius: 7px;
    cursor: pointer;
    transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.view-switch-btn:hover,
.view-switch-btn.active {
    background: #fff;
    color: #1d4ed8;
    box-shadow: 0 1px 4px rgba(15, 23, 42, .12);
}

.saved-view-select {
    min-width: 142px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #fff;
    padding: 8px 10px;
    color: #334155;
    font: inherit;
    font-size: 12px;
}

.btn-save-view { white-space: nowrap; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.list-feed { display: flex; flex-direction: column; gap: 8px; }
.chart-controls { display: flex; gap: 8px; margin-bottom: 16px; }
.chart-controls select { border: 1px solid #dbe3ef; border-radius: 8px; padding: 8px 10px; background: #fff; }
.btn-reset-filters { align-self: flex-end; white-space: nowrap; }
.advanced-filter-disclosure { width: 100%; margin-top: 10px; }
.advanced-filter-disclosure summary { display: inline-flex; cursor: pointer; color: #475569; font-size: 12px; font-weight: 700; padding: 4px 0; }
.advanced-filter-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; width: 100%; margin-top: 8px; }
.advanced-filter-row select, .advanced-filter-row input { border: 1px solid #dbe3ef; border-radius: 8px; background: #fff; padding: 8px 10px; font: inherit; font-size: 12px; color: #334155; }
.advanced-filter-row input { min-width: 140px; }
.active-filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 9px; background: #eff6ff; color: #1d4ed8; font-size: 11px; font-weight: 600; }
.filter-chip button { border: 0; background: transparent; color: inherit; cursor: pointer; padding: 0; font-size: 14px; line-height: 1; }
.records-pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 4px 4px; color: #64748b; font-size: 12px; }
.records-pagination-actions { display: flex; align-items: center; gap: 8px; }
.records-pagination-actions .btn:disabled { opacity: .45; cursor: not-allowed; }
.records-loading, .records-error, .records-empty { padding: 42px 20px; text-align: center; color: #64748b; }
.records-error { color: #b91c1c; }
.records-error button { margin-top: 12px; }

.side-peek-subtitle { margin-top: 3px; color: #64748b; font-size: 11px; }
.page-editor-toolbar { display: flex; gap: 6px; margin-bottom: 12px; }
.page-editor-toolbar button { border: 1px solid #dbe3ef; background: #fff; color: #334155; border-radius: 7px; padding: 6px 9px; font-size: 12px; cursor: pointer; }
.page-editor-toolbar button:hover { border-color: #93c5fd; color: #1d4ed8; background: #eff6ff; }
.peek-blocks-editor { display: flex; flex-direction: column; gap: 8px; min-height: 140px; }
.notion-block { display: flex; align-items: flex-start; gap: 8px; }
.notion-block .block-handle { color: #94a3b8; padding-top: 8px; user-select: none; }
.notion-block [contenteditable] { flex: 1; min-height: 36px; outline: none; border-radius: 7px; padding: 8px 10px; border: 1px solid transparent; line-height: 1.55; }
.notion-block [contenteditable]:focus { border-color: #bfdbfe; background: #f8fbff; }
.notion-block h3 { margin: 0; font-size: 18px; }
.notion-block.todo input { margin-top: 12px; accent-color: #2563eb; }
.notion-block.todo [contenteditable] { min-height: 32px; }
.notion-block.dragging { opacity: .45; }
.notion-block.drag-over { border-top: 2px solid #2563eb; padding-top: 6px; }
.block-move { opacity: 0; border: 0; background: transparent; color: #64748b; cursor: pointer; padding: 7px 2px; }
.notion-block:hover .block-move, .block-move:focus { opacity: 1; }
.block-delete { opacity: 0; border: 0; background: transparent; color: #94a3b8; cursor: pointer; padding: 7px 4px; }
.notion-block:hover .block-delete, .block-delete:focus { opacity: 1; }
.page-save-btn { margin-top: 16px; width: 100%; }
.peek-comment-composer { border-top: 1px solid #e2e8f0; margin-top: 16px; padding-top: 14px; }
.peek-comment-composer textarea { width: 100%; resize: vertical; border: 1px solid #dbe3ef; border-radius: 8px; padding: 9px; font: inherit; font-size: 13px; }
.peek-comment-composer .btn { margin-top: 8px; }

/* Central File Manager */
.file-manager-view {
    min-width: 0;
}

.file-manager-shell {
    padding: 22px;
    background: rgba(255, 255, 255, 0.94);
}

.file-manager-header,
.file-manager-toolbar,
.file-manager-content-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-manager-header {
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.file-manager-header h2 {
    margin: 0;
    color: hsl(var(--text-primary));
    font-size: 22px;
}

.file-manager-header p {
    margin: 5px 0 0;
    color: hsl(var(--text-muted));
    font-size: 13px;
}

.file-manager-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.file-manager-toolbar {
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
}

.file-manager-toolbar label {
    color: #475569;
    font-size: 12px;
    font-weight: 700;
}

.file-manager-toolbar select {
    min-width: 210px;
    padding: 8px 10px;
}

.file-manager-search {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 220px;
    min-width: 160px;
    padding: 0 10px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #fff;
    color: #64748b;
}

.file-manager-search input {
    width: 100%;
    min-width: 0;
    padding: 9px 4px;
    border: 0;
    outline: 0;
    background: transparent;
}

.file-manager-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 8px 2px;
    color: #64748b;
    font-size: 13px;
}

.file-manager-breadcrumb button {
    padding: 3px 6px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: #2563eb;
    cursor: pointer;
}

.file-manager-breadcrumb button:hover { background: #eff6ff; }

.file-manager-layout {
    display: grid;
    grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
    min-height: 420px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

.file-manager-folder-panel {
    padding: 14px;
    border-right: 1px solid #e2e8f0;
    background: #f8fafc;
}

.file-manager-panel-title {
    margin-bottom: 10px;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.file-manager-folder-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    padding: 8px 9px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #334155;
    font: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

.file-manager-folder-item:hover,
.file-manager-folder-item.active { background: #e0edff; color: #1d4ed8; }

.file-manager-folder-item .folder-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-manager-folder-actions,
.file-manager-row-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.file-manager-icon-btn {
    padding: 4px 6px;
    border: 1px solid #dbe3ef;
    border-radius: 6px;
    background: #fff;
    color: #475569;
    cursor: pointer;
}

.file-manager-icon-btn:hover { border-color: #93c5fd; color: #1d4ed8; }

.file-manager-content { min-width: 0; background: #fff; }

.file-manager-content-header {
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid #e2e8f0;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
}

.file-manager-list { overflow-x: auto; }

.file-manager-table {
    width: 100%;
    min-width: 620px;
    border-collapse: collapse;
}

.file-manager-table th,
.file-manager-table td {
    padding: 11px 14px;
    border-bottom: 1px solid #eef2f7;
    text-align: left;
    vertical-align: middle;
    font-size: 13px;
}

.file-manager-table th { color: #64748b; font-size: 11px; text-transform: uppercase; }
.file-manager-table tr:hover td { background: #f8fbff; }
.file-manager-file-name { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #1e3a8a; font-weight: 700; }
.file-manager-empty { padding: 48px 16px; color: #94a3b8; text-align: center; }

@media (max-width: 760px) {
    .file-manager-shell { padding: 14px; }
    .file-manager-header { align-items: flex-start; flex-direction: column; }
    .file-manager-actions { justify-content: flex-start; }
    .file-manager-toolbar { align-items: stretch; flex-direction: column; }
    .file-manager-toolbar select { width: 100%; min-width: 0; }
    .file-manager-layout { grid-template-columns: 1fr; }
    .file-manager-folder-panel { border-right: 0; border-bottom: 1px solid #e2e8f0; }
}

@media (max-width: 900px) {
    .notion-view-switcher { max-width: 100%; overflow-x: auto; }
    .view-switch-btn { flex: 0 0 auto; }
    .saved-view-select { min-width: 120px; }
    .side-peek-panel { width: min(94vw, 450px); }
    .records-pagination { align-items: flex-start; flex-direction: column; }
    .advanced-filter-row > * { max-width: 100%; flex: 1 1 130px; }
}

