/* DialogLens demo: shared design system for the client app and the admin panel. */
:root {
  --navy-900: #0F1E36; --navy-800: #13294B; --navy-700: #1F3A5F; --navy-500: #3E5C85;
  --blue-600: #2563EB; --blue-500: #2F6FB2; --blue-100: #E8F0FB; --blue-50: #F3F7FC;
  --sky: #6FB1FF; --teal: #0E9F8E; --green: #2E7D4F; --green-100: #E8F5EC;
  --amber: #B7791F; --amber-100: #FEF3C7; --red: #C0392B; --red-100: #FDECEA; --violet: #6D5BD0; --violet-100: #EEEBFB;
  --bg: #F5F7FA; --card: #FFFFFF; --line: #E3E8EF; --line-2: #CBD5E1;
  --text: #1F2937; --muted: #6B7280; --faint: #9CA3AF;
  --radius: 8px; --shadow: 0 1px 2px rgba(15, 30, 54, .06), 0 4px 16px rgba(15, 30, 54, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 13px/1.45 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--blue-500); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 3px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 8px; }
h3 { font-size: 14px; margin: 0 0 6px; }
p { margin: 0 0 8px; }
.mono { font-family: var(--mono); font-size: 12px; }
td.mono, .nowrap { white-space: nowrap; }
.small { font-size: 11.5px; color: var(--muted); }
.muted { color: var(--muted); }
.pos { color: var(--green); font-weight: 600; } .neg { color: var(--red); font-weight: 600; }
.ok { color: var(--green); font-weight: 600; } .err { color: var(--red); font-weight: 600; } .warn-t { color: var(--amber); font-weight: 600; }
.r { text-align: right; } .c { text-align: center; }
.mt { margin-top: 14px; } .mt-s { margin-top: 8px; } .mb { margin-bottom: 14px; }
.flex { display: flex; align-items: center; gap: 8px; } .flex.wrap { flex-wrap: wrap; } .sp { flex: 1; }
.hidden { display: none !important; }

