/* catcom Editionen — Login-Seiten (apps/api/public). Eine Schrift (System-UI), vier Größen, Tokens und
   Hell/Dunkel-Logik aus mock/styles/app.css, Raster und Wortmarke aus mock/styles/start.css.
   Bauhaus-Klarheit: ein Raster, eine kräftige Linie, die Wortmarke als einziges großes Element,
   Orange (#FF5000) nur als Signal — Punkt der Wortmarke, Fehlertext. Keine Schatten, keine Verläufe. */

/* ─── Tokens (Kopie aus mock/styles/app.css, nur was die Login-Seiten brauchen) ──────────────────── */
:root {
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --fs-s: 12px;
  --fs-m: 15px;
  --fs-l: 20px;
  --fs-xl: 40px;

  --s1: 8px;
  --s2: 16px;
  --s3: 24px;
  --s4: 32px;
  --s6: 48px;
  --s8: 64px;
  --s12: 96px;

  --max: 1320px;
  --gutter: 32px;
  --col-gap: 24px;
}

/* Hell (Vorgabe). Kontraste auf --bg: --ink 17,6 · --ink-2 5,5 · --line-3 3,6 (Bedienelemente 3 : 1).
   Orange: --warn #FF5000 für Marke und Linien; als Schrift --warn-ink (gleicher Farbton, dunkler, 5,4 : 1). */
:root {
  color-scheme: light;
  --bg: #f7f7f6;
  --surface: #ffffff;
  --raised: #ffffff;
  --wall: #ededeb;
  --ink: #111111;
  --ink-2: #656562;
  --ink-3: #a4a4a0; /* nur Linien, Flächen und abgeschaltete Bedienelemente — nie Lesetext */
  --rule: #111111;
  --line: #e0e0dc;
  --line-2: #c8c8c4;
  --line-3: #82827e;
  --track: #e6e6e3;
  --seg-on: #ffffff;
  --on-ink: #ffffff;
  --warn: #ff5000;
  --warn-ink: #b83a00;
  --on-warn: #111111;
}

/* Dunkel: Anthrazit statt Schwarz, gebrochenes Weiß, Orange bleibt Signal und ist hier auch als Schrift #FF5000.
   Zweimal derselbe Block — einmal gewählt (data-theme="dark"), einmal über das System. Nur zusammen ändern. */
@media screen {
  :root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #141414;
    --surface: #1c1c1c;
    --raised: #1a1a1a;
    --wall: #353534;
    --ink: #ececea;
    --ink-2: #a6a6a2;
    --ink-3: #6c6c69;
    --rule: #e9e9e7;
    --line: #2c2c2b;
    --line-2: #4a4a48;
    --line-3: #7a7a77;
    --track: #262625;
    --seg-on: #3a3a39;
    --on-ink: #141414;
    --warn: #ff5000;
    --warn-ink: #ff5000;
    --on-warn: #111111;
  }
}

@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141414;
    --surface: #1c1c1c;
    --raised: #1a1a1a;
    --wall: #353534;
    --ink: #ececea;
    --ink-2: #a6a6a2;
    --ink-3: #6c6c69;
    --rule: #e9e9e7;
    --line: #2c2c2b;
    --line-2: #4a4a48;
    --line-3: #7a7a77;
    --track: #262625;
    --seg-on: #3a3a39;
    --on-ink: #141414;
    --warn: #ff5000;
    --warn-ink: #ff5000;
    --on-warn: #111111;
  }
}

/* ─── Grundlagen ───────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  font: 400 var(--fs-m) / 1.5 var(--font);
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}

main {
  flex: 1;
  outline: none;
}

h1,
h2,
h3,
p,
dl,
dd,
figure {
  margin: 0;
}

h1,
h2,
h3 {
  font-weight: 500;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

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

a {
  color: inherit;
}

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

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* Programmatisch fokussierte Überschriften/Bereiche (tabindex="-1") sind keine Bedienelemente — kein Rahmen. */
[tabindex="-1"]:focus {
  outline: none;
}

[hidden] {
  display: none !important;
}

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

.skip {
  position: absolute;
  left: var(--s2);
  top: -100px;
  z-index: 50;
  background: var(--surface);
  padding: var(--s1) var(--s2);
}

.skip:focus {
  top: var(--s1);
}

/* ─── Typografie ───────────────────────────────────────────────────────────── */
.subhead {
  font-size: var(--fs-l);
  font-weight: 500;
  line-height: 1.3;
}

