/* =====================================================
   MRP — Material Requirements Planning
   LeanSpace — mrp- prefix namespace
   ===================================================== */

/* ---- Wrapper ---- */

.mrp-wrap {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 20px 56px;
    box-sizing: border-box;
}

/* ---- Header ---- */

.mrp-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.mrp-title {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 700;
    color: #111827;
    line-height: 1.3;
}

.mrp-subtitle {
    margin: 0;
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
}

/* ---- Tab bar ---- */

.mrp-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 24px;
    padding: 6px;
    background: #f8fafc;
    border-radius: 12px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
}

.mrp-tabs::-webkit-scrollbar {
    display: none;
}

.mrp-tab {
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    flex-shrink: 0;
    font-family: inherit;
}

.mrp-tab:hover {
    background: #e2e8f0;
    color: #334155;
}

.mrp-tab--active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.30);
}

/* ---- Toolbar ---- */

.mrp-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.mrp-toolbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.mrp-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.mrp-search {
    flex: 1;
    max-width: 320px;
    padding: 8px 12px 8px 36px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    color: #111827;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 10px center;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}

.mrp-search:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

/* ---- Card ---- */

.mrp-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08), 0 2px 10px rgba(0, 0, 0, 0.05);
    border: 1.5px solid #f1f5f9;
    overflow: hidden;
    margin-bottom: 20px;
}

.mrp-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    gap: 12px;
    flex-wrap: wrap;
}

.mrp-card-title {
    font-size: 15px;
    font-weight: 700;
    color: #111827;
    margin: 0;
}

.mrp-card-body {
    padding: 16px 20px;
}

/* ---- Table ---- */

.mrp-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.mrp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    color: #111827;
}

.mrp-table thead th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
    z-index: 1;
}

.mrp-table tbody tr {
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.12s;
}

.mrp-table tbody tr:hover {
    background: #f8fafc;
}

.mrp-table tbody td {
    padding: 10px 14px;
    vertical-align: middle;
    line-height: 1.45;
}

.mrp-table tbody tr:last-child {
    border-bottom: none;
}

/* ---- Badges ---- */

.mrp-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
    padding: 2px 9px;
    white-space: nowrap;
    line-height: 1.6;
    letter-spacing: 0.01em;
}

/* Status badges */
.mrp-badge--planned {
    background: #f3f4f6;
    color: #4b5563;
    border: 1px solid #d1d5db;
}

.mrp-badge--draft {
    background: #f3f4f6;
    color: #4b5563;
    border: 1px solid #d1d5db;
}

