:root {
  color-scheme: dark;
  --bg: var(--brand-paper);
  --bg-soft: var(--brand-surface-soft);
  --panel: var(--brand-surface);
  --panel-strong: #1b3048;
  --line: var(--brand-line);
  --text: var(--brand-ink);
  --muted: var(--brand-muted);
  --blue: var(--brand-teal);
  --blue-soft: #203d60;
  --green: var(--brand-green);
  --red: #ff9d9d;
  --amber: #f1cf87;
  --shadow: 0 8px 24px rgb(0 0 0 / 13%);
  --radius: 10px;
}

:root[data-theme="medium"] {
  color-scheme: dark;
  --bg: var(--brand-paper);
  --bg-soft: var(--brand-surface-soft);
  --panel: var(--brand-surface);
  --panel-strong: #344a64;
  --line: var(--brand-line);
  --text: var(--brand-ink);
  --muted: var(--brand-muted);
  --blue: var(--brand-teal);
  --blue-soft: #2b496e;
  --green: var(--brand-green);
  --red: #ff9d9d;
  --amber: #f1cf87;
  --shadow: 0 8px 24px rgb(0 0 0 / 10%);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: var(--brand-paper);
  --bg-soft: var(--brand-surface-soft);
  --panel: var(--brand-surface);
  --panel-strong: #f0f5fb;
  --line: var(--brand-line);
  --text: var(--brand-ink);
  --muted: var(--brand-muted);
  --blue: var(--brand-teal);
  --blue-soft: #e4effc;
  --green: var(--brand-green);
  --red: #ae3039;
  --amber: #8b5900;
  --shadow: 0 8px 24px rgb(19 57 42 / 8%);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--brand-font);
  line-height: 1.5;
}
button, input, select { font: inherit; }
button, select { cursor: pointer; }
a { color: var(--blue); }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--blue) 70%, white);
  outline-offset: 3px;
}
.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 100; padding: .7rem 1rem; background: var(--text); color: var(--bg); }
.skip-link:focus { top: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: .75rem clamp(1rem, 3vw, 2.5rem);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.brand { display: inline-flex; align-items: center; gap: .7rem; color: var(--text); font-size: 1.25rem; font-weight: 800; text-decoration: none; }
.brand .jurbr-brand-logo { height: 34px; }
.product-name { padding-left: .7rem; border-left: 1px solid var(--line); color: var(--muted); font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: .75rem; }
.module-nav { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem 1.25rem; }
.module-nav a { min-height: 44px; display: inline-flex; align-items: center; color: var(--text); font-size: .9rem; text-decoration: none; }
.module-nav a:hover { color: var(--blue); text-decoration: underline; }
.icon-button { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); font-size: 1.2rem; }
.top-actions .theme-toggle { width: 44px; height: 44px; min-width: 44px; min-height: 44px; background: var(--panel); border-color: var(--line); color: var(--text); }

