/* ============================================
   TPM / OEE Module
   Phase 6.5 - Total Productive Maintenance
   Apple-style Design
   ============================================ */

/* ===== Sub-tabs ===== */

.tpm-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 12px;
    padding: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.tpm-tabs::-webkit-scrollbar {
    display: none;
}

.tpm-tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #86868b;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    white-space: nowrap;
    flex-shrink: 0;
}

.tpm-tab:hover:not(.active) {
    color: #1d1d1f;
}

.tpm-tab.active {
    background: #fff;
    color: #667eea;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* ===== Buttons ===== */

.tpm-btn {
    padding: 10px 20px;
    border-radius: 12px;
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1.2;
}

.tpm-btn:active {
    transform: scale(0.97);
}

.tpm-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.tpm-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.tpm-btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.tpm-btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

.tpm-btn-secondary {
    background: #f5f5f7;
    color: #6e6e73;
}

.tpm-btn-secondary:hover {
    background: #e8e8ed;
    color: #1d1d1f;
}

.tpm-btn-danger {
    background: #fee2e2;
    color: #ef4444;
}

.tpm-btn-danger:hover {
    background: #fecaca;
    color: #dc2626;
}

.tpm-btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
    border-radius: 8px;
}

/* ===== Header ===== */

.tpm-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.tpm-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1d1d1f;
    margin: 0;
}

.tpm-header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ===== Equipment Grid ===== */

.tpm-equipment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.tpm-equipment-card {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.06);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.tpm-equipment-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.1);
}

/* ===== Card Elements ===== */

.tpm-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.tpm-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1d1d1f;
    margin: 0;
    flex: 1;
}

.tpm-card-body {
    margin-bottom: 14px;
}

.tpm-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
    gap: 8px;
    flex-wrap: wrap;
}

.tpm-card-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.tpm-card-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #86868b;
}

.tpm-card-meta .icon {
    font-size: 0.9rem;
}

/* ===== Criticality Badges ===== */

.tpm-criticality-A {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

.tpm-criticality-B {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
}

.tpm-criticality-C {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
}

/* ===== Status Badges ===== */

.tpm-status-active {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.tpm-status-maintenance {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.tpm-status-broken {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.tpm-status-decommissioned {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: rgba(110, 110, 115, 0.1);
    color: #6e6e73;
}

/* ===== OEE Gauge ===== */

.tpm-oee-gauge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
}

.tpm-oee-value {
    font-size: 3rem;
    font-weight: 800;
    color: #1d1d1f;
    line-height: 1;
    letter-spacing: -0.02em;
}

.tpm-oee-value.good {
    color: #10b981;
}

.tpm-oee-value.warning {
    color: #f59e0b;
}

.tpm-oee-value.critical {
    color: #ef4444;
}

.tpm-oee-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #86868b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 8px;
}

/* ===== OEE Breakdown ===== */

.tpm-oee-breakdown {
    display: flex;
    gap: 16px;
    margin: 16px 0;
    flex-wrap: wrap;
}

.tpm-oee-breakdown-item {
    flex: 1;
    min-width: 80px;
}

.tpm-oee-breakdown-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #86868b;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 6px;
}

.tpm-oee-breakdown-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1d1d1f;
    margin-bottom: 6px;
}

.tpm-oee-bar {
    width: 100%;
    height: 8px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 4px;
    overflow: hidden;
}

.tpm-oee-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 2px;
}

.tpm-oee-bar-fill.availability {
    background: linear-gradient(90deg, #667eea, #764ba2);
}

.tpm-oee-bar-fill.performance {
    background: linear-gradient(90deg, #10b981, #059669);
}

.tpm-oee-bar-fill.quality {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.tpm-oee-bar-fill.oee {
    background: linear-gradient(90deg, #667eea, #764ba2);
}

@keyframes tpm-bar-grow {
    from {
        width: 0;
    }
}

.tpm-oee-bar-fill.animate {
    animation: tpm-bar-grow 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== OEE Card ===== */

.tpm-oee-card {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
}

.tpm-oee-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.tpm-oee-metric {
    text-align: center;
    padding: 12px 0;
}

.tpm-oee-metric-value {
    font-size: 2rem;
    font-weight: 800;
    color: #1d1d1f;
    line-height: 1;
}

.tpm-oee-metric-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #86868b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 6px;
}

.tpm-oee-metric-trend {
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 4px;
}

.tpm-oee-metric-trend.up {
    color: #10b981;
}

.tpm-oee-metric-trend.down {
    color: #ef4444;
}

.tpm-oee-metric-trend.flat {
    color: #86868b;
}

/* ===== TPM Checklist ===== */

.tpm-category-section {
    margin-bottom: 16px;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.06);
    background: #fff;
}

.tpm-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    cursor: pointer;
    transition: background 0.15s ease;
    user-select: none;
}

.tpm-category-header:hover {
    background: rgba(0, 0, 0, 0.02);
}

.tpm-category-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tpm-category-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.tpm-category-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1d1d1f;
}

.tpm-category-subtitle {
    font-size: 0.75rem;
    color: #86868b;
    margin-top: 2px;
}

.tpm-category-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #86868b;
}

