/* ==========================================================================
   家族資產管理系統 — shared stylesheet
   Design system: Stripe (awesome-design-md/design-md/stripe/DESIGN.md)

   Two deliberate adaptations from the source system:
   1. sohne-var is proprietary, so the stack falls back to the platform UI sans
      plus a Traditional Chinese face.
   2. Stripe's signature weight 300 is unreadable for CJK glyphs at UI sizes and
      works against this site's elderly-friendly brief, so body text runs at 400
      and only large Latin-heavy display text goes lighter. Everything else --
      palette, blue-tinted layered shadows, 4-8px radii, tabular numerals for
      financial data, precision spacing -- follows the system as written.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */

:root {
  color-scheme: light;

  /* Surfaces */
  --surface: #ffffff;
  --surface-sunken: #f6f9fc;
  --surface-muted: #f9fbfd;
  --surface-inset: rgba(83, 58, 253, 0.04);

  /* Ink — Stripe uses deep navy, never black */
  --ink: #061b31;
  --ink-label: #273951;
  --ink-body: #64748d;
  --ink-muted: #8a99b3;

  /* Brand */
  --primary: #533afd;
  --primary-hover: #4434d4;
  --primary-soft: #b9b9f9;
  --primary-wash: rgba(83, 58, 253, 0.06);
  --brand-dark: #1c1e54;

  /* Status */
  --success: #108c3d;
  --success-bg: rgba(21, 190, 83, 0.16);
  --success-border: rgba(21, 190, 83, 0.4);
  --warning: #9b6829;
  --warning-bg: rgba(250, 178, 25, 0.16);
  --warning-border: rgba(250, 178, 25, 0.45);
  --danger: #c81e52;
  --danger-bg: rgba(234, 34, 97, 0.1);

  /* Lines */
  --border: #e5edf5;
  --border-strong: #d3e0ec;

  /* Elevation — blue-tinted, layered (the system's signature) */
  --shadow-1: rgba(23, 23, 23, 0.06) 0 3px 6px;
  --shadow-2: rgba(23, 23, 23, 0.08) 0 15px 35px;
  --shadow-3: rgba(50, 50, 93, 0.25) 0 30px 45px -30px,
              rgba(0, 0, 0, 0.1) 0 18px 36px -18px;
  --shadow-4: rgba(3, 3, 39, 0.25) 0 14px 21px -14px,
              rgba(0, 0, 0, 0.1) 0 8px 17px -8px;

  /* Radii — the system stays conservative, 4-8px */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;

  /* Categorical series palette (validated — see note below) */
  --series-1: #533afd;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-other: #8a99b3;

  --chart-surface: #ffffff;
  --gridline: #e5edf5;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
    "Microsoft JhengHei", "Noto Sans TC", "Hiragino Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;

  --max-width: 1120px;
}

/*
  Series palette provenance — validated with the dataviz skill's checker, not
  eyeballed. Light  (surface #ffffff): all checks pass; worst adjacent CVD ΔE 9.1,
  worst adjacent normal-vision ΔE 19.6. Three slots sit under 3:1 contrast, so the
  relief rule applies and the allocation chart always ships visible direct labels
  plus a table view. Dark (surface #0d253d): all checks pass including contrast.
*/

