/* Register-Watch – handgeschriebenes CSS, kein Framework, kein Build-Schritt, keine CDNs.
   Ruhig, hell und dunkel; Farbe nur für Zustände (neu = info, geändert = warn, Fehler = danger). */

@layer reset, tokens, base, layout, components, motion, utilities;

@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/static/fonts/InterVariable-latin.woff2") format("woff2-variations");
}

@property --p { syntax: "<number>"; inherits: false; initial-value: 0; }

@view-transition { navigation: auto; }

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { min-height: 100dvh; }
  img, svg { display: block; max-width: 100%; }
  input, button, select, textarea { font: inherit; color: inherit; }
  button { cursor: pointer; background: none; border: 0; padding: 0; }
  a { color: inherit; text-decoration: none; }
  ul, ol { list-style: none; padding: 0; }
  h1, h2, h3 { font-size: inherit; font-weight: inherit; }
  [hidden] { display: none !important; }
}

@layer tokens {
  :root {
    color-scheme: light dark;

    --brand: #1B2430;          /* qdrt-Navy aus dem Logo */
    --on-brand: #FFFFFF;

    --info: #1D4ED8;  --warn: #B45309;  --danger: #B42318;  --ok: #047857;

    --bg: #F6F7F9;  --surface: #FFFFFF;  --surface-2: #F0F2F5;  --line: #E2E6EB;
    --text: #1B2430;  --text-2: #4A5565;  --text-3: #687384;

    --radius-s: 8px;  --radius-m: 12px;  --radius-l: 18px;  --radius-pill: 999px;
    --shadow-1: 0 1px 2px rgb(27 36 48 / .06), 0 1px 1px rgb(27 36 48 / .04);
    --shadow-2: 0 4px 12px rgb(27 36 48 / .08), 0 1px 3px rgb(27 36 48 / .06);
    --shadow-3: 0 18px 40px rgb(27 36 48 / .12), 0 4px 10px rgb(27 36 48 / .06);

    --font: "Inter Variable", system-ui, sans-serif;
    --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", monospace;

    --dur-1: 140ms;  --dur-2: 260ms;  --dur-3: 480ms;
    --ease-out: cubic-bezier(.16, 1, .3, 1);

    --sidebar-w: 224px;
    --topbar-h: 60px;
    --focus: 0 0 0 2px var(--surface), 0 0 0 4px color-mix(in oklab, var(--info) 80%, var(--text));
  }

  @media (prefers-color-scheme: dark) {
    :root {
      --brand: #E6EAF0;
      --on-brand: #121820;
      --info: #8AB0FF;  --warn: #F2B866;  --danger: #FF8F87;  --ok: #5FD3A0;
      --bg: #0F141B;  --surface: #161C25;  --surface-2: #1D2430;  --line: #2A3340;
      --text: #E6EAF0;  --text-2: #A9B3C1;  --text-3: #8592A3;
      --shadow-1: 0 1px 2px rgb(0 0 0 / .4);
      --shadow-2: 0 4px 14px rgb(0 0 0 / .45);
      --shadow-3: 0 18px 40px rgb(0 0 0 / .55);
    }
  }
}

@layer base {
  html { background: var(--bg); color: var(--text); }
  body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
    background: var(--bg);
  }
  h1 { font-size: 26px; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; }
  h2 { font-size: 16px; font-weight: 620; letter-spacing: -.01em; }
  h3 { font-size: 14px; font-weight: 600; }
  p { text-wrap: pretty; }
  :focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-s); }
  code, .mono { font-family: var(--font-mono); font-size: .9em; }
  .num { font-variant-numeric: tabular-nums; }
}

