/* CRM2 — тихий рабочий инструмент: бирюзовый акцент, табличные цифры, сайдбар на компьютере, нижнее меню на телефоне. */
:root{
  --bg:#EEF2F1; --surface:#FFFFFF; --sunk:#E4EAE9; --ink:#14201F; --muted:#5A6B69; --line:#D6DEDC;
  --accent:#0B6B66; --accent-ink:#FFFFFF; --accent-soft:#D7EBE8;
  --warn:#9A5A0B; --warn-soft:#F8E8D2; --danger:#B42318; --danger-soft:#FBE3E0; --ok:#2E7D32; --ok-soft:#E1F1E1;
  --font:"Segoe UI",system-ui,-apple-system,Roboto,"Helvetica Neue",Arial,sans-serif;
  --mono:ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  --r:12px;
}
@media (prefers-color-scheme:dark){:root{
  --bg:#0E1515; --surface:#162020; --sunk:#1E2A29; --ink:#E6EEEC; --muted:#93A6A3; --line:#2A3836;
  --accent:#3FB8AE; --accent-ink:#06201E; --accent-soft:#163331;
  --warn:#E3A25A; --warn-soft:#3A2A16; --danger:#F07A6E; --danger-soft:#3A1A17; --ok:#7CC47F; --ok-soft:#18301A; color-scheme:dark}}
*{box-sizing:border-box}
html,body{margin:0;height:100%}
body{background:var(--bg);color:var(--ink);font:15px/1.45 var(--font);-webkit-text-size-adjust:100%}
button,input,select,textarea{font:inherit;color:inherit}
button{cursor:pointer}
a{color:var(--accent)}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
h1,h2,h3{margin:0;font-weight:650;text-wrap:balance}
.num{font-variant-numeric:tabular-nums}
.muted{color:var(--muted)}
.boot{display:grid;place-items:center;height:100vh;color:var(--muted)}
.hidden{display:none!important}

/* layout */
.app{display:flex;min-height:100vh}
.side{width:236px;flex:none;background:var(--surface);border-right:1px solid var(--line);position:sticky;top:0;height:100vh;display:flex;flex-direction:column;padding:18px 12px;gap:4px}
.logo{display:flex;align-items:center;gap:10px;font-weight:700;font-size:18px;padding:2px 10px 16px}
.logo img{width:30px;height:30px}
.nav{display:flex;align-items:center;gap:10px;padding:9px 10px;border-radius:10px;color:var(--muted);text-decoration:none;font-weight:550;border:0;background:none;text-align:left;width:100%}
.nav:hover{background:var(--sunk)}
.nav.on{background:var(--accent-soft);color:var(--accent)}
.nav .badge{margin-left:auto}
.side .foot{margin-top:auto;display:flex;flex-direction:column;gap:2px;border-top:1px solid var(--line);padding-top:10px}
.side .me{font-size:13px;padding:6px 10px;color:var(--muted)}
.main{flex:1;min-width:0;display:flex;flex-direction:column}
.top{position:sticky;top:0;z-index:20;background:var(--bg);display:flex;align-items:center;gap:10px;padding:14px 28px 10px;padding-top:max(14px,env(safe-area-inset-top))}
.top h1{font-size:22px;flex:1;min-width:0}
.page{padding:4px 28px 40px;display:flex;flex-direction:column;gap:18px;max-width:1280px;width:100%}
.tabbar{display:none}
@media (max-width:860px){
  .side{display:none}
  .top{padding-left:max(16px,env(safe-area-inset-left));padding-right:max(16px,env(safe-area-inset-right))}
  .top h1{font-size:19px}
  .page{padding:4px max(16px,env(safe-area-inset-right)) calc(96px + env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left))}
  .tabbar{display:grid;grid-template-columns:repeat(6,1fr);position:fixed;left:0;right:0;bottom:0;z-index:30;background:var(--surface);border-top:1px solid var(--line);padding:4px 4px calc(4px + env(safe-area-inset-bottom))}
  .tabbar .nav{flex-direction:column;gap:2px;font-size:11px;padding:6px 2px;justify-content:center;align-items:center;text-align:center}
}
svg.i{width:20px;height:20px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;flex:none}

/* controls */
.btn{border:1px solid transparent;border-radius:10px;padding:9px 14px;font-weight:600;background:var(--sunk);display:inline-flex;align-items:center;gap:7px;justify-content:center;white-space:nowrap;text-decoration:none;color:var(--ink)}
.btn:hover{filter:brightness(.97)}
.btn.primary{background:var(--accent);color:var(--accent-ink)}
.btn.ghost{background:transparent;border-color:var(--line)}
.btn.danger{background:var(--danger-soft);color:var(--danger)}
.btn.sm{padding:6px 10px;font-size:13.5px;border-radius:8px}
.btn.icon{padding:7px}
.btn:disabled{opacity:.55;cursor:default}
.input,select.input,textarea.input{border:1px solid var(--line);background:var(--surface);border-radius:10px;padding:9px 11px;min-height:40px;width:100%}
textarea.input{resize:vertical;min-height:80px}
.field{display:flex;flex-direction:column;gap:5px;min-width:0}
.field label{font-size:13px;color:var(--muted);font-weight:550}
.grid2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.grid3{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}
@media (max-width:600px){.grid2,.grid3{grid-template-columns:1fr}}
.row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.spacer{flex:1}
.chips{display:flex;gap:6px;flex-wrap:wrap}
.chip{border:1px solid var(--line);background:var(--surface);border-radius:999px;padding:5px 12px;font-size:13.5px;white-space:nowrap}
.chip.on{background:var(--ink);color:var(--bg);border-color:var(--ink)}
.chip .n{opacity:.65;margin-left:4px;font-variant-numeric:tabular-nums}
.badge{display:inline-block;font-size:11.5px;font-weight:700;border-radius:6px;padding:1px 7px;white-space:nowrap;letter-spacing:.01em}
.b-ok{background:var(--ok-soft);color:var(--ok)} .b-warn{background:var(--warn-soft);color:var(--warn)} .b-danger{background:var(--danger-soft);color:var(--danger)}
.b-acc{background:var(--accent-soft);color:var(--accent)} .b-mute{background:var(--sunk);color:var(--muted)}
.err{color:var(--danger);font-size:13.5px}

/* cards & kpis */
.card{background:var(--surface);border-radius:var(--r);padding:16px;display:flex;flex-direction:column;gap:12px;min-width:0}
.card h2{font-size:15px;display:flex;align-items:center;gap:8px}
.card h2 .spacer{flex:1}
.kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px}
@media (max-width:860px){.kpis{grid-template-columns:repeat(2,minmax(0,1fr))}}
.kpi{background:var(--surface);border-radius:var(--r);padding:14px 16px;display:flex;flex-direction:column;gap:3px;border:0;text-align:left;color:inherit;min-width:0}
button.kpi:hover{outline:1px solid var(--line)}
.kpi .l{font-size:12.5px;color:var(--muted);font-weight:550}
.kpi .v{font-size:24px;font-weight:650;font-variant-numeric:tabular-nums;letter-spacing:-.01em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.kpi .s{font-size:12.5px;color:var(--muted)}
.kpi.hl{background:var(--accent);color:var(--accent-ink)} .kpi.hl .l,.kpi.hl .s{color:var(--accent-ink);opacity:.85}
.cols{display:grid;grid-template-columns:minmax(0,3fr) minmax(0,2fr);gap:18px;align-items:start}
@media (max-width:1050px){.cols{grid-template-columns:1fr}}
.list{display:flex;flex-direction:column}
.li{display:flex;gap:10px;align-items:center;padding:9px 0;border-top:1px solid var(--line);min-width:0}
.li:first-child{border-top:0}
.li .t{flex:1;min-width:0}
.li .t .a{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.li .t .b{font-size:13px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.linkbtn{background:none;border:0;padding:0;color:inherit;text-align:left;font:inherit;cursor:pointer}
.linkbtn:hover .a,.linkbtn:hover{color:var(--accent)}
.empty{color:var(--muted);font-size:14px;padding:8px 0}
.bars{display:flex;align-items:flex-end;gap:6px;height:140px;padding-top:8px}
.bar{flex:1;display:flex;flex-direction:column;align-items:center;gap:4px;min-width:0;height:100%;justify-content:flex-end}
.bar i{display:block;width:100%;max-width:38px;background:var(--accent);border-radius:5px 5px 0 0;min-height:2px}
.bar span{font-size:11px;color:var(--muted);font-variant-numeric:tabular-nums}
@media (max-width:700px){.bars.dense{gap:3px}.bars.dense .bar:nth-child(even) span{visibility:hidden}.bars.dense .bar b{font-size:10px}}
.bar b{font-size:11px;font-weight:600;font-variant-numeric:tabular-nums}

/* tables */
.tablewrap{background:var(--surface);border-radius:var(--r);overflow:auto}
table{width:100%;border-collapse:collapse;font-size:14px}
th{text-align:left;font-size:12px;color:var(--muted);font-weight:600;padding:10px 12px;border-bottom:1px solid var(--line);white-space:nowrap;position:sticky;top:0;background:var(--surface);cursor:pointer;user-select:none}
th.r,td.r{text-align:right}
td{padding:9px 12px;border-bottom:1px solid var(--line);vertical-align:top}
tr:last-child td{border-bottom:0}
tbody tr:hover{background:var(--sunk);cursor:pointer}
td .sub{font-size:12.5px;color:var(--muted)}
tfoot td{font-weight:650;background:var(--sunk)}
.cb{width:18px;height:18px;accent-color:var(--accent)}
@media (max-width:700px){.hide-m{display:none}}

/* client card */
.head{display:flex;gap:14px;align-items:flex-start;flex-wrap:wrap}
.head .t{flex:1;min-width:220px;display:flex;flex-direction:column;gap:4px}
.head h1{font-size:24px}
.kv{display:grid;grid-template-columns:max-content 1fr;gap:6px 16px;font-size:14px}
.kv dt{color:var(--muted)} .kv dd{margin:0;min-width:0;overflow-wrap:anywhere}
.contact{border:1px solid var(--line);border-radius:10px;padding:10px 12px;display:flex;flex-direction:column;gap:6px}
.contact .nm{font-weight:650}
.timeline{display:flex;flex-direction:column;gap:0}
.ev{display:grid;grid-template-columns:86px 1fr auto;gap:10px;padding:8px 0;border-top:1px solid var(--line);font-size:14px}
.ev:first-child{border-top:0}
.ev .w{font-size:12px;color:var(--muted);font-variant-numeric:tabular-nums}
.ev .x{white-space:pre-wrap;overflow-wrap:anywhere;min-width:0}
.task{display:flex;gap:10px;align-items:flex-start;padding:7px 0;border-top:1px solid var(--line)}
.task:first-child{border-top:0}
.check{width:22px;height:22px;border-radius:6px;border:2px solid var(--line);background:none;flex:none;padding:0;display:grid;place-items:center}
.check.on{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
.check svg.i{width:14px;height:14px}

/* leads board */
.board{display:grid;grid-template-columns:repeat(6,minmax(165px,1fr));gap:12px;overflow-x:auto;padding-bottom:6px}
.colm{background:var(--sunk);border-radius:var(--r);padding:10px;display:flex;flex-direction:column;gap:8px;min-height:120px}
.colm h3{font-size:13px;display:flex;justify-content:space-between;color:var(--muted);font-weight:650;padding:2px 4px}
.lcard{background:var(--surface);border-radius:10px;padding:10px;display:flex;flex-direction:column;gap:4px;border:0;text-align:left;color:inherit}
.lcard:hover{outline:1px solid var(--accent)}
.lcard .a{font-weight:600}
.lcard .b{font-size:12.5px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
@media (max-width:860px){.board{display:none}}
.leadlist{display:none}
@media (max-width:860px){.leadlist{display:flex}}

/* sheet */
.scrim{position:fixed;inset:0;background:rgba(8,18,17,.45);z-index:50;display:flex;align-items:center;justify-content:center;padding:16px}
.sheetbox{background:var(--surface);width:100%;max-width:620px;max-height:calc(100vh - 32px);overflow:auto;border-radius:16px;padding:20px;display:flex;flex-direction:column;gap:14px}
.sheetbox.wide{max-width:900px}
.sheethead{display:flex;align-items:center;gap:10px}
.sheethead h2{flex:1;font-size:18px}
@media (max-width:600px){.scrim{align-items:flex-end;padding:0}.sheetbox{border-radius:16px 16px 0 0;max-height:94vh;padding-bottom:calc(20px + env(safe-area-inset-bottom))}}
#toast{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);z-index:60;display:flex;flex-direction:column;gap:8px;align-items:center;pointer-events:none}
.toast{background:var(--ink);color:var(--bg);padding:10px 16px;border-radius:12px;font-size:14px;pointer-events:auto;display:flex;gap:12px;align-items:center;box-shadow:0 8px 24px rgba(0,0,0,.2)}
.toast button{background:none;border:0;color:var(--bg);text-decoration:underline;font-weight:700}
@media (max-width:860px){#toast{bottom:calc(84px + env(safe-area-inset-bottom))}}

/* auth */
.auth{min-height:100vh;display:grid;place-items:center;padding:16px}
.auth form{background:var(--surface);border-radius:18px;padding:28px;width:100%;max-width:400px;display:flex;flex-direction:column;gap:14px}
.auth h1{font-size:22px}
.progress{height:8px;background:var(--sunk);border-radius:99px;overflow:hidden}
.progress i{display:block;height:100%;background:var(--accent);width:0;transition:width .2s}
.recip{display:flex;gap:10px;align-items:center;padding:8px 0;border-top:1px solid var(--line);font-size:14px}
.recip:first-child{border-top:0}
.recip .t{flex:1;min-width:0}
.notice{background:var(--warn-soft);border-radius:10px;padding:10px 12px;font-size:14px}
.notice.info{background:var(--accent-soft)}
@media (prefers-reduced-motion:reduce){*{transition:none!important}}