.theme-dark {
  color-scheme: dark;

  --surface: #0d253d;
  --surface-sunken: #071a2b;
  --surface-muted: #102c47;
  --surface-inset: rgba(139, 125, 255, 0.08);

  --ink: #eef4fb;
  --ink-label: #c3d3e5;
  --ink-body: #9fb3c8;
  --ink-muted: #7d92aa;

  --primary: #8b7dff;
  --primary-hover: #a297ff;
  --primary-soft: #4a3aa7;
  --primary-wash: rgba(139, 125, 255, 0.12);
  --brand-dark: #1c1e54;

  --success: #4ad07f;
  --success-bg: rgba(21, 190, 83, 0.18);
  --success-border: rgba(21, 190, 83, 0.45);
  --warning: #f0b955;
  --warning-bg: rgba(250, 178, 25, 0.18);
  --warning-border: rgba(250, 178, 25, 0.4);
  --danger: #ff7ba3;
  --danger-bg: rgba(234, 34, 97, 0.18);

  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.2);

  --shadow-1: rgba(0, 0, 0, 0.3) 0 3px 6px;
  --shadow-2: rgba(0, 0, 0, 0.4) 0 15px 35px;
  --shadow-3: rgba(0, 0, 0, 0.5) 0 30px 45px -30px,
              rgba(0, 0, 0, 0.35) 0 18px 36px -18px;
  --shadow-4: rgba(0, 0, 0, 0.6) 0 14px 21px -14px,
              rgba(0, 0, 0, 0.4) 0 8px 17px -8px;

  --series-1: #7c6cff;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-other: #7d92aa;

  --chart-surface: #0d253d;
  --gridline: rgba(255, 255, 255, 0.12);
}

/* --------------------------------------------------------------------------
   2. Reset & base
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

/* Reader-controlled text size — the original brief was an elderly-friendly UI,
   so this is a first-class control rather than a browser-zoom afterthought. */
html[data-textsize="large"] { font-size: 19px; }
html[data-textsize="xlarge"] { font-size: 21px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.55;
  color: var(--ink-body);
  background: var(--surface-sunken);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  color: var(--ink);
  line-height: 1.15;
  letter-spacing: -0.01em;
  font-weight: 500;
}

a {
  color: var(--primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover { color: var(--primary-hover); }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

img { max-width: 100%; display: block; }

button, input, select {
  font: inherit;
  color: inherit;
}

/* Financial data always gets tabular figures; large standalone numbers keep
   proportional figures so they don't look loose (dataviz: figures rule). */
.tnum { font-variant-numeric: tabular-nums; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: 100;
  background: var(--surface);
  color: var(--primary);
  padding: 10px 16px;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  transition: top 0.2s;
}

.skip-link:focus { top: 8px; }

/* --------------------------------------------------------------------------
   3. Layout
   -------------------------------------------------------------------------- */

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

.page-main { padding-bottom: 64px; }

.stack-lg > * + * { margin-top: 24px; }

/* --------------------------------------------------------------------------
   4. Top bar
   -------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  margin-right: auto;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--primary) 0%, var(--brand-dark) 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.9rem;
  flex: none;
}

.brand-name {
  font-size: 1.02rem;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.brand-sub {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-muted);
  font-weight: 400;
  letter-spacing: 0.02em;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   5. Buttons & controls
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: var(--primary);
  color: #fff;
  font-size: 0.94rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:hover { background: var(--primary-hover); color: #fff; }

.btn-ghost {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary-soft);
}

.btn-ghost:hover {
  background: var(--primary-wash);
  color: var(--primary-hover);
}

.btn-quiet {
  background: transparent;
  color: var(--ink-label);
  border-color: var(--border);
}

.btn-quiet:hover {
  background: var(--surface-muted);
  color: var(--ink);
}

.icon-btn {
  width: 38px;
  height: 38px;
  flex: none;
  padding: 0;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-label);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.15s, border-color 0.15s;
}

.icon-btn:hover {
  background: var(--surface-muted);
  border-color: var(--border-strong);
}

/* Segmented control — text size, units, scenario */
.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--ink-body);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.segmented button + button { border-left: 1px solid var(--border); }

.segmented button:hover { background: var(--surface-muted); color: var(--ink); }

.segmented button[aria-pressed="true"],
.segmented button[aria-checked="true"] {
  background: var(--primary);
  color: #fff;
}

/* --------------------------------------------------------------------------
   6. Cards & panels
   -------------------------------------------------------------------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: 24px;
}

.panel-title {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 4px;
}

.panel-note {
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* --------------------------------------------------------------------------
   7. Portfolio hero + stat tiles
   -------------------------------------------------------------------------- */

.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  padding: 28px;
  margin-top: 24px;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
}

.hero-label {
  font-size: 0.86rem;
  color: var(--ink-body);
  letter-spacing: 0.01em;
}

