/* =====================================================================
   NRWZ KundenManager – Design System (app.css)
   Eine zentrale Stylesheet-Quelle. Loest die ~30 Zeilen styles.css
   und die 3129 inline <font>-Tags des Altsystems ab.
   ===================================================================== */

/* ---- 1. Design-Tokens ------------------------------------------------ */
:root {
  --nrwz-orange:      #f39200;
  --nrwz-orange-dark: #d97e00;
  --nrwz-orange-soft: #fff4e3;

  --ink:        #1f2430;
  --ink-soft:   #4a5263;
  --muted:      #8a93a6;
  --line:       #e6e9f0;
  --bg:         #f4f6fa;
  --surface:    #ffffff;

  --ok:    #2e9e5b;
  --warn:  #e0a106;
  --error: #d23b3b;

  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 1px 2px rgba(20,30,50,.06), 0 6px 20px rgba(20,30,50,.06);
  --shadow-sm: 0 1px 2px rgba(20,30,50,.08);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---- 2. Reset / Basis ------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--nrwz-orange-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3 { color: var(--ink); margin: 0 0 .4em; line-height: 1.25; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; }

/* ---- 3. Marke -------------------------------------------------------- */
.wordmark { font-weight: 800; letter-spacing: -.5px; color: var(--ink); }
.wordmark-accent { color: var(--nrwz-orange); }

/* ---- 4. Topbar / Navigation ----------------------------------------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.topbar .wordmark { font-size: 1.25rem; }
.nav { display: flex; gap: 4px; margin-left: 12px; }
.nav a {
  padding: 8px 14px; border-radius: var(--radius-sm);
  color: var(--ink-soft); font-weight: 500; text-decoration: none;
}
.nav a:hover { background: var(--bg); }
.nav a.is-active { background: var(--nrwz-orange-soft); color: var(--nrwz-orange-dark); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }

/* ---- 5. Layout ------------------------------------------------------- */
.page { max-width: 1180px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.grid { display: grid; gap: 18px; }
.grid-kpi { grid-template-columns: repeat(4, 1fr); }

/* ---- 6. Karten ------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.kpi { padding: 18px 20px; }
.kpi-label { color: var(--muted); font-size: .82rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 1.85rem; font-weight: 750; margin-top: 6px; }
.kpi-foot { color: var(--muted); font-size: .82rem; margin-top: 4px; }

/* ---- 7. Tabellen ----------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th {
  text-align: left; color: var(--muted); font-weight: 600;
  font-size: .78rem; text-transform: uppercase; letter-spacing: .03em;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.table tbody tr:hover { background: var(--bg); }
.table tbody tr:last-child td { border-bottom: 0; }

/* ---- 8. Formulare ---------------------------------------------------- */
.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: .85rem; font-weight: 600;
  color: var(--ink-soft); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--nrwz-orange);
  box-shadow: 0 0 0 3px rgba(243,146,0,.15);
}

