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

body {
  background: var(--bg-field-1), var(--bg-field-2), var(--bg-field-3), var(--bg-field-4), var(--bg);
  background-attachment: fixed;
  font-family: "Inter", -apple-system, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  line-height: 1.5;
}

header.ad-top {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--line);
}

header.ad-top .ad-wordmark {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.5px;
}

header.ad-top nav {
  display: flex;
  gap: 1rem;
  flex: 1;
}

header.ad-top nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  transition: background 0.2s;
}

header.ad-top nav a:hover {
  background: var(--surface2);
}

header.ad-top nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

header.ad-top form {
  display: flex;
  gap: 0.5rem;
}

header.ad-top select,
header.ad-top button {
  padding: 0.5rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface2);
  color: var(--ink);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
}

header.ad-top button:hover,
header.ad-top select:hover {
  background: var(--surface);
}

header.ad-top .ad-build {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

header.ad-top .ad-freshness {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  white-space: nowrap;
}

header.ad-top .ad-freshness--ok {
  background: var(--good-soft);
  color: var(--good);
}

header.ad-top .ad-freshness--warn {
  background: var(--bad-soft);
  color: var(--bad);
}

header.ad-top .ad-freshness--none {
  background: var(--neutral);
  color: var(--bg);
}

header.ad-top .ad-freshness a {
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
}

main {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1rem;
}

footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 0.875rem;
  text-align: center;
}

.ad-card {
  border-radius: var(--radius);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  background: var(--surface);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.ad-card--quiet {
  background: var(--surface2);
}

.ad-chip {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  margin-right: 0.5rem;
}

.ad-chip--buy {
  background: var(--good-soft);
  color: var(--good);
}

.ad-chip--sell {
  background: var(--bad-soft);
  color: var(--bad);
}

.ad-chip--hold {
  background: var(--neutral);
  color: var(--bg);
}

.ad-chip--watch {
  background: var(--accent-soft);
  color: var(--accent);
}

.ad-chip--avoid {
  background: var(--bad-soft);
  color: var(--bad);
}

.ad-btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 0.5rem;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 500;
  transition: opacity 0.2s;
  font-family: inherit;
}

.ad-btn:hover {
  opacity: 0.9;
}

.ad-btn--secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid color-mix(in oklab, var(--ink) 22%, transparent);
}

/* Period strip (Aktie, Depot): a segmented pill in the same idiom as the
   navigation, so the choice reads as navigation rather than as a form. */
.ad-ranges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.25rem;
  margin-bottom: 1rem;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
}

.ad-ranges button {
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
  background: transparent;
  border: none;
  border-radius: 0.5rem;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.ad-ranges button:hover:not(:disabled) {
  background: var(--surface);
}

.ad-ranges button[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.ad-ranges button:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

/* Native form controls fall back to browser defaults without this. The edge
   derives from --ink, not --line: on a light card --line is too faint to show
   where a field is, and --ink flips with the theme so dark mode holds too. */
main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
main select,
main textarea {
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid color-mix(in oklab, var(--ink) 22%, transparent);
  border-radius: 0.5rem;
  padding: 0.55rem 0.8rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

main input:focus,
main select:focus,
main textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

main input::placeholder,
main textarea::placeholder {
  color: var(--muted);
}

main label {
  font-size: 0.875rem;
  color: var(--muted);
}

.ad-kpi-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.ad-kpi {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1 1 10rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  text-align: center;
}

.ad-kpi__v {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
}

.ad-kpi__k {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.ad-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}

.ad-table th {
  background: var(--surface2);
  padding: 0.75rem;
  text-align: left;
  font-weight: 600;
  color: var(--ink2);
  border-bottom: 1px solid var(--line);
}

.ad-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--rule);
}

.ad-table tr:hover {
  background: var(--surface2);
}

.ad-levels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
}

.ad-levels > div {
  text-align: center;
}

.ad-levels span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.ad-levels b {
  display: block;
  font-size: 1.25rem;
  color: var(--accent);
}

.ad-reasons {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ad-reasons li {
  padding: 0.5rem 0;
  padding-left: 1.5rem;
  position: relative;
}

.ad-reasons li:before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--accent);
}

.ad-empty {
  text-align: center;
  padding: 3rem 1rem;
}

.ad-empty h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.ad-empty p {
  margin-bottom: 1.5rem;
  color: var(--muted);
}

.ad-empty code {
  display: block;
  background: var(--surface);
  padding: 1rem;
  border-radius: 0.5rem;
  font-family: "Courier New", monospace;
  font-size: 0.875rem;
  overflow-x: auto;
}

.ad-section {
  margin: 2rem 0;
  padding: 1.5rem;
  background: var(--surface);
  border-radius: var(--radius);
}

.ad-section h2 {
  margin-bottom: 1rem;
  font-size: 1.25rem;
}

.ad-section--error {
  background: var(--bad-soft);
  color: var(--bad);
}

.ad-chart {
  margin: 2rem 0;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  min-height: 300px;
}

.ad-chart__table {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--surface2);
  border-radius: 0.5rem;
  cursor: pointer;
}

.ad-chart__table summary {
  font-weight: 500;
  color: var(--accent);
}

.ad-error-page {
  padding: 2rem;
  text-align: center;
}

.ad-error-page h1 {
  margin-bottom: 1rem;
}

.ad-error-page p {
  margin-bottom: 1rem;
  color: var(--muted);
}

.ad-error-page pre {
  background: var(--surface);
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  text-align: left;
}

