/* =========================================================================
   Grundlage: Schriften, Farben (hell/dunkel), Buttons, Formulare, Meldungen
   ========================================================================= */

@font-face {
  font-family: "Newsreader";
  src: url("../fonts/newsreader-latin-opsz-normal.f94a697b1650.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-wght-normal.260c81a4759b.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-latin-400-normal.79936b18df9f.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-latin-500-normal.b1c8a895f5fd.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* feste Markenfarben (Startseite, Login-Grafik) */
  --frame: rgba(45, 43, 42, 0.2);          /* dünne Rahmen (Login-Karte) */
  --frame-strong: rgba(45, 43, 42, 0.3);   /* Felder, Zweitknopf */
  --ink: #2d2b2a;
  --ink-muted: #7a7670;
  --paper: #f5f2ed;
  --sky: #dcebf3;
  --signal: #2f6bff;   /* Akzent (Knöpfe, Menü-Strich, Zähler): Blau */

  /* App-Farben (hell) */
  --bg: #f7f6f6;
  --panel: #ffffff;
  --text: #1c1816;
  --muted: #938a84;
  --muted-2: #6f6762;
  --line: #e2e0de;
  --line-soft: #eeeceb;
  --hover: #f5f4f3;
  --active: #e2e0de;
  --seg: #ecebe9;
  --input: #ffffff;
  --btn-dark: #1c1816;
  --btn-dark-text: #ffffff;
  --pos: #2e7d32;
  --pos-soft: #e6f1e6;
  --neg: #b42318;
  --neg-soft: #fbe9e7;
  --warn: #9a5800;
  --warn-soft: #fbf0dc;
  --info: #2f5fb3;
  --info-soft: #e7eefb;
  --shadow-panel: 0 4px 6px rgba(49, 44, 41, 0.02), 0 1px 3px rgba(49, 44, 41, 0.05);
  --shadow-card: 0 1px 1px rgba(111, 103, 98, 0.06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1a18;
    --panel: #252120;
    --text: #f4f1ee;
    --muted: #938a84;
    --muted-2: #b2aaa4;
    --line: #3a3532;
    --line-soft: #312c2a;
    --hover: #2c2826;
    --active: #3a3532;
    --seg: #1d1a18;
    --input: #1d1a18;
    --btn-dark: #f4f1ee;
    --btn-dark-text: #1c1816;
    --pos: #7ccf80;
    --pos-soft: rgba(124, 207, 128, 0.12);
    --neg: #f58a7d;
    --neg-soft: rgba(245, 138, 125, 0.12);
    --warn: #f2b65a;
    --warn-soft: rgba(242, 182, 90, 0.12);
    --info: #8fb2f6;
    --info-soft: rgba(143, 178, 246, 0.12);
    --shadow-panel: 0 4px 6px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-card: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1d1a18;
  --panel: #252120;
  --text: #f4f1ee;
  --muted: #938a84;
  --muted-2: #b2aaa4;
  --line: #3a3532;
  --line-soft: #312c2a;
  --hover: #2c2826;
  --active: #3a3532;
  --seg: #1d1a18;
  --input: #1d1a18;
  --btn-dark: #f4f1ee;
  --btn-dark-text: #1c1816;
  --pos: #7ccf80;
  --pos-soft: rgba(124, 207, 128, 0.12);
  --neg: #f58a7d;
  --neg-soft: rgba(245, 138, 125, 0.12);
  --warn: #f2b65a;
  --warn-soft: rgba(242, 182, 90, 0.12);
  --info: #8fb2f6;
  --info-soft: rgba(143, 178, 246, 0.12);
  --shadow-panel: 0 4px 6px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-card: none;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; }
p { margin: 0 0 1em; }
code, .mono { font-family: var(--mono); letter-spacing: 0; }
.muted { color: var(--muted-2); }
.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; }

/* Körnung (für dunkle Flächen) */
.grain::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Logo ---------- */
.logo { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; }
.logo svg { width: 26px; height: 26px; flex: none; }
/* Schriftzug: [QVX] in Mono mit blauen Klammern, daneben Finance in Serifenschrift */
.wordmark { display: inline-flex; align-items: baseline; gap: 0.32em; font-size: 25px; line-height: 1; white-space: nowrap; }
.wm-mark { font-family: var(--mono); font-size: 0.84em; font-weight: 500; letter-spacing: 0.03em; }
.wm-mark b { font-weight: 500; color: var(--signal); }
.wm-rest { font-family: var(--serif); font-weight: 500; letter-spacing: -0.03em; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 32px; padding: 0 12px; border-radius: 6px; border: 1px solid transparent;
  font: inherit; font-size: 14px; font-weight: 500; letter-spacing: -0.01em; line-height: 1;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-dark { background: var(--btn-dark); color: var(--btn-dark-text); }
.btn-dark:hover { opacity: 0.88; }
.btn-outline { background: var(--panel); color: var(--text); border-color: var(--line); }
.btn-outline:hover { background: var(--hover); }
.btn-ghost { background: transparent; color: var(--muted-2); }
.btn-ghost:hover { color: var(--text); background: var(--hover); }
.btn-danger { background: transparent; color: var(--neg); border-color: color-mix(in srgb, var(--neg) 40%, transparent); }
.btn-danger:hover { background: var(--neg-soft); }
.btn-lg { height: 40px; padding: 0 18px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline-flex; margin: 0; }

/* ---------- Formulare ---------- */
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], select, textarea {
  width: 100%; height: 40px; padding: 0 12px;
  font: inherit; font-size: 14px; color: var(--text);
  background: var(--input); border: 1px solid var(--line); border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; }
select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23938a84' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--muted); box-shadow: 0 0 0 3px color-mix(in srgb, var(--muted) 22%, transparent); }
input.mono { font-family: var(--mono); font-size: 13px; letter-spacing: 0; }
.field-check > label { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 13px; line-height: 1.45; color: var(--muted-2); cursor: pointer; }
.field-check input { flex: none; width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--text); }
.help { font-size: 12px; color: var(--muted-2); margin: 6px 0 0; }
.error { font-size: 12px; color: var(--neg); margin: 6px 0 0; }
.has-error input:not([type="checkbox"]), .has-error select, .has-error textarea { border-color: var(--neg); }
.form-error { background: var(--neg-soft); color: var(--neg); border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 16px; }

