:root {
  --brand-gradient: linear-gradient(to right, #1a70f5, #1759e0);
  --surface-gradient: linear-gradient(to bottom right, #ffffff, #f8fafc);
}

/* Moderne scrollbar stil */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* Moderne fokus-ring */
*:focus {
  outline: 2px solid #2d8fff;
  outline-offset: 2px;
}

/* Smooth transitions */
.transition-all {
  transition-duration: 200ms;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Modern inputs */
input, select, textarea {
  transition: all 0.2s ease-in-out;
}

input:focus, select:focus, textarea:focus {
  box-shadow: 0 0 0 2px rgba(45, 143, 255, 0.1);
}

/* Button hover effects */
button:hover {
  transform: translateY(-1px);
}

/* Card hover effects */
.hover-card {
  transition: all 0.2s ease-in-out;
}

.hover-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px -5px rgba(0, 0, 0, 0.1);
}

/* Modern table styles */
table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}

th {
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  border-bottom: 2px solid #e2e8f0;
  padding: 0.75rem 1rem;
  font-weight: 600;
  text-align: left;
  color: #1f2937;
}

td {
  border: 1px solid #e2e8f0;
  padding: 0.75rem 1rem;
  transition: background-color 0.2s ease;
}

tr:hover td {
  background-color: #f8fafc;
}

table tr:first-child th:first-child {
  border-top-left-radius: 0.5rem;
}

table tr:first-child th:last-child {
  border-top-right-radius: 0.5rem;
}

table tr:last-child td:first-child {
  border-bottom-left-radius: 0.5rem;
}

table tr:last-child td:last-child {
  border-bottom-right-radius: 0.5rem;
}

th:not(:first-child),
td:not(:first-child) {
  border-left: none;
}

tr:not(:first-child) td {
  border-top: none;
}

.matrix-cell {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
    aspect-ratio: 1;
    display: flex !important;
    flex-flow: row wrap !important;
    align-content: flex-start !important;
    justify-content: flex-start !important;
    gap: 2px;
    padding: 6px;
    border-radius: 0.5rem;
    position: relative;
    transition: all 0.2s;
    min-height: 80px;
}

/* Adaptive risk dot sizing */
.matrix-cell .risk-dot {
    --base-size: 28px;
    --min-size: 16px;
    --dot-count: 1;
    width: clamp(var(--min-size), calc(var(--base-size) / (var(--dot-count) * 0.4)), var(--base-size)) !important;
    height: clamp(var(--min-size), calc(var(--base-size) / (var(--dot-count) * 0.4)), var(--base-size)) !important;
    font-size: clamp(8px, calc(12px / (var(--dot-count) * 0.4)), 12px) !important;
    margin: 2px !important;
    position: relative !important;
    background-color: #1F2937;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.2s;
    cursor: pointer;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    border-radius: 50%;
}

/* Update dot count based on number of dots */
.matrix-cell:has(.risk-dot:nth-child(1)) .risk-dot { --dot-count: 1; }
.matrix-cell:has(.risk-dot:nth-child(2)) .risk-dot { --dot-count: 2; }
.matrix-cell:has(.risk-dot:nth-child(3)) .risk-dot { --dot-count: 3; }
.matrix-cell:has(.risk-dot:nth-child(4)) .risk-dot { --dot-count: 4; }
.matrix-cell:has(.risk-dot:nth-child(5)) .risk-dot { --dot-count: 5; }
.matrix-cell:has(.risk-dot:nth-child(n+6)) .risk-dot { --dot-count: 6; }
.matrix-cell:has(.risk-dot:nth-child(n+8)) .risk-dot { --dot-count: 8; }
.matrix-cell:has(.risk-dot:nth-child(n+10)) .risk-dot { --dot-count: 10; }

.matrix-cell .risk-dot:hover {
    transform: scale(1.2);
    z-index: 20;
}

.risk-tooltip {
    opacity: 0;
    visibility: hidden;
    position: absolute;
    background: white;
    padding: 8px 16px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1000;
    pointer-events: none;
    transition: opacity 0.2s;
    white-space: nowrap;
    font-size: 12px;
    color: #1F2937;
    transform: translateY(-100%);
    top: -8px;
    font-weight: normal;
    min-width: 200px;
}

.risk-dot:hover .risk-tooltip {
    opacity: 1;
    visibility: visible;
}

@media (max-width: 768px) {
    .risk-tooltip {
        display: none;
    }
}

.risk-matrix {
    background: linear-gradient(to bottom right, #ffffff, #f9fafb);
    border-radius: 1rem;
    overflow: hidden;
}

.content-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(4px);
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
}

.content-section {
    position: relative;
}

.risk-matrix-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
}

.sannsynlighet-label {
    position: relative;
    margin-left: 2rem;
}

.matrix-grid {
    display: grid;
    gap: 0.5rem;
    width: 100%;
}

.matrix-header {
    display: grid;
    grid-template-columns: 80px repeat(auto-fit, minmax(60px, 1fr));
    gap: 0.5rem;
    align-items: center;
}

.matrix-row {
    display: grid;
    grid-template-columns: 80px repeat(auto-fit, minmax(60px, 1fr));
    gap: 0.5rem;
    align-items: center;
}

.row-label, .col-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #4B5563;
    text-align: center;
}

.empty-corner {
    width: 80px;
}

/* Styling for risk dots */
.risk-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    position: absolute;
    background-color: #1F2937;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.risk-dot:hover {
    transform: scale(1.5);
    z-index: 20;
}

.matrix-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    position: relative;
    transition: all 0.2s;
}

.matrix-cell:hover {
    transform: scale(1.05);
    z-index: 10;
}