/* Hero figure — exactly one per view (dataviz). Proportional figures. */
.hero-figure {
  font-size: clamp(2.1rem, 6vw, 3.1rem);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-top: 6px;
}

.hero-figure .unit {
  font-size: 0.42em;
  font-weight: 500;
  color: var(--ink-body);
  letter-spacing: 0;
  margin-left: 6px;
}

.hero-sub {
  margin-top: 8px;
  font-size: 0.9rem;
  color: var(--ink-body);
}

.hero-scenario {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.hero-scenario-label {
  font-size: 0.78rem;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
}

/* KPI row */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  margin-top: 24px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}

.stat-tile {
  background: var(--surface);
  padding: 16px 18px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--ink-body);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.stat-hint {
  font-size: 0.76rem;
  color: var(--ink-muted);
  margin-top: 2px;
}

/* --------------------------------------------------------------------------
   8. Allocation chart (horizontal stacked bar, part-to-whole)
   -------------------------------------------------------------------------- */

.alloc { margin-top: 28px; }

.alloc-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.alloc-title {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink);
}

/* The 2px gap is in the surface color and is the only separator between
   segments — never a stroke around a mark. */
.alloc-bar {
  display: flex;
  gap: 2px;
  width: 100%;
  height: 24px;
  background: var(--chart-surface);
}

.alloc-seg {
  height: 100%;
  min-width: 3px;
  flex: 0 1 auto;
  border-radius: 2px;
}

/* 4px rounded data-ends on the outer edges of the stack. */
.alloc-seg:first-child { border-radius: var(--r-sm) 2px 2px var(--r-sm); }
.alloc-seg:last-child { border-radius: 2px var(--r-sm) var(--r-sm) 2px; }

/* Legend doubles as the table view — the relief the contrast WARN requires.
   Text wears ink tokens; the swatch beside it carries identity. */
.alloc-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 4px 20px;
  margin-top: 14px;
}

.alloc-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.86rem;
  padding: 3px 0;
}

.alloc-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex: none;
  transform: translateY(1px);
}

.alloc-name { color: var(--ink-label); }

.alloc-value {
  margin-left: auto;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.alloc-share {
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  min-width: 3.4em;
  text-align: right;
}

/* --------------------------------------------------------------------------
   9. Toolbar (search / filter / sort)
   -------------------------------------------------------------------------- */

.toolbar {
  margin-top: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: 18px;
}

.toolbar-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.search-field {
  position: relative;
  flex: 1 1 260px;
}

.search-field input {
  width: 100%;
  padding: 11px 38px 11px 38px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.98rem;
}

.search-field input::placeholder { color: var(--ink-muted); }

.search-field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-wash);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-muted);
  pointer-events: none;
  font-size: 0.95rem;
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  line-height: 1;
}

.search-clear:hover { color: var(--ink); background: var(--surface-muted); }

.select-field {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.92rem;
  cursor: pointer;
}

.select-field:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-wash);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chip {
  padding: 7px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-label);
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.chip:hover { border-color: var(--primary-soft); color: var(--primary); }

.chip[aria-pressed="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.chip-count {
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
  margin-left: 4px;
}

.result-line {
  margin-top: 20px;
  font-size: 0.88rem;
  color: var(--ink-body);
}

/* --------------------------------------------------------------------------
   10. Property grid & cards
   -------------------------------------------------------------------------- */

.property-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
  margin-top: 14px;
  list-style: none;
}

.card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-3);
  border-color: var(--primary-soft);
  color: inherit;
}

.card-media {
  aspect-ratio: 16 / 9;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-media-empty {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--ink-muted);
  font-size: 1.6rem;
  background:
    linear-gradient(135deg, var(--primary-wash) 0%, transparent 60%),
    var(--surface-muted);
}

.card-body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  justify-content: space-between;
}

.card-title {
  font-size: 1.12rem;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.015em;
}

.card-address {
  font-size: 0.84rem;
  color: var(--ink-body);
  margin-top: 5px;
  display: flex;
  gap: 5px;
  align-items: flex-start;
}

