/* Sophalcon-Designsystem fuer Login, Dashboards und Hubs.
   Tokens und Formensprache stammen aus dem Pilotkunden-Playbook (Charter/Avenir Next/
   SF Mono, Amber/Ink/Stone/Mist, Karten mit abgeschnittener Ecke). Alle Klassen tragen
   das Praefix "sx-", damit sie sich nicht mit Bootstrap in noch nicht migrierten
   Templates beissen. Hell ist der Standard, dunkel folgt prefers-color-scheme. */

:root {
  color-scheme: light dark;

  --ink: #1B2124;
  --stone: #E8E6DE;
  --mist: #F4F3EE;
  --surface: #FFFFFF;
  --amber: #C77A32;
  /* Abweichung vom Playbook (dort #FFF): Weiss auf diesem Amber erreicht nur ~3,4:1,
     Ink darauf ~4,7:1 - fuer Buttontext in normaler Groesse braucht es 4,5:1. */
  --amber-contrast: #1B2124;
  --slate: #4B5A63;
  --border: #DAD7CC;
  --success: #4B7A5A;
  --success-soft: #4B7A5A14;
  /* Semantische Warnfarbe, bewusst NICHT der Akzent */
  --danger: #A63D2F;
  --danger-soft: #A63D2F12;

  /* Kategorie-Palette (Mitarbeiter im Kalender, spaeter Diagramme): sechs unterscheidbare
     Toene, die zur Marke passen; --cat-none fuer "nicht zugeordnet". */
  --cat-1: #C77A32; --cat-2: #3E6E8E; --cat-3: #4B7A5A;
  --cat-4: #85587F; --cat-5: #A8473B; --cat-6: #5C6B73; --cat-none: #8A9397;

  --font-display: "Charter", "Iowan Old Style", Georgia, serif;
  --font-body: "Avenir Next", "Avenir", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #EDEAE2;
    --stone: #2A2F31;
    --mist: #1B1F21;
    --surface: #232829;
    --amber: #D68A45;
    --amber-contrast: #1B2124;
    --slate: #9AA7AC;
    --border: #383E40;
    --success: #7FAE8C;
    --success-soft: #7FAE8C1A;
    --danger: #E0786A;
    --danger-soft: #E0786A1A;
    --cat-1: #D68A45; --cat-2: #6FA3C4; --cat-3: #7FAE8C;
    --cat-4: #B58BAE; --cat-5: #D4776A; --cat-6: #9AA7AC; --cat-none: #738086;
  }
}

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

.sx-body {
  margin: 0;
  background: var(--mist);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15.5px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
.sx-body h1, .sx-body h2, .sx-body h3 {
  font-family: var(--font-display);
  font-weight: 400;
  text-wrap: balance;
  margin: 0;
}
.sx-body a { color: var(--slate); }
.sx-body a:hover { color: var(--ink); }
.sx-body a:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 2px; }

/* ---------- Bausteine ---------- */
.sx-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 28px;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%);
}

.sx-lockup { display: block; height: 44px; width: auto; overflow: visible; }
.sx-lockup text { font-family: Georgia, "Charter", "Iowan Old Style", serif; }
.sx-lockup-wing { fill: var(--amber); }
.sx-lockup-ink { fill: var(--ink); }
.sx-lockup-amber { fill: var(--amber); }

.sx-label {
  display: block;
  margin-bottom: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--slate);
}
.sx-input {
  width: 100%;
  padding: 11px 13px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--mist);
  border: 1px solid var(--border);
  border-radius: 3px;
}
.sx-input:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 1px;
  border-color: var(--amber);
  background: var(--surface);
}
/* Browser-Autofill faerbt Felder sonst gelb/blau und uebergeht das Theme */
.sx-input:-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 40px var(--mist) inset;
  caret-color: var(--ink);
}

.sx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.sx-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.sx-btn-primary { background: var(--amber); color: var(--amber-contrast); }
.sx-btn-primary:hover { filter: brightness(0.93); }
.sx-btn-block { width: 100%; }

.sx-alert {
  margin: 0 0 18px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--ink);
  background: var(--danger-soft);
  border-left: 3px solid var(--danger);
}
.sx-alert--success { background: var(--success-soft); border-left-color: var(--success); }

/* ---------- Anmeldeseite ---------- */
.sx-auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 32px 20px;
}
.sx-auth-card { width: 100%; max-width: 400px; padding: 32px 30px 30px; }
.sx-auth-card h1 { font-size: 30px; margin-top: 30px; }
.sx-auth-sub { margin: 6px 0 24px; color: var(--slate); font-size: 14.5px; }
.sx-auth-card .sx-field + .sx-field { margin-top: 16px; }
.sx-auth-card .sx-btn { margin-top: 24px; }

.sx-auth-foot {
  text-align: center;
  font-size: 12.5px;
  color: var(--slate);
}
.sx-auth-foot p { margin: 0 0 4px; }
.sx-auth-foot .sx-mono { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.03em; }
.sx-auth-foot a { text-underline-offset: 3px; }

@media (max-width: 420px) {
  .sx-auth-card { padding: 26px 22px 24px; }
}

/* ---------- Allgemein ---------- */
.sx-mono { font-family: var(--font-mono); }

.sx-btn-quiet { background: transparent; color: var(--slate); border-color: var(--border); }
.sx-btn-quiet:hover { color: var(--ink); border-color: var(--slate); }
.sx-btn-sm { padding: 6px 12px; font-size: 13px; }
.sx-btn[hidden] { display: none; }   /* display:inline-flex oben wuerde das hidden-Attribut sonst aushebeln */

.sx-textarea { resize: vertical; min-height: 96px; line-height: 1.5; }