/* ---------- Rahmen ---------- */
@layer layout {
  .shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas: "side top" "side main";
    min-height: 100dvh;
  }
  .shell-sidebar {
    grid-area: side;
    position: sticky; top: 0;
    height: 100dvh;
    display: flex; flex-direction: column; gap: 28px;
    padding: 22px 14px 18px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    view-transition-name: sidebar;
  }
  .shell-topbar {
    grid-area: top;
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 0 32px;
    background: color-mix(in oklab, var(--bg) 80%, transparent);
    backdrop-filter: blur(14px) saturate(1.4);
    -webkit-backdrop-filter: blur(14px) saturate(1.4);
    view-transition-name: topbar;
  }
  .shell-main {
    grid-area: main;
    width: min(100%, 1400px);
    padding: 12px 32px 28px;
    display: flex; flex-direction: column; gap: 22px;
  }
  .shell-footer {
    margin-top: auto;
    padding-top: 22px;
    display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: space-between;
    font-size: 12px; color: var(--text-3);
    border-top: 1px solid var(--line);
  }
  .page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
  .page-head p { color: var(--text-2); margin-top: 4px; }

  .grid { display: grid; gap: 16px; }
  .grid-kpi { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }

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

  @media (max-width: 820px) {
    .shell {
      grid-template-columns: minmax(0, 1fr);
      grid-template-rows: auto auto 1fr;
      grid-template-areas: "side" "top" "main";
    }
    .shell-sidebar {
      position: static; height: auto;
      flex-direction: row; align-items: center; gap: 12px;
      padding: 10px 16px;
      border-right: 0; border-bottom: 1px solid var(--line);
    }
    .shell-topbar { position: static; padding: 0 16px; height: 52px; }
    .shell-main { padding: 8px 16px 24px; }
  }
}