.tpm-category-chevron {
    font-size: 1rem;
    color: #86868b;
    transition: transform 0.2s ease;
}

.tpm-category-section.open .tpm-category-chevron {
    transform: rotate(180deg);
}

.tpm-category-body {
    display: none;
    padding: 0 20px 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
}

.tpm-category-section.open .tpm-category-body {
    display: block;
}

/* Check Items */

.tpm-check-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    gap: 12px;
}

.tpm-check-item:last-child {
    border-bottom: none;
}

.tpm-check-item-text {
    flex: 1;
    font-size: 0.85rem;
    color: #1d1d1f;
    line-height: 1.4;
}

.tpm-check-result {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.tpm-check-result button {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 2px solid rgba(0, 0, 0, 0.08);
    background: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #86868b;
}

.tpm-check-result button:hover {
    border-color: rgba(0, 0, 0, 0.15);
    background: rgba(0, 0, 0, 0.02);
}

.tpm-check-result button.pass {
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.3);
}

.tpm-check-result button.pass.selected {
    background: #10b981;
    border-color: #10b981;
    color: #fff;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.tpm-check-result button.fail {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

.tpm-check-result button.fail.selected {
    background: #ef4444;
    border-color: #ef4444;
    color: #fff;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.tpm-check-result button.na {
    color: #86868b;
    border-color: rgba(0, 0, 0, 0.08);
}

.tpm-check-result button.na.selected {
    background: #6e6e73;
    border-color: #6e6e73;
    color: #fff;
    box-shadow: 0 2px 8px rgba(110, 110, 115, 0.3);
}

/* ===== Anomaly ===== */

.tpm-anomaly-flag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    margin-top: 8px;
}

.tpm-anomaly-flag .icon {
    font-size: 0.9rem;
}

.tpm-anomaly-input {
    width: 100%;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1.5px solid rgba(245, 158, 11, 0.3);
    font-size: 0.85rem;
    color: #1d1d1f;
    outline: none;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
    margin-top: 8px;
    background: rgba(245, 158, 11, 0.04);
}

.tpm-anomaly-input:focus {
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

.tpm-anomaly-input::placeholder {
    color: #d4a574;
}

/* ===== Maintenance ===== */

.tpm-maint-card {
    background: #fff;
    border-radius: 14px;
    padding: 18px 20px;
    margin-bottom: 12px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-left: 4px solid rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
}

.tpm-maint-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.tpm-maint-card.tpm-overdue {
    border-left-color: #ef4444;
    background: rgba(239, 68, 68, 0.02);
}

.tpm-maint-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 10px;
}

.tpm-maint-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1d1d1f;
    flex: 1;
}

.tpm-maint-card-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: #86868b;
    margin-top: 4px;
}

