:root {
  --ink: #17211b;
  --muted: #68736c;
  --paper: #f5f4ed;
  --surface: #fffefa;
  --line: #dddcd4;
  --green: #195c43;
  --green-dark: #104632;
  --mint: #dcecdf;
  --amber: #e7a33e;
  --red: #c95745;
  --shadow: 0 18px 50px rgba(28, 42, 34, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 5%, rgba(231, 163, 62, 0.13), transparent 22rem),
    var(--paper);
  font-family: "DM Sans", sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.page-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }

.hero {
  min-height: 285px;
  padding: 64px 0 42px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 40px;
}

.eyebrow, .section-label {
  margin: 0 0 12px;
  color: var(--green);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.17em;
}

h1, h2 { font-family: "Manrope", sans-serif; }
h1 { margin: 0; max-width: 680px; font-size: clamp(3rem, 8vw, 6.2rem); letter-spacing: -0.07em; line-height: 0.94; }
h1 span { color: var(--green); }
h2 { margin: 0; font-size: 1.45rem; letter-spacing: -0.035em; }
.hero-copy { max-width: 650px; margin: 22px 0 0; color: var(--muted); font-size: 1.08rem; line-height: 1.7; }
.hero-actions { display: flex; gap: 10px; flex-shrink: 0; }

.button {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 12px 18px;
  font-weight: 700;
  transition: transform 150ms ease, background 150ms ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { color: white; background: var(--green); }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { color: var(--ink); background: transparent; border-color: #b9bbb4; }
.button-full { width: 100%; margin-top: 4px; padding: 14px; }
.form-actions { display: grid; grid-template-columns: 1fr; gap: 8px; }
.form-actions:has(#cancel-edit:not(.is-hidden)) { grid-template-columns: 1fr 0.7fr; }
.is-hidden { display: none; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.metric-card, .panel { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.metric-card { padding: 22px; border-radius: 14px; }
.metric-card p { margin: 0 0 14px; color: var(--muted); font-weight: 600; }
.metric-card strong { display: block; font-family: "Manrope"; font-size: 2rem; }
.metric-card span { display: block; margin-top: 5px; color: #8a928d; font-size: 0.78rem; }
.metric-card-alert strong { color: var(--red); }

.workspace-grid { display: grid; grid-template-columns: 0.86fr 1.14fr; gap: 16px; }
.panel { border-radius: 16px; padding: 28px; }
.panel-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 26px; }
.step-badge { display: grid; place-items: center; width: 37px; height: 37px; border-radius: 50%; background: var(--mint); color: var(--green); font-weight: 700; font-size: 0.8rem; }

form { display: grid; gap: 16px; }
label { display: grid; gap: 7px; font-size: 0.84rem; color: #3d4841; font-weight: 700; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input, select, textarea {
  width: 100%;
  border: 1px solid #d0d2cb;
  border-radius: 9px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fcfcf8;
  outline: none;
  font-weight: 500;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(25, 92, 67, 0.1); }
textarea { resize: vertical; }

.matrix-wrap { position: relative; padding: 0 0 24px 30px; }
.risk-matrix { display: grid; grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(5, 1fr); gap: 5px; aspect-ratio: 1.35; }
.matrix-cell { position: relative; min-width: 0; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 4px; padding: 7px; border-radius: 7px; }
.matrix-cell.low { background: #dcead8; }
.matrix-cell.medium { background: #f5dfac; }
.matrix-cell.high { background: #efc0b8; }
.cell-score { position: absolute; right: 5px; bottom: 3px; color: rgba(23, 33, 27, 0.35); font-size: 0.65rem; font-weight: 700; }
.risk-marker { position: relative; z-index: 1; display: grid; place-items: center; width: 24px; height: 24px; border: 2px solid white; border-radius: 50%; color: white; background: var(--ink); box-shadow: 0 3px 8px rgba(0,0,0,.2); font-size: .67rem; font-weight: 800; }
.axis-label { position: absolute; color: var(--muted); font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.axis-y { left: -28px; top: 48%; transform: rotate(-90deg); }
.axis-x { bottom: 0; left: 52%; }
.legend { display: flex; justify-content: center; gap: 22px; color: var(--muted); font-size: .78rem; }
.legend span { display: flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; }
.dot-low { background: #8fbe86; } .dot-medium { background: var(--amber); } .dot-high { background: var(--red); }

.register-panel { margin-top: 16px; }
.register-heading { align-items: center; }
.register-controls { display: flex; align-items: center; gap: 16px; }
.filter-label select { min-width: 160px; }
.text-button { padding: 8px; border: 0; background: none; color: var(--red); font-size: .84rem; font-weight: 700; }
.risk-list { display: grid; gap: 9px; }
.risk-row { display: grid; grid-template-columns: 55px minmax(230px, 1.8fr) minmax(160px, .8fr) minmax(200px, 1.2fr) 78px; gap: 16px; align-items: center; padding: 17px 12px; border-top: 1px solid #e6e5df; }
.score-pill { justify-self: center; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; font-weight: 800; }
.score-pill.low { color: #315d37; background: #dcead8; }
.score-pill.medium { color: #805616; background: #f5dfac; }
.score-pill.high { color: #87382d; background: #efc0b8; }
.risk-title { margin: 0 0 6px; font-weight: 700; }
.risk-meta, .risk-mitigation { margin: 0; color: var(--muted); font-size: .83rem; line-height: 1.45; }
.risk-owner strong { display: block; margin-bottom: 5px; font-size: .84rem; }
.status-select { width: auto; padding: 5px 8px; font-size: .74rem; }
.risk-actions { display: grid; justify-items: end; gap: 5px; }
.edit-risk, .delete-risk { border: 0; background: transparent; font-weight: 700; }
.edit-risk { color: var(--green); font-size: .78rem; }
.edit-risk:hover { text-decoration: underline; }
.delete-risk { color: #929892; font-size: .76rem; }
.delete-risk:hover { color: var(--red); }
.empty-state { padding: 55px 20px; text-align: center; color: var(--muted); border-top: 1px solid #e6e5df; }
.empty-state strong { display: block; margin-bottom: 7px; color: var(--ink); font-family: "Manrope"; }

footer { display: flex; justify-content: space-between; padding: 30px 2px 48px; color: var(--muted); font-size: .78rem; }
.toast { position: fixed; right: 24px; bottom: 24px; padding: 12px 16px; color: white; background: var(--ink); border-radius: 9px; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 850px) {
  .hero { align-items: flex-start; flex-direction: column; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .workspace-grid { grid-template-columns: 1fr; }
  .risk-row { grid-template-columns: 48px 1fr 42px; }
  .risk-owner, .risk-mitigation { grid-column: 2 / 3; }
  .risk-actions { grid-column: 3; grid-row: 1; }
}

@media (max-width: 560px) {
  .page-shell { width: min(100% - 24px, 1180px); }
  .hero { padding-top: 40px; }
  .hero-actions { width: 100%; flex-direction: column; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric-card, .panel { padding: 18px; }
  .field-row { grid-template-columns: 1fr; }
  .register-heading, footer { align-items: flex-start; flex-direction: column; }
  .register-controls { width: 100%; justify-content: space-between; }
}
