:root {
  --ink: #17201d;
  --muted: #6d7772;
  --paper: #f3f4f1;
  --panel: #ffffff;
  --line: #e3e6e1;
  --green: #176b4d;
  --green-dark: #0d4d37;
  --green-soft: #e7f3ed;
  --orange: #e56f2d;
  --orange-soft: #fff0e7;
  --red: #b73d3d;
  --red-soft: #fbeaea;
  --yellow: #9b7212;
  --yellow-soft: #fff7d9;
  --shadow: 0 10px 28px rgba(25, 42, 34, 0.06);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: "DM Sans", "Noto Sans SC", sans-serif; color: var(--ink); background: var(--paper); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: #15221d; color: #fff; padding: 24px 16px 18px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--orange); font-weight: 800; letter-spacing: -.04em; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 17px; }
.brand span { margin-top: 2px; color: #9fb0a8; font-size: 12px; }
.business-switcher { display:grid; gap:6px; margin:0 6px 18px; padding:11px; border:1px solid #33473e; border-radius:9px; background:#1d2d26; }
.business-switcher span { color:#82958b; font-size:9px; text-transform:uppercase; letter-spacing:.08em; }
.business-switcher select { width:100%; min-width:0; border:0; outline:0; color:#fff; background:#1d2d26; font-size:11px; font-weight:600; }
.business-switcher option { color:#18211d; background:#fff; }
.nav-list, .sidebar-section { display: grid; gap: 5px; }
.nav-item { width: 100%; border: 0; border-radius: 9px; padding: 11px 10px; display: grid; grid-template-columns: 25px 1fr auto; align-items: center; text-align: left; color: #c7d1cc; background: transparent; font-size: 13px; }
.nav-item span { font-size: 10px; color: #71837a; }
.nav-item b { min-width: 21px; padding: 2px 6px; border-radius: 10px; color: #dce9e2; background: #2b3c34; text-align: center; font-size: 10px; }
.nav-item:hover, .nav-item.active { color: #fff; background: #293a33; }
.nav-item.active { box-shadow: inset 3px 0 var(--orange); }
.sidebar-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid #2b3b34; }
.sidebar-section > p { margin: 0 10px 8px; color: #708078; text-transform: uppercase; font-size: 10px; letter-spacing: .14em; }
.nav-item.muted { opacity: .78; }
.account-card { margin-top: auto; display: grid; grid-template-columns: 34px 1fr 8px; align-items: center; gap: 10px; padding: 14px 8px 0; border-top: 1px solid #2b3b34; }
.account-card strong, .account-card span { display: block; font-size: 12px; }
.account-card span { margin-top: 2px; color: #7f9288; font-size: 10px; }
.online-dot, .connection-dot { width: 8px; height: 8px; border-radius: 50%; background: #40ca88; box-shadow: 0 0 0 4px rgba(64,202,136,.12); }

.main-area { min-width: 0; padding: 24px 28px 32px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 20px; }
.eyebrow { margin: 0 0 4px; color: var(--green); font-weight: 700; font-size: 10px; letter-spacing: .14em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 26px; letter-spacing: -.035em; }
h2 { margin-bottom: 0; font-size: 16px; letter-spacing: -.015em; }
h3 { margin-bottom: 12px; font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.search-box { width: min(380px, 32vw); height: 40px; display: flex; align-items: center; gap: 9px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.search-box input { min-width: 0; flex: 1; border: 0; outline: 0; font-size: 12px; }
kbd { padding: 3px 6px; border: 1px solid var(--line); border-radius: 5px; color: #87908c; background: #f7f8f6; font-size: 9px; }
.primary-button, .send-button, .wide-button { border: 0; border-radius: 8px; color: #fff; background: var(--green); font-weight: 600; font-size: 12px; }
.primary-button { height: 40px; padding: 0 16px; }
.primary-button:hover, .send-button:hover, .wide-button:hover { background: var(--green-dark); }
.icon-button { position: relative; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 9px; color: #7a8580; background: #fff; }
.icon-button b { position: absolute; top: -5px; right: -4px; min-width: 16px; padding: 2px 4px; border-radius: 9px; color: #fff; background: var(--orange); font-size: 9px; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.metrics article { min-width: 0; padding: 15px 17px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.72); }
.metrics span, .metrics small { display: block; color: var(--muted); font-size: 10px; }
.metrics strong { display: block; margin: 3px 0; font-size: 23px; letter-spacing: -.04em; }
.metrics .up { color: var(--green); }
.metrics .warning { color: var(--orange); }

.workspace { display: grid; grid-template-columns: 270px minmax(430px, 1fr) 284px; min-height: 680px; gap: 12px; }
.panel { border: 1px solid var(--line); border-radius: 11px; background: var(--panel); box-shadow: var(--shadow); }
.panel-heading { min-height: 61px; padding: 16px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.panel-heading.compact { min-height: 67px; }
.panel-heading span, .panel-heading p { display: block; margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.filter-row, .table-filters { display: flex; gap: 5px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.filter { border: 0; border-radius: 7px; padding: 7px 9px; color: var(--muted); background: transparent; font-size: 10px; }
.filter.active, .filter:hover { color: var(--green-dark); background: var(--green-soft); }
.conversation-items { max-height: 610px; overflow-y: auto; }
.conversation-card { position: relative; display: grid; grid-template-columns: 38px 1fr; gap: 10px; padding: 14px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.conversation-card:hover, .conversation-card.active { background: #f4f8f5; }
.conversation-card.active::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--green); }
.avatar { width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: #fff; background: #526e62; font-weight: 700; font-size: 12px; }
.avatar.small { width: 34px; height: 34px; background: #355347; font-size: 10px; }
.conversation-card h3 { margin: 0 0 4px; font-size: 12px; }
.conversation-card p { margin: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 10px; }
.conversation-meta { display: flex; justify-content: space-between; margin-bottom: 3px; }
.conversation-meta time { color: #8e9792; font-size: 9px; }
.conversation-tags { display: flex; gap: 4px; margin-top: 8px; }
.tag { padding: 3px 6px; border-radius: 5px; background: #edf0ed; color: #647069; font-size: 8px; }
.tag.risk { background: var(--orange-soft); color: #ad511e; }
.tag.ai { background: var(--green-soft); color: var(--green); }

.chat-panel { display: flex; min-width: 0; flex-direction: column; }
.chat-header { min-height: 68px; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.customer-head { display: flex; align-items: center; gap: 10px; }
.customer-head h2 { margin-bottom: 3px; }
.customer-head p { margin: 0; color: var(--muted); font-size: 10px; }
.mode-switch { display: flex; align-items: center; gap: 9px; }
.mode-switch > span { color: var(--green); font-size: 10px; font-weight: 600; }
.takeover-button { padding: 8px 10px; border: 1px solid #d5aaa1; border-radius: 7px; color: #9f3d2a; background: #fff8f6; font-size: 10px; }
.takeover-button.active { color: #fff; border-color: var(--orange); background: var(--orange); }
.context-strip { display: flex; flex-wrap: wrap; gap: 7px 14px; padding: 10px 16px; color: var(--muted); background: #f7f8f6; border-bottom: 1px solid var(--line); font-size: 9px; }
.context-strip b { color: var(--ink); }
.risk-badge { color: #a45320; }
.messages { flex: 1; min-height: 325px; padding: 20px 18px; overflow-y: auto; background: radial-gradient(circle at 10% 15%, rgba(23,107,77,.04), transparent 30%), #fafbf9; }
.message { max-width: 76%; margin-bottom: 14px; }
.message.in { margin-right: auto; }
.message.out { margin-left: auto; }
.bubble { padding: 10px 12px; border-radius: 11px; color: #35403b; background: #fff; border: 1px solid var(--line); font-size: 11px; line-height: 1.6; }
.message.out .bubble { color: #123b2d; background: #dff2e8; border-color: #cbe5d7; }
.message small { display: block; margin-top: 4px; color: #929b96; font-size: 8px; }
.message.out small { text-align: right; }
.attachment { margin-top: 8px; padding: 9px; display: flex; align-items: center; gap: 9px; border: 1px solid #d8ded9; border-radius: 8px; background: #f7f8f6; }
.attachment i { width: 28px; height: 32px; display: grid; place-items: center; border-radius: 5px; color: #fff; background: var(--green); font-style: normal; font-size: 8px; }
.attachment b, .attachment span { display: block; }
.attachment b { font-size: 9px; }.attachment span { color: var(--muted); font-size: 8px; }
.system-note { width: fit-content; margin: 10px auto 18px; padding: 6px 9px; border-radius: 6px; color: #6f7873; background: #eef0ed; font-size: 8px; }
.ai-draft { margin: 0 14px 14px; border: 1px solid #b9d7c8; border-radius: 10px; overflow: hidden; }
.draft-heading { display: flex; justify-content: space-between; padding: 8px 11px; color: var(--green-dark); background: var(--green-soft); font-size: 10px; font-weight: 600; }
.draft-heading small { color: var(--green); font-size: 8px; font-weight: 400; }
.ai-draft textarea { width: 100%; min-height: 74px; padding: 11px; resize: vertical; border: 0; outline: 0; color: #39433f; line-height: 1.5; font-size: 10px; }
.draft-actions { display: flex; justify-content: flex-end; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line); }
.ghost-button { padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; color: #59635e; background: #fff; font-size: 10px; }
.send-button { padding: 8px 13px; }

.insight-panel { overflow: hidden; }
.confidence { padding: 4px 7px; border-radius: 6px; color: var(--green) !important; background: var(--green-soft); }
.insight-section { padding: 15px 16px; border-bottom: 1px solid var(--line); }
.details-grid { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.details-grid dt { color: var(--muted); font-size: 8px; }.details-grid dd { margin: 2px 0 0; font-size: 10px; font-weight: 600; }.details-grid .good { color: var(--green); }
.check-list, .task-list { margin: 0; padding: 0; list-style: none; }
.check-list { display: grid; gap: 9px; font-size: 10px; }.check-list i { display: inline-grid; width: 17px; height: 17px; margin-right: 7px; place-items: center; border-radius: 50%; color: var(--green); background: var(--green-soft); font-style: normal; }
.attention { background: #fffcf8; }
.task-list { display: grid; gap: 11px; }
.task-list li { display: flex; gap: 9px; align-items: center; }
.task-list li > span { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; color: #a94c1d; background: var(--orange-soft); font-size: 10px; font-weight: 700; }
.task-list b, .task-list small { display: block; }.task-list b { font-size: 9px; }.task-list small { margin-top: 2px; color: var(--muted); font-size: 8px; }
.wide-button { width: calc(100% - 32px); margin: 15px 16px; padding: 10px; }

.project-view { display: grid; gap: 12px; }
.knowledge-view { display: grid; gap: 12px; }
.knowledge-hero { padding: 20px; display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.knowledge-hero h2 { margin: 4px 0 7px; font-size: 21px; }.knowledge-hero p:not(.eyebrow) { max-width: 690px; margin-bottom: 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.knowledge-metrics { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }.knowledge-metrics article { padding: 15px 17px; }.knowledge-metrics span,.knowledge-metrics small { display:block; color:var(--muted); font-size:9px; }.knowledge-metrics strong { display:block; margin:4px 0; font-size:22px; }
.knowledge-grid { display:grid; grid-template-columns:minmax(0,1fr) 300px; gap:12px; }.source-panel { overflow:hidden; }.source-list { padding:4px 16px 10px; }.source-list article { display:grid; grid-template-columns:34px minmax(0,1fr) auto; gap:11px; align-items:center; padding:14px 0; border-bottom:1px solid var(--line); }.source-list article:last-child { border-bottom:0; }.source-list h3 { margin:0 0 3px; font-size:11px; }.source-list p { margin:0 0 3px; color:#46514c; font-size:9px; }.source-list small { color:var(--muted); font-size:8px; }
.grade { width:30px; height:30px; display:grid; place-items:center; border-radius:8px; font-style:normal; font-size:11px; font-weight:800; }.grade-a { color:#fff; background:var(--green); }.grade-b { color:#32604d; background:#dfeee7; }.grade-c { color:#956019; background:var(--yellow-soft); }.grade-d { color:#747c78; background:#ecefec; }
.source-state { padding:5px 7px; border-radius:6px; font-size:8px; white-space:nowrap; }.source-state.ready,.source-state.active { color:var(--green); background:var(--green-soft); }.source-state.review { color:#a3561f; background:var(--orange-soft); }.source-state.safe { color:#626b67; background:#edf0ed; }
.knowledge-side { display:grid; align-content:start; gap:12px; }.learning-loop,.review-card { overflow:hidden; }.learning-loop ol { margin:0; padding:8px 16px 16px; list-style:none; }.learning-loop li { display:flex; align-items:center; gap:10px; padding:10px 0; border-bottom:1px solid var(--line); }.learning-loop li:last-child { border:0; }.learning-loop li i { width:24px; height:24px; display:grid; place-items:center; border-radius:50%; color:var(--green); background:var(--green-soft); font-style:normal; font-size:9px; font-weight:700; }.learning-loop b,.learning-loop small { display:block; }.learning-loop b { font-size:9px; }.learning-loop small { margin-top:2px; color:var(--muted); font-size:8px; }.review-card { padding:17px 16px; }.review-card h2 { margin-bottom:12px; }.review-card ul { margin:0; padding:0 0 0 17px; color:#4c5852; font-size:9px; line-height:2; }.review-card .wide-button { width:100%; margin:12px 0 0; }
.project-toolbar { padding: 18px 20px; display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.project-toolbar h2 { margin: 5px 0 4px; font-size: 20px; }.project-toolbar p { margin-bottom: 0; color: var(--muted); font-size: 10px; }
.back-button { margin-bottom: 13px; padding: 0; border: 0; color: var(--green); background: transparent; font-size: 10px; }
.toolbar-actions { display: flex; gap: 8px; }
.progress-card { padding: 20px 28px; }
.progress-steps { display: flex; align-items: center; justify-content: center; }
.step { display: flex; align-items: center; gap: 9px; }
.step i { width: 28px; height: 28px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid #cfd6d2; border-radius: 50%; color: #87918c; font-style: normal; font-size: 10px; }
.step span, .step small { display: block; white-space: nowrap; }.step span { font-size: 10px; font-weight: 600; }.step small { margin-top: 2px; color: var(--muted); font-size: 8px; font-weight: 400; }
.step.done i { color: #fff; border-color: var(--green); background: var(--green); }.step.active i { color: var(--green); border: 2px solid var(--green); }.step.active span { color: var(--green-dark); }
.line { width: clamp(25px, 5vw, 75px); height: 1px; margin: 0 10px; background: #d9deda; }.line.done { background: var(--green); }
.project-grid { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 12px; }
.items-panel { min-width: 0; }
.table-filters { padding: 0; border: 0; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; font-size: 9px; }
th { color: var(--muted); background: #f7f8f6; font-weight: 500; }
td strong, td small { display: block; }td strong { margin-bottom: 3px; font-size: 10px; }td small { color: var(--muted); font-size: 8px; }
.status { display: inline-block; padding: 4px 6px; border-radius: 5px; font-size: 8px; }.status.ready { color: var(--green); background: var(--green-soft); }.status.wait { color: #9e5a1d; background: var(--orange-soft); }.status.quoted { color: #415c81; background: #eaf0fa; }
.project-side { display: grid; align-content: start; gap: 12px; }.side-card { overflow: hidden; }
.supplier-progress { padding: 5px 16px 14px; }.supplier-row { padding: 11px 0; border-bottom: 1px solid var(--line); }.supplier-row:last-child { border: 0; }.supplier-row div { display: flex; justify-content: space-between; }.supplier-row b { font-size: 10px; }.supplier-row span { font-size: 8px; color: var(--muted); }.mini-progress { height: 4px; margin-top: 7px; overflow: hidden; border-radius: 3px; background: #edf0ed; }.mini-progress i { display: block; height: 100%; background: var(--green); }
.quote-guard { padding: 17px 16px; }.quote-guard h2 { margin-bottom: 13px; }.quote-guard ul { padding: 0; list-style: none; display: grid; gap: 8px; font-size: 9px; }.quote-guard .pass { color: var(--green); }.quote-guard .fail { color: var(--red); }.quote-guard .warn { color: var(--yellow); }.quote-guard .wide-button { width: 100%; margin: 10px 0 7px; }.quote-guard > small { display: block; color: var(--muted); font-size: 8px; line-height: 1.5; }.danger-disabled { background: #6b756f; }

.hidden { display: none !important; }
.empty-state { min-height: 500px; display: grid; place-items: center; align-content: center; text-align: center; }.empty-state > span { width: 55px; height: 55px; display: grid; place-items: center; border-radius: 16px; color: #fff; background: var(--green); font-weight: 700; }.empty-state h2 { margin: 16px 0 7px; font-size: 22px; }.empty-state p { color: var(--muted); font-size: 11px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(10,20,16,.52); backdrop-filter: blur(5px); }
.modal { position: relative; width: min(510px, 100%); padding: 28px; border-radius: 14px; background: #fff; box-shadow: 0 30px 80px rgba(0,0,0,.25); }.modal h2 { margin: 5px 0 9px; font-size: 22px; }.modal > p:not(.eyebrow) { color: var(--muted); font-size: 11px; line-height: 1.6; }.modal-close { position: absolute; top: 15px; right: 15px; border: 0; background: transparent; color: #777; font-size: 23px; }
.dropzone { min-height: 150px; margin: 20px 0 13px; display: grid; place-items: center; align-content: center; gap: 5px; border: 1.5px dashed #a7bcb1; border-radius: 10px; background: #f5f9f7; cursor: pointer; }.dropzone span { color: var(--green); font-size: 28px; }.dropzone b { font-size: 12px; }.dropzone small { color: var(--muted); font-size: 9px; }.privacy-note { padding: 10px; border-radius: 7px; color: #75592a; background: var(--yellow-soft); font-size: 9px; line-height: 1.5; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 40; max-width: 350px; padding: 12px 16px; border-radius: 9px; color: #fff; background: #16241e; box-shadow: 0 12px 34px rgba(0,0,0,.2); opacity: 0; pointer-events: none; transform: translateY(10px); transition: .2s ease; font-size: 11px; }.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 245px minmax(420px, 1fr); }.insight-panel { display: none; }
  .metrics,.knowledge-metrics { grid-template-columns: repeat(2, 1fr); }.project-grid,.knowledge-grid { grid-template-columns: 1fr; }.project-side { grid-template-columns: 1fr 1fr; }.knowledge-side { grid-template-columns:1fr 1fr; }
}
@media (max-width: 850px) {
  .app-shell { grid-template-columns: 68px minmax(0, 1fr); }.sidebar { padding-inline: 9px; }.brand { padding-inline: 4px; }.brand > div:last-child, .nav-item:not(.active) b, .nav-item { font-size: 0; }.business-switcher { padding:7px 4px; }.business-switcher span { display:none; }.business-switcher select { font-size:0; height:20px; }.business-switcher select:focus { font-size:9px; }.nav-item { grid-template-columns: 1fr; place-items: center; }.nav-item span { font-size: 9px; }.account-card { grid-template-columns: 1fr; }.account-card > div:nth-child(2), .account-card i { display: none; }
  .main-area { padding: 18px 14px; }.topbar { align-items: flex-start; }.top-actions { flex-wrap: wrap; justify-content: flex-end; }.search-box { order: 3; width: 100%; }.workspace { grid-template-columns: 1fr; }.conversation-list { display: none; }.project-toolbar,.knowledge-hero { align-items: flex-start; flex-direction: column; }.progress-card { overflow-x: auto; }.project-side,.knowledge-side { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .main-area { padding-inline: 10px; }.topbar { flex-direction: column; }.top-actions { width: 100%; justify-content: flex-start; }.search-box { width: 100%; }.metrics { grid-template-columns: 1fr 1fr; }.metrics article { padding: 11px; }.metrics strong { font-size: 18px; }.chat-header { align-items: flex-start; gap: 8px; }.mode-switch { align-items: flex-end; flex-direction: column; }.context-strip { gap: 5px 9px; }.draft-heading { gap: 6px; flex-direction: column; }.project-toolbar .toolbar-actions { flex-direction: column; width: 100%; }.project-toolbar .toolbar-actions button { width: 100%; }.progress-steps { justify-content: flex-start; }.step span { display: none; }
}
#system-status { font-size: 12px; color: #a34b35; background: #fff3ec; border: 1px solid #ffd6c4; border-radius: 999px; padding: 7px 11px; white-space: nowrap; }
#system-status.connected { color: #16704a; background: #eaf8f0; border-color: #bde8cf; }
.setup-overlay { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 24px; background: rgba(14,24,38,.62); backdrop-filter: blur(8px); }
.setup-card { width: min(440px, 100%); display: grid; gap: 16px; padding: 30px; border-radius: 22px; background: #fff; box-shadow: 0 24px 80px rgba(0,0,0,.28); }
.setup-card h2,.setup-card p { margin: 0; }
.setup-card label { display: grid; gap: 7px; color: #4d5968; font-size: 13px; font-weight: 700; }
.setup-card input { min-height: 44px; border: 1px solid #d8dee7; border-radius: 10px; padding: 0 12px; font: inherit; }
#setup-error { color: #b92e2e; min-height: 18px; }