.tpm-maint-card-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.tpm-maint-type {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.tpm-maint-type.preventive {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.tpm-maint-type.corrective {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.tpm-maint-type.predictive {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.tpm-maint-type.autonomous {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.tpm-maint-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* ===== Frequency Badge ===== */

.tpm-frequency {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.tpm-frequency.daily {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.tpm-frequency.weekly {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.tpm-frequency.monthly {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.tpm-frequency.quarterly {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.tpm-frequency.yearly {
    background: rgba(110, 110, 115, 0.1);
    color: #6e6e73;
}

/* ===== Modals ===== */

.tpm-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.tpm-modal {
    background: #fff;
    border-radius: 20px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.tpm-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.tpm-modal-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: #1d1d1f;
    margin: 0;
}

.tpm-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #86868b;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color 0.2s ease;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tpm-modal-close:hover {
    color: #1d1d1f;
    background: rgba(0, 0, 0, 0.04);
}

.tpm-modal-body {
    padding: 24px;
}

.tpm-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* ===== Forms ===== */

.tpm-form-group {
    margin-bottom: 18px;
}

.tpm-form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #86868b;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.tpm-form-input,
.tpm-form-select,
.tpm-form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #1d1d1f;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
    background: #fff;
}

.tpm-form-input:focus,
.tpm-form-select:focus,
.tpm-form-textarea:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.tpm-form-input::placeholder,
.tpm-form-textarea::placeholder {
    color: #c7c7cc;
}

.tpm-form-textarea {
    resize: vertical;
    min-height: 80px;
}

.tpm-form-select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236e6e73' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 10px center;
    background-repeat: no-repeat;
    background-size: 20px;
    padding-right: 36px;
}

.tpm-form-row {
    display: flex;
    gap: 12px;
}

.tpm-form-row .tpm-form-group {
    flex: 1;
}

.tpm-form-hint {
    font-size: 0.75rem;
    color: #86868b;
    margin-top: 4px;
}

/* ===== Stats Summary ===== */

.tpm-stats-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.tpm-stat-box {
    background: #fff;
    border-radius: 14px;
    padding: 18px 16px;
    text-align: center;
    border: 1px solid rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
}

.tpm-stat-box:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.tpm-stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: #1d1d1f;
    line-height: 1;
}

.tpm-stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #86868b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 6px;
}

.tpm-stat-box.accent .tpm-stat-value {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tpm-stat-box.success .tpm-stat-value {
    color: #10b981;
}

.tpm-stat-box.warning .tpm-stat-value {
    color: #f59e0b;
}

.tpm-stat-box.danger .tpm-stat-value {
    color: #ef4444;
}

/* Stats Grid (2-column) */

.tpm-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.tpm-stats-card {
    background: #fff;
    border-radius: 14px;
    padding: 20px;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.tpm-stats-card h3 {
    font-size: 1rem;
    font-weight: 700;
    color: #1d1d1f;
    margin: 0 0 16px 0;
}

.tpm-stats-card.full-width {
    grid-column: 1 / -1;
}

/* ===== Ranking ===== */

.tpm-ranking-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tpm-ranking-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    gap: 12px;
}

.tpm-ranking-item:last-child {
    border-bottom: none;
}

.tpm-ranking-position {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.tpm-ranking-position:nth-child(1) {
    background: #fef3c7;
    color: #d97706;
}

.tpm-ranking-item:nth-child(1) .tpm-ranking-position {
    background: #fef3c7;
    color: #d97706;
}

.tpm-ranking-item:nth-child(2) .tpm-ranking-position {
    background: #f1f5f9;
    color: #64748b;
}

.tpm-ranking-item:nth-child(3) .tpm-ranking-position {
    background: #fed7aa;
    color: #c2410c;
}

.tpm-ranking-name {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 600;
    color: #1d1d1f;
    min-width: 0;
}

.tpm-ranking-bar {
    width: 120px;
    height: 8px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}

.tpm-ranking-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.5s ease;
}

.tpm-ranking-score {
    font-size: 0.9rem;
    font-weight: 700;
    color: #1d1d1f;
    min-width: 40px;
    text-align: right;
}

/* ===== Pareto ===== */

.tpm-pareto-container {
    margin-top: 12px;
}

.tpm-pareto-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.tpm-pareto-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: #1d1d1f;
    min-width: 100px;
    flex-shrink: 0;
    text-align: right;
}

.tpm-pareto-bar {
    flex: 1;
    height: 24px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.tpm-pareto-bar-fill {
    height: 100%;
    border-radius: 6px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.5s ease;
    min-width: 2px;
}

.tpm-pareto-value {
    font-size: 0.8rem;
    font-weight: 700;
    color: #1d1d1f;
    min-width: 44px;
    text-align: right;
    flex-shrink: 0;
}

.tpm-pareto-cumulative {
    font-size: 0.7rem;
    color: #86868b;
    min-width: 40px;
    text-align: right;
    flex-shrink: 0;
}

/* ===== Actions ===== */

.tpm-action-card {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 10px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    gap: 12px;
    align-items: flex-start;
    transition: all 0.2s ease;
}

.tpm-action-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.tpm-action-checkbox {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.12);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
    color: transparent;
    background: #fff;
}

.tpm-action-checkbox:hover {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.04);
}

.tpm-action-checkbox.completed {
    background: #10b981;
    border-color: #10b981;
    color: #fff;
}

.tpm-action-content {
    flex: 1;
    min-width: 0;
}

.tpm-action-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: 4px;
}

.tpm-action-title.completed-text {
    text-decoration: line-through;
    color: #86868b;
}

.tpm-action-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 0.75rem;
    color: #86868b;
}

.tpm-action-meta .overdue {
    color: #ef4444;
    font-weight: 600;
}

/* ===== Priority Badges ===== */

.tpm-priority-low {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(110, 110, 115, 0.1);
    color: #6e6e73;
}

.tpm-priority-medium {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.tpm-priority-high {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.tpm-priority-urgent {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    background: rgba(185, 28, 28, 0.12);
    color: #b91c1c;
}

/* ===== Filters ===== */

.tpm-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.tpm-filter-select {
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: #fff;
    font-size: 0.85rem;
    color: #1d1d1f;
    outline: none;
    cursor: pointer;
    min-width: 140px;
    transition: border-color 0.2s ease;
}

.tpm-filter-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.tpm-filter-search {
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: #fff;
    font-size: 0.85rem;
    color: #1d1d1f;
    outline: none;
    min-width: 200px;
    transition: border-color 0.2s ease;
}

.tpm-filter-search:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.tpm-filter-search::placeholder {
    color: #c7c7cc;
}

/* ===== Empty State ===== */

.tpm-empty {
    text-align: center;
    padding: 60px 20px;
    color: #86868b;
}

.tpm-empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.tpm-empty h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1d1d1f;
    margin: 0 0 8px 0;
}

.tpm-empty p {
    font-size: 0.85rem;
    margin: 0 0 20px 0;
    color: #86868b;
}

/* ===== Template Cards ===== */

.tpm-template-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.tpm-template-card {
    padding: 16px;
    border-radius: 12px;
    border: 2px solid rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    background: #fff;
}

.tpm-template-card:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.04);
}

.tpm-template-card.selected {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.08);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.tpm-template-card .icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.tpm-template-card .name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1d1d1f;
}

