/* =====================================================================
   Kunden KI – Admin Dashboard
   Design-System: Creme/Weiss, dunkle Schrift, Gruen/Tuerkis Akzent,
   dezente Glows, moderne Karten, runde Buttons, Ampel-Badges.
   ===================================================================== */

:root {
  --cream: #f6f4ee;
  --cream-2: #efece3;
  --white: #ffffff;
  --ink: #14201c;
  --ink-soft: #3a4944;
  --muted: #7c8a84;
  --line: #e3e0d6;

  --green: #18b87b;
  --green-deep: #0f9a66;
  --teal: #15c5b8;
  --accent-grad: linear-gradient(135deg, #18b87b 0%, #15c5b8 100%);

  --amp-green: #1eb980;
  --amp-yellow: #e6a51a;
  --amp-red: #e3553b;
  --amp-grey: #aab3ae;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --shadow: 0 6px 24px rgba(20, 32, 28, 0.07);
  --shadow-lg: 0 14px 44px rgba(20, 32, 28, 0.12);
  --glow: 0 0 0 1px rgba(24, 184, 123, 0.12), 0 10px 40px rgba(21, 197, 184, 0.16);
  --sidebar-w: 248px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

/* Versteckte Elemente bleiben verborgen – auch wenn ihre Klasse display:grid/flex setzt.
   (Steuert Modal, Lade-Overlay, App-Gerüst und Toast korrekt aus.) */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--cream);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

h1, h2, h3, h4 { margin: 0 0 .2em; font-weight: 700; letter-spacing: -0.01em; }
a { color: var(--green-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
small { color: var(--muted); }

/* ---------- Logo / Glow ---------- */
.logo-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent-grad);
  box-shadow: 0 0 14px rgba(21, 197, 184, .7);
  display: inline-block; flex: none;
}
.glow { box-shadow: var(--glow), var(--shadow-lg); }

/* ===================================================================
   AUTH (login / invite)
   =================================================================== */
.auth-body {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(21,197,184,.14), transparent 60%),
    radial-gradient(800px 500px at 110% 110%, rgba(24,184,123,.14), transparent 60%),
    var(--cream);
}
.auth-card {
  width: 100%; max-width: 410px; background: var(--white);
  border-radius: 22px; padding: 36px 32px; border: 1px solid var(--line);
}
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand .logo-dot { width: 18px; height: 18px; margin-bottom: 12px; }
.auth-brand h1 { font-size: 26px; }
.auth-sub { color: var(--muted); margin: 0; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.auth-error { color: var(--amp-red); font-size: 13px; min-height: 1em; margin: 4px 0 0; }
.auth-info { text-align: center; color: var(--muted); padding: 12px 0; }
.auth-foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 18px; }
.invite-meta { background: var(--cream); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--white);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 13px; width: 100%; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(24,184,123,.15);
}
textarea { resize: vertical; min-height: 70px; }
input[readonly] { background: var(--cream-2); color: var(--ink-soft); }

/* ===================================================================
   BUTTONS
   =================================================================== */
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border: none;
  border-radius: var(--radius-pill); padding: 11px 20px;
  transition: transform .12s ease, box-shadow .15s ease, background .15s, opacity .15s;
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent-grad); color: #fff; box-shadow: 0 8px 22px rgba(24,184,123,.28); }
.btn-primary:hover { box-shadow: 0 10px 28px rgba(24,184,123,.4); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--cream-2); }
.btn-danger { background: #fdece8; color: var(--amp-red); }
.btn-danger:hover { background: #fbded6; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.icon-btn {
  background: transparent; border: none; font-size: 18px; cursor: pointer;
  color: var(--ink-soft); width: 38px; height: 38px; border-radius: var(--radius-sm);
}
.icon-btn:hover { background: var(--cream-2); }

/* ===================================================================
   APP SHELL
   =================================================================== */
.app-loading {
  position: fixed; inset: 0; display: flex; gap: 12px; align-items: center;
  justify-content: center; color: var(--muted); font-weight: 600;
}
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--white); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 18px; }
.brand strong { display: block; font-size: 16px; }
.brand small { display: block; color: var(--muted); font-size: 12px; }

.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 13px;
  border-radius: var(--radius-sm); color: var(--ink-soft); font-weight: 600;
  font-size: 14px; text-decoration: none; transition: background .12s, color .12s;
}
.nav a .nav-ic { width: 18px; text-align: center; opacity: .9; }
.nav a:hover { background: var(--cream-2); text-decoration: none; }
.nav a.active { background: var(--cream); color: var(--green-deep); }
.nav a.active::before {
  content: ""; position: absolute; left: 0; width: 3px; height: 22px;
  background: var(--accent-grad); border-radius: 3px; margin-left: -14px;
}
.nav a { position: relative; }

