/* Tools Website — design tokens and components (DESIGN_SYSTEM.md, from UI UX Pro Max).
   Raw colour values appear ONLY in :root below; components use the tokens. */

@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/ibm-plex-sans-latin-700-normal.woff2") format("woff2"); }

/* ---- Tokens ---- */
:root {
  --color-ink: #0F172A;
  --color-primary: #1E3A8A;
  --color-primary-hover: #1E40AF;
  --color-on-primary: #FFFFFF;
  --color-accent: #A16207;
  --color-bg: #F8FAFC;
  --color-surface: #FFFFFF;
  --color-surface-muted: #E8ECF1;
  --color-muted: #64748B;
  --color-border: #E2E8F0;
  --color-input-border: #94A3B8;
  --color-focus: #1E3A8A;
  --color-danger: #DC2626;
  --color-success: #15803D;

  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --text-xs: 0.875rem;  --lh-xs: 1.25rem;
  --text-sm: 1rem;      --lh-sm: 1.5rem;
  --text-md: 1.125rem;  --lh-md: 1.75rem;
  --text-lg: 1.25rem;   --lh-lg: 1.75rem;
  --text-xl: 1.5rem;    --lh-xl: 2rem;
  --text-2xl: 2rem;     --lh-2xl: 2.5rem;

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-6: 24px; --space-8: 32px; --space-12: 48px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --shadow-1: 0 1px 2px rgb(15 23 42 / .06), 0 1px 3px rgb(15 23 42 / .10);
  --z-sticky: 10; --z-bottom-bar: 20; --z-nav: 30; --z-toast: 100;
  --dur-fast: 150ms; --dur-panel: 200ms; --dur-chart: 250ms;
  --max-width: 1200px;
  --gutter: var(--space-4);
  --touch: 44px;
  --input-height: 48px;
  --nav-height: 56px;
}
@media (min-width: 768px) { :root { --gutter: var(--space-6); } }

/* ---- Base ---- */
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--lh-sm);
}
h1 { font-size: var(--text-2xl); line-height: var(--lh-2xl); font-weight: 700; margin: 0 0 var(--space-4); }
h2 { font-size: var(--text-xl); line-height: var(--lh-xl); font-weight: 600; margin: var(--space-8) 0 var(--space-4); }
h3 { font-size: var(--text-lg); line-height: var(--lh-lg); font-weight: 600; margin: 0 0 var(--space-3); }
p { margin: 0 0 var(--space-4); }
.lead { font-size: var(--text-md); line-height: var(--lh-md); max-width: 70ch; }
a { color: var(--color-primary); text-underline-offset: 2px; }
a:hover { color: var(--color-primary-hover); }
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.num, table { font-variant-numeric: tabular-nums; }
.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;
}
.icon { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.wrap { max-width: var(--max-width); margin-inline: auto; padding-inline: var(--gutter); }
.page { padding-block: var(--space-6) var(--space-12); }
.print-only { display: none; }

.skip-link {
  position: absolute; left: var(--space-2); top: calc(-2 * var(--space-12)); z-index: var(--z-toast);
  background: var(--color-surface); color: var(--color-primary);
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm); box-shadow: var(--shadow-1);
}
.skip-link:focus { top: var(--space-2); }

