:root {
  --bg: #f3f5f8; --card: #ffffff; --text: #18202b; --muted: #6b7686; --line: #e4e8ee;
  --accent: #1a56db; --accent-weak: #e8effd; --ok: #1f9d55; --ok-weak: #e5f6ec; --bad: #d64545; --bad-weak: #fdeaea;
  --warn: #c27c0e; --warn-weak: #fdf3e1; --chip: #eef1f5; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --top: 52px; --bottom: 60px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f141a; --card: #171e26; --text: #e7ebf0; --muted: #94a0b0; --line: #26303b; --accent: #5b8cff; --accent-weak: #1b2840;
    --ok-weak: #13301f; --bad-weak: #3a1a1a; --warn-weak: #3a2c12; --chip: #212a35; --shadow: none; color-scheme: dark; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif; }
body { overscroll-behavior-y: none; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--text); }
#app { min-height: 100%; }
svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.state svg { width: 44px; height: 44px; }

/* ---------- chrome ---------- */
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 30; height: calc(var(--top) + var(--safe-t)); padding: var(--safe-t) 6px 0; display: flex; align-items: center; gap: 2px; background: var(--card); border-bottom: 1px solid var(--line); }
.topbar .title { flex: 1; min-width: 0; font-size: 17px; font-weight: 650; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.icon-btn { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; position: relative; flex: none; }
.icon-btn:active { background: var(--chip); }
.icon-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.badge { position: absolute; top: 5px; right: 5px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.demo-strip { position: fixed; left: 0; right: 0; top: calc(var(--top) + var(--safe-t)); z-index: 29; background: var(--warn-weak); color: var(--warn); font-size: 12px; font-weight: 600; text-align: center; padding: 3px 8px; border-bottom: 1px solid var(--line); }
.main { padding: calc(var(--top) + var(--safe-t) + 22px) 0 calc(var(--bottom) + var(--safe-b) + 16px); min-height: 100vh; }
.main.no-demo { padding-top: calc(var(--top) + var(--safe-t) + 4px); }
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; height: calc(var(--bottom) + var(--safe-b)); padding-bottom: var(--safe-b); display: flex; background: var(--card); border-top: 1px solid var(--line); }
.bottomnav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; color: var(--muted); font-weight: 600; }
.bottomnav button.on { color: var(--accent); }
.bottomnav svg { width: 23px; height: 23px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- generic ---------- */
.pad { padding: 0 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.list { display: flex; flex-direction: column; gap: 8px; padding: 8px 12px; }
.mini { padding: 11px 12px; display: flex; flex-direction: column; gap: 5px; }
.mini:active { background: var(--chip); }
.mini .t { font-weight: 640; font-size: 15.5px; }
.mini .meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--muted); }
.mini .meta span { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.mini .meta svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; flex: none; }
.amount { font-weight: 650; white-space: nowrap; }
.stage { display: inline-flex; align-items: center; max-width: 100%; gap: 6px; padding: 3px 9px 3px 7px; border-radius: 99px; background: var(--chip); font-size: 12px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--dot, var(--accent)); flex: none; }
.stage.btn { border: 1px solid var(--line); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 12px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.toolbar { display: flex; gap: 8px; align-items: center; padding: 8px 12px 0; }
.search { flex: 1; display: flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 0 10px; height: 40px; }
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; height: 100%; }
.search svg { width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 2; }
.tbtn { height: 40px; min-width: 40px; padding: 0 10px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; font-weight: 600; position: relative; }
.tbtn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }
.tbtn .dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.fab { position: fixed; right: 16px; bottom: calc(var(--bottom) + var(--safe-b) + 16px); z-index: 25; width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 16px rgba(26,86,219,.35); }
.fab svg { width: 26px; height: 26px; stroke: #fff; fill: none; stroke-width: 2.4; }
.btn { height: 44px; padding: 0 16px; border-radius: 12px; font-weight: 650; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--card); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }
.total { padding: 6px 14px 0; font-size: 12.5px; color: var(--muted); }
.more { margin: 4px 12px 12px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-weak); color: var(--accent); display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 700; background: var(--chip); color: var(--muted); }
.pill.ok { background: var(--ok-weak); color: var(--ok); } .pill.bad { background: var(--bad-weak); color: var(--bad); } .pill.warn { background: var(--warn-weak); color: var(--warn); } .pill.acc { background: var(--accent-weak); color: var(--accent); }