.sx-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--slate);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.sx-chip:hover { color: var(--ink); border-color: var(--slate); }
.sx-chip[aria-pressed="true"], .sx-chip[aria-current="page"] { color: var(--ink); background: var(--surface); border-color: var(--ink); }
a.sx-chip { text-decoration: none; }
.sx-chip:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.sx-chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--slate)); }

/* ---------- App-Oberflaeche (Dashboards) ---------- */
.sx-topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 58px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.sx-topbar .sx-lockup { height: 30px; }
.sx-topbar-brand { display: block; line-height: 0; }
.sx-topbar-nav { display: flex; gap: 2px; margin-left: 6px; }
.sx-topbar-nav a {
  padding: 6px 11px;
  font-size: 14px;
  text-decoration: none;
  color: var(--slate);
  border-radius: 3px;
}
.sx-topbar-nav a:hover { color: var(--ink); background: var(--mist); }
.sx-topbar-nav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--amber); border-radius: 0; }
.sx-topbar-spacer { flex: 1; }
@media (max-width: 760px) {
  .sx-topbar { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 10px; }
  .sx-topbar-nav { max-width: 100%; margin-left: 0; overflow-x: auto; scrollbar-width: none; }
  .sx-topbar-nav a { white-space: nowrap; }
}
.sx-topbar-user { font-size: 13px; color: var(--slate); text-decoration: none; }
.sx-topbar-user:hover { color: var(--ink); text-decoration: underline; }
.sx-topbar-user .m { display: none; }

.sx-page { max-width: 1400px; margin: 0 auto; padding: 22px 24px 56px; }

@media (max-width: 640px) {
  .sx-topbar { padding: 0 14px; gap: 10px; }
  .sx-topbar-user .n { display: none; }
  .sx-topbar-user .m { display: inline; }
  .sx-page { padding: 16px 12px 40px; }
}

/* ---------- Dialoge ---------- */
.sx-dialog {
  width: min(440px, calc(100% - 32px));
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
}
.sx-dialog::backdrop { background: rgba(27, 33, 36, 0.5); }
.sx-dialog-inner { padding: 24px 26px; }
.sx-dialog h2 { font-size: 22px; margin-bottom: 16px; }
.sx-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.sx-dl { display: grid; grid-template-columns: auto 1fr; gap: 9px 18px; margin: 0; }
.sx-dl dt {
  padding-top: 3px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--slate);
}
.sx-dl dd { margin: 0; }

/* ---------- Pillen ---------- */
.sx-pill {
  display: inline-block;
  padding: 1px 7px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--slate);
  border: 1px solid var(--border);
  border-radius: 2px;
}
.sx-pill--danger { color: var(--danger); background: var(--danger-soft); border-color: var(--danger); }

/* ---------- Kennzahlen, Tabellen, Balken ---------- */
.sx-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}
.sx-stats--2 { grid-template-columns: repeat(2, 1fr); }
.sx-stats--4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .sx-stats--4 { grid-template-columns: repeat(2, 1fr); } }
.sx-stat { padding: 16px 22px 14px; background: var(--surface); }
.sx-stat .n { font-family: var(--font-display); font-size: 38px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sx-stat .l { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--slate); }
.sx-stat.is-alert .n { color: var(--danger); }
.sx-stat.is-ok .n { color: var(--success); }
@media (max-width: 640px) {
  .sx-stat { padding: 12px 14px 10px; }
  .sx-stat .n { font-size: 30px; }
}

.sx-table-wrap { overflow-x: auto; }
.sx-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.sx-table th {
  padding: 10px 16px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--slate);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.sx-table td { padding: 11px 16px; vertical-align: top; border-bottom: 1px solid var(--border); }
.sx-table tr:last-child td { border-bottom: 0; }
.sx-table .num { text-align: right; font-variant-numeric: tabular-nums; }

.sx-bars { display: grid; gap: 16px; margin: 0; padding: 0; list-style: none; }
.sx-bar-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; font-size: 14px; }
.sx-bar-val { font-family: var(--font-mono); font-size: 12.5px; color: var(--slate); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sx-bar-track { height: 8px; background: var(--stone); border-radius: 1px; overflow: hidden; }
.sx-bar-fill { height: 100%; background: var(--c, var(--slate)); }

/* ---------- Veraenderung (Vergleich zum Vorzeitraum) ---------- */
.sx-delta { display: inline-block; margin-top: 6px; font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--slate); }
.sx-delta--up { color: var(--success); }
.sx-delta--down { color: var(--danger); }
.sx-delta small { font-weight: 400; color: var(--slate); }

/* ---------- Liniendiagramm (static/sophalcon-charts.js) ---------- */
.sx-chart { position: relative; width: 100%; height: 280px; }
.sx-chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.sx-chart .grid { stroke: var(--border); stroke-width: 1; }
.sx-chart .axis { stroke: var(--slate); stroke-opacity: 0.55; stroke-width: 1; }
.sx-chart text { fill: var(--slate); font-family: var(--font-mono); font-size: 10.5px; }
.sx-chart .line { fill: none; stroke: var(--amber); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.sx-chart .area { fill: var(--amber); fill-opacity: 0.13; stroke: none; }
.sx-chart .dot { fill: var(--amber); stroke: var(--surface); stroke-width: 2; }
.sx-chart .guide { stroke: var(--slate); stroke-dasharray: 3 3; }
.sx-tip {
  position: absolute; z-index: 5; padding: 6px 10px; font-size: 12px; line-height: 1.35; white-space: nowrap;
  color: var(--surface); background: var(--ink); border-radius: 2px; pointer-events: none;
  transform: translate(-50%, -115%);
}
.sx-tip b { font-weight: 600; }
.sx-chart-empty { display: grid; place-items: center; height: 100%; color: var(--slate); font-size: 14px; }
