:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #657384;
  --line: #d8dee6;
  --accent: #0f7b6c;
  --accent-2: #2d5d8b;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); }
a { color: inherit; text-decoration: none; }
button { border: 0; border-radius: 6px; background: var(--accent); color: #fff; padding: 9px 14px; font-weight: 650; cursor: pointer; }
.secondary-button { background: #475569; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; font: inherit; background: #fff; }
textarea { min-height: 80px; resize: vertical; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 8px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
code { white-space: pre-wrap; font-size: 12px; color: #334155; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 220px; background: #111827; color: #f8fafc; padding: 22px 16px; display: flex; flex-direction: column; gap: 20px; }
.brand { font-weight: 800; font-size: 18px; }
.sidebar nav { display: grid; gap: 6px; }
.sidebar a { padding: 10px 12px; border-radius: 6px; color: #cbd5e1; }
.sidebar a:hover { background: #1f2937; color: #fff; }
.logout { margin-top: auto; }
.logout button { width: 100%; background: #374151; }
.main { margin-left: 220px; padding: 28px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.page-header h1 { margin: 0; font-size: 24px; }
.page-header span { color: var(--muted); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; margin-bottom: 18px; overflow-x: auto; }
.panel h2 { margin: 0 0 14px; font-size: 17px; }
.narrow { max-width: 760px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metrics div { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 18px; display: grid; gap: 6px; }
.metrics strong { font-size: 30px; }
.metrics span { color: var(--muted); }
.grid-form { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 14px; align-items: end; }
.grid-form .span-2 { grid-column: span 2; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input, .inline-form select { min-width: 150px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }
.notice { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; border-radius: 6px; padding: 10px 12px; margin-bottom: 14px; }
.login-page { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #102a43, #0f766e); }
.login-panel { width: min(380px, calc(100vw - 32px)); background: #fff; border-radius: 8px; padding: 28px; display: grid; gap: 16px; box-shadow: 0 22px 70px rgba(0,0,0,.25); }
.login-panel h1 { margin: 0 0 4px; font-size: 24px; }
.settings-list { display: grid; grid-template-columns: 180px 1fr; gap: 12px 18px; }
.settings-list dt { color: var(--muted); }
.settings-list dd { margin: 0; font-weight: 650; }
.prompt-area { min-height: 260px; }
.advisor-layout { display: grid; grid-template-columns: 260px minmax(0, 900px); gap: 18px; align-items: start; }
.advisor-main { min-width: 0; }
.target-panel { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 14px; position: sticky; top: 18px; }
.target-panel h2 { margin: 0 0 12px; font-size: 16px; }
.target-list { display: grid; gap: 6px; }
.target-list a { display: flex; justify-content: space-between; gap: 10px; padding: 9px 10px; border-radius: 6px; color: var(--ink); border: 1px solid transparent; }
.target-list a.active { background: #ecfdf5; border-color: #99f6e4; color: #065f46; }
.target-list em { font-style: normal; color: var(--muted); }
.advisor-form { grid-template-columns: 1fr; }
.advisor-answer { white-space: pre-wrap; line-height: 1.65; }
.muted { color: var(--muted); }
.knowledge-editor { min-height: 560px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; line-height: 1.55; }
.form-actions { margin-top: 12px; }
.chat-history { display: grid; gap: 10px; }
.chat-row { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #f8fafc; }
.chat-row.assistant { background: #f0fdfa; }
.chat-row strong { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.chat-row p { margin: 0; white-space: pre-wrap; }
.panel-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-title-row h2 { margin: 0; }
.pagination { display: flex; align-items: center; gap: 12px; justify-content: flex-end; margin-top: 14px; color: var(--muted); }
.pagination a { color: var(--accent-2); font-weight: 650; }
.table-actions { display: flex; gap: 8px; align-items: center; }
.text-button { color: var(--accent-2); font-weight: 650; }
.summary-cell { max-width: 320px; white-space: normal; line-height: 1.45; }
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.profile-grid div, .profile-block { border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; padding: 10px 12px; }
.profile-grid strong, .profile-block strong { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.profile-grid span, .profile-block p { margin: 0; white-space: pre-wrap; }
.status-box { background: #0f172a; color: #e2e8f0; border-radius: 8px; padding: 14px; overflow-x: auto; font-size: 12px; }
@media (max-width: 860px) {
  .sidebar { position: static; width: auto; }
  .main { margin-left: 0; padding: 16px; }
  .grid-form, .metrics, .advisor-layout { grid-template-columns: 1fr; }
  .target-panel { position: static; }
  .profile-grid { grid-template-columns: 1fr; }
  .grid-form .span-2 { grid-column: auto; }
}