/* ---- Navbar ---- */
.site-header { background: var(--color-surface); border-bottom: 1px solid var(--color-border); position: sticky; top: 0; z-index: var(--z-nav); }
.site-nav { display: flex; align-items: center; justify-content: space-between; min-height: var(--nav-height); gap: var(--space-4); position: relative; }
.brand { font-weight: 700; font-size: var(--text-md); color: var(--color-ink); text-decoration: none; min-height: var(--touch); display: inline-flex; align-items: center; }
.nav-links { list-style: none; margin: 0; padding: 0; display: flex; gap: var(--space-4); }
.nav-links a { display: inline-flex; align-items: center; min-height: var(--touch); color: var(--color-ink); text-decoration: none; }
.nav-links a:hover { color: var(--color-primary); }
.nav-links a[aria-current="page"] { color: var(--color-primary); font-weight: 600; box-shadow: inset 0 -2px 0 var(--color-primary); }
.nav-desktop { display: none; }
.nav-menu > summary {
  list-style: none; display: inline-flex; align-items: center; gap: var(--space-2);
  min-height: var(--touch); min-width: var(--touch); cursor: pointer; padding-inline: var(--space-2);
}
.nav-menu > summary::-webkit-details-marker { display: none; }
.nav-menu .nav-links {
  position: absolute; right: 0; top: 100%; flex-direction: column; gap: 0; min-width: 14rem;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-1); padding: var(--space-2) var(--space-4);
}
@media (min-width: 768px) {
  .nav-desktop { display: flex; }
  .nav-menu { display: none; }
}

/* ---- Footer, breadcrumbs ---- */
.site-footer { background: var(--color-surface); border-top: 1px solid var(--color-border); padding-block: var(--space-8); color: var(--color-muted); font-size: var(--text-xs); line-height: var(--lh-xs); }
.breadcrumbs ol { list-style: none; margin: 0 0 var(--space-4); padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); font-size: var(--text-xs); line-height: var(--lh-xs); color: var(--color-muted); }
.breadcrumbs li + li::before { content: "›"; content: "›" / ""; margin-right: var(--space-2); }

/* ---- Buttons, cards ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--touch); padding: 0 var(--space-4); border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; touch-action: manipulation;
  transition: background-color var(--dur-fast) ease-out, color var(--dur-fast) ease-out;
}
.btn-primary { background: var(--color-primary); color: var(--color-on-primary); border: 1px solid var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-hover); color: var(--color-on-primary); }
.btn-secondary { background: var(--color-surface); color: var(--color-primary); border: 1px solid var(--color-input-border); }
.btn-secondary:hover { background: var(--color-bg); }
.btn-link { background: none; border: 0; color: var(--color-primary); text-decoration: underline; padding-inline: var(--space-2); font-weight: 500; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-1); padding: var(--space-6); }

/* ---- Home ---- */
.tool-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); }
.tool-card p { margin: 0; color: var(--color-muted); }

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

/* ---- Forms (input-field, unit-switch, check, disclosure) ---- */
.calc-form { display: grid; gap: var(--space-4); }
.field { display: grid; gap: var(--space-1); min-width: 0; }
.field-label { font-weight: 500; }
.field-row { display: flex; gap: var(--space-2); align-items: stretch; flex-wrap: wrap; }
.field-control {
  flex: 1 1 10rem; display: flex; align-items: center; gap: var(--space-2);
  min-height: var(--input-height); padding-inline: var(--space-3);
  background: var(--color-surface); border: 1px solid var(--color-input-border); border-radius: var(--radius-sm);
}
.field-control:focus-within { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.field-input {
  flex: 1; min-width: 0; border: 0; padding: 0; background: transparent;
  font: inherit; color: var(--color-ink); min-height: calc(var(--input-height) - 2px);
}
.field-input:focus { outline: none; }
.field-affix { color: var(--color-muted); }
.field-help { margin: 0; font-size: var(--text-xs); line-height: var(--lh-xs); color: var(--color-muted); }
.field-error { margin: 0; display: flex; gap: var(--space-1); align-items: flex-start; color: var(--color-danger); font-size: var(--text-xs); line-height: var(--lh-xs); }
.has-error > .field-row .field-control { border-color: var(--color-danger); }
.error-summary {
  display: flex; gap: var(--space-2); align-items: flex-start; padding: var(--space-3);
  color: var(--color-danger); background: var(--color-surface); border: 1px solid var(--color-danger); border-radius: var(--radius-sm);
}

.unit-switch { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: var(--space-1); }
.unit-options {
  position: relative; display: inline-flex; align-self: start; overflow: hidden;
  background: var(--color-surface); border: 1px solid var(--color-input-border); border-radius: var(--radius-sm);
}
.unit-input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.unit-label {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--input-height);
  padding: 0 var(--space-4); cursor: pointer; color: var(--color-ink); border-left: 1px solid var(--color-input-border);
  touch-action: manipulation; transition: background-color var(--dur-fast) ease-out, color var(--dur-fast) ease-out;
}
.unit-options > .unit-label:first-of-type { border-left: 0; }
.unit-input:checked + .unit-label { background: var(--color-primary); color: var(--color-on-primary); font-weight: 600; }
.unit-input:focus-visible + .unit-label { outline: 2px solid var(--color-focus); outline-offset: -4px; }
.unit-input:checked:focus-visible + .unit-label { outline-color: var(--color-on-primary); }
.unit-switch.is-stacked .unit-options { display: grid; }
.unit-switch.is-stacked .unit-label { justify-content: flex-start; border-left: 0; border-top: 1px solid var(--color-input-border); }
.unit-switch.is-stacked .unit-options > .unit-label:first-of-type { border-top: 0; }

