* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Orbitron:wght@400;500;600;700;800;900&display=swap');

    font-family: 'Inter', sans-serif;
    background: hsl(270, 28%, 5%);
    color: #e5e7eb;
    line-height: 1.6;
    min-height: 100vh;
    background-attachment: fixed;
}

.container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 20px 30px;
}

/* Header */
.header {
    background: rgba(0,0,0,0.4); backdrop-filter: blur(10px); border-bottom: 1px solid rgba(255,255,255,0.05);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(230, 43, 43, 0.2);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-section h1 {
    font-size: 1.8em;
    margin-bottom: 2px;
    color: #e62b2b;
    letter-spacing: 2px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    text-shadow: 0 0 16px rgba(230, 43, 43, 0.7);
}

.logo-section p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85em;
    letter-spacing: 0.5px;
}

.user-info {
    display: flex;
    gap: 15px;
    align-items: center;
}

.user-details {
    text-align: right;
    background: rgba(255, 255, 255, 0.08);
    padding: 8px 16px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px);
}

.user-name {
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 2px;
}

.user-role {
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.9);
}

.user-hub {
    font-size: 0.8em;
    color: rgba(255, 255, 255, 0.75);
}

.btn-logout {
    padding: 8px 18px;
    background: #ffffff;
    color: #e62b2b;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9em;
    transition: all 0.3s ease;
}

.btn-logout:hover {
    background: #f5f5f5;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Offline Toggle */
.offline-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.15);
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.85em;
    color: #ffffff;
}

.offline-toggle.offline {
    background: rgba(220, 38, 38, 0.3);
    border-color: rgba(220, 38, 38, 0.6);
}

.toggle-switch {
    width: 36px;
    height: 20px;
    background: #cccccc;
    border-radius: 10px;
    position: relative;
    transition: background 0.3s ease;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.offline-toggle.offline .toggle-switch {
    background: #dc2626;
}

.offline-toggle.offline .toggle-switch::after {
    transform: translateX(16px);
}

/* Buttons */
.btn-primary, .btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95em;
    transition: all 0.3s ease;
}

.btn-primary {
    background: rgba(0,0,0,0.4); backdrop-filter: blur(10px); border-bottom: 1px solid rgba(255,255,255,0.05);
    color: white;
    border: 2px solid #e62b2b;
}

.btn-primary:hover {
    /* Remove animations */
}

.btn-secondary {
    background: #ffffff;
    color: #e62b2b;
    border: 1px solid #e62b2b;
}

.btn-secondary:hover {
    background: #f5f0ff;
    transform: translateY(-2px);
}

.btn-danger {
    padding: 8px 16px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9em;
    transition: all 0.3s ease;
}

.btn-danger:hover {
    background: #b91c1c;
    transform: translateY(-1px);
}

/* App Layout */
.app-body {
    display: flex;
    min-height: calc(100vh - 70px);
}

.app-sidebar {
    width: 260px;
    background: rgba(0, 0, 0, 0.25);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    padding: 25px 20px;
    backdrop-filter: blur(10px);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: transparent;
    color: #9ca3af;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.05em;
    font-weight: 600;
    text-align: left;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #e5e7eb;
}

.nav-btn.active {
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
    border-left: 4px solid #e62b2b;
}

/* Main Content */
.main-content {
    flex: 1;
    min-height: 600px;
    padding: 25px 30px;
}

.view {
    display: none;
}

.view.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e62b2b;
}

.view-header h2 {
    color: #ffffff;
    font-size: 1.6em;
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 1px;
}

/* Hub Toggle Tabs */
.hub-tab {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    color: #e5e7eb;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.hub-tab:hover {
    background: rgba(255, 255, 255, 0.15);
}

.hub-tab.active {
    background: #e62b2b;
    color: white;
    border-color: #e62b2b;
    box-shadow: 0 0 10px rgba(230, 43, 43, 0.4);
}

.view-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.search-box, .filter-select {
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 5px;
    color: #e5e7eb;
    font-size: 0.95em;
}

.search-box::placeholder {
    color: #9ca3af;
}

.search-box:focus, .filter-select:focus {
    outline: none;
    border-color: #e62b2b;
    box-shadow: 0 0 8px rgba(230, 43, 43, 0.15);
}

/* Grid Layouts */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 1024px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

/* Cards */
.card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(12px);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.card h3 {
    color: #e62b2b;
    margin-bottom: 20px;
    font-size: 1.2em;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(230, 43, 43, 0.3);
}

.card h4 {
    color: #e5e7eb;
    margin-top: 20px;
    margin-bottom: 10px;
}