/* ---------- Bausteine ---------- */
@layer components {
  .icon {
    width: 18px; height: 18px; flex: none;
    fill: none; stroke: currentColor; stroke-width: 1.75;
    stroke-linecap: round; stroke-linejoin: round;
  }
  .icon-sm { width: 15px; height: 15px; }

  /* Seitenleiste */
  .brand { display: flex; flex-direction: column; gap: 8px; padding: 2px 10px; color: var(--text); }
  .brand-logo { width: 88px; height: auto; }
  .brand-app { font-size: 11.5px; font-weight: 650; letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); }
  .nav { display: flex; flex-direction: column; gap: 2px; }
  .nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px;
    border-radius: var(--radius-s);
    color: var(--text-2); font-weight: 520; font-size: 14.5px;
    white-space: nowrap;
    transition: background var(--dur-1), color var(--dur-1);
  }
  .nav-item:hover { background: var(--surface-2); color: var(--text); }
  .nav-item[aria-current="page"] { background: var(--surface-2); color: var(--text); font-weight: 600; }

  @media (max-width: 820px) {
    .brand-app { display: none; }
    .brand-logo { width: 64px; }
    .nav { flex-direction: row; overflow-x: auto; }
    .nav-item { padding: 8px 10px; }
  }

  /* Kopfleiste */
  .topbar-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
  .who { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--text-2); font-weight: 550; }

  /* Karten */
  .card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-m);
    box-shadow: var(--shadow-1);
    padding: 20px;
  }
  .card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }

  /* Kennzahlen */
  .kpi { display: flex; flex-direction: column; gap: 6px; min-height: 132px; transition: box-shadow var(--dur-2); }
  .kpi:hover { box-shadow: var(--shadow-2); }
  .kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .kpi-label { font-size: 13px; font-weight: 600; color: var(--text-2); letter-spacing: .01em; }
  .kpi-icon {
    display: grid; place-items: center;
    width: 32px; height: 32px; border-radius: 9px;
    background: var(--surface-2); color: var(--text-2);
  }
  .kpi-value { font-size: 38px; font-weight: 650; letter-spacing: -.03em; line-height: 1.1; margin-top: auto; }
  .kpi-sub { font-size: 12.5px; color: var(--text-3); }
  .kpi.tone-info .kpi-value, .kpi.tone-info .kpi-icon { color: var(--info); }
  .kpi.tone-warn .kpi-value, .kpi.tone-warn .kpi-icon { color: var(--warn); }
  .kpi.tone-danger .kpi-value, .kpi.tone-danger .kpi-icon { color: var(--danger); }

  /* Leerer Zustand */
  .empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 36px 16px; }
  .empty-icon {
    display: grid; place-items: center;
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--surface-2); color: var(--text-3);
    margin-bottom: 4px;
  }
  .empty p { max-width: 46ch; color: var(--text-2); font-size: 14px; }

  /* Schlüssel-Wert-Liste */
  .kv { display: grid; grid-template-columns: minmax(130px, 38%) minmax(0, 1fr); gap: 10px 16px; font-size: 14px; }
  .kv dt { color: var(--text-2); }
  .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
  .muted { color: var(--text-3); }
  .text-danger { color: var(--danger); }

  /* Kontingent */
  .meter { height: 6px; margin-top: 8px; border-radius: var(--radius-pill); background: var(--surface-2); overflow: hidden; max-width: 260px; }
  .meter > span {
    display: block; height: 100%;
    background: var(--text-2);
    transform-origin: left; transform: scaleX(var(--p));
    transition: --p var(--dur-3) var(--ease-out);
  }

  /* Status-Chips */
  .chip {
    --c: var(--text-3);
    display: inline-flex; align-items: center; gap: 6px;
    padding: 2px 10px 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 12.5px; font-weight: 600; white-space: nowrap;
    color: color-mix(in oklab, var(--c) 88%, var(--text));
    background: color-mix(in oklab, var(--c) 12%, transparent);
  }
  .chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
  .chip.tone-info { --c: var(--info); }
  .chip.tone-warn { --c: var(--warn); }
  .chip.tone-danger { --c: var(--danger); }
  .chip.tone-ok { --c: var(--ok); }

  /* Tabellen */
  .table-wrap { overflow-x: auto; }
  .table { width: 100%; border-collapse: collapse; font-size: 14px; }
  .table th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--text-2); padding: 8px 12px; border-bottom: 1px solid var(--line); }
  .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
  .table tr:last-child td { border-bottom: 0; }
  .nowrap { white-space: nowrap; }

  /* Knöpfe */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 38px; padding: 0 16px;
    border-radius: 10px; border: 1px solid var(--line);
    background: var(--surface); color: var(--text);
    font-size: 14px; font-weight: 600;
    transition: background var(--dur-1), border-color var(--dur-1), transform var(--dur-1);
  }
  .btn:active { transform: translateY(1px); }
  .btn-primary { background: var(--brand); border-color: transparent; color: var(--on-brand); }
  .btn-primary:hover { background: color-mix(in oklab, var(--brand) 88%, var(--bg)); }
  .btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
  .btn-ghost:hover { background: var(--surface-2); color: var(--text); }
  .btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
  .btn-lg { height: 44px; padding: 0 20px; font-size: 14.5px; border-radius: 12px; }
  .btn-block { width: 100%; }

  /* Formulare */
  .stack { display: flex; flex-direction: column; gap: 14px; }
  .field { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
  .input {
    height: 42px; padding: 0 12px;
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--surface); color: var(--text);
    font-size: 15px; font-weight: 450;
    transition: border-color var(--dur-1), box-shadow var(--dur-1);
  }
  .input:focus { outline: none; border-color: var(--text-3); box-shadow: var(--focus); }

  /* Anmeldung */
  .auth {
    min-height: 100dvh;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
    padding: 24px 16px;
    background:
      radial-gradient(1200px 600px at 50% -10%, color-mix(in oklab, var(--text) 6%, transparent), transparent 70%),
      var(--bg);
  }
  .auth-card {
    width: min(100%, 400px);
    display: flex; flex-direction: column; gap: 20px;
    padding: 32px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-l);
    box-shadow: var(--shadow-3);
  }
  .auth-brand { color: var(--text); }
  .auth-logo { width: 96px; height: auto; }
  .auth-card .lead { color: var(--text-2); margin-top: 4px; font-size: 14.5px; }
  .auth-error {
    display: flex; align-items: flex-start; gap: 8px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13.5px; font-weight: 550;
    color: var(--danger);
    background: color-mix(in oklab, var(--danger) 10%, transparent);
  }
  .auth-error .icon { margin-top: 2px; }
  .auth-foot { font-size: 12.5px; color: var(--text-3); }
}