.check { display: flex; align-items: center; gap: var(--space-3); min-height: var(--touch); }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--color-primary); }

.disclosure { border-top: 1px solid var(--color-border); padding-top: var(--space-2); }
.disclosure > summary {
  list-style: none; position: relative; display: flex; flex-direction: column; justify-content: center;
  min-height: var(--touch); padding-left: var(--space-6); cursor: pointer;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::before {
  content: ""; position: absolute; left: var(--space-1); top: 50%; width: 8px; height: 8px;
  border-right: 2px solid var(--color-primary); border-bottom: 2px solid var(--color-primary);
  transform: translateY(-75%) rotate(-45deg); transition: transform var(--dur-panel) ease-out;
}
.disclosure[open] > summary::before { transform: translateY(-75%) rotate(45deg); }
.disclosure-title { font-weight: 600; color: var(--color-primary); }
.disclosure-hint { font-size: var(--text-xs); line-height: var(--lh-xs); color: var(--color-muted); }
.advanced-body { display: grid; gap: var(--space-4); padding-top: var(--space-4); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }

main:focus { outline: none; }

/* ---- Results ---- */
.result { display: grid; gap: var(--space-4); }
.result-heading { margin: 0; font-size: var(--text-lg); line-height: var(--lh-lg); }
.result-label { margin: 0; color: var(--color-muted); }
.result-value { margin: 0; font-size: var(--text-2xl); line-height: var(--lh-2xl); font-weight: 700; }
#results { scroll-margin-top: var(--nav-height); }
.results:focus { outline: none; }
body.is-stale .emi-bar { opacity: .55; }
.results.is-stale .result { opacity: .55; transition: opacity var(--dur-panel) ease-out; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: var(--space-3); margin: 0; }
.stat { background: var(--color-bg); border-radius: var(--radius-sm); padding: var(--space-3); }
.stat-label { font-size: var(--text-xs); line-height: var(--lh-xs); font-weight: 400; color: var(--color-muted); }
.stat-value { margin: 0; font-size: var(--text-md); line-height: var(--lh-md); font-weight: 600; }
.stat-hint { margin: 0; font-size: var(--text-xs); line-height: var(--lh-xs); color: var(--color-muted); }
.notice {
  margin: 0; display: flex; gap: var(--space-2); align-items: flex-start; padding: var(--space-3);
  background: var(--color-surface-muted); border-radius: var(--radius-sm);
}

/* ---- Stacked bar ---- */
.chart { margin: 0; display: grid; gap: var(--space-2); }
.chart-title { font-weight: 600; }
.stacked-bar { display: block; width: 100%; height: 24px; border-radius: var(--radius-sm); overflow: hidden; }
.bar-principal { fill: var(--color-primary); }
.bar-interest { fill: var(--color-accent); }
.bar-hatch { stroke: var(--color-surface); stroke-width: .6; opacity: .45; }
.chart-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-4); font-size: var(--text-xs); line-height: var(--lh-xs); }
.swatch { display: inline-block; width: 12px; height: 12px; margin-right: var(--space-1); border-radius: 2px; vertical-align: -1px; }
.swatch-principal { background: var(--color-primary); }
.swatch-interest { background: var(--color-accent); }

