/* FLUXWERK – Designsystem. Module nutzen diese Klassen; eigene Styles in modules/<key>/style.css sind erlaubt. */
:root {
  --bg: #f3f6f7;
  --surface: #ffffff;
  --surface-2: #eef3f4;
  --border: #d9e2e5;
  --text: #0f2328;
  --muted: #526569;
  --brand: #0b3b4a;
  --brand-2: #0f5566;
  --accent: #0a7068; /* AA-Kontrast (≥ 4,5:1) mit weißer Schrift und auf --accent-soft */
  --accent-soft: #d5f3ef;
  --on-accent: #ffffff; /* Schrift auf Akzentflächen (Knöpfe, Zähler) */
  --warm: #e8650d;
  --warm-soft: #fde8d8;
  --warm-text: #9a3f08; /* Orange als Schrift (Badges) – lesbar auf hellem Grund */
  --danger: #c62828;
  --danger-soft: #fbe2e2;
  --ok: #256b29;
  --ok-soft: #dcf1dd;
  --info: #175e9e;
  --info-soft: #dbeafb;
  --radius: 14px;
  --radius-s: 9px;
  --shadow: 0 1px 2px rgb(15 35 40 / 6%), 0 4px 16px rgb(15 35 40 / 6%);
  --tap: 46px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1518; --surface: #12211f; --surface-2: #182b2c; --border: #24393b; --text: #e4eeef; --muted: #93a8ab;
    --brand: #0b3b4a; --brand-2: #135d6e; --accent: #22c3b4; --accent-soft: #123c39; --on-accent: #04201d; --warm: #ff8a3d; --warm-soft: #3d2614; --warm-text: #ff8a3d;
    --danger: #ff6b6b; --danger-soft: #3d1717; --ok: #5fcf72; --ok-soft: #173520; --info: #6aaef0; --info-soft: #14283d;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1518; --surface: #12211f; --surface-2: #182b2c; --border: #24393b; --text: #e4eeef; --muted: #93a8ab;
  --brand: #0b3b4a; --brand-2: #135d6e; --accent: #22c3b4; --accent-soft: #123c39; --on-accent: #04201d; --warm: #ff8a3d; --warm-soft: #3d2614; --warm-text: #ff8a3d;
  --danger: #ff6b6b; --danger-soft: #3d1717; --ok: #5fcf72; --ok-soft: #173520; --info: #6aaef0; --info-soft: #14283d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 15px; line-height: 1.45; background: var(--bg); color: var(--text); -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); }
small { font-size: .82rem; }
.ic { flex: none; }

/* Layout-Helfer */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.wrap { flex-wrap: wrap; }
.gap-s { gap: 8px; } .gap { gap: 14px; } .gap-l { gap: 22px; }
.grow { flex: 1; min-width: 0; }
.between { justify-content: space-between; }
.center { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px; }
.full { min-height: 100vh; }
.pad { padding: 24px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-2 { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.hide-mobile { } @media (max-width: 760px) { .hide-mobile { display: none !important; } }
.right { text-align: right; } .nowrap { white-space: nowrap; } .mono { font-variant-numeric: tabular-nums; }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 248px; flex: none; background: var(--brand); color: #dcebee; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { color: #fff; padding: 18px 18px 10px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; letter-spacing: .06em; color: var(--brand); }
.brand b { color: #22d3c5; font-weight: 800; }
.topbar .brand b, .login-card .brand b { color: var(--accent); } /* auf heller Fläche: Akzent statt Neon-Türkis */
.sidebar .muted { color: #a9c2c6; }
.tap-min { display: inline-flex; align-items: center; min-height: 44px; }
.brand.big { font-size: 1.6rem; justify-content: center; color: var(--text); }
.nav-group { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-group-title { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; opacity: .55; padding: 8px 10px 4px; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: inherit; min-height: 42px; background: none; border: 0; font: inherit; cursor: pointer; }
.sidebar .nav-link:hover { background: rgb(255 255 255 / 7%); }
.sidebar .nav-link.active { background: rgb(34 211 197 / 16%); color: #fff; box-shadow: inset 3px 0 0 #22d3c5; }
.sidebar-foot { margin-top: auto; padding: 14px; border-top: 1px solid rgb(255 255 255 / 10%); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-foot .icon-btn { color: #dcebee; }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.me > div { display: flex; flex-direction: column; min-width: 0; }
.me strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #22d3c5; color: #04161b; display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.content { flex: 1; }
.bottombar { display: none; }
.backdrop { display: none; }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .drawer-open .sidebar { transform: none; }
  .drawer-open .backdrop { display: block; position: fixed; inset: 0; background: rgb(0 0 0 / 40%); z-index: 30; }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top));
    position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); }
  .content { padding-bottom: 76px; }
  .bottombar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom); }
  .bottombar .nav-link { flex: 1; flex-direction: column; gap: 2px; font-size: .7rem; padding: 8px 2px; color: var(--muted); border-radius: 0; justify-content: center; }
  .bottombar .nav-link.active { color: var(--accent); }
}

/* Seiten */
.page { padding: 22px; max-width: 1280px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
@media (max-width: 760px) { .page { padding: 14px; } h1 { font-size: 1.3rem; } }

/* Karten */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
/* Kopf-Links der Kacheln („Öffnen“, „Alle“) als ausreichend große Tap-Fläche (Handschuh) */
.card-head .row > a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 6px; margin: -10px -6px; }
.card.flat { box-shadow: none; }
.card.clickable { cursor: pointer; transition: border-color .15s; } .card.clickable:hover { border-color: var(--accent); }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.stat-warn { border-color: var(--warm); background: var(--warm-soft); }
.stat-danger { border-color: var(--danger); background: var(--danger-soft); }
.stat-ok { border-color: var(--ok); background: var(--ok-soft); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 18px; border-radius: var(--radius-s);
  border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; transition: filter .15s, background .15s; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent); } .btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); } .btn-secondary:hover:not(:disabled) { border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--accent); } .btn-ghost:hover:not(:disabled) { background: var(--accent-soft); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warm { background: var(--warm); color: #fff; }
.btn-big { min-height: 64px; font-size: 1.1rem; border-radius: var(--radius); padding: 0 26px; }
.btn.block, .block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; border: 0; background: transparent; color: var(--text); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }

/* Formulare */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: .82rem; font-weight: 600; color: var(--muted); }
.field-hint { font-size: .78rem; color: var(--muted); }
.field-error { font-size: .78rem; color: var(--danger); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-s);
  min-height: var(--tap); padding: 0 12px; width: 100%; }
