/* Meyer Control Center — Gestaltung der Verwaltungsoberflaeche.
 *
 * Ersetzt Pico CSS. Die Farbwerte liegen als Variablen vor, damit heller und
 * dunkler Modus dieselbe Struktur benutzen. Alle Bedienelemente der bisherigen
 * Oberflaeche haben hier eine Entsprechung — die Seiten behalten ihre
 * Funktionen, nur das Aussehen aendert sich.
 */

:root {
  --page: #f4f6f8;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --surface-hover: #f2f6ff;
  --sidebar: #ffffff;
  --text: #182230;
  --muted: #667085;
  --faint: #98a2b3;
  --line: #e6eaf0;
  --line-strong: #d5dbe5;
  --primary: #2457d6;
  --primary-2: #1b46b5;
  --primary-soft: #eef3ff;
  --success: #16845b;
  --success-soft: #eaf8f2;
  --warning: #b7791f;
  --warning-soft: #fff7e5;
  --danger: #c53b3b;
  --danger-soft: #fff0f0;
  --purple: #7047c7;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 10px 30px rgba(16, 24, 40, .045);
  --radius: 14px;
  --sidebar-w: 242px;
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

html[data-theme="dark"] {
  --page: #10141b;
  --surface: #171c25;
  --surface-alt: #1b212c;
  --surface-hover: #202838;
  --sidebar: #141922;
  --text: #f1f4f8;
  --muted: #a6b0bf;
  --faint: #758195;
  --line: #293241;
  --line-strong: #394456;
  --primary: #7aa2ff;
  --primary-2: #99b7ff;
  --primary-soft: rgba(76, 121, 234, .14);
  --success: #59c99d;
  --success-soft: rgba(22, 132, 91, .16);
  --warning: #e8b45b;
  --warning-soft: rgba(183, 121, 31, .15);
  --danger: #f27a7a;
  --danger-soft: rgba(197, 59, 59, .15);
  --shadow: 0 10px 30px rgba(0, 0, 0, .14);
}

* { box-sizing: border-box; }

body {
  margin: 0; min-height: 100vh;
  background: var(--page); color: var(--text);
  font-family: var(--font); font-size: 14px;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: 29px; letter-spacing: -.035em; }
h2 { font-size: 17px; letter-spacing: -.015em; }
h3 { font-size: 13px; }
small { font-size: 11px; }
code, pre, .mono { font-family: var(--mono); }
.muted { color: var(--muted); }

.icon { width: 19px; height: 19px; fill: none; stroke: currentColor;
        stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }

/* --- Seitenleiste --- */
.layout { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  padding: 20px 14px 16px; background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 40; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 26px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 10px; color: #fff;
  background: linear-gradient(135deg, var(--primary), #4b7bf2);
  display: grid; place-items: center; font-weight: 850;
  box-shadow: 0 7px 20px rgba(36, 87, 214, .22);
}
.brand strong { display: block; font-size: 14px; letter-spacing: -.01em; }
.brand span { color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.nav-group { margin-bottom: 18px; }
.nav-label { padding: 0 11px 7px; color: var(--faint); font-size: 9px;
             font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.nav { display: grid; gap: 3px; }
.nav a {
  color: var(--muted); min-height: 40px; border-radius: 9px; padding: 0 11px;
  display: flex; align-items: center; gap: 10px; text-decoration: none;
}
.nav a:hover { color: var(--text); background: var(--surface-alt); text-decoration: none; }
.nav a.active { color: var(--primary); background: var(--primary-soft); font-weight: 700; }
.nav a .count {
  margin-left: auto; min-width: 22px; padding: 2px 6px; border-radius: 999px;
  background: var(--surface-alt); color: var(--muted); text-align: center;
  font-size: 9px; font-weight: 700;
}
.sidebar-footer { margin-top: auto; }
.user { display: flex; align-items: center; gap: 9px; padding: 10px 7px 0; border-top: 1px solid var(--line); }
.avatar { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
          background: var(--primary-soft); color: var(--primary); font-weight: 800; }
.user strong { display: block; font-size: 11px; }
.user small { color: var(--muted); font-size: 9px; }
.user a { margin-left: auto; color: var(--muted); padding: 6px; }

/* --- Kopfzeile --- */
.main { margin-left: var(--sidebar-w); }
.topbar {
  height: 72px; position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(16px); border-bottom: 1px solid var(--line);
  padding: 0 30px; display: flex; align-items: center; justify-content: space-between;
}
.mobile { display: none; }
.top-left { display: flex; align-items: center; gap: 12px; }
.top-title { font-size: 13px; font-weight: 750; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--muted); display: grid; place-items: center;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); }
.live {
  height: 34px; padding: 0 10px; display: flex; align-items: center; gap: 7px;
  border-radius: 999px; color: var(--success); background: var(--success-soft);
  font: 650 10px var(--mono);
}
.live i { width: 6px; height: 6px; border-radius: 50%; background: currentColor;
          box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 18%, transparent); }

.content { padding: 30px; max-width: 1640px; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end;
             gap: 18px; margin-bottom: 23px; flex-wrap: wrap; }
.page-head p { margin: 0; color: var(--muted); font-size: 12px; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* --- Karten und Tafeln --- */
.card { background: var(--surface); border: 1px solid var(--line);
        border-radius: var(--radius); box-shadow: var(--shadow); }
article { background: var(--surface); border: 1px solid var(--line);
          border-radius: var(--radius); box-shadow: var(--shadow);
          padding: 18px; margin-bottom: 16px; }
article > header { margin: -18px -18px 16px; padding: 14px 18px;
                   border-bottom: 1px solid var(--line); }
article > footer { margin: 16px -18px -18px; padding: 14px 18px;
                   border-top: 1px solid var(--line); }
.panel { overflow: hidden; padding: 0; }
.panel-head { min-height: 58px; border-bottom: 1px solid var(--line); padding: 14px 16px;
              display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-head h2 { margin: 0 0 3px; }
.panel-head small { color: var(--muted); font-size: 9px; }

/* --- Kennzahlen --- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 13px; }
.kpi { padding: 17px; min-height: 132px; }
.kpi-head { display: flex; align-items: center; justify-content: space-between; }
.kpi-head span { color: var(--muted); font-size: 11px; font-weight: 650; }
.kpi-icon { width: 31px; height: 31px; display: grid; place-items: center;
            border-radius: 9px; color: var(--primary); background: var(--primary-soft); }
.kpi-value { margin: 17px 0 6px; font-size: 27px; letter-spacing: -.04em; font-weight: 770; }
.kpi-foot { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }

/* --- Bedienelemente --- */
button, input[type=submit], .btn, [role=button] {
  min-height: 36px; border-radius: 9px; padding: 0 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 12px; font-weight: 650;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
}
button:hover, .btn:hover { border-color: var(--primary); }
button.primary, input[type=submit], button[type=submit] {
  border-color: var(--primary); color: #fff; background: var(--primary);
}
html[data-theme="dark"] button.primary,
html[data-theme="dark"] button[type=submit] { color: #101828; }
button.outline, button.secondary { background: var(--surface); color: var(--muted); }
button.danger, button.contrast { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
button:disabled { opacity: .5; cursor: not-allowed; }
button[aria-busy="true"]::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: dreh .7s linear infinite;
}
@keyframes dreh { to { transform: rotate(360deg); } }

input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); padding: 9px 10px; color: var(--text);
  font-size: 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
input[type=checkbox], input[type=radio] { width: auto; }
label { display: block; color: var(--muted); font-size: 11px; margin-bottom: 5px; }
label > input, label > select, label > textarea { margin-top: 4px; }
fieldset { border: 0; padding: 0; margin: 0 0 12px; }

/* --- Tabellen --- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 14px; text-align: left; color: var(--faint);
     background: var(--surface-alt); border-bottom: 1px solid var(--line);
     font-size: 9px; text-transform: uppercase; letter-spacing: .12em; white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 12px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-hover); }

/* --- Zustandsanzeigen --- */
.status { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px;
          border-radius: 999px; font-size: 10px; font-weight: 700; }
.status.ok { color: var(--success); background: var(--success-soft); }
.status.warn { color: var(--warning); background: var(--warning-soft); }
.status.bad { color: var(--danger); background: var(--danger-soft); }
.status i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
mark { background: var(--warning-soft); color: var(--warning); padding: 2px 6px; border-radius: 6px; }

.bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--primary); }

/* --- Code und Ausgaben --- */
pre { border: 1px solid var(--line); border-radius: 11px; background: #101725; color: #d8e4f3;
      padding: 14px; font: 11px/1.65 var(--mono); overflow: auto; margin: 0 0 12px; }
code { font-size: 11px; }
:not(pre) > code { background: var(--surface-alt); border: 1px solid var(--line);
                   border-radius: 6px; padding: 2px 6px; }

details { border: 1px solid var(--line); border-radius: 11px; margin-bottom: 12px; overflow: hidden; }
details > summary { padding: 12px 14px; cursor: pointer; background: var(--surface-alt);
                    font-size: 12px; font-weight: 650; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸ "; color: var(--muted); }
details[open] > summary::before { content: "▾ "; }
details > *:not(summary) { padding: 0 14px; }
details > *:not(summary):last-child { padding-bottom: 14px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.container, .container-fluid { width: 100%; }

/* --- Anpassung an kleinere Bildschirme --- */
@media (max-width: 1160px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 820px) {
  :root { --sidebar-w: 0px; }
  .sidebar { width: 242px; transform: translateX(-102%); transition: .22s; }
  .sidebar.open { transform: translateX(0); }
  .mobile { display: grid; }
  .topbar { padding: 0 15px; }
  .content { padding: 20px 15px; }
}
@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .live { display: none; }
}
