:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #fafafb;
  --line: #e7e9ed;
  --line-2: #d5d8de;
  --ink: #0d0f12;
  --text: #0d0f12;
  --mute: #646b77;
  --green: #0c7a52;
  --red: #c0352b;
  --amber: #99590a;
  --blue: #2450c4;
  --display: 'Sora', system-ui, sans-serif;
  --body: 'Inter', system-ui, sans-serif;
  --shadow: 0 1px 2px rgba(13, 15, 18, .04), 0 8px 24px -16px rgba(13, 15, 18, .12);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 14.5px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: -.02em; line-height: 1.15; color: var(--ink); }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cfd3da; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
.mute { color: var(--mute); }
.grad { color: var(--mute); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line-2); background: #fff; cursor: pointer; font-weight: 500; white-space: nowrap; transition: background .15s, border-color .15s, transform .15s, box-shadow .15s; text-decoration: none; }
.btn:hover { border-color: var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; border-color: var(--line-2); }
.btn.primary { border-color: var(--ink); color: #fff; font-weight: 600; background: var(--ink); }
.btn.primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 22px -12px rgba(13, 15, 18, .6); }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.big { padding: 15px 30px; font-size: 16px; border-radius: 12px; }
.input, select.input, textarea.input { width: 100%; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--line-2); background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(13, 15, 18, .08); }
.input::placeholder { color: #9ba1ac; }
select.input { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23646b77' stroke-width='1.8'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
input[type=color].input { padding: 3px; height: 38px; width: 46px; }
input[type=checkbox] { accent-color: var(--ink); width: 16px; height: 16px; }
label.lbl { display: block; font-size: 12px; font-weight: 500; color: var(--mute); margin-bottom: 5px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: #f3f4f6; border: 1px solid var(--line); white-space: nowrap; color: var(--ink); }
.badge i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.good { color: var(--green); background: #eef8f3; border-color: #cfe9dc; }
.badge.bad { color: var(--red); background: #fdf1f0; border-color: #f3d2ce; }
.badge.warn { color: var(--amber); background: #fdf6e9; border-color: #f0dfbd; }
.badge.info { color: var(--blue); background: #eff3fd; border-color: #d3dcf6; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.login-card { width: min(420px, 100%); padding: 40px; border-radius: 18px; background: #fff; border: 1px solid var(--line); box-shadow: 0 40px 90px -50px rgba(13, 15, 18, .35); display: grid; gap: 16px; }
.login-card h1 { font-size: 30px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 700 18px var(--display); color: var(--ink); }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; color: #fff; font-weight: 800; background: var(--ink); }
.err { color: var(--red); min-height: 1.3em; font-size: 13.5px; }

/* shell */
.shell { display: grid; grid-template-columns: 232px 1fr; height: 100%; }
.side { display: flex; flex-direction: column; gap: 2px; padding: 20px 12px; background: #fff; border-right: 1px solid var(--line); }
.side .brand { padding: 4px 10px 22px; font-size: 15px; line-height: 1.2; }
.side a.nav { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 9px; color: var(--mute); text-decoration: none; cursor: pointer; font-weight: 500; transition: background .15s, color .15s; }
.side a.nav:hover { background: #f3f4f6; color: var(--ink); }
.side a.nav.on { background: var(--ink); color: #fff; }
.side a.nav span { display: grid; place-items: center; width: 18px; height: 18px; }
.side a.nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.side .sep { margin: 16px 12px 6px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: #9ba1ac; }
.side .me { margin-top: auto; padding: 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.side .me b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .me small { color: var(--mute); text-transform: capitalize; }
.side .me button { margin-top: 10px; width: 100%; }
.main { overflow: auto; padding: 28px clamp(18px, 3vw, 40px) 60px; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.head h1 { font-size: 26px; }
.head .tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.head .tools .input { width: auto; min-width: 150px; }

/* home */
.hero-card { position: relative; overflow: hidden; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 24px; padding: 34px; border-radius: 16px; border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow); margin-bottom: 18px; }
.hero-card h1 { font-size: clamp(26px, 3.6vw, 40px); font-weight: 700; letter-spacing: -.03em; }
.hero-card p { color: var(--mute); margin-top: 8px; font-size: 15.5px; }
.hero-card .lane { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: repeating-linear-gradient(90deg, var(--ink) 0 40px, transparent 40px 90px); animation: lane 1.2s linear infinite; opacity: .18; }
@keyframes lane { to { background-position-x: -90px; } }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 22px; }
.tile { padding: 20px; border-radius: 14px; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); }
.tile small { color: var(--mute); font-size: 12.5px; }
.tile b { display: block; font: 700 34px var(--display); margin-top: 6px; font-variant-numeric: tabular-nums; color: var(--ink); }
.tile .bar { height: 4px; border-radius: 4px; background: #eceef1; margin-top: 12px; overflow: hidden; }
.tile .bar i { display: block; height: 100%; border-radius: 4px; background: var(--ink); transition: width .6s; }
.tile.hot b { color: var(--green); }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin-bottom: 22px; box-shadow: var(--shadow); }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 16px; }
.panel-body { padding: 20px; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel-2); }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; transition: background .12s; }
tbody tr.click:hover { background: #f6f7f9; }
td .name { font-weight: 600; } td .sub, .sub { color: var(--mute); font-size: 12.5px; }
.empty { padding: 50px 20px; text-align: center; color: var(--mute); }
.empty b { display: block; color: var(--ink); font: 600 17px var(--display); margin-bottom: 6px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--mute); font-size: 13px; }
.bulk { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 16px; background: #f3f4f6; border-bottom: 1px solid var(--line); }
.bulk .input { width: auto; }

/* pipeline */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 16px; align-items: flex-start; min-height: 60vh; }
.col { flex: 0 0 280px; background: #eef0f3; border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; max-height: calc(100vh - 150px); transition: border-color .15s, box-shadow .15s; }
.col.over { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(13, 15, 18, .08); }
.col-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; font-weight: 600; }
.col-head i { width: 9px; height: 9px; border-radius: 50%; }
.col-head span { margin-left: auto; color: var(--mute); font-weight: 500; font-size: 13px; }
.col-body { padding: 0 10px 10px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; overflow-y: auto; min-height: 60px; }
.kcard { padding: 13px; border-radius: 10px; background: #fff; border: 1px solid var(--line); cursor: grab; transition: border-color .15s, transform .15s, box-shadow .15s; box-shadow: 0 1px 2px rgba(13, 15, 18, .05); }
.kcard:hover { border-color: var(--line-2); transform: translateY(-2px); box-shadow: 0 10px 20px -14px rgba(13, 15, 18, .35); }
.kcard.drag { opacity: .4; }
.kcard b { display: block; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcard .meta { display: flex; flex-wrap: wrap; gap: 5px 10px; color: var(--mute); font-size: 12.5px; margin-top: 6px; }
.col-more { text-align: center; color: var(--mute); font-size: 12.5px; padding: 4px 0 8px; }

/* drawer (lead) */
.scrim { position: fixed; inset: 0; background: rgba(13, 15, 18, .35); backdrop-filter: blur(2px); z-index: 40; animation: fade .2s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(1080px, 100%); z-index: 41; background: #fff; border-left: 1px solid var(--line); display: flex; flex-direction: column; animation: slide .28s cubic-bezier(.2, .8, .2, 1); box-shadow: -30px 0 80px -40px rgba(13, 15, 18, .45); }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(60px); opacity: 0; } }
.d-head { padding: 22px 26px; border-bottom: 1px solid var(--line); background: #fff; }
.d-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.d-top h2 { font-size: 24px; }
.d-ids { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.d-call { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; }
.phone { font: 700 28px var(--display); color: var(--ink); text-decoration: none; letter-spacing: -.02em; }
.phone:hover { text-decoration: underline; }
.d-call .input { width: auto; }
.x { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line-2); background: #fff; cursor: pointer; font-size: 18px; line-height: 1; flex: none; }
.x:hover { border-color: var(--ink); }
.d-body { flex: 1; overflow: auto; display: grid; grid-template-columns: 1.1fr 1fr; gap: 0; }
.d-col { padding: 22px 26px; }
.d-col + .d-col { border-left: 1px solid var(--line); background: var(--panel-2); }
.d-col h3 { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--mute); font-family: var(--body); font-weight: 600; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 22px; }
.kv > div { background: #fff; padding: 12px 14px; min-width: 0; }
.kv > div.wide { grid-column: 1 / -1; }
.kv small { display: block; color: var(--mute); font-size: 11.5px; margin-bottom: 3px; }
.kv span { font-weight: 500; overflow-wrap: anywhere; }
.kv a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; } .kv a:hover { text-decoration-color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.links { display: flex; flex-wrap: wrap; gap: 8px; }
.outcomes { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; margin-bottom: 14px; }
.outcome { display: flex; align-items: center; gap: 8px; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: #fff; cursor: pointer; font-weight: 500; font-size: 13.5px; text-align: left; transition: transform .12s, border-color .12s, box-shadow .12s; }
.outcome:hover { transform: translateY(-1px); border-color: var(--ink); box-shadow: 0 8px 16px -12px rgba(13, 15, 18, .4); }
.outcome.good { color: var(--green); border-color: #bfdfce; }
.outcome.win { border-color: var(--ink); color: #fff; font-weight: 600; background: var(--ink); }
.outcome.bad { color: var(--red); border-color: #efc9c5; }
.outcome.warn { color: var(--amber); border-color: #e8d3a6; }
.outcome.info { color: var(--blue); border-color: #c5d1f3; }
.note-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: center; }
.note-row .input { width: auto; flex: 1; min-width: 170px; }
.timeline { display: grid; gap: 10px; margin-top: 8px; }
.tl { padding: 12px 14px; border-radius: 10px; background: #fff; border: 1px solid var(--line); }
.tl-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--mute); }
.tl-top b { color: var(--ink); font-weight: 600; }
.tl p { margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.tl.note { border-left: 3px solid var(--ink); }
.d-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 26px; border-top: 1px solid var(--line); background: #fff; }

/* modal */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(13, 15, 18, .4); backdrop-filter: blur(2px); animation: fade .2s; }
.modal-card { width: min(520px, 100%); max-height: 90vh; overflow: auto; padding: 26px; border-radius: 16px; background: #fff; border: 1px solid var(--line); box-shadow: 0 40px 90px -40px rgba(13, 15, 18, .5); display: grid; gap: 14px; }
.modal-card h2 { font-size: 19px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: end; }
.set-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row .input { width: auto; flex: 1; min-width: 120px; }
.set-row .tiny { flex: 0 0 62px; min-width: 0; text-align: center; }

#toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 70; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { padding: 11px 18px; border-radius: 10px; background: var(--ink); color: #fff; box-shadow: 0 20px 40px -20px rgba(13, 15, 18, .6); font-weight: 500; animation: pop .25s; }
.toast.bad { background: var(--red); }
@keyframes pop { from { transform: translateY(12px); opacity: 0; } }
.money { position: fixed; z-index: 80; top: -40px; font-size: 28px; pointer-events: none; animation: rain 1.8s ease-in forwards; }
@keyframes rain { to { transform: translateY(110vh) rotate(360deg); opacity: .2; } }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { flex-direction: row; align-items: center; overflow-x: auto; padding: 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side .brand, .side .sep { display: none; }
  .side a.nav { white-space: nowrap; padding: 8px 10px; }
  .side .me { margin: 0 0 0 auto; padding: 6px 10px; display: flex; gap: 10px; align-items: center; }
  .side .me small { display: none; } .side .me button { margin: 0; width: auto; }
  .d-body { grid-template-columns: 1fr; }
  .d-col + .d-col { border-left: 0; border-top: 1px solid var(--line); }
  .kv { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
