/* One block per tab: overview, my business, flood cost, ask AI. */

/* ---------- overview ---------- */
.kpis { display: grid; grid-template-columns: 1.4fr repeat(3, minmax(0, 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.kpi { display: grid; align-content: start; gap: 2px; padding: var(--space-4) var(--space-5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.kpi-figure { font-size: var(--text-figure); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.kpi-label { font-size: var(--text-sm); font-weight: 600; }
.kpi-note { font-size: var(--text-xs); color: var(--ink-3); }
.kpi .icon { width: 20px; height: 20px; color: var(--brand); margin-bottom: var(--space-1); }
.kpi-hero { background: var(--brand-deep); border-color: var(--brand-deep); color: #fff; box-shadow: var(--shadow-md); }
.kpi-hero .kpi-note, .kpi-hero .icon { color: var(--band-1); }
.kpi-bar { height: 6px; margin-top: var(--space-2); border-radius: 999px; background: rgba(255, 255, 255, 0.16); overflow: hidden; }
.kpi-bar span { display: block; height: 100%; border-radius: inherit; background: var(--band-2); transform-origin: left; transition: transform 600ms var(--ease-out-expo); }

.overview-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); margin-bottom: var(--space-4); }
#map { height: clamp(320px, 58vh, 600px); border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--surface-sunk); }
.leaflet-container { font-family: var(--font); }
.leaflet-tile-pane { filter: grayscale(1) sepia(0.06) contrast(0.85) brightness(1.06); }   /* quiet base, so the water reads */
.leaflet-popup-content-wrapper { border-radius: var(--radius-md); box-shadow: var(--shadow-md); }
.leaflet-popup-content { margin: var(--space-3) var(--space-4); min-width: 12rem; }
.pop-name { font-weight: 700; font-size: var(--text-sm); line-height: 1.3; }
.pop-depth { margin: var(--space-1) 0 var(--space-2); font-size: var(--text-sm); color: var(--ink-2); }
.pop-depth strong { color: var(--brand); }
.shelter-pin { display: inline-block; flex: none; width: 16px; height: 14px; background: var(--dry); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.leaflet-tooltip.shelter-label { border: 0; box-shadow: none; background: none; color: var(--dry); font-weight: 700; font-size: var(--text-xs); text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.leaflet-tooltip.shelter-label::before { display: none; }

/* past floods strip */
.history-lead { margin-top: var(--space-1); font-size: var(--text-sm); }
.history-lead strong { color: var(--brand); }
.flood-strip { display: block; width: 100%; margin: var(--space-3) 0 var(--space-2); overflow: visible; }
.flood-strip .axis { stroke: var(--line-strong); stroke-width: 1; }
.flood-strip text { font: 11px var(--font); fill: var(--ink-3); }
.flood-strip .flood-count { font-weight: 700; fill: var(--brand); }
.flood-dot { fill: var(--brand); stroke: var(--surface); stroke-width: 1.5; }
.flood-dot.is-account { fill: var(--surface); stroke: var(--brand); }
#history details { margin-top: var(--space-3); font-size: var(--text-sm); }
#history summary { cursor: pointer; color: var(--brand); font-weight: 600; }
.flood-list { display: grid; gap: var(--space-2); margin-top: var(--space-3); }
.flood-list .muted { display: block; font-size: var(--text-xs); color: var(--ink-3); }

/* all businesses */
.directory #directory-filter { max-width: 18rem; }
.directory-head, .directory button { display: grid; grid-template-columns: minmax(0, 1fr) repeat(3, 4rem); gap: var(--space-2); align-items: center; }
.directory-head { padding: 0 var(--space-3) var(--space-2); font-size: var(--text-xs); font-weight: 600; color: var(--ink-3); text-align: center; }
.directory-head span:first-child { text-align: left; }
#directory { max-height: 28rem; overflow-y: auto; border-top: 1px solid var(--line); }
#directory li[hidden] { display: none; }
.directory button { width: 100%; padding: var(--space-2) var(--space-3); border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer; transition: background-color var(--duration-fast); }
.directory button:hover { background: var(--surface-sunk); }
.directory button[aria-current="true"] { background: var(--brand-wash); box-shadow: inset 3px 0 0 var(--accent); }
.directory .name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: var(--text-sm); }
.directory .meta { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-xs); color: var(--ink-3); }
.depth-chip { padding: 3px 0; border-radius: 6px; text-align: center; font-size: var(--text-xs); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-3); background: var(--surface-sunk); }
/* two classes, so the band colour beats the chip's neutral background */
.depth-chip.band-1 { background: var(--band-1); color: var(--ink); }
.depth-chip.band-2 { background: var(--band-2); color: var(--ink); }
.depth-chip.band-3 { background: var(--band-3); color: #fff; }
.depth-chip.band-4 { background: var(--band-4); color: #fff; }
.depth-chip.band-5 { background: var(--band-5); color: #fff; }
@media (max-width: 520px) {   /* phones: name on its own line, the three depths below it, each labelled */
  .directory-head { display: none; }
  .directory button { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: var(--space-1); }
  .directory button > span:first-child { grid-column: 1 / -1; }
  .depth-chip::before { content: "1 in " attr(data-rp) ": "; font-weight: 500; }
}

@media (min-width: 1040px) {
  .overview-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
}
@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-hero, .kpi:last-child { grid-column: 1 / -1; }
}

/* ---------- my business ---------- */
.biz-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-5); }
.biz-head .tags { margin-top: var(--space-2); }
.biz-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.risk .scenario { margin-bottom: var(--space-5); }
.headline { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2); }
.headline strong { font-size: var(--text-figure); font-weight: 800; letter-spacing: -0.03em; line-height: 1; color: var(--brand); font-variant-numeric: tabular-nums; }
.headline span { font-size: var(--text-xl); font-weight: 700; }
.headline.is-dry strong { color: var(--dry); }
.subhead { margin-top: var(--space-1); font-size: var(--text-sm); color: var(--ink-2); }

.gauge { display: block; width: 100%; max-width: 34rem; height: auto; margin: var(--space-5) 0 var(--space-2); }
.gauge text { font: 12px var(--font); fill: var(--ink-2); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }   /* a light outline keeps labels readable over water */
.gauge .figure, .gauge .knob { fill: var(--ink-3); }
.gauge .door { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.gauge .counter { fill: var(--surface-sunk); stroke: var(--ink); stroke-width: 1.5; }
.gauge .floor { fill: var(--line); }
.gauge .water { fill-opacity: 0.6; transform-box: fill-box; transform-origin: bottom; transition: transform 700ms var(--ease-out-expo); }
.gauge .waterline { stroke: var(--band-4); stroke-width: 2; transition: transform 700ms var(--ease-out-expo); }
.gauge .other-level { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 4 3; opacity: 0.55; }
.gauge .level.is-active, .gauge .object-label { font-weight: 700; fill: var(--ink); }
.gauge .street { stroke: var(--ink); stroke-width: 2; }
.gauge .storey { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 1 3; }

.biz-side { display: grid; gap: var(--space-3); }
.facts { display: grid; gap: var(--space-2); }
.fact { padding: var(--space-3) var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); }
.fact-label { margin: 0; display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
.fact-value { margin-top: 2px; font-weight: 700; }
.fact-note { margin-top: 2px; font-size: var(--text-sm); color: var(--ink-2); }
.fact .btn { margin-top: var(--space-2); }
.photo-thumb { display: block; width: 96px; height: 72px; margin-top: var(--space-2); object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.photo-button { position: relative; }
.photo-button:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.photo-button[aria-disabled="true"] { opacity: 0.6; pointer-events: none; }

.next { display: grid; gap: var(--space-2); }
.next-step { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); width: 100%; padding: var(--space-4); border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--surface); text-align: left; cursor: pointer; transition: border-color var(--duration-fast), transform var(--duration-fast), box-shadow var(--duration-fast); }
.next-step:hover { border-color: var(--ink-3); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.next-step strong { display: block; font-size: var(--text-md); color: var(--ink); }
.next-step span { font-size: var(--text-sm); color: var(--ink-2); }
.next-step .icon { width: 20px; height: 20px; color: var(--ink-2); }
.next-step.is-primary { border: 1.5px solid var(--accent); background: var(--accent-wash); }
.next-step.is-primary .icon { color: var(--accent); }

@media (max-width: 900px) { .biz-grid { grid-template-columns: minmax(0, 1fr); } }
@media (min-width: 901px) { .gauge text { font-size: 9.5px; } }   /* the drawing scales up on wide screens; its labels should not */

/* ---------- flood cost ---------- */
.cost-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: var(--space-4); align-items: start; }
.cost-form { display: grid; gap: var(--space-5); }
.cost-form legend { margin-bottom: var(--space-2); font-weight: 700; }
.cost-form .hint { margin: -2px 0 var(--space-2); font-size: var(--text-sm); color: var(--ink-2); }
.choice { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) 0; font-size: var(--text-sm); cursor: pointer; }
.choice input { width: 18px; height: 18px; accent-color: var(--brand); }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.input-label { display: grid; gap: var(--space-1); font-size: var(--text-sm); font-weight: 600; }
.money, .unit { position: relative; }
.money .field { padding-left: 2.6rem; }
.money::before { content: "RM"; position: absolute; left: var(--space-3); top: 50%; transform: translateY(-50%); font-size: var(--text-sm); font-weight: 600; color: var(--ink-3); }
.unit .field { padding-right: 3rem; }
.unit::after { content: attr(data-unit); position: absolute; right: var(--space-3); top: 50%; transform: translateY(-50%); font-size: var(--text-sm); color: var(--ink-3); }
.cost-form details summary { cursor: pointer; font-weight: 700; }
.cost-form details[open] summary { margin-bottom: var(--space-3); }
.form-error { color: #9c2f10; font-size: var(--text-sm); font-weight: 600; }
.form-error:empty { display: none; }

.cost-results { display: grid; gap: var(--space-4); }
.cost-empty { display: grid; gap: var(--space-2); place-items: start; color: var(--ink-2); }
.cost-empty .icon { width: 32px; height: 32px; color: var(--brand); }
.headline-figures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.figure-box { padding: var(--space-4); border-radius: var(--radius-md); background: var(--surface-sunk); }
.figure-box.is-key { background: var(--brand-deep); color: #fff; }
.figure-box .kpi-figure { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.25rem); }
.figure-box .kpi-note { color: inherit; opacity: 0.75; }
.table-scroll { overflow-x: auto; }   /* the table scrolls inside its card on narrow screens, not the page */
.loss-table { width: 100%; min-width: 26rem; border-collapse: collapse; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.loss-table th, .loss-table td { padding: var(--space-2) var(--space-2); border-bottom: 1px solid var(--line); text-align: right; }
.loss-table th:first-child, .loss-table td:first-child { text-align: left; }
.loss-table thead th { font-size: var(--text-xs); font-weight: 600; color: var(--ink-3); }
.loss-table tbody th { font-weight: 600; }
.verdict { padding: var(--space-4); border-radius: var(--radius-md); border: 1.5px solid var(--line-strong); }
.verdict.is-yes { border-color: var(--dry); background: #edf6ef; }
.verdict.is-no { border-color: var(--accent); background: var(--accent-wash); }
.verdict strong { display: block; font-size: var(--text-lg); }
.cost-results details { font-size: var(--text-sm); color: var(--ink-2); }
.cost-results details summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.cost-results details p { margin-top: var(--space-2); }

@media (max-width: 900px) { .cost-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- ask AI ---------- */
.ask-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.ask-side { display: grid; gap: var(--space-3); }
.ask-side .btn { width: 100%; margin-top: var(--space-3); }
.chat { display: grid; gap: var(--space-3); }
.messages { display: grid; align-content: start; gap: var(--space-3); min-height: 16rem; max-height: 30rem; overflow-y: auto; padding-right: var(--space-1); }
.messages li { max-width: 88%; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); font-size: var(--text-sm); white-space: pre-wrap; animation: enter var(--duration-normal) var(--ease-out) both; }
.msg-user { justify-self: end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg-model { justify-self: start; background: var(--surface-sunk); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg-error { justify-self: start; background: var(--danger-wash); color: #7a2a12; }
.msg-wait { justify-self: start; color: var(--ink-3); font-style: italic; }
.sources { margin-top: var(--space-2); padding-left: var(--space-4); list-style: disc; white-space: normal; font-size: var(--text-xs); }
.search-suggestions { display: block; margin-top: var(--space-2); white-space: normal; }
.ask-form { display: flex; gap: var(--space-2); }

@media (max-width: 900px) { .ask-grid { grid-template-columns: minmax(0, 1fr); } }