/* ---------- states ---------- */
.state { padding: 48px 24px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.state svg { width: 44px; height: 44px; stroke: var(--muted); fill: none; stroke-width: 1.5; }
.state h3 { margin: 0; color: var(--text); font-size: 16px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.spinner.sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.skel { height: 74px; border-radius: 14px; background: linear-gradient(90deg, var(--card) 0%, var(--chip) 50%, var(--card) 100%); background-size: 200% 100%; animation: sk 1.2s infinite; border: 1px solid var(--line); }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- card / details ---------- */
.head { padding: 12px 14px 4px; }
.head h1 { margin: 0; font-size: 20px; line-height: 1.25; }
.head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.stagebar { display: flex; gap: 4px; overflow-x: auto; padding: 10px 12px; scrollbar-width: none; }
.stagebar::-webkit-scrollbar { display: none; }
.stagebar button { flex: none; padding: 8px 12px; font-size: 12px; font-weight: 700; border-radius: 8px; background: var(--chip); color: var(--muted); white-space: nowrap; }
.stagebar button.past { background: var(--accent-weak); color: var(--accent); }
.stagebar button.cur { background: var(--accent); color: #fff; }
.stagebar button.cur.S { background: var(--ok); } .stagebar button.cur.F { background: var(--bad); }
.quick { display: flex; gap: 8px; padding: 4px 12px 8px; overflow-x: auto; }
.quick .btn { height: 38px; font-size: 13px; padding: 0 12px; flex: none; }
.tabs { position: sticky; top: calc(var(--top) + var(--safe-t) + 22px); z-index: 20; display: flex; gap: 2px; overflow-x: auto; background: var(--bg); padding: 4px 8px 0; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.no-demo .tabs { top: calc(var(--top) + var(--safe-t)); }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; padding: 10px 12px; font-size: 14px; font-weight: 650; color: var(--muted); border-bottom: 2.5px solid transparent; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.section { margin: 10px 12px; overflow: hidden; }
.section > .sh { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.section > .sh svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; transition: transform .2s; }
.section.closed > .sh svg { transform: rotate(-90deg); }
.section.closed > .sb { display: none; }
.field { display: flex; gap: 8px; align-items: flex-start; padding: 9px 14px; border-top: 1px solid var(--line); }
.field .fl { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.field .fv { word-break: break-word; white-space: pre-wrap; }
.field .fv.empty { color: var(--muted); opacity: .6; }
.field .pen { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: var(--muted); flex: none; }
.field .pen svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2; }
.field .pen:active { background: var(--chip); }
.req { color: var(--bad); }
.linkv { color: var(--accent); font-weight: 600; }
.file-a { display: inline-flex; gap: 6px; align-items: center; padding: 6px 10px; border-radius: 10px; background: var(--chip); margin: 2px 4px 2px 0; font-size: 13px; font-weight: 600; }
.file-a svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }

/* ---------- sheet / modal / toast ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(10,15,25,.45); z-index: 60; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; max-height: 88vh; display: flex; flex-direction: column; background: var(--card); border-radius: 18px 18px 0 0; padding-bottom: var(--safe-b); animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 2px; }
.sheet .sh { display: flex; align-items: center; gap: 8px; padding: 6px 14px 10px; border-bottom: 1px solid var(--line); }
.sheet .sh h3 { flex: 1; margin: 0; font-size: 17px; }
.sheet .sbody { overflow-y: auto; padding: 12px 14px; -webkit-overflow-scrolling: touch; }
.sheet .sfoot { display: flex; gap: 8px; padding: 10px 14px 12px; border-top: 1px solid var(--line); }
.sheet .sfoot .btn { flex: 1; }
.opt { display: flex; align-items: center; gap: 10px; padding: 12px 6px; border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.opt:last-child { border-bottom: 0; }
.opt svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; flex: none; }
.opt .check { margin-left: auto; color: var(--accent); }
.opt.danger { color: var(--bad); }
.inp { width: 100%; height: 44px; border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; background: var(--bg); outline: none; }
textarea.inp { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; }
.inp:focus { border-color: var(--accent); }
.inp.err { border-color: var(--bad); background: var(--bad-weak); }
.ferr { color: var(--bad); font-size: 12.5px; margin-top: 4px; }
.lbl { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 5px; font-weight: 600; }
.toast-wrap { position: fixed; left: 12px; right: 12px; bottom: calc(var(--bottom) + var(--safe-b) + 12px); z-index: 80; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { padding: 12px 14px; border-radius: 12px; background: #1d2633; color: #fff; font-weight: 600; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: up .2s; }
.toast.ok { background: var(--ok); } .toast.bad { background: var(--bad); } .toast.warn { background: #9a6208; }
.drawer { position: fixed; top: 0; bottom: 0; right: 0; width: min(86vw, 340px); z-index: 61; background: var(--card); display: flex; flex-direction: column; padding-top: var(--safe-t); animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(40px); opacity: .5; } }
.drawer .prof { display: flex; gap: 12px; align-items: center; padding: 18px 16px; border-bottom: 1px solid var(--line); }
.drawer .items { flex: 1; overflow-y: auto; padding: 6px 8px; }
.drawer .opt { padding: 12px 10px; border: 0; border-radius: 10px; }
.drawer .opt:active { background: var(--chip); }
.drawer hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }

/* ---------- timeline / chat ---------- */
.composer { display: flex; gap: 6px; padding: 10px 12px 4px; }
.composer .chip { flex: 1; text-align: center; }
.tl { padding: 6px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.tli { padding: 10px 12px; display: flex; gap: 10px; }
.tli .ic { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--chip); color: var(--muted); }
.tli .ic svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2; }
.tli .ic.call { background: var(--ok-weak); color: var(--ok); } .tli .ic.task { background: var(--accent-weak); color: var(--accent); } .tli .ic.comment { background: var(--warn-weak); color: var(--warn); }
.tli .tt { font-weight: 650; font-size: 14px; }
.tli .tx { font-size: 14px; margin-top: 3px; white-space: pre-wrap; word-break: break-word; }
.tli audio { width: 100%; margin-top: 6px; height: 36px; }
.chatwrap { display: flex; flex-direction: column; height: calc(100vh - var(--top) - var(--safe-t) - 22px - var(--bottom) - var(--safe-b)); }
.msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 82%; padding: 8px 11px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); align-self: flex-start; font-size: 14.5px; white-space: pre-wrap; word-break: break-word; }
.msg.me { align-self: flex-end; background: var(--accent); color: #fff; border-color: var(--accent); }
.msg.sys { align-self: center; background: transparent; border: 0; color: var(--muted); font-size: 12px; text-align: center; }
.msg .mt { font-size: 11px; opacity: .7; margin-top: 3px; text-align: right; }
.msg .ma { font-size: 11.5px; font-weight: 700; opacity: .8; margin-bottom: 2px; }
.msg img { max-width: 100%; border-radius: 8px; display: block; margin-top: 4px; }
.sendbar { display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line); background: var(--card); }
.sendbar input[type=text] { flex: 1; }

