:root {
    --bg: #f6f7f9; --card: #fff; --ink: #1d2433; --muted: #5d6676; --line: #e3e6eb;
    --brand: #0b5cad; --brand-soft: #e7f0fa; --ok: #1f7a4a; --ok-soft: #e5f4ec;
    --warn: #9a5b00; --warn-soft: #fdf1dc; --bad: #a3282b; --bad-soft: #fbe8e8;
    --ai: #6b3fb5; --ai-soft: #f1ebfa;
  }
  * { box-sizing: border-box; }
  body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
  header { background: var(--card); border-bottom: 1px solid var(--line); padding: 10px 20px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
  .logo { font-weight: 700; font-size: 18px; color: var(--brand); }
  .logo span { color: var(--ink); font-weight: 500; }
  nav { display: flex; gap: 4px; flex-wrap: wrap; }
  nav button { border: 0; background: none; padding: 8px 12px; border-radius: 8px; font: inherit; color: var(--muted); cursor: pointer; }
  nav button.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
  .profile-switch { margin-left: auto; display: flex; gap: 8px; align-items: center; }
  select, input, textarea { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
  main { max-width: 1180px; margin: 0 auto; padding: 20px; }
  .mock-banner { background: var(--warn-soft); color: var(--warn); padding: 8px 20px; font-size: 13px; text-align: center; }
  h1 { font-size: 22px; margin: 0 0 4px; }
  h2 { font-size: 17px; margin: 0 0 12px; }
  .sub { color: var(--muted); margin: 0 0 18px; }
  .grid { display: grid; gap: 16px; }
  .g4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
  .g2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
  .card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
  .stat .n { font-size: 28px; font-weight: 700; }
  .stat .l { color: var(--muted); font-size: 13px; }
  .pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
  .p-ok { background: var(--ok-soft); color: var(--ok); }
  .p-warn { background: var(--warn-soft); color: var(--warn); }
  .p-bad { background: var(--bad-soft); color: var(--bad); }
  .p-ai { background: var(--ai-soft); color: var(--ai); }
  .p-info { background: var(--brand-soft); color: var(--brand); }
  .btn { border: 1px solid var(--brand); background: var(--brand); color: #fff; padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; }
  .btn.ghost { background: #fff; color: var(--brand); }
  .btn.sm { padding: 4px 10px; font-size: 13px; }
  table { width: 100%; border-collapse: collapse; }
  th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
  th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
  .match { display: grid; grid-template-columns: 64px 1fr 200px; gap: 14px; align-items: start; }
  .score { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 17px; }
  .reasons { margin: 8px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
  .reasons li { font-size: 12.5px; padding: 2px 8px; border-radius: 6px; }
  .r-ok { background: var(--ok-soft); color: var(--ok); }
  .r-bad { background: var(--bad-soft); color: var(--bad); }
  .r-q { background: var(--warn-soft); color: var(--warn); }
  .meta { color: var(--muted); font-size: 13px; }
  .filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
  .field { display: grid; grid-template-columns: 220px 1fr 130px; gap: 12px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .field label { font-weight: 600; font-size: 14px; }
  .field .src { font-size: 12px; text-align: right; }
  .field input, .field textarea { width: 100%; }
  .field.missing input { border-color: var(--warn); background: #fffaf0; }
  .field.ai textarea { border-color: #cdb8ee; background: #fbf9fe; }
  .split { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
  .chat .msg { padding: 9px 12px; border-radius: 10px; margin-bottom: 8px; font-size: 14px; }
  .chat .agent { background: var(--ai-soft); }
  .chat .user { background: var(--brand-soft); margin-left: 30px; }
  .kanban { display: grid; grid-template-columns: repeat(6, minmax(175px, 1fr)); gap: 12px; overflow-x: auto; }
  .col { background: #eef0f3; border-radius: 10px; padding: 10px; min-height: 260px; }
  .col h3 { font-size: 13px; margin: 2px 4px 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
  .ticket { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 9px; margin-bottom: 8px; font-size: 13.5px; }
  .ticket b { display: block; margin-bottom: 3px; }
  .profile-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 16px; }
  .profile-form label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
  fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px 16px; margin: 0 0 16px; background: #fff; }
  legend { font-weight: 700; padding: 0 6px; }
  .check { display: flex; gap: 8px; align-items: center; font-weight: 500 !important; color: var(--ink) !important; }
  .hidden { display: none !important; }
  .deadline-soon { color: var(--bad); font-weight: 600; }
  .note { font-size: 13px; color: var(--muted); }
  .checklist { list-style: none; padding: 0; margin: 0; }
  .checklist li { padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
  .stat.link { cursor: pointer; }
  .stat.link:hover { border-color: var(--brand); }
  .stat .n.ok { color: var(--ok); } .stat .n.bad { color: var(--bad); } .stat .n.warn { color: var(--warn); } .stat .n.brand { color: var(--brand); }
  .stat.big { grid-column: span 2; }
  .due { text-align: right; min-width: 108px; }
  .due .d { font-weight: 700; }
  .due.soon .d, .due.soon .days { color: var(--bad); }
  .due .days { font-size: 12.5px; color: var(--muted); }
  .p-new { background: #e6f6f8; color: #0b6e7a; }
  .p-neutral { background: #eef0f3; color: var(--muted); }
  .feed { list-style: none; margin: 0; padding: 0; }
  .feed li { display: grid; grid-template-columns: 92px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
  .ticket select, .ticket input { width: 100%; font-size: 13px; padding: 4px 6px; margin-top: 6px; }
  .ticket .row { display: grid; grid-template-columns: 1fr; gap: 0; }
  .ticket .row label { font-size: 11px; color: var(--muted); display: grid; margin-top: 6px; }
  .ticket .row label input { margin-top: 2px; }
  .ticket .amt { font-weight: 700; color: var(--ok); }
  .seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
  .seg button { border: 0; background: #fff; padding: 6px 12px; font: inherit; font-size: 14px; cursor: pointer; color: var(--muted); }
  .seg button.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
  .toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
  .toolbar .right { margin-left: auto; display: flex; gap: 8px; }
  .tablewrap { overflow-x: auto; }
  .mail .mail-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
  .mail .mail-subj { font-weight: 600; margin: 4px 0 2px; }
  .mail .mail-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
  .mail.done { opacity: .7; }
  .mail-foot select { max-width: 320px; }
  #mailBadge:empty { display: none; }
  code { background: #eef0f3; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
  .live-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
  .fake-browser { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
  .fake-browser .bar { background: #eef0f3; padding: 6px 10px; font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 32px; }
  .fake-browser .viewport { height: 340px; overflow-y: auto; padding: 12px; }
  .fake-login { display: grid; gap: 8px; max-width: 260px; margin: 30px auto; outline: 3px solid var(--warn); outline-offset: 8px; border-radius: 6px; }
  .fake-form .ff { display: grid; grid-template-columns: 150px 1fr; gap: 8px; font-size: 12.5px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
  .fake-form .ff .v { background: #f6f7f9; border-radius: 4px; padding: 1px 6px; min-height: 18px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .fake-form .ff.cur .v { outline: 2px solid var(--ai); }
  .live-log { list-style: none; margin: 0; padding: 0; height: 300px; overflow-y: auto; font-size: 13px; }
  .live-log li { padding: 4px 0; border-bottom: 1px solid var(--line); }
  .live-log li.wait { color: var(--warn); font-weight: 600; }
  .live-log li.ok { color: var(--ok); font-weight: 600; }
  .pulse { box-shadow: 0 0 0 0 rgba(11,92,173,.6); animation: pulse 1.4s infinite; }
  @keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(11,92,173,0); } 100% { box-shadow: 0 0 0 0 rgba(11,92,173,0); } }
  @media (max-width: 860px) { .live-grid { grid-template-columns: 1fr; } .fake-browser .viewport { height: 260px; } .live-log { height: 180px; } }
  .chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; }
  .chip { display: inline-flex; gap: 6px; align-items: center; background: var(--brand-soft); color: var(--brand); border-radius: 999px; padding: 4px 6px 4px 12px; font-weight: 600; font-size: 13px; }
  .chip button { border: 0; background: #fff; color: var(--brand); border-radius: 50%; width: 22px; height: 22px; cursor: pointer; font-size: 14px; line-height: 1; }
  .apps-grid { display: grid; grid-template-columns: 270px 1fr; gap: 16px; align-items: start; }
  .app-item { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; cursor: pointer; font-size: 14px; }
  .app-item.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
  .prog { height: 6px; background: #eef0f3; border-radius: 4px; margin: 6px 0 3px; overflow: hidden; }
  .prog span { display: block; height: 100%; background: var(--ok); }
  .ws-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
  .tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
  .tabs button { border: 0; background: none; padding: 7px 10px; font: inherit; font-size: 13.5px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
  .tabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
  .tabs button:disabled { opacity: .45; cursor: default; }
  .ws-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 16px; align-items: start; }
  .ws-source { position: sticky; top: 10px; }
  .fake-browser .viewport.tall { height: 470px; }
  .q { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; background: #fff; cursor: pointer; }
  .q.ok { border-color: #b9dfc9; background: #fbfefc; }
  .q.need { border-color: var(--warn); background: #fffaf0; }
  .q.active { box-shadow: 0 0 0 2px var(--ai); }
  .q-head { display: flex; gap: 8px; align-items: baseline; }
  .q-num { flex: none; width: 22px; height: 22px; border-radius: 50%; background: #eef0f3; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
  .q-text { font-weight: 600; }
  .q input, .q textarea { width: 100%; }
  .q-actions { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
  .over { color: var(--bad) !important; font-weight: 700; }
  .sign-box { background: #f6f7f9; border: 1px dashed var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13.5px; }
  .ws-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
  .pdf-wrap { background: #e5e7eb; padding: 14px; border-radius: 10px; max-height: 520px; overflow-y: auto; }
  .pdf-page { background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.15); padding: 22px 24px; font-family: Georgia, serif; font-size: 12.5px; }
  .pdf-title { font-weight: 700; font-size: 15px; text-align: center; }
  .pdf-sub { text-align: center; color: var(--muted); font-size: 11px; margin-bottom: 12px; font-family: system-ui, sans-serif; }
  .pdf-field { margin-bottom: 7px; }
  .pdf-box { border-bottom: 1px solid #444; min-height: 18px; color: #1747a6; font-family: system-ui, sans-serif; padding: 1px 4px; white-space: pre-wrap; }
  .pdf-field.long .pdf-box { border: 1px solid #444; min-height: 54px; max-height: 90px; overflow: hidden; font-size: 11.5px; }
  .pdf-box.sig { border-bottom-style: dashed; min-height: 26px; }
  .pdf-field.cur, .hand.cur { outline: 2px solid var(--ai); outline-offset: 2px; border-radius: 3px; }
  .photo { background: #6b6f76; padding: 18px; border-radius: 10px; }
  .paper { background: #fdfcf7; transform: rotate(-1.2deg); padding: 18px; box-shadow: 0 4px 14px rgba(0,0,0,.35); font-family: Georgia, serif; font-size: 13px; }
  .hand { margin: 9px 0; line-height: 1.6; position: relative; padding-left: 28px; }
  .marker { position: absolute; left: 0; top: 1px; width: 21px; height: 21px; border-radius: 50%; background: var(--ai); color: #fff; font: 700 11px system-ui, sans-serif; display: grid; place-items: center; }
  .pasted textarea { width: 100%; font-size: 13.5px; }
  .src-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .src-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px; cursor: pointer; display: grid; gap: 2px; font-size: 14px; }
  .src-card.on { border-color: var(--brand); background: var(--brand-soft); }
  .src-card .big { font-size: 22px; }
  dialog.wide { max-width: 560px; }
  .analyzing { text-align: center; padding: 50px 20px; }
  .spinner { width: 34px; height: 34px; border: 4px solid var(--brand-soft); border-top-color: var(--brand); border-radius: 50%; margin: 0 auto 12px; animation: spin 0.8s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
  #toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 8px; font-size: 14px; transition: opacity .2s; z-index: 10; opacity: 0; visibility: hidden; }
  #toast.on { opacity: 1; visibility: visible; }
  .btn:disabled { opacity: .4; cursor: default; }
  @media (max-width: 1000px) { .apps-grid { grid-template-columns: 1fr; } .ws-grid { grid-template-columns: 1fr; } .ws-source { position: static; } .fake-browser .viewport.tall { height: 320px; } }
  @media (max-width: 560px) { .src-cards { grid-template-columns: 1fr; } }
  .p-tag { background: #fdeef6; color: #9b2c66; }
  .unlock { border-color: #e3c7f5; background: #fbf7fe; margin-bottom: 14px; }
  .chip-q { border: 1px dashed var(--ai); background: #fff; color: var(--ai); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
  .bgc { border: 1px dashed #b8bec8; background: #fff; color: var(--muted); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; }
  .bgc.yes { border: 1px solid var(--ok); background: var(--ok-soft); color: var(--ok); font-weight: 600; }
  .bgc.no { border: 1px solid var(--line); background: #f3f4f6; color: #9aa1ab; text-decoration: line-through; }
  .bgc:disabled { cursor: default; }
  dialog { border: 1px solid var(--line); border-radius: 12px; padding: 18px; max-width: 420px; width: 92vw; }
  dialog form { display: grid; gap: 10px; }
  dialog label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
  @media (max-width: 860px) {
    .split { grid-template-columns: 1fr; }
    .field { grid-template-columns: 1fr; gap: 4px; }
    .field .src { text-align: left; }
    .match { grid-template-columns: 52px 1fr; }
    .match > :last-child { grid-column: 1 / -1; }
    .profile-switch { margin-left: 0; }
    #statsOpp, #statsApp { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .stat { padding: 12px; }
    .stat .n { font-size: 24px; }
    .stat.big { grid-column: 1 / -1; }
    .due { text-align: left; }
  }
.src-card.off { opacity: .5; cursor: default; }
.profile-form label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; font-weight: 500; }
.auth-card { max-width: 420px; margin: 50px auto; }
.auth-card form { display: grid; gap: 12px; margin-top: 10px; }
.auth-card label, #inviteForm label, #pwForm label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
#inviteForm, #pwForm { display: grid; gap: 10px; }
#inviteForm label.check { display: flex; }
.linkbox { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.linkbox input { flex: 1; min-width: 260px; font-family: ui-monospace, monospace; font-size: 13px; }
#whoami a { color: var(--brand); cursor: pointer; }
.code-input { font-size: 22px !important; letter-spacing: 4px; text-align: center; font-family: ui-monospace, monospace; }
.qr { display: grid; place-items: center; margin: 8px 0; }
.qr svg { width: 220px; height: 220px; }
.backup-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; font: 600 16px ui-monospace, monospace; background: #f6f7f9; border-radius: 8px; padding: 12px; text-align: center; }
