/*
 * HAVS System (signed-in app) layout and components.
 * Layout: docs/design/04-app-calculator-layout.png. Content: 03-layouts-and-structure.png §5–6.
 */

body.app-body { background: var(--app-bg); }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  padding: 24px 14px 20px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  isolation: isolate;
}
.sidebar::after {
  content: ""; position: absolute; left: -60px; right: -60px; bottom: 60px; height: 220px; z-index: -1;
  background:
    radial-gradient(ellipse 60% 40% at 30% 60%, rgba(37, 99, 235, 0.18), transparent 70%),
    radial-gradient(ellipse 50% 35% at 80% 80%, rgba(20, 184, 166, 0.12), transparent 70%);
  pointer-events: none;
}
.sidebar .side-logo { display: none; padding: 0 8px 18px; }
.sidebar .side-logo .logo-text strong { color: #fff; }
.sidebar .side-logo .logo-text span { color: var(--sidebar-text); }
.side-nav { display: grid; gap: 4px; }
.side-link {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; border-radius: var(--radius);
  color: var(--sidebar-text); text-decoration: none;
  font-weight: 500; font-size: 0.97rem;
}
.side-link svg { width: 22px; height: 22px; flex-shrink: 0; }
.side-link:hover { background: var(--sidebar-hover); color: var(--sidebar-text-strong); }
.side-link[aria-current="page"] { background: var(--sidebar-active); color: var(--sidebar-text-strong); box-shadow: inset 0 1px 0 rgba(255,255,255,0.06); }
.side-bottom { margin-top: auto; padding-top: 24px; display: grid; gap: 18px; }
.side-motto { display: flex; align-items: center; gap: 12px; padding: 0 10px; font-size: 0.82rem; line-height: 1.35; color: var(--sidebar-text); }
.side-motto svg { width: 32px; height: 32px; color: var(--sidebar-text-strong); flex-shrink: 0; }

.app-main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  min-height: var(--nav-height); padding: 10px 28px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .logo { margin-right: auto; }
.topbar .logo-text strong { font-size: 1.25rem; letter-spacing: 0; }
.topbar .logo-text span { font-family: var(--font-sans); font-size: 0.85rem; font-weight: 400; margin-top: 3px; }
/* Hide page content until the sign-in check has finished */
body[data-auth="required"]:not(.auth-ok) .app-content { visibility: hidden; }

.account { position: relative; }
.workspace {
  display: flex; align-items: center; gap: 12px; padding: 4px 8px 4px 16px; text-align: left;
  border: 0; border-left: 1px solid var(--border); background: none; color: var(--text); font: inherit; cursor: pointer;
}
.workspace:hover strong { color: var(--link); }
.account-menu {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 40; min-width: 240px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow); padding: 8px;
}
.account-menu .acc-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.account-menu .acc-head strong { display: block; font-size: 0.92rem; }
.account-menu .acc-head span { display: block; font-size: 0.82rem; color: var(--muted); word-break: break-all; }
.account-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text); font: inherit; font-size: 0.92rem; cursor: pointer; text-align: left;
}
.account-menu button:hover { background: var(--field); }
.account-menu button svg { width: 18px; height: 18px; color: var(--muted); }
.workspace .avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-navy); color: #fff; font-weight: 700; font-size: 0.9rem; flex-shrink: 0; }
.workspace .avatar svg { width: 20px; height: 20px; }
.workspace strong { display: block; font-size: 0.92rem; }
.workspace span { display: block; font-size: 0.8rem; color: var(--muted); }
.drawer-btn { display: none; }
.app-content { padding: 28px; flex: 1; }
.scrim { display: none; }

/* ---------- Page header ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: clamp(1.45rem, 2.6vw, 1.85rem); font-weight: 800; letter-spacing: -0.015em; }
.page-head p { color: var(--muted); margin-top: 6px; }
.page-head .controls { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.page-head .select { min-height: 46px; width: auto; }

/* ---------- Calculator ---------- */
.calc-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: var(--space-card-gap); align-items: start; }
.calc-col { display: grid; gap: 16px; min-width: 0; }
.calc-side { position: sticky; top: calc(var(--nav-height) + 16px); }