.page-shell { width: min(1600px, 100%); margin: 0 auto; padding: 0 clamp(1rem, 3vw, 2.5rem) 3rem; }
.hero { display: flex; justify-content: space-between; gap: 2rem; align-items: end; padding: clamp(2.4rem, 6vw, 5.5rem) 0 2rem; }
.eyebrow { margin: 0 0 .55rem; color: var(--green); font-size: .76rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1 { max-width: 850px; margin: 0; font-size: clamp(2.1rem, 4.6vw, 4.5rem); line-height: 1.03; letter-spacing: -.045em; }
.hero-copy { max-width: 740px; margin: 1.1rem 0 0; color: var(--muted); font-size: clamp(1rem, 1.3vw, 1.16rem); }
.hero-status { display: flex; align-items: center; gap: .55rem; flex: 0 0 auto; color: var(--muted); font-size: .86rem; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgb(86 227 159 / 12%); }

.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.metrics article { display: flex; align-items: baseline; gap: .6rem; padding: 1rem 1.15rem; border: 1px solid var(--line); border-radius: 14px; background: color-mix(in srgb, var(--panel) 86%, transparent); }
.metrics strong { font-size: 1.6rem; }
.metrics span { color: var(--muted); font-size: .9rem; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr); position: relative; }
.workspace.has-detail { grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 1rem; }
.catalog-pane, .detail-panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-soft); box-shadow: var(--shadow); }
.catalog-pane { min-width: 0; padding: 1rem; }
.toolbar { display: grid; gap: .75rem; }
.search-field { display: flex; align-items: center; gap: .7rem; padding: 0 .9rem; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--muted); }
.search-field input { width: 100%; min-height: 46px; border: 0; outline: 0; background: transparent; color: var(--text); }
.filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; gap: .6rem; }
select { width: 100%; min-height: 44px; padding: 0 .75rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); }
.favorite-filter { min-height: 44px; display: flex; align-items: center; gap: .4rem; padding: 0 .7rem; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); white-space: nowrap; }
.catalog-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin: 1.35rem 0 .85rem; }
.catalog-heading h2 { margin: 0; }
.catalog-heading p { margin: .15rem 0 0; color: var(--muted); font-size: .86rem; }
.legend { display: flex; align-items: center; gap: .35rem; max-width: 35ch; color: var(--muted); font-size: .875rem; }
.impact-dot { width: 7px; height: 7px; margin-left: .35rem; border-radius: 50%; background: var(--muted); }
.impact-dot.increase { background: var(--red); }
.impact-dot.mixed { background: var(--amber); }
.impact-dot.reduction { background: var(--green); }
.notice { padding: .85rem 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--muted); }