.card-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.metric-label {
  font-size: 0.74rem;
  color: var(--ink-muted);
}

.metric-value {
  font-size: 0.95rem;
  color: var(--ink);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.card-valuation {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--surface-inset);
  border: 1px solid var(--border);
}

.card-valuation .metric-label { margin-bottom: 2px; }

.card-valuation-figure {
  font-size: 1.12rem;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.card-valuation-share {
  font-size: 0.76rem;
  color: var(--ink-muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.card-foot { margin-top: auto; }

/* --------------------------------------------------------------------------
   11. Badges
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-sm);
  font-size: 0.76rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--ink-label);
  white-space: nowrap;
  flex: none;
}

.badge-city {
  background: var(--primary-wash);
  border-color: var(--primary-soft);
  color: var(--primary);
}

.badge-warning {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning);
}

.badge-success {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success);
}

.badge-muted {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--ink-muted);
}

/* --------------------------------------------------------------------------
   12. Notices
   -------------------------------------------------------------------------- */

.notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-muted);
  font-size: 0.88rem;
  color: var(--ink-body);
}

.notice-icon { flex: none; font-size: 1rem; line-height: 1.4; }

.notice strong { color: var(--ink); font-weight: 500; }

.notice-warning {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning);
}

.notice-warning strong { color: var(--warning); }

.notice-danger {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}

/* --------------------------------------------------------------------------
   13. States
   -------------------------------------------------------------------------- */

.state {
  text-align: center;
  padding: 56px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-top: 24px;
}

.state-icon { font-size: 2rem; margin-bottom: 12px; }

.state h2 {
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.state p { color: var(--ink-body); font-size: 0.94rem; }

.state .btn { margin-top: 18px; }

/* Skeleton loading — keeps layout stable while JSON is in flight */
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
  margin-top: 14px;
}

.skeleton-card {
  height: 320px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: linear-gradient(
    100deg,
    var(--surface) 30%,
    var(--surface-muted) 50%,
    var(--surface) 70%
  );
  background-size: 300% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  from { background-position: 150% 0; }
  to { background-position: -50% 0; }
}

/* --------------------------------------------------------------------------
   14. Detail page
   -------------------------------------------------------------------------- */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 20px 0 4px;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.breadcrumb a { text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

.detail-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: 26px;
  margin-top: 12px;
}

.detail-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.detail-title {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 500;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.detail-address {
  margin-top: 10px;
  font-size: 0.94rem;
  color: var(--ink-body);
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.detail-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.detail-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  margin-top: 22px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}

/* Data table — dense data inside generous chrome (Stripe layout principle) */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  white-space: nowrap;
}

table.data th {
  text-align: left;
  font-weight: 500;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  background: var(--surface-muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}

table.data td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--ink-label);
  vertical-align: top;
}

table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--surface-muted); }

table.data td.num,
table.data th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

table.data td.strong { color: var(--ink); font-weight: 500; }
table.data td.wrap { white-space: normal; min-width: 220px; }

.table-foot {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.remark {
  color: var(--danger);
  font-weight: 500;
}

/* Valuation scenario emphasis */
tr.scenario-base td { background: var(--primary-wash); }
tr.scenario-base:hover td { background: var(--primary-wash); }

/* Lists inside the analysis panel */
.tick-list { list-style: none; }

.tick-list li {
  position: relative;
  padding: 5px 0 5px 26px;
  color: var(--ink-label);
  font-size: 0.92rem;
}

.tick-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--success);
  font-weight: 600;
}

.policy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.policy-item {
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  border-left: 3px solid var(--success);
  background: var(--surface-muted);
}

.policy-item h4 {
  font-size: 0.92rem;
  color: var(--ink);
  margin-bottom: 5px;
  font-weight: 500;
}

.policy-item p { font-size: 0.85rem; color: var(--ink-body); }

.subsection { margin-top: 26px; }

.subsection > h3 {
  font-size: 0.98rem;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.lead {
  font-size: 1rem;
  color: var(--ink-label);
  line-height: 1.65;
  padding: 16px 18px;
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--r-md);
}