.label {
  display: block;
  font-size: var(--fs-s);
  line-height: 1.4;
  color: var(--ink-2);
}

.muted {
  color: var(--ink-2);
}

.hint,
.note {
  font-size: var(--fs-s);
  color: var(--ink-2);
}

.hint:empty {
  display: none;
}

/* Gruppe: KLEINE VERSALIEN, danach Haarlinie bis zum rechten Rand */
.rule {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin: 0 0 var(--s3);
  font-size: var(--fs-s);
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line-2);
}

/* Meldungen: Fehler in Orange (Signal), Status in Grau. Leer = unsichtbar, aber im Baum (aria-live). */
.msg {
  margin: 0;
  font-size: var(--fs-m);
  line-height: 1.4;
}

.msg:empty {
  display: none;
}

.msg--error {
  color: var(--warn-ink);
}

.msg--status {
  color: var(--ink-2);
}

/* ─── Bedienelemente ───────────────────────────────────────────────────────── */
.field {
  display: grid;
  gap: 4px;
}

.field .input {
  width: 100%;
}

/* Unterstrichene Eingaben (PRisM): die Linie ist das einzige Zeichen des Felds */
.input {
  border: 0;
  border-bottom: 1px solid var(--line-3);
  border-radius: 0;
  background-color: transparent;
  padding: 4px 0;
  outline: none;
  min-height: 32px;
}

.input:focus {
  border-bottom-color: var(--ink);
  box-shadow: 0 1px 0 var(--ink);
}

.input::placeholder {
  color: var(--ink-2);
}

.input[aria-invalid="true"] {
  border-bottom-color: var(--warn);
  box-shadow: 0 1px 0 var(--warn);
}

.input--code {
  font-size: var(--fs-l);
  letter-spacing: 0.2em;
  max-width: 12ch;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: var(--s1);
}

.check input {
  accent-color: var(--ink);
  margin: 4px 0 0;
  flex: none;
}

.btn {
  border: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  padding: 3px 16px;
  font-size: var(--fs-s);
  font-weight: 500;
  line-height: 20px;
  color: var(--ink);
}

.btn:hover:not(:disabled) {
  background: var(--ink);
  color: var(--on-ink);
}

.btn:disabled {
  border-color: var(--line-2);
  color: var(--ink-2);
  cursor: default;
}

.btn--primary {
  justify-self: start;
  background: var(--ink);
  color: var(--on-ink);
  padding: 8px 20px;
  font-size: var(--fs-m);
}

.btn--primary:hover:not(:disabled) {
  background: transparent;
  color: var(--ink);
}

.btn--primary:disabled {
  background: var(--line-2);
  border-color: var(--line-2);
  color: var(--ink-2);
}

.btn[aria-busy="true"] {
  cursor: progress;
}

.btn-text,
.link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--line-2);
  text-underline-offset: 3px;
}

.btn-text:hover,
.link:hover {
  text-decoration-color: var(--ink);
}

/* Segment-Schalter (Hell · Dunkel · System) */
.seg {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 2px;
  padding: 2px;
  border-radius: 6px;
  background: var(--track);
}

.seg button {
  border: 0;
  border-radius: 4px;
  background: transparent;
  padding: 4px 10px;
  font-size: var(--fs-s);
  font-weight: 500;
  line-height: 20px;
  color: var(--ink-2);
  white-space: nowrap;
}

.seg button:hover:not(:disabled) {
  color: var(--ink);
}

.seg button[aria-pressed="true"] {
  background: var(--seg-on);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-3);
}

/* ─── Seite: Wortmarke, kräftige Linie, Aussage links, Formular rechts ──────── */
.auth {
  min-height: 100vh;
  width: 100%;
  max-width: calc(var(--max) + 2 * var(--gutter));
  margin: 0 auto;
  padding: var(--s3) var(--gutter) var(--s4);
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: auto 1fr auto;
  column-gap: var(--col-gap);
  row-gap: var(--s6);
}

.auth__head {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s2);
  padding-bottom: var(--s2);
  border-bottom: 2px solid var(--rule);
}

