:root {
  --navy-900: #061529;
  --navy-800: #0a1f3c;
  --navy-700: #12325c;
  --navy-600: #1c4a82;
  --ink: #17202e;
  --muted: #5d6b7f;
  --line: #d9e0ea;
  --paper: #f3f6fa;
  --card: #ffffff;
  --amber: #f5a623;
  --amber-deep: #c9791a;
  --green: #1f9d6b;
  --shadow: 0 1px 2px rgba(10, 31, 60, .06), 0 8px 24px -12px rgba(10, 31, 60, .22);
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(rgba(28, 74, 130, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(28, 74, 130, .05) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Topbar ---------- */
.topbar {
  background: linear-gradient(135deg, var(--navy-800), var(--navy-700));
  color: #fff;
  border-bottom: 3px solid var(--amber);
  box-shadow: var(--shadow);
}
.topbar__inner {
  max-width: 1180px; margin: 0 auto; padding: 22px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 16px; }
.brand__mark {
  width: 40px; height: 40px; flex: none; border-radius: 9px;
  background:
    repeating-linear-gradient(45deg, var(--amber) 0 6px, var(--navy-900) 6px 12px);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.85);
}
.brand__text h1 {
  margin: 0; font-size: 1.35rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}
.brand__text p { margin: 3px 0 0; font-size: .82rem; color: #b9c7dc; letter-spacing: .02em; }

.topbar__right { display: flex; align-items: center; gap: 16px; }
.stats { display: flex; gap: 10px; }
.stat {
  min-width: 78px; padding: 8px 14px; border-radius: 10px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.stat__num { font-family: var(--mono); font-size: 1.3rem; font-weight: 700; line-height: 1; }
.stat__label { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: #a9bad2; }
.stat--done .stat__num { color: var(--amber); }
.stat--open .stat__num { color: #ff9a8b; }

/* ---------- Toolbar ---------- */
.toolbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(243, 246, 250, .86); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.toolbar__inner {
  max-width: 1180px; margin: 0 auto; padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
}
.langswitch {
  display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px;
}
.langswitch__btn {
  font-family: var(--sans); font-size: .82rem; font-weight: 600; color: var(--muted);
  border: none; background: transparent; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  transition: background .15s, color .15s;
}
.langswitch__btn:hover { color: var(--navy-700); }
.langswitch__btn.is-active { background: var(--navy-800); color: #fff; }

.search {
  flex: 1; min-width: 200px; max-width: 460px;
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 0 14px;
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--navy-600); box-shadow: 0 0 0 3px rgba(28,74,130,.12); }
.search svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search input {
  border: none; outline: none; width: 100%; padding: 11px 0; font-family: var(--sans); font-size: .92rem; background: transparent; color: var(--ink);
}
.toolbar__actions { display: flex; align-items: center; gap: 16px; }
.hint { font-size: .78rem; color: var(--muted); }
.btn {
  font-family: var(--sans); font-size: .85rem; font-weight: 600; letter-spacing: .02em;
  padding: 10px 16px; border-radius: 9px; border: 1px solid transparent; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px; transition: transform .1s, background .15s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn--ghost { background: #fff; color: var(--navy-700); border-color: var(--line); }
.btn--ghost:hover { border-color: var(--navy-600); color: var(--navy-800); }

/* ---------- App / sections ---------- */
.app { max-width: 1180px; margin: 0 auto; padding: 28px; }
.loading { padding: 60px; text-align: center; color: var(--muted); font-family: var(--mono); }

.section { margin-bottom: 34px; }
.section__head { display: flex; align-items: baseline; gap: 12px; margin: 0 0 14px; padding-bottom: 8px; border-bottom: 2px solid var(--navy-800); }
.section__title { font-size: 1.05rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--navy-800); margin: 0; }
.section__count { font-family: var(--mono); font-size: .8rem; color: var(--muted); }

/* ---------- Term card ---------- */
.term {
  display: grid; grid-template-columns: 1.05fr 1fr; gap: 0;
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--line);
  border-radius: 12px; margin-bottom: 12px; overflow: hidden; box-shadow: var(--shadow);
  transition: border-color .2s;
}
.term.is-edited { border-left-color: var(--amber); }
.term.is-hidden { display: none; }

.term__info { padding: 16px 20px; border-right: 1px dashed var(--line); }
.term__headline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.term__name { font-family: var(--mono); font-size: 1.08rem; font-weight: 700; color: var(--navy-800); }
.tag {
  font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  padding: 3px 8px; border-radius: 5px; color: #fff;
}
.tag--norm { background: #2c6e9b; }
.tag--typ { background: #7a4fb5; }
.tag--produkt { background: var(--navy-700); }
.tag--abkuerzung { background: #3c8f6d; }
.term__meta { margin-top: 6px; font-size: .74rem; color: var(--muted); font-family: var(--mono); letter-spacing: .02em; }
.term__context {
  margin-top: 10px; font-size: .82rem; line-height: 1.5; color: #40506a;
  background: #f6f8fb; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
.term__context mark { background: rgba(245,166,35,.32); color: inherit; padding: 0 2px; border-radius: 3px; font-weight: 600; }

.term__edit { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; background: #fbfcfe; }
.field__label { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); display: block; margin-bottom: 5px; }
.suggestion { font-family: var(--mono); font-size: .86rem; color: #40506a; }
.override-input {
  width: 100%; font-family: var(--mono); font-size: .9rem; color: var(--ink);
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; resize: vertical; min-height: 42px; line-height: 1.4;
  transition: border-color .15s, box-shadow .15s;
}
.override-input::placeholder { color: #9aa7b8; }
.override-input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px rgba(245,166,35,.18); }

.effective { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.effective__val { font-family: var(--mono); font-size: .82rem; color: var(--navy-700); }
.savestate { font-size: .72rem; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; opacity: 0; transition: opacity .2s; }
.savestate.show { opacity: 1; }
.savestate--saving { color: var(--muted); }
.savestate--saved { color: var(--green); }
.savestate--reset { color: var(--amber-deep); }
.linkbtn { background: none; border: none; padding: 0; cursor: pointer; font-family: var(--sans); font-size: .74rem; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.linkbtn:hover { color: var(--navy-700); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--navy-900); color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: .85rem; box-shadow: 0 12px 30px -10px rgba(0,0,0,.5); opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; border-left: 3px solid var(--amber);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 720px) {
  .term { grid-template-columns: 1fr; }
  .term__info { border-right: none; border-bottom: 1px dashed var(--line); }
}

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background-color: var(--navy-900);
  background-image:
    radial-gradient(1200px 600px at 70% -10%, rgba(28,74,130,.55), transparent 60%),
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: auto, 30px 30px, 30px 30px;
}
.login { width: 100%; max-width: 420px; }
.login__card {
  background: var(--card); border-radius: 16px; padding: 34px 32px;
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.6); border-top: 3px solid var(--amber);
}
.login__brand { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.login__brand h1 { margin: 0; font-size: 1.15rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--navy-800); }
.login__brand p { margin: 3px 0 0; font-size: .78rem; color: var(--muted); }
.login__form { display: flex; flex-direction: column; }
.login__input { margin-bottom: 16px; min-height: 46px; }
.login__btn {
  background: var(--navy-800); color: #fff; border: none; justify-content: center; padding: 13px; font-size: .95rem;
}
.login__btn:hover { background: var(--navy-700); }
.login__error {
  margin: -6px 0 14px; padding: 9px 12px; font-size: .82rem; color: #a12a1a;
  background: #fdece9; border: 1px solid #f4c9c1; border-radius: 8px;
}
.login__foot { margin: 20px 0 0; font-size: .72rem; color: var(--muted); text-align: center; }

/* Logout im Header */
.logout {
  color: #b9c7dc; font-size: .78rem; text-decoration: none; border: 1px solid rgba(255,255,255,.18);
  padding: 7px 12px; border-radius: 8px; transition: background .15s, color .15s;
}
.logout:hover { background: rgba(255,255,255,.08); color: #fff; }
