/* ==========================================
   Project Control & Procurement Design System
   ========================================== */

/* 1. CSS Custom Properties for Themes */
:root {
    /* Color Palette - HSL based */
    --primary-h: 243;
    --primary-s: 75%;
    --primary-l: 59%;
    --primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
    --primary-hover: hsl(var(--primary-h), var(--primary-s), calc(var(--primary-l) - 8%));
    
    --teal-h: 173;
    --teal-s: 80%;
    --teal-l: 40%;
    --teal: hsl(var(--teal-h), var(--teal-s), var(--teal-l));
    --teal-hover: hsl(var(--teal-h), var(--teal-s), calc(var(--teal-l) - 8%));

    --danger-h: 360;
    --danger-s: 83%;
    --danger-l: 62%;
    --danger: hsl(var(--danger-h), var(--danger-s), var(--danger-l));
    
    --warning-h: 38;
    --warning-s: 92%;
    --warning-l: 50%;
    --warning: hsl(var(--warning-h), var(--warning-s), var(--warning-l));

    --success-h: 142;
    --success-s: 70%;
    --success-l: 45%;
    --success: hsl(var(--success-h), var(--success-s), var(--success-l));

    /* Font Families */
    --font-sans: 'Inter', 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Variables (Default) */
html.dark, body.dark {
    --bg-app: #080c14;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-solid: #111827;
    --bg-sidebar: #0f1524;
    --bg-header: rgba(8, 12, 20, 0.8);
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-inverse: #0f172a;
    --glass-opacity: 0.05;
    --card-glow: rgba(79, 70, 229, 0.15);
}

/* Light Mode Variables */
html.light, body.light {
    --bg-app: #f4f6fa;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-solid: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-header: rgba(244, 246, 250, 0.8);
    --border: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.15);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-inverse: #f8fafc;
    --glass-opacity: 0.02;
    --card-glow: rgba(79, 70, 229, 0.05);
}

