/* Real Nirman — design tokens
   Brand (logo): ink #0B0B0C · gold #C8A964 · teal #366E87
   Secondary (proposed): stone #F3EFE7 (warm surfaces) · sage #7E9479 (success / approvals) */
:root {
  --ink: #0B0B0C; --gold: #C8A964; --teal: #366E87; --stone: #F3EFE7; --sage: #7E9479; --clay: #B4674A;
  --bg: #FBFAF7; --surface: #FFFFFF; --sidebar: var(--stone); --text: #17171A; --muted: #6B6A66; --line: #E5E0D6;
  --hover: #ECE6DA; --accent: var(--teal); --accent-ink: #fff; --gold-soft: #F4ECD9; --teal-soft: #E3EEF2; --sage-soft: #E8EEE6;
  --shadow: 0 1px 2px rgba(20, 18, 14, .05), 0 6px 24px rgba(20, 18, 14, .06);
  --radius: 14px; --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --display: "Manrope", var(--font);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121214; --surface: #1A1A1D; --sidebar: #0E0E10; --text: #EDEBE6; --muted: #A09D96; --line: #2A2A2E;
    --hover: #222226; --gold-soft: #2B2619; --teal-soft: #15262D; --sage-soft: #1C241B; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121214; --surface: #1A1A1D; --sidebar: #0E0E10; --text: #EDEBE6; --muted: #A09D96; --line: #2A2A2E;
  --hover: #222226; --gold-soft: #2B2619; --teal-soft: #15262D; --sage-soft: #1C241B; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--teal); }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--text); }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.01em; margin: 0; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 10px; padding: 9px 14px; font-weight: 600; font-size: 14px; text-decoration: none; color: var(--text); transition: background .15s, border-color .15s; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
:root[data-theme="dark"] .btn.primary { background: var(--gold); color: var(--ink); border-color: var(--gold); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { background: var(--gold); color: var(--ink); border-color: var(--gold); } }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon { width: 18px; height: 18px; flex: none; }

/* ------------------------------------------------------------------ layout */
.shell { display: grid; grid-template-columns: 284px 1fr; height: 100vh; height: 100dvh; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.sb-top { padding: 14px 14px 8px; display: flex; flex-direction: column; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand img { width: 30px; height: 30px; }
.brand b { font-family: var(--display); letter-spacing: .14em; font-size: 14px; }
.brand small { display: block; color: var(--muted); font-size: 11px; letter-spacing: .02em; }
.new-btn { width: 100%; justify-content: flex-start; padding: 10px 12px; }
.search { position: relative; }
.search input { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 10px 8px 32px; font-size: 14px; }
.search svg { position: absolute; left: 9px; top: 9px; color: var(--muted); }
.sb-scroll { overflow-y: auto; padding: 4px 8px 12px; flex: 1; min-height: 0; }
.sb-group { margin-top: 10px; }
.sb-group > header { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px; color: var(--muted); font-size: 11.5px;
  font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.sb-group > header .count { font-weight: 600; letter-spacing: 0; }
.p-item { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 9px; cursor: pointer; position: relative; font-size: 14px; }
.p-item:hover, .p-item.active { background: var(--hover); }
.p-item .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-item .more { opacity: 0; border: 0; background: none; padding: 2px 4px; border-radius: 6px; color: var(--muted); }
.p-item:hover .more, .p-item.active .more, .p-item .more:focus-visible { opacity: 1; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; }
.dot.running { background: var(--gold); animation: pulse 1.2s infinite; }
.dot.done { background: var(--sage); }
.dot.error { background: var(--clay); }
@keyframes pulse { 50% { opacity: .35; } }
.pin { color: var(--gold); font-size: 11px; }
.sb-foot { border-top: 1px solid var(--line); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 10px; cursor: pointer; border: 0; background: none; text-align: left; width: 100%; }
.user-card:hover { background: var(--hover); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: var(--gold); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.plan-badge { font-size: 11px; font-weight: 700; color: var(--teal); background: var(--teal-soft); padding: 1px 7px; border-radius: 99px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line); min-height: 56px; background: var(--bg); }
.topbar h1 { font-size: 16px; font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-alert { padding: 8px 18px; background: var(--gold-soft); border-bottom: 1px solid var(--line); font-size: 13px; display: grid; gap: 3px; }
.admin-alert a { color: inherit; font-weight: 600; }
.topbar select { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 5px 8px; font-size: 13px; }
.menu-btn { display: none; }
.content { flex: 1; overflow-y: auto; min-height: 0; }
.wrap { max-width: 980px; margin: 0 auto; padding: 24px 20px 40px; }

/* ------------------------------------------------------------------ wizard */
.hero-new { text-align: center; padding: 10px 0 22px; }
.hero-new img { width: 46px; height: 46px; }
.hero-new h2 { font-size: 28px; margin-top: 10px; }
.hero-new p { color: var(--muted); margin: 6px 0 0; }
.wiz { display: grid; grid-template-columns: 1fr 290px; gap: 20px; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.steps { display: flex; gap: 6px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); font-weight: 600; padding-right: 10px; }
.step i { font-style: normal; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; font-size: 12px; }
.step.on { color: var(--text); }
.step.on i { background: var(--ink); color: var(--gold); border-color: var(--ink); }
.step.done i { background: var(--sage); border-color: var(--sage); color: #fff; }
.form { padding: 18px; display: grid; gap: 16px; }
.form h3 { font-size: 18px; }
.field label.l { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.field .hint { color: var(--muted); font-size: 12.5px; }
.field input[type=text], .field input[type=number], .field input[type=email], .field input[type=password], .field select, .field textarea { width: 100%; border: 1px solid var(--line);
  background: var(--bg); border-radius: 10px; padding: 9px 11px; }
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .composer textarea:focus { outline: 2px solid var(--teal); outline-offset: 0; border-color: transparent; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.opt { border: 1.5px solid var(--line); background: var(--bg); border-radius: 11px; padding: 10px 12px; text-align: left; font-size: 13.5px; font-weight: 600; }
.opt:hover { border-color: var(--muted); }
.opt.on { border-color: var(--teal); background: var(--teal-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--bg); border-radius: 99px; padding: 5px 11px; font-size: 13px; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
:root[data-theme="dark"] .chip.on { background: var(--gold); color: var(--ink); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: var(--bg); padding: 8px 12px; font-size: 13px; font-weight: 600; }
.seg button.on { background: var(--teal); color: #fff; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
.check input { margin-top: 3px; accent-color: var(--teal); }
.drop { border: 1.5px dashed var(--line); border-radius: 12px; padding: 16px; text-align: center; color: var(--muted); font-size: 13.5px; cursor: pointer; }
.drop.over { border-color: var(--teal); background: var(--teal-soft); }
.files-list { list-style: none; padding: 0; margin: 8px 0 0; font-size: 13px; }
.wiz-nav { display: flex; justify-content: space-between; padding: 14px 18px; border-top: 1px solid var(--line); }
.estimate { position: sticky; top: 16px; padding: 18px; display: grid; gap: 12px; }
.estimate .k { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.estimate .v { font-family: var(--display); font-size: 24px; font-weight: 800; }
.estimate .v.small { font-size: 18px; }
.estimate .sub { color: var(--muted); font-size: 12.5px; }
.risk { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 800; letter-spacing: .04em; }
.risk.LOW { background: var(--sage-soft); color: var(--sage); }
.risk.MEDIUM { background: var(--gold-soft); color: #94782f; }
.risk.HIGH { background: #F6E3DC; color: var(--clay); }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--teal); border-radius: 99px; transition: width .4s; }

/* ------------------------------------------------------------------ thread */
.thread { display: flex; flex-direction: column; gap: 22px; }
.msg { display: flex; gap: 12px; }
.msg .who { width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.msg.user { flex-direction: row-reverse; }
.msg.user .bubble { background: var(--ink); color: #f4f2ec; border-radius: 16px 16px 4px 16px; max-width: 78%; padding: 11px 14px; }
:root[data-theme="dark"] .msg.user .bubble { background: #2A2A2E; }
.msg.user .who { background: var(--gold-soft); color: #8a6d24; }
.msg.ai .who { background: var(--ink); }
.msg.ai .who img { width: 20px; height: 20px; }
.msg.ai .body { flex: 1; min-width: 0; }
.msg.ai .text { padding-top: 4px; }

.result { overflow: hidden; }
.result-grid { display: grid; grid-template-columns: 250px 1fr; }
.links { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-right: 1px solid var(--line); background: var(--bg); }
.link-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--surface); display: grid; gap: 8px; }
.link-card .h { display: flex; gap: 10px; align-items: center; }
.link-card .n { width: 26px; height: 26px; border-radius: 8px; background: var(--ink); color: var(--gold); display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; }
.link-card b { font-size: 14px; line-height: 1.25; }
.link-card .meta { color: var(--muted); font-size: 12px; }
.link-card .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.figure { position: relative; background: #0d0d0f; min-height: 320px; }
.figure img { width: 100%; height: 100%; object-fit: cover; display: block; aspect-ratio: 16 / 10; }
.figure .tag { position: absolute; left: 12px; top: 12px; background: rgba(11, 11, 12, .72); color: #fff; font-size: 12px; padding: 4px 9px; border-radius: 99px; backdrop-filter: blur(6px); }
.stats { display: flex; gap: 18px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px; }
.stats div b { display: block; font-size: 15px; font-family: var(--display); }
.stats div span { color: var(--muted); }
.planning { padding: 16px; border-top: 1px solid var(--line); display: grid; gap: 14px; }
.planning .head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.planning .head h3 { font-size: 16px; flex: 1; }
.p-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.p-card { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--bg); border-top: 3px solid var(--teal); }
.p-card:nth-child(2) { border-top-color: var(--gold); }
.p-card:nth-child(3) { border-top-color: var(--clay); }
.p-card h4 { margin: 0 0 6px; font-size: 13.5px; }
.p-card ul, .next ol { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text); }
.p-card li, .next li { margin: 3px 0; }
.next { font-size: 13px; }
details.next summary { cursor: pointer; font-weight: 700; font-size: 13.5px; }
/* screening: likelihood, changes from the brief, consents, room standards, other regulations */
.s-box { display: grid; gap: 10px; }
.s-like, .s-note { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--bg); display: grid; gap: 6px; font-size: 13.5px; }
.s-note { border-left: 3px solid var(--gold); }
.s-note ul { margin: 6px 0 8px; padding-left: 18px; font-size: 13px; }
.s-note > div + div { margin-top: 6px; }
.s-text { color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.s-sub { font-weight: 700; font-size: 13px; margin-top: 8px; }
.s-row { padding: 8px 0; border-top: 1px solid var(--line); }
.s-title { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 13.5px; }
.s-tag { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: var(--hover); color: var(--muted); white-space: nowrap; }
.s-tag.needed, .s-tag.below, .s-tag.lower { background: #F6E3DC; color: var(--clay); }
.s-tag.likely, .s-tag.check, .s-tag.moderate { background: var(--gold-soft); color: #94782f; }
.s-tag.applies { background: var(--teal-soft); color: var(--teal); }
.s-tag.meets, .s-tag.higher { background: var(--sage-soft); color: var(--sage); }
details.next details.next { margin-top: 8px; }
details.next ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.src-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.src-links a { font-size: 12.5px; text-decoration: none; border: 1px solid var(--line); background: var(--surface); color: var(--teal);
  border-radius: 99px; padding: 3px 10px; }
.src-links a:hover { background: var(--teal-soft); }
.feedback { display: flex; gap: 6px; align-items: center; padding: 10px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.feedback .btn.on { background: var(--sage-soft); border-color: var(--sage); color: var(--sage); }
.pending { padding: 22px; display: grid; gap: 12px; }
.pending .stepline { display: flex; gap: 10px; align-items: center; font-size: 14px; color: var(--muted); }
.pending .stepline.on { color: var(--text); font-weight: 600; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.shimmer { height: 220px; border-radius: 12px; background: linear-gradient(90deg, var(--hover), var(--bg), var(--hover)); background-size: 200% 100%; animation: sh 1.4s infinite; }
@keyframes sh { to { background-position: -200% 0; } }
.err { color: var(--clay); }

.composer-wrap { border-top: 1px solid var(--line); background: var(--bg); padding: 12px 20px 16px; }
.composer { max-width: 980px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; border: 1px solid var(--line); background: var(--surface);
  border-radius: 16px; padding: 8px 8px 8px 14px; box-shadow: var(--shadow); }
.composer textarea { flex: 1; border: 0; resize: none; background: transparent; padding: 7px 0; max-height: 180px; min-height: 24px; }
.composer textarea:focus { outline: none; }
.suggest { max-width: 980px; margin: 0 auto 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.suggest .chip { cursor: pointer; }
.limit-note { max-width: 980px; margin: 0 auto 8px; color: var(--clay); font-size: 13px; text-align: center; }
.seg button:disabled { opacity: .55; cursor: not-allowed; }
.disclaimer { max-width: 980px; margin: 6px auto 0; color: var(--muted); font-size: 11.5px; text-align: center; }

/* ------------------------------------------------------------------ modal / menu / toast */
.menu { position: fixed; z-index: 50; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; min-width: 200px; }
.menu button { display: flex; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; font-size: 14px; gap: 8px; align-items: center; }
.menu button:hover { background: var(--hover); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.menu .sub { color: var(--muted); font-size: 11.5px; padding: 6px 10px 2px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.modal-bg { position: fixed; inset: 0; background: rgba(10, 10, 12, .45); display: grid; place-items: center; z-index: 60; padding: 16px; }
.modal { width: min(520px, 100%); max-height: 90vh; overflow: auto; padding: 22px; display: grid; gap: 14px; }
.modal h3 { font-size: 20px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 70; font-size: 14px; box-shadow: var(--shadow); }
.empty { color: var(--muted); font-size: 13px; padding: 8px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv span { color: var(--muted); }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1000px) {
  .wiz { grid-template-columns: 1fr; }
  .estimate { position: static; grid-template-columns: repeat(2, 1fr); }
  .result-grid { grid-template-columns: 1fr; }
  .result-grid .figure { order: -1; }
  .links { border-right: 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, 1fr); }
  .p-cards { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 86vw; max-width: 320px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .shell.open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
  .menu-btn { display: inline-flex; }
  .wrap { padding: 16px 16px 30px; }
  .row2, .row3 { grid-template-columns: 1fr; }
  .links { grid-template-columns: 1fr; }
  .msg.user .bubble { max-width: 92%; }
  .composer-wrap { padding: 10px 16px 12px; }
  .hero-new h2 { font-size: 22px; }
  .suggest { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .suggest .chip { white-space: nowrap; }
  .disclaimer { display: none; }
}
