/* ============================================================
   Datenweiser – Design-System (Phase 1)
   Schrift: Manrope (variabel, lokal) · Zahlen/Aktenzeichen: Mono
   ============================================================ */

@font-face {
  font-family: 'Manrope';
  src: url('../fonts/manrope-var.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --ink: #16232e;
  --ink-soft: #51616e;
  --paper: #f4f6f5;
  --surface: #ffffff;
  --line: #e2e7e6;

  --brand: #0e5a63;
  --brand-deep: #0b3d44;
  --brand-soft: #e2eeef;
  --brand-ghost: #f0f6f6;

  --amber: #a86a12;
  --amber-bg: #fbf2e0;
  --green: #2c7a52;
  --green-bg: #e5f2ea;
  --red: #b0392f;
  --red-bg: #f9e9e7;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(22, 35, 46, .05), 0 4px 14px rgba(22, 35, 46, .06);

  --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', 'Consolas', monospace;
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  font-family: 'Manrope', system-ui, sans-serif;
  font-weight: 450;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}

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

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; font-weight: 750; letter-spacing: -.015em; }
h2 { font-size: 1.05rem; font-weight: 700; }
h3 { font-size: .95rem; font-weight: 700; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 3px; }

/* ---------- App-Rahmen ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, var(--brand-deep), #0d3239);
  color: #dcebe9;
  display: flex; flex-direction: column;
  padding: 1.1rem .9rem;
  position: sticky; top: 0; height: 100vh;
}

.brand {
  display: flex; align-items: baseline; gap: .45rem;
  padding: .2rem .55rem 1.1rem;
  color: #fff;
}
.brand strong { font-size: 1.12rem; font-weight: 800; letter-spacing: -.02em; }
.brand span { font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .14em; color: #9dc2be; }

.nav { display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: .6rem;
  padding: .52rem .6rem;
  border-radius: var(--radius-sm);
  color: #c6dbd8; font-weight: 600; font-size: .9rem;
}
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(255,255,255,.13); color: #fff; }
.nav .nav-label {
  margin: 1rem .6rem .3rem; font-size: .66rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .13em; color: #7fa5a1;
}
.nav svg { width: 17px; height: 17px; flex: none; opacity: .85; }

.sidebar-foot { border-top: 1px solid rgba(255,255,255,.12); padding-top: .8rem; font-size: .8rem; }
.sidebar-foot .who { color: #fff; font-weight: 700; }
.sidebar-foot .role { color: #9dc2be; font-size: .72rem; }
.sidebar-foot form { margin: .5rem 0 0; }
.sidebar-foot button {
  background: none; border: 1px solid rgba(255,255,255,.25); color: #dcebe9;
  padding: .3rem .7rem; border-radius: var(--radius-sm);
  font: inherit; font-size: .78rem; font-weight: 600; cursor: pointer;
}
.sidebar-foot button:hover { background: rgba(255,255,255,.1); }

.main { display: flex; flex-direction: column; min-width: 0; }

/* ---------- Topbar mit Schnellsuche ---------- */
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .8rem 1.6rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.quicksearch { flex: 1; max-width: 520px; position: relative; }
.quicksearch input {
  width: 100%;
  padding: .55rem .9rem .55rem 2.3rem;
  border: 1.5px solid var(--line);
  border-radius: 99px;
  font: inherit; font-size: .9rem;
  background: var(--paper);
  transition: border-color .15s, background .15s;
}
.quicksearch input:focus { border-color: var(--brand); background: #fff; outline: none; }
.quicksearch svg {
  position: absolute; left: .85rem; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--ink-soft); pointer-events: none;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .8rem; font-size: .85rem; }

.content { padding: 1.6rem; max-width: 1080px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; }
.page-head p { margin: .1rem 0 0; color: var(--ink-soft); font-size: .88rem; }

