* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', Arial, sans-serif; background: #f0f2f5; color: #333; font-size: 14px; }

/* Layout */
.app-wrapper { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #1e293b; color: #cbd5e1; min-height: 100vh; flex-shrink: 0; position: fixed; top: 0; left: 0; bottom: 0; overflow-y: auto; z-index: 100; }
.main-content { margin-left: 220px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* Sidebar */
.sidebar-header { padding: 20px 16px 16px; border-bottom: 1px solid #334155; display: flex; align-items: center; gap: 10px; }
.logo { font-size: 24px; }
.logo-text { font-size: 13px; color: #94a3b8; }
.logo-text strong { color: #60a5fa; font-size: 15px; display: block; }
.nav-menu { list-style: none; padding: 12px 0; }
.nav-menu li { margin: 2px 8px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; text-decoration: none; color: #94a3b8; transition: all .15s; font-size: 13px; }
.nav-link:hover { background: #334155; color: #e2e8f0; }
.nav-link.active { background: #3b82f6; color: #fff; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

/* Topbar */
.topbar { background: #fff; padding: 14px 24px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e2e8f0; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.topbar-title { font-size: 16px; font-weight: 600; color: #1e293b; }
.topbar-info { font-size: 12px; color: #94a3b8; }

/* Content */
.content-area { padding: 24px; flex: 1; }

/* Cards */
.card { background: #fff; border-radius: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.08); margin-bottom: 20px; }
.card-header { padding: 16px 20px; border-bottom: 1px solid #f1f5f9; display: flex; justify-content: space-between; align-items: center; }
.card-title { font-size: 15px; font-weight: 600; color: #1e293b; }
.card-body { padding: 20px; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: 12px; padding: 20px; box-shadow: 0 1px 4px rgba(0,0,0,.08); display: flex; align-items: center; gap: 14px; }
.stat-icon { font-size: 28px; }
.stat-value { font-size: 24px; font-weight: 700; color: #1e293b; line-height: 1; }
.stat-label { font-size: 12px; color: #64748b; margin-top: 3px; }

/* Badges */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-primary { background: #dbeafe; color: #1d4ed8; }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef9c3; color: #a16207; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-secondary { background: #f1f5f9; color: #475569; }
.badge-info { background: #e0f2fe; color: #0369a1; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
table th { background: #f8fafc; color: #475569; font-weight: 600; padding: 10px 12px; text-align: left; border-bottom: 2px solid #e2e8f0; white-space: nowrap; }
table td { padding: 9px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
table tr:hover td { background: #f8fafc; }
table tr:last-child td { border-bottom: none; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: none; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500; text-decoration: none; transition: all .15s; }
.btn-primary { background: #3b82f6; color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-success { background: #22c55e; color: #fff; }
.btn-success:hover { background: #16a34a; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-secondary { background: #e2e8f0; color: #475569; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: #374151; margin-bottom: 5px; }
.form-control { width: 100%; padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 13px; color: #374151; background: #fff; transition: border-color .15s; }
.form-control:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.1); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.alert-success { background: #dcfce7; color: #15803d; border-left: 4px solid #22c55e; }
.alert-danger { background: #fee2e2; color: #b91c1c; border-left: 4px solid #ef4444; }
.alert-warning { background: #fef9c3; color: #a16207; border-left: 4px solid #f59e0b; }
.alert-info { background: #e0f2fe; color: #0369a1; border-left: 4px solid #0ea5e9; }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1000; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal { background: #fff; border-radius: 14px; padding: 24px; width: 90%; max-width: 640px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-lg { max-width: 900px; }
.modal-xl { max-width: 1100px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid #f1f5f9; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: #64748b; padding: 4px 8px; border-radius: 6px; }
.modal-close:hover { background: #f1f5f9; }

/* Progress */
.progress { height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 4px; background: #3b82f6; transition: width .3s; }

/* Steps */
.steps { display: flex; gap: 0; margin-bottom: 24px; }
.step { flex: 1; text-align: center; padding: 12px; border-bottom: 3px solid #e2e8f0; font-size: 12px; color: #94a3b8; cursor: pointer; }
.step.active { border-color: #3b82f6; color: #3b82f6; font-weight: 600; }
.step.done { border-color: #22c55e; color: #22c55e; }
.step-num { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; background: #e2e8f0; color: #64748b; font-size: 11px; font-weight: 700; align-items: center; justify-content: center; margin-bottom: 4px; }
.step.active .step-num { background: #3b82f6; color: #fff; }
.step.done .step-num { background: #22c55e; color: #fff; }

/* FMEA specific */
.fmea-score-cell { text-align: center; font-weight: 700; }
.fmea-ap-H { color: #b91c1c; background: #fee2e2; padding: 2px 8px; border-radius: 4px; }
.fmea-ap-M { color: #a16207; background: #fef9c3; padding: 2px 8px; border-radius: 4px; }
.fmea-ap-L { color: #15803d; background: #dcfce7; padding: 2px 8px; border-radius: 4px; }
.score-picker { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.score-btn { width: 28px; height: 28px; border: 2px solid #e2e8f0; border-radius: 6px; background: #fff; cursor: pointer; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; transition: all .1s; }
.score-btn:hover { border-color: #3b82f6; background: #eff6ff; }
.score-btn.selected { border-color: #3b82f6; background: #3b82f6; color: #fff; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid #e2e8f0; margin-bottom: 20px; }
.tab { padding: 8px 16px; border: none; background: none; cursor: pointer; font-size: 13px; color: #64748b; border-bottom: 2px solid transparent; margin-bottom: -2px; border-radius: 6px 6px 0 0; }
.tab:hover { background: #f8fafc; color: #374151; }
.tab.active { color: #3b82f6; border-bottom-color: #3b82f6; font-weight: 600; background: #eff6ff; }

/* Misc */
.text-muted { color: #94a3b8; font-size: 12px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.w-full { width: 100%; }
.empty-state { text-align: center; padding: 48px 20px; color: #94a3b8; }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar .form-control { width: auto; min-width: 160px; }
.section-title { font-size: 14px; font-weight: 600; color: #374151; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid #f1f5f9; }
.rpn-value { font-weight: 700; font-size: 15px; }
.rpn-high { color: #b91c1c; }
.rpn-med  { color: #a16207; }
.rpn-low  { color: #15803d; }
.info-block { background: #f8fafc; border-radius: 8px; padding: 14px; margin-bottom: 16px; font-size: 13px; }
.info-block dt { font-weight: 600; color: #475569; float: left; width: 140px; }
.info-block dd { margin-left: 150px; color: #374151; margin-bottom: 6px; }