.mrp-badge--released {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.mrp-badge--active {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.mrp-badge--in_progress {
    background: #fff7ed;
    color: #c2410c;
    border: 1px solid #fed7aa;
}

.mrp-badge--completed {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.mrp-badge--cancelled {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.mrp-badge--frozen {
    background: #f5f3ff;
    color: #6d28d9;
    border: 1px solid #ddd6fe;
}

/* Product type badges */
.mrp-type-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    padding: 2px 8px;
    white-space: nowrap;
    line-height: 1.6;
}

.mrp-type-badge--finished {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.mrp-type-badge--semi {
    background: #f5f3ff;
    color: #6d28d9;
    border: 1px solid #ddd6fe;
}

.mrp-type-badge--purchased {
    background: #f3f4f6;
    color: #4b5563;
    border: 1px solid #d1d5db;
}

.mrp-type-badge--phantom {
    background: transparent;
    color: #9ca3af;
    border: 1px dashed #d1d5db;
}

/* ---- BOM Tree ---- */

.mrp-bom-tree {
    font-size: 13px;
    line-height: 1.5;
}

.mrp-bom-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 7px;
    transition: background 0.12s;
    cursor: default;
}

.mrp-bom-item:hover {
    background: #f8fafc;
}

.mrp-bom-item--depth-0 { padding-left: 10px; }
.mrp-bom-item--depth-1 { padding-left: 34px; }
.mrp-bom-item--depth-2 { padding-left: 58px; }
.mrp-bom-item--depth-3 { padding-left: 82px; }
.mrp-bom-item--depth-4 { padding-left: 106px; }

.mrp-bom-item__indent {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    color: #d1d5db;
    font-size: 16px;
    line-height: 1;
    user-select: none;
}

.mrp-bom-item__connector {
    width: 18px;
    height: 18px;
    border-left: 2px solid #d1d5db;
    border-bottom: 2px solid #d1d5db;
    border-radius: 0 0 0 4px;
    flex-shrink: 0;
    margin-right: 4px;
}

.mrp-bom-item__info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.mrp-bom-item__name {
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

.mrp-bom-item__qty {
    font-size: 12px;
    color: #374151;
    background: #f3f4f6;
    border-radius: 4px;
    padding: 1px 7px;
    white-space: nowrap;
}

.mrp-bom-item__scrap {
    font-size: 11px;
    color: #9ca3af;
    white-space: nowrap;
}

.mrp-bom-item__actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s;
}

.mrp-bom-item:hover .mrp-bom-item__actions {
    opacity: 1;
}

.mrp-bom-item--root {
    background: #f0f4ff;
    border: 1.5px solid #c7d2fe;
    margin-bottom: 6px;
}

.mrp-bom-item--root .mrp-bom-item__name {
    color: #3730a3;
    font-size: 14px;
}

/* ---- MRP Suggestions ---- */

.mrp-suggestion-group {
    margin-bottom: 20px;
}

.mrp-suggestion-group-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 10px;
    padding: 6px 14px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mrp-suggestion-group-title--critical {
    background: #fef2f2;
    color: #b91c1c;
    border-left: 3px solid #ef4444;
}

.mrp-suggestion-group-title--high {
    background: #fff7ed;
    color: #c2410c;
    border-left: 3px solid #f97316;
}

.mrp-suggestion-group-title--normal {
    background: #eff6ff;
    color: #1d4ed8;
    border-left: 3px solid #3b82f6;
}

.mrp-suggestion-group-title--low {
    background: #f3f4f6;
    color: #4b5563;
    border-left: 3px solid #9ca3af;
}

.mrp-suggestion-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1.5px solid #e5e7eb;
    margin-bottom: 8px;
    background: #fff;
    transition: box-shadow 0.15s, border-color 0.15s;
    flex-wrap: wrap;
}

.mrp-suggestion-row:hover {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.mrp-urgency--critical {
    border-color: #fca5a5;
    background: #fff5f5;
}

.mrp-urgency--critical:hover {
    border-color: #ef4444;
    box-shadow: 0 2px 10px rgba(239, 68, 68, 0.12);
}

.mrp-urgency--high {
    border-color: #fdba74;
    background: #fffaf5;
}

.mrp-urgency--high:hover {
    border-color: #f97316;
    box-shadow: 0 2px 10px rgba(249, 115, 22, 0.12);
}

.mrp-urgency--normal {
    border-color: #93c5fd;
    background: #f8faff;
}

.mrp-urgency--low {
    border-color: #e5e7eb;
    background: #fafafa;
}

.mrp-suggestion-icon {
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 1px;
}

.mrp-suggestion-main {
    flex: 1;
    min-width: 0;
}

.mrp-suggestion-name {
    font-weight: 700;
    font-size: 14px;
    color: #111827;
    margin-bottom: 4px;
}

.mrp-suggestion-detail {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.5;
}

.mrp-suggestion-calc {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
    font-family: 'Courier New', monospace;
}

.mrp-suggestion-qty {
    font-size: 18px;
    font-weight: 700;
    color: #111827;
    flex-shrink: 0;
    text-align: right;
    white-space: nowrap;
}

.mrp-suggestion-qty-unit {
    font-size: 12px;
    font-weight: 400;
    color: #6b7280;
    display: block;
}

.mrp-suggestion-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    flex-wrap: wrap;
    align-items: flex-start;
}

/* ---- Calculation Status Card ---- */

.mrp-calc-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 14px;
    padding: 24px 28px;
    color: #fff;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.mrp-calc-card__info {
    flex: 1;
    min-width: 0;
}

.mrp-calc-card__title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 6px;
    line-height: 1.3;
}

.mrp-calc-card__subtitle {
    font-size: 13px;
    opacity: 0.85;
    margin: 0;
}

.mrp-calc-card__actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* ---- Metric Grid ---- */

.mrp-metric-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.mrp-metric {
    background: #fff;
    border-radius: 10px;
    padding: 16px 18px;
    border: 1.5px solid #f1f5f9;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mrp-metric__value {
    font-size: 26px;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.5px;
    line-height: 1;
}

.mrp-metric__label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
    line-height: 1.4;
}

.mrp-metric__icon {
    font-size: 20px;
    margin-bottom: 4px;
}