/* ---------- Karten & Tabellen ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.2rem;
}
.card > h2 { margin-bottom: .9rem; }
.card .card-hint { color: var(--ink-soft); font-size: .84rem; margin: -.5rem 0 1rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.2rem; box-shadow: var(--shadow);
}
.stat .num { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .lbl { font-size: .78rem; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .08em; }

table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th {
  text-align: left; font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .09em; color: var(--ink-soft);
  padding: .45rem .6rem; border-bottom: 1.5px solid var(--line);
}
td { padding: .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--brand-ghost); }

/* Signatur-Element: Aktenzeichen immer als Mono-Badge */
.az {
  font-family: var(--mono);
  font-size: .82rem; font-weight: 600;
  background: var(--brand-soft); color: var(--brand-deep);
  padding: .14rem .5rem; border-radius: 5px;
  white-space: nowrap;
}

.badge {
  display: inline-block; padding: .13rem .55rem; border-radius: 99px;
  font-size: .72rem; font-weight: 700;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-gray { background: var(--paper); color: var(--ink-soft); }

/* ---------- Formulare ---------- */
label { display: block; font-size: .82rem; font-weight: 700; margin-bottom: .3rem; }
.field { margin-bottom: 1rem; }
.field .help { font-size: .78rem; color: var(--ink-soft); margin-top: .25rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="color"], select, textarea {
  width: 100%;
  padding: .55rem .75rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit; font-size: .9rem;
  background: #fff;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: none; }
textarea { min-height: 150px; resize: vertical; line-height: 1.5; }
input[type="color"] { padding: .2rem; height: 42px; width: 90px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .88rem; font-weight: 600; }
.check input { width: auto; }

.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .55rem 1.1rem;
  border: none; border-radius: var(--radius-sm);
  background: var(--brand); color: #fff;
  font: inherit; font-size: .88rem; font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: var(--brand-deep); text-decoration: none; }
.btn-outline { background: transparent; color: var(--brand); border: 1.5px solid var(--brand); }
.btn-outline:hover { background: var(--brand-ghost); }
.btn-sm { padding: .35rem .8rem; font-size: .8rem; }

/* ---------- Meldungen ---------- */
.flash { padding: .75rem 1rem; border-radius: var(--radius-sm); font-size: .88rem; font-weight: 600; margin-bottom: 1rem; }
.flash-success { background: var(--green-bg); color: var(--green); }
.flash-error { background: var(--red-bg); color: var(--red); }
.flash-info { background: var(--brand-soft); color: var(--brand-deep); }

.empty {
  text-align: center; color: var(--ink-soft); padding: 2.2rem 1rem; font-size: .9rem;
}

/* ---------- Login ---------- */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(1100px 500px at 85% -10%, var(--brand-soft), transparent),
    var(--paper);
  padding: 1.5rem;
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 2rem 2.1rem;
}
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand strong { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; color: var(--brand-deep); }
.auth-brand div { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .15em; color: var(--ink-soft); margin-top: .15rem; }
.auth-card .btn { width: 100%; justify-content: center; margin-top: .3rem; }
.auth-foot { text-align: center; margin-top: 1.1rem; font-size: .8rem; color: var(--ink-soft); }

.code-input {
  font-family: var(--mono); font-size: 1.35rem !important; letter-spacing: .45em;
  text-align: center;
}

/* ---------- Tabs (Einstellungen) ---------- */
.tabs { display: flex; gap: .3rem; border-bottom: 1.5px solid var(--line); margin-bottom: 1.3rem; flex-wrap: wrap; }
.tabs a {
  padding: .5rem .9rem; font-size: .87rem; font-weight: 700; color: var(--ink-soft);
  border-bottom: 2.5px solid transparent; margin-bottom: -1.5px;
}
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- Responsiv ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: .5rem; padding: .7rem .9rem; }
  .brand { padding: 0 .5rem 0 0; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav .nav-label { display: none; }
  .sidebar-foot { border: none; padding: 0; margin-left: auto; display: flex; align-items: center; gap: .6rem; }
  .sidebar-foot .role { display: none; }
  .content { padding: 1rem; }
  .form-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
@media (max-width: 1000px) { .dash-cols { grid-template-columns: 1fr !important; } }
