:root {
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  color: #18202a;
  background: #f4f6f9;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: #1758a8; text-decoration: none; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 5vw; background: white; border-bottom: 1px solid #dce2e8;
}
.brand { font-weight: 750; color: #18202a; }
nav { display: flex; gap: 18px; }
.container { max-width: 1100px; margin: 32px auto; padding: 0 18px; }
.card {
  background: white; border: 1px solid #dce2e8; border-radius: 14px;
  padding: 24px; box-shadow: 0 8px 24px rgba(20, 35, 55, .06);
}
.narrow { max-width: 480px; margin: 70px auto; }
.muted { color: #607080; }
.chat-card { max-width: 780px; margin: 0 auto; }
.messages {
  min-height: 390px; max-height: 58vh; overflow-y: auto;
  padding: 15px; margin: 20px 0; background: #f8fafc;
  border: 1px solid #e1e7ed; border-radius: 12px;
}
.message {
  max-width: 82%; margin: 10px 0; padding: 12px 14px;
  border-radius: 12px; white-space: pre-wrap; line-height: 1.45;
}
.assistant { background: white; border: 1px solid #dce2e8; }
.user { margin-left: auto; background: #1f66bb; color: white; }
.error { border-color: #d97070; }
.chat-form { display: flex; gap: 10px; }
input, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid #bbc6d1;
  border-radius: 8px; font: inherit;
}
.chat-form input { flex: 1; }
button, .button {
  display: inline-block; border: 0; border-radius: 8px; padding: 11px 16px;
  background: #1f66bb; color: white; font-weight: 650; cursor: pointer;
}
.stack { display: grid; gap: 16px; }
.stack label { display: grid; gap: 7px; font-weight: 650; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.checkbox { display: flex !important; grid-template-columns: auto 1fr; align-items: center; }
.checkbox input { width: auto; }
.form-actions { display: flex; gap: 16px; align-items: center; }
.page-heading { display: flex; justify-content: space-between; align-items: center; }
.table-wrap { overflow-x: auto; background: white; border-radius: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid #e4e9ee; }
th { background: #eef3f7; }
.actions { display: flex; gap: 10px; }
.actions form { margin: 0; }
.link { background: none; color: #1758a8; padding: 0; }
.danger { color: #a62626; }
.flash { padding: 12px; margin-bottom: 18px; border-radius: 8px; }
.flash.success { background: #e8f5e9; }
.flash.error { background: #fdeaea; }
@media (max-width: 700px) {
  .grid-2 { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; gap: 12px; }
  nav { flex-wrap: wrap; }
}

select { width: 100%; padding: 11px 12px; border: 1px solid #bbc6d1; border-radius: 8px; font: inherit; background: white; }
.modal { position: fixed; inset: 0; background: rgba(10,20,30,.58); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal.hidden { display: none; }
.modal-panel { position: relative; width: min(760px, 96vw); max-height: 92vh; overflow-y: auto; background: white; border-radius: 14px; padding: 24px; }
.modal-close { position: absolute; top: 10px; right: 12px; background: transparent; color: #333; font-size: 24px; padding: 4px 10px; }
.message-tools { display: flex; gap: 8px; margin-top: 10px; }
.message-tools button { background: #eef3f7; color: #263645; padding: 6px 9px; font-size: 12px; }
.message-tools.submitted button{opacity:.55;cursor:default}.message-tools button:disabled{cursor:wait}
.message-sources { border-top: 1px solid #e4e9ee; color: #607080; font-size: 12px; margin-top: 10px; padding-top: 8px; }
.message-sources a { font-weight: 650; }
.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(120px,1fr)); gap: 14px; margin: 20px 0; }
.stat { background: white; border: 1px solid #dce2e8; border-radius: 12px; padding: 18px; display: grid; gap: 5px; }
.stat strong { font-size: 28px; }
.stat span { color: #607080; }
.dashboard-panels { align-items: start; }
.prewrap { white-space: pre-wrap; }
.comments { margin-top: 20px; }
.comment { border-bottom: 1px solid #e4e9ee; padding: 12px 0; }
.comment small { margin-left: 10px; color: #71808f; }
.badge { background: #fff2c7; border-radius: 999px; padding: 3px 7px; margin-left: 8px; font-size: 12px; }
@media (max-width: 900px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

.admin-ai-actions{display:flex;gap:10px;flex-wrap:wrap}.admin-ai-actions form{margin:0}.ai-summary{background:#f5f8fb;border-left:4px solid #1f66bb;padding:12px}hr{border:0;border-top:1px solid #e1e7ed;margin:22px 0}
.ai-review-notice{background:#fff8df;border:1px solid #e5c665;border-left:5px solid #c99300;border-radius:8px;margin:14px 0 20px;padding:14px}.ai-review-notice p{margin:7px 0}.ai-review-confirmation{background:#fff8df;border-radius:8px;padding:12px}
.router-choice-list{border:1px solid #dce2e8;border-radius:8px;max-height:320px;overflow:auto;padding:6px}.router-choice{align-items:flex-start;border-bottom:1px solid #edf0f3;display:flex;gap:10px;padding:10px}.router-choice:last-child{border-bottom:0}.router-choice input{margin-top:4px;width:auto}.router-choice span{display:flex;flex-direction:column}.router-choice small{color:#607080;margin-top:3px}
.sort-link{align-items:center;color:#18202a;display:flex;gap:6px;white-space:nowrap}.filter-row th{background:#f8fafc;padding:7px}.filter-row input,.filter-row select{font-size:13px;min-width:90px;padding:7px}.filter-row th:nth-child(5) input{min-width:230px}.filter-actions{align-items:center;display:flex;gap:9px}.filter-actions button{font-size:13px;padding:8px 10px}.empty-state{color:#607080;padding:28px;text-align:center}
.status-badge{background:#e7f0fb;border-radius:999px;color:#174f8e;display:inline-block;font-size:12px;font-weight:700;padding:4px 9px}.readonly-field{background:#f3f6f8;color:#4f5f6f}
