/*
 * styles.css — application stylesheet (TRA-12 brand-aligned).
 *
 * Loads after styles/tokens.css. All visual constants come from tokens;
 * this file should contain zero literal hex codes, named colours, or
 * pixel/rem values for spacing/typography (border widths and shadow
 * specs are exempt). Component patterns follow Brand System v1.0
 * Section 8 (buttons, forms, tables, cards, navigation, banners).
 *
 * Tokens.css defines body defaults (font, colour, background); the body
 * rule below adds layout-only properties on top.
 */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  padding: 2rem 2rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

header .subtitle {
  margin: 0.25rem 0 0;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

main {
  flex: 1;
  padding: 2rem;
  max-width: 800px;
  width: 100%;
}

.status-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.5rem;
}

.status-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.status-card p {
  margin: 0.25rem 0;
}

.status-card a {
  color: var(--color-accent);
}

footer {
  padding: 1rem 2rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

/* Working-view header strip ----------------------------------------------- */

.working-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.working-header .engagement-label {
  font-size: 1.1rem;
  font-weight: 600;
}

.working-header .header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.save-indicator {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  min-width: 9rem;
  text-align: right;
}

.save-indicator--saved {
  color: var(--color-text-muted);
}

.save-indicator--dirty {
  color: var(--color-text-muted);
}

.save-indicator--saving {
  color: var(--color-text);
}

.save-indicator--failed {
  color: var(--color-error);
}

/* === Buttons (Brand System Section 8.1) ===================================
 * Five variants: Primary (default), Secondary (.secondary), Tertiary
 * (.btn-tertiary), Brand (.btn-brand), Destructive (.btn-destructive).
 * Three sizes: Small (.btn-sm) 32px, Default 40px, Large (.btn-lg) 48px.
 * States: hover darkens, focus shows 3px Slate Teal ring (no layout
 * shift), disabled at 50% opacity with no pointer.
 */

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0 var(--space-4);
  background: var(--color-accent);
  color: var(--color-text-inverse);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1;
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease-standard),
    border-color var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard);
}

button:hover {
  background: var(--color-accent-hover);
}

button:active {
  background: var(--color-accent-hover);
  filter: brightness(0.92);
}

button:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

button:disabled,
button:disabled:hover {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

button[hidden] {
  display: none;
}

button.btn-sm {
  min-height: 32px;
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
}

button.btn-lg {
  min-height: 48px;
  padding: 0 var(--space-5);
  font-size: var(--text-base);
}

/* Secondary: outlined accent. */
button.secondary {
  background: transparent;
  color: var(--color-accent);
  border-color: var(--color-accent);
}

button.secondary:hover {
  background: var(--color-surface-alt);
  color: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
}

/* Tertiary: text-only, used for low-importance actions. */
button.btn-tertiary {
  background: transparent;
  color: var(--color-text);
  border-color: transparent;
}

button.btn-tertiary:hover {
  background: var(--color-surface-alt);
}

/* Brand: Khaki marketing CTA only. */
button.btn-brand {
  background: var(--color-brand);
  color: var(--color-text);
}

button.btn-brand:hover {
  background: var(--tiree-khaki-200);
}

/* Destructive: irreversible actions. */
button.btn-destructive {
  background: var(--color-error);
  color: var(--color-text-inverse);
}

button.btn-destructive:hover {
  filter: brightness(0.92);
}

/* === Forms (Brand System Section 8.2) ====================================
 * Inputs, textareas, selects: 40px tall, 1px border, --radius-md, focus
 * ring 3px Slate Teal. Labels above inputs (handled at component level).
 * Required asterisk in --color-error (handled by component CSS that
 * adds the asterisk).
 */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  transition:
    border-color var(--duration-fast) var(--ease-standard),
    box-shadow var(--duration-fast) var(--ease-standard);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: var(--shadow-focus);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  cursor: not-allowed;
}

textarea {
  resize: vertical;
  min-height: var(--space-9); /* 6rem */
}

.note {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin: 0.5rem 0 0;
}

.placeholder {
  color: var(--color-text-muted);
  font-style: italic;
}

/* Working-view two-column body (sidebar + content pane) ------------------ */

.working-body {
  display: flex;
  align-items: stretch;
  min-height: calc(100vh - 12rem);
}