/* ---------- Bewegung ---------- */
@layer motion {
  @keyframes rise { from { opacity: 0; translate: 0 10px; } to { opacity: 1; translate: 0 0; } }
  .auth-card { animation: rise var(--dur-3) var(--ease-out) both; }
  .grid-kpi > * { animation: rise var(--dur-3) var(--ease-out) both; animation-delay: calc(var(--i, 0) * 40ms); }
  .grid-kpi > :nth-child(2) { --i: 1; }
  .grid-kpi > :nth-child(3) { --i: 2; }
  .grid-kpi > :nth-child(4) { --i: 3; }
  ::view-transition-group(*) { animation-duration: var(--dur-2); animation-timing-function: var(--ease-out); }

  @media (prefers-reduced-motion: reduce) {
    *, ::view-transition-group(*) { animation-duration: 1ms !important; transition-duration: 1ms !important; }
  }
}

@layer utilities {
  .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;
  }
}

/* ---------- M2: Watchlisten, Firma hinzufügen, Firmendetail ---------- */
@layer layout {
  .grid-lists { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .grid-form { grid-template-columns: minmax(0, 1.7fr) minmax(260px, 1fr); align-items: start; }
  .grid-detail { grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); align-items: start; }
  .page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
  .page-actions form { display: contents; }
  .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
  .stack-sm { display: flex; flex-direction: column; gap: 8px; }

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

@layer components {
  .small { font-size: 12.5px; }
  .right { text-align: right; }
  .back {
    display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
    margin-bottom: -10px;
    font-size: 13.5px; font-weight: 550; color: var(--text-2);
  }
  .back:hover { color: var(--text); }
  .head-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
  .chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
  a.chip:hover { text-decoration: underline; text-underline-offset: 2px; }

  .card-narrow { max-width: 640px; }
  .card-lead { color: var(--text-2); font-size: 14px; margin-bottom: 14px; }
  .card-flush { padding: 0; overflow: hidden; }
  .card-quiet { background: var(--surface-2); box-shadow: none; }
  .card-quiet .card-head { margin-bottom: 10px; }

  /* Listenkarten */
  .list-card { display: flex; flex-direction: column; gap: 8px; min-height: 120px; transition: box-shadow var(--dur-2), border-color var(--dur-2); }
  .list-card:hover { box-shadow: var(--shadow-2); border-color: color-mix(in oklab, var(--line) 60%, var(--text-3)); }
  .list-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .list-card-desc { color: var(--text-2); font-size: 13.5px; }
  .list-card-meta { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 13px; color: var(--text-2); }

  /* Knöpfe */
  .btn-danger { background: transparent; border-color: transparent; color: var(--danger); }
  .btn-danger:hover { background: color-mix(in oklab, var(--danger) 10%, transparent); }
  .btn:disabled { opacity: .5; cursor: not-allowed; }

  /* Aufklappmenü ohne JavaScript */
  .menu { position: relative; }
  .menu > summary { list-style: none; }
  .menu > summary::-webkit-details-marker { display: none; }
  .menu-panel {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
    width: min(360px, 90vw);
    box-shadow: var(--shadow-3);
  }
  .sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0 12px; }

  /* Formulare */
  .field-hint { font-size: 12.5px; font-weight: 450; color: var(--text-3); }
  .field-label { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
  .field-error { font-size: 12.5px; font-weight: 600; color: var(--danger); }
  .field-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(90px, .8fr) minmax(0, 1.2fr); gap: 12px; }
  .field-row:has(> :only-child) { grid-template-columns: minmax(0, 360px); }
  @media (max-width: 640px) { .field-row { grid-template-columns: minmax(0, 1fr); } }
  select.input {
    appearance: none; -webkit-appearance: none;
    padding-right: 34px;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
    background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
  }
  .textarea { width: 100%; height: auto; min-height: 84px; padding: 10px 12px; line-height: 1.45; resize: vertical; }
  .input-sm { height: 34px; font-size: 14px; }
  .inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
  .inline-form .input { width: auto; min-width: 160px; }
  .recognized { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; color: var(--c, var(--text-2)); }
  .recognized.tone-ok { --c: var(--ok); }
  .recognized.tone-warn { --c: var(--warn); }
  .recognized.tone-muted { --c: var(--text-3); font-weight: 500; }

  /* Hinweise */
  .notice {
    --c: var(--info);
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px; border-radius: 10px;
    font-size: 14px;
    color: color-mix(in oklab, var(--c) 70%, var(--text));
    background: color-mix(in oklab, var(--c) 9%, transparent);
    border: 1px solid color-mix(in oklab, var(--c) 22%, transparent);
  }
  .notice > .icon { margin-top: 2px; color: var(--c); }
  .notice.tone-warn { --c: var(--warn); }
  .notice.tone-danger { --c: var(--danger); }
  .notice.tone-ok { --c: var(--ok); }
  .card > .notice + *, .stack > .notice { margin-top: 0; }
  .card > .notice:not(:last-child) { margin-bottom: 14px; }

  /* Schritte */
  .steps { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 13.5px; font-weight: 550; color: var(--text-3); }
  .steps li { display: flex; align-items: center; gap: 8px; }
  .step-no {
    display: grid; place-items: center;
    width: 24px; height: 24px; border-radius: 50%;
    font-size: 12px; font-weight: 650;
    border: 1px solid var(--line); background: var(--surface);
  }
  .steps .is-current { color: var(--text); }
  .steps .is-current .step-no { background: var(--brand); color: var(--on-brand); border-color: transparent; }
  .steps .is-done { color: var(--text-2); }
  .steps .is-done .step-no { color: var(--ok); border-color: color-mix(in oklab, var(--ok) 40%, transparent); }

  .how { display: flex; flex-direction: column; gap: 12px; font-size: 14px; color: var(--text-2); counter-reset: how; }
  .how li { position: relative; padding-left: 30px; }
  .how li::before {
    counter-increment: how; content: counter(how);
    position: absolute; left: 0; top: 1px;
    display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
    font-size: 11.5px; font-weight: 650; color: var(--text-2); background: var(--surface);
  }
  .how strong { color: var(--text); }
  .card-quiet .notice { margin-top: 14px; }

  /* Fortschritt */
  .progress-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
  .progress-head h2 { margin-bottom: 2px; }
  .progress-head p { font-size: 14px; }
  .spin, .status-icon {
    display: grid; place-items: center; flex: none;
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--surface-2); color: var(--info);
  }
  .status-icon { color: var(--text-2); }
  .status-icon.tone-danger { color: var(--danger); background: color-mix(in oklab, var(--danger) 10%, transparent); }
  .progress { height: 6px; border-radius: var(--radius-pill); background: var(--surface-2); overflow: hidden; margin-bottom: 14px; }
  .progress > span {
    display: block; height: 100%; width: 100%;
    background: var(--info);
    transform-origin: left; transform: scaleX(var(--p, 0));
    transition: --p var(--dur-3) var(--ease-out);
  }
  .progress.is-indeterminate > span { width: 35%; transform: none; }
  .card-status { border-color: color-mix(in oklab, var(--info) 25%, var(--line)); }
  .card-status.tone-danger { border-color: color-mix(in oklab, var(--danger) 30%, var(--line)); }
  .kv + .field-hint { display: block; margin-top: 14px; }
  .card-status > form { margin-top: 4px; }

  /* Treffer */
  .hits { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
  .hits-legend { font-size: 13.5px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; padding: 0; }
  .hit {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--line); border-radius: var(--radius-m);
    background: var(--surface);
    cursor: pointer;
    transition: border-color var(--dur-1), box-shadow var(--dur-1), background var(--dur-1);
  }
  .hit:hover { border-color: color-mix(in oklab, var(--line) 50%, var(--text-3)); }
  .hit:has(input:checked) { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
  .hit:has(input:focus-visible) { box-shadow: var(--focus); }
  .hit input { margin-top: 3px; accent-color: var(--brand); width: 16px; height: 16px; flex: none; }
  .hit.is-disabled { cursor: default; background: var(--surface-2); }
  .hit.is-disabled .hit-name { color: var(--text-2); }
  .hit-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
  .hit-name { font-weight: 620; font-size: 15px; }
  .hit-meta { font-size: 13.5px; color: var(--text-2); }
  .hit .chips:empty { display: none; }

  /* Tabelle der Watchlist */
  .toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .search { position: relative; display: flex; align-items: center; flex: 1 1 260px; max-width: 420px; color: var(--text-3); }
  .search > .icon { position: absolute; left: 11px; pointer-events: none; }
  .search .input { width: 100%; padding-left: 34px; }
  .card-flush .table th:first-child, .card-flush .table td:first-child { padding-left: 16px; }
  .card-flush .table th:last-child, .card-flush .table td:last-child { padding-right: 16px; }
  .card-flush .empty { padding: 44px 16px; }
  .table tbody tr { transition: background var(--dur-1); }
  .table-companies tbody tr:hover { background: color-mix(in oklab, var(--surface-2) 60%, transparent); }
  .row-link { font-weight: 600; }
  .row-link:hover { text-decoration: underline; text-underline-offset: 3px; }
  .sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
  .sort { display: inline-flex; align-items: center; gap: 4px; color: inherit; }
  .sort:hover { color: var(--text); }
  .sort.is-active { color: var(--text); }
  .sort-dir { font-size: 11px; }

  /* Firmendetail */
  .prose { white-space: pre-line; line-height: 1.55; }
  .sub-title { font-size: 13px; font-weight: 600; color: var(--text-2); margin: 18px 0 8px; }
  .tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
  .tag {
    display: inline-flex; align-items: center; gap: 2px;
    padding: 3px 4px 3px 10px; border-radius: var(--radius-pill);
    font-size: 13px; font-weight: 550;
    background: var(--surface-2);
  }
  .tag:not(:has(form)) { padding-right: 10px; }
  .tag a:hover { text-decoration: underline; text-underline-offset: 2px; }
  .tag-x { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: var(--text-3); }
  .tag-x:hover { background: var(--line); color: var(--text); }
  #note-saved { min-height: 1em; }

  .entries { display: flex; flex-direction: column; }
  .entry { border-top: 1px solid var(--line); }
  .entry:first-child { border-top: 0; }
  .entry summary {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 2px; cursor: pointer; list-style: none;
    font-size: 14px;
  }
  .entry summary::-webkit-details-marker { display: none; }
  .entry summary::before {
    content: ""; flex: none; width: 6px; height: 6px;
    border-right: 1.5px solid var(--text-3); border-bottom: 1.5px solid var(--text-3);
    transform: rotate(-45deg); transition: transform var(--dur-1);
  }
  .entry details[open] > summary::before { transform: rotate(45deg); }
  .entry-no { flex: none; font-weight: 600; color: var(--text-2); min-width: 84px; }
  .entry-preview { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
  .entry details[open] .entry-preview { display: none; }
  .entry-text { padding: 0 2px 14px 18px; font-size: 14px; line-height: 1.6; white-space: pre-line; max-width: 90ch; }
}

@layer motion {
  @keyframes spin { to { rotate: 360deg; } }
  @keyframes slide { from { translate: -100% 0; } to { translate: 290% 0; } }
  .spin .icon { animation: spin 1.1s linear infinite; }
  .progress.is-indeterminate > span { animation: slide 1.6s var(--ease-out) infinite; }
  .hits > .hit { animation: rise var(--dur-2) var(--ease-out) both; }
}

@layer motion {
  @media (prefers-reduced-motion: reduce) {
    .spin .icon, .progress.is-indeterminate > span { animation: none; }
  }
}

/* ---------- M3: Verlauf ---------- */
@layer components {
  .timeline { display: flex; flex-direction: column; gap: 18px; }
  .timeline-item { display: grid; grid-template-columns: 1fr; gap: 8px; padding-left: 16px; border-left: 2px solid var(--line); }
  .timeline-when { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
  .timeline-changes { display: flex; flex-direction: column; gap: 12px; }
  .change-head { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
  .change-summary { font-size: 14px; overflow-wrap: anywhere; }
  .change-diff summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--text-3); margin-top: 4px; }
  .change-diff summary:hover { color: var(--text-2); }
  .beforeafter { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 6px 12px; margin-top: 8px; font-size: 13.5px; }
  .beforeafter dt { color: var(--text-3); font-weight: 600; }
  .beforeafter dd { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
  .left-list { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
}

/* ---------- M4: Dashboard ---------- */
@layer layout {
  .grid-dashboard { grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); align-items: start; }
  @media (max-width: 1100px) { .grid-dashboard { grid-template-columns: minmax(0, 1fr); } }
}

@layer components {
  .feed-top { padding: 18px 16px 0; margin-bottom: 12px; }
  .feed-filter { justify-content: flex-start; border-top: 1px solid var(--line); }
  .feed-filter .input { width: auto; min-width: 170px; }
  .feed-count { margin-left: auto; }
  .check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-2); cursor: pointer; }
  .check input { accent-color: var(--brand); width: 15px; height: 15px; }
  .feed { padding: 4px 16px 12px; }
  .feed-day {
    position: sticky; top: var(--topbar-h); z-index: 1;
    padding: 12px 0 6px; font-size: 12.5px; font-weight: 650; color: var(--text-2);
    background: var(--surface);
  }
  .feed-list { display: flex; flex-direction: column; }
  .feed-item {
    display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 4px 12px; align-items: start;
    padding: 12px 0; border-top: 1px solid var(--line);
  }
  .feed-day + .feed-list > .feed-item:first-child { border-top: 0; }
  .feed-time { font-size: 13px; color: var(--text-3); padding-top: 2px; }
  .feed-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin-bottom: 6px; }
  .feed-body .chips { margin-bottom: 4px; }
  .feed-item:not(.is-unseen) .change-summary { color: var(--text-2); }
  .feed-action { align-self: start; }
  .pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 6px 16px 16px; font-size: 13px; }
  .card-flush > .empty { padding: 44px 16px; }

  .attention { display: flex; flex-direction: column; gap: 14px; }
  .attention li { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
  .upcoming { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
  .upcoming li { display: flex; justify-content: space-between; gap: 12px; }
  .upcoming .num { white-space: nowrap; }
  .feed-changes { display: flex; flex-direction: column; gap: 12px; }

  @media (max-width: 640px) {
    .feed-item { grid-template-columns: minmax(0, 1fr); }
    .feed-time { padding: 0; }
    .feed-filter .input { min-width: 0; flex: 1 1 140px; }
  }
}

@layer layout {
  @media (max-width: 1100px) {
    .grid-dashboard > .stack { order: -1; }  /* Aufmerksamkeit vor dem langen Feed */
  }
  @media (max-width: 640px) {
    .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .kpi { min-height: 0; padding: 14px; }
    .kpi-value { font-size: 30px; }
    .kpi-sub { font-size: 12px; }
  }
}

/* ---------- M5: Jahresabschlüsse ---------- */
@layer components {
  .statement {
    margin: 0; padding: 4px 2px;
    font-family: var(--font-mono); font-size: 13px; line-height: 1.55;
    white-space: pre-wrap; overflow-wrap: anywhere;
    max-height: 70vh; overflow: auto;
  }
  .kv-wide { grid-template-columns: minmax(130px, 220px) minmax(0, 1fr); }
}
