/* The admin surface. Plain CSS, no build, no framework.
 *
 * The rules below are TRANSLATIONS of the client's shadcn components, not new designs:
 * each one names the Svelte component and the class string it came from, so a change over
 * there can be followed here. The components themselves could not be reused - they are
 * Svelte plus Tailwind 4 plus tailwind-variants, and neither belongs in this repository.
 */

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

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 0.875rem;          /* text-sm, the client's base for interface chrome */
  line-height: 1.5;
}

a { color: var(--primary); text-underline-offset: 4px; }

/* --- frame ---------------------------------------------------------------- */

header.app {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
header.app .logo { display: block; height: 1.5rem; width: auto; }
header.app .where { color: var(--muted-foreground); font-size: 0.8125rem; }
header.app .spacer { flex: 1; }

main { max-width: 56rem; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

footer.app {
  max-width: 56rem; margin: 0 auto; padding: 0 1.25rem 2rem;
  color: var(--muted-foreground); font-size: 0.75rem;
}

h1 { font-size: 1.25rem; font-weight: 600; margin: 0 0 0.25rem; }
h2 { font-size: 1rem; font-weight: 600; margin: 1.5rem 0 0.5rem; }
p.lead { color: var(--muted-foreground); margin: 0 0 1.5rem; }

/* --- card: ui/card/card.svelte -------------------------------------------- */
/* bg-card text-card-foreground rounded-xl border shadow-sm */

.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

/* --- form: ui/label, ui/input, ui/native-select --------------------------- */
/* label: text-sm font-medium leading-none
   input: h-9 w-full rounded-md border bg-transparent px-3 py-1 text-base shadow-xs
          focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] */

.field { margin-bottom: 1rem; }
.field label {
  display: block; margin-bottom: 0.375rem;
  font-weight: 500; line-height: 1;
}
.field .hint { display: block; margin-top: 0.375rem; color: var(--muted-foreground); font-size: 0.75rem; }

/* Every text-ish field, listed by type. An omission here is invisible in review and loud
 * on screen: `password` was missing, so the sign-in form had one full-width field and one
 * browser-default box under it. */
input[type="text"], input[type="password"], input[type="email"],
input[type="date"], input[type="number"], select {
  height: 2.25rem;
  width: 100%;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background: transparent;
  color: inherit;
  font: inherit;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  outline: none;
}
input:focus-visible, select:focus-visible {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 50%, transparent);
}
input[aria-invalid="true"] { border-color: var(--destructive); }

.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > * { flex: 1 1 12rem; }

/* --- button: ui/button/button.svelte -------------------------------------- */
/* base:    inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium
            h-9 px-4 py-2 transition-all disabled:opacity-50
   default: bg-primary text-primary-foreground shadow-xs hover:bg-primary/90
   outline: bg-background border hover:bg-accent hover:text-accent-foreground */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  height: 2.25rem; padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: var(--primary-foreground);
  font: inherit; font-weight: 500;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}
.btn:hover { background: color-mix(in oklab, var(--primary) 90%, transparent); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 50%, transparent); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

.btn.outline {
  background: var(--background); color: inherit; border-color: var(--border);
}
.btn.outline:hover { background: var(--accent); color: var(--accent-foreground); }

/* --- table: ui/table/table.svelte ----------------------------------------- */
/* head row: border-b  ·  th: h-10 px-2 text-left font-medium text-muted-foreground
   td: p-2 align-middle  ·  row: border-b hover:bg-muted/50 */