/* === Working-view sidebar (Brand System Section 8.5) ===================
 * White surface, 1px right border, no background fill on inactive items.
 * Active state uses Slate Teal text with a 2px Slate Teal left edge plus
 * a Khaki 50 (--color-surface-alt) tint for visual lift; chose this over
 * full-bleed Slate Teal background to preserve the light-on-light
 * sidebar feel and reserve solid Slate Teal for primary buttons and
 * table headers.
 */

.section-sidebar {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  padding: var(--space-4) 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
}

.section-sidebar .sidebar-item {
  display: block;
  width: 100%;
  min-height: auto;
  padding: var(--space-3) var(--space-4);
  background: transparent;
  color: var(--color-text);
  border: none;
  border-left: 2px solid transparent;
  border-radius: 0;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  text-align: left;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard);
}

.section-sidebar .sidebar-item:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
}

.section-sidebar .sidebar-item.active {
  background: var(--color-surface-alt);
  color: var(--color-accent);
  border-left-color: var(--color-accent);
  font-weight: var(--weight-semibold);
}

.section-sidebar .sidebar-item:focus-visible {
  outline: none;
  box-shadow: inset var(--shadow-focus);
}

.section-content {
  flex: 1 1 auto;
  padding: 1.5rem 2rem;
  overflow: auto;
  /*
   * Override the global "main { max-width: 800px }" rule (which is correct
   * for the centered list view but cripples the working view's section pane,
   * forcing the asset and threat tables into 800px and wrapping every cell).
   */
  max-width: none;
  min-width: 0;
}

.section-content h2 {
  margin: 0 0 1rem;
  font-size: 1.2rem;
  font-weight: 600;
}

