/* Hazard Vulnerability Analysis Tool — app styles (on top of /assets/labs.css) */
.app-page .page-title { margin-bottom: 18px; }
.app-block { margin-top: 20px; }
.h-sm { font-size: 22px; margin: 0 0 14px; }
.h-xs { font-size: 17px; margin: 0 0 6px; letter-spacing: -0.01em; }
.sub { margin: -8px 0 12px; }
.block-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
.grid-fields { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: end; }
.field-msg { min-height: 1.4em; margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.field-msg.err { color: var(--danger); font-weight: 600; }
.field-msg.ok { color: var(--ok); font-weight: 600; }
.danger { color: var(--danger) !important; border-color: color-mix(in srgb, var(--danger) 45%, var(--line)) !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.file-btn { cursor: pointer; position: relative; display: inline-flex; font-weight: 650; }
.file-btn:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.link-btn { font: inherit; font-size: 14px; background: none; border: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; padding: 6px 4px; min-height: 32px; }
.inline-label { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.inline-label select { min-height: 38px; padding: 6px 10px; width: auto; }
.panel:focus { outline: none; }
.panel:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
[hidden] { display: none !important; }

/* Progress */
.progress { margin-top: 18px; padding: 14px 18px; }
.progress-text { margin: 0 0 8px; font-size: 15px; }
.bar-svg { width: 100%; height: 8px; border-radius: 4px; overflow: hidden; }
.app-disclaimer { margin-top: 28px; }
.bar-track { fill: var(--surface-2); }
.bar-fill { fill: var(--accent); }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-top: 22px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { font: inherit; font-weight: 650; background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted); padding: 12px 14px; cursor: pointer; white-space: nowrap; min-height: 48px; }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab:hover { color: var(--text); }

/* Setup */
.hz-group { border: 0; padding: 0; margin: 18px 0 0; min-width: 0; }
.hz-group legend { font-weight: 700; font-size: 15px; padding: 0 0 8px; }
.hz-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px 18px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.hz-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; }
.hz-item .check { font-size: 15px; align-items: center; }
.hz-item .check input { margin-top: 0; }
.add-form { display: grid; gap: 12px; grid-template-columns: 2fr 1.4fr auto; align-items: end; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.add-form .btn { min-height: 48px; }
@media (max-width: 720px) { .add-form { grid-template-columns: 1fr; } }

/* Score */
.scale-help summary, .hz-notes summary, .table-view summary { cursor: pointer; font-weight: 650; color: var(--accent); padding: 4px 0; min-height: 32px; }
.scale-grid { display: grid; gap: 14px 22px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-top: 12px; }
.scale-grid p { margin: 0; }
.score-tools { display: flex; flex-wrap: wrap; gap: 12px 16px; margin-top: 20px; padding: 16px; }
.score-tools label { flex: 1 1 200px; font-size: 14px; }
.hz-card { margin-top: 14px; padding: 18px 20px; }
.hz-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.hz-head .h-xs { margin: 0; }
.score-grid { display: grid; gap: 10px 12px; grid-template-columns: repeat(7, minmax(0, 1fr)); }
@media (max-width: 1080px) { .score-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 640px) { .score-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .score-grid .prob { grid-column: 1 / -1; } }
.score-field { font-size: 13px; font-weight: 600; gap: 4px; }
.score-field select { min-height: 44px; padding: 8px 10px; font-size: 15px; }
.score-grid.is-na .score-field:not(.prob) { opacity: 0.55; }
.score-label { color: var(--muted); }
.hz-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; }
.hz-result { margin: 0; font-size: 15px; }
.hz-notes { margin-top: 8px; }
.hz-notes textarea { min-height: 64px; margin-top: 6px; }

/* Tier tokens: fills meet 3:1 against card surfaces in both themes */
:root { --t-critical: #8f1239; --t-high: #c2410c; --t-medium: #8a6a00; --t-low: #3f6b96; --t-na: #6b7785; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) { --t-critical: #ff7aa2; --t-high: #ff9d57; --t-medium: #e8c14a; --t-low: #86b3e0; --t-na: #9aa6b4; } }
:root[data-theme="dark"] { --t-critical: #ff7aa2; --t-high: #ff9d57; --t-medium: #e8c14a; --t-low: #86b3e0; --t-na: #9aa6b4; }
.tier-badge { display: inline-block; font-size: 12px; font-weight: 750; letter-spacing: 0.02em; padding: 3px 9px; border-radius: 999px; color: var(--bg); background: var(--t-na); vertical-align: 1px; }
.tier-badge.tier-critical { background: var(--t-critical); }
.tier-badge.tier-high { background: var(--t-high); }
.tier-badge.tier-medium { background: var(--t-medium); }
.tier-badge.tier-low { background: var(--t-low); }
.key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--t-na); vertical-align: -1px; }
.key.tier-critical { background: var(--t-critical); } .key.tier-high { background: var(--t-high); } .key.tier-medium { background: var(--t-medium); } .key.tier-low { background: var(--t-low); }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 0; margin: 10px 0 4px; font-size: 14px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }

/* Results */
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 20px 0 6px; }
.stat { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; min-width: 0; }
.stat .k { font-size: 13px; color: var(--muted); }
.stat .v { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.stat.hero { grid-column: span 2; }
.stat.hero .v { font-size: 44px; }
.stat .sub { margin: 2px 0 0; overflow-wrap: anywhere; }
@media (max-width: 400px) { .stat.hero { grid-column: auto; } }
.viz-root { width: 100%; min-width: 0; }
.rank-chart { width: 100%; height: auto; font-family: var(--font); }
.rank-chart .grid { stroke: var(--line); stroke-width: 1; }
.rank-chart .axis { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.rank-chart .label { fill: var(--text); font-size: 13px; }
.rank-chart .value { fill: var(--text); font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.rank-chart .track { fill: var(--surface-2); }
.rank-chart .bar { fill: var(--t-na); }
.rank-chart .bar.tier-critical { fill: var(--t-critical); } .rank-chart .bar.tier-high { fill: var(--t-high); } .rank-chart .bar.tier-medium { fill: var(--t-medium); } .rank-chart .bar.tier-low { fill: var(--t-low); }
.table-view { margin-top: 10px; }
.table-scroll { overflow-x: auto; max-width: 100%; }
.table-scroll:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.data-table { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table tbody th { font-weight: 600; white-space: normal; min-width: 160px; }
.data-table thead th { font-size: 13px; color: var(--muted); }
.matrix-wrap { overflow-x: auto; }
.matrix { border-collapse: separate; border-spacing: 6px; width: 100%; max-width: 640px; }
.matrix th { font-size: 13px; color: var(--muted); font-weight: 650; text-align: center; padding: 4px; }
.matrix tbody th { text-align: right; width: 70px; }
.matrix .corner { text-align: left; vertical-align: bottom; }
.matrix td { padding: 0; }
.cell { font: inherit; width: 100%; min-height: 72px; border-radius: var(--radius-sm); border: 2px solid transparent; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--bg); background: var(--t-na); }
.cell .n { font-size: 24px; font-weight: 750; line-height: 1; }
.cell .t { font-size: 12px; font-weight: 650; }
.cell.tier-critical { background: var(--t-critical); } .cell.tier-high { background: var(--t-high); } .cell.tier-medium { background: var(--t-medium); } .cell.tier-low { background: var(--t-low); }
.cell.zero { background: var(--surface-2); color: var(--muted); }
.cell[aria-pressed="true"] { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg) inset; }
.cell:hover { filter: brightness(1.06); }

/* Register */
.act-form { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.act-form .span2 { grid-column: span 2; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
@media (max-width: 760px) { .act-form { grid-template-columns: 1fr; } .act-form .span2 { grid-column: auto; } }
.gaps { margin-bottom: 14px; }
.gaps p { margin: 0 0 6px; }
.gap-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.gap-list li { color: var(--text); }
.act-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.act-item { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding: 14px 16px; background: var(--bg); }
.act-item.overdue { border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }
.act-main { flex: 1 1 320px; min-width: 0; }
.act-main p { margin: 0 0 4px; overflow-wrap: anywhere; }
.act-haz { font-size: 14px; font-weight: 650; }
.act-text { font-size: 16px; }
.od { color: var(--danger); }
.act-ctl { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.status-select { width: auto; min-height: 38px; padding: 6px 10px; font-size: 14px; }

/* Print */
.print-only { display: none; }
@media print {
  @page { margin: 14mm; }
  :root { --bg: #fff; --text: #000; --muted: #333; --line: #bbb; --surface: #fff; --surface-2: #eee; color-scheme: light; }
  body { font-size: 11pt; background: #fff; color: #000; }
  .top, .foot, .skip, .screen-only { display: none !important; }
  .page { padding: 0; }
  .print-only { display: block !important; }
  .rep-title { font-size: 20pt; margin-bottom: 6px; }
  #report h2 { font-size: 14pt; margin-top: 16px; }
  #report .data-table { font-size: 9pt; }
  #report .data-table th, #report .data-table td { padding: 4px 6px; white-space: normal; }
  #report .table-scroll { overflow: visible; }
  .rep-foot { margin-top: 18px; color: #333; }
}
.community { margin-top: 16px; }
.hz-item { flex-wrap: wrap; }
.hz-item.is-out .check span { color: var(--muted); text-decoration: line-through; }
.hz-item .why { min-height: 38px; padding: 6px 10px; font-size: 14px; flex: 1 1 100%; margin: 0 0 6px 30px; width: auto; }
.rep-sign { margin-top: 14px; }
@media (max-width: 640px) { .tabs { flex-wrap: wrap; overflow-x: visible; } .tab { padding: 10px 10px; } }
