/* ---------------------------------------------------------------------------
   fX-Box Hub — Grundgestaltung
   Bewusst ohne externe Abhaengigkeiten (kein CDN, keine Webfonts von fremden
   Servern). Hell/Dunkel folgt der Systemeinstellung ueber prefers-color-scheme.
   --------------------------------------------------------------------------- */

:root {
  --bg:        #f4f5f7;
  --surface:   #ffffff;
  --surface-2: #eceef1;
  --border:    #d8dce2;
  --text:      #171a1f;
  --text-dim:  #5c6673;
  --accent:    #b8842a;
  --accent-fg: #ffffff;
  --ok:        #1f9254;
  --warn:      #b7791f;
  --error:     #c0392b;
  --info:      #2b6cb0;
  --radius:    10px;
  --shadow:    0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0e1116;
    --surface:   #161b22;
    --surface-2: #1e242d;
    --border:    #2b323c;
    --text:      #e8eaed;
    --text-dim:  #9aa4b2;
    --accent:    #e8b44a;
    --accent-fg: #16181d;
    --ok:        #3fb27f;
    --warn:      #e8b44a;
    --error:     #f0736a;
    --info:      #6aa9e8;
    --shadow:    0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Kopfzeile ----------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1.25rem;
  padding: .7rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; letter-spacing: .02em; font-size: 1.05rem; color: var(--text); }
.brand span { color: var(--accent); }
.topbar nav { display: flex; gap: .35rem; flex-wrap: wrap; flex: 1; }
.topbar nav a {
  padding: .35rem .7rem; border-radius: var(--radius);
  color: var(--text-dim); font-weight: 500;
}
.topbar nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.topbar nav a.active { background: var(--accent); color: var(--accent-fg); }
.topbar .user { color: var(--text-dim); font-size: .85rem; white-space: nowrap; }

main { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 .75rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
.lead { color: var(--text-dim); margin: 0 0 1.5rem; }

/* --- Karten -------------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem; margin-bottom: 1rem;
}
.card h2, .card h3 { margin-top: 0; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); }
.row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 220px; }
.row.tight > * { flex: 0 0 auto; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }

/* --- Kennzahlen ---------------------------------------------------------- */
.stats { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat { background: var(--surface-2); border-radius: var(--radius); padding: .75rem .9rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.stat .label { color: var(--text-dim); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }

/* --- Status -------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .12rem .55rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600;
  border: 1px solid currentColor;
}
.badge.ok    { color: var(--ok); }
.badge.warn  { color: var(--warn); }
.badge.error { color: var(--error); }
.badge.off   { color: var(--text-dim); }
.dot { width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }

.banner {
  border-radius: var(--radius); padding: .7rem .9rem; margin: .75rem 0;
  border-left: 4px solid var(--info); background: var(--surface-2);
}
.banner strong { display: block; }
.banner.warn  { border-left-color: var(--warn); }
.banner.error { border-left-color: var(--error); }
.banner.ok    { border-left-color: var(--ok); }
.banner p { margin: .2rem 0 0; color: var(--text-dim); font-size: .9rem; }

/* --- Fortschrittsbalken (Papierstand) ------------------------------------ */
.meter { height: .55rem; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: .35rem 0; }
.meter > span { display: block; height: 100%; background: var(--ok); border-radius: 999px; }
.meter.warn  > span { background: var(--warn); }
.meter.error > span { background: var(--error); }

/* --- Formulare ----------------------------------------------------------- */
label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-dim); margin-bottom: .2rem; }
input[type=text], input[type=password], input[type=number], input[type=color],
input[type=datetime-local], input[type=file], select, textarea {
  width: 100%; padding: .45rem .6rem;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit;
}
input[type=color] { padding: .15rem; height: 2.2rem; }
textarea { min-height: 5rem; resize: vertical; font-family: var(--sans); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.field { margin-bottom: .8rem; }
.check { display: flex; align-items: center; gap: .5rem; margin: .35rem 0; }
.check input { width: auto; }
.check label { margin: 0; font-weight: 500; color: var(--text); }
.hint { font-size: .8rem; color: var(--text-dim); margin-top: .15rem; }

button, .btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .45rem .9rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none;
}
button:hover, .btn:hover { border-color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn-danger  { color: var(--error); }
.btn-sm { padding: .25rem .6rem; font-size: .85rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }

/* --- Tabellen ------------------------------------------------------------ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--text-dim); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
code, .mono { font-family: var(--mono); font-size: .85em; }

/* --- Meldungen ----------------------------------------------------------- */
.flash { border-radius: var(--radius); padding: .6rem .9rem; margin-bottom: 1rem; font-weight: 500; }
.flash.ok    { background: color-mix(in srgb, var(--ok) 15%, var(--surface)); border: 1px solid var(--ok); }
.flash.error { background: color-mix(in srgb, var(--error) 15%, var(--surface)); border: 1px solid var(--error); }

/* --- Balken-/Verlaufsgrafik (reines SVG, kein Framework) ----------------- */
.chart { width: 100%; height: auto; display: block; }
.chart .axis  { stroke: var(--border); stroke-width: 1; }
.chart .line  { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .area  { fill: var(--accent); opacity: .12; }
.chart .bar   { fill: var(--accent); }
.chart text   { fill: var(--text-dim); font-size: 10px; font-family: var(--sans); }

/* --- Login --------------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-card { width: 100%; max-width: 360px; }

/* --- Template-Editor ----------------------------------------------------- */
.designer { display: grid; gap: 1rem; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.designer canvas { width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); touch-action: none; cursor: crosshair; }
.slot-list { list-style: none; margin: 0; padding: 0; }
.slot-list li { border: 1px solid var(--border); border-radius: 8px; padding: .5rem; margin-bottom: .5rem; }
.slot-list li.selected { border-color: var(--accent); }
.slot-list .coords { display: grid; grid-template-columns: repeat(4, 1fr); gap: .35rem; }
.slot-list .coords label { font-size: .7rem; }

@media (max-width: 860px) {
  .designer { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
  main { padding: 1rem .75rem 3rem; }
}