/* ---- Schedule ---- */
.schedule-panel { margin-top: var(--space-8); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-2) var(--space-4) var(--space-4); }
.schedule-body { display: grid; gap: var(--space-4); padding-top: var(--space-3); }
.table-scroll { overflow: auto; max-height: 70vh; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); }
.schedule-table { width: 100%; border-collapse: collapse; font-size: var(--text-xs); line-height: var(--lh-xs); white-space: nowrap; }
.schedule-table caption { caption-side: top; text-align: left; padding: var(--space-3); font-weight: 600; color: var(--color-ink); }
.schedule-table th, .schedule-table td { padding: var(--space-2) var(--space-3); text-align: right; border-bottom: 1px solid var(--color-border); }
.schedule-table th:first-child, .schedule-table .cell-text { text-align: left; }
.schedule-table thead th { position: sticky; top: 0; z-index: 1; background: var(--color-surface); }
.schedule-table tbody th { font-weight: 500; }
.schedule-table tbody tr:nth-child(even) { background: var(--color-surface-muted); }
.tag { display: inline-block; margin-left: var(--space-2); padding: 0 var(--space-2); border-radius: 999px; background: var(--color-surface-muted); border: 1px solid var(--color-border); }
.schedule-panel:has(#f-view-yearly:checked) .table-monthly-wrap { display: none; }
.schedule-panel:has(#f-view-monthly:checked) .table-yearly-wrap { display: none; }

/* ---- Mobile EMI bar ---- */
.emi-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-bottom-bar);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  min-height: var(--nav-height); padding: var(--space-3) var(--gutter) calc(var(--space-3) + env(safe-area-inset-bottom));
  background: var(--color-primary); color: var(--color-on-primary); font-weight: 600; text-decoration: none;
}
.emi-bar:hover { color: var(--color-on-primary); }
@media (max-width: 1023.98px) {
  body:has(.emi-bar) { padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom)); }
}
@media (min-width: 1024px) { .emi-bar { display: none; } }

/* ---- Ads and affiliates ---- */
.ad-slot { margin-block: var(--space-6); text-align: center; }
.ad-label { margin: 0 0 var(--space-1); font-size: var(--text-xs); line-height: var(--lh-xs); color: var(--color-muted); }
.adsbygoogle { display: block; }
.ad-after-results .adsbygoogle, .ad-in-content .adsbygoogle { min-height: 250px; }
@media (min-width: 768px) { .ad-after-results .adsbygoogle, .ad-in-content .adsbygoogle { min-height: 280px; } }
.ad-sidebar { display: none; }
@media (min-width: 1024px) { .ad-sidebar { display: block; } .ad-sidebar .adsbygoogle { min-height: 600px; } }
.affiliate-box { margin-top: var(--space-8); }
.sponsored-label { margin: 0 0 var(--space-1); font-size: var(--text-xs); line-height: var(--lh-xs); font-weight: 600; color: var(--color-muted); }
.affiliate-heading { margin-top: 0; }
.offer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-4); }
.affiliate-note { margin: var(--space-4) 0 0; font-size: var(--text-xs); }

/* ---- Live status, share ---- */
.live-status { min-height: var(--lh-xs); margin: 0 0 var(--space-2); font-size: var(--text-xs); line-height: var(--lh-xs); color: var(--color-muted); }
.share { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.share-status { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--text-xs); line-height: var(--lh-xs); }
.share-status .icon { color: var(--color-success); }