textarea { padding: 10px 12px; min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="checkbox"], input[type="radio"] { width: 22px; min-height: 22px; height: 22px; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); cursor: pointer; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.form-grid .span-all { grid-column: 1 / -1; }

/* Listen & Tabellen */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--border); color: inherit; min-height: 54px; }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr.clickable { cursor: pointer; } tr.clickable:hover td { background: var(--surface-2); }

/* Badges & Hinweise */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); } .badge-warn { background: var(--warm-soft); color: var(--warm-text); }
.badge-danger { background: var(--danger-soft); color: var(--danger); } .badge-info { background: var(--info-soft); color: var(--info); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.alert { padding: 12px 14px; border-radius: var(--radius-s); border: 1px solid; }
.alert-danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.alert-warn { background: var(--warm-soft); border-color: var(--warm); color: var(--warm-text); }
.alert-ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.alert-info { background: var(--info-soft); border-color: var(--info); color: var(--info); }
.empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 32px 16px; color: var(--muted); text-align: center; }
.empty p { margin: 0; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button { background: none; border: 0; font: inherit; padding: 10px 14px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; min-height: var(--tap); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .count { margin-left: 6px; font-size: .75rem; background: var(--surface-2); border-radius: 999px; padding: 1px 7px; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgb(5 20 25 / 55%); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border-radius: var(--radius); width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgb(0 0 0 / 30%); }
.modal.wide { width: min(920px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.modal-body { padding: 10px 16px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
@media (max-width: 760px) {
  .modal-backdrop { padding: 0; place-items: end stretch; }
  .modal, .modal.wide { width: 100%; max-height: 92vh; border-radius: var(--radius) var(--radius) 0 0; }
}

/* Toasts, Spinner */
.toasts { position: fixed; z-index: 60; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 900px) { .toasts { left: 16px; bottom: 84px; } }
.toast { background: var(--text); color: var(--surface); padding: 12px 16px; border-radius: var(--radius-s); box-shadow: var(--shadow); transition: opacity .3s, transform .3s; }
.toast-danger { background: var(--danger); color: #fff; } .toast-ok { background: var(--ok); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; display: inline-block; }
.spinner.sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 10% -10%, #135d6e 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #0f9f94 0%, transparent 55%), var(--brand); }
.login-card { width: min(400px, 100%); background: var(--surface); border-radius: 20px; padding: 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 30px 80px rgb(0 0 0 / 35%); }
.login-card p { text-align: center; margin: -6px 0 6px; }

/* Startseite */
.hero { background: linear-gradient(120deg, var(--brand), var(--brand-2)); color: #e8f4f5; border-radius: var(--radius); padding: 20px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: center; }
.hero h1 { color: #fff; }
.quick { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.quick a { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 600; min-height: 88px; }
.quick a .ic { color: var(--accent); }
.quick a:hover { border-color: var(--accent); }

/* Offline: Statusleiste, Hinweis „Stand von“, Warteschlange */
.top-sticky { position: sticky; top: 0; z-index: 20; }
.offline-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 12px;
  background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: .86rem; }
.offline-bar button { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 4px 10px; border: 0;
  border-radius: 999px; background: transparent; color: var(--muted); font: inherit; cursor: pointer; }
.offline-bar.off .offline-bar-main { color: var(--text); background: var(--warm-soft); }
.offline-bar.wait .offline-bar-main { color: var(--info); background: var(--info-soft); }
.offline-bar.sync .offline-bar-main { color: var(--accent); background: var(--accent-soft); }
.offline-bar.sync .offline-bar-main .ic { animation: spin 1.2s linear infinite; }
.offline-bar .offline-bar-failed { color: var(--danger); background: var(--danger-soft); }
.stale-note { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; padding: 4px 10px; border-radius: 999px;
  background: var(--warm-soft); color: var(--text); font-size: .82rem; }
.offline-item { align-items: flex-start; flex-wrap: wrap; }
.pending-tag { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--info-soft); color: var(--info); font-size: .75rem; }

/* Kopfzeile: Marke im hellen und dunklen Modus lesbar */
.topbar .brand { color: var(--text); }
