:root {
  --bg: #f4f6f9;
  --sidebar-bg: #1c2333;
  --sidebar-fg: #c7cede;
  --sidebar-active: #2e3a55;
  --accent: #4f6df5;
  --accent-dark: #3953d3;
  --card-bg: #ffffff;
  --border: #e3e7ee;
  --text: #1e2433;
  --text-muted: #6b7280;
  --danger: #e5484d;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 25, 40, 0.08), 0 1px 2px rgba(20, 25, 40, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

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

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
}

.brand {
  font-weight: 700;
  font-size: 17px;
  color: #fff;
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 12px;
}

.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.sidebar nav a {
  color: var(--sidebar-fg);
  padding: 10px 20px;
  text-decoration: none;
  border-left: 3px solid transparent;
}

.sidebar nav a:hover { background: rgba(255,255,255,0.05); color: #fff; }

.sidebar nav a.active {
  background: var(--sidebar-active);
  color: #fff;
  border-left-color: var(--accent);
  font-weight: 600;
}

.sidebar-footer {
  padding: 14px 20px 0;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin-top: 12px;
}

.sidebar-footer .user { font-weight: 600; color: #fff; margin-bottom: 4px; }
.sidebar-footer .logout { font-size: 13px; color: #f0a; color: #ff8b8b; }

.content { flex: 1; padding: 28px 32px; max-width: 1200px; }
.content-plain { display: flex; align-items: center; justify-content: center; min-height: 100vh; width: 100%; }

h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.subtitle { color: var(--text-muted); margin: 0 0 22px; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.stat-card .value { font-size: 26px; font-weight: 700; }
.stat-card .label { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }
.stat-card.warn .value { color: var(--warning); }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); font-weight: 600; }
tr:hover td { background: #fafbfd; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #eef1f8;
  color: var(--text-muted);
}
.badge-ja { background: #e6f6ea; color: var(--success); }
.badge-nein { background: #fdeaea; color: var(--danger); }
.badge-prio-5 { background: #fdeaea; color: var(--danger); }
.badge-prio-4 { background: #fff2e0; color: var(--warning); }
.badge-prio-3, .badge-prio-2, .badge-prio-1 { background: #eef1f8; color: var(--text-muted); }
.badge-warn { background: #fff2e0; color: var(--warning); }
.badge-gut { background: #e6f6ea; color: var(--success); }
.badge-schlecht { background: #fdeaea; color: var(--danger); }
.badge-offen { background: #eef1f8; color: var(--text-muted); }
.badge-fehler { background: #fff2e0; color: var(--warning); }

.cell-truncate { max-width: 320px; white-space: pre-wrap; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: center; }
.toolbar select, .toolbar input[type=text] {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13.5px; background: #fff;
}
.spacer { flex: 1; }

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #f5f6f9; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { color: var(--danger); border-color: #f5c6c6; }
.btn-danger:hover { background: #fdeaea; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

form.inline { display: inline; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 13px; }
.field .hint { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
input[type=text], input[type=number], input[type=password], input[type=email], input[type=file],
textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
textarea { resize: vertical; min-height: 70px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.flash { padding: 11px 16px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.flash-success { background: #e6f6ea; color: #146c2e; }
.flash-error { background: #fdeaea; color: #a1272b; }

.login-box {
  width: 340px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  text-align: center;
}
.login-box h1 { margin-bottom: 4px; }
.login-box p.subtitle { margin-bottom: 22px; }
.login-box form { text-align: left; }
.login-box button { width: 100%; margin-top: 6px; }

/* Chat */
.chat-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 130px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg { max-width: 72%; padding: 11px 15px; border-radius: 14px; line-height: 1.5; white-space: pre-wrap; }
.msg-user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg-assistant { align-self: flex-start; background: #eef1f8; color: var(--text); border-bottom-left-radius: 4px; }
.msg-system { align-self: center; color: var(--text-muted); font-size: 12.5px; font-style: italic; }
.chat-form { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--border); }
.chat-form textarea { flex: 1; min-height: 46px; max-height: 160px; }
.chat-hint { color: var(--text-muted); font-size: 12.5px; padding: 0 14px 12px; }

.rate-box {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid rgba(30, 36, 51, 0.08);
}
.rate-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
}
.rate-btn:hover { background: #f5f6f9; }
.rate-btn.active-good { background: #e6f6ea; border-color: #b7e4c4; color: var(--success); font-weight: 600; }
.rate-btn.active-bad { background: #fdeaea; border-color: #f5c6c6; color: var(--danger); font-weight: 600; }
.rate-note-toggle {
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  padding: 3px 4px;
}
.rate-status { font-size: 11.5px; color: var(--text-muted); }
.rate-note { display: flex; gap: 6px; width: 100%; margin-top: 6px; }
.rate-note textarea { flex: 1; min-height: 44px; font-size: 12.5px; }

.reco-box {
  align-self: flex-start;
  max-width: 92%;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.reco-header { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 8px; }
.reco-title { font-weight: 700; font-size: 14.5px; }
.reco-score { font-size: 12.5px; color: var(--accent); font-weight: 600; }
.reco-diff-leicht { background: #e6f6ea; color: var(--success); }
.reco-diff-mittel { background: #fff2e0; color: var(--warning); }
.reco-diff-schwer { background: #fdeaea; color: var(--danger); }
.reco-vorteile { margin: 0 0 8px; padding-left: 18px; font-size: 13px; }
.reco-vorteile li { margin-bottom: 2px; }
.reco-kundentext {
  margin: 0 0 8px;
  padding: 8px 12px;
  background: #f7f8fb;
  border-left: 3px solid var(--border);
  font-size: 13px;
  font-style: italic;
  color: var(--text);
}
.reco-hinweis { font-size: 12.5px; color: var(--text-muted); }

.product-cards {
  align-self: flex-start;
  max-width: 92%;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}
.product-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  width: 220px;
  box-shadow: var(--shadow);
}
.product-card.featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.product-badge {
  position: absolute;
  top: -9px;
  right: 14px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
}
.product-name { font-weight: 700; font-size: 15px; }
.product-group { margin-top: 1px; }
.product-claim { color: var(--accent); font-size: 12.5px; font-weight: 600; margin-top: 4px; }
.product-price { font-size: 19px; font-weight: 700; margin-top: 10px; }
.product-duration { margin-top: 1px; }
.product-features { margin: 10px 0 0; padding-left: 18px; font-size: 12.5px; }
.product-features li { margin-bottom: 3px; }
.product-reason { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-muted); font-style: italic; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }

.small { font-size: 12.5px; color: var(--text-muted); }
.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12.5px; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 16px;
}

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; }
  .form-grid, .two-col { grid-template-columns: 1fr; }
}