/* ---- Export ---- */
.export { display: grid; gap: var(--space-3); }
.export-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.csv-columns { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 var(--space-4); }
.csv-columns legend { width: 100%; margin-bottom: var(--space-1); }
.print-meta { font-size: var(--text-xs); }

/* ---- Long-form content, FAQ, related tools ---- */
.prose { max-width: 75ch; }
.content { margin-top: var(--space-8); }
.prose h2 { margin-top: var(--space-12); }
.prose ul, .prose ol { margin: 0 0 var(--space-4); padding-left: var(--space-6); }
.prose .table-scroll { margin-bottom: var(--space-4); }
.prose .schedule-table thead th { white-space: normal; vertical-align: bottom; }
.prose li + li { margin-top: var(--space-2); }
.formula {
  padding: var(--space-3) var(--space-4); overflow-x: auto; font-weight: 600;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm);
}
.faq { max-width: 75ch; margin-top: var(--space-12); }
.faq-item {
  margin-bottom: var(--space-3); padding: var(--space-2) var(--space-4);
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md);
}
.faq-item p { margin: var(--space-2) 0; }
.related-tools { margin-top: var(--space-12); }

/* ---- Information pages, footer links ---- */
.meta-updated { color: var(--color-muted); font-size: var(--text-xs); line-height: var(--lh-xs); }
.footer-links { list-style: none; margin: 0 0 var(--space-4); padding: 0; display: flex; flex-wrap: wrap; gap: 0 var(--space-4); }
.footer-links a { display: inline-flex; align-items: center; min-height: var(--touch); }

.unit-switch.has-error .unit-options { border-color: var(--color-danger); }