.tpm-template-card .desc {
    font-size: 0.7rem;
    color: #86868b;
    margin-top: 4px;
}

.tpm-template-card .count {
    font-size: 0.65rem;
    color: #86868b;
    margin-top: 4px;
}

/* ===== Photo Upload ===== */

.tpm-photo-section {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.tpm-photo-box {
    width: 120px;
    text-align: center;
}

.tpm-photo-placeholder {
    width: 120px;
    height: 90px;
    border: 2px dashed rgba(0, 0, 0, 0.12);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.75rem;
    color: #86868b;
    flex-direction: column;
    gap: 4px;
    background: rgba(0, 0, 0, 0.02);
}

.tpm-photo-placeholder:hover {
    border-color: #667eea;
    color: #667eea;
    background: rgba(102, 126, 234, 0.04);
}

.tpm-photo-placeholder .photo-icon {
    font-size: 1.5rem;
}

.tpm-photo-preview {
    width: 120px;
    height: 90px;
    border-radius: 12px;
    object-fit: cover;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.08);
    transition: opacity 0.2s ease;
}

.tpm-photo-preview:hover {
    opacity: 0.85;
}

.tpm-photo-label {
    font-size: 0.7rem;
    color: #86868b;
    margin-top: 4px;
}

.tpm-photo-remove {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 0.7rem;
    cursor: pointer;
    padding: 2px 0;
    font-weight: 600;
}

.tpm-photo-remove:hover {
    text-decoration: underline;
}

/* ===== Back Button ===== */

.tpm-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 0;
    background: none;
    border: none;
    font-size: 0.9rem;
    color: #667eea;
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 16px;
}

.tpm-back-btn:hover {
    text-decoration: underline;
}

/* ===== Progress Bar ===== */

.tpm-progress {
    background: rgba(0, 0, 0, 0.06);
    border-radius: 6px;
    height: 8px;
    overflow: hidden;
    margin: 12px 0;
}

.tpm-progress-bar {
    height: 100%;
    border-radius: 6px;
    transition: width 0.5s ease;
    background: linear-gradient(90deg, #667eea, #764ba2);
}

.tpm-progress-text {
    font-size: 0.75rem;
    color: #86868b;
    margin-top: 4px;
}

/* ===== Loading State ===== */

.tpm-loading {
    text-align: center;
    padding: 40px;
    color: #86868b;
    font-size: 0.9rem;
}

.tpm-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(0, 0, 0, 0.06);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: tpm-spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

@keyframes tpm-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== Divider ===== */

.tpm-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.06);
    margin: 20px 0;
    border: none;
}

