/* ========== Design System Tokens ========== */
:root {
    /* Backgrounds */
    --bg-color: #f0f4f8;
    --card-bg: rgba(255, 255, 255, 0.82);
    --card-bg-solid: #ffffff;
    
    /* Text Colors */
    --text-primary: #0f172a;      /* Slate 900 */
    --text-secondary: #475569;    /* Slate 600 */
    --text-muted: #94a3b8;       /* Slate 400 */
    
    /* Accent & Semantic Colors */
    --accent-blue: #2563eb;       /* Blue 600 */
    --accent-blue-light: rgba(37, 99, 235, 0.08);
    --success: #16a34a;          /* Green 600 - Match Guide */
    --success-light: rgba(22, 163, 74, 0.1);
    --warning: #ca8a04;          /* Yellow 700 - Match Guide */
    --warning-light: rgba(202, 138, 4, 0.1);
    --orange: #ea580c;           /* Orange 600 - Match Guide */
    --orange-light: rgba(234, 88, 12, 0.1);
    --danger: #dc2626;           /* Red 600 - Match Guide */
    --danger-light: rgba(220, 38, 38, 0.1);
    
    /* Risk Levels (Section 3 of Guide) */
    --risk-1: #16a34a; /* Normal (Green) */
    --risk-2: #ca8a04; /* Watch (Yellow) */
    --risk-3: #ea580c; /* Risk (Orange) */
    --risk-4: #dc2626; /* High Risk (Red) */
    
    /* Effects */
    --glass: blur(20px);
    --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --card-shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -10px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    --cubic: cubic-bezier(0.34, 1.56, 0.64, 1);
    
    /* Radius */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
}

/* ========== Base Styles ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', 'Sarabun', sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, hsla(217, 91%, 60%, 0.05) 0, transparent 50%), 
        radial-gradient(at 50% 0%, hsla(210, 100%, 23%, 0.03) 0, transparent 50%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    /* Removed initial opacity 0 to prevent blank screens on JS errors */
}

body.content-ready {
    animation: fadeIn 0.5s ease-out;
}

/* ========== Main Dashboard Layout ========== */
.main-layout-wrapper {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 0;
    min-height: 100vh;
    transition: grid-template-columns 0.4s var(--cubic);
}

.main-layout-wrapper.collapsed {
    grid-template-columns: 80px 1fr;
}

.admin-nav {
    background: var(--card-bg-solid);
    border-right: 1px solid #e2e8f0;
    padding: 1.5rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: all 0.4s var(--cubic);
    display: flex;
    flex-direction: column;
}

.admin-nav.collapsed {
    padding: 1.5rem 0.5rem;
}

.nav-logo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 3rem;
    padding: 0 0.5rem;
}

.logo-text {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--text-primary);
    transition: opacity 0.3s;
}

.logo-text i {
    font-size: 1.5rem;
    color: var(--accent-blue);
}

.admin-nav.collapsed .logo-text span {
    display: none;
}