/* Reset & Basics */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-app);
    color: var(--text-main);
    overflow-x: hidden;
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-brand {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--teal));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.brand-icon svg {
    width: 24px;
    height: 24px;
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(to right, var(--text-main), var(--teal));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.sidebar-nav {
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.nav-item svg {
    width: 20px;
    height: 20px;
    transition: var(--transition);
}

.nav-item:hover {
    color: var(--text-main);
    background-color: var(--border);
}

.nav-item.active {
    color: white;
    background-color: var(--primary);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.nav-item.active svg {
    transform: scale(1.05);
}

.sidebar-footer {
    padding: 20px 16px;
    border-top: 1px solid var(--border);
}

.theme-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    background-color: var(--border);
    border: 1px solid transparent;
    color: var(--text-main);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    font-family: var(--font-sans);
    transition: var(--transition);
}

.theme-btn:hover {
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.sun-icon, .moon-icon {
    display: flex;
    align-items: center;
}

.sun-icon svg, .moon-icon svg {
    width: 18px;
    height: 18px;
}

html.dark .sun-icon { display: block; }
html.dark .moon-icon { display: none; }
html.light .sun-icon { display: none; }
html.light .moon-icon { display: block; }

/* Main Content Workspace */
.main-content {
    flex: 1;
    margin-left: 280px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.main-header {
    height: 80px;
    padding: 0 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-header);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-main);
}

.mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
}

.mobile-toggle svg {
    width: 24px;
    height: 24px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--teal), var(--primary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    border: 2px solid var(--border);
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Views Container */
.view-container {
    padding: 40px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.app-view {
    display: none;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.app-view.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* KPI Dashboard Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.kpi-card {
    background-color: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 3px;
    background: transparent;
    transition: var(--transition);
}

.kpi-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
    box-shadow: 0 10px 30px -10px var(--card-glow);
}

.kpi-card:hover::before {
    background: linear-gradient(to right, var(--primary), var(--teal));
}

.kpi-icon-wrapper {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.kpi-icon-wrapper svg {
    width: 24px;
    height: 24px;
}

.kpi-icon-wrapper.blue { background-color: rgba(79, 70, 229, 0.15); color: #818cf8; }
.kpi-icon-wrapper.green { background-color: rgba(16, 185, 129, 0.15); color: #34d399; }
.kpi-icon-wrapper.teal { background-color: rgba(13, 148, 136, 0.15); color: #2dd4bf; }
.kpi-icon-wrapper.orange { background-color: rgba(245, 158, 11, 0.15); color: #fbbf24; }

html.light .kpi-icon-wrapper.blue { background-color: rgba(79, 70, 229, 0.08); color: var(--primary); }
html.light .kpi-icon-wrapper.green { background-color: rgba(16, 185, 129, 0.08); color: var(--success); }
html.light .kpi-icon-wrapper.teal { background-color: rgba(13, 148, 136, 0.08); color: var(--teal); }
html.light .kpi-icon-wrapper.orange { background-color: rgba(245, 158, 11, 0.08); color: #d97706; }

.kpi-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.kpi-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.kpi-value {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* Alerts Section */
.dashboard-section {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.text-red {
    color: var(--danger);
}

.alerts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

.alert-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.alert-item {
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.alert-item.procurement {
    background: rgba(245, 158, 11, 0.06);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.alert-meta {
    font-weight: 500;
}

.alert-date {
    font-weight: 700;
    color: var(--danger);
}

.alert-item.procurement .alert-date {
    color: var(--warning);
}

/* Tables styling */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.85rem;
}

.data-table th {
    background-color: rgba(255, 255, 255, 0.03);
    padding: 14px 18px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

html.light .data-table th {
    background-color: rgba(0, 0, 0, 0.02);
}

.data-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    vertical-align: middle;
}

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

.data-table tbody tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

html.light .data-table tbody tr:hover td {
    background-color: rgba(0, 0, 0, 0.01);
}

.td-actions {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: var(--transition);
    border: 1px solid transparent;
}

.btn svg {
    width: 16px;
    height: 16px;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.btn-teal {
    background-color: var(--teal);
    color: white;
}

.btn-teal:hover {
    background-color: var(--teal-hover);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.25);
}

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text-main);
}

.btn-outline:hover {
    background-color: var(--border);
    border-color: var(--border-hover);
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon svg {
    width: 15px;
    height: 15px;
}

.btn-edit {
    color: #38bdf8;
    background-color: rgba(56, 189, 248, 0.1);
}
.btn-edit:hover {
    background-color: rgba(56, 189, 248, 0.2);
}

.btn-delete {
    color: var(--danger);
    background-color: rgba(239, 68, 68, 0.1);
}
.btn-delete:hover {
    background-color: rgba(239, 68, 68, 0.2);
}

/* Tags / Badges */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    border: 1px solid transparent;
}

.tag-gray { background: rgba(148, 163, 184, 0.1); color: #94a3b8; border-color: rgba(148, 163, 184, 0.2); }
.tag-blue { background: rgba(56, 189, 248, 0.1); color: #38bdf8; border-color: rgba(56, 189, 248, 0.2); }
.tag-green { background: rgba(52, 211, 153, 0.1); color: #34d399; border-color: rgba(52, 211, 153, 0.2); }
.tag-orange { background: rgba(251, 191, 36, 0.1); color: #fbbf24; border-color: rgba(251, 191, 36, 0.2); }
.tag-red { background: rgba(248, 113, 113, 0.1); color: #f87171; border-color: rgba(248, 113, 113, 0.2); }
.tag-indigo { background: rgba(129, 140, 248, 0.1); color: #818cf8; border-color: rgba(129, 140, 248, 0.2); }

/* Progress Mini elements */
.progress-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.progress-text {
    min-width: 32px;
    font-weight: 600;
}

.progress-bar-bg {
    flex: 1;
    height: 8px;
    background-color: var(--border);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(to right, var(--primary), var(--teal));
    border-radius: 9999px;
    transition: width 0.4s ease;
}

/* Projects list layout (Horizontal rows) */
.projects-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 24px;
}

.project-row-item {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    transition: var(--transition);
}

.project-row-item:hover {
    transform: translateY(-2px);
    border-color: var(--border-hover);
    box-shadow: 0 8px 30px -10px var(--card-glow);
}

.proj-row-info {
    flex: 2.2;
    min-width: 250px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.proj-row-title-block {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.proj-row-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    text-decoration: none;
    transition: var(--transition);
}

.proj-row-title:hover {
    color: var(--primary);
}

.proj-row-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 420px;
}

.proj-row-meta {
    flex: 1.3;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.78rem;
}

.proj-row-progress {
    flex: 1.8;
    min-width: 220px;
}

.proj-row-status {
    flex: 0.8;
    min-width: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.proj-row-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Project Detail View specific */
.detail-header-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 30px;
    display: flex;
    justify-content: space-between;
    gap: 40px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.detail-meta {
    flex: 2;
    min-width: 300px;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    margin-bottom: 16px;
    padding: 0;
    transition: var(--transition);
}

.btn-back:hover {
    color: var(--text-main);
}

.btn-back svg {
    width: 16px;
    height: 16px;
}

.detail-title-block {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.detail-title {
    font-size: 1.4rem;
    font-weight: 700;
}

.detail-desc {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.detail-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    font-size: 0.85rem;
}

.detail-stats {
    flex: 1;
    min-width: 250px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.detail-stat-box {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
}

html.light .detail-stat-box {
    background: rgba(0, 0, 0, 0.01);
}

.detail-stat-box .label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 500;
}

.detail-stat-box .val {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
}

.detail-stat-box .text-blue { color: #38bdf8; }
.detail-stat-box .text-green { color: #34d399; }

.detail-stat-box .progress-bar-bg {
    margin-top: 8px;
}

/* Tabs */
.tab-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.tab-header {
    display: flex;
    border-bottom: 1px solid var(--border);
    gap: 8px;
}

.tab-btn {
    background: none;
    border: none;
    padding: 14px 20px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 600;
    font-family: var(--font-sans);
    border-bottom: 2px solid transparent;
    transition: var(--transition);
}

.tab-btn:hover {
    color: var(--text-main);
}

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

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease forwards;
}

.action-bar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.tab-section-title {
    font-size: 1rem;
    font-weight: 700;
}

/* Gantt Chart Custom Layout */
.gantt-chart-container {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: auto;
    max-height: 480px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.gantt-timeline-header {
    display: grid;
    grid-template-columns: 240px 1fr;
    border-bottom: 1px solid var(--border);
    background-color: rgba(255, 255, 255, 0.02);
    position: sticky;
    top: 0;
    z-index: 10;
}

html.light .gantt-timeline-header {
    background-color: rgba(0, 0, 0, 0.01);
}

.gantt-col-name {
    padding: 16px;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-right: 1px solid var(--border);
}

.gantt-col-timeline {
    display: flex;
    position: relative;
    min-width: 600px;
}

.gantt-time-segment {
    flex: 1;
    text-align: center;
    padding: 16px 8px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    border-right: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gantt-time-segment:last-child {
    border-right: none;
}

.gantt-rows {
    min-width: 840px; /* 240 + 600 */
}

.gantt-row {
    display: grid;
    grid-template-columns: 240px 1fr;
    border-bottom: 1px solid var(--border);
}

.gantt-row:last-child {
    border-bottom: none;
}

.gantt-row-label {
    padding: 16px;
    font-weight: 600;
    font-size: 0.8rem;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background-color: rgba(255, 255, 255, 0.005);
}

.gantt-row-label span.assignee {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
}

.gantt-row-bar-area {
    padding: 16px 0;
    position: relative;
    min-width: 600px;
    background-size: calc(100% / var(--segments-count, 4)) 100%;
    /* Create grid lines using gradient background */
    background-image: linear-gradient(to right, var(--border) 1px, transparent 1px);
}

.gantt-bar {
    position: absolute;
    height: 28px;
    background: linear-gradient(135deg, var(--primary), var(--teal));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    padding: 0 10px;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: var(--transition);
}

.gantt-bar:hover {
    transform: scaleY(1.05);
    filter: brightness(1.1);
    box-shadow: 0 6px 12px rgba(79, 70, 229, 0.25);
    z-index: 5;
}

.gantt-bar-progress {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.15);
    pointer-events: none;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(3, 7, 18, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background-color: var(--bg-card-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 580px;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.modal-box.modal-lg {
    max-width: 780px;
}

.modal-overlay.active .modal-box {
    transform: scale(1);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.6rem;
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-main);
}

.modal-form {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    max-height: 80vh;
    overflow-y: auto;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group.md-8 { grid-column: span 1; }
.form-group.md-4 { grid-column: span 1; }

@media(min-width: 768px) {
    .modal-form .form-row {
        grid-template-columns: repeat(12, 1fr);
    }
    .modal-form .form-row > .form-group {
        grid-column: span 6;
    }
    .modal-form .form-row > .form-group.md-8 {
        grid-column: span 8;
    }
    .modal-form .form-row > .form-group.md-4 {
        grid-column: span 4;
    }
}

.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-input {
    background-color: var(--bg-app);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-family: var(--font-sans);
    transition: var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid var(--border);
    padding-top: 20px;
    margin-top: 10px;
}

/* Search Filters UI */
.view-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.search-filters {
    display: flex;
    gap: 12px;
    flex: 1;
    max-width: 600px;
}

.search-filters .form-input {
    flex: 1;
}

/* Sidebar Responsive details */
@media (max-width: 1024px) {
    .sidebar {
        left: -280px;
    }
    .sidebar.active {
        left: 0;
    }
    .main-content {
        margin-left: 0;
    }
    .mobile-toggle {
        display: block;
        margin-right: 16px;
    }
    .main-header {
        padding: 0 24px;
    }
    .view-container {
        padding: 24px;
    }
    .project-row-item {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    .proj-row-desc {
        max-width: none;
        white-space: normal;
    }
}

@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr !important;
    }
    .form-row > .form-group {
        grid-column: span 1 !important;
    }
    .kpi-grid {
        grid-template-columns: 1fr;
    }
    .detail-header-card {
        padding: 20px;
        flex-direction: column;
    }
    .view-header-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .search-filters {
        flex-direction: column;
        max-width: none;
    }
}

/* UI/UX Utility overrides */
.bg-green-soft {
    background-color: rgba(16, 185, 129, 0.08) !important;
}
.bg-green-soft:hover {
    background-color: rgba(16, 185, 129, 0.12) !important;
}
.text-xs {
    font-size: 0.75rem !important;
}
.text-xs th, .text-xs td {
    padding: 8px 12px !important;
}
.text-teal {
    color: var(--teal) !important;
}
.btn-teal {
    background-color: var(--teal) !important;
    color: white !important;
}
.btn-teal:hover {
    background-color: #0d9488 !important;
}
.btn-xs {
    padding: 4px 8px !important;
    font-size: 0.75rem !important;
    border-radius: var(--radius-sm) !important;
}
.mb-6 {
    margin-bottom: 1.5rem !important;
}
.mt-6 {
    margin-top: 1.5rem !important;
}
.md-3 {
    grid-column: span 3 !important;
}
.md-6 {
    grid-column: span 6 !important;
}

