/*
 * DrillBrain v8 — readable field surfaces and actionable site risks.
 * Load after modern-v7.css. The existing Site / Bore / Ground / Community /
 * Tools visibility rules remain in their original stylesheets.
 *
 * Risk UI contract:
 *   .db-risk-card wraps a real button.db-risk-card-main; its optional footer
 *   may be inside the button or a sibling below it.
 *   data-severity: high | medium | low | unknown (moderate also supported).
 *   data-status: unreviewed | action-needed | reviewed.
 *   A reviewed flag is a record of review, never a clearance state.
 *   dialog.db-risk-dialog uses head, scrollable body and optional footer.
 */

:root {
  --db-ink: #172e3b;
  --db-navy: #102e3e;
  --db-teal: #0d746a;
  --db-paper: #f3f7f7;
  --db-line: #dbe5e7;
  --db-muted: #546b76;
  --db-soft-teal: #eaf6f2;
  --db-focus: #087b91;
  --db-shadow: 0 6px 22px rgba(19, 47, 60, .055);
  --bg: var(--db-paper);
  --text: var(--db-ink);
  --muted: var(--db-muted);
  --line: var(--db-line);
  --cyan: var(--db-teal);
}

body {
  color: var(--db-ink);
  background: #f3f7f7;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

button, input, select, textarea { font-family: inherit; }
button, a, summary { -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .56; transform: none; }

/* An outline remains visible for keyboard users, including form controls. */
:is(button, a, summary, [role="button"], input, select, textarea):focus-visible {
  outline: 3px solid var(--db-focus) !important;
  outline-offset: 3px;
}

.brand > div:last-child b { color: var(--db-navy); }
.search { border-color: #cedde0; box-shadow: 0 2px 8px rgba(17, 46, 61, .025); }
.search input::placeholder { color: #637783; opacity: 1; }
.search:focus-within { border-color: #5caaa3; box-shadow: 0 0 0 3px rgba(13, 116, 106, .1); }
.mapHint b { color: #b4f0e5; }
.mapHint span { color: #d3e3e9; }
.intelPane { background: var(--db-paper); }
.siteTop small { color: #52716e; font-size: 10px; font-weight: 750; letter-spacing: .1em; }
.siteTop h1 { color: var(--db-navy); font-weight: 720; letter-spacing: -.035em; }
.siteTop p { line-height: 1.5; }

.card, .heroCard, .planHero {
  border: 1px solid var(--db-line) !important;
  border-radius: 18px !important;
  background: #fff !important;
  box-shadow: var(--db-shadow);
  margin-bottom: 16px;
}
.cardHead { gap: 10px; margin-bottom: 12px; }
.cardHead span { color: #4c666e; letter-spacing: .055em; line-height: 1.45; }
.cardHead em { line-height: 1.45; }
.card h3, .heroCard h2 { color: var(--db-navy); letter-spacing: -.018em; }
.card p, .heroCard p { color: var(--db-muted); }
.card.watch { border-color: #e4c58c !important; }
.why, .screen, .bore, .savedItem { border-radius: 12px; }
.why { background: #f7fafb; }
.why b { color: var(--db-navy); }

/* Distinct score tiles make the risk entry point visibly interactive. */
.scoreRow { gap: 10px; border: 0; background: transparent; overflow: visible; }
.score { padding: 15px 13px; color: var(--db-ink); text-align: left; box-shadow: 0 3px 12px rgba(19, 47, 60, .035); }
.score small { font-size: 10px; line-height: 1.4; font-weight: 720; letter-spacing: .055em; }
.score strong { font-size: 23px; font-weight: 730; line-height: 1.2; font-variant-numeric: tabular-nums; }
.score span { font-size: 12px; line-height: 1.45; }
.score.db-risk-score,
.score[data-risk-open],
.score[role="button"] {
  position: relative;
  cursor: pointer;
  padding-right: 25px;
  background: #edf8f4 !important;
  border-color: #b9dad2 !important;
}
.score.db-risk-score::after,
.score[data-risk-open]::after,
.score[role="button"]::after {
  content: "›";
  position: absolute;
  right: 10px;
  top: 50%;
  color: var(--db-teal);
  font-size: 25px;
  line-height: 1;
  transform: translateY(-50%);
}
.score.db-risk-score small,
.score[data-risk-open] small,
.score[role="button"] small { color: #29685e; }

#tabs button { min-height: 44px; padding: 10px 13px; }
.modes button { min-height: 44px; }
.dbBoreTopActions, .engToolbar, .fieldButtons { gap: 9px; }
.dbBoreTopActions button, .engToolbar button, .fieldButtons button,
.dbcRoleTools button, .dbcNetworkTabs button, .dbcRoleDock button,
.dbcHeroActions button { min-height: 44px; }
.dbHelpBtn, .dbTourClose { width: 44px; height: 44px; min-height: 44px; flex: 0 0 44px; }
.dbSectionPicker select, .dbToolPicker select { border-color: #cbdcde; color: var(--db-navy); font-weight: 600; }

/* Risk workspace. Colour reinforces the written severity and review labels. */
.db-risk-summary,
.db-risk-overview,
.db-risk-brief,
.db-risk-dialog { color: var(--db-ink); }

.db-risk-summary {
  display: grid;
  gap: 16px;
  padding: 22px;
  margin-bottom: 16px;
  border: 1px solid #cddfdc !important;
  border-radius: 20px !important;
  background: linear-gradient(130deg, #eaf6f2, #fff 78%) !important;
  box-shadow: var(--db-shadow);
}
.db-risk-summary h2 { margin: 0 0 7px; color: var(--db-navy); font-size: 28px; line-height: 1.16; letter-spacing: -.035em; }
.db-risk-summary p { margin: 0; color: #4d686e; font-size: 14px; line-height: 1.6; }
.db-risk-summary > small,
.db-risk-summary > div > small { color: #286d63; font-size: 10px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.db-risk-summary > .db-risk-context { padding: 0; margin: 0; border: 0; border-radius: 0; background: transparent; }
.db-risk-summary > .db-risk-context > small { display: block; margin-bottom: 8px; }

.db-risk-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.db-risk-metric {
  display: grid;
  align-content: start;
  gap: 4px;
  min-width: 0;
  padding: 13px;
  text-align: left;
  border: 1px solid #d5e3e1;
  border-radius: 14px;
  background: #fff;
  color: var(--db-navy);
}
.db-risk-metric strong, .db-risk-metric b { display: block; font-size: 27px; font-weight: 730; line-height: 1.1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.db-risk-metric span, .db-risk-metric small { color: #526a72; font-size: 12px; line-height: 1.4; }
button.db-risk-metric { min-height: 82px; }
.db-risk-metric[aria-pressed="true"] { border-color: #7cb8ad; background: #f2faf7; }

.db-risk-toolbar,
.db-risk-actions,
.db-risk-action-row { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.db-risk-toolbar { justify-content: space-between; margin: 0 0 16px; }
.db-risk-toolbar > div { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; }
.db-risk-toolbar label { display: grid; gap: 5px; color: var(--db-muted); font-size: 12px; font-weight: 650; }
.db-risk-toolbar > .db-risk-filter { flex: 1 1 160px; }
.db-risk-toolbar input { box-sizing: border-box; width: 100%; min-width: 0; min-height: 44px; padding: 10px 12px; border: 1px solid #cddcde; border-radius: 11px; background: #fff; color: var(--db-navy); font: inherit; font-size: 16px; font-weight: 400; }
.db-risk-toolbar label select { width: 100%; }
.db-risk-toolbar input::placeholder { color: #637882; opacity: 1; }
.db-risk-filter { min-width: 0; }
.db-risk-filter[aria-pressed="true"],
.db-risk-filter.active { border-color: #92c5ba !important; color: #0c6057 !important; background: #e9f5f0 !important; }

.db-risk-toolbar :is(button, select),
.db-risk-actions :is(button, a),
.db-risk-action-row :is(button, select),
.db-risk-footer :is(button, a),
.db-risk-dialog button:not(.db-risk-card-main) {
  min-height: 44px;
  border: 1px solid #cddcde;
  border-radius: 11px;
  padding: 10px 13px;
  color: var(--db-navy);
  background: #fff;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.4;
}
.db-risk-actions a, .db-risk-footer a { display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.db-risk-actions .primary,
.db-risk-footer .primary,
.db-risk-toolbar .primary,
.db-risk-dialog button.primary { color: #fff; }
.db-risk-action-row { margin: 12px 0; }
.db-risk-action-row > label { display: grid; gap: 5px; font-size: 12px; color: var(--db-muted); }
.db-risk-action-row > label select { min-width: 160px; }

.db-risk-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); align-items: stretch; gap: 12px; }
.db-risk-card {
  --risk-colour: #536875;
  --risk-soft: #eff3f5;
  --risk-line: #cbd6dc;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--db-line);
  border-top: 3px solid var(--risk-line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 3px 12px rgba(19, 47, 60, .035);
}
.db-risk-card-main {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex: 1 1 auto;
  width: 100%;
  min-height: 44px;
  padding: 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--db-ink);
  text-align: left;
  font-size: 14px;
  line-height: 1.55;
}
.db-risk-card-main:focus-visible { outline-offset: -4px; }
.db-risk-card-main:active { background: #f2f8f7; transform: none; }
.db-risk-card-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; color: var(--db-navy); font-size: 16px; line-height: 1.35; font-weight: 730; }
.db-risk-card-title h3, .db-risk-card-title strong { margin: 0; color: inherit; font-size: inherit; font-weight: inherit; line-height: inherit; }
.db-risk-card-main > p,
.db-risk-detail { margin: 8px 0 0; color: var(--db-muted); font-size: 13px; font-weight: 400; line-height: 1.6; overflow-wrap: anywhere; }
.db-risk-item-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin: 10px 0 0; color: var(--db-muted); font-size: 12px; line-height: 1.45; }
.db-risk-card-main > .db-risk-item-meta:first-child { margin: 0 0 10px; }
.db-risk-card-main > p.db-risk-item-meta { margin: 8px 0 14px; }

.db-risk-chip,
.db-risk-status,
.db-risk-action-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  max-width: 100%;
  padding: 5px 8px;
  border: 1px solid #d6e1e4;
  border-radius: 8px;
  background: #f1f5f6;
  color: #4d636f;
  font-size: 11px;
  font-weight: 650;
  font-style: normal;
  line-height: 1.35;
}
.db-risk-chip { color: var(--risk-colour, #526674); border-color: var(--risk-line, #d4dfe3); background: var(--risk-soft, #f0f4f5); }
:is(.db-risk-card, .db-risk-chip)[data-severity="high"] { --risk-colour: #9f392d; --risk-soft: #fff1ee; --risk-line: #e6b2a9; }
:is(.db-risk-card, .db-risk-chip)[data-severity="medium"],
:is(.db-risk-card, .db-risk-chip)[data-severity="moderate"] { --risk-colour: #815512; --risk-soft: #fff7e7; --risk-line: #e5ca96; }
:is(.db-risk-card, .db-risk-chip)[data-severity="low"] { --risk-colour: #286657; --risk-soft: #ecf7f1; --risk-line: #b9d8cb; }
:is(.db-risk-card, .db-risk-chip)[data-severity="unknown"] { --risk-colour: #526674; --risk-soft: #eff3f5; --risk-line: #cbd6dc; }
:is(.db-risk-status, .db-risk-action-status)[data-status="action-needed"] { color: #815512; background: #fff6e5; border-color: #e6c992; }
:is(.db-risk-status, .db-risk-action-status)[data-status="reviewed"] { color: #355965; background: #edf4f6; border-color: #cddde2; }

.db-risk-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 9px; margin-top: auto; padding: 12px 16px; border-top: 1px solid #e3ebed; background: #f8fbfb; }
.db-risk-footer small { color: var(--db-muted); font-size: 12px; line-height: 1.45; }
.db-risk-card-main > .db-risk-footer { margin: auto -16px -16px; }
.db-risk-card-main > .db-risk-footer > span:last-child { color: #126a61; font-size: 12px; font-weight: 650; }
.db-risk-note,
.db-risk-context { padding: 13px 15px; margin: 12px 0; border: 1px solid #dce7e9; border-radius: 13px; background: #f3f8f8; color: #46616c; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.db-risk-note p, .db-risk-context p { margin: 0; color: inherit; font-size: inherit; line-height: inherit; }
.db-risk-note[data-kind="warning"] { border-color: #e4cc9f; background: #fff8ea; color: #785817; }
.db-risk-help,
.db-risk-muted { color: var(--db-muted); font-size: 12px; line-height: 1.6; }
.db-risk-help { margin: 8px 0 0; }
.db-risk-live { color: #375e68; font-size: 13px; line-height: 1.5; }
.db-risk-empty { display: grid; justify-items: start; gap: 9px; padding: 24px; border: 1px dashed #bdd0d2; border-radius: 16px; background: #f7fafb; color: var(--db-muted); font-size: 14px; line-height: 1.6; }
.db-risk-empty h3, .db-risk-empty b { margin: 0; color: var(--db-navy); }
.db-risk-empty p { margin: 0; }

/* References stay readable even when a source title or URL is long. */
.db-risk-source-list { display: grid; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.db-risk-source { display: grid; gap: 4px; padding: 12px 13px; border: 1px solid #dbe5e8; border-radius: 12px; background: #fff; color: #37545e; font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.db-risk-source > div { display: grid; gap: 4px; min-width: 0; }
.db-risk-source > div > b { color: var(--db-navy); font-size: 14px; }
button.db-risk-source { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%; min-height: 64px; text-align: left; }
.db-risk-source small, .db-risk-source span { color: var(--db-muted); font-size: 12px; line-height: 1.5; }
.db-risk-source[data-source-status="unavailable"],
.db-risk-source[data-source-status="partial"],
.db-risk-source[data-source-status="not_checked"] { border-color: #e1d0ab; background: #fffaf0; }
.db-risk-source:is([data-source-status="unavailable"], [data-source-status="partial"], [data-source-status="not_checked"]) > .db-risk-chip { border-color: #e1cd9f; background: #fff5df; color: #7a581c; }
a.db-risk-source, .db-risk-source a, .db-risk-link { color: #096b70; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a.db-risk-source { min-height: 48px; }
.db-risk-link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 4px 0; font-size: 13px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
.db-risk-source-list > .db-risk-link { display: flex; min-height: 46px; padding: 11px 13px; border: 1px solid #dbe5e8; border-radius: 12px; background: #fff; }
.db-risk-link > [aria-hidden="true"] { flex: 0 0 auto; }
.db-risk-sources { margin-top: 13px; border: 1px solid #dbe5e8; border-radius: 13px; background: #f8fbfb; }
.card.db-risk-sources { padding: 0; margin-top: 16px; }
.db-risk-sources > summary { min-height: 44px; padding: 12px 14px; color: var(--db-navy); cursor: pointer; font-size: 13px; font-weight: 650; }
.db-risk-sources > summary > span { margin-left: 7px; color: #566e78; font-size: 11px; font-weight: 600; white-space: nowrap; }
.db-risk-sources > .db-risk-muted { margin: 0; padding: 0 14px 12px; font-size: 12px; }
.db-risk-sources > .db-risk-source-list { margin: 0; padding: 0 12px 12px; }

.db-risk-overview { display: grid; gap: 13px; }
.db-risk-overview > .cardHead { margin-bottom: 0; }
.db-risk-overview h2 { margin: 0; color: var(--db-navy); font-size: 25px; line-height: 1.2; letter-spacing: -.03em; }
.db-risk-overview > .db-risk-note { margin: 0; }
.db-risk-brief { padding: 20px; border: 1px solid var(--db-line); border-radius: 16px; background: #fff; }
label.db-risk-brief { display: grid; gap: 10px; margin-top: 16px; color: var(--db-navy); font-size: 14px; font-weight: 650; }
.db-risk-dialog .db-risk-brief textarea { height: 48vh; height: 48dvh; min-height: 300px; }
.db-risk-brief h3 { margin: 0 0 10px; color: var(--db-navy); font-size: 18px; }
.db-risk-brief pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--db-ink); font: inherit; font-size: 14px; line-height: 1.7; }
.db-risk-brief p { color: var(--db-muted); font-size: 14px; line-height: 1.65; }
.db-risk-context dl { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4px 16px; margin: 0; }
.db-risk-context dt { color: var(--db-muted); font-size: 12px; }
.db-risk-context dd { margin: 0; color: var(--db-navy); font-weight: 600; }
#dbRiskSavedActions .db-risk-action-row { padding: 13px; border: 1px solid #dce6e8; border-radius: 12px; background: #f8fbfb; }
#dbRiskSavedActions .db-risk-action-row > div { flex: 1 1 180px; min-width: 0; overflow-wrap: anywhere; }
#dbRiskSavedActions .db-risk-action-row > div > b { display: block; margin-bottom: 6px; color: var(--db-navy); font-size: 14px; }
#dbRiskSavedActions .db-risk-action-row p { margin: 5px 0 0; font-size: 12px; line-height: 1.55; }
#dbRiskSavedActions .db-risk-action-row > button { flex: 0 0 auto; min-width: 62px; }

/* Native dialog handles focus and the modal layer; only its body scrolls. */
body.db-risk-modal-open { overflow: hidden; }
dialog.db-risk-dialog {
  width: min(760px, calc(100% - 40px));
  max-width: 760px;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(218, 231, 233, .9);
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 24px 90px rgba(10, 33, 45, .24);
  overscroll-behavior: contain;
}
dialog.db-risk-dialog[open] { display: flex; flex-direction: column; }
dialog.db-risk-dialog:not([open]) { display: none; }
dialog.db-risk-dialog::backdrop { background: rgba(12, 33, 45, .5); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.db-risk-dialog-head { display: flex; flex: 0 0 auto; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 24px 18px; border-bottom: 1px solid #e1ebed; background: #f7fbfa; }
.db-risk-dialog-head > div { min-width: 0; }
.db-risk-dialog-head h2 { margin: 7px 0 5px; color: var(--db-navy); font-size: 25px; line-height: 1.2; letter-spacing: -.025em; overflow-wrap: anywhere; }
.db-risk-dialog-head p { margin: 0; color: var(--db-muted); font-size: 13px; line-height: 1.55; }
.db-risk-dialog-head small { color: #3f756d; font-size: 10px; font-weight: 750; letter-spacing: .075em; text-transform: uppercase; }
.db-risk-dialog .db-risk-dialog-head > button { flex: 0 0 44px; width: 44px; height: 44px; padding: 0; border: 1px solid #dbe6e7; border-radius: 50%; background: #fff; color: #3c5662; font-size: 23px; font-weight: 400; }
.db-risk-dialog-body { flex: 1 1 auto; min-height: 0; padding: 20px 24px 24px; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; -webkit-overflow-scrolling: touch; }
.db-risk-dialog > .db-risk-footer { flex: 0 0 auto; margin: 0; padding: 14px 24px; }
.db-risk-section { margin: 0 0 20px; }
.db-risk-section:last-child { margin-bottom: 0; }
.db-risk-section h3 { margin: 0 0 9px; color: var(--db-navy); font-size: 16px; line-height: 1.35; letter-spacing: -.015em; }
.db-risk-section p { margin: 0 0 10px; color: #4a626e; font-size: 14px; line-height: 1.65; }
.db-risk-section ul, .db-risk-section ol { padding-left: 21px; margin: 8px 0 0; color: #405966; font-size: 14px; line-height: 1.6; }
.db-risk-section li { margin: 7px 0; padding-left: 2px; }
.db-risk-section li::marker { color: #567e7b; }
.db-risk-section > .db-risk-chip { margin: 0 6px 10px 0; }
.db-risk-section > .db-risk-context:first-child { margin-top: 0; }

.db-risk-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; margin-top: 12px; }
.db-risk-form label { display: grid; gap: 6px; color: #49616c; font-size: 13px; font-weight: 650; }
.db-risk-form label:has(textarea), .db-risk-form > textarea, .db-risk-form > .db-risk-actions, .db-risk-form > .db-risk-help { grid-column: 1 / -1; }
.db-risk-form input,
.db-risk-form select,
.db-risk-form textarea,
.db-risk-dialog select,
.db-risk-dialog textarea {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #c7d9dc;
  border-radius: 11px;
  background: #fff;
  color: var(--db-ink);
  font-family: inherit;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
}
.db-risk-form textarea, .db-risk-dialog textarea { min-height: 104px; resize: vertical; }
.db-risk-form input[type="checkbox"], .db-risk-form input[type="radio"] { width: 20px; min-height: 20px; height: 20px; margin: 0; accent-color: var(--db-teal); }
.db-risk-form input::placeholder, .db-risk-form textarea::placeholder { color: #637882; opacity: 1; }

@media (hover: hover) {
  .score.db-risk-score:hover,
  .score[data-risk-open]:hover,
  .score[role="button"]:hover { background: #e3f4ed !important; border-color: #86bfae !important; }
  .db-risk-card-main:hover { background: #f5faf8; }
  button.db-risk-metric:hover { border-color: #8ebcaf; background: #f6fbf8; }
  .db-risk-toolbar button:not(.primary):hover,
  .db-risk-actions button:not(.primary):hover,
  .db-risk-footer button:not(.primary):hover { border-color: #8ab6ac; background: #f2f8f6; }
  a.db-risk-source:hover { border-color: #8bbcb2; background: #f5faf8; }
  button.db-risk-source:hover, .db-risk-source-list > .db-risk-link:hover { border-color: #8bbcb2; }
  .db-risk-source a:hover, .db-risk-link:hover { color: #044b52; text-decoration-thickness: 2px; }
}

@media (max-width: 820px) {
  .card, .heroCard, .planHero { box-shadow: 0 3px 14px rgba(19, 47, 60, .04); }
  .scoreRow { gap: 8px; }
  .score { padding: 13px 10px; }
  .score strong { font-size: 21px; }
  .score small { font-size: 10px; letter-spacing: .025em; }
  .score span { font-size: 11px; }
  .db-risk-summary { padding: 18px; border-radius: 18px !important; }
  .db-risk-summary h2 { font-size: 25px; }
  .db-risk-metric { padding: 12px 10px; }
  .db-risk-metric strong, .db-risk-metric b { font-size: 25px; }
  .db-risk-metric span, .db-risk-metric small { font-size: 11px; }
  .db-risk-toolbar { align-items: flex-start; }
  .db-risk-toolbar > div { width: 100%; }
  .db-risk-toolbar select { font-size: 16px; max-width: 100%; }
  .db-risk-grid { grid-template-columns: minmax(0, 1fr); }
  .intelPane, .fieldPanel,
  body:is(.db-focus-bore, .db-focus-model) .intelPane { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
  #dbBottomNav { border-radius: 19px; padding: 5px; box-shadow: 0 6px 26px rgba(15, 44, 55, .14); }
  #dbBottomNav button { position: relative; min-height: 52px; padding: 9px 2px 6px; color: #4f6672 !important; font-size: 11px; font-weight: 650; line-height: 1.25; }
  #dbBottomNav button.active { background: #e7f4ef !important; color: #075e55 !important; font-weight: 750; }
  #dbBottomNav button.active::before { content: ""; position: absolute; top: 5px; left: calc(50% - 8px); width: 16px; height: 3px; border-radius: 3px; background: #278976 !important; }
  #toast { max-width: calc(100vw - 28px); right: 14px; bottom: calc(88px + env(safe-area-inset-bottom)); }
}

@media (max-width: 620px) {
  dialog.db-risk-dialog {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    max-width: none;
    height: calc(100vh - 24px - env(safe-area-inset-top));
    height: calc(100dvh - 24px - env(safe-area-inset-top));
    max-height: calc(100vh - 24px - env(safe-area-inset-top));
    max-height: calc(100dvh - 24px - env(safe-area-inset-top));
    margin: auto 0 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 22px 22px 0 0;
  }
  .db-risk-dialog-head { padding: 18px 16px 15px; gap: 12px; }
  .db-risk-dialog-head h2 { font-size: 23px; }
  .db-risk-dialog-body { padding: 18px 16px calc(22px + env(safe-area-inset-bottom)); scrollbar-gutter: auto; }
  .db-risk-dialog > .db-risk-footer { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .db-risk-dialog > .db-risk-footer > button,
  .db-risk-dialog > .db-risk-footer > a { flex: 1 1 120px; }
  .db-risk-form { grid-template-columns: minmax(0, 1fr); }
  .db-risk-form > * { min-width: 0; }
  .db-risk-dialog .db-risk-actions { width: 100%; }
  .db-risk-dialog .db-risk-actions > button { flex: 1 1 140px; }
  .db-risk-brief { padding: 16px; }
  button.db-risk-source { grid-template-columns: minmax(0, 1fr); gap: 8px; }
}

@media (max-width: 380px) {
  .score small { font-size: 9.5px; }
  .score strong { font-size: 19px; }
  .db-risk-summary { padding: 15px; }
  .db-risk-metrics { gap: 6px; }
  .db-risk-metric { padding: 10px 8px; }
  .db-risk-card-main, .db-risk-footer { padding-left: 13px; padding-right: 13px; }
  .db-risk-card-main > .db-risk-footer { margin-right: -13px; margin-left: -13px; }
  #dbBottomNav button { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}

@media print {
  .db-risk-summary, .db-risk-card, .db-risk-brief, .db-risk-source { background: #fff !important; box-shadow: none; break-inside: avoid; }
  .db-risk-toolbar, .db-risk-actions, .db-risk-dialog-head > button { display: none !important; }
  .db-risk-grid { grid-template-columns: minmax(0, 1fr); }
  .db-risk-card { overflow: visible; }
  .db-risk-brief pre { white-space: pre-wrap; }
}

/* Site-scoped results remain hidden until the selected site's request succeeds. */
#dbSiteScreeningStatus { display: none; }
body.db-site-screening-pending:not(.db-focus-bore):not(.db-focus-model):not(.db-focus-field) #dbSiteScreeningStatus { display: block; margin: 14px 0; }
body.db-site-screening-pending :is(#snapshot, #plan, #evidence, #bits) { display: none !important; }