/* ---------- smart hub / reports ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px; }
.tile { padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; min-height: 120px; text-align: left; }
.tile svg { width: 28px; height: 28px; stroke: var(--accent); fill: none; stroke-width: 1.8; }
.tile b { font-size: 16px; } .tile span { font-size: 12.5px; color: var(--muted); }
.tile.off { opacity: .6; }
.bar { position: relative; height: 34px; border-radius: 8px; background: var(--chip); overflow: hidden; margin: 6px 0; display: flex; align-items: center; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent-weak); border-right: 3px solid var(--accent); }
.bar.S i { background: var(--ok-weak); border-color: var(--ok); } .bar.F i { background: var(--bad-weak); border-color: var(--bad); }
.bar span { position: relative; padding: 0 10px; font-size: 13px; font-weight: 600; display: flex; width: 100%; justify-content: space-between; gap: 8px; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px 12px 0; }
.kpi { padding: 10px; } .kpi b { display: block; font-size: 18px; } .kpi span { font-size: 11.5px; color: var(--muted); font-weight: 600; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th, table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; }
table.t th { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
table.t td.n, table.t th.n { text-align: right; white-space: nowrap; }

/* ---------- kp / steps ---------- */
.steps { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; }
.step { display: flex; align-items: center; gap: 12px; font-weight: 600; }
.step .si { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--chip); flex: none; }
.step .si svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2.6; }
.step.done .si { background: var(--ok); color: #fff; } .step.error .si { background: var(--bad); color: #fff; } .step.demo .si { background: var(--warn-weak); color: var(--warn); }
.note { margin: 10px 12px; padding: 10px 12px; border-radius: 12px; font-size: 13.5px; background: var(--accent-weak); color: var(--text); }
.note.warn { background: var(--warn-weak); } .note.bad { background: var(--bad-weak); }
.wfp { display: flex; align-items: center; gap: 6px; padding: 8px 0; font-size: 12px; color: var(--muted); }
.wfp .arrow { flex: 1; height: 2px; background: var(--line); }
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px; gap: 14px; max-width: 420px; margin: 0 auto; }
.login .logo { width: 64px; height: 64px; border-radius: 18px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 22px; }
.login h1 { margin: 6px 0 0; font-size: 24px; }
.login .portal { display: flex; align-items: center; gap: 8px; padding: 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); font-weight: 600; }
.hold { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