.auth__mark {
  font-size: var(--fs-l);
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.auth__dot {
  color: var(--warn);
}

.auth__tools {
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.auth__body {
  grid-column: 1 / 8;
  align-self: center;
}

/* Inhaltsseiten (Einrichten, Mandanten): Aussage oben, die breite Tafel füllt den Rest */
.auth--top {
  grid-template-rows: auto auto 1fr auto;
}

.auth--top .auth__body {
  align-self: start;
}

.auth__claim {
  font-size: var(--fs-xl);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 0 0 var(--s3);
  max-width: 14ch;
}

.auth__text {
  font-size: var(--fs-l);
  font-weight: 400;
  line-height: 1.4;
  color: var(--ink-2);
  max-width: 34ch;
}

.auth__text + .auth__text {
  margin-top: var(--s2);
}

/* Formular / Tafel rechts: Haarlinie oben, ein Raster aus 16-px-Abständen */
.auth__panel {
  grid-column: 9 / -1;
  grid-row: 2;
  align-self: center;
  display: grid;
  gap: var(--s2);
  padding-top: var(--s2);
  border-top: 1px solid var(--rule);
  align-content: start;
}

.auth--top .auth__panel {
  align-self: start;
}

.auth__panel--wide {
  grid-column: 1 / -1;
  grid-row: auto;
}

.auth__note {
  margin: 0;
  font-size: var(--fs-s);
  color: var(--ink-2);
}

.auth__foot {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1) var(--s4);
  padding-top: var(--s2);
  border-top: 1px solid var(--line-2);
  font-size: var(--fs-s);
  color: var(--ink-2);
}

.auth__foot-links {
  margin-left: auto;
  display: flex;
  gap: var(--s2);
}

.auth__foot-links span {
  border-bottom: 1px solid var(--line-2);
}

/* Wer angemeldet ist: eine Zeile mit E-Mail und „Abmelden“ */
.who {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s1) var(--s2);
  font-size: var(--fs-s);
  color: var(--ink-2);
}

.who__mail {
  color: var(--ink);
}

/* Zwei Wege nebeneinander (Passkey · Code) */
.paths {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s6) var(--col-gap);
}

.path {
  display: grid;
  gap: var(--s2);
  align-content: start;
}

.path__text {
  color: var(--ink-2);
  max-width: 40ch;
}

.step {
  display: grid;
  gap: var(--s2);
}

/* Steckbrief der Einladung / Begriffspaare */
.facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px var(--s3);
}

.facts dt {
  font-size: var(--fs-s);
  color: var(--ink-2);
}

.facts dd {
  overflow-wrap: anywhere;
}

/* QR-Code: ein echtes Objekt, bleibt in beiden Modi schwarz auf weiß */
.qr {
  width: 208px;
  height: 208px;
  padding: 8px;
  background: #ffffff;
  border: 1px solid var(--line-2);
}

.qr canvas {
  width: 100%;
  height: 100%;
}

.secret {
  letter-spacing: 0.08em;
  overflow-wrap: anywhere;
  user-select: all;
}

/* Ersatzcodes: zwei Spalten, tabellarische Ziffern, einmalig sichtbar */
.codes {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  gap: 4px var(--s4);
  padding: var(--s2) 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  letter-spacing: 0.06em;
  user-select: all;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1) var(--s2);
}

/* Mandanten (links) und Motive (rechts) */
.tenants-grid {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
  gap: var(--s4) var(--col-gap);
}

.tenant {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s2);
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: none;
  padding: 10px 0;
  text-align: left;
  color: var(--ink);
}

.tenant:hover,
.tenant[aria-current="true"] {
  border-bottom-color: var(--ink);
}

.tenant[aria-current="true"] {
  font-weight: 500;
}

.role {
  flex: none;
  font-size: var(--fs-s);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.motif {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px var(--s2);
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.motif__title {
  font-weight: 500;
}

.motif__caption {
  grid-column: 1;
  color: var(--ink-2);
}

.motif__count {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: start;
  font-size: var(--fs-s);
  color: var(--ink-2);
  white-space: nowrap;
}

.empty {
  color: var(--ink-2);
  padding: var(--s2) 0;
}

/* ─── Schmal ───────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .auth {
    row-gap: var(--s4);
    grid-template-rows: auto auto auto auto;
  }

  .auth__body,
  .auth__panel {
    grid-column: 1 / -1;
    grid-row: auto;
    align-self: start;
  }

  .auth__claim {
    font-size: 28px;
    max-width: none;
  }

  .auth__text {
    font-size: var(--fs-m);
    max-width: none;
  }

  .auth__foot-links {
    margin-left: 0;
  }

  .paths,
  .tenants-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 600px) {
  :root {
    --gutter: 16px;
  }

  .auth {
    padding-top: var(--s2);
  }

  .auth__head {
    flex-wrap: wrap;
  }

  .codes {
    grid-template-columns: max-content;
  }
}