/* Risk Map */
.risk-map {
    background: rgba(255, 255, 255, 0.03);
    padding: 20px;
    border-radius: 6px;
    min-height: 300px;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.component-node {
    padding: 15px;
    border-radius: 6px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid;
    font-weight: 600;
    font-size: 0.9em;
}

.component-node:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.component-node.critical {
    background: rgba(220, 38, 38, 0.15);
    border-color: #dc2626;
    color: #dc2626;
}

.component-node.high {
    background: rgba(234, 88, 12, 0.15);
    border-color: #ea580c;
    color: #ea580c;
}

.component-node.moderate {
    background: rgba(234, 179, 8, 0.15);
    border-color: #eab308;
    color: #eab308;
}

.component-node.nominal {
    background: rgba(34, 197, 94, 0.15);
    border-color: #22c55e;
    color: #22c55e;
}

.component-node-label {
    font-size: 0.85em;
    display: block;
    margin-top: 8px;
    opacity: 0.85;
}

/* Map Legend */
.map-legend {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9em;
    color: #d1d5db;
}

.legend-color {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    margin-right: 8px;
    vertical-align: middle;
}

.legend-color.critical { background: #dc2626; }
.legend-color.high { background: #ea580c; }
.legend-color.moderate { background: #eab308; }
.legend-color.nominal { background: #22c55e; }

.metric-chart-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px 0;
    position: relative;
}

#sectorMetricChart {
    width: 100%;
    max-width: 320px;
    height: auto;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
}

.chart-legend {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 15px;
    font-size: 0.95em;
    color: #d1d5db;
}

.chart-legend div {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pie-tooltip {
    position: absolute;
    pointer-events: none;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(55, 0, 145, 0.92);
    color: white;
    font-size: 0.85em;
    white-space: nowrap;
    opacity: 0;
    transform: translate(-50%, -110%);
    transition: opacity 0.15s ease;
    z-index: 10;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.metric-box {
    padding: 20px;
    border-radius: 6px;
    text-align: center;
    border: 2px solid;
}

.metric-box.critical {
    background: rgba(220, 38, 38, 0.12);
    border-color: #dc2626;
}

.metric-box.high {
    background: rgba(234, 88, 12, 0.12);
    border-color: #ea580c;
}

.metric-box.moderate {
    background: rgba(234, 179, 8, 0.12);
    border-color: #eab308;
}

.metric-box.nominal {
    background: rgba(34, 197, 94, 0.12);
    border-color: #22c55e;
}

.metric-value {
    font-size: 2.5em;
    font-weight: bold;
    margin-bottom: 8px;
}

.metric-box.critical .metric-value { color: #dc2626; }
.metric-box.high .metric-value { color: #ea580c; }
.metric-box.moderate .metric-value { color: #b8960a; }
.metric-box.nominal .metric-value { color: #16a34a; }

.metric-label {
    font-size: 0.95em;
    color: #9ca3af;
}

/* Component List */
.component-list {
    max-height: 400px;
    overflow-y: auto;
}

.selected-component-actions {
    padding: 12px 14px;
    background: rgba(230, 43, 43, 0.08);
    border: 1px solid rgba(230, 43, 43, 0.25);
    border-radius: 8px;
    color: #27272a;
    margin-bottom: 15px;
    font-size: 0.95em;
}

.component-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: rgba(255, 255, 255, 0.04);
    border-left: 4px solid;
    border-radius: 4px;
    margin-bottom: 10px;
    transition: all 0.3s ease;
}

.component-item:hover {
    transform: translateX(5px);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.component-item.critical { border-left-color: #dc2626; }
.component-item.high { border-left-color: #ea580c; }
.component-item.moderate { border-left-color: #eab308; }
.component-item.nominal { border-left-color: #22c55e; }

.component-info {
    flex: 1;
}

.component-id {
    font-weight: 600;
    color: #e5e7eb;
    margin-bottom: 3px;
}

.component-details {
    font-size: 0.85em;
    color: #9ca3af;
}

.component-cii {
    background: rgba(255, 255, 255, 0.06);
    padding: 8px 12px;
    border-radius: 4px;
    font-weight: 600;
    min-width: 60px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Task List */
.task-list, .engineer-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.task-item, .engineer-item {
    background: rgba(255, 255, 255, 0.04);
    padding: 15px;
    border-radius: 4px;
    border-left: 4px solid #e62b2b;
    cursor: pointer;
    transition: all 0.3s ease;
}

.task-item:hover, .engineer-item:hover, .diagnostic-card:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.diagnostic-card {
    background: rgba(255, 255, 255, 0.04);
    padding: 15px;
    border-radius: 4px;
    border-left: 4px solid;
    margin-bottom: 10px;
    transition: all 0.3s ease;
}

.diagnostic-card.critical { border-left-color: #dc2626; }
.diagnostic-card.high { border-left-color: #ea580c; }
.diagnostic-card.moderate { border-left-color: #eab308; }

.diagnostic-title {
    font-weight: 600;
    color: #e5e7eb;
    margin-bottom: 4px;
}

.diagnostic-reason {
    font-size: 0.9em;
    color: #d1d5db;
}

.diagnostic-action {
    margin-top: 8px;
    font-size: 0.8em;
    color: #e62b2b;
    font-weight: 600;
}

.task-item strong, .engineer-item strong {
    color: #e62b2b;
    display: block;
    margin-bottom: 5px;
}

.task-priority {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
    margin-top: 8px;
}

.task-priority.critical {
    background: rgba(220, 38, 38, 0.15);
    color: #dc2626;
    border: 1px solid #dc2626;
}

.task-priority.high {
    background: rgba(234, 88, 12, 0.15);
    color: #ea580c;
    border: 1px solid #ea580c;
}

.task-priority.moderate {
    background: rgba(191, 219, 254, 0.18);
    color: #1d4ed8;
    border: 1px solid #93c5fd;
}

/* Assignments Table */
.assignments-table {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.assignment-row {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1fr 1fr;
    gap: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    align-items: center;
    transition: all 0.3s ease;
}

.assignment-row.clickable {
    cursor: pointer;
}
.assignment-row.clickable:hover {
    background: rgba(168, 85, 247, 0.1);
    border-color: rgba(168, 85, 247, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.assignment-row:nth-child(even) {
    background: rgba(255, 255, 255, 0.06);
}

.assignment-field {
    font-size: 0.9em;
    color: #d1d5db;
}

.assignment-field strong {
    color: #e62b2b;
    display: block;
    margin-bottom: 3px;
}

/* Component Detail */
.component-detail {
    background: rgba(255, 255, 255, 0.04);
    padding: 20px;
    border-radius: 6px;
    border-left: 4px solid #e62b2b;
}

.component-detail-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 15px;
}

.component-detail-row strong {
    color: #9ca3af;
    display: block;
    margin-bottom: 5px;
    font-size: 0.9em;
}

.component-detail-row span {
    color: #e5e7eb;
    font-weight: 600;
}

/* Inspection Form */
.inspection-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    color: #e5e7eb;
    font-weight: 600;
}

.form-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.form-group input[type="file"],
.form-group input[type="text"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 5px;
    color: #e5e7eb;
    font-family: inherit;
    font-size: 0.95em;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #e62b2b;
    box-shadow: 0 0 8px rgba(230, 43, 43, 0.15);
}

.form-group textarea {
    resize: vertical;
}

/* AI Analysis */
.ai-analysis {
    background: rgba(255, 255, 255, 0.04);
    padding: 20px;
    border-radius: 6px;
    border-left: 4px solid #22c55e;
    min-height: 200px;
}

.ai-result {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 10px;
    border-left: 4px solid #22c55e;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.ai-result.critical {
    border-left-color: #dc2626;
    background: rgba(220, 38, 38, 0.12);
}

.ai-result strong {
    color: #e62b2b;
    display: block;
    margin-bottom: 8px;
}

/* AI Processing Animation */
.ai-processing {
    text-align: center;
    padding: 30px;
}

.ai-processing .scan-line {
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, #e62b2b, transparent);
    animation: scanLine 2s ease-in-out infinite;
    margin-bottom: 15px;
    border-radius: 2px;
}

@keyframes scanLine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.ai-processing .status-text {
    color: #e62b2b;
    font-weight: 600;
    font-size: 0.95em;
}

/* Truth Check */
.truth-check-section {
    margin-top: 15px;
    padding: 15px;
    background: rgba(220, 38, 38, 0.1);
    border: 1px solid #e62b2b;
    border-radius: 6px;
}

.truth-check-section p {
    color: #d1d5db;
    margin-bottom: 10px;
    font-size: 0.9em;
}

/* Pulse Animation for Critical */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.component-node.critical {
    animation: pulse 2s ease-in-out infinite;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #1a1a2e;
    padding: 30px;
    border-radius: 10px;
    border: 1px solid rgba(230, 43, 43, 0.3);
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
    color: #e62b2b;
    margin-bottom: 20px;
}

.close {
    color: #9ca3af;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover {
    color: #e5e7eb;
}

/* Form */
.form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form .form-group select {
    width: 100%;
}

/* Notification */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    background: #22c55e;
    color: white;
    border-radius: 5px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    display: none;
    z-index: 2000;
    animation: slideIn 0.3s ease;
    font-weight: 500;
}

.notification.show {
    display: block;
}

.notification.error {
    background: #dc2626;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
    }
    to {
        transform: translateX(0);
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .logo-section h1 {
        font-size: 1.5em;
    }

    .user-info {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .view-header {
        flex-direction: column;
        gap: 15px;
    }

    .view-controls {
        width: 100%;
        flex-direction: column;
    }

    .risk-map {
        grid-template-columns: repeat(2, 1fr);
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .assignment-row {
        grid-template-columns: 1fr;
    }

    .main-content {
        padding: 15px;
    }
}