@media (max-width: 768px) {
  header.ad-top {
    flex-wrap: wrap;
  }

  header.ad-top nav {
    order: 3;
    flex-basis: 100%;
  }

  .ad-levels {
    grid-template-columns: 1fr;
  }

  footer {
    flex-direction: column;
    gap: 1rem;
  }
}

/* --- depot styles --- */

.ad-spark { width: 96px; height: 24px; display: block; }
.ad-spark polyline { fill: none; stroke: var(--s1); stroke-width: 1.5; }
.ad-spark--none { display: inline; }

.ad-prow[data-href] { cursor: pointer; }
.ad-prow:focus-within { outline: 2px solid var(--accent); outline-offset: -2px; }
.ad-prow__name { color: var(--muted); font-size: 0.875rem; }

/* AC 4, "Gewinn nach rechts, Verlust nach links": zero is the middle of the
   track, not its left edge. Each fill hangs off that middle -- a gain to the
   right, a loss to the left -- so the side already carries the sign and the
   colour only confirms it. `--ad-contrib-width` is the inline share of the
   widest |amount| (0..100 %); half the track is a full-width bar, hence /2. */
.ad-contrib__bar { position: relative; height: 10px; background: var(--surface2); border-radius: 5px; }
.ad-contrib__bar::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: var(--muted); }
.ad-contrib__fill { position: absolute; top: 0; height: 100%; width: calc(var(--ad-contrib-width, 0%) / 2); left: 50%; border-radius: 0 5px 5px 0; background: var(--good); }
.ad-contrib__fill--neg { left: auto; right: 50%; border-radius: 5px 0 0 5px; background: var(--bad); }

.ad-alloc { display: flex; gap: 2px; height: 16px; border-radius: 5px; overflow: hidden; }
.ad-alloc__slice--cash { background: var(--neutral); }
.ad-alloc__slice--rest { background: var(--muted); }
.ad-alloc__slice--1 { background: var(--s1); }
.ad-alloc__slice--2 { background: color-mix(in oklab, var(--s1) 85%, var(--surface2)); }
.ad-alloc__slice--3 { background: color-mix(in oklab, var(--s1) 70%, var(--surface2)); }
.ad-alloc__slice--4 { background: color-mix(in oklab, var(--s1) 55%, var(--surface2)); }
.ad-alloc__slice--5 { background: color-mix(in oklab, var(--s1) 40%, var(--surface2)); }
.ad-alloc__slice--6 { background: color-mix(in oklab, var(--s1) 30%, var(--surface2)); }
.ad-alloc__slice--7 { background: color-mix(in oklab, var(--s1) 20%, var(--surface2)); }

.ad-ranges button[aria-pressed="true"] { background: var(--accent-soft); }
.ad-ranges button[disabled] { color: var(--muted); cursor: not-allowed; }

/* --- web-stock --------------------------------------------------------- */
/* One row per scored component. `--ad-score-width` is the inline share of the
   widest component (0..100 %), the same shape `--ad-contrib-width` has; the
   number stands beside the bar, so the bar is never the only carrier. */
.ad-scores { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ad-score { display: grid; grid-template-columns: 10rem 1fr 3rem; align-items: center; gap: 8px; }
.ad-score__bar { position: relative; height: 10px; background: var(--surface2); border-radius: 5px; }
.ad-score__fill { position: absolute; inset: 0 auto 0 0; width: var(--ad-score-width, 0%); border-radius: 5px; background: var(--s1); }
.ad-score__v { text-align: right; font-variant-numeric: tabular-nums; }

.ad-news { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ad-news span { color: var(--muted); }

.ad-timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ad-timeline span { color: var(--muted); font-variant-numeric: tabular-nums; }

.ad-order { display: grid; gap: 8px; max-width: 28rem; }
.ad-order__estimate { color: var(--muted); }
/* The estimate's scarcity warning: not enough money, or not enough shares.
   It is the one line of the form that must not read as a muted aside, so it
   takes the same pair of tokens every other bad news on the page takes. */
.ad-order__warning {
  background: var(--bad-soft);
  color: var(--bad);
  border-radius: 8px;
  padding: 8px 10px;
}

/* /mehr: one card per sub-page, title over its sentence. */
.ad-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.ad-tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px;
  border-radius: 18px;
  background: var(--surface2);
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.ad-tile:hover,
.ad-tile:focus-visible {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.ad-tile__title {
  font-weight: 600;
  color: var(--accent);
}

.ad-tile__text {
  font-size: 14px;
  color: var(--ink2);
}

/* /aktie: the holdings and the watchlist, one click each. */
.ad-picks__title {
  margin-top: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.ad-picks {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.ad-picks a {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}

.ad-picks a:hover,
.ad-picks a:focus-visible {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.ad-picks .ad-sym {
  margin-left: 4px;
  font-size: 12px;
  color: var(--muted);
}

/* tenant-auth: the login, invitation and password forms. */
.ad-auth { display: grid; gap: 8px; max-width: 24rem; }
.ad-qr { width: 12rem; height: auto; }
.ad-auth__error {
  background: var(--bad-soft);
  color: var(--bad);
  border-radius: 8px;
  padding: 8px 10px;
}

/* tenant-privacy: the legal pages, their footer links, the consent and confirm ticks. */
.ad-legal { max-width: 48rem; }
.ad-footer__legal { display: flex; gap: 1rem; }
.ad-auth__consent { display: flex; gap: 8px; align-items: baseline; }