/* Home loan: loan amount vs property price (works without JS), savings, LTV and comparison. */
.calc-form:has(#f-mode-amount:checked) [data-mode-block="price"],
.calc-form:has(#f-mode-price:checked) [data-mode-block="amount"] { display: none; }
.mode-block { display: grid; gap: var(--space-4); }
.savings, .ltv { margin-top: var(--space-4); }
.sub-heading { font-size: var(--text-md); line-height: var(--lh-md); margin: 0 0 var(--space-2); }
.notices { display: grid; gap: var(--space-2); }
.compare { margin-top: var(--space-6); }
.compare-table .is-chosen { font-weight: 600; box-shadow: inset 0 3px 0 var(--color-primary); }

/* Home loan tax card */
.tax { margin-top: var(--space-6); }
.tax-panel { margin-top: var(--space-4); }
.tax-notes { margin: var(--space-4) 0 0; padding-left: var(--space-6); font-size: var(--text-xs); line-height: var(--lh-xs); color: var(--color-muted); }

/* Fabric costing */
.calc-form:has(#f-type-polyester:checked) [data-field="sizing"] { display: none; }
.field-group { display: grid; gap: var(--space-4); border: 0; margin: 0; padding: 0; min-width: 0; }
.field-group-title { font-weight: 600; margin-bottom: var(--space-2); }
.fabric-headline { display: flex; flex-wrap: wrap; gap: var(--space-4) var(--space-8); }
.breakdown-table { white-space: normal; }
.breakdown-table tbody tr:nth-child(even) { background: none; }
.breakdown-table tbody tr + tr { border-top: 1px solid var(--color-border); }
.breakdown-table td { white-space: nowrap; }
.breakdown-table .cell-note { display: block; font-weight: 400; color: var(--color-muted); }
.breakdown-table .is-total th, .breakdown-table .is-total td { font-weight: 700; }
.breakdown-table .is-reference th, .breakdown-table .is-reference td { color: var(--color-muted); }
/* Compact form (fabric costing): short fields side by side, labels aligned so the inputs line up. */
.calc-form.is-compact { gap: var(--space-2); padding: var(--space-4); }
.calc-form.is-compact .field-group { gap: var(--space-2); }
.field-line { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; column-gap: var(--space-3); row-gap: var(--space-1); }
.field-line > .field { grid-row: span 3; grid-template-rows: subgrid; }
.field-line .field-label { align-self: end; font-size: var(--text-xs); line-height: var(--lh-xs); }
.field-line .field-control { min-width: 0; }
.field-line .field-input { min-width: 0; width: 100%; }
.breakdown-table th, .breakdown-table td { padding-block: 2px; }
.result.is-compact { padding: var(--space-4); }
/* Visually hidden (still read by screen readers): the headline already says "Costing per metre". */
.result.is-compact .result-heading, .result.is-compact .breakdown-table caption { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.result.is-compact .fabric-actions { margin-top: var(--space-3); gap: var(--space-2); }
.result.is-compact .fabric-actions .btn { padding-inline: var(--space-3); }
@media (min-width: 1024px) {
  .calc-form.is-compact .field-control { min-height: 40px; }
  .calc-form.is-compact .field-input { min-height: 38px; }
}
.fabric-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-4); align-items: center; }

/* Market rates */
.market-chart-card h2 { margin-top: 0; }
.market-updated { color: var(--color-muted); margin-top: calc(-1 * var(--space-2)); }
.market-periods { margin-bottom: var(--space-3); }
.market-table [data-period] { display: none; }
.market:has(#f-period-1d:checked) .market-table [data-period="1d"],
.market:has(#f-period-1w:checked) .market-table [data-period="1w"],
.market:has(#f-period-1m:checked) .market-table [data-period="1m"],
.market:has(#f-period-3m:checked) .market-table [data-period="3m"],
.market:has(#f-period-6m:checked) .market-table [data-period="6m"],
.market:has(#f-period-1y:checked) .market-table [data-period="1y"] { display: table-cell; }
@media (min-width: 768px) {
  .market-periods { display: none; }
  .market-table [data-period] { display: table-cell; }
}
.market-table { white-space: normal; }
.market-table td { white-space: nowrap; }
.market-table .cell-note { display: block; font-weight: 400; color: var(--color-muted); }
.market-table .cell-unit { color: var(--color-muted); }
.market-table tbody tr:nth-child(even) { background: none; }
.market-table tbody tr + tr { border-top: 1px solid var(--color-border); }
.market-table .market-group th { text-align: left; font-weight: 700; }
.chg.is-up { color: var(--color-success); font-weight: 600; }
.chg.is-down { color: var(--color-danger); font-weight: 600; }
.chg.is-flat { color: var(--color-muted); }
.market-chart-card { margin-top: var(--space-6); }
.market-chart-form { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.market-select { min-height: var(--input-height); border: 1px solid var(--color-input-border); border-radius: var(--radius-sm); padding-inline: var(--space-3); background: var(--color-surface); color: var(--color-ink); font: inherit; max-width: 100%; }
.market-ranges { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-block: var(--space-3); }
.market-ranges [aria-current="true"] { font-weight: 700; text-decoration: none; }
.market-chart { display: block; width: 100%; height: 200px; background: var(--color-bg); border-radius: var(--radius-sm); }
.market-line { fill: none; stroke: var(--color-primary); stroke-width: 2; vector-effect: non-scaling-stroke; }
.market-chart-scale { color: var(--color-muted); font-size: var(--text-xs); line-height: var(--lh-xs); }
.market-notice { font-weight: 600; }
.market-sources { margin-top: var(--space-8); }
.market-chart-card[aria-busy="true"] { opacity: 0.6; }

/* Market alerts */
.alerts-form { display: grid; gap: var(--space-4); max-width: 640px; }
.alerts-items, .alerts-types { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: var(--space-2); }
.alerts-group { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); align-items: center; }
.alerts-group-label { font-weight: 600; min-width: 9rem; }
.alerts-consent { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-2); align-items: center; }
.alerts-trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.alerts-box { margin-top: var(--space-8); }
.alerts-stop { margin-top: var(--space-4); }
