:root {
  /* Professional Color Palette */
  --primary-color: #2c3e50; /* Deep Blue/Slate */
  --secondary-color: #34495e; /* Lighter Slate */
  --accent-color: #3498db; /* Professional Blue */
  --accent-hover: #2980b9;
  --background-color: #f4f6f8; /* Light gray background */
  --sidebar-bg: #1e293b; /* Dark sidebar */
  --sidebar-text: #e2e8f0;
  --card-bg: #ffffff;
  --text-main: #333333;
  --text-muted: #666666;
  --border-color: #e0e0e0;

  /* Severity Colors */
  --color-very-high: #e74c3c;
  --color-high: #e67e22;
  --color-moderate: #f1c40f;
  --color-low: #3498db;
  --color-negligible: #2ecc71;
  --color-nil: #bdc3c7;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", sans-serif;
  background-color: --background-color;
  color: var(--text-main);
  overflow: hidden; /* Prevent body scroll, use inner scroll */
  height: 100vh;
}

/* Layout */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 1rem;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 1rem 0.5rem 2rem 0.5rem;
  font-size: 1.2rem;
  color: var(--accent-color);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 1rem;
}

.brand i {
  font-size: 1.5rem;
}

.menu_group h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #94a3b8;
  margin-bottom: 0.5rem;
  padding-left: 0.75rem;
}

.menu_group ul {
  list-style: none;
  margin-bottom: 2rem;
}

.menu_group li {
  padding: 0.75rem 0.75rem;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
}

.menu_group li:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.menu_group li.active {
  background-color: var(--accent-color);
  color: #fff;
  font-weight: 500;
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.bottom-actions {
  margin-top: auto;
}

/* Main Content */
.content-area {
  flex-grow: 1;
  padding: 2rem;
  overflow-y: auto;
  position: relative;
}

/* Sections/Tabs */
.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-content.active {
  display: block;
}

/* Print Mode overrides */
.print-mode .tab-content {
    display: block !important;
    margin-bottom: 2rem;
    border-bottom: 2px dashed #ccc;
    padding-bottom: 2rem;
}
.print-mode .header-section {
    page-break-before: always;
}
.print-mode #general {
    page-break-before: avoid; /* First page */
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.header-section {
  margin-bottom: 2rem;
}

.header-section h1 {
  font-size: 1.8rem;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.header-section p {
  color: var(--text-muted);
}

/* Cards & Forms */
.card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.05),
    0 2px 4px -1px rgba(0, 0, 0, 0.02);
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-color);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.input-group.full-width {
  grid-column: 1 / -1;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--secondary-color);
}

input,
select,
textarea {
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Severity Specific Styles */
.status-bar {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: white;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.status-item {
  display: flex;
  flex-direction: column;
}

.status-item.flex-grow {
  flex: 1;
}

.read-only-text {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--primary-color);
}

.calculation-result {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-left: 5px solid var(--accent-color);
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 1rem;
}

.result-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.result-box input {
  text-align: center;
  font-size: 1.2rem;
  font-weight: bold;
  width: 120px;
  background: white;
}

.equals {
  font-size: 1.5rem;
  color: var(--text-muted);
}

/* Tables Layout */
.tables-container {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.table-wrapper.main-table {
  flex: 2;
  min-width: 400px;
}

.side-tables {
  flex: 1;
  min-width: 250px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.9rem;
}

th,
td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}

th {
  background-color: #f8fafc;
  font-weight: 600;
  color: var(--secondary-color);
}

td input[type="number"] {
  width: 100%;
  padding: 0.4rem;
}

/* Widen inputs in Barrier tables */
.barrier-table input[type="number"] {
    min-width: 60px;
}
.barrier-table input[type="text"] {
    min-width: 150px;
}
.barrier-table select {
    min-width: 100px;
}
.barrier-table th, .barrier-table td {
    padding: 0.5rem;
    font-size: 0.85rem;
}

/* Allow table response to overflow nicely if needed */
.table-responsive {
    overflow-x: auto;
}

tfoot td {
  border-top: 2px solid var(--border-color);
  border-bottom: none;
  background-color: #f8fafc;
}

/* Reference Table Colors */
.ref-table {
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
}
.ref-table th {
    background-color: #e2e8f0; /* Slightly darker than default */
    border-bottom: 2px solid #ccc;
}
.ref-table td {
    padding: 0.6rem;
    font-size: 0.85rem;
}
.note-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: -1rem;
    margin-bottom: 1rem;
}