/* ---- 9. Buttons ------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  transition: background .15s, border-color .15s;
}
.btn-primary { background: var(--nrwz-orange); color: #fff; }
.btn-primary:hover { background: var(--nrwz-orange-dark); text-decoration: none; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink-soft); }
.btn-ghost:hover { background: var(--bg); }
.btn-block { width: 100%; justify-content: center; }

/* ---- 10. Badges / Alerts -------------------------------------------- */
.badge { display: inline-flex; padding: 3px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; }
.badge-ok    { background: #e6f5ec; color: var(--ok); }
.badge-warn  { background: #fdf3da; color: var(--warn); }
.badge-error { background: #fbe6e6; color: var(--error); }

.alert { padding: 12px 14px; border-radius: var(--radius-sm);
  font-size: .9rem; margin-bottom: 16px; }
.alert-error { background: #fbe6e6; color: var(--error);
  border: 1px solid #f3caca; }

/* ---- 11. Login ------------------------------------------------------- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 32px 28px;
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand .wordmark { font-size: 1.7rem; }
.login-sub { color: var(--muted); font-weight: 600; margin: 4px 0 0;
  letter-spacing: .02em; }
.login-foot { text-align: center; color: var(--muted);
  font-size: .8rem; margin: 22px 0 0; }

/* ---- 12. Responsive -------------------------------------------------- */
@media (max-width: 900px) {
  .grid-kpi { grid-template-columns: repeat(2, 1fr); }
  .nav { display: none; }
}
@media (max-width: 560px) {
  .page { padding: 20px 16px 48px; }
  .grid-kpi { grid-template-columns: 1fr; }
  .table { font-size: .85rem; }
}

/* ---- 13. Ergaenzungen: Listen-Toolbar, Pager, Formular-Raster ------- */
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.link-strong { font-weight: 600; color: var(--ink); }
.link-strong:hover { color: var(--nrwz-orange-dark); }

.toolbar { display: flex; gap: 8px; margin: 0 0 16px; max-width: 480px; }
.toolbar .input { flex: 1; }

.pager { display: flex; align-items: center; gap: 14px; margin-top: 18px; }
.pager-info { color: var(--muted); font-size: .88rem; }
.is-disabled { opacity: .45; pointer-events: none; }

.form-grid { display: grid; gap: 4px; max-width: 720px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
.field-error { display: block; color: var(--error); font-size: .8rem; margin-top: 4px; }
.field-checks { display: flex; flex-wrap: wrap; gap: 18px; margin: 4px 0 16px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: .92rem; color: var(--ink-soft); }
.form-foot { display: flex; align-items: center; justify-content: space-between;
  gap: 16px; border-top: 1px solid var(--line); padding-top: 16px; margin-top: 4px; flex-wrap: wrap; }

/* ---- 14. Kundenakte -------------------------------------------------- */
.head-actions { display: flex; gap: 8px; }
.akte-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; margin-bottom: 18px; }
.card-head h2 { margin: 0; font-size: 1.05rem; }

.datalist { display: grid; grid-template-columns: 130px 1fr; gap: 10px 16px;
  margin: 0; padding: 18px 20px; }
.datalist dt { color: var(--muted); font-size: .85rem; font-weight: 600; }
.datalist dd { margin: 0; }

.contact-list { list-style: none; margin: 0; padding: 6px 0; }
.contact-list li { padding: 12px 20px; border-bottom: 1px solid var(--line); }
.contact-list li:last-child { border-bottom: 0; }
.contact-name { font-weight: 600; }

.table .num, .num { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 800px) {
  .akte-grid { grid-template-columns: 1fr; }
}

/* ---- 15. Leerzustand / Fehlerseite ---------------------------------- */
.empty-state { text-align: center; padding: 64px 20px; }
.empty-state h1 { font-size: 3rem; color: var(--nrwz-orange); margin-bottom: 8px; }

/* ---- 16. Trend-Indikator (Dashboard-KPI) ---------------------------- */
.trend { font-weight: 700; font-variant-numeric: tabular-nums; }
.trend-up   { color: var(--ok); }
.trend-down { color: var(--error); }
.trend-flat { color: var(--muted); }

/* Zentrierung & maximale Breite (1200px) */
.wrap { max-width: 1200px; margin-left: auto; margin-right: auto; padding-top: 40px; padding-left: 20px; padding-right: 20px; }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 0 20px; height: 60px; display: flex; align-items: center; gap: 28px; }

/* Live-Autocomplete Kundensuche */
.ac-list { position:absolute; left:0; right:0; top:100%; z-index:30; background:#fff; border:1px solid var(--line); border-radius:8px; box-shadow:0 6px 20px rgba(0,0,0,.12); max-height:280px; overflow-y:auto; margin-top:4px; }
.ac-item { padding:8px 12px; cursor:pointer; font-size:.92rem; }
.ac-item:hover { background:var(--surface); }

.field-ac { position: relative; }

.btn-sm { padding: 4px 10px; font-size: 13px; line-height: 1.2; }

/* ---- Header / Topbar (ueberarbeitet) ---- */
.topbar-inner .wordmark {
  display: inline-flex; align-items: center;
  font-size: 1.2rem; font-weight: 800; letter-spacing: -.3px;
  color: var(--ink); text-decoration: none; white-space: nowrap;
  flex: 0 0 auto;
}
.topbar-inner .wordmark .wordmark-accent { color: var(--nrwz-orange); }
.topbar-inner .nav { display: flex; gap: 4px; margin-left: 4px; }
.topbar-inner .nav a {
  padding: 8px 14px; border-radius: var(--radius-sm);
  color: var(--ink-soft); font-weight: 500; text-decoration: none;
  line-height: 1; white-space: nowrap;
}
.topbar-inner .nav a:hover { background: var(--bg); color: var(--ink); }
.topbar-inner .nav a.is-active { background: var(--nrwz-orange-soft); color: var(--nrwz-orange-dark); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }
.nav-logout {
  padding: 7px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); color: var(--ink-soft);
  font-weight: 500; text-decoration: none; line-height: 1; white-space: nowrap;
}
.nav-logout:hover { background: var(--bg); color: var(--ink); }
