/* Work tool: dense, calm, scannable. Deep green sidebar, warm-grey surface, stage colours only on the stripe. */
:root {
  --bg: #F4F3EF;
  --card: #FFFFFF;
  --ink: #1A1D1B;
  --muted: #6E716C;
  --line: #E1DFD8;
  --side: #163A2E;
  --side-ink: #E9F2EC;
  --accent: #1F7A55;
  --new: #3B6FE0; --contacted: #C98A14; --proposal: #8A4FD8; --won: #1F9D63; --lost: #A9A49A;
  --f: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f); font-size: 15px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 22px 14px; display: flex; flex-direction: column; gap: 26px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; padding: 0 8px; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: #E9F2EC url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M9 10h4v12H9zM15 14h4v8h-4zM21 7h3v15h-3z' fill='%23163A2E'/%3E%3C/svg%3E") center / 100% no-repeat; }
.tabs { display: grid; gap: 2px; }
.tab { text-align: left; padding: 9px 10px; border: 0; border-radius: 8px; background: none; color: rgba(233,242,236,.75); }
.tab:hover { background: rgba(255,255,255,.07); color: var(--side-ink); }
.tab[aria-current="page"] { background: rgba(255,255,255,.12); color: #fff; font-weight: 600; }
.mode { margin-top: auto; font-size: 12px; color: rgba(233,242,236,.6); padding: 0 8px; line-height: 1.4; }
.mode b { color: var(--side-ink); font-weight: 600; display: block; }

.main { padding: 26px 28px 40px; min-width: 0; display: grid; gap: 20px; align-content: start; }
.top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 14px; }
h1 { font-size: 26px; margin: 0; letter-spacing: -0.01em; }
.sub { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; }
.btn { border: 1px solid var(--accent); background: var(--accent); color: #fff; padding: 9px 16px; border-radius: 8px; font-weight: 600; transition: filter .15s, transform .1s; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: var(--card); color: var(--accent); }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat small { color: var(--muted); font-size: 13px; }
.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat i { font-style: normal; font-size: 12px; color: var(--muted); }

/* board */
.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.col { background: #EAE8E1; border-radius: 10px; padding: 10px; min-height: 360px; display: flex; flex-direction: column; gap: 8px; transition: background .15s; }
.col.over { background: #DCEDE3; }
.col-h { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 4px 6px; font-weight: 600; font-size: 14px; }
.col-h span { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; font-size: 13px; }
.lead { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 10px 14px; cursor: grab; text-align: left; width: 100%; display: grid; gap: 3px; transition: box-shadow .15s, transform .15s; }
.lead::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--c); }
.lead:hover { box-shadow: 0 4px 14px rgba(0,0,0,.07); transform: translateY(-1px); }
.lead.dragging { opacity: .45; }
.lead b { font-weight: 600; }
.lead .co { color: var(--muted); font-size: 13px; }
.lead .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; }
.lead .sum { color: var(--ink); font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lead.fresh { animation: fresh 1.6s ease-out; }
@keyframes fresh { 0% { box-shadow: 0 0 0 3px rgba(59,111,224,.55); } 100% { box-shadow: 0 0 0 0 rgba(59,111,224,0); } }

/* clients */
.toolbar input { width: min(420px, 100%); padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.tablewrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; margin-top: 12px; }
.table { width: 100%; border-collapse: collapse; min-width: 720px; }
.table th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 500; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: #FAF9F6; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }

/* telegram */
.feedview { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 28px; align-items: start; }
.phone { background: #DCE4D8; border-radius: 22px; border: 8px solid #1A1D1B; overflow: hidden; height: 600px; display: flex; flex-direction: column; }
.phone-top { background: #fff; display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.phone-top small { display: block; color: var(--muted); font-size: 12px; }
.bot-ava { width: 34px; height: 34px; border-radius: 50%; background: var(--side); color: #fff; display: grid; place-items: center; font-weight: 700; }
.chat { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg { background: #fff; border-radius: 12px 12px 12px 4px; padding: 8px 10px 6px; max-width: 92%; white-space: pre-line; font-size: 14px; box-shadow: 0 1px 1px rgba(0,0,0,.06); }
.msg time { display: block; text-align: right; font-size: 11px; color: var(--muted); margin-top: 2px; }
.feed-note { max-width: 60ch; }
.feed-note h2 { margin: 0 0 8px; font-size: 18px; }
.feed-note p { color: #3B3E3A; }
code { font-family: var(--mono); font-size: 13px; background: #E9E7E0; padding: 1px 5px; border-radius: 4px; }

/* drawer */
.drawer { position: fixed; inset: 0; background: rgba(20,22,20,.28); display: flex; justify-content: flex-end; z-index: 20; }
.drawer-in { width: min(440px, 100%); height: 100%; background: var(--card); padding: 24px; overflow-y: auto; position: relative; box-shadow: -10px 0 30px rgba(0,0,0,.12); animation: slide .22s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.x { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); font-size: 20px; line-height: 1; }
.d-name { font-size: 22px; font-weight: 700; margin: 0 40px 2px 0; }
.d-co { color: var(--muted); margin: 0 0 16px; }
.d-grid { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; font-size: 14px; margin-bottom: 18px; }
.d-grid dt { color: var(--muted); }
.d-grid dd { margin: 0; }
.d-msg { background: var(--bg); border-radius: 8px; padding: 10px 12px; margin: 0 0 18px; font-size: 14px; }
.d-stage { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.d-h { font-size: 13px; color: var(--muted); font-weight: 600; margin: 20px 0 8px; text-transform: none; }
.d-note { display: flex; gap: 8px; }
.d-note input { flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.tl { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.tl li { font-size: 14px; padding-left: 14px; border-left: 2px solid var(--line); white-space: pre-line; }
.tl small { display: block; color: var(--muted); font-size: 12px; }

/* modal */
.modal { border: 0; border-radius: 14px; padding: 0; width: min(460px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal::backdrop { background: rgba(20,22,20,.35); }
.modal form { padding: 22px; display: grid; gap: 12px; }
.modal h2 { margin: 0 0 4px; font-size: 20px; }
.modal label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.modal input, .modal select, .modal textarea { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #fff; font-size: 15px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.err { color: #B4372C; margin: 0; font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 30; max-width: 92vw; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; padding: 12px 14px; gap: 14px; overflow-x: auto; }
  .tabs { display: flex; }
  .mode { display: none; }
  .main { padding: 18px 14px 32px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .feedview { grid-template-columns: 1fr; }
  .phone { height: 480px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
