:root {
    /* Enterprise Colors */
    --primary: #0284c7; /* PWA Blue */
    --primary-light: #e0f2fe;
    --primary-dark: #0369a1;
    --secondary: #0f172a; /* Slate 900 for headings */
    --bg-main: #f4f7f9; /* Professional soft gray */
    --bg-card: #ffffff;
    --border: #e2e8f0;
    
    /* Text Colors */
    --text-main: #334155;
    --text-muted: #64748b;
    --text-heading: #0f172a;
    
    /* Status Badge Colors (Soft Pills) */
    --status-todo-bg: #f1f5f9; --status-todo-text: #475569;
    --status-survey-bg: #e0f2fe; --status-survey-text: #0284c7;
    --status-design-bg: #f3e8ff; --status-design-text: #7e22ce;
    --status-designed-bg: #fce7f3; --status-designed-text: #db2777;
    --status-build-bg: #fef3c7; --status-build-text: #d97706;
    --status-done-bg: #d1fae5; --status-done-text: #059669;
    --status-cancel-bg: #fee2e2; --status-cancel-text: #dc2626;

    /* Professional Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Kanit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Navbar (Clean, White, Professional) */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-heading);
    letter-spacing: -0.01em;
}

.logo i {
    font-size: 1.6rem;
    color: var(--primary);
}

.view-switcher {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

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

.view-switcher select {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-main);
    color: var(--text-heading);
    font-size: 0.9rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    transition: all 0.2s;
}

.view-switcher select:hover, .view-switcher select:focus {
    border-color: var(--primary);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Buttons */
.btn-primary, .btn-secondary {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

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

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

.btn-secondary {
    background: #f1f5f9;
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #e2e8f0;
    color: var(--text-heading);
}

/* Main Content Area */
#app-content {
    padding: 2.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* Dashboard Metrics (Enterprise Style) */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.metric-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    min-height: 110px;
}

.border-left-blue { border-left: 4px solid var(--primary); }
.border-left-orange { border-left: 4px solid #f59e0b; }
.border-left-purple { border-left: 4px solid #8b5cf6; }
.border-left-green { border-left: 4px solid #10b981; }

.metric-card-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.metric-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.metric-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-heading);
}

.metric-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-heading);
    line-height: 1;
}

.metric-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    background: transparent;
}

.icon-blue { color: var(--primary); }
.icon-orange { color: #d97706; }
.icon-purple { color: #8b5cf6; }
.icon-green { color: #059669; }

/* Dashboard Middle Panels */
.dashboard-middle-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.panel-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.panel-header {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Custom Chart Layout */
.chart-container-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.chart-canvas-wrapper {
    position: relative;
    width: 150px;
    height: 150px;
    flex-shrink: 0;
}

.chart-center-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.chart-center-text .percent {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-heading);
    line-height: 1;
}

.chart-center-text .label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.chart-custom-legend {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    flex: 1;
}

.legend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
}

.legend-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-main);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-percent {
    font-weight: 600;
    color: var(--text-muted);
}

/* Team List */
.team-list {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.team-member {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.team-member-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.team-member-name {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-heading);
}

.team-member-name img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    background: #e2e8f0;
}

.team-member-stats {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.team-progress-bar {
    width: 100%;
    height: 6px;
    background: #f1f5f9;
    border-radius: 4px;
    overflow: hidden;
}

.team-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* Data Table */
.table-container {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

th {
    background: #f8fafc;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

tbody tr {
    transition: background-color 0.15s;
}

tbody tr:hover {
    background-color: #f8fafc;
}

td strong {
    color: var(--text-heading);
    font-weight: 500;
}

/* Progress Bar */
.progress-wrapper {
    width: 100%;
    max-width: 150px;
    height: 8px;
    background: #f1f5f9;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    margin-top: 4px;
}

.progress-plan {
    position: absolute;
    top: 0; left: 0; height: 100%;
    background: #cbd5e1;
    z-index: 1;
}

.progress-actual {
    position: absolute;
    top: 0; left: 0; height: 100%;
    background: var(--primary);
    z-index: 2;
}

.progress-actual.delayed {
    background: #ef4444;
}

/* Kanban Board */
.kanban-board {
    display: flex;
    gap: 1.25rem;
    overflow-x: auto;
    padding-bottom: 2rem;
    height: calc(100vh - 140px);
}

.kanban-column {
    background: #f8fafc;
    border-radius: var(--radius-md);
    min-width: 300px;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    max-height: 100%;
    border: 1px solid var(--border);
}

.column-header {
    padding: 1rem;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-heading);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: #f1f5f9;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.task-count {
    background: var(--border);
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.column-body {
    padding: 1rem;
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Task Card */
.task-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    cursor: grab;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.task-card:hover {
    box-shadow: var(--shadow-md);
    border-color: #cbd5e1;
}

.task-card:active {
    cursor: grabbing;
}

.task-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    align-items: center;
}

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

.task-branch {
    font-size: 0.75rem;
    color: var(--primary-dark);
    background: var(--primary-light);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.task-title {
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-heading);
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.task-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Modal styling */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.4);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
    animation: fadeIn 0.15s ease-out;
}

.modal-content {
    background: var(--bg-card);
    width: 90%;
    max-width: 800px;
    border-radius: var(--radius-md);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

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

.modal-header h2 {
    font-size: 1.1rem;
    color: var(--text-heading);
    font-weight: 600;
}

.close-btn {
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}
.close-btn:hover { color: var(--text-main); }

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background: #f8fafc;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.form-section {
    margin-bottom: 2rem;
}

.form-section h3 {
    margin-bottom: 1rem;
    font-size: 1rem;
    color: var(--text-heading);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-section h3::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 16px;
    background: var(--primary);
    border-radius: 2px;
}

.form-row {
    display: flex;
    gap: 1.25rem;
    margin-bottom: 1rem;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
}

.form-group input, .form-group select {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--text-main);
    outline: none;
    transition: all 0.2s;
    background: var(--bg-card);
}

.form-group input:focus, .form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Badges (Professional Soft Pills) */
.badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    display: inline-block;
}

.badge.ยังไม่ดำเนินการ { background: var(--status-todo-bg); color: var(--status-todo-text); }
.badge.สำรวจแล้ว { background: var(--status-survey-bg); color: var(--status-survey-text); }
.badge.กำลังทำแบบ-ประมาณราคา { background: var(--status-design-bg); color: var(--status-design-text); }
.badge.แบบก่อสร้าง-ประมาณราคาแล้วเสร็จ { background: var(--status-designed-bg); color: var(--status-designed-text); }
.badge.กำลังก่อสร้าง { background: var(--status-build-bg); color: var(--status-build-text); }
.badge.ส่งมอบงานแล้ว { background: var(--status-done-bg); color: var(--status-done-text); }
.badge.ยกเลิกโครงการ { background: var(--status-cancel-bg); color: var(--status-cancel-text); }

/* Custom scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