.mrp-metric--critical .mrp-metric__value { color: #dc2626; }
.mrp-metric--warning  .mrp-metric__value { color: #d97706; }
.mrp-metric--ok       .mrp-metric__value { color: #16a34a; }
.mrp-metric--info     .mrp-metric__value { color: #2563eb; }

/* ---- Routing Steps ---- */

.mrp-routing-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mrp-routing-step {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px 16px;
    transition: box-shadow 0.15s;
}

.mrp-routing-step:hover {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.07);
}

.mrp-routing-step__num {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mrp-routing-step__body {
    flex: 1;
    min-width: 0;
}

.mrp-routing-step__name {
    font-weight: 600;
    font-size: 14px;
    color: #111827;
    margin-bottom: 4px;
}

.mrp-routing-step__meta {
    font-size: 12px;
    color: #6b7280;
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.mrp-routing-step__actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s;
}

.mrp-routing-step:hover .mrp-routing-step__actions {
    opacity: 1;
}

/* ---- Capacity bar ---- */

.mrp-capacity-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.mrp-capacity-label {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    width: 160px;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mrp-capacity-bar-wrap {
    flex: 1;
    height: 10px;
    background: #f1f5f9;
    border-radius: 5px;
    overflow: hidden;
}

.mrp-capacity-bar {
    height: 100%;
    border-radius: 5px;
    transition: width 0.5s ease;
    min-width: 2px;
}

.mrp-capacity-bar--ok      { background: #22c55e; }
.mrp-capacity-bar--warn    { background: #f59e0b; }
.mrp-capacity-bar--danger  { background: #ef4444; }

.mrp-capacity-pct {
    font-size: 13px;
    font-weight: 700;
    color: #374151;
    width: 44px;
    text-align: right;
    flex-shrink: 0;
}

/* ---- Progress bar (Work Orders) ---- */

.mrp-progress-wrap {
    height: 6px;
    background: #f1f5f9;
    border-radius: 3px;
    overflow: hidden;
    min-width: 80px;
}

.mrp-progress-bar {
    height: 100%;
    border-radius: 3px;
    background: #667eea;
    transition: width 0.4s ease;
    min-width: 2px;
}

.mrp-progress-label {
    font-size: 11px;
    color: #6b7280;
    margin-top: 3px;
    white-space: nowrap;
}

/* ---- Empty state ---- */

.mrp-empty-state {
    text-align: center;
    padding: 60px 24px;
    color: #374151;
}

.mrp-empty-state__icon {
    font-size: 52px;
    margin-bottom: 14px;
    line-height: 1;
}

.mrp-empty-state__title {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 8px;
    color: #111827;
}

.mrp-empty-state__hint {
    font-size: 14px;
    color: #9ca3af;
    margin: 0;
    line-height: 1.6;
    max-width: 380px;
    margin-left: auto;
    margin-right: auto;
}

.mrp-empty-state__action {
    margin-top: 20px;
}

/* ---- Modal overlay ---- */

.mrp-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 9100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    backdrop-filter: blur(2px);
}

/* ---- Modal ---- */

.mrp-modal {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.20);
    animation: mrpModalIn 0.18s ease;
    overflow: hidden;
}

.mrp-modal--lg {
    max-width: 900px;
}

.mrp-modal--sm {
    max-width: 440px;
}

@keyframes mrpModalIn {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.mrp-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px 14px;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
    gap: 12px;
}

.mrp-modal-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #111827;
    flex: 1;
    min-width: 0;
}

.mrp-modal-close {
    background: none;
    border: none;
    font-size: 18px;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.mrp-modal-close:hover {
    background: #f3f4f6;
    color: #374151;
}

.mrp-modal-body {
    padding: 18px 22px;
    overflow-y: auto;
    flex: 1;
}

.mrp-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 22px;
    border-top: 1px solid #f1f5f9;
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* ---- Form ---- */

.mrp-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.mrp-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 4px;
}

.mrp-form-row--3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.mrp-form-row--full {
    grid-template-columns: 1fr;
}

.mrp-form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 14px;
}

.mrp-form-group--wide {
    grid-column: 1 / -1;
}

.mrp-form-group label {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.mrp-form-group input,
.mrp-form-group select,
.mrp-form-group textarea {
    padding: 8px 11px;
    border: 1.5px solid #e5e7eb;
    border-radius: 7px;
    font-size: 14px;
    color: #111827;
    background: #fafafa;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
    box-sizing: border-box;
    width: 100%;
}

.mrp-form-group input:focus,
.mrp-form-group select:focus,
.mrp-form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
    background: #fff;
}

.mrp-form-group textarea {
    resize: vertical;
    min-height: 72px;
}

.mrp-form-group select {
    cursor: pointer;
    appearance: auto;
}

.mrp-form-hint {
    font-size: 11px;
    color: #9ca3af;
    margin: 3px 0 0;
    line-height: 1.5;
}

.mrp-section-title {
    font-size: 13px;
    font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 20px 0 12px;
    padding-bottom: 7px;
    border-bottom: 1.5px solid #f1f5f9;
}

/* ---- Buttons ---- */

.mrp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 18px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s, box-shadow 0.15s, transform 0.1s;
    line-height: 1;
    white-space: nowrap;
    font-family: inherit;
}

.mrp-btn:active { transform: scale(0.97); }

.mrp-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.mrp-btn--primary {
    background: #667eea;
    color: #fff;
    box-shadow: 0 1px 4px rgba(102, 126, 234, 0.30);
}

.mrp-btn--primary:hover:not(:disabled) {
    background: #5a6fd8;
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.40);
}

.mrp-btn--secondary {
    background: #fff;
    color: #374151;
    border: 1.5px solid #d1d5db;
}

.mrp-btn--secondary:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #9ca3af;
}

.mrp-btn--success {
    background: #16a34a;
    color: #fff;
    box-shadow: 0 1px 4px rgba(22, 163, 74, 0.25);
}

.mrp-btn--success:hover:not(:disabled) {
    background: #15803d;
    box-shadow: 0 3px 10px rgba(22, 163, 74, 0.35);
}

.mrp-btn--danger {
    background: #fef2f2;
    color: #dc2626;
    border: 1.5px solid #fecaca;
}

.mrp-btn--danger:hover:not(:disabled) {
    background: #dc2626;
    color: #fff;
    border-color: #dc2626;
}

.mrp-btn--warning {
    background: #fff7ed;
    color: #c2410c;
    border: 1.5px solid #fed7aa;
}

.mrp-btn--warning:hover:not(:disabled) {
    background: #ea580c;
    color: #fff;
    border-color: #ea580c;
}

.mrp-btn--ai {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    color: #fff;
    box-shadow: 0 1px 4px rgba(124, 58, 237, 0.25);
}

.mrp-btn--ai:hover:not(:disabled) {
    background: linear-gradient(135deg, #6d28d9 0%, #5b21b6 100%);
    box-shadow: 0 3px 10px rgba(124, 58, 237, 0.35);
}

.mrp-btn--white {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(4px);
}

.mrp-btn--white:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.55);
}