/* ---------- Meldungen ---------- */
.alert { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 12px; border: 1px solid var(--line); background: var(--panel); }
.alert::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.alert-success::before { background: var(--pos); }
.alert-error::before { background: var(--neg); }
.alert-warning::before, .alert-info::before { background: var(--warn); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-waiting_ip, .badge-key_submitted { background: var(--warn-soft); color: var(--warn); }
.badge-waiting_key { background: var(--info-soft); color: var(--info); }
.badge-active { background: var(--pos-soft); color: var(--pos); }
.badge-paused, .badge-off { background: var(--hover); color: var(--muted-2); }
/* Rechnungen */
.badge-inv-open { background: var(--warn-soft); color: var(--warn); }
.badge-inv-processing { background: var(--info-soft); color: var(--info); }
.badge-inv-paid { background: var(--pos-soft); color: var(--pos); }
.badge-inv-cancelled { background: var(--hover); color: var(--muted-2); }

/* ---------- Segment-Schalter (Sprache, Theme, Filter) ---------- */
.seg { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: 8px; background: var(--seg); border: 1px solid var(--line-soft); }
.seg > *, .seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 28px; height: 26px; padding: 0 6px; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); font: inherit; font-size: 12px; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.seg svg { width: 15px; height: 15px; }
.seg > *:hover, .seg button:hover { color: var(--text); }
.seg [aria-pressed="true"], .seg [aria-current="true"], .seg .is-on {
  background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(28, 24, 22, 0.1);
}
.seg form { display: contents; }
