:root {
  --brand: #0d5c54; --brand-2: #127a6f; --brand-soft: #e6f2f0;
  --ink: #1b2330; --muted: #677284; --line: #e2e6eb; --bg: #f4f6f8; --card: #fff;
  --ok: #178044; --warn: #b87404; --bad: #c02626; --gold: #b8892d;
  --radius: 14px; --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); height: 100%; }
body { display: flex; flex-direction: column; }
a { color: var(--brand); }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 10px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; transition: .15s; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.primary:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--brand); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--brand); }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.big { padding: 15px 28px; font-size: 17px; }
.btn.block { display: flex; width: 100%; margin-top: 8px; }
.btn.link { background: none; border: none; color: var(--brand); padding: 4px 6px; font-weight: 600; }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 17px; color: var(--brand); display: flex; align-items: center; gap: 8px; }
.logo { color: var(--gold); font-size: 20px; }
.top-actions { display: flex; gap: 8px; }
.mobile-only { display: none; }

/* Landing */
.landing { max-width: 1000px; margin: 0 auto; padding: 56px 20px; }
.hero { text-align: center; max-width: 720px; margin: 0 auto 48px; }
.hero h1 { font-size: clamp(30px, 5vw, 46px); margin: 0 0 16px; line-height: 1.15; }
.hero h1 span { color: var(--brand); }
.lead { font-size: 18px; color: var(--muted); line-height: 1.55; margin: 0 0 28px; }
.fine { color: var(--muted); font-size: 13px; margin-top: 14px; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.features div { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.features p { color: var(--muted); font-size: 14px; margin: 8px 0 0; line-height: 1.5; }

/* Shell */
.shell { flex: 1; display: grid; grid-template-columns: 300px 1fr; min-height: 0; max-width: 1280px; width: 100%; margin: 0 auto; }
.side { padding: 16px; overflow-y: auto; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.card-title { font-weight: 700; font-size: 14px; margin-bottom: 10px; }
.ref { font-weight: 700; font-size: 18px; margin: 2px 0 8px; font-variant-numeric: tabular-nums; }
.status-pill { display: inline-block; background: var(--brand-soft); color: var(--brand); border-radius: 99px; padding: 4px 10px; font-size: 12px; font-weight: 600; }

.progress, .timeline { list-style: none; margin: 0; padding: 0; }
.progress li, .timeline li { position: relative; padding: 0 0 12px 24px; font-size: 13px; color: var(--muted); }
.progress li::before, .timeline li::before { content: ""; position: absolute; left: 4px; top: 3px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line); background: #fff; }
.progress li::after, .timeline li::after { content: ""; position: absolute; left: 9px; top: 16px; bottom: 0; width: 2px; background: var(--line); }
.progress li:last-child::after, .timeline li:last-child::after { display: none; }
li.done { color: var(--ink); } li.done::before { background: var(--brand); border-color: var(--brand); }
li.current { color: var(--brand); font-weight: 700; } li.current::before { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
li.editable { cursor: pointer; }
li.editable:hover { color: var(--brand); }
.edit-hint { font-size: 11px; color: var(--brand); font-weight: 600; opacity: .8; }
.msg.user .edit-link { display: block; margin-left: auto; font-size: 12px; padding: 2px 4px; }
.kv-v { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.kv-v .btn.link { padding: 0 4px; font-size: 12px; white-space: nowrap; }
.tag.req { background: #fff3d6; color: #8a5a00; font-weight: 700; margin-left: 6px; }
.visa-item { font-size: 13px; padding: 6px 0; border-top: 1px dashed var(--line); }

/* Chat */
.chat { display: flex; flex-direction: column; min-height: 0; height: calc(100vh - 57px); }
.messages { flex: 1; overflow-y: auto; padding: 24px 24px 8px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: min(760px, 92%); line-height: 1.55; font-size: 15px; }
.msg .bubble { padding: 12px 15px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; }
.msg.assistant .bubble { background: #fff; border: 1px solid var(--line); border-top-left-radius: 4px; }
.msg.user { align-self: flex-end; }
.msg.user .bubble { background: var(--brand); color: #fff; border-top-right-radius: 4px; }
.msg.staff .bubble { background: #fff8e8; border: 1px solid #f0dca8; }
.msg .who { font-size: 12px; color: var(--muted); margin: 0 0 4px 4px; }
.typing .bubble { color: var(--muted); font-style: italic; }

.widget { margin-top: 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); white-space: normal; }
.widget.locked { opacity: .65; pointer-events: none; }
.widget .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.err { color: var(--bad); font-size: 14px; margin-top: 10px; white-space: pre-wrap; }

.field { margin-bottom: 14px; }
.field > label, .field > .lbl { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field input[type=text], .field input[type=email], .field input[type=tel], .field input[type=number], .field select, .field textarea, .grid-row input, .grid-row select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font: inherit; background: #fff; }
.field textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand) !important; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { border: 1px solid var(--line); border-radius: 99px; padding: 7px 13px; cursor: pointer; font-size: 14px; user-select: none; background: #fff; }
.opt input { display: none; }
.opt.on, .opt:has(input:checked) { background: var(--brand); color: #fff; border-color: var(--brand); }
.checks label { display: flex; gap: 8px; align-items: center; padding: 6px 0; font-size: 14px; }

/* Recommendation & comparison */
.rec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.rec { border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; position: relative; background: #fff; }
.rec.on { border-color: var(--brand); background: var(--brand-soft); }
.rec .name { font-weight: 700; font-size: 14px; padding-right: 20px; }
.rec .price { font-weight: 700; color: var(--brand); margin: 6px 0 4px; }
.rec .tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 11px; background: #f0f2f5; border-radius: 6px; padding: 2px 6px; color: var(--muted); }
.tag.best { background: #fff3d6; color: #8a5a00; font-weight: 700; }
.tag.type { background: var(--brand-soft); color: var(--brand); }
.rec .tick { position: absolute; top: 10px; right: 10px; width: 18px; height: 18px; border-radius: 5px; border: 2px solid var(--line); }
.rec.on .tick { background: var(--brand); border-color: var(--brand); }
.cmp-wrap { overflow-x: auto; }
table.cmp { border-collapse: collapse; width: 100%; min-width: 560px; font-size: 13.5px; }
table.cmp th, table.cmp td { border-bottom: 1px solid var(--line); padding: 9px 10px; text-align: left; vertical-align: top; }
table.cmp th { background: #fafbfc; font-size: 12px; color: var(--muted); font-weight: 600; width: 130px; }
table.cmp thead td { font-weight: 700; font-size: 14px; }
table.cmp ul { margin: 0; padding-left: 16px; }
.yes { color: var(--ok); font-weight: 600; } .no { color: var(--muted); }

/* People & documents */
.grid-row { display: grid; grid-template-columns: 2fr 1.4fr 80px auto auto 28px; gap: 8px; align-items: center; margin-bottom: 8px; }
.grid-row.head { font-size: 12px; color: var(--muted); font-weight: 600; }
.grid-row label { font-size: 13px; display: flex; gap: 4px; align-items: center; white-space: nowrap; }
.grid-row.visa { grid-template-columns: 2fr 1.3fr 1fr 1.3fr auto 28px; }
.x { border: none; background: none; color: var(--muted); font-size: 18px; cursor: pointer; }
.person { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; overflow: hidden; }
.person-h { background: #fafbfc; padding: 10px 12px; font-weight: 700; font-size: 14px; display: flex; justify-content: space-between; gap: 8px; }
.doc { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); align-items: center; }
.doc .t { font-weight: 600; font-size: 14px; }
.doc .h { font-size: 12px; color: var(--muted); }
.doc .notes { grid-column: 1 / -1; font-size: 12.5px; margin: 0; padding-left: 18px; }
.doc .notes li.bad { color: var(--bad); } .doc .notes li { color: var(--warn); }
.chip { font-size: 11px; font-weight: 700; border-radius: 6px; padding: 2px 7px; text-transform: uppercase; }
.chip.valid { background: #e3f4ea; color: var(--ok); } .chip.warning { background: #fdf1d9; color: var(--warn); }
.chip.invalid { background: #fbe4e4; color: var(--bad); } .chip.pending { background: #eef0f3; color: var(--muted); } .chip.missing { background: #fff; color: var(--muted); border: 1px dashed var(--line); }
.doc-actions { display: flex; gap: 6px; align-items: center; }
.upl { position: relative; overflow: hidden; }
.upl input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.opt-label { font-size: 11px; color: var(--muted); font-weight: 400; }

/* Review & estimate */
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 14px; margin-bottom: 12px; }
.kv div:nth-child(odd) { color: var(--muted); }
table.est { width: 100%; border-collapse: collapse; font-size: 14px; }
table.est td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.est td:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.est tr.sec td { font-weight: 700; color: var(--brand); font-size: 12px; text-transform: uppercase; border-bottom: none; padding-top: 12px; }
table.est tr.total td { font-weight: 800; font-size: 16px; border-top: 2px solid var(--brand); border-bottom: none; }
.pay-cta { text-align: center; padding: 8px 0; }

.composer { display: flex; gap: 8px; padding: 12px 24px 18px; border-top: 1px solid var(--line); background: var(--bg); }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font: inherit; max-height: 140px; }
.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 20; max-width: 90vw; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 57px 0 0 0; background: var(--bg); z-index: 4; transform: translateX(-100%); transition: transform .2s; border: none; }
  .side.open { transform: none; }
  .mobile-only { display: inline-flex; }
  .messages { padding: 16px 12px 8px; }
  .composer { padding: 10px 12px 14px; }
  .msg { max-width: 100%; }
  .grid-row, .grid-row.visa { grid-template-columns: 1fr 1fr; }
  .grid-row.head { display: none; }
  .kv { grid-template-columns: 1fr; }
  .kv div:nth-child(odd) { margin-top: 6px; }
}
