* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, Segoe UI, sans-serif; color: #1a1a1a; background: #f6f7f8; }
.sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 220px; background: #1d2330; color: #cdd5e0; padding: 16px; overflow-y: auto; }
.sidebar h2 { color: #fff; font-size: 16px; margin: 0 0 16px; }
.sidebar h3 { color: #6b7a90; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; margin: 14px 0 6px; }
.sidebar nav a { display: block; color: #cdd5e0; text-decoration: none; padding: 6px 8px; border-radius: 4px; font-size: 13px; }
.sidebar nav a:hover, .sidebar nav a.active { background: #2c3447; color: #fff; }
.topbar { margin-left: 220px; padding: 12px 24px; background: #fff; border-bottom: 1px solid #e1e4ea; display: flex; justify-content: space-between; align-items: center; }
.topbar .me { color: #6b7a90; font-size: 13px; }
.content { margin-left: 220px; padding: 24px; }
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #1d2330; }
.login { background: #fff; padding: 32px; border-radius: 8px; min-width: 320px; display: flex; flex-direction: column; gap: 12px; }
.login h1 { margin: 0 0 12px; font-size: 18px; }
.login label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.login input { padding: 8px; border: 1px solid #d1d5db; border-radius: 4px; font: inherit; }
.login button { padding: 10px; background: #1d2330; color: #fff; border: 0; border-radius: 4px; cursor: pointer; font: inherit; }
.error { color: #b00020; font-size: 13px; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid #eef0f3; font-size: 13px; }
th { background: #f6f7f8; font-weight: 600; color: #6b7a90; }
button, input, textarea, select { font-family: inherit; }
.filters { display: flex; gap: 8px; margin-bottom: 16px; }
.filters select, .filters input { padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 4px; }
.filters button { padding: 6px 14px; background: #1d2330; color: #fff; border: 0; border-radius: 4px; cursor: pointer; }
.callmeta { display: flex; gap: 16px; flex-wrap: wrap; padding: 12px; background: #fff; border-radius: 6px; margin-bottom: 16px; font-size: 13px; }
.transcript { display: flex; flex-direction: column; gap: 8px; }
.turn { background: #fff; border: 1px solid #e1e4ea; border-radius: 6px; padding: 10px 14px; }
.turn-user { border-left: 3px solid #3b82f6; }
.turn-assistant { border-left: 3px solid #10b981; }
.turn-tool { border-left: 3px solid #a855f7; }
.turn-meta { display: flex; gap: 12px; font-size: 11px; color: #6b7a90; margin-bottom: 4px; }
.turn-meta .role { font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.turn-text { font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.turn-tools { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.tool { background: #f6f7f8; border-radius: 4px; padding: 8px 10px; font-size: 12px; }
.tool-ok { border-left: 2px solid #10b981; }
.tool-err { border-left: 2px solid #b00020; }
.tool-name { font-weight: 600; }
.tool-latency { color: #6b7a90; margin-left: 8px; }
.tool pre { margin: 4px 0 0; padding: 6px; background: #fff; border: 1px solid #e1e4ea; border-radius: 3px; overflow-x: auto; font-family: ui-monospace, SFMono-Regular, monospace; font-size: 11px; }

/* Agent config form (/admin/agent) */
.agentform fieldset { background: #fff; border: 1px solid #e1e4ea; border-radius: 6px; padding: 16px; margin-bottom: 16px; }
.agentform legend { padding: 0 8px; font-weight: 600; color: #1d2330; }
.agentform label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-size: 13px; }
.agentform input[type=text], .agentform input[type=number], .agentform select, .agentform textarea {
  padding: 8px; border: 1px solid #d1d5db; border-radius: 4px; font: inherit;
}
.agentform textarea { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 12px; }
.agentform .check { flex-direction: row; align-items: center; gap: 8px; }
.agentform .actions { display: flex; gap: 8px; }
.agentform button { padding: 10px 20px; background: #1d2330; color: #fff; border: 0; border-radius: 4px; cursor: pointer; font-weight: 600; }
.success { padding: 8px 12px; background: #dcfce7; color: #166534; border-radius: 4px; margin-bottom: 16px; }
.muted { color: #6b7a90; font-size: 12px; }
.testprompt { background: #fff; padding: 16px; border-radius: 6px; margin-top: 24px; }
.testprompt textarea { width: 100%; padding: 8px; border: 1px solid #d1d5db; border-radius: 4px; font: inherit; }
.testprompt button { padding: 8px 16px; background: #1d2330; color: #fff; border: 0; border-radius: 4px; cursor: pointer; }
.testprompt #probeReply { white-space: pre-wrap; padding: 12px; background: #f6f7f8; border-radius: 4px; margin-top: 8px; min-height: 40px; }
.testprompt details { margin-top: 12px; }
.testprompt pre { background: #f6f7f8; padding: 8px; border-radius: 4px; overflow-x: auto; font-size: 11px; max-height: 300px; }

/* Instructions list (/admin/instructions) */
.newinstr { background: #fff; padding: 16px; border-radius: 6px; margin-bottom: 16px; }
.newinstr label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; font-size: 13px; }
.newinstr input, .newinstr textarea { padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 4px; font: inherit; }
.newinstr .check { flex-direction: row; align-items: center; gap: 8px; }
.newinstr button { padding: 8px 16px; background: #1d2330; color: #fff; border: 0; border-radius: 4px; cursor: pointer; }
.instr-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.instr { background: #fff; border: 1px solid #e1e4ea; border-radius: 6px; padding: 8px 12px; display: flex; gap: 8px; align-items: flex-start; }
.instr.off { opacity: 0.55; }
.instr.dragging { opacity: 0.4; }
.instr .drag { cursor: grab; user-select: none; color: #6b7a90; padding-top: 4px; }
.instr details { flex: 1; }
.instr summary { cursor: pointer; font-size: 14px; }
.instr-edit { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.instr-edit label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.instr-edit input, .instr-edit textarea { padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 4px; font: inherit; }
.instr-edit .actions { display: flex; gap: 8px; }
.instr-edit button { padding: 6px 14px; border-radius: 4px; cursor: pointer; border: 0; }
.instr-edit button[type=submit]:not([formaction*=delete]) { background: #1d2330; color: #fff; }
.instr-edit button[formaction*=delete] { background: #fee2e2; color: #b00020; }

/* Documents (/admin/documents) */
.upload { background: #fff; padding: 16px; border-radius: 6px; margin-bottom: 16px; display: flex; gap: 8px; align-items: flex-end; }
.upload label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.upload button { padding: 8px 16px; background: #1d2330; color: #fff; border: 0; border-radius: 4px; cursor: pointer; }
tr.disabled td { opacity: 0.5; }
.danger { background: #fee2e2; color: #b00020; border: 0; padding: 4px 8px; border-radius: 4px; cursor: pointer; }
.cancel { padding: 8px 16px; background: #fff; color: #1d2330; border: 1px solid #d1d5db; border-radius: 4px; text-decoration: none; }
.docreview { background: #fff; padding: 16px; border-radius: 6px; }
.docreview label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.docreview textarea { width: 100%; padding: 8px; border: 1px solid #d1d5db; border-radius: 4px; font-family: ui-monospace, SFMono-Regular, monospace; font-size: 12px; }
.docreview .actions { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.docreview button { padding: 8px 16px; background: #1d2330; color: #fff; border: 0; border-radius: 4px; cursor: pointer; }

/* Agent versions diff (/admin/agent-versions) */
table.diff td { vertical-align: top; }
table.diff pre { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 11px; white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow-y: auto; margin: 0; padding: 6px; background: #f6f7f8; border-radius: 3px; }
table.diff tr.changed { background: #fef9c3; }
table.diff tr.changed td { border-bottom: 1px solid #facc15; }
table.diff tr.same { opacity: 0.55; }