.bg-red {
  background-color: rgba(231, 76, 60, 0.1);
  color: #c0392b;
}
.bg-orange {
  background-color: rgba(230, 126, 34, 0.1);
  color: #d35400;
}
.bg-yellow {
  background-color: rgba(241, 196, 15, 0.1);
  color: #b7950b;
}
.bg-blue {
  background-color: rgba(52, 152, 219, 0.1);
  color: #2980b9;
}
.bg-green {
  background-color: rgba(46, 204, 113, 0.1);
  color: #27ae60;
}
/* Risk Matrix Styles */
.matrix-container {
    overflow-x: auto;
}

.matrix-grid {
    display: grid;
    grid-template-columns: 150px repeat(5, 1fr);
    gap: 5px;
    min-width: 600px;
}

.prob-label {
    text-align: center;
    font-weight: bold;
    padding: 10px;
    background-color: #f1f5f9;
    border-radius: 4px;
}

.sev-label {
    grid-column: 1;
    display: flex;
    align-items: center;
    font-weight: bold;
    padding: 10px;
    background-color: #f1f5f9;
    border-radius: 4px;
}

.risk-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    padding: 15px;
    border-radius: 6px;
    color: white;
    cursor: default;
    transition: transform 0.2s, box-shadow 0.2s;
    font-size: 1.1rem;
    opacity: 0.35; /* Faded by default */
}

/* Base Colors */
.risk-cell.high { background-color: var(--color-very-high); }
.risk-cell.med { background-color: var(--color-moderate); color: #333; }
.risk-cell.low { background-color: var(--color-negligible); }

/* Active State */
.risk-cell.active-risk {
    opacity: 1;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(0,0,0,0.3);
    border: 3px solid #333;
    z-index: 10;
}

.risk-result-container {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.risk-box {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.risk-value {
    font-size: 1.5rem;
    font-weight: bold;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    min-width: 100px;
    text-align: center;
}

/* Risk Comparison */
.risk-comparison-container {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.risk-card {
    flex: 1;
    min-width: 300px;
}

.risk-card h3 {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    color: var(--secondary-color);
}

.risk-detail {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.risk-result-box {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.risk-index {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
}

.risk-tol {
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 4px;
}

.action-btn {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s;
    float: right;
    margin-top: -5px;
}

.action-btn:hover {
    background-color: var(--accent-hover);
}

#barrier_reg_table td {
    vertical-align: middle;
}
#barrier_reg_table input, #barrier_reg_table select {
    width: 100%;
}
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem;
  color: var(--text-muted);
  text-align: center;
}

.empty-state i {
  font-size: 4rem;
  margin-bottom: 1rem;
  color: #cbd5e1;
}

/* Risk Summary Table Colors (Matching Screenshot) */
.risk-summary-table th, .risk-summary-table td {
    border: 1px solid #000 !important; /* Explicit borders like screenshot */
    text-align: center;
    vertical-align: middle;
}

.bg-current-header { background-color: #2ecc71; color: black; font-weight: bold; } /* Green */
.bg-resultant-header { background-color: #2980b9; color: black; font-weight: bold; } /* Blue/Teal */

.bg-current-sub { background-color: #bdc3c7; color: black; } /* Light Grey */
.bg-resultant-sub { background-color: #85c1e9; color: black; } /* Light Blue */

.bg-current-light { background-color: #abebc6; } /* Light Green */
.bg-resultant-light { background-color: #fad7a0 !important; } /* Light Orange (for Total rows per screenshot) */

.bg-metric-label { font-weight: bold; background-color: #d5d8dc; } /* Grey */
.bg-metric-val { font-weight: bold; }

/* Override table styles specifically for this table */
.risk-summary-table {
    border: 2px solid #000;
} 

/* Responsive */
@media (max-width: 900px) {
  .app-container {
    flex-direction: column;
    overflow-y: auto;
  }
  .sidebar {
    width: 100%;
    height: auto;
    padding-bottom: 0;
  }
  .menu_group ul {
    display: flex;
    overflow-x: auto;
    margin-bottom: 0;
    padding-bottom: 1rem;
  }
  .menu_group li {
    white-space: nowrap;
  }
  .content-area {
    overflow-y: visible;
    height: auto;
  }
  .tables-container {
    flex-direction: column;
  }
}