.mrp-btn--sm {
    padding: 5px 12px;
    font-size: 12px;
    border-radius: 6px;
}

.mrp-btn--xs {
    padding: 3px 8px;
    font-size: 11px;
    border-radius: 5px;
}

/* ---- AI Planner ---- */

.mrp-ai-section {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 20px;
    align-items: start;
}

.mrp-ai-insights {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mrp-ai-insight-card {
    background: #fff;
    border-radius: 10px;
    border: 1.5px solid #e5e7eb;
    padding: 14px 16px;
    transition: box-shadow 0.15s;
}

.mrp-ai-insight-card:hover {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.07);
}

.mrp-ai-insight-card--bottleneck {
    border-left: 3px solid #ef4444;
}

.mrp-ai-insight-card--risk {
    border-left: 3px solid #f59e0b;
}

.mrp-ai-insight-card--timing {
    border-left: 3px solid #3b82f6;
}

.mrp-ai-insight-card--ok {
    border-left: 3px solid #22c55e;
}

.mrp-ai-insight-title {
    font-size: 13px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mrp-ai-insight-body {
    font-size: 13px;
    color: #374151;
    line-height: 1.6;
}

/* AI Chat panel */

.mrp-ai-chat {
    background: #fff;
    border-radius: 12px;
    border: 1.5px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    height: 480px;
}

.mrp-ai-chat-header {
    padding: 14px 16px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
    font-weight: 700;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.mrp-ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mrp-ai-chat-msg {
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.55;
    max-width: 90%;
    word-break: break-word;
}

.mrp-ai-chat-msg--user {
    background: #667eea;
    color: #fff;
    align-self: flex-end;
    border-radius: 12px 12px 3px 12px;
}

.mrp-ai-chat-msg--ai {
    background: #f8fafc;
    color: #111827;
    align-self: flex-start;
    border: 1px solid #e5e7eb;
    border-radius: 12px 12px 12px 3px;
}

.mrp-ai-chat-msg--thinking {
    background: #f3f4f6;
    color: #9ca3af;
    font-style: italic;
    align-self: flex-start;
}

.mrp-ai-chat-input-row {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #f1f5f9;
    flex-shrink: 0;
}

.mrp-ai-chat-input {
    flex: 1;
    padding: 8px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    min-height: 38px;
    max-height: 90px;
    transition: border-color 0.15s;
}

.mrp-ai-chat-input:focus {
    outline: none;
    border-color: #667eea;
}

/* ---- Plan items list / Gantt-light ---- */

.mrp-plan-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.12s;
    flex-wrap: wrap;
}

.mrp-plan-item:last-child {
    border-bottom: none;
}

.mrp-plan-item:hover {
    background: #f8fafc;
}

.mrp-plan-item__product {
    font-weight: 600;
    font-size: 14px;
    color: #111827;
    flex: 1;
    min-width: 120px;
}

.mrp-plan-item__qty {
    font-size: 13px;
    color: #374151;
    white-space: nowrap;
}

.mrp-plan-item__dates {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
}

/* ---- Loading states ---- */

.mrp-loading {
    text-align: center;
    padding: 48px 24px;
    color: #9ca3af;
    font-size: 15px;
}

.mrp-loading::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #e5e7eb;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: mrpSpin 0.7s linear infinite;
    vertical-align: middle;
    margin-left: 8px;
}