/* demo ribbon */
.demo-bar { height: 30px; background: #111827; color: #D1D5DB; display: flex; align-items: center; gap: 10px; padding: 0 14px; font-size: 12px; position: sticky; top: 0; z-index: 30; }
.demo-bar b { color: #fff; font-weight: 600; }
.demo-bar .tag { background: #F59E0B; color: #111827; border-radius: 4px; padding: 1px 7px; font-weight: 700; font-size: 11px; }
.demo-bar a { color: #BFDBFE; }
.demo-bar select { background: #374151; color: #E5E7EB; border: 0; border-radius: 4px; padding: 2px 6px; font: inherit; }

/* shell */
.app { display: flex; min-height: calc(100vh - 30px); }
.side { width: 216px; flex-shrink: 0; background: var(--navy-800); color: #DCE6F2; padding: 12px 10px 30px; position: sticky; top: 30px; height: calc(100vh - 30px); overflow-y: auto; }
.logo { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; color: #fff; padding: 4px 8px 8px; letter-spacing: -.01em; }
.logo img { width: 24px; height: 24px; }
.logo small { display: block; font-weight: 500; font-size: 10.5px; color: #8FA7C4; letter-spacing: .02em; }
.nsec { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: #8FA7C4; margin: 14px 8px 4px; }
.side a { display: flex; align-items: center; gap: 8px; color: #DCE6F2; padding: 6px 8px; border-radius: 6px; margin: 1px 0; text-decoration: none; }
.side a:hover { background: rgba(255,255,255,.08); }
.side a.on { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.side a .cnt { margin-left: auto; background: rgba(255,255,255,.18); color: #fff; font-size: 10.5px; border-radius: 9px; padding: 0 7px; font-weight: 600; }
.side a .cnt.red { background: #E5534B; }
.side a .opt { margin-left: auto; font-size: 9.5px; color: #8FA7C4; border: 1px solid #3E5C85; border-radius: 4px; padding: 0 4px; }
.main { flex: 1; min-width: 0; }
.top { height: 52px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 22px; position: sticky; top: 30px; z-index: 20; }
.top select { padding: 5px 8px; border: 1px solid var(--line-2); border-radius: 6px; font: inherit; background: #fff; }
.top .lbl { color: var(--muted); font-size: 12px; }
.user { display: flex; align-items: center; gap: 8px; cursor: pointer; position: relative; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #DBE7F5; color: var(--navy-700); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 11px; flex-shrink: 0; }
.user small { display: block; color: var(--muted); font-size: 11px; line-height: 1.1; }
.content { padding: 18px 22px 40px; max-width: 1480px; }

/* page header */
.ph { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.ph > div:first-child { flex: 1; min-width: 0; }
.sub { color: var(--muted); }
.crumb { font-size: 12px; color: var(--muted); margin-bottom: 4px; }

/* grid + cards */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .ct { padding: 12px 14px 0; }
.card.hl { border-color: #C9DBF3; box-shadow: 0 0 0 3px var(--blue-50); }
.ct { font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.ct .more { margin-left: auto; font-weight: 400; font-size: 12px; }
.kpi .l { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.kpi .v { font-size: 22px; font-weight: 700; margin: 2px 0; letter-spacing: -.01em; }
.kpi .d { font-size: 12px; color: var(--muted); }
.kpi.click { cursor: pointer; } .kpi.click:hover { border-color: var(--line-2); }

/* tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px; background: #F8FAFC; border-bottom: 1px solid var(--line); padding: 7px 10px; white-space: nowrap; }
th.sortable { cursor: pointer; } th.sortable:hover { color: var(--text); }
td { border-bottom: 1px solid var(--line); padding: 8px 10px; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td, tr.sel td { background: var(--blue-50); }
td.r, th.r { text-align: right; }
.compact td, .compact th { padding: 6px 8px; font-size: 12px; }
.tfoot td { background: #F8FAFC; font-weight: 600; }
.pager { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }

/* pills */
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; line-height: 1.6; }
.k-g { background: var(--green-100); color: #256A42; } .k-a { background: var(--amber-100); color: #8A5A0B; }
.k-r { background: var(--red-100); color: #B42318; } .k-b { background: var(--blue-100); color: #1D4F91; }
.k-n { background: #EEF2F7; color: #4B5563; } .k-v { background: var(--violet-100); color: #4C3BAE; } .k-t { background: #E0F5F2; color: #0B7163; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* buttons + forms */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: #fff; color: var(--text); border-radius: 6px; padding: 6px 12px; font: inherit; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn:hover { background: #F8FAFC; }
.btn.primary { background: var(--blue-500); border-color: var(--blue-500); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #285f99; }
.btn.danger { color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.filters { display: flex; gap: 10px; align-items: flex-end; margin-bottom: 12px; flex-wrap: wrap; }
.f span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
select, input, textarea { font: inherit; color: inherit; }
.f select, .f input, .field input, .field select, .field textarea, .search { padding: 6px 9px; border: 1px solid var(--line-2); border-radius: 6px; background: #fff; }
.search { min-width: 220px; }
.field { margin-bottom: 11px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.field input, .field select, .field textarea { width: 100%; }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.req::after { content: " *"; color: var(--red); }
.switch { display: inline-block; width: 32px; height: 18px; border-radius: 10px; background: #CBD5E1; position: relative; vertical-align: middle; cursor: pointer; flex-shrink: 0; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch.on { background: var(--green); } .switch.on::after { left: 16px; }
.check { display: flex; align-items: flex-start; gap: 8px; margin: 6px 0; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; }
.seg a { padding: 5px 10px; color: var(--text); text-decoration: none; border-right: 1px solid var(--line-2); }
.seg a:last-child { border-right: 0; } .seg a.on { background: var(--navy-700); color: #fff; }

/* tabs + steps */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 4px 0 14px; flex-wrap: wrap; }
.tabs a { padding: 7px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; }
.tabs a.on { color: var(--blue-500); border-bottom-color: var(--blue-500); font-weight: 600; }
.tabs a .cnt { background: #EEF2F7; color: var(--muted); border-radius: 9px; padding: 0 6px; font-size: 10.5px; margin-left: 4px; }
.steps { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.step { flex: 1; min-width: 110px; padding: 7px 10px; border-radius: 6px; background: #EEF2F7; color: var(--muted); font-size: 12px; cursor: pointer; }
.step.on { background: var(--navy-700); color: #fff; font-weight: 600; }
.step.done { background: var(--green-100); color: #256A42; }

/* callouts, chips, code */
.note { font-size: 12px; color: var(--muted); margin-top: 8px; }
.warn { background: var(--amber-100); border: 1px solid #F6D58E; border-radius: 6px; padding: 8px 10px; font-size: 12.5px; }
.info { background: var(--blue-100); border: 1px solid #C9DBF3; border-radius: 6px; padding: 8px 10px; font-size: 12.5px; }
.okbox { background: var(--green-100); border: 1px solid #BFE3CB; border-radius: 6px; padding: 8px 10px; font-size: 12.5px; }
.errbox { background: var(--red-100); border: 1px solid #F5C2BD; border-radius: 6px; padding: 8px 10px; font-size: 12.5px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: #EEF2F7; border-radius: 999px; padding: 3px 10px; font-size: 12px; margin: 0 6px 6px 0; }
.chip .x { cursor: pointer; color: var(--muted); }
.code, .log { background: #0F172A; color: #E2E8F0; border-radius: 6px; padding: 10px 12px; font-family: var(--mono); font-size: 11.5px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.code .w, .log .w { color: #FBBF24; } .code .g { color: #86EFAC; } .code .r { color: #FCA5A5; text-align: left; } .code .c { color: #94A3B8; text-align: left; }
.bar { height: 8px; background: #EEF2F7; border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--blue-500); }
.legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--muted); margin-top: 4px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 12px; font-size: 12.5px; }
.kv > div:nth-child(odd) { color: var(--muted); }
.lineage { font-family: var(--mono); font-size: 11.5px; background: #F8FAFC; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }

/* timeline */
.tl { position: relative; padding-left: 18px; }
.tl::before { content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.tl .e { position: relative; margin-bottom: 10px; }
.tl .e::before { content: ""; position: absolute; left: -16px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: #9CA3AF; }
.tl .e.t-log::before { background: #6B7280; } .tl .e.t-chat::before { background: var(--blue-500); } .tl .e.t-biz::before { background: var(--green); } .tl .e.t-bad::before { background: var(--red); } .tl .e.t-rel::before { background: var(--violet); }
.tl .t { font-size: 11.5px; color: var(--muted); }

/* conversation excerpts */
.ex { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; }
.ex .h { font-size: 11.5px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 6px; align-items: center; }
.msg { margin: 3px 0; } .msg b { font-size: 11.5px; color: #374151; } .msg.agent b { color: var(--blue-500); }
.msg.hl { background: var(--amber-100); border-radius: 4px; padding: 1px 4px; } .msg.bad { background: var(--red-100); border-radius: 4px; padding: 1px 4px; }

/* modal, drawer, toast */
.overlay { position: fixed; inset: 0; background: rgba(15, 30, 54, .42); display: flex; align-items: flex-start; justify-content: center; z-index: 100; padding: 60px 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 820px; }
.modal .mh { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; font-weight: 700; font-size: 15px; }
.modal .mh .x { margin-left: auto; cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; }
.modal .mb { padding: 16px 18px; }
.modal .mf { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #111827; color: #F9FAFB; border-radius: 8px; padding: 10px 14px; font-size: 12.5px; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 380px; animation: tin .2s ease; }
.toast.ok { border-left: 4px solid #34D399; } .toast.warn { border-left: 4px solid #FBBF24; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.menu { position: absolute; top: 40px; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); min-width: 210px; padding: 6px; z-index: 50; }
.menu a { display: block; padding: 7px 10px; border-radius: 6px; color: var(--text); text-decoration: none; }
.menu a:hover { background: #F3F4F6; }

/* drop zone + progress */
.drop { border: 2px dashed var(--line-2); border-radius: 8px; padding: 18px; text-align: center; color: var(--muted); background: #FAFBFD; cursor: pointer; }
.drop:hover, .drop.drag { border-color: var(--blue-500); background: var(--blue-50); }
.progress { height: 6px; background: #EEF2F7; border-radius: 3px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--blue-500); width: 0; transition: width .25s; }

/* AI Analyst */
.ai-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 14px; align-items: start; }
.ai-thread { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: calc(100vh - 190px); }
.ai-msgs { flex: 1; padding: 16px 18px; overflow-y: auto; }
.ai-q { background: var(--navy-700); color: #fff; border-radius: 12px 12px 2px 12px; padding: 9px 13px; margin: 0 0 14px auto; max-width: 78%; width: fit-content; }
.ai-a { margin-bottom: 18px; }
.ai-a .who { font-size: 11.5px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 6px; align-items: center; }
.ai-a .body { border: 1px solid var(--line); border-radius: 12px 12px 12px 2px; padding: 11px 14px; background: #FCFDFE; }
.ai-a .body p { margin: 0 0 8px; } .ai-a .body ul { margin: 4px 0 8px; padding-left: 18px; }
.tools { font-family: var(--mono); font-size: 11px; color: var(--muted); background: #F8FAFC; border: 1px dashed var(--line-2); border-radius: 6px; padding: 7px 9px; margin-bottom: 8px; }
.tools div { margin: 1px 0; } .tools .done { color: var(--green); }
.evid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.evid a { display: inline-flex; align-items: center; gap: 5px; border: 1px solid #C9DBF3; background: var(--blue-50); border-radius: 999px; padding: 2px 10px; font-size: 11.5px; text-decoration: none; }
.ai-input { border-top: 1px solid var(--line); padding: 10px 12px; display: flex; gap: 8px; }
.ai-input textarea { flex: 1; resize: none; border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 11px; min-height: 42px; max-height: 120px; }
.sugg a { display: block; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; margin-bottom: 6px; color: var(--text); background: #fff; text-decoration: none; font-size: 12.5px; }
.sugg a:hover { border-color: var(--blue-500); background: var(--blue-50); }
.caret::after { content: "▍"; animation: blink 1s steps(1) infinite; color: var(--blue-500); }
@keyframes blink { 50% { opacity: 0; } }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(1200px 600px at 20% 0%, #2F6FB2 0%, #13294B 55%, #0F1E36 100%); padding: 20px; }
.login-card { background: #fff; border-radius: 12px; width: 380px; max-width: 100%; padding: 26px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.login-card .logo { color: var(--navy-800); padding: 0 0 14px; }
.code6 { display: flex; gap: 8px; margin: 8px 0 14px; }
.code6 input { width: 42px; height: 46px; text-align: center; font-size: 20px; font-weight: 600; border: 1px solid var(--line-2); border-radius: 6px; }
.democreds { background: var(--amber-100); border: 1px solid #F6D58E; border-radius: 8px; padding: 9px 11px; font-size: 12px; margin-bottom: 14px; }
.democreds code { font-family: var(--mono); background: rgba(255,255,255,.6); padding: 0 4px; border-radius: 3px; }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .cols, .ai-layout { grid-template-columns: 1fr; } }
@media print { .demo-bar, .side, .top { display: none !important; } }