.case-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .7rem; }
.case-card { position: relative; display: flex; flex-direction: column; min-height: 196px; padding: 1rem; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); color: var(--text); text-align: left; transition: border-color .18s ease; }
.case-card:hover { border-color: var(--blue); }
.case-card[aria-current="true"] { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.card-meta { display: flex; align-items: center; gap: .42rem; padding-right: 2.75rem; color: var(--muted); font-size: .875rem; }
.case-number { color: var(--blue); font-weight: 900; }
.impact-label { margin-left: auto; font-weight: 700; }
.impact-label.increase { color: var(--red); }
.impact-label.mixed { color: var(--amber); }
.impact-label.reduction { color: var(--green); }
.impact-label.neutral { color: var(--muted); }
.case-card h3 { margin: .75rem 0 .4rem; font-size: 1.05rem; line-height: 1.25; }
.case-card p { margin: 0; color: var(--muted); font-size: .875rem; }
.card-footer { display: flex; align-items: center; justify-content: space-between; gap: .4rem; margin-top: auto; padding-top: .8rem; color: var(--muted); font-size: .875rem; }
.card-footer > span:first-child { min-width: 0; }
.card-footer .impact-label { flex: 0 0 auto; }
.status-pill { padding: .2rem .45rem; border-radius: 999px; background: var(--blue-soft); color: var(--blue); font-weight: 700; }
.favorite-button { position: absolute; top: .4rem; right: .4rem; width: 44px; height: 44px; border: 0; background: transparent; color: var(--muted); font-size: 1.3rem; }
.favorite-button.active { color: var(--amber); }
.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; padding: 1.1rem 0 .2rem; }
.pagination button, .detail-navigation button, .tab-button { min-height: 44px; padding: .5rem .72rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
.pagination span { color: var(--muted); font-size: .875rem; }

.detail-panel { position: sticky; top: 84px; display: none; max-height: calc(100vh - 100px); overflow: hidden; }
.workspace.has-detail .detail-panel { display: flex; flex-direction: column; }
.detail-toolbar { display: flex; justify-content: space-between; gap: 1rem; padding: .8rem; border-bottom: 1px solid var(--line); }
.detail-navigation { display: flex; gap: .45rem; }
.detail-content { overflow: auto; padding: clamp(1rem, 2.5vw, 2rem); }
.detail-kicker { display: flex; align-items: center; gap: .55rem; color: var(--muted); font-size: .875rem; }
.detail-content h2 { margin: .65rem 0 .35rem; font-size: clamp(1.65rem, 2.5vw, 2.5rem); line-height: 1.1; }
.detail-summary { margin: 0 0 1.25rem; color: var(--muted); }
.tabs { display: flex; gap: .35rem; overflow-x: auto; padding-bottom: .35rem; border-bottom: 1px solid var(--line); }
.tab-button[aria-selected="true"] { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
.tab-panel { padding-top: 1rem; }
.section-card { margin-bottom: .85rem; padding: 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.section-card h3 { margin: 0 0 .65rem; font-size: 1rem; }
.section-card p { margin: .35rem 0; }
.study-kind { color: var(--muted); font-size: .875rem; }
.detail-navigation button:disabled { opacity: .4; cursor: not-allowed; }
.table-scroll { overflow-x: auto; }
.warning-list { margin: 0; padding-left: 1.2rem; color: var(--muted); }
.warning-list li + li { margin-top: .45rem; }
.legal-list { display: grid; gap: .5rem; }
.legal-list a { display: flex; justify-content: space-between; gap: 1rem; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: 9px; text-decoration: none; }
.legal-list small { color: var(--muted); }

.simulator-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.simulator-form label { display: grid; gap: .3rem; color: var(--muted); font-size: .875rem; }
.simulator-form input[type="number"] { min-height: 44px; padding: 0 .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); }
.checkbox-row { grid-column: 1 / -1; display: flex !important; grid-template-columns: auto 1fr; align-items: start; gap: .55rem !important; padding: .75rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-soft); }
.primary-button { grid-column: 1 / -1; min-height: 44px; border: 0; border-radius: 8px; background: var(--blue); color: var(--bg); font-weight: 850; }
:root[data-theme="light"] .primary-button { color: #fff; }
.simulation-status { grid-column: 1 / -1; color: var(--muted); }
.simulation-impact { margin: 1rem 0 .35rem; padding: .7rem .9rem; border: 1px solid currentColor; border-radius: 10px; font-size: .9rem; }
.simulation-impact.increase { color: var(--red); }
.simulation-impact.reduction { color: var(--green); }
.simulation-impact.neutral { color: var(--muted); }
.result-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .55rem; margin: 1rem 0; }
.result-card { padding: .8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-soft); }
.result-card span { display: block; color: var(--muted); font-size: .875rem; }
.result-card strong { display: block; margin-top: .2rem; font-size: 1.05rem; }
.memory-table { width: 100%; min-width: 460px; border-collapse: collapse; font-size: .875rem; }
.memory-table th, .memory-table td { padding: .65rem .45rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.memory-table th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.memory-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.disclaimer { padding: .75rem; border-left: 3px solid var(--amber); background: color-mix(in srgb, var(--amber) 8%, transparent); color: var(--muted); font-size: .875rem; }
.footer { display: flex; justify-content: space-between; gap: 1rem; padding: 1.5rem clamp(1rem, 3vw, 2.5rem); border-top: 1px solid var(--line); color: var(--muted); font-size: .875rem; }
.footer p { margin: 0; }

@media (max-width: 1180px) {
  .case-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace.has-detail { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); }
}

@media (max-width: 900px) {
  .hero { padding-top: 2.8rem; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: 1fr 1fr; }
  .catalog-heading { align-items: start; flex-direction: column; }
  .case-grid { grid-template-columns: 1fr; }
  .workspace.has-detail { display: block; }
  .workspace.has-detail .detail-panel { position: fixed; inset: 0; z-index: 60; max-height: none; border: 0; border-radius: 0; }
  .detail-toolbar { padding-top: max(.8rem, env(safe-area-inset-top)); }
  .detail-content { padding-bottom: max(2rem, env(safe-area-inset-bottom)); }
  .simulator-form, .result-cards { grid-template-columns: 1fr; }
  .footer { flex-direction: column; }
}

@media (max-width: 500px) {
  .topbar { align-items: flex-start; flex-wrap: wrap; gap: .5rem; }
  .top-actions { width: 100%; justify-content: space-between; }
  .product-name { font-size: .9rem; }
  .page-shell { padding-inline: .7rem; }
  .metrics article { display: grid; gap: 0; }
  .catalog-pane { padding: .7rem; }
  .filters { grid-template-columns: 1fr; }
  .detail-navigation button { font-size: .875rem; }
}

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