@keyframes mrpSpin {
    to { transform: rotate(360deg); }
}

/* ---- Plan selector ---- */

.mrp-plan-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.mrp-plan-selector label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}

.mrp-plan-selector select {
    flex: 1;
    max-width: 300px;
    padding: 7px 10px;
    border: 1.5px solid #e5e7eb;
    border-radius: 7px;
    font-size: 14px;
    color: #111827;
    background: #fff;
    font-family: inherit;
    cursor: pointer;
}

.mrp-plan-selector select:focus {
    outline: none;
    border-color: #667eea;
}

/* ---- Status click-advance ---- */

.mrp-status-btn {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.mrp-status-btn:hover {
    filter: brightness(0.9);
}

.mrp-status-btn::after {
    content: ' ▶';
    font-size: 9px;
    opacity: 0.6;
}

/* ---- Inline indicator ---- */

.mrp-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
}

.mrp-indicator--ok    { color: #16a34a; }
.mrp-indicator--warn  { color: #d97706; }
.mrp-indicator--empty { color: #9ca3af; }

/* ---- Info rows ---- */

.mrp-info-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #6b7280;
    padding: 3px 0;
}

.mrp-info-row strong {
    color: #374151;
    font-weight: 600;
}

/* =====================================================
   Responsive
   ===================================================== */

@media (max-width: 1200px) {
    .mrp-metric-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .mrp-ai-section {
        grid-template-columns: 1fr;
    }

    .mrp-ai-chat {
        height: 360px;
    }
}

@media (max-width: 900px) {
    .mrp-wrap {
        padding: 16px 14px 40px;
    }

    .mrp-capacity-label {
        width: 120px;
    }
}

@media (max-width: 768px) {
    .mrp-wrap {
        padding: 12px 10px 36px;
    }

    .mrp-title {
        font-size: 18px;
    }

    .mrp-metric-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .mrp-form-row {
        grid-template-columns: 1fr;
    }

    .mrp-form-row--3 {
        grid-template-columns: 1fr;
    }

    .mrp-modal {
        max-width: 100%;
        max-height: 95vh;
        border-radius: 14px 14px 0 0;
        margin-top: auto;
    }

    .mrp-modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .mrp-suggestion-row {
        flex-wrap: wrap;
    }

    .mrp-bom-item--depth-3 { padding-left: 60px; }
    .mrp-bom-item--depth-4 { padding-left: 80px; }

    .mrp-calc-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .mrp-capacity-row {
        flex-wrap: wrap;
    }

    .mrp-capacity-label {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .mrp-metric-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .mrp-metric__value {
        font-size: 20px;
    }

    .mrp-tabs {
        gap: 4px;
        padding: 4px;
    }

    .mrp-tab {
        padding: 8px 12px;
        font-size: 12px;
    }

    .mrp-modal-header,
    .mrp-modal-body,
    .mrp-modal-footer {
        padding-left: 16px;
        padding-right: 16px;
    }

    .mrp-table thead th,
    .mrp-table tbody td {
        padding: 8px 10px;
    }
}