/* ===== Tooltip ===== */

.tpm-tooltip {
    position: relative;
    cursor: help;
}

.tpm-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1d1d1f;
    color: #fff;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 100;
}

.tpm-tooltip:hover::after {
    opacity: 1;
}

/* ===== Badge Count ===== */

.tpm-badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    background: #ef4444;
    color: #fff;
}

/* ===== List View Alternative ===== */

.tpm-list-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: #fff;
    border-radius: 12px;
    margin-bottom: 8px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
    cursor: pointer;
}

.tpm-list-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

.tpm-list-item-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
    background: rgba(102, 126, 234, 0.1);
}

.tpm-list-item-content {
    flex: 1;
    min-width: 0;
}

.tpm-list-item-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1d1d1f;
}

.tpm-list-item-subtitle {
    font-size: 0.8rem;
    color: #86868b;
    margin-top: 2px;
}

.tpm-list-item-trailing {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

/* ===== OEE Timeline ===== */

.tpm-timeline {
    position: relative;
    padding-left: 24px;
}

.tpm-timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 1px;
}

.tpm-timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.tpm-timeline-item:last-child {
    padding-bottom: 0;
}

.tpm-timeline-dot {
    position: absolute;
    left: -20px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #667eea;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.tpm-timeline-content {
    font-size: 0.85rem;
    color: #1d1d1f;
}

.tpm-timeline-time {
    font-size: 0.75rem;
    color: #86868b;
    margin-top: 2px;
}

/* ===== Responsive ===== */

@media (max-width: 768px) {
    .tpm-equipment-grid {
        grid-template-columns: 1fr;
    }

    .tpm-stats-summary {
        grid-template-columns: repeat(2, 1fr);
    }

    .tpm-stats-grid {
        grid-template-columns: 1fr;
    }

    .tpm-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .tpm-header-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .tpm-oee-breakdown {
        flex-direction: column;
    }

    .tpm-ranking-bar {
        width: 80px;
    }

    .tpm-pareto-label {
        min-width: 70px;
        font-size: 0.7rem;
    }

    .tpm-template-cards {
        grid-template-columns: 1fr;
    }

    .tpm-form-row {
        flex-direction: column;
    }

    .tpm-filters {
        flex-direction: column;
    }

    .tpm-filter-select,
    .tpm-filter-search {
        width: 100%;
        min-width: unset;
    }
}

@media (max-width: 480px) {
    .tpm-stats-summary {
        grid-template-columns: 1fr;
    }

    .tpm-modal-overlay {
        padding: 8px;
    }

    .tpm-modal {
        max-width: 100%;
        border-radius: 14px;
    }

    .tpm-modal-header {
        padding: 16px;
    }

    .tpm-modal-body {
        padding: 16px;
    }

    .tpm-modal-footer {
        padding: 12px 16px;
    }

    .tpm-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .tpm-tabs::-webkit-scrollbar {
        display: none;
    }

    .tpm-tab {
        white-space: nowrap;
        flex-shrink: 0;
        min-width: unset;
    }

    .tpm-check-result button {
        width: 44px;
        height: 44px;
        border-radius: 10px;
    }

    .tpm-action-checkbox {
        width: 44px;
        height: 44px;
        min-width: 44px;
    }

    .tpm-photo-section {
        flex-direction: column;
        align-items: flex-start;
    }

    .tpm-photo-box {
        width: 100%;
    }

    .tpm-photo-placeholder,
    .tpm-photo-preview {
        width: 100%;
        height: 140px;
    }

    .tpm-oee-value {
        font-size: 2.25rem;
    }

    .tpm-stat-value {
        font-size: 1.5rem;
    }

    .tpm-oee-metric-value {
        font-size: 1.5rem;
    }

    .tpm-card-footer {
        flex-direction: column;
        align-items: flex-start;
    }

    .tpm-maint-card-header {
        flex-direction: column;
    }

    .tpm-pareto-label {
        min-width: 60px;
        font-size: 0.65rem;
    }

    .tpm-ranking-bar {
        width: 60px;
    }

    .tpm-check-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .tpm-check-result {
        align-self: flex-end;
    }
}
