:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --ink: #1e2a38;
  --muted: #5f6b7a;
  --line: #e1e6ee;
  --accent: #0074ff;          /* Blue Dots brand: Blue 500 */
  --accent-soft: #e6f0ff;     /* Blue Dots brand: Pale Lilac */
  --green: #d9ead3;
  --green-ink: #2f6b23;
  --yellow: #fff2cc;
  --yellow-ink: #7a5a00;
  --red: #f4cccc;
  --red-ink: #8a1f1f;
  --shadow: 0 1px 2px rgba(20, 16, 40, .06), 0 4px 16px rgba(20, 16, 40, .05);
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  display: flex; flex-direction: column;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
a { color: var(--accent); }

/* Header */
.top {
  height: 56px; flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; }
.bd-logo { display: block; height: 34px; width: auto; }
.brand-divider { width: 1px; height: 28px; background: var(--line); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; font-size: 15.5px; letter-spacing: -.01em; }
.brand-tag { font-size: 11.5px; color: var(--muted); }
.hero-logo { display: block; height: 56px; width: auto; margin-bottom: 18px; }
.scope { background: var(--accent-soft); border: 1px solid #bcd6ff; border-left: 4px solid var(--accent); border-radius: 10px;
  padding: 12px 14px; font-size: 13.5px; line-height: 1.5; color: #1e2a38; margin: 4px 0 22px; }
.net-name { font-weight: 500; color: var(--muted); }
.net-name:not(:empty)::before { content: "/"; margin: 0 8px 0 2px; color: var(--line); }
.downloads { display: flex; align-items: center; gap: 8px; }
.pill {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink);
  text-decoration: none; font-size: 13px; font-weight: 500; cursor: pointer; background: var(--surface);
}
.pill:hover { border-color: var(--accent); color: var(--accent); }
.pill.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Buttons and inputs */
.btn {
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--surface);
  border-radius: 10px; padding: 10px 16px; cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:disabled { opacity: .5; cursor: default; }
.btn.big { width: 100%; padding: 14px; font-size: 16px; margin-top: 8px; }