/* --------------------------------------------------------------------------
   15. Gallery & lightbox
   -------------------------------------------------------------------------- */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  list-style: none;
  align-items: start;
}

.gallery button {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface-muted);
  cursor: zoom-in;
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}

.gallery button:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-3);
  border-color: var(--primary-soft);
}

.gallery img {
  width: 100%;
  /* height:auto is required — the width/height attributes on the <img> are
     presentational hints that would otherwise beat aspect-ratio. */
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.gallery figcaption {
  padding: 9px 12px;
  font-size: 0.84rem;
  color: var(--ink-body);
  border-top: 1px solid var(--border);
  background: var(--surface);
  text-align: left;
}

.lightbox {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: 100vw;
  max-height: 100vh;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.lightbox::backdrop {
  background: rgba(6, 27, 49, 0.92);
  backdrop-filter: blur(4px);
}

.lightbox-inner {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  padding: 16px;
}

.lightbox-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #fff;
}

.lightbox-caption { font-size: 0.94rem; }

.lightbox-count {
  font-size: 0.82rem;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

.lightbox-stage {
  display: grid;
  place-items: center;
  min-height: 0;
  position: relative;
}

.lightbox-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--r-md);
}

.lightbox-nav {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
}

.lightbox button {
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-radius: var(--r-md);
  padding: 9px 16px;
  cursor: pointer;
  font-size: 0.9rem;
}

.lightbox button:hover { background: rgba(255, 255, 255, 0.2); }
.lightbox button:disabled { opacity: 0.35; cursor: default; }

/* --------------------------------------------------------------------------
   16. Prev/next & footer
   -------------------------------------------------------------------------- */

.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.pager a {
  flex: 1 1 220px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.pager a:hover { border-color: var(--primary-soft); box-shadow: var(--shadow-1); }
.pager a:last-child { text-align: right; }
.pager .pager-dir { font-size: 0.76rem; color: var(--ink-muted); }
.pager .pager-name { font-size: 0.98rem; color: var(--ink); font-weight: 500; }

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 56px;
  padding: 24px 0 40px;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.site-footer .container {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* Standalone fallback pages (404, offline) */
.fallback-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  text-align: center;
  padding: 24px;
}

.fallback-page h1 {
  font-size: 3rem;
  font-weight: 400;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.fallback-page p { margin-bottom: 12px; }

/* --------------------------------------------------------------------------
   17. Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 720px) {
  .container { padding: 0 14px; }
  .topbar-inner { padding: 10px 14px; gap: 10px; }
  .brand-sub { display: none; }
  .hero, .panel, .detail-header { padding: 20px 16px; }
  .toolbar { padding: 14px; }
  .property-grid, .skeleton-grid { grid-template-columns: 1fr; }
  .hero-top { flex-direction: column; }
  .hero-scenario { align-items: flex-start; width: 100%; }
  .hero-scenario .segmented { width: 100%; }
  .hero-scenario .segmented button { flex: 1; }

  /* Give the controls their own row rather than squeezing them beside the
     brand — three segmented groups don't fit on a phone header. */
  .topbar-controls { width: 100%; justify-content: space-between; }
  .brand { margin-right: 0; }
  .alloc-legend { grid-template-columns: 1fr; }
  .site-footer .container { flex-direction: column; }
}

/* --------------------------------------------------------------------------
   18. Print
   -------------------------------------------------------------------------- */

@media print {
  :root {
    --surface: #fff;
    --surface-sunken: #fff;
    --surface-muted: #fff;
    --surface-inset: #fff;
    --ink: #000;
    --ink-label: #222;
    --ink-body: #444;
    --border: #bbb;
    --shadow-1: none;
    --shadow-2: none;
    --shadow-3: none;
  }

  .topbar-controls,
  .toolbar,
  .skip-link,
  .pager,
  .detail-actions,
  .gallery button { display: none !important; }

  .topbar { position: static; border-bottom: 1px solid #bbb; }
  .panel, .hero, .card, .detail-header { box-shadow: none; break-inside: avoid; }
  table.data { white-space: normal; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.75em; }
}