.risk-tooltip {
    position: absolute;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
    max-width: 300px;
    word-wrap: break-word;
    white-space: normal !important;
}

.risk-dot:hover .risk-tooltip {
    visibility: visible;
    opacity: 1;
}

/* Risk form section styles */
.risk-form-section {
    position: relative;
    padding: 1.25rem;
    margin: 1rem 0;
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
}

.risk-form-section:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: -1.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: 97%;
    height: 1px;
    background: linear-gradient(to right, transparent, #e5e7eb, transparent);
}

.risk-form-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.risk-form-section-title svg {
    width: 1.25rem;
    height: 1.25rem;
    color: #6B7280;
}

.risk-level-label {
    text-align: center;
    width: 100%;
    display: block;
    margin-top: 0.5rem;
}

/* Modern Minimalistic Button Styles */
button {
    position: relative;
    transition: all 0.2s ease-in-out;
    font-weight: 500;
    font-size: 0.875rem;
}

/* Primary Button */
.btn-primary {
    background: #2563EB;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    border: none;
    box-shadow: none;
}

.btn-primary:hover {
    background: #1D4ED8;
    transform: none;
}

.btn-primary:active {
    background: #1E40AF;
}

/* Secondary Button */
.btn-secondary {
    background: transparent;
    color: #4B5563;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    border: 1px solid #E5E7EB;
}

.btn-secondary:hover {
    background: #F9FAFB;
    border-color: #D1D5DB;
    transform: none;
}

.btn-secondary:active {
    background: #F3F4F6;
}

/* Danger Button */
.btn-danger {
    background: #EF4444;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    border: none;
}

.btn-danger:hover {
    background: #DC2626;
    transform: none;
}

.btn-danger:active {
    background: #B91C1C;
}

/* Icon Button */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.375rem;
    border-radius: 0.375rem;
    background: transparent;
    color: #4B5563;
    border: none;
}

.btn-icon:hover {
    background: #F3F4F6;
    transform: none;
}

.btn-icon:active {
    background: #E5E7EB;
}

/* Disabled state for all buttons */
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Loading state */
button.loading {
    position: relative;
    color: transparent !important;
}

button.loading::after {
    content: "";
    position: absolute;
    width: 1rem;
    height: 1rem;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: button-loading-spinner 0.75s linear infinite;
}

@keyframes button-loading-spinner {
    from {
        transform: translate(-50%, -50%) rotate(0turn);
    }
    to {
        transform: translate(-50%, -50%) rotate(1turn);
    }
}

/* Focus styles */
button:focus {
    outline: 2px solid #2563EB;
    outline-offset: 2px;
}

button:focus:not(:focus-visible) {
    outline: none;
}

/* Tooltip styling */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 10px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 100;
}

[data-tooltip]:hover:before {
    opacity: 1;
    visibility: visible;
}

/* Rapport-spesifikk styling */
.report-matrix .matrix-cell {
    display: flex !important;
    flex-flow: row wrap !important;
    align-content: flex-start !important;
    justify-content: flex-start !important;
    gap: 2px !important;
    padding: 4px !important;
    min-height: 80px !important;
    min-width: 80px !important;
}

.report-matrix .risk-dot {
    --base-size: 20px;
    --min-size: 12px;
    --dot-count: 1;
    width: clamp(var(--min-size), calc(var(--base-size) / (var(--dot-count) * 0.4)), var(--base-size)) !important;
    height: clamp(var(--min-size), calc(var(--base-size) / (var(--dot-count) * 0.4)), var(--base-size)) !important;
    font-size: clamp(6px, calc(10px / (var(--dot-count) * 0.4)), 10px) !important;
    position: relative !important;
    margin: 1px !important;
    flex: 0 0 auto !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    background-color: #1F2937 !important;
    border: 1px solid #fff !important;
    color: #fff !important;
}

/* Update dot count based on number of dots for report */
.report-matrix .matrix-cell:has(.risk-dot:nth-child(1)) .risk-dot { --dot-count: 1; }
.report-matrix .matrix-cell:has(.risk-dot:nth-child(2)) .risk-dot { --dot-count: 2; }
.report-matrix .matrix-cell:has(.risk-dot:nth-child(3)) .risk-dot { --dot-count: 3; }
.report-matrix .matrix-cell:has(.risk-dot:nth-child(4)) .risk-dot { --dot-count: 4; }
.report-matrix .matrix-cell:has(.risk-dot:nth-child(5)) .risk-dot { --dot-count: 5; }
.report-matrix .matrix-cell:has(.risk-dot:nth-child(n+6)) .risk-dot { --dot-count: 6; }
.report-matrix .matrix-cell:has(.risk-dot:nth-child(n+8)) .risk-dot { --dot-count: 8; }
.report-matrix .matrix-cell:has(.risk-dot:nth-child(n+10)) .risk-dot { --dot-count: 10; }

.report-matrix-cell {
    min-height: 80px !important;
    min-width: 80px !important;
    display: flex !important;
    flex-flow: row wrap !important;
    align-content: flex-start !important;
    justify-content: flex-start !important;
    gap: 2px !important;
    padding: 4px !important;
}

@media print {
    .report-matrix .matrix-cell,
    .report-matrix-cell {
        break-inside: avoid;
        page-break-inside: avoid;
        display: flex !important;
        flex-flow: row wrap !important;
        align-content: flex-start !important;
        justify-content: flex-start !important;
        min-height: 80px !important;
        min-width: 80px !important;
    }

    .report-matrix .risk-dot {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* Legg til denne klassen */
.modal-open {
    overflow: hidden;
}