/* =====================================================
   Risk Register — Phase 64
   ===================================================== */

/* Container */
.rr-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 16px 8px 40px;
}

/* Header */
.rr-header {
    margin-bottom: 20px;
}

.rr-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.rr-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: #111827;
}

.rr-stats {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.rr-stat {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.rr-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
}

.rr-stat-label {
    font-size: 13px;
    color: #6b7280;
}

/* Buttons */
.rr-btn-primary {
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
.rr-btn-primary:hover { background: #1d4ed8; }
.rr-btn-primary:disabled { background: #93c5fd; cursor: not-allowed; }

.rr-btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.rr-btn-secondary:hover { background: #e5e7eb; }

.rr-btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 15px;
    transition: background 0.15s;
}
.rr-btn-icon:hover { background: #f3f4f6; }
.rr-btn-delete:hover { background: #fee2e2; }

/* Matrix */
.rr-matrix-wrapper {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
}

.rr-matrix-title {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 12px;
}

.rr-matrix {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rr-matrix-y-label {
    font-size: 11px;
    color: #9ca3af;
    text-align: center;
    writing-mode: horizontal-tb;
    margin-bottom: 2px;
}

.rr-matrix-grid {
    display: inline-flex;
    flex-direction: column;
    gap: 3px;
}

.rr-matrix-row {
    display: flex;
    align-items: center;
    gap: 3px;
}

.rr-matrix-row-label {
    width: 22px;
    text-align: right;
    font-size: 11px;
    color: #6b7280;
    font-weight: 600;
    padding-right: 4px;
    flex-shrink: 0;
}

.rr-matrix-cell {
    width: 44px;
    height: 44px;
    border: 1.5px solid;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    position: relative;
}

.rr-matrix-cell:hover {
    transform: scale(1.12);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 2;
}

.rr-matrix-count {
    font-size: 16px;
    font-weight: 700;
    color: #111827;
}

.rr-matrix-score {
    font-size: 10px;
    color: #9ca3af;
}

.rr-matrix-x-labels {
    display: flex;
    align-items: center;
    gap: 3px;
    margin-top: 2px;
}

.rr-matrix-x-label {
    width: 44px;
    text-align: center;
    font-size: 11px;
    color: #6b7280;
    font-weight: 600;
}

.rr-matrix-x-title {
    font-size: 11px;
    color: #9ca3af;
    text-align: center;
    margin-top: 2px;
    margin-left: 26px;
}

.rr-matrix-legend {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.rr-legend-item {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid;
    color: #374151;
}

/* Risk List */
.rr-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Risk Card */
.rr-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-left: 4px solid #6b7280;
    border-radius: 10px;
    padding: 14px 16px;
    transition: box-shadow 0.15s;
}
.rr-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.rr-card.rr-card-dimmed { opacity: 0.4; }

.rr-card-top {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.rr-score-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    height: 56px;
    border: 2px solid;
    border-radius: 10px;
    flex-shrink: 0;
    padding: 4px;
}

.rr-score-num {
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
}

.rr-score-level {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-top: 2px;
}

.rr-card-main {
    flex: 1;
    min-width: 0;
}

.rr-card-title {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 6px;
    line-height: 1.3;
}

.rr-card-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 6px;
}

.rr-tag {
    background: #f3f4f6;
    color: #374151;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
}

.rr-status-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid;
}

.rr-owner {
    font-size: 12px;
    color: #6b7280;
}

.rr-card-factors {
    font-size: 12px;
    color: #6b7280;
}

.rr-card-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.rr-card-desc {
    font-size: 13px;
    color: #4b5563;
    margin-top: 8px;
    line-height: 1.5;
}

.rr-card-mitigation {
    font-size: 13px;
    color: #4b5563;
    margin-top: 6px;
    background: #f0fdf4;
    border-left: 3px solid #86efac;
    padding: 6px 10px;
    border-radius: 0 6px 6px 0;
}

.rr-mitigation-label {
    font-weight: 600;
    color: #16a34a;
}

.rr-card-review {
    font-size: 12px;
    color: #6b7280;
    margin-top: 6px;
}

/* Empty state */
.rr-empty {
    text-align: center;
    padding: 48px 20px;
    color: #6b7280;
}
.rr-empty-icon { font-size: 40px; margin-bottom: 12px; }
.rr-empty-title { font-size: 18px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.rr-empty-text { font-size: 14px; margin-bottom: 16px; }

/* Loading / Error */
.rr-loading,
.rr-error {
    padding: 24px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}
.rr-error { color: #dc2626; }

/* Modal */
.rr-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.rr-modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
}

.rr-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid #f3f4f6;
    flex-shrink: 0;
}

.rr-modal-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #111827;
}

.rr-modal-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #6b7280;
    padding: 4px 6px;
    border-radius: 6px;
    line-height: 1;
}
.rr-modal-close:hover { background: #f3f4f6; }

.rr-modal-body {
    padding: 16px 20px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.rr-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px 18px;
    border-top: 1px solid #f3f4f6;
    flex-shrink: 0;
}

/* Form fields */
.rr-form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rr-form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.rr-form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

.rr-label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.rr-input,
.rr-select,
.rr-textarea {
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    color: #111827;
    background: #fff;
    transition: border-color 0.15s;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
}
.rr-input:focus,
.rr-select:focus,
.rr-textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.rr-textarea {
    resize: vertical;
    min-height: 72px;
}

/* Score preview */
.rr-score-preview { }

.rr-score-preview-inner {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1.5px solid;
    width: 100%;
    box-sizing: border-box;
    justify-content: center;
}

/* Toast */
.rr-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #111827;
    color: #fff;
    font-size: 14px;
    padding: 10px 20px;
    border-radius: 8px;
    z-index: 10001;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
    white-space: nowrap;
}
.rr-toast.rr-toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.rr-toast.rr-toast-error { background: #dc2626; }

/* Sprint action button on risk card */
.rr-card-sprint-action {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
}

.rr-btn-sprint {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.rr-btn-sprint:hover {
    background: #dbeafe;
    border-color: #93c5fd;
}

/* Responsive */
@media (max-width: 600px) {
    .rr-form-row-2 { grid-template-columns: 1fr; }
    .rr-form-row-3 { grid-template-columns: 1fr 1fr; }
    .rr-matrix-cell { width: 36px; height: 36px; }
    .rr-matrix-x-label { width: 36px; }
    .rr-score-badge { min-width: 48px; height: 48px; }
    .rr-title-row { flex-direction: column; align-items: flex-start; }
}