.sidebar-foot { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.user-chip { font-size: 13px; color: var(--ink-soft); }
.user-chip strong { display: block; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 16px 26px;
  background: rgba(246,244,238,.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 19px; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.role-badge {
  background: var(--cream-2); color: var(--ink-soft); padding: 5px 12px;
  border-radius: var(--radius-pill); font-size: 12px; font-weight: 700;
}
.content { padding: 24px 26px 60px; max-width: 1280px; width: 100%; }

/* ===================================================================
   CARDS / KPI
   =================================================================== */
.card {
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  transition: transform .14s, box-shadow .14s;
}
.card.hoverable:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.section { margin-bottom: 30px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.section-head h3 { font-size: 17px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.kpi {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; right: -30px; top: -30px; width: 80px; height: 80px;
  background: radial-gradient(circle, rgba(21,197,184,.12), transparent 70%);
}
.kpi .kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi .kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; }
.kpi .kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.green .kpi-value { color: var(--amp-green); }
.kpi.red .kpi-value { color: var(--amp-red); }
.kpi.yellow .kpi-value { color: var(--amp-yellow); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* ===================================================================
   BADGES / AMPEL
   =================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px;
  border-radius: var(--radius-pill); font-size: 12px; font-weight: 700; white-space: nowrap;
}
.badge.soft { background: var(--cream-2); color: var(--ink-soft); }

.amp { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; font-size: 12.5px; }
.amp-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.amp.gruen  .amp-dot { background: var(--amp-green);  box-shadow: 0 0 10px rgba(30,185,128,.6); }
.amp.gelb   .amp-dot { background: var(--amp-yellow); box-shadow: 0 0 10px rgba(230,165,26,.6); }
.amp.rot    .amp-dot { background: var(--amp-red);    box-shadow: 0 0 10px rgba(227,85,59,.6); }
.amp.grau   .amp-dot { background: var(--amp-grey); }
.amp.gruen  { color: var(--amp-green); }
.amp.gelb   { color: var(--amp-yellow); }
.amp.rot    { color: var(--amp-red); }
.amp.grau   { color: var(--muted); }

.badge.b-gruen { background: #e3f6ee; color: var(--amp-green); }
.badge.b-gelb  { background: #fcf2da; color: #b9810f; }
.badge.b-rot   { background: #fde7e2; color: var(--amp-red); }
.badge.b-grau  { background: var(--cream-2); color: var(--muted); }

/* ===================================================================
   TABLE (Desktop) + Card-Liste (Mobile)
   =================================================================== */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--white); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--cream);
  white-space: nowrap;
}
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tr.clickable { cursor: pointer; transition: background .12s; }
table.data tr.clickable:hover { background: var(--cream); }

.list-cards { display: none; flex-direction: column; gap: 12px; }
.lc {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); cursor: pointer; transition: transform .12s, box-shadow .12s;
}
.lc:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.lc-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.lc-title { font-weight: 700; }
.lc-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-soft); padding: 2px 0; gap: 10px; }
.lc-row span:first-child { color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty .em-ic { font-size: 30px; opacity: .5; }

/* ===================================================================
   PIPELINE
   =================================================================== */
.pipeline { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 12px; }
.pipe-step {
  flex: none; min-width: 130px; background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 12.5px; position: relative;
}
.pipe-step .pipe-n { font-weight: 800; color: var(--muted); font-size: 11px; }
.pipe-step .pipe-t { font-weight: 700; margin: 2px 0 6px; }
.pipe-step.cur { border-color: var(--green); box-shadow: 0 0 0 2px rgba(24,184,123,.18); }

/* ===================================================================
   TABS / FORMS / MODAL
   =================================================================== */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab {
  padding: 9px 15px; font-weight: 600; font-size: 14px; color: var(--muted);
  border: none; background: none; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab.active { color: var(--green-deep); border-bottom-color: var(--green); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid label, .form-stack label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-grid label.full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,32,28,.45);
  display: grid; place-items: center; padding: 20px; z-index: 100; backdrop-filter: blur(3px);
}
.modal { background: var(--white); border-radius: 20px; width: 100%; max-width: 620px; max-height: 90vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 22px; overflow-y: auto; }

.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }

.detail-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
.stat-row { display: flex; flex-wrap: wrap; gap: 18px; }
.stat-row .stat { font-size: 13px; }
.stat-row .stat b { display: block; font-size: 18px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
.spacer { flex: 1; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: var(--radius-pill);
  font-weight: 600; font-size: 14px; box-shadow: var(--shadow-lg); z-index: 200;
}
.toast.err { background: var(--amp-red); }

.note-item { background: var(--cream); border-radius: var(--radius-sm); padding: 10px 13px; margin-bottom: 8px; font-size: 14px; }
.note-item .note-meta { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

.checklist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.checklist li { display: flex; align-items: center; gap: 12px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 14px; }
.checklist li.done .ci-title { text-decoration: line-through; color: var(--muted); }
.ci-title { flex: 1; font-weight: 600; font-size: 14px; }

.banner { background: #fff8e6; border: 1px solid #f0e0b0; color: #8a6d12; padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 18px; }

.mobile-only { display: none; }

/* ===================================================================
   RESPONSIVE
   =================================================================== */
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60; width: 80%; max-width: 300px;
    transform: translateX(-105%); transition: transform .22s ease; height: 100vh;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-flex; }
  .grid-2, .grid-3, .detail-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .content { padding: 18px 16px 60px; }
  /* Tabellen -> Karten */
  .table-wrap { display: none; }
  .list-cards { display: flex; }
  .kv { grid-template-columns: 130px 1fr; }
}
@media (min-width: 861px) {
  .list-cards { display: none !important; }
}
