:root {
  --brand: #0095d6;
  --brand-dark: #0077ad;
  --hero: #003a54;
  --ink: #1a2332;
  --muted: #5a6a7a;
  --line: #d0d7de;
  --panel: #ffffff;
  --bg: #e8eef3;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --danger: #b42318;
  --ok: #15803d;
  --warn: #a16207;
  --font: "Segoe UI", "Source Sans 3", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, #f4f7fa 0%, var(--bg) 100%);
  min-height: 100vh;
}

a { color: var(--brand-dark); }

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .65rem 1rem;
  background: linear-gradient(90deg, var(--hero), var(--brand));
  color: #fff;
}
.app-header a { color: #fff; text-decoration: none; font-weight: 600; }
.app-header__nav { display: flex; gap: 1rem; align-items: center; font-size: .9rem; }

.app-main { padding: 0; max-width: none; margin: 0; }

.flash {
  margin: .75rem 1rem;
  padding: .65rem .9rem;
  border-radius: 4px;
  background: #fff;
  border-left: 4px solid var(--brand);
}
.flash--error { border-left-color: var(--danger); }
.flash--success { border-left-color: var(--ok); }

.login {
  max-width: 420px;
  margin: 3rem auto;
  padding: 1.75rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.login h1 { margin-top: 0; color: var(--brand-dark); }
.login__lead { color: var(--muted); }
.login__form, .stack-form, .field { display: grid; gap: .35rem; }
.login__form label, .stack-form label { font-size: .85rem; font-weight: 600; }
.field__label { font-size: .78rem; font-weight: 700; color: var(--ink); }
.field__hint { font-size: .72rem; color: var(--muted); }
.field__input, input, select, textarea, button {
  font: inherit;
  padding: .45rem .55rem;
  border: 1px solid var(--line);
  border-radius: 6px;
}
button, .btn {
  background: var(--brand);
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
  padding: .45rem .85rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  border-radius: 6px;
}
.btn--ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn--accent { background: var(--brand); }
.btn--sm { padding: .28rem .55rem; font-size: .8rem; }
.btn--block { width: 100%; justify-content: center; }
.btn-danger, .btn--danger { background: var(--danger); }
button:hover, .btn:hover { filter: brightness(.95); }

.einsatz-list { padding: 1rem 1.25rem 2rem; max-width: 1100px; margin: 0 auto; }
.einsatz-list__head { display: flex; justify-content: space-between; align-items: center; }
.einsatz-cards { list-style: none; padding: 0; display: grid; gap: .5rem; }
.einsatz-cards a {
  display: grid; gap: .15rem; padding: .75rem 1rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: inherit; box-shadow: var(--shadow-sm);
}
.einsatz-form { padding: 1rem 1.25rem; max-width: 560px; margin: 0 auto; }

/* ===== Layout B (Onboarding-analog): Toolbar + Stamm | Editor + Timeline ===== */
body.etb-edit-page .app-main { padding: 0; }
body.etb-edit-page .app-header { display: none; }

.etb-app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

.etb-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-shrink: 0;
}
.etb-toolbar__left { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.etb-toolbar__title { margin: 0; font-size: 1.05rem; }
.etb-toolbar__sub { margin: .15rem 0 0; font-size: .78rem; color: var(--muted); }
.etb-toolbar__right { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.etb-sync-pill { font-size: .72rem; font-weight: 600; color: var(--ok); }
.etb-sync-pill.is-busy { color: var(--brand-dark); }
.etb-sync-pill.is-err { color: var(--danger); }
.etb-draft-hint { font-size: .7rem; color: var(--warn); }

.etb-workspace {
  display: flex;
  gap: .65rem;
  padding: .65rem .75rem;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

.etb-stamm {
  width: 270px;
  flex-shrink: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.etb-stamm__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem .85rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #fafbfc);
  cursor: pointer;
  list-style: none;
}
.etb-stamm__head::-webkit-details-marker { display: none; }
.etb-stamm__head h2 { margin: 0; font-size: .88rem; font-weight: 700; }
.etb-stamm__toggle-hint { font-size: .68rem; color: var(--muted); }
.etb-stamm__grid {
  margin: 0;
  padding: .75rem .85rem;
  display: flex;
  flex-direction: column;
  gap: .65rem;
  overflow: auto;
  flex: 1;
}
.etb-stamm__save { margin-top: .15rem; }

.etb-stage {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: .65rem;
  min-height: 0;
  align-items: start;
}

.etb-editor, .etb-timeline {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.etb-editor {
  background: #fafbfc;
  max-height: 100%;
  overflow: auto;
}
.etb-timeline {
  height: 100%;
  align-self: stretch;
}

.etb-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .75rem .9rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #fafbfc);
}
.etb-panel-head h2 { margin: 0; font-size: .88rem; font-weight: 700; }
.etb-hint { font-size: .72rem; color: var(--muted); }

.etb-entry-form { padding: .75rem .9rem 1rem; display: grid; gap: .65rem; }
.etb-excel-head {
  display: grid;
  grid-template-columns: 4.5rem 5.5rem 1fr 1fr;
  gap: .5rem;
  font-size: .68rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.etb-entry-form__row--system {
  display: grid;
  grid-template-columns: 4.5rem 5.5rem 1fr 1fr;
  gap: .5rem;
  align-items: start;
}
.etb-field--system { background: #f1f5f9; color: var(--muted); }
.etb-field--inhalt { min-height: 7rem; resize: vertical; }
.etb-typ-picker, .etb-absender-quick { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .35rem; }
.etb-typ-picker__btn, .etb-absender-quick__btn {
  background: #f8fafc;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: .28rem .5rem;
  font-size: .78rem;
  font-weight: 700;
}
.etb-typ-picker__btn.is-active {
  background: #fff7ed;
  border-color: #fdba74;
  color: #9a3412;
}
.etb-entry-form__actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: flex-end;
  align-items: center;
}
.etb-error { color: var(--danger); margin: 0; font-size: .85rem; }

.etb-tl {
  list-style: none;
  margin: 0;
  padding: .65rem .5rem .75rem;
  overflow: auto;
  flex: 1;
  position: relative;
}
.etb-tl::before {
  content: "";
  position: absolute;
  left: 1.15rem;
  top: .5rem;
  bottom: .5rem;
  width: 2px;
  background: linear-gradient(180deg, var(--brand), var(--line));
  border-radius: 2px;
}
.etb-tl__item {
  position: relative;
  display: grid;
  grid-template-columns: 1.8rem 3.1rem 1fr;
  gap: .55rem;
  padding: .45rem .35rem .45rem .15rem;
  margin-bottom: .25rem;
  border-radius: 12px;
  cursor: pointer;
}
.etb-tl__item::before {
  content: "";
  position: absolute;
  left: .92rem;
  top: 1.05rem;
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--line);
  z-index: 1;
}
.etb-tl__item:hover { background: #f8fafc; }
.etb-tl__item.is-active {
  background: #fff7ed;
  box-shadow: inset 3px 0 0 var(--brand);
}
.etb-tl__item.is-active::before {
  border-color: var(--brand);
  background: var(--brand);
}
.etb-tl__nr {
  font-size: .72rem;
  font-weight: 800;
  color: var(--muted);
  padding-top: .4rem;
  text-align: right;
}
.etb-tl__time {
  font-size: .82rem;
  font-weight: 800;
  color: var(--hero);
  padding-top: .35rem;
  text-align: right;
}
.etb-tl__content { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.etb-tl__label {
  font-size: .82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.etb-tl__meta { font-size: .72rem; color: var(--muted); }
.etb-empty { padding: 1rem; color: var(--muted); font-size: .85rem; }

@media (max-width: 1100px) {
  .etb-app { height: auto; min-height: 100dvh; overflow: auto; }
  .etb-workspace { flex-direction: column; overflow: auto; }
  .etb-stamm { width: 100%; max-height: none; }
  .etb-stamm__grid { display: grid; grid-template-columns: 1fr 1fr; }
  .etb-stamm__save { grid-column: 1 / -1; }
  .etb-stage { grid-template-columns: 1fr; }
  .etb-timeline { max-height: 360px; }
  .etb-entry-form__row--system, .etb-excel-head { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .etb-stamm__grid, .etb-entry-form__row--system, .etb-excel-head { grid-template-columns: 1fr; }
  .etb-excel-head { display: none; }
}

/* ===== App-Shell / linke Hauptnavigation ===== */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100dvh;
}
.app-nav {
  background: linear-gradient(180deg, var(--hero) 0%, #002a3d 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 1rem .85rem;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow: auto;
}
.app-nav__brand {
  display: flex;
  gap: .65rem;
  align-items: center;
  margin-bottom: 1.25rem;
  padding: .25rem .35rem;
}
.app-nav__logo {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 8px;
  background: var(--brand);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: .85rem;
}
.app-nav__brand strong { display: block; font-size: .95rem; }
.app-nav__brand small { color: rgba(255,255,255,.72); font-size: .72rem; }
.app-nav__links { display: flex; flex-direction: column; gap: .2rem; flex: 1; }
.app-nav__links a,
.app-nav__muted {
  color: rgba(255,255,255,.88);
  text-decoration: none;
  padding: .45rem .65rem;
  border-radius: 6px;
  font-size: .88rem;
  font-weight: 600;
}
.app-nav__muted { opacity: .45; cursor: default; }
.app-nav__links a:hover { background: rgba(255,255,255,.1); }
.app-nav__links a.is-active {
  background: rgba(0,149,214,.35);
  box-shadow: inset 3px 0 0 #fff;
}
.app-nav__section {
  margin: .85rem .35rem .35rem;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: rgba(255,255,255,.55);
  font-weight: 700;
}
.app-nav__footer {
  border-top: 1px solid rgba(255,255,255,.15);
  padding-top: .75rem;
  margin-top: .75rem;
  font-size: .82rem;
}
.app-nav__footer a { color: #fff; }
.app-nav__user { font-weight: 700; margin-bottom: .35rem; }

.app-content { min-width: 0; display: flex; flex-direction: column; min-height: 100dvh; }
.app-topbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.app-topbar__title { font-size: 1.15rem; font-weight: 700; }
.app-main { padding: 1rem 1.25rem 2rem; flex: 1; }
.app-main--login {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at top, rgba(0,149,214,.18), transparent 55%),
    linear-gradient(180deg, #f4f7fa, var(--bg));
}
.app-nav-toggle { display: none; }
.app-nav-toggle--float {
  position: fixed;
  top: .65rem;
  left: .65rem;
  z-index: 40;
}

.app-shell--etb { height: 100dvh; overflow: hidden; }
.app-shell--etb .app-content { min-height: 0; height: 100dvh; }
.app-main--etb { padding: 0; min-height: 0; height: 100%; overflow: hidden; }
.app-shell--etb .etb-app { height: 100%; min-height: 0; }

.login__brand {
  color: var(--brand);
  font-weight: 800;
  letter-spacing: .04em;
  font-size: .9rem;
  margin-bottom: .35rem;
}

.module-page { max-width: 720px; }
.module-page__lead { color: var(--muted); font-size: 1.02rem; }
.module-page__list { line-height: 1.6; }
.module-page__note { color: var(--muted); font-size: .85rem; }

.admin-cards { list-style: none; padding: 0; display: grid; gap: .65rem; max-width: 640px; }
.admin-cards a, .admin-cards__soon {
  display: grid; gap: .2rem; padding: .9rem 1rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: inherit; box-shadow: var(--shadow-sm);
}
.admin-cards__soon { opacity: .65; }

.admin-users__head, .einsatz-list__head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem;
}
.einsatz-list__lead { margin: 0; color: var(--muted); }
.table-wrap { overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th, .data-table td { text-align: left; padding: .65rem .75rem; border-bottom: 1px solid var(--line); }
.data-table th { background: #f8fafc; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.data-table tr.is-inactive { opacity: .55; }
.badge { font-size: .72rem; padding: .15rem .4rem; border-radius: 4px; background: #eef2f6; }
.badge--muted { color: var(--muted); }

.panel-form {
  max-width: 480px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.form-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .5rem; }
.check-row { display: flex !important; flex-direction: row !important; align-items: center; gap: .5rem; }
.field-readonly { margin: .35rem 0; }

/* Preview */
.etb-preview-page { margin: 0; background: #f4f7fa; }
.etb-preview { max-width: 900px; margin: 0 auto; padding: 1rem; }
.etb-preview__head {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .85rem 1rem; background: linear-gradient(90deg, var(--hero), var(--brand));
  color: #fff; border-radius: var(--radius); margin-bottom: .75rem;
}
.etb-preview__head span { display: block; font-size: .82rem; opacity: .9; }
.etb-preview__stamm {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .75rem 1rem; margin-bottom: .75rem;
}
.etb-preview__stamm dt { font-size: .7rem; color: var(--muted); font-weight: 700; }
.etb-preview__stamm dd { margin: .15rem 0 0; font-weight: 600; }
.etb-preview__list { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; }
.etb-preview__list li {
  display: grid; grid-template-columns: 2.5rem 3rem 2.5rem 3rem 1fr; gap: .5rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .65rem .75rem;
}
.etb-preview__list .nr, .etb-preview__list .time { font-weight: 800; color: var(--hero); }
.etb-preview__list .typ, .etb-preview__list .abs { font-weight: 700; font-size: .85rem; }
.etb-preview__list .body { grid-column: 1 / -1; white-space: pre-wrap; }
.etb-preview__foot {
  margin-top: 1rem; padding: .75rem; text-align: center; font-weight: 700;
  background: #fff7ed; border: 1px solid #fdba74; border-radius: var(--radius);
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-nav {
    position: fixed; inset: 0 auto 0 0; width: min(280px, 88vw); z-index: 50;
    transform: translateX(-105%); transition: transform .2s ease;
  }
  body.nav-open .app-nav { transform: translateX(0); box-shadow: 8px 0 24px rgba(0,0,0,.25); }
  body.nav-open::after {
    content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 45;
  }
  .app-nav-toggle { display: inline-flex; }
  .app-shell--etb { height: auto; overflow: auto; }
  .app-shell--etb .app-content, .app-main--etb, .app-shell--etb .etb-app { height: auto; min-height: 100dvh; }
  .etb-preview__list li { grid-template-columns: 2rem 2.5rem 2rem 2.5rem; }
  .etb-preview__stamm { grid-template-columns: 1fr; }
}