/* Settings form ---------------------------------------------------------- */

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-width: 520px;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.settings-label {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.settings-field input,
.settings-field select {
  padding: 0.5rem;
  background: var(--color-surface-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 1rem;
}

.settings-note {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.settings-warning {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-style: italic;
  min-height: 1em;
}

/* Section toolbar (heading + primary action) ----------------------------- */

.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.section-toolbar h2 {
  margin: 0;
}

/* Asset / threat table --------------------------------------------------- */

/*
 * Tables can have many columns (asset has 7, threat has 8). On narrow
 * viewports the natural row width may exceed the available pane; the
 * wrapper provides horizontal scroll instead of letting cells wrap.
 */
/* === Tables (Brand System Section 8.3) ====================================
 * Slate Teal header (white text, 600, 12px), 12px 16px header padding,
 * 10px 16px body padding, 1px Light Grey bottom border on rows, hover
 * row Khaki 50, numeric columns right-aligned. Date columns ISO or
 * DD MMM YYYY, owned by component code (this CSS is alignment-only).
 */

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.asset-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.asset-table th,
.asset-table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.asset-table thead th {
  padding: var(--space-3) var(--space-4);
  background: var(--color-accent);
  color: var(--color-text-inverse);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.asset-table tbody td {
  border-bottom: 1px solid var(--color-border);
}

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

.asset-table tbody tr:hover {
  background: var(--color-surface-alt);
}

.asset-table .numeric-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.asset-table .actions-cell {
  white-space: nowrap;
  text-align: left;
}

.asset-table .actions-cell button {
  margin-right: var(--space-2);
}

/* Asset modal ------------------------------------------------------------ */

.asset-modal {
  width: min(640px, 92vw);
  max-height: 90vh;
  overflow: auto;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.5rem;
}

.asset-modal::backdrop {
  background: var(--color-overlay);
}

.asset-modal h2 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

.asset-modal h3 {
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.asset-modal .modal-field {
  display: block;
  margin-bottom: 0.75rem;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.asset-modal .modal-field span {
  display: block;
  margin-bottom: 0.25rem;
}

.asset-modal .modal-field input,
.asset-modal .modal-field textarea,
.asset-modal .modal-field select {
  width: 100%;
  padding: 0.5rem;
  background: var(--color-surface-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 1rem;
}

.asset-modal .locked-display {
  display: inline-block;
  padding: 0.5rem;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-text);
  font-style: italic;
}

.asset-modal .modal-preview {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.95rem;
}

.asset-modal .modal-preview .preview-label {
  color: var(--color-text-muted);
  margin-right: 0.4rem;
}

.asset-modal .dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.asset-modal .error {
  color: var(--color-error);
  font-size: 0.9rem;
  min-height: 1.2em;
  margin: 0.5rem 0;
}

.asset-modal .catalog-description {
  margin: 0 0 1rem;
  padding: 0.6rem 0.8rem;
  background: var(--color-surface-alt);
  border-left: 3px solid var(--color-accent);
  border-radius: 4px;
  color: var(--color-text);
  font-size: 0.9rem;
  line-height: 1.45;
}

.asset-modal .field-help {
  display: block;
  margin-top: 0.25rem;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-style: italic;
}

/* Pairings section ------------------------------------------------------- */

.gate-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.pairings-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.pairings-toolbar-left,
.pairings-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.sort-label {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.sort-label select {
  padding: 0.35rem 0.5rem;
  background: var(--color-surface-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.pairings-count {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

button.secondary {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

button.secondary:hover {
  background: var(--color-surface-alt);
  opacity: 1;
}

.pairings-table .denormalized-cell {
  color: var(--color-text-muted);
}

.pairings-toast {
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--tiree-teal-50);
  border-left: 4px solid var(--color-info);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: var(--text-sm);
}

/* === Banners and callouts (Brand System Section 8.6) ====================
 * Five variants: info, success, warning, error, brand. Each has a
 * tinted background and a 4px left border in the semantic colour.
 * Lucide icon glyph is owned by the consuming component (this CSS
 * provides the box; the icon comes from the SVG inline).
 */

.banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-left: 4px solid transparent;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

.banner.banner-info {
  background: var(--tiree-teal-50);
  border-left-color: var(--color-info);
  color: var(--color-text);
}

.banner.banner-success {
  background: var(--color-banner-success-bg);
  border-left-color: var(--color-success);
  color: var(--color-text);
}

.banner.banner-warning {
  background: var(--color-banner-warning-bg);
  border-left-color: var(--color-warning);
  color: var(--color-text);
}

.banner.banner-error {
  background: var(--color-banner-error-bg);
  border-left-color: var(--color-error);
  color: var(--color-text);
}

.banner.banner-brand {
  background: var(--tiree-khaki-50);
  border-left-color: var(--tiree-khaki);
  color: var(--color-text);
}

.banner__icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
}

.banner__body {
  flex: 1 1 auto;
}

.banner__body p {
  margin: 0;
}

/* Bulk-create modal ------------------------------------------------------ */

.pairings-create-modal {
  width: min(820px, 95vw);
}

.dialog-lead {
  margin: 0 0 1rem;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.bulk-pickers {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.bulk-picker {
  flex: 1 1 320px;
  min-width: 0;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.75rem;
}

.bulk-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  gap: 0.5rem;
}

.bulk-picker-header h3 {
  margin: 0;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.bulk-picker-actions {
  display: flex;
  gap: 0.4rem;
}

.bulk-picker-actions button {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
}

.bulk-list {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.bulk-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--color-text);
}

.bulk-item:hover {
  background: var(--color-surface-alt);
}

.bulk-item input[type="checkbox"] {
  margin: 0;
  flex: 0 0 auto;
}

.bulk-item-name {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bulk-item-category {
  flex: 0 0 auto;
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.bulk-list-empty {
  margin: 0.5rem 0;
  color: var(--color-text-muted);
  font-style: italic;
  font-size: 0.9rem;
}

.bulk-preview {
  margin: 1rem 0 0;
  font-size: 0.95rem;
  color: var(--color-text);
  font-weight: 600;
}

/* Pairing score modal --------------------------------------------------- */

.pairing-score-modal {
  width: min(720px, 95vw);
}

.threat-probability-summary {
  margin: 0.5rem 0 1rem;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.flori-block {
  margin: 1.25rem 0;
  padding: 1rem;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 6px;
}

.flori-block h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--color-text);
}

.flori-overview {
  margin: 0 0 0.75rem;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  white-space: pre-wrap;
}

.flori-readonly {
  margin: 0 0 0.4rem;
  color: var(--color-text);
}

.flori-note {
  margin: 0 0 0.5rem;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-style: italic;
}

.flori-descriptor {
  margin-top: 0.5rem;
  white-space: pre-wrap;
}

.flori-descriptor.flori-descriptor-empty {
  color: var(--color-text-muted);
  font-style: italic;
  background: transparent;
  border-left-color: var(--color-border);
}

.pairing-score-preview {
  position: sticky;
  bottom: 0;
  background: var(--color-surface);
  margin-top: 1rem;
}

/* List view header and table ---------------------------------------------- */

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.list-header h2 {
  margin: 0;
}

.list-actions {
  display: flex;
  gap: 0.5rem;
}

.engagement-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  font-size: var(--text-sm);
}

.engagement-table th,
.engagement-table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  vertical-align: middle;
}

.engagement-table thead th {
  background: var(--color-accent);
  color: var(--color-text-inverse);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.02em;
  cursor: pointer;
  user-select: none;
}

.engagement-table thead th.actions-col {
  cursor: default;
}

.engagement-table tbody td {
  border-bottom: 1px solid var(--color-border);
}

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

.engagement-table tbody tr:hover {
  background: var(--color-surface-alt);
}

.engagement-table .clickable-cell {
  cursor: pointer;
}

.engagement-table .actions-cell {
  white-space: nowrap;
  text-align: right;
}

.engagement-table .actions-cell button {
  margin-left: var(--space-2);
}

.empty-state {
  padding: 2rem;
  text-align: center;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin: 0;
}

/* New engagement dialog --------------------------------------------------- */

.new-engagement-dialog {
  width: min(480px, 90vw);
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.5rem;
}

.new-engagement-dialog::backdrop {
  background: var(--color-overlay);
}

.new-engagement-dialog h2 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

.new-engagement-dialog label {
  display: block;
  margin-bottom: 0.85rem;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.new-engagement-dialog input,
.new-engagement-dialog textarea {
  margin-top: 0.3rem;
  display: block;
}

.new-engagement-dialog .dialog-intro {
  margin: 0 0 1rem;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

.new-engagement-dialog .eng-help {
  display: block;
  margin-top: 0.3rem;
}

.new-engagement-dialog .dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.new-engagement-dialog .error {
  color: var(--color-error);
  font-size: 0.9rem;
  margin: 0.5rem 0;
  min-height: 1.2em;
}

/* Vulnerability section --------------------------------------------------- */

.section-lead {
  margin: 0 0 1rem;
  color: var(--color-text-muted);
  font-size: 0.95rem;
  max-width: 70ch;
}

.vulnerabilities-table tbody tr.vulnerability-row {
  cursor: pointer;
}

.vulnerabilities-table tbody tr.vulnerability-row:hover,
.vulnerabilities-table tbody tr.vulnerability-row:focus {
  background: var(--color-surface-alt);
  outline: none;
}

.vulnerabilities-table .unscored-cell {
  color: var(--color-text-muted);
  font-style: italic;
}

/*
 * Rating badges (TRA-12). Solid fills with the five-band rating tokens.
 * Text colour comes from the paired --color-rating-{band}-text token,
 * which encodes the higher-contrast direction per the WCAG analysis in
 * tokens.css. Badge text size is var(--text-xs) at semibold weight.
 */
.rating-badge {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.rating-badge.rating-very-low {
  background: var(--color-rating-very-low);
  color: var(--color-rating-very-low-text);
}

.rating-badge.rating-low {
  background: var(--color-rating-low);
  color: var(--color-rating-low-text);
}

.rating-badge.rating-moderate {
  background: var(--color-rating-moderate);
  color: var(--color-rating-moderate-text);
}

.rating-badge.rating-high {
  background: var(--color-rating-high);
  color: var(--color-rating-high-text);
}

.rating-badge.rating-very-high {
  background: var(--color-rating-very-high);
  color: var(--color-rating-very-high-text);
}

/* Vulnerability scoring modal -------------------------------------------- */

.vulnerability-score-modal {
  width: min(820px, 95vw);
}

.fourd-block {
  margin: 1.25rem 0;
  padding: 1rem 1rem 0.75rem;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 6px;
}

.fourd-block legend {
  padding: 0 0.5rem;
  font-weight: 600;
  font-size: 1rem;
  color: var(--color-text);
}

.fourd-overview {
  margin: 0.25rem 0 0.75rem;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.fourd-options {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.fourd-option {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  cursor: pointer;
  background: var(--color-surface);
  transition: background 0.1s, border-color 0.1s;
}

.fourd-option:hover {
  background: var(--color-surface-alt);
}

.fourd-option input[type="radio"] {
  margin-top: 0.25rem;
  flex: 0 0 auto;
}

.fourd-option-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1 1 auto;
  min-width: 0;
}

.fourd-option-head {
  font-weight: 600;
  color: var(--color-text);
}

.fourd-option-description {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

.fourd-option:has(input:checked) {
  border-color: var(--color-accent);
  background: var(--color-surface-alt);
}

.vulnerability-observation {
  margin-top: 1.25rem;
}

.vulnerability-observation h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  text-transform: none;
  letter-spacing: 0;
}

.vulnerability-observation textarea {
  width: 100%;
  resize: vertical;
}

.vulnerability-score-preview {
  position: sticky;
  bottom: 0;
  background: var(--color-surface);
  margin-top: 1rem;
}

/* Risk Register section --------------------------------------------------- */

.filter-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin: 0 0 1rem;
}

.filter-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-summary {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-left: auto;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.filter-count {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.reset-link {
  background: none;
  border: none;
  color: var(--color-accent);
  cursor: pointer;
  padding: 0;
  font: inherit;
  font-size: 0.9rem;
  text-decoration: underline;
}

.reset-link:hover {
  color: var(--color-accent);
}

.filter-dropdown {
  position: relative;
}

.filter-trigger {
  font-size: 0.9rem;
  padding: 0.35rem 0.7rem;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  border-radius: 5px;
  cursor: pointer;
}

.filter-trigger::after {
  content: " ▾";
  font-size: 0.7rem;
  margin-left: 0.25rem;
  color: var(--color-text-muted);
}

.filter-dropdown.open .filter-trigger {
  border-color: var(--color-accent);
}

.filter-panel {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 0.25rem);
  min-width: 220px;
  max-height: 320px;
  overflow-y: auto;
  padding: 0.5rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  box-shadow: var(--shadow-3);
  z-index: 10;
}

.filter-dropdown.open .filter-panel {
  display: block;
}

.filter-select-all {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem 0.4rem;
  border-radius: 4px;
  color: var(--color-accent);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.filter-select-all:hover {
  background: var(--color-surface-alt);
}

.filter-separator {
  height: 1px;
  background: var(--color-border);
  margin: 0.35rem 0;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.4rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
}

.filter-option:hover {
  background: var(--color-surface-alt);
}

.filter-option input[type="checkbox"] {
  margin: 0;
  flex: 0 0 auto;
}

.risk-register-table th.sortable-header {
  cursor: pointer;
  user-select: none;
}

.risk-register-table th.sortable-header:hover {
  background: var(--color-surface-alt);
}

.risk-register-table th.sort-active {
  color: var(--color-accent);
}

.risk-register-table .sort-chevron {
  font-size: 0.75rem;
  margin-left: 0.15rem;
  color: var(--color-accent);
}

.risk-register-table tbody tr.row-unscored td {
  color: var(--color-text-muted);
}

.risk-register-table .rating-cell {
  white-space: nowrap;
}

.risk-register-table .rating-cell .rating-badge {
  display: inline-block;
}

/* Make the Risk Rating column slightly heavier to draw the eye to the
   bottom-line result. */
.risk-register-table tbody tr td:last-child .rating-badge {
  font-size: 0.85rem;
  padding: 0.2rem 0.7rem;
  font-weight: 700;
}

/* ===== TRA-8: Recommendations + Residual Risk views ===== */

.section-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.section-header-row h2 {
  margin: 0 0 0.25rem 0;
}

.section-header-row .section-lead {
  margin: 0;
}

.recommendations-table .badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-accent);
  color: var(--color-accent);
  white-space: nowrap;
}

.recommendations-table td {
  vertical-align: middle;
}

.recommendations-table td:last-child button {
  margin-right: 0.35rem;
}

/* Recommendation modal */

.recommendation-modal {
  width: min(960px, 96vw);
  max-height: 92vh;
}

.recommendation-modal h3 {
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  font-size: 1rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.25rem;
}

.recommendation-modal .risks-addressed-actions {
  margin: 0.5rem 0 0.75rem;
}

#mitigation-matrix-wrapper {
  margin-top: 0.5rem;
}

.matrix-empty {
  font-style: italic;
  color: var(--color-text-muted);
}

.mitigation-matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.mitigation-matrix th,
.mitigation-matrix td {
  border-bottom: 1px solid var(--color-border);
  padding: 0.4rem 0.5rem;
  text-align: left;
  vertical-align: middle;
}

.mitigation-matrix th {
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.mitigation-matrix select {
  width: 100%;
  font-size: 0.85rem;
  padding: 0.2rem 0.3rem;
}

.mitigation-matrix select.contribution-fully {
  background: var(--color-surface-alt);
  border-color: var(--color-success);
  font-weight: var(--weight-semibold);
}

.mitigation-matrix .matrix-remove {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  border-radius: 4px;
  padding: 0 0.5rem;
  font-size: 1rem;
  line-height: 1.4;
  cursor: pointer;
}

.mitigation-matrix .matrix-remove:hover {
  border-color: var(--color-error);
  color: var(--color-error);
}

/* Add Risks sub-modal */

.add-risks-modal {
  width: min(720px, 96vw);
  max-height: 90vh;
}

.add-risks-list {
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.25rem;
  margin-top: 0.5rem;
}

.add-risks-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
}

.add-risks-row:last-child {
  border-bottom: none;
}

.add-risks-row:hover {
  background: var(--color-surface-alt);
}

.add-risks-row-label {
  flex: 1 1 auto;
}

/* Residual Risk view */

.residual-risk-table .residual-delta {
  margin-left: 0.35rem;
  font-weight: 700;
}

.residual-risk-table .residual-delta-down {
  color: var(--color-success);
}

.residual-risk-table .residual-delta-equal {
  color: var(--color-text-muted);
}

.section-lead.muted {
  color: var(--color-text-muted);
  font-style: italic;
}

/* Engagement detail view (TRA-9) ------------------------------------------ */

.eng-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 760px;
}

.eng-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}

.eng-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: transparent;
  color: var(--color-text);
  border: none;
  border-radius: 0;
  padding: 0.85rem 1rem;
  text-align: left;
  font-family: var(--font-sans);
  cursor: pointer;
}

.eng-section-header:hover {
  background: var(--color-surface-alt);
  opacity: 1;
}

.eng-section-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.eng-chevron {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  transition: transform 0.1s ease;
}

.eng-section-body {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--color-border);
}

.eng-section-body[hidden] {
  display: none;
}

.eng-subheading {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.eng-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.eng-label {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.eng-help {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  line-height: 1.4;
  margin-top: 0.15rem;
}

.eng-help strong {
  color: var(--color-text);
  font-weight: 600;
}

.eng-form input[type="text"],
.eng-form input[type="date"],
.eng-form select,
.eng-form textarea {
  width: 100%;
  background: var(--color-surface-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.5rem;
  font-family: var(--font-sans);
  font-size: 1rem;
}

.eng-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.eng-list-empty {
  margin: 0;
  color: var(--color-text-muted);
  font-style: italic;
  font-size: 0.9rem;
}

.eng-list-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.eng-list-row input {
  flex: 1 1 auto;
}

.eng-list-row button,
.eng-assessor-row button,
.eng-list button {
  font-size: 0.85rem;
  padding: 0.35rem 0.7rem;
}

.eng-assessor-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 0.5rem;
  align-items: center;
}

@media (max-width: 720px) {
  .eng-assessor-row {
    grid-template-columns: 1fr;
  }
}

/* === Configuration tool (TRA-13) =========================================
 * Reuses the working-view shell (.working-header, .working-body,
 * .section-sidebar, .section-content) so the panel has the same chrome
 * as the engagement view. Rules below are scoped to .config-* classes
 * for the per-section content and the gear button.
 */

.config-button {
  padding: 0 var(--space-2);
  min-width: 40px;
}

.config-button svg {
  display: block;
}

.config-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.config-section-header h2 {
  margin: 0 0 var(--space-2);
}

.config-section-lead {
  margin: 0 0 var(--space-3);
  color: var(--color-text-muted);
  font-size: 0.9rem;
  line-height: 1.4;
  max-width: 60ch;
}

.config-section-actions {
  display: flex;
  gap: var(--space-2);
}

.config-form-slot:empty {
  display: none;
}

.config-form-slot {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.config-entry-form .modal-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
}

.config-entry-form .modal-field > span {
  font-weight: var(--weight-semibold);
  font-size: 0.9rem;
}

.config-entry-form .dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.config-entry-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.config-category-heading {
  margin: var(--space-4) 0 var(--space-1);
  font-size: 0.85rem;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.config-category-heading:first-child {
  margin-top: 0;
}

.config-entry-row {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  align-items: flex-start;
}

.config-entry-main {
  flex: 1 1 auto;
  min-width: 0;
}

.config-entry-name {
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-1);
}

.config-entry-description {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.config-entry-actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

.config-category-manager {
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border);
}

.config-category-manager h3 {
  margin: 0 0 var(--space-2);
}

.config-category-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.config-category-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.config-category-name {
  font-weight: var(--weight-semibold);
}

.config-category-count {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.config-category-actions {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}

.config-category-add {
  display: flex;
  gap: var(--space-2);
  align-items: flex-end;
}

.config-category-add .modal-field {
  flex: 1 1 auto;
  margin: 0;
}

.config-reset-footer {
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border);
}

.config-reset-footer h3 {
  margin: 0 0 var(--space-2);
}