table.data { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
table.data th {
  height: 2.5rem; padding: 0 0.5rem; text-align: left;
  font-weight: 500; color: var(--muted-foreground);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td { padding: 0.5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:hover { background: color-mix(in oklab, var(--muted) 50%, transparent); }
table.data td.mono { font-family: var(--font-mono); font-size: 0.8125rem; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.375rem 1rem; margin: 0; }
dl.facts dt { color: var(--muted-foreground); }
dl.facts dd { margin: 0; }
dl.facts dd.mono { font-family: var(--font-mono); font-size: 0.8125rem; word-break: break-all; }

/* --- badge: ui/badge/badge.svelte ----------------------------------------- */
/* inline-flex items-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit */

.badge {
  display: inline-flex; align-items: center; width: fit-content;
  padding: 0.125rem 0.5rem;
  border: 1px solid transparent; border-radius: var(--radius-md);
  font-size: 0.75rem; font-weight: 500;
  background: var(--secondary); color: var(--secondary-foreground);
}
.badge.ok   { background: color-mix(in oklab, var(--success) 15%, transparent); color: var(--success); border-color: color-mix(in oklab, var(--success) 30%, transparent); }
.badge.warn { background: color-mix(in oklab, var(--warn) 15%, transparent); color: var(--warn); border-color: color-mix(in oklab, var(--warn) 30%, transparent); }
.badge.bad  { background: color-mix(in oklab, var(--destructive) 12%, transparent); color: var(--destructive); border-color: color-mix(in oklab, var(--destructive) 30%, transparent); }

/* --- notices -------------------------------------------------------------- */

.notice {
  display: flex; gap: 0.625rem; align-items: flex-start;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border); border-left-width: 3px;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
}
.notice strong { font-weight: 600; }
.notice.warn { border-left-color: var(--warn); background: color-mix(in oklab, var(--warn) 8%, transparent); }
.notice.bad  { border-left-color: var(--destructive); background: color-mix(in oklab, var(--destructive) 8%, transparent); }
.notice.ok   { border-left-color: var(--success); background: color-mix(in oklab, var(--success) 8%, transparent); }

/* --- phone ---------------------------------------------------------------- */

@media (max-width: 40rem) {
  main { padding: 1rem; }
  .row { flex-direction: column; }
  header.app { padding: 0.75rem 1rem; }
}

/* --- the logo ------------------------------------------------------------- */
/* The lettering follows currentColor; the CD's dark value is #F4F4F4, its light one
 * #565F66. The mark keeps its pink in both, exactly as in the client. */

.logo-wrap { display: inline-flex; color: #565f66; }
@media (prefers-color-scheme: dark) { :root:not(.light) .logo-wrap { color: #f4f4f4; } }
.dark .logo-wrap { color: #f4f4f4; }

/* --- the field that does not apply ---------------------------------------- */
/* Only one of "Enddatum" and "Dauer in Monaten" belongs to the selected mode, and this
 * page carries no script. `:has()` with `option:checked` follows the live selection, so
 * the irrelevant field disappears as the admin changes the dropdown - without JavaScript
 * on a page served by the pod that holds the signing key.
 *
 * The fallback matters: a browser without `:has()` simply shows BOTH fields, which is
 * what this page did before and is merely untidy, never wrong. The server ignores the
 * field that does not belong to the mode either way. */

form:has(#mode option[value="months"]:checked) .only-until  { display: none; }
form:has(#mode option[value="until"]:checked)  .only-months { display: none; }

/* --- the read views ------------------------------------------------------- */

nav.app { display: flex; gap: 1rem; margin-left: 0.5rem; }
nav.app a { color: var(--muted-foreground); text-decoration: none; font-weight: 500; }
nav.app a:hover { color: var(--foreground); }
nav.app a[aria-current="page"] { color: var(--foreground); }

.stats { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.stat {
  flex: 1 1 7rem; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 0.875rem 1rem;
}
.stat .n { display: block; font-size: 1.5rem; font-weight: 600; line-height: 1.2; }
.stat .l { display: block; color: var(--muted-foreground); font-size: 0.8125rem; }

form.search { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
form.search input { flex: 1 1 16rem; }

.reg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; }
.reg-head .addr { font-weight: 600; }
.muted { color: var(--muted-foreground); }
.card .muted { font-size: 0.8125rem; }
dl.facts.answers { margin-top: 0.875rem; padding-top: 0.875rem; border-top: 1px solid var(--border); }
.card form .hint { display: block; margin-top: 0.5rem; color: var(--muted-foreground); font-size: 0.8125rem; }

/* --- sign-in and the root page ------------------------------------------- */
/* The modeller's arrangement: a card centred on a muted ground, logo and a caption above
 * it. Same proportions (max-width 24rem, padding 1.5rem, gap 1.25rem) so the two screens
 * read as one product without this service carrying a Node tool chain. */

body.signin { background: color-mix(in oklab, var(--muted) 30%, var(--background)); }

.signin-wrap {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  padding: 1.5rem;
  max-width: none;
}

.signin-head {
  display: flex; flex-direction: column; align-items: center; gap: 0.75rem;
  text-align: center;
}

.signin-card {
  width: 100%;
  max-width: 24rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 0;
}
.signin-card h1 { font-size: 1rem; font-weight: 600; margin: 0 0 0.25rem; }
.signin-card .field { margin-bottom: 0; }
.signin-card .muted { font-size: 0.875rem; }
.signin-card .hint { margin: 0; color: var(--muted-foreground); font-size: 0.75rem; }
.signin-card dl.facts { grid-template-columns: 1fr; gap: 0.25rem; }
.signin-card dl.facts dt { font-weight: 600; color: var(--foreground); margin-top: 0.5rem; }

.btn.wide { width: 100%; }

/* --- signing out ---------------------------------------------------------- */
/* A form, because signing out changes something -- but it looks like a link, because it is
 * needed rarely and should not compete with the navigation. */

form.signout { margin: 0; display: flex; }
form.signout button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border);
}
form.signout button:hover { color: var(--foreground); text-decoration-color: currentColor; }
form.signout button:focus-visible {
  outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 2px;
}

/* --- die Fassung in der Fusszeile ----------------------------------------- */
/* Klein und beilaeufig: sie wird gesucht, wenn etwas nicht stimmt, und darf den Rest
   der Zeile nicht betonen. Monospace, damit "0.1.4" nicht wie Fliesstext aussieht. */
.version {
	font-family: var(--font-mono);
	font-size: 0.75rem;
	color: var(--muted-foreground);
	padding: 0.05rem 0.4rem;
	border: 1px solid var(--border);
	border-radius: 0.375rem;
	margin-left: 0.25rem;
}

/* --- ein Ergebnis auf- und zuklappen -------------------------------------- */
/* <details> statt eines Skripts. Der Marker der Sommerzeile wird ersetzt, weil das
   Standarddreieck je nach Browser anders sitzt und die Kopfzeile ein Flex-Element ist --
   ein `list-item` darin bricht die Ausrichtung. */
details.reg > summary {
	cursor: pointer;
	list-style: none;
	user-select: none;
}
details.reg > summary::-webkit-details-marker { display: none; }
details.reg > summary .addr::before {
	content: "\25B8";           /* zeigt nach rechts: zu */
	display: inline-block;
	width: 1em;
	margin-left: -1em;
	color: var(--muted-foreground);
	transition: transform 0.12s ease;
}
details.reg[open] > summary .addr::before { transform: rotate(90deg); }
details.reg > summary:focus-visible {
	outline: 2px solid var(--ring);
	outline-offset: 2px;
	border-radius: 0.375rem;
}
/* Zugeklappt traegt die Karte nur die Kopfzeile -- ohne das bleibt der Innenabstand der
   Tabelle als leerer Streifen stehen. */
details.reg:not([open]) > summary { margin-bottom: 0; }

/* --- Filterzeile und der Verwerfen-Knopf ---------------------------------- */
.filter { margin: -0.25rem 0 1rem 0; font-size: 0.8125rem; }
.filter a { color: var(--primary); }
form.inline { display: inline; margin: 0; }
td.right { text-align: right; }
.btn.small { padding: 0.15rem 0.6rem; font-size: 0.75rem; }

/* --- der Lizenztext ------------------------------------------------------- */
/* Vorformatiert, weil es Markdown ist und kein Fliesstext: Ueberschriften und Listen
   stehen im Quelltext, und genau der ist es, dem zugestimmt wurde. Umbrechen statt
   waagerecht scrollen -- ein Rechtstext liest sich sonst nicht. */
pre.terms {
	white-space: pre-wrap;
	word-break: break-word;
	max-height: 32rem;
	overflow-y: auto;
	background: var(--muted);
	border: 1px solid var(--border);
	border-radius: 0.5rem;
	padding: 1rem;
	font-family: var(--font-mono);
	font-size: 0.8125rem;
	line-height: 1.6;
	margin: 0.75rem 0 0 0;
}
