:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #17202a;
  --muted: #6b7280;
  --line: #dfe3e8;
  --primary: #1e5eff;
  --primary-dark: #1247cf;
  --danger: #b42318;
  --warning: #b54708;
  --success: #067647;
  --radius: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { line-height: 1.2; margin-top: 0; }
h1 { font-size: 30px; margin-bottom: 8px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 20px 0 6px; }
.topbar { min-height: 64px; display: flex; align-items: center; gap: 28px; padding: 12px 28px; background: #111827; color: white; }
.brand { color: white; font-weight: 750; letter-spacing: .02em; }
.topbar nav { display: flex; gap: 18px; flex: 1; flex-wrap: wrap; }
.topbar nav a { color: #d1d5db; }
.topbar nav a:hover { color: white; }
.logout-form { display: flex; align-items: center; gap: 14px; }
.link-button { border: 0; background: transparent; color: #d1d5db; cursor: pointer; font: inherit; padding: 0; }
.page { max-width: 1480px; margin: 0 auto; padding: 28px; }
.muted { color: var(--muted); margin-top: 0; }
.eyebrow { color: var(--primary); font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 7px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: 0 2px 7px rgba(17,24,39,.04); }
.page-heading, .chat-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 25px; margin-bottom: 24px; }
.progress-card { min-width: 220px; background: white; border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; display: grid; }
.progress-card strong { font-size: 22px; }
.progress-card span { color: var(--muted); font-size: 13px; }
.progress { width: 100%; height: 8px; margin-top: 10px; accent-color: var(--primary); }
.table-card { padding: 0; overflow: hidden; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: #fafafa; }
td small { display: block; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
.channel-badge, .status, .severity { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px; background: #eef1f5; color: #374151; font-size: 12px; font-weight: 700; }
.status-confirmed, .status-closed, .status-acceptable, .status-corrected { background: #dcfae6; color: var(--success); }
.status-open, .status-new, .status-error, .status-in_progress { background: #fff1e8; color: var(--warning); }
.status-internal { background: #f2f4f7; color: #344054; }
.severity-high, .severity-critical, .finding-card.severity-high .severity, .finding-card.severity-critical .severity { background: #fee4e2; color: var(--danger); }
.button, button { border-radius: 9px; border: 1px solid transparent; padding: 9px 13px; font-weight: 700; font: inherit; cursor: pointer; display: inline-flex; justify-content: center; }
.primary { background: var(--primary); color: white; border-color: var(--primary); }
.primary:hover { background: var(--primary-dark); }
.secondary { background: white; border-color: #cfd5dc; color: var(--ink); }
.full { width: 100%; }
.stack-form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; color: #374151; font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid #cfd5dc; border-radius: 9px; padding: 10px 11px; font: inherit; color: var(--ink); background: white; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(30,94,255,.13); border-color: var(--primary); }
.alert { padding: 12px 14px; border-radius: 9px; background: #eff6ff; color: #1e40af; margin-bottom: 18px; }
.alert-error { background: #fef3f2; color: var(--danger); }
.alert-success { background: #ecfdf3; color: var(--success); }
.form-alert { margin: 0 0 14px; }
.login-page { min-height: calc(100vh - 64px); display: grid; place-items: center; }
.login-card { width: min(430px, 100%); background: white; border: 1px solid var(--line); border-radius: 18px; padding: 34px; box-shadow: 0 22px 60px rgba(17,24,39,.12); }
.chat-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 430px; gap: 22px; align-items: start; }
.message-timeline { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.message { width: min(76%, 760px); border-radius: 14px; padding: 14px 15px 11px; background: white; border: 1px solid var(--line); position: relative; }
.message-outbound { align-self: flex-end; background: #eaf1ff; border-color: #c9d9ff; }
.message-internal, .message-unknown { align-self: center; background: #f1f1f1; }
.message-meta { display: flex; justify-content: space-between; gap: 15px; color: var(--muted); font-size: 12px; margin-bottom: 7px; }
.message-meta strong { color: #374151; }
.message-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.source-kind { display: block; color: #8a94a3; margin-top: 8px; }
.media-placeholder { font-style: italic; color: var(--muted); }
.evidence-picker { display: flex; grid-template-columns: auto 1fr; flex-direction: row; align-items: center; gap: 6px; font-size: 11px; color: var(--primary); margin-bottom: 8px; }
.evidence-picker input { width: auto; }
.message:has(.evidence-picker input:checked) { box-shadow: 0 0 0 3px rgba(30,94,255,.16); border-color: var(--primary); }
.evidence-requirement { display: grid; gap: 2px; padding: 10px 12px; border-radius: 9px; background: #eff6ff; color: #1e40af; font-size: 13px; }
.evidence-requirement span { color: #475467; }
.audit-panel { display: grid; gap: 16px; }
.internal-contact-card { padding: 15px 18px; }
.internal-contact-card summary { cursor: pointer; font-weight: 750; }
.internal-contact-card form { margin-top: 12px; }
.sticky-card { position: static; }
.no-error-form { margin-top: 10px; }
.finding-card { border-left: 5px solid #f79009; }
.finding-card.severity-high, .finding-card.severity-critical { border-left-color: #d92d20; }
.finding-topline { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.evidence-list blockquote, blockquote { margin: 9px 0; padding: 11px 12px; background: #f8fafc; border-left: 3px solid #94a3b8; white-space: pre-wrap; }
blockquote small { display: block; color: var(--muted); margin-bottom: 4px; }
.rules-help details { border-top: 1px solid var(--line); padding: 10px 0; }
.rules-help summary { cursor: pointer; font-weight: 700; }
.task-layout { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 22px; align-items: start; }
.task-layout aside { display: grid; gap: 16px; }
.task-main { border-left: 5px solid #f79009; }
.timeline { padding-left: 20px; }
.timeline li { margin-bottom: 15px; }
.timeline span { display: block; color: var(--muted); font-size: 12px; }
.timeline p { margin: 4px 0; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; }
.rule-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.rule-card ul { padding-left: 20px; }
.form-hint { margin: -6px 0 0; color: var(--muted); font-size: 13px; }
.learning-layout { display: grid; grid-template-columns: 420px minmax(0, 1fr); gap: 22px; align-items: start; }
.learning-list { display: grid; gap: 16px; }
.learning-guidance { white-space: pre-wrap; font-size: 16px; }
.channel-strip { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 14px; margin-bottom: 4px; }
.channel-tile { flex: 0 0 auto; display: grid; gap: 2px; min-width: 155px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--ink); }
.channel-tile span { color: var(--muted); font-size: 12px; }
.channel-tile.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(30,94,255,.1); }
.search-bar { display: grid; grid-template-columns: minmax(280px, 1fr) 220px 190px auto; gap: 12px; align-items: end; margin-bottom: 18px; }
.last-message { max-width: 430px; }
.last-message span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 20px; }
.rule-actions { margin-top: -8px; font-size: 13px; }
.findings-filter { display: grid; grid-template-columns: minmax(260px, 1fr) 220px auto auto; gap: 12px; align-items: end; margin-bottom: 18px; }
.finding-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.new-rule-card { margin-bottom: 22px; scroll-margin-top: 20px; }
.rule-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.rule-form .wide { grid-column: 1 / -1; }
.back-link { display: inline-block; margin-bottom: 14px; }
.empty { text-align: center; color: var(--muted); padding: 40px; }
@media (max-width: 980px) {
  .chat-workspace, .task-layout, .rule-grid, .learning-layout, .finding-grid { grid-template-columns: 1fr; }
  .search-bar, .findings-filter { grid-template-columns: 1fr 1fr; }
  .sticky-card { position: static; }
  .topbar { padding: 0 16px; gap: 16px; }
  .topbar nav { gap: 12px; }
  .page { padding: 18px; }
}
@media (max-width: 680px) {
  .topbar nav { display: none; }
  .message { width: 92%; }
  .page-heading { display: block; }
  .progress-card { margin-top: 15px; }
  .table-card { overflow-x: auto; }
  .search-bar, .findings-filter, .rule-form { grid-template-columns: 1fr; }
  .rule-form .wide { grid-column: auto; }
}