/* Start screen */
.start { flex: 1; overflow: auto; display: flex; justify-content: center; padding: 40px 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.start-card { width: 100%; max-width: 640px; padding: 32px; align-self: flex-start; }
.start-card h1 { margin: 0 0 8px; font-size: 26px; letter-spacing: -.01em; }
.lead { color: var(--muted); margin: 0 0 24px; }
.field { display: block; margin-bottom: 20px; }
.field > span { display: block; font-weight: 600; margin-bottom: 8px; }
.field input, .field select {
  width: 100%; font: inherit; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.field input:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.choice {
  text-align: left; font: inherit; padding: 14px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; cursor: pointer; display: flex; flex-direction: column; gap: 4px;
}
.choice small { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.choice.selected { border-color: var(--accent); background: var(--accent-soft); }
.drop {
  position: relative; border: 1.5px dashed var(--line); border-radius: 10px; padding: 18px; text-align: center;
  margin-bottom: 16px; background: #fafcff;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop p { margin: 2px 0; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-list { list-style: none; padding: 0; margin: 10px 0 0; text-align: left; }
.file-list li { font-size: 13px; padding: 4px 8px; background: var(--accent-soft); border-radius: 6px; margin-top: 4px; }

/* Workspace */
.work { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(340px, 42%) 1fr; }
.chat { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--surface); }
.messages { flex: 1; overflow: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 92%; padding: 10px 14px; border-radius: 14px; word-wrap: break-word; }
.msg p { margin: 0 0 8px; } .msg p:last-child { margin-bottom: 0; }
.msg ul, .msg ol { margin: 4px 0 8px; padding-left: 20px; }
.msg.agent { align-self: flex-start; background: var(--bg); border-top-left-radius: 4px; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-top-right-radius: 4px; }
.msg.note { align-self: center; background: transparent; color: var(--muted); font-size: 13px; padding: 2px 8px; }
.msg.error { align-self: stretch; background: #fdeeee; color: var(--red-ink); font-size: 14px; }
.activity { display: flex; align-items: center; gap: 8px; padding: 6px 20px; color: var(--muted); font-size: 13px; }
.spinner {
  width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.composer textarea {
  flex: 1; font: inherit; resize: none; max-height: 160px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
}
.attach { position: relative; display: grid; place-items: center; width: 40px; height: 42px; color: var(--muted); cursor: pointer; border-radius: 10px; }
.attach:hover { background: var(--bg); color: var(--accent); }
.attach input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Panel */
.panel { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.tabs { display: flex; gap: 4px; padding: 10px 16px 0; background: var(--bg); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button {
  font: inherit; font-weight: 500; font-size: 14px; color: var(--muted); background: none; border: none; padding: 10px 12px;
  border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; position: relative;
}
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); }
.tabs button.flash::after {
  content: ""; position: absolute; top: 8px; right: 2px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
}
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--line); font-size: 12px; text-align: center; }
.panel-body { flex: 1; overflow: auto; padding: 24px; }

/* Progress */
.progress-head { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.stat { flex: 1 1 140px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat b { display: block; font-size: 22px; }
.stat span { color: var(--muted); font-size: 13px; }
.checklist { list-style: none; padding: 0; margin: 0 0 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.checklist li { display: flex; gap: 12px; align-items: center; padding: 11px 14px; border-top: 1px solid var(--line); }
.checklist li:first-child { border-top: none; }
.tick { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); flex: 0 0 auto; display: grid; place-items: center; font-size: 12px; color: #fff; }
.done .tick { background: var(--green-ink); border-color: var(--green-ink); }
.done .tick::before { content: "✓"; }
.checklist .qid { color: var(--muted); font-size: 12px; width: 40px; }
h2.section { font-size: 15px; margin: 0 0 10px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: 0 0 14px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; }
.sw.asked { background: var(--green); } .sw.default { background: var(--yellow); } .sw.open { background: var(--red); }
.rule { padding: 8px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 6px; }
.rule.error { background: #fdeeee; color: var(--red-ink); }
.rule.warn { background: var(--yellow); color: var(--yellow-ink); }
.rule.ok { background: var(--green); color: var(--green-ink); }

/* Documents */
.doc { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 28px 32px; max-width: 980px; }
.doc h1 { font-size: 22px; margin-top: 0; } .doc h2 { font-size: 17px; margin-top: 28px; } .doc h3 { font-size: 15px; }
.doc table, .sheet table { border-collapse: collapse; width: 100%; font-size: 13.5px; margin: 8px 0 16px; }
.doc th, .doc td, .sheet th, .sheet td { border: 1px solid var(--line); padding: 7px 9px; text-align: left; vertical-align: top; }
.doc th, .sheet th { background: #eef3fb; font-weight: 600; }
.doc td:first-child { white-space: nowrap; }
.empty { color: var(--muted); text-align: center; padding: 60px 20px; }

/* Sheet preview */
.sheet-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.sheet-tabs button { font: inherit; font-size: 13px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.sheet-tabs button.active { border-color: var(--accent); background: var(--accent-soft); }
.sheet { overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.sheet table { margin: 0; font-size: 12.5px; min-width: 900px; }
.sheet th { position: sticky; top: 0; z-index: 1; }
.sheet td.asked { background: var(--green); } .sheet td.default { background: var(--yellow); } .sheet td.open { background: var(--red); }
.sheet th { min-width: 96px; white-space: nowrap; }
.sheet td { min-width: 96px; max-width: 320px; }
.sheet td:nth-child(2) { min-width: 200px; }
.sheet td:nth-child(5) { min-width: 240px; }
.sheet.profile td:nth-child(6), .sheet.profile td:nth-child(11), .sheet.profile td:nth-child(15),
.sheet.profile td:nth-child(20) { min-width: 260px; }
.sheet.registration td:nth-child(4), .sheet.registration td:nth-child(10) { min-width: 240px; }

/* Open items */
.oi { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--red-ink); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px; }
.oi b { display: block; } .oi .meta { color: var(--muted); font-size: 13px; margin-top: 4px; }

@media (max-width: 900px) {
  .work { grid-template-columns: 1fr; grid-template-rows: 55% 45%; }
  .chat { border-right: none; border-bottom: 1px solid var(--line); }
  .choices { grid-template-columns: 1fr; }
  .downloads .muted { display: none; }
  .panel-body { padding: 16px; }
  .doc { padding: 18px; }
}
@media (max-width: 600px) {
  .top { padding: 0 12px; }
  .net-name, #dlDm, #dlCn { display: none; }
  .brand { white-space: nowrap; }
  .brand-tag, .brand-divider { display: none; }
  .bd-logo { height: 26px; }
}

/* Tab title bar with its own download button(s) */
.tab-bar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.tab-title h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.tab-title p { margin: 3px 0 0; color: var(--muted); font-size: 13.5px; }
.tab-actions { display: flex; gap: 8px; flex-wrap: wrap; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; font-size: 14px; padding: 9px 16px; white-space: nowrap; }
a.btn.primary { box-shadow: 0 1px 2px rgba(0, 80, 200, .25); }
a.btn.primary:hover { filter: brightness(1.08); }
a.btn.primary::before { content: ""; width: 14px; height: 14px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11 3h2v10.17l3.59-3.58L18 11l-6 6-6-6 1.41-1.41L11 13.17z M5 19h14v2H5z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11 3h2v10.17l3.59-3.58L18 11l-6 6-6-6 1.41-1.41L11 13.17z M5 19h14v2H5z'/%3E%3C/svg%3E") center / contain no-repeat; }

/* Network JSON tab */
.file-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.file-tabs button { font: inherit; font-size: 13px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.file-tabs button.active { border-color: var(--accent); background: var(--accent-soft); }
pre.code { background: #1e2a38; color: #e8eef7; border-radius: 10px; padding: 16px; font-size: 12.5px; line-height: 1.5;
  max-height: 60vh; overflow: auto; margin: 0 0 14px; white-space: pre; }
details.todo { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-size: 13.5px; }
details.todo summary { cursor: pointer; font-weight: 600; }
details.todo ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); }

/* Long words, links and wide tables never push the page sideways */
.chat { min-width: 0; }
.msg { overflow-wrap: anywhere; }
.doc { overflow-x: auto; }
.doc td, .oi, .rule { overflow-wrap: anywhere; }