.calc-col > *, .tool-row { min-width: 0; }
.tool-row {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.tool-head { display: flex; align-items: center; gap: 14px; }
.tool-head .tool-name { flex: 1; }
.pts-badge {
  display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0;
  min-width: 76px; padding: 6px 12px; border-radius: var(--radius); background: var(--bg-soft);
}
.pts-badge strong { font-size: 1.35rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.pts-badge span { font-size: 0.75rem; color: var(--muted); }
.tool-fields {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
}
.tool-row .field-label { font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; white-space: nowrap; }
.tool-row .input-group { min-height: 46px; }
.tool-row .input-group input { font-size: 1rem; }
.tool-row .start-time { padding-right: 10px; }
.tool-row .time-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.tool-fields > *, .tool-row .time-pair > * { min-width: 0; }
.tool-photo {
  width: 64px; height: 58px; flex-shrink: 0; border-radius: var(--radius); overflow: hidden;
  display: grid; place-items: center; background: var(--bg-soft); color: var(--link);
}
.tool-photo img, .tool-cell .thumb img { width: 100%; height: 100%; object-fit: contain; padding: 2px; }
.tool-photo:has(img), .tool-cell .thumb:has(img) { background: var(--illus-bg); }
.tool-photo svg { width: 36px; height: 36px; }
.tool-name { position: relative; min-width: 0; }
.tool-name strong { display: block; font-size: 1.02rem; }
.tool-name small { display: block; color: var(--muted); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-name .change { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 0.8rem; color: var(--link); font-weight: 600; }
.tool-name .change svg { width: 14px; height: 14px; }
.tool-name select { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; font: inherit; }
.tool-row .del { width: 36px; height: 36px; border: 0; background: none; color: var(--muted); border-radius: var(--radius-sm); cursor: pointer; display: grid; place-items: center; }
.tool-row .del svg { width: 22px; height: 22px; }
.tool-row .del:hover { color: var(--status-limit); background: var(--status-limit-bg); }
.single .del { visibility: hidden; }

.add-row {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  border: 1.5px dashed color-mix(in srgb, var(--link) 35%, var(--border)); border-radius: var(--radius-md);
  padding: 16px 18px; background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.add-row .plus { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--link); flex-shrink: 0; }
.add-row .plus svg { width: 22px; height: 22px; }
.add-row strong { display: block; color: var(--link); }
.add-row span { font-size: 0.88rem; color: var(--muted); }
.add-row .btn { margin-left: auto; }

/* Timeline */
.timeline-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; margin-bottom: 16px; }
.timeline-head .total { color: var(--muted); font-size: 0.92rem; }
.timeline-head .total b { color: var(--text); }
.timeline { display: grid; grid-template-columns: 120px minmax(0, 1fr); row-gap: 10px; }
.timeline .label { font-size: 0.88rem; display: flex; align-items: center; min-height: 26px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 8px; }
.timeline .lane { position: relative; min-height: 26px; }
.timeline .lane::before { content: ""; position: absolute; inset: 0; background-image: repeating-linear-gradient(to right, var(--border) 0 1px, transparent 1px calc(100% / var(--hours))); background-size: 100% 100%; opacity: 0.9; }
.timeline .bar { position: absolute; top: 4px; bottom: 4px; border-radius: 4px; min-width: 6px; }
.timeline .axis { position: relative; height: 22px; border-top: 1px solid var(--muted); margin-top: 2px; }
.timeline .axis span { position: absolute; top: 6px; transform: translateX(-50%); font-size: 0.78rem; color: var(--muted); }
.timeline-empty { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 0.92rem; padding: 6px 0; }
.timeline-empty svg { width: 22px; height: 22px; color: var(--link); flex-shrink: 0; }

/* Summary card */
.summary-head { display: flex; justify-content: space-between; align-items: center; gap: 4px 12px; flex-wrap: wrap; margin-bottom: 16px; }
.summary-head h2 { font-size: 1.3rem; font-weight: 800; }
.date-chip { display: inline-flex; align-items: center; gap: 6px; color: var(--link); font-size: 0.88rem; font-weight: 600; white-space: nowrap; }
.date-chip svg { width: 16px; height: 16px; }
.summary-top { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px; align-items: center; margin-bottom: 16px; }
.gauge { position: relative; width: 176px; height: 176px; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge .track { stroke: var(--track); }
.gauge .arc { stroke: var(--status-safe); transition: stroke-dashoffset 0.6s cubic-bezier(.2,.8,.2,1), stroke 0.3s; }
[data-level="action"] .gauge .arc { stroke: var(--status-action); }
[data-level="limit"] .gauge .arc { stroke: var(--status-limit); }
.gauge-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.gauge-label strong { font-size: 2.5rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.gauge-label span { font-size: 0.9rem; color: var(--muted); margin-top: 6px; }
.status-box { border-radius: var(--radius-md); padding: 16px; background: var(--field); }
.status-box .head { display: flex; align-items: center; gap: 10px; font-size: 1.3rem; font-weight: 700; }
.status-box .head svg { width: 24px; height: 24px; flex-shrink: 0; color: var(--muted); }
.status-box p { margin-top: 8px; font-size: 0.9rem; color: var(--muted); }
[data-level="safe"] .status-box { background: var(--status-safe-bg); }
[data-level="safe"] .status-box svg { color: var(--status-safe); }
[data-level="action"] .status-box { background: var(--status-action-bg); }
[data-level="action"] .status-box svg { color: var(--status-action); }
[data-level="limit"] .status-box { background: var(--status-limit-bg); }
[data-level="limit"] .status-box svg { color: var(--status-limit); }
.facts { margin: 0; }
.facts div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.facts dt { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.93rem; }
.facts dt svg { width: 16px; height: 16px; }
.facts dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Guidance list */
.guide-head { display: flex; justify-content: space-between; align-items: center; gap: 4px 12px; flex-wrap: wrap; margin-bottom: 14px; }
.guide-head h2 { display: flex; align-items: center; gap: 10px; font-size: 1.2rem; font-weight: 800; }
.guide-head h2 svg { width: 22px; height: 22px; color: var(--status-action); }
.guide-head a { font-size: 0.88rem; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.guide-head a svg { width: 16px; height: 16px; }
.guide-items { display: grid; gap: 10px; }
.guide-item { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: var(--radius-md); background: var(--bg-soft); color: var(--text); text-decoration: none; }
a.guide-item:hover { background: var(--accent-soft); }
.guide-item > svg:first-child { width: 28px; height: 28px; flex-shrink: 0; color: var(--muted); }
.guide-item.safe > svg:first-child { color: var(--status-safe); }
.guide-item.action > svg:first-child { color: var(--status-action); }
.guide-item.limit > svg:first-child { color: var(--status-limit); }
.guide-item strong { display: block; font-size: 0.93rem; }
.guide-item span { display: block; font-size: 0.83rem; color: var(--muted); }
.guide-item .chev { width: 18px; height: 18px; margin-left: auto; color: var(--muted); flex-shrink: 0; }

/* Details */
.details-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: var(--space-form); }

/* Action bar */
.action-bar {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  margin: 24px -28px -28px; padding: 14px 28px;
  background: color-mix(in srgb, var(--app-bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
}
.action-bar .spacer { flex: 1; }
.action-bar .btn { min-width: 170px; }
.btn-teal { background: var(--accent-teal); color: #fff; }
.btn-teal:hover { background: var(--accent-teal-hover); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 200; display: none; place-items: center; padding: 16px; background: rgba(8, 18, 34, 0.5); }
.modal.open { display: grid; }
.modal-panel { width: min(640px, 100%); max-height: min(80vh, 720px); display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); border: 1px solid var(--border); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 20px 22px 12px; }
.modal-head h2 { font-size: 1.2rem; }
.modal-body { padding: 0 22px 22px; overflow-y: auto; }
.modal-body .input-group { margin-bottom: 14px; }
/* Picker anchored above the "Add another tool" card */
.modal.anchored { display: block; padding: 0; background: rgba(8, 18, 34, 0.18); }
.modal.anchored .modal-panel { position: fixed; animation: pop-in 0.16s ease-out; }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
/* Bottom sheet on phones */
.modal.sheet { place-items: end stretch; padding: 0; }
.modal.sheet .modal-panel { width: 100%; max-height: 82vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; animation: sheet-up 0.2s ease-out; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.tool-item.other .tool-photo { background: var(--accent-soft); color: var(--link); }
.tool-item.other .tool-photo svg { width: 26px; height: 26px; }
.add-row { cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.add-row:hover { border-color: var(--link); background: var(--accent-soft); }
.add-row .plus { border: 0; cursor: pointer; transition: transform 0.15s; }
.add-row:hover .plus { transform: scale(1.06); }

/* ---------- Tool list (library + picker) ---------- */
.tool-list { display: grid; gap: 10px; }
.tool-item {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 12px; text-align: left; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); cursor: pointer;
}
.tool-item:hover { border-color: var(--link); }
.tool-item .tool-photo { width: 64px; height: 56px; }
.tool-item .tool-photo svg { width: 30px; height: 30px; }
.tool-item .info-col { flex: 1; min-width: 0; }
.tool-item strong { display: block; }
.tool-item small { display: block; color: var(--muted); font-size: 0.85rem; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { font-size: 0.75rem; font-weight: 600; padding: 2px 9px; border-radius: var(--radius-pill); background: var(--field); color: var(--muted); }
.chip.blue { background: var(--accent-soft); color: var(--link); }
.tool-item .chev { width: 20px; height: 20px; color: var(--muted); flex-shrink: 0; }

.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.lib-card { display: flex; gap: 14px; align-items: flex-start; }
.lib-card .tool-photo { width: 72px; height: 64px; flex-shrink: 0; }
.lib-card .info-col { flex: 1; min-width: 0; }
.lib-card strong { display: block; }
.lib-card small { display: block; color: var(--muted); font-size: 0.85rem; }
.lib-card .lib-actions { display: flex; gap: 8px; margin-top: 12px; }
.lib-card .lib-actions .btn { min-height: 34px; padding: 4px 12px; font-size: 0.85rem; }
.lib-card .lib-actions .btn svg { width: 16px; height: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-form); }
.form-grid .wide { grid-column: 1 / -1; }

/* ---------- Dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-card-gap); margin-bottom: var(--space-card-gap); }
.stat-card .top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.stat-card .label { color: var(--muted); font-size: 0.9rem; font-weight: 500; }
.stat-card .value { font-size: 2.2rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-card .value small { font-size: 1rem; font-weight: 600; }
.trend { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.trend b { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: var(--radius-pill); font-weight: 700; background: var(--field); color: var(--text); }
.trend b svg { width: 14px; height: 14px; }
.trend b.good { background: var(--status-safe-bg); color: var(--status-safe-text); }
.trend b.bad { background: var(--status-limit-bg); color: var(--status-limit-text); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--space-card-gap); margin-bottom: var(--space-card-gap); align-items: start; }

.chart-wrap { position: relative; height: 280px; }
.chart-wrap svg { width: 100%; height: 100%; overflow: visible; }
.chart-wrap .grid line { stroke: var(--border); }
.chart-wrap .axis text { fill: var(--muted); font-size: 11px; font-family: var(--font-sans); }
.chart-wrap .ref-eav { stroke: var(--status-action); stroke-dasharray: 5 4; stroke-width: 1.5; }
.chart-wrap .ref-elv { stroke: var(--status-limit); stroke-dasharray: 5 4; stroke-width: 1.5; }
.chart-wrap .ref-label { font-size: 11px; font-weight: 600; font-family: var(--font-sans); fill: var(--muted); }
.chart-wrap .area { fill: var(--link); opacity: 0.08; }
.chart-wrap .line { fill: none; stroke: var(--link); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-wrap .dot { fill: var(--link); stroke: var(--surface); stroke-width: 2; }
.chart-wrap .cross { stroke: var(--muted); stroke-width: 1; opacity: 0; }
.chart-wrap .hover-dot { fill: var(--link); stroke: var(--surface); stroke-width: 3; opacity: 0; }
.chart-wrap.hovering .cross, .chart-wrap.hovering .hover-dot { opacity: 1; }
.tooltip { position: absolute; pointer-events: none; z-index: 2; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 12px; font-size: 0.85rem; min-width: 150px; opacity: 0; transform: translate(-50%, calc(-100% - 14px)); transition: opacity 0.1s; }
.chart-wrap.hovering .tooltip { opacity: 1; }
.tooltip .t-date { color: var(--muted); font-size: 0.78rem; }
.tooltip .t-val { font-size: 1.15rem; font-weight: 800; margin: 2px 0 6px; font-variant-numeric: tabular-nums; }
.chart-empty { height: 100%; display: grid; place-items: center; color: var(--muted); text-align: center; }

.risk-list { display: grid; gap: 12px; }
.risk-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; }
.risk-row .bar { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.risk-row .bar i { display: block; height: 100%; border-radius: 4px; }
.risk-row b { font-variant-numeric: tabular-nums; }

/* Assessments table */
.table-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions .btn { min-height: 34px; padding: 4px 10px; font-size: 0.85rem; }
.row-actions .btn svg { width: 16px; height: 16px; }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.search .input { padding-left: 38px; min-height: 44px; width: 260px; }

.empty { text-align: center; padding: 56px 20px; }
.empty .icon-tile { margin: 0 auto 18px; width: 72px; height: 72px; border-radius: 50%; }
.empty .icon-tile svg { width: 32px; height: 32px; }
.empty h2 { font-size: 1.35rem; }
.empty p { color: var(--muted); margin: 8px auto 24px; max-width: 30rem; }
.empty .btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.notice { margin-bottom: var(--space-card-gap); }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); opacity: 0; visibility: hidden;
  display: flex; align-items: center; gap: 10px;
  background: var(--text); color: var(--bg);
  padding: 12px 18px; border-radius: var(--radius-md); box-shadow: var(--shadow);
  font-weight: 600; transition: transform 0.2s, opacity 0.2s, visibility 0.2s; z-index: 300;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
.toast svg { width: 20px; height: 20px; color: var(--status-safe); }
.toast a { color: inherit; }

.print-only { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1279px) {
  .calc-layout, .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .calc-side { position: static; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1023px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; z-index: 100; left: 0; top: 0; bottom: 0; width: 280px;
    transform: translateX(-100%); transition: transform 0.25s ease;
  }
  .sidebar .side-logo { display: block; }
  .app.drawer-open .sidebar { transform: none; }
  .app.drawer-open .scrim { display: block; position: fixed; inset: 0; z-index: 90; background: rgba(8, 18, 34, 0.5); }
  .drawer-btn { display: grid; }
  .topbar { padding: 10px 16px; }
  .app-content { padding: 20px 16px; }
  .action-bar { margin: 20px -16px -20px; padding: 12px 16px; }
}
@media (max-width: 767px) {
  .workspace div { display: none; }
  .workspace { padding-left: 0; border-left: 0; }
  .topbar .logo-text span { display: none; }
  .stats { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-card { padding: 16px; }
  .stat-card .value { font-size: 1.7rem; }
  .stat-card .icon-tile { width: 38px; height: 38px; }
  .stat-card .icon-tile svg { width: 20px; height: 20px; }
  .trend .vs { display: none; }
  .chart-wrap { height: 220px; }
  .page-head .controls { width: 100%; }
  .page-head .controls > * { flex: 1; }
  .search .input { width: 100%; }
  .search { width: 100%; }
  .tool-row { padding: 14px; }
  .tool-head { gap: 12px; }
  .tool-photo { width: 56px; height: 52px; }
  .pts-badge { min-width: 64px; padding: 6px 8px; }
  .tool-fields { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .add-row .btn { margin-left: 0; width: 100%; }
  .timeline { grid-template-columns: 90px minmax(0, 1fr); }
  .summary-top { grid-template-columns: 1fr; justify-items: center; }
  .status-box { width: 100%; }
  .details-grid, .form-grid { grid-template-columns: 1fr; }
  .action-bar { display: grid; grid-template-columns: 1fr 1fr; }
  .action-bar .spacer { display: none; }
  .action-bar .btn { min-width: 0; }
  .action-bar .btn-ghost { order: 4; }
  /* Assessments as stacked cards */
  .assess-table thead { display: none; }
  .assess-table, .assess-table tbody, .assess-table tr, .assess-table td { display: block; }
  .assess-table tr { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px; margin-bottom: 12px; }
  .assess-table td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 0; padding: 6px 0; text-align: right; }
  .assess-table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 0.85rem; text-align: left; }
  .assess-table td:first-child { padding-bottom: 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border); text-align: left; }
  .assess-table .tool-cell { min-width: 0; }
  .assess-table .actions-cell { padding-top: 10px; }
  .assess-table .row-actions { width: 100%; }
  .assess-table .row-actions .btn-ghost { flex: 1; }
}

/* Printable report */
@media print {
  @page { margin: 14mm; }
  body.app-body { background: #fff; }
  .sidebar, .topbar, .action-bar, .add-row, .no-print, .tool-row .del, .tool-name .change { display: none !important; }
  .app { display: block; }
  .app-content { padding: 0; }
  .print-only { display: block; }
  .calc-layout { display: block; }
  .calc-col { display: block; }
  .card, .tool-row { box-shadow: none; break-inside: avoid; margin-bottom: 12px; }
  .print-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #0b2d5b; padding-bottom: 12px; margin-bottom: 18px; }
}
