:root {
  --navy: #1F2A44; --navy-2: #2B3A5C; --orange: #F28C28; --orange-2: #E07B14; --orange-soft: #FEF3E2;
  --bg: #F4F5F8; --card: #FFFFFF; --text: #111827; --muted: #6B7280; --line: #E5E7EB;
  --green: #059669; --green-soft: #D1FAE5; --red: #DC2626; --red-soft: #FEE2E2; --blue: #2563EB; --blue-soft: #DBEAFE;
  --radius: 14px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif; font-size: 15px; }
body { overscroll-behavior-y: none; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; position: relative; padding-bottom: calc(76px + var(--safe-b)); }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--navy); color: #fff; padding: calc(12px + var(--safe-t)) 16px 12px; display: flex; align-items: center; gap: 10px; }
.topbar h1 { font-size: 17px; font-weight: 700; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { font-size: 12px; opacity: .7; font-weight: 500; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 0; background: rgba(255,255,255,.1); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn svg { width: 20px; height: 20px; }
.hero { background: var(--navy); color: #fff; padding: 4px 16px 56px; }
.hero .greet { font-size: 13px; opacity: .75; }
.hero .name { font-size: 22px; font-weight: 800; margin-top: 2px; }
.hero-cards { margin: -44px 16px 0; }

.page { padding: 14px 16px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 18px 2px 8px; font-weight: 700; font-size: 15px; }
.section-title a, .link { color: var(--orange-2); font-size: 13px; font-weight: 600; cursor: pointer; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.card + .card { margin-top: 10px; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi .value { font-size: 21px; font-weight: 800; margin-top: 4px; letter-spacing: -.3px; }
.kpi .hint { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.kpi.accent { background: linear-gradient(135deg, var(--orange), var(--orange-2)); color: #fff; }
.kpi.accent .label, .kpi.accent .hint { color: rgba(255,255,255,.85); }

/* pipeline bars */
.pipe-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; }
.pipe-row .pl { width: 132px; font-size: 12.5px; color: #374151; flex: none; }
.pipe-row .bar { flex: 1; height: 8px; background: #F1F2F5; border-radius: 99px; overflow: hidden; }
.pipe-row .bar i { display: block; height: 100%; border-radius: 99px; }
.pipe-row .pc { width: 28px; text-align: right; font-weight: 700; font-size: 13px; }

/* lists */
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.item { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.item:last-child { border-bottom: 0; }
.item:active { background: #FAFAFB; }
.item .main { flex: 1; min-width: 0; }
.item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 12.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .r { text-align: right; flex: none; }
.avatar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; font-size: 14px; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 99px; white-space: nowrap; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 6px; background: #F1F2F5; color: #374151; }
.pill.green { background: var(--green-soft); color: var(--green); } .pill.red { background: var(--red-soft); color: var(--red); }
.pill.orange { background: var(--orange-soft); color: var(--orange-2); } .pill.blue { background: var(--blue-soft); color: var(--blue); }

/* chips / search */
.search { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 12px; padding: 0 12px; box-shadow: var(--shadow); }
.search input { border: 0; outline: 0; flex: 1; padding: 12px 0; background: transparent; }
.search svg { width: 18px; height: 18px; color: var(--muted); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); padding: 7px 12px; border-radius: 99px; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip b { font-weight: 700; margin-left: 4px; }

/* bottom nav */
.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: var(--safe-b); }
.nav-inner { display: flex; width: 100%; max-width: 560px; }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 0 8px; font-size: 11px; font-weight: 600; color: #9CA3AF; }
.nav a svg { width: 22px; height: 22px; }
.nav a.on { color: var(--orange-2); }
.fab { position: fixed; right: max(16px, calc(50vw - 264px)); bottom: calc(88px + var(--safe-b)); z-index: 25; width: 56px; height: 56px; border-radius: 18px; background: var(--orange); color: #fff; border: 0; box-shadow: 0 8px 20px rgba(242,140,40,.45); display: grid; place-items: center; cursor: pointer; }
.fab svg { width: 26px; height: 26px; }

/* forms */
.btn { border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--navy); color: #fff; }
.btn.primary { background: var(--orange); } .btn.ghost { background: #EEF0F4; color: var(--navy); }
.btn.green { background: var(--green); } .btn.danger { background: var(--red-soft); color: var(--red); }
.btn.block { width: 100%; } .btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .6; }
.btn svg { width: 18px; height: 18px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: #374151; margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid #D1D5DB; border-radius: 10px; padding: 11px 12px; background: #fff; outline: none; font-size: 15px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(242,140,40,.15); }
.field textarea { min-height: 80px; resize: vertical; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-group { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 14px 2px; margin-bottom: 12px; }
.form-group h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--orange-2); }
.seg { display: flex; background: #EEF0F4; border-radius: 10px; padding: 3px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 8px; font-weight: 600; font-size: 13px; cursor: pointer; color: var(--muted); }
.seg button.on { background: #fff; color: var(--navy); box-shadow: var(--shadow); }

/* login */
.login { min-height: 100vh; display: flex; flex-direction: column; background: var(--navy); }
.login .brand { padding: 64px 28px 36px; color: #fff; }
.login .logo { width: 72px; height: 72px; border-radius: 20px; background: linear-gradient(160deg,#101729,#1F2A44); display: grid; place-items: center; margin-bottom: 18px; box-shadow: 0 8px 22px rgba(0,0,0,.28); }
.login .logo svg { width: 52px; height: 52px; }
.login h2 { margin: 0; font-size: 28px; font-weight: 800; }
.login p { margin: 6px 0 0; opacity: .7; }
.login form { background: var(--bg); flex: 1; border-radius: 24px 24px 0 0; padding: 28px 22px; }

/* lead detail */
.lead-head { background: var(--navy); color: #fff; padding: 2px 16px 16px; }
.lead-head .nm { font-size: 21px; font-weight: 800; }
.lead-head .meta { font-size: 13px; opacity: .75; margin-top: 3px; }
.lead-head .actions { display: flex; gap: 8px; margin-top: 14px; }
.lead-head .actions a, .lead-head .actions button { flex: 1; background: rgba(255,255,255,.1); border: 0; color: #fff; border-radius: 12px; padding: 10px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; cursor: pointer; }
.lead-head .actions svg { width: 20px; height: 20px; }
.stepper { display: flex; gap: 0; overflow-x: auto; padding: 14px 16px 6px; background: #fff; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.stepper::-webkit-scrollbar { display: none; }
.step { flex: none; display: flex; flex-direction: column; align-items: center; width: 78px; position: relative; }
.step .c { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #D1D5DB; background: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #9CA3AF; z-index: 1; }
.step.done .c { background: var(--green); border-color: var(--green); color: #fff; }
.step.cur .c { background: var(--orange); border-color: var(--orange); color: #fff; box-shadow: 0 0 0 4px rgba(242,140,40,.2); }
.step::before { content: ''; position: absolute; top: 11px; left: -50%; width: 100%; height: 2px; background: #E5E7EB; }
.step:first-child::before { display: none; }
.step.done::before, .step.cur::before { background: var(--green); }
.step .l { font-size: 10.5px; text-align: center; margin-top: 5px; color: var(--muted); line-height: 1.2; font-weight: 500; }
.step.cur .l { color: var(--text); font-weight: 700; }
.tabs { display: flex; background: #fff; overflow-x: auto; border-bottom: 1px solid var(--line); position: sticky; top: calc(62px + var(--safe-t)); z-index: 15; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; border: 0; background: transparent; padding: 12px 14px; font-weight: 600; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; }
.tabs button.on { color: var(--navy); border-color: var(--orange); }
.kv { display: grid; grid-template-columns: 42% 58%; row-gap: 9px; font-size: 14px; }
.kv .k { color: var(--muted); } .kv .v { font-weight: 500; word-break: break-word; }
.doc-row { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.doc-row:last-child { border-bottom: 0; }
.doc-row .ok { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.doc-row .ok svg { width: 16px; height: 16px; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.thumbs a { width: 54px; height: 54px; border-radius: 8px; overflow: hidden; background: #F1F2F5; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: var(--red); position: relative; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.timeline .ev { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.timeline .ev:last-child { border-bottom: 0; }
.timeline .ic { width: 30px; height: 30px; border-radius: 10px; background: #F1F2F5; display: grid; place-items: center; flex: none; }
.timeline .ic svg { width: 16px; height: 16px; color: var(--navy); }
.timeline .tx { font-size: 14px; } .timeline .tm { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.money-bar { height: 10px; background: #F1F2F5; border-radius: 99px; overflow: hidden; margin: 8px 0 4px; }
.money-bar i { display: block; height: 100%; background: var(--green); }

/* sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--bg); width: 100%; max-width: 560px; max-height: 92vh; border-radius: 20px 20px 0 0; display: flex; flex-direction: column; animation: up .2s ease-out; }
.sheet-h { display: flex; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); background: #fff; border-radius: 20px 20px 0 0; }
.sheet-h h2 { flex: 1; margin: 0; font-size: 17px; }
.sheet-h .x { border: 0; background: #EEF0F4; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 18px; }
.sheet-b { overflow-y: auto; padding: 14px 16px; }
.sheet-f { padding: 12px 16px calc(12px + var(--safe-b)); background: #fff; border-top: 1px solid var(--line); display: flex; gap: 10px; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } }
.stage-opt { display: flex; align-items: center; gap: 10px; padding: 12px; background: #fff; border-radius: 12px; margin-bottom: 6px; cursor: pointer; border: 2px solid transparent; }
.stage-opt.on { border-color: var(--orange); }
.stage-opt.dis { opacity: .4; pointer-events: none; }
.stage-opt .d { width: 12px; height: 12px; border-radius: 50%; }

#toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); z-index: 100; pointer-events: none; }
#toast div { background: #111827; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: up .2s; max-width: 90vw; }
#toast div.err { background: var(--red); }
.spinner { width: 28px; height: 28px; border: 3px solid #E5E7EB; border-top-color: var(--orange); border-radius: 50%; animation: spin .7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.qt-line { background: #fff; border-radius: 12px; padding: 10px; margin-bottom: 8px; box-shadow: var(--shadow); }
.qt-line .top { display: flex; gap: 8px; }
.qt-line input { border: 1px solid #D1D5DB; border-radius: 8px; padding: 8px; width: 100%; font-size: 14px; }
.qt-line .grid { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 6px; margin-top: 6px; }
.qt-line .grid label { font-size: 10.5px; color: var(--muted); font-weight: 600; }
.totals { background: #fff; border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.totals .big { font-weight: 800; font-size: 17px; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px; }
.menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.menu-grid a { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 8px; display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; text-align: center; }
.menu-grid a span { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--orange-soft); color: var(--orange-2); }
.menu-grid a svg { width: 22px; height: 22px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .bold { font-weight: 700; } .right { text-align: right; }
.mt { margin-top: 12px; } .flex { display: flex; gap: 8px; align-items: center; } .grow { flex: 1; }
.hide { display: none !important; }

/* ---------- desktop / website layout ---------- */
.nav-brand, .desk { display: none !important; }
@media (min-width: 900px) {
  body { font-size: 15px; }
  #app { max-width: none; padding: 0 0 0 248px; }
  .nav { top: 0; bottom: 0; right: auto; width: 248px; border-top: 0; background: var(--navy); padding: 0; flex-direction: column; justify-content: flex-start; }
  .nav-inner { flex-direction: column; padding: 14px 12px; height: 100%; overflow-y: auto; gap: 2px; }
  .nav-brand { display: flex !important; align-items: center; gap: 10px; color: #fff; font-weight: 800; font-size: 17px; padding: 8px 10px 22px; }
  .nav-brand svg { width: 26px; height: 26px; color: var(--orange); flex: none; }
  .nav a, .nav a.desk { display: flex !important; flex: none; flex-direction: row; gap: 12px; padding: 11px 12px; border-radius: 10px; font-size: 14.5px; color: rgba(255,255,255,.72); }
  .nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
  .nav a.on { background: var(--orange); color: #fff; }
  .nav a svg { width: 20px; height: 20px; }
  .nav-user.desk { display: block !important; margin-top: auto; color: #fff; font-weight: 600; font-size: 14px; padding: 14px 12px 6px; border-top: 1px solid rgba(255,255,255,.1); }
  .nav-user small { display: block; font-weight: 500; opacity: .6; font-size: 12px; margin-top: 2px; }
  .topbar { padding: 16px 32px; }
  .topbar h1 { font-size: 20px; }
  .page, .hero > *, .hero-cards, .lead-head > *, .stepper, .tabs { max-width: 1180px; margin-left: auto; margin-right: auto; }
  .page { padding: 20px 32px 40px; }
  .hero { padding: 6px 32px 64px; }
  .hero-cards { padding: 0 32px; margin-top: -48px; }
  .kpis { grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .kpi .value { font-size: 26px; }
  .lead-head { padding: 4px 32px 20px; }
  .lead-head .actions { max-width: 560px; margin-left: 0; }
  .stepper, .tabs { padding-left: 32px; padding-right: 32px; max-width: none; justify-content: flex-start; }
  .tabs { top: 64px; }
  .step { width: 92px; }
  form.page, #leadf { max-width: 860px; }
  .fab { right: 36px; bottom: 36px; }
  #toast { bottom: 36px; left: calc(50% + 124px); }
  .sheet-bg { align-items: center; }
  .sheet { max-width: 620px; border-radius: 20px; max-height: 86vh; }
  .sheet-f { border-radius: 0 0 20px 20px; padding-bottom: 12px; }
  .menu-grid { grid-template-columns: repeat(4, 1fr); }
  .item:hover { background: #FAFAFB; }
  .qt-line .grid { grid-template-columns: 1fr 1fr 1fr 1fr; }
  #lines { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
  .login { flex-direction: row; margin-left: -248px; }
  .login .brand { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 64px; }
  .login .brand h2 { font-size: 40px; }
  .login form, .login > div:last-child { flex: none; width: 480px; border-radius: 0; display: flex; flex-direction: column; justify-content: center; padding: 48px; }
}
@media (min-width: 1200px) {
  .dash-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 0 24px; align-items: start; }
}
.nbadge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 99px; background: var(--red); color: #fff; font-size: 10.5px; line-height: 18px; text-align: center; font-weight: 700; }
.field input.filled, .field textarea.filled { background: #F0FDF4; border-color: #86EFAC; }
.scanbox { border: 2px dashed #FBD38D; background: #FFFBF3; }
.lead-head .actions { overflow-x: auto; scrollbar-width: none; }
.lead-head .actions > * { min-width: 58px; }
@media print { .topbar, .nav, .fab, .btn, #toast { display: none !important; } #app { padding: 0 !important; } .page { padding: 0 !important; } .card { box-shadow: none !important; } }