.btn-toggle {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-toggle:hover {
    background: var(--accent-blue-light);
    color: var(--accent-blue);
}

.nav-links {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    border-radius: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.nav-link:hover {
    background: #f8fafc;
    color: var(--accent-blue) !important;
}

.nav-link.active {
    background: var(--accent-blue-light) !important;
    color: var(--accent-blue) !important;
}

.admin-nav.collapsed .nav-link {
    justify-content: center;
    padding: 0.8rem 0;
}

.admin-nav.collapsed .nav-link span {
    display: none;
}

.admin-nav.collapsed .nav-link i {
    font-size: 1.25rem;
}

.nav-footer {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid #f1f5f9;
}

.admin-main-view {
    padding: 2.5rem;
    background: var(--bg-color);
    max-height: 100vh;
    overflow-y: auto;
    flex: 1;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.view-subtitle {
    color: var(--text-secondary);
    opacity: 0.8;
    font-size: 0.9rem;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.view-title {
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.view-subtitle {
    color: var(--text-secondary);
    opacity: 0.8;
    font-size: 0.9rem;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.leading-relaxed {
    line-height: 1.8 !important;
}

.text-sm-muted {
    font-size: 0.85rem;
    color: var(--text-secondary);
    opacity: 0.8;
}

/* ========== Layout ========== */
.dashboard {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem;
    display: grid;
    gap: 2rem;
    width: 100%;
    min-width: 0;
}

.header {
    background: var(--card-bg);
    backdrop-filter: var(--glass);
    padding: 2rem;
    border-radius: var(--radius-xl);
    border: 1px solid var(--card-bg-solid);
    box-shadow: var(--card-shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.875rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.header p {
    color: var(--text-secondary);
    font-weight: 500;
}

/* ========== Login Page ========== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 440px;
    background: var(--card-bg);
    backdrop-filter: var(--glass);
    padding: 3rem;
    border-radius: var(--radius-xl);
    border: 1px solid white;
    box-shadow: var(--card-shadow);
    text-align: center;
    animation: fadeInUp 0.6s ease-out;
}

.login-banner {
    width: calc(100% + 6rem);
    margin: -3rem -3rem 2.5rem;
    overflow: hidden;
    height: 200px;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-bottom: 2px solid var(--accent-blue);
}

.login-banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

.login-banner:hover img {
    transform: scale(1.05);
}

/* Semi-Gauge Refinements */
.semi-gauge-container svg {
    overflow: visible;
}

#gauge-needle {
    z-index: 5;
}

/* Vertical Chart Refinements */
.vertical-chart-container {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    height: 240px;
    padding: 0 10px 15px;
    width: 100%;
}

.v-bar-item {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    height: 100%;
    flex: 1 1 0; /* Forced equal distribution */
    min-width: 0;
}

.v-bar-fill {
    width: 50% !important;
    min-width: 30px;
    min-height: 2px;
}

/* Clickable Table Rows */
.clickable-row {
    cursor: pointer;
    transition: all 0.2s var(--cubic);
}

.clickable-row:hover {
    background: rgba(37, 99, 235, 0.02) !important;
}

.clickable-row.active {
    background: var(--accent-blue-light) !important;
    position: relative;
}

.clickable-row.active td:first-child {
    box-shadow: inset 4px 0 0 var(--accent-blue);
}

.login-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 2.5rem;
}

.input-group {
    text-align: left;
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper i {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
}

.input-wrapper input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 2.75rem;
    border-radius: var(--radius-md);
    border: 1px solid #e2e8f0;
    background: white;
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 4px var(--accent-blue-light);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--accent-blue);
    color: white;
}

.btn-primary:hover {
    background: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: 0 12px 20px -3px rgba(37, 99, 235, 0.3);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid #e2e8f0;
}

.btn-ghost:hover {
    background: #f8fafc;
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.btn-text {
    background: transparent;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.btn-text:hover {
    color: var(--accent-blue);
    text-decoration: underline;
}

.btn-login {
    width: 100%;
}

.error-toast {
    background: var(--danger-light);
    color: var(--danger);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.error-toast.visible {
    display: flex;
}

.login-footer-note {
    margin-top: 2rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ========== Survey Styles ========== */
.survey-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 1rem 3rem;
}

.survey-progress-wrap {
    background: var(--card-bg);
    backdrop-filter: var(--glass);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--card-shadow);
    border: 1px solid white;
    margin-bottom: 1.5rem;
}

.survey-progress-top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.survey-progress-title {
    font-weight: 700;
    font-size: 0.7rem;
}

.survey-progress-pct {
    color: var(--accent-blue);
    font-weight: 800;
    font-size: 0.75rem;
}

.survey-progress-container {
    height: 5px;
    background: #f1f5f9;
    border-radius: 3px;
    overflow: hidden;
}

.survey-progress-bar {
    height: 100%;
    background: linear-gradient(to right, var(--accent-blue), #60a5fa);
    transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.survey-section {
    animation: fadeIn 0.4s ease-out;
}

.survey-step-heading {
    font-size: 1rem;
    font-weight: 800;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.survey-step-heading i {
    color: var(--accent-blue);
    font-size: 0.9rem;
}

.question-card {
    background: var(--card-bg);
    backdrop-filter: var(--glass);
    padding: 0.85rem !important;
    border-radius: 0.85rem;
    border: 1px solid white;
    box-shadow: var(--card-shadow);
    margin-bottom: 0.85rem;
    transition: var(--transition);
    position: relative;
    border-left: 4px solid var(--accent-blue) !important;
}

.question-card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-2px);
}

.rating-option {
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.rating-option:hover {
    transform: scale(1.002);
}

.question-card.answered {
    border-left: 4px solid var(--success);
}

.desc-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.desc-item:hover {
    border-color: var(--accent-blue);
    background: white;
}

.matrix-grid {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 0.6rem;
}

.matrix-item {
    background: #f8fafc;
    border: 1px solid #eef2f6;
    border-radius: 8px;
    padding: 0.4rem 0.75rem;
    transition: all 0.2s var(--cubic);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
    cursor: pointer;
    text-align: left;
}

.matrix-item:hover {
    border-color: #d1d9e6;
    background: white;
}

.matrix-item.active {
    background: white;
    border-color: var(--accent-blue);
    box-shadow: 0 4px 10px -5px rgba(37,99,235,0.05);
    transform: translateX(4px);
}

.matrix-item.active::after {
    display: none; 
}

.matrix-score-sidebar {
    width: 32px;
    height: 32px;
    background: #f1f5f9;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
    font-weight: 900;
    color: var(--text-muted);
    transition: all 0.3s;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.015);
}

.matrix-item.active .matrix-score-sidebar {
    background: var(--accent-blue);
    color: white;
    box-shadow: 0 4px 8px var(--accent-blue-light);
}

.matrix-content-main {
    flex: 1;
}

.matrix-grade-title {
    font-size: 0.88rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.matrix-item.active .matrix-grade-title {
    color: var(--accent-blue);
}

.matrix-desc {
    font-size: 0.82rem;
    line-height: 1.35;
    color: var(--text-secondary);
    font-weight: 500;
}

.matrix-item.active .matrix-desc {
    color: var(--text-primary);
}

@media (max-width: 600px) {
    .matrix-item {
        padding: 1.25rem;
        gap: 1.25rem;
        transform: none !important;
    }
    .matrix-score-sidebar {
        width: 48px;
        height: 48px;
        font-size: 1.25rem;
    }
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid #e2e8f0;
    font-family: inherit;
    min-height: 100px;
}

.survey-footer {
    display: flex;
    justify-content: space-between;
    padding: 2rem 0;
    margin-top: 2rem;
    border-top: 1px solid #e2e8f0;
}

/* ========== Missions Selection ========== */
.mission-selector-grid {
    display: grid;
    gap: 1rem;
    margin-top: 1.5rem;
}

.mission-option-card {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    background: white;
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}

.mission-option-card:hover {
    border-color: var(--accent-blue);
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-5px);
}

.mission-num {
    width: 42px;
    height: 42px;
    background: var(--accent-blue-light);
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-weight: 800;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.mission-info {
    flex: 1;
}

.mission-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
}

.mission-staff {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.badge {
    font-size: 0.7rem;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 800;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
    display: inline-block;
}

.badge-pending {
    background: #fef3c7;
    color: #92400e;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.sync-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    margin-left: 0.25rem;
    vertical-align: middle;
}

.sync-tag i {
    font-size: 0.75rem;
    opacity: 0.8;
}

.sync-tag.cloud-done {
    color: var(--success);
    background: var(--success-light);
    border-color: rgba(22, 163, 74, 0.1);
}

/* ========== Dashboard Layout ========== */
.main-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 2rem;
    align-items: start;
    min-width: 0;
}

.dashboard-main-layout {
    grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
    gap: 1.5rem;
    width: 100%;
}

.dashboard-main-layout > * {
    min-width: 0;
}

#task-status-card {
    margin-bottom: 1.5rem;
    min-width: 0;
}

.card {
    background: var(--card-bg);
    backdrop-filter: var(--glass);
    border-radius: var(--radius-xl);
    border: 1px solid white;
    box-shadow: var(--card-shadow);
    padding: 2rem;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-4px);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.card-title i {
    color: var(--accent-blue);
}

/* ========== Tables ========== */
.table-scroll {
    overflow-x: auto;
    max-width: 100%;
    min-width: 0;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table th, 
.history-table td {
    padding: 0.75rem 0.6rem;
    font-size: 0.85rem;
    line-height: 1.4;
}

.history-table th {
    background: rgba(248, 250, 252, 0.5);
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
}

.approval-queue-list {
    display: grid;
    gap: 0.75rem;
}

.approval-queue-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: center;
    padding: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    background: #f8fafc;
}

.approval-queue-title {
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.approval-queue-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* ========== Approval Documents ========== */
.approval-doc-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.approval-doc-stat {
    background: var(--card-bg);
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    padding: 1rem;
    box-shadow: var(--card-shadow);
}

.approval-doc-stat-label {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.approval-doc-stat-value {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--text-primary);
}

.approval-documents-list {
    display: grid;
    gap: 1rem;
}

.approval-mission-group {
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #ffffff;
}

.approval-mission-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.approval-mission-title {
    font-weight: 900;
    color: var(--text-primary);
}

.approval-round-list {
    display: grid;
}

.approval-round-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: center;
    padding: 1rem;
    border-top: 1px solid #f1f5f9;
}

.approval-round-row:first-child {
    border-top: 0;
}

.approval-round-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.35rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.approval-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-secondary);
    padding: 1rem;
    border-bottom: 2px solid #e2e8f0;
}

td {
    padding: 1rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    border-bottom: 1px solid #f1f5f9;
}

.date-cell {
    white-space: nowrap;
    min-width: 120px;
}

/* ========== Charts & Gauges ========== */
.ring-wrapper {
    position: relative;
    width: 260px;
    height: 260px;
    margin: 0 auto;
}

.ring-svg {
    transform: rotate(-90deg);
}

.ring-track {
    fill: none;
    stroke: #f1f5f9;
    stroke-width: 20;
}

.ring-fill {
    fill: none;
    stroke: var(--accent-blue);
    stroke-width: 20;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s ease-out;
}

.cipp-table {
    min-width: 900px;
}

.cipp-table th {
    padding: 0.75rem 0.5rem;
    font-size: 0.75rem;
    background: #f8fafc;
}

.cipp-table td {
    padding: 0.75rem 0.5rem;
    vertical-align: middle;
}

.col-topic-cell {
    min-width: 160px;
    line-height: 1.4;
}

.sd-cell {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
}

.cell-badge {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 0.85rem;
}

.r-pill {
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.r-normal { color: var(--success); background: var(--success-light); }
.r-risk { color: var(--warning); background: var(--warning-light); }
.r-crit { color: var(--danger); background: var(--danger-light); }

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.dot-normal { background: var(--success); }
.dot-risk { background: var(--warning); }
.dot-crit { background: var(--danger); }

/* Bar chart styles in side panels */
.bar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.bar-label {
    width: 65px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.bar-track {
    flex: 1;
    height: 8px;
    background: #f1f5f9;
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: var(--accent-blue);
    border-radius: 4px;
    transition: width 0.8s ease-out;
}

.bar-value {
    width: 25px;
    font-size: 0.75rem;
    font-weight: 800;
    text-align: right;
}

/* ========== Animations ========== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ========== Responsive ========== */
@media (max-width: 1100px) {
    .main-layout {
        grid-template-columns: 1fr;
    }

    .dashboard-main-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 640px) {
    .dashboard {
        padding: 1rem;
    }
    .header {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    .rating-options {
        grid-template-columns: 1fr;
    }
}
/* ========== Modals & Overlays ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--card-bg-solid);
    width: 90%;
    max-width: 480px;
    padding: 2.5rem;
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    text-align: center;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s var(--cubic);
}

.modal-close-btn {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid #f1f5f9;
    background: white;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    z-index: 10;
}

.modal-close-btn:hover {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fee2e2;
    transform: rotate(90deg);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-icon {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 2rem;
}

.modal-icon.info { background: var(--accent-blue-light); color: var(--accent-blue); }
.modal-icon.success { background: var(--success-light); color: var(--success); }
.modal-icon.warning { background: var(--warning-light); color: var(--warning); }
.modal-icon.danger { background: var(--danger-light); color: var(--danger); }

.modal-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.modal-desc {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 2rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.modal-btn-confirm, .modal-btn-cancel {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    flex: 1;
}

.modal-btn-confirm {
    background: var(--accent-blue);
    color: white;
}

.modal-btn-confirm:hover {
    background: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
}

.modal-btn-cancel {
    background: #f8fafc;
    color: var(--text-secondary);
    border: 1px solid #e2e8f0;
}

.modal-btn-cancel:hover {
    background: #f1f5f9;
}

/* Specific for Mission Modal Scrollable List */
#mission-list-container::-webkit-scrollbar {
    width: 6px;
}

#mission-list-container::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

#mission-list-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

#mission-list-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ========== Admin Management Nav & Layout ========== */
.admin-nav .nav-link {
    width: 100%;
    margin-bottom: 0.25rem;
}

.admin-nav .nav-link:hover {
    background: #f8fafc;
    color: var(--accent-blue) !important;
}

.admin-nav .nav-link.active {
    background: var(--accent-blue-light) !important;
    color: var(--accent-blue) !important;
}

.admin-nav .nav-link i {
    width: 20px;
    text-align: center;
}

.view-pane {
    animation: fadeIn 0.4s ease-out;
}

.editor-tabs .btn-ghost.active {
    background: var(--accent-blue);
    color: white !important;
    border-color: var(--accent-blue);
}

.stat-grid .stat-tile {
    background: var(--card-bg-solid);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid #f1f5f9;
}

.stat-grid .stat-tile i {
    font-size: 1.25rem;
    width: 44px;
    height: 44px;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

.stat-grid .stat-tile-value {
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1.1;
    color: var(--text-primary);
}

.stat-grid .stat-tile-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 700;
    margin-top: 0.1rem;
}

/* Evaluator Management Styles */
.evaluator-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    padding: 0.5rem 0;
}

.evaluator-card {
    background: white;
    padding: 1rem;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
    border-left: 4px solid var(--warning);
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.evaluator-card.status-done {
    border-left-color: var(--success);
}

.evaluator-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px -3px rgba(0,0,0,0.05);
    border-color: var(--accent-blue-light);
}

.evaluator-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.evaluator-info .avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.evaluator-info .name {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.evaluator-info .position {
    font-size: 0.7rem;
    color: var(--text-secondary);
    opacity: 0.8;
}

/* Sidebar Custom Scrollbar */
.admin-nav::-webkit-scrollbar {
    width: 4px;
}
.admin-nav::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

/* ========== Assessment UI Components (Match Guide) ========== */

.cell-badge {
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-weight: 800;
    font-size: 0.85rem;
}

.badge-success-light { background: #dcfce7; color: #166534; }
.badge-orange { background: #ffedd5; color: #9a3412; }

.r-pill {
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-weight: 800;
    font-size: 0.75rem;
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.r-status-normal { background: var(--risk-1); }
.r-status-watch { background: var(--risk-2); }
.r-status-risk { background: var(--risk-3); }
.r-status-danger { background: var(--risk-4); }

.status-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.3);
}

.dot-normal { background: var(--risk-1); }
.dot-watch { background: var(--risk-2); }
.dot-risk { background: var(--risk-3); }
.dot-danger { background: var(--risk-4); }

.sd-val {
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

.sd-val.badge-danger { background: var(--danger-light); color: var(--danger); }
.sd-val.badge-orange { background: var(--orange-light); color: var(--orange); }
.sd-val.badge-warning { background: var(--warning-light); color: var(--warning); }
.sd-val.badge-success { background: var(--success-light); color: var(--success); }

/* Global Alert Banner */
.badge-draft { 
    background: #ffedd5; 
    color: #ea580c; 
    border: 1px solid #fed7aa; 
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.75rem;
}

.alert-banner {
    background: #fef2f2;
    border: 1px solid #fee2e2;
    border-left: 5px solid var(--danger);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    animation: slideDown 0.5s var(--cubic);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.05);
}

.alert-banner i {
    font-size: 1.75rem;
    color: var(--danger);
}

.alert-banner-content {
    flex: 1;
}

.alert-banner-title {
    font-weight: 800;
    color: #991b1b;
    font-size: 1.1rem;
    margin-bottom: 0.15rem;
}

.alert-banner-desc {
    color: #b91c1c;
    font-size: 0.9rem;
    opacity: 0.9;
}

.alert-banner-btn {
    background: var(--danger);
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.85rem;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.alert-banner-btn:hover {
    background: #b91c1c;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(185, 28, 28, 0.3);
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
