/* Демо «Pulse CRM» — фронтенд-демо с вымышленными данными. */
:root {
  --bg: #f3f5fb;
  --panel: #ffffff;
  --ink: #161a33;
  --muted: #5b627f;
  --line: #e1e5f2;
  --indigo: #3b3fb5;
  --indigo-d: #2c2f93;
  --indigo-soft: #e7e8fb;
  --green: #12805c;
  --green-soft: #dcf5ea;
  --amber: #946200;
  --amber-soft: #fff1cc;
  --red: #b3261e;
  --red-soft: #fde4e1;
  --sidebar: #161a33;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; overflow: hidden; }
h1, h2, h3, h4, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #1a6fd1; outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app { position: relative; display: grid; grid-template-columns: 224px 1fr; height: 100vh; overflow: hidden; }
.side { background: var(--sidebar); color: #cfd3f0; padding: 18px 14px; display: flex; flex-direction: column; gap: 22px; overflow: auto; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; font-size: 1.1rem; letter-spacing: -.01em; padding: 4px 8px; }
.brand__m { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: linear-gradient(140deg, #7a7ff2, #3b3fb5); font-weight: 900; }
.menu { display: grid; gap: 4px; }
.menu__btn { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border: 0; background: transparent; color: #cfd3f0; border-radius: 10px; font-weight: 700; cursor: pointer; text-align: start; transition: background .2s, color .2s; }
.menu__btn svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.menu__btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.menu__btn[aria-current="page"] { background: #fff; color: var(--indigo-d); }
.side__note { margin-top: auto; font-size: .78rem; color: #9aa0cc; padding: 0 8px; }
.col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 14px clamp(14px, 2.4vw, 28px); background: var(--panel); border-bottom: 1px solid var(--line); }
.top__title { font-size: 1.35rem; letter-spacing: -.02em; }
.top__title:focus { outline: none; }
.top__tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.search { position: relative; display: block; }
.search svg { position: absolute; inset-inline-start: 12px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); fill: var(--muted); pointer-events: none; }
.search input { width: 240px; max-width: 100%; min-height: 42px; padding: 0 12px 0 38px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.search input:focus { outline: none; border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(59, 63, 181, .2); background: #fff; }
.badge-demo { display: inline-block; padding: 5px 12px; border-radius: 999px; background: var(--amber-soft); color: var(--amber); font-weight: 800; font-size: .8rem; }
.main { flex: 1; min-height: 0; overflow-y: auto; padding: clamp(14px, 2.4vw, 28px); padding-bottom: 80px; }
.main:focus { outline: none; }
.view.is-in { animation: viewIn .35s ease both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; font-weight: 700; cursor: pointer; transition: background .2s, border-color .2s, transform .15s, box-shadow .2s; }
.btn:active { transform: scale(.98); }
.btn--primary { background: var(--indigo); color: #fff; }
.btn--primary:hover { background: var(--indigo-d); }
.btn--ghost { background: #fff; border-color: var(--line); }
.btn--ghost:hover { border-color: #b8bfe0; }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: .88rem; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.card h2 { font-size: 1rem; margin-bottom: 14px; }

/* Дашборд */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 16px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.kpi__l { font-size: .8rem; font-weight: 700; color: var(--muted); }
.kpi__v { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 12px; }
.bars { display: grid; gap: 14px; }
.bar__row { display: grid; gap: 6px; }
.bar__head { display: flex; justify-content: space-between; gap: 10px; font-weight: 700; font-size: .92rem; }
.bar__head span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar__track { height: 12px; background: var(--indigo-soft); border-radius: 999px; overflow: hidden; }
.bar__fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #7a7ff2, var(--indigo)); transition: width .6s cubic-bezier(.22, .8, .24, 1); }
.bar__fill--won { background: linear-gradient(90deg, #3cc79b, var(--green)); }
.feed { display: grid; gap: 10px; }
.feed li { position: relative; padding-inline-start: 18px; font-size: .92rem; }
.feed li::before { content: ""; position: absolute; inset-inline-start: 0; top: .5em; width: 8px; height: 8px; border-radius: 50%; background: var(--indigo); }
.feed li:first-child::before { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }

/* Тулбар и чипы */
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 38px; padding: 0 14px; border: 1px solid var(--line); background: #fff; border-radius: 999px; font-weight: 700; font-size: .88rem; cursor: pointer; transition: background .2s, color .2s; }
.chip:hover { border-color: #b8bfe0; }
.chip[aria-pressed="true"] { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.chip em { font-style: normal; opacity: .7; margin-inline-start: 4px; font-variant-numeric: tabular-nums; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tools select { min-height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.count { color: var(--muted); font-size: .86rem; font-weight: 600; margin-bottom: 8px; }

/* Таблица клиентов */
.tbl-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: start; border-bottom: 1px solid var(--line); }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); background: #fafbff; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f7f8ff; }
td.num, th.num { text-align: end; font-variant-numeric: tabular-nums; }
.link { border: 0; background: transparent; padding: 0; font-weight: 800; color: var(--indigo-d); cursor: pointer; text-align: start; border-radius: 4px; }
.link:hover { text-decoration: underline; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 800; }
.pill--lead { background: var(--amber-soft); color: var(--amber); }
.pill--active { background: var(--green-soft); color: var(--green); }
.pill--paused { background: #e8eaf3; color: #4a516e; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

/* Канбан */
.hint-line { color: var(--muted); font-size: .88rem; margin-bottom: 12px; }
.kan { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: start; }
.col-k { background: #e9ecf8; border-radius: 14px; padding: 10px; min-height: 160px; transition: background .2s, box-shadow .2s; }
.col-k.dragover { background: #dde0fa; box-shadow: inset 0 0 0 2px var(--indigo); }
.col-k__h { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; padding: 4px 6px 10px; }
.col-k__h h2 { font-size: .92rem; }
.col-k__h span { color: var(--muted); font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.deals { display: grid; gap: 8px; }
.deal { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; cursor: grab; box-shadow: 0 1px 2px rgba(22, 26, 51, .05); }
.deal.dragging { opacity: .4; }
.deal h3 { font-size: .95rem; line-height: 1.3; }
.deal p { color: var(--muted); font-size: .84rem; }
.deal__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.deal__amt { font-weight: 800; font-variant-numeric: tabular-nums; }
.mv { display: flex; gap: 4px; }
.mv button { width: 36px; height: 36px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; font-weight: 800; }
.mv button:hover:not(:disabled) { background: var(--indigo-soft); border-color: var(--indigo); }
.mv button:disabled { opacity: .35; cursor: not-allowed; }

/* Задачи */
.add { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.add input { flex: 1 1 220px; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.add input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(59, 63, 181, .2); }
.tasks { display: grid; gap: 8px; }
.task { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.task input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--indigo); flex: none; cursor: pointer; }
.task__t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.task.done .task__t { text-decoration: line-through; color: var(--muted); }
.task__due { font-size: .8rem; font-weight: 800; padding: 3px 10px; border-radius: 999px; background: var(--indigo-soft); color: var(--indigo-d); white-space: nowrap; }
.task__due.over { background: var(--red-soft); color: var(--red); }
.icon-btn { width: 38px; height: 38px; border: 1px solid transparent; background: transparent; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 1.2rem; line-height: 1; }
.icon-btn:hover { background: var(--red-soft); color: var(--red); }

/* Панель клиента */
.scrim { position: absolute; inset: 0; background: rgba(22, 26, 51, .38); z-index: 20; animation: fade .2s both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(440px, 100%); background: var(--panel); z-index: 30; box-shadow: -20px 0 40px -20px rgba(22, 26, 51, .4); overflow-y: auto; padding: 20px; animation: slide .28s cubic-bezier(.22, .8, .24, 1) both; }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer__h { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.drawer__h h2 { font-size: 1.35rem; letter-spacing: -.02em; }
.drawer dl { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin-bottom: 18px; align-items: center; }
.drawer dt { color: var(--muted); font-weight: 700; font-size: .86rem; }
.drawer dd select { min-height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; max-width: 100%; }
.drawer h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 16px 0 8px; }
.mini { display: grid; gap: 6px; }
.mini li { padding: 8px 12px; background: var(--bg); border-radius: 8px; font-size: .9rem; display: flex; justify-content: space-between; gap: 8px; }
.notes textarea { width: 100%; min-height: 70px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; resize: vertical; margin: 8px 0; }

/* Диалог */
.dlg { border: 0; border-radius: 16px; padding: 22px; width: min(420px, calc(100% - 24px)); box-shadow: 0 30px 60px -20px rgba(22, 26, 51, .55); color: var(--ink); }
.dlg::backdrop { background: rgba(22, 26, 51, .45); }
.dlg h2 { font-size: 1.25rem; margin-bottom: 14px; }
.field { margin-bottom: 12px; }
.field label { display: block; margin-bottom: 4px; font-weight: 700; font-size: .88rem; }
.field input, .field select, .field textarea { width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.field.bad input { border-color: var(--red); }
.err { color: var(--red); font-weight: 700; font-size: .82rem; margin-top: 3px; }
.err:empty { display: none; }
.hint { color: var(--muted); font-size: .84rem; margin-bottom: 12px; }
.dlg__act { display: flex; justify-content: flex-end; gap: 8px; }

.toast { position: absolute; left: 50%; bottom: 16px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 700; font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 50; max-width: calc(100% - 24px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Адаптив: ширина фрейма, а не экрана */
@media (max-width: 980px) {
  .kan { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .side { flex-direction: row; align-items: center; gap: 8px; padding: 8px 10px; overflow: visible; }
  .brand span:last-child { display: none; }
  .brand { padding: 0; }
  .menu { grid-auto-flow: column; grid-auto-columns: 1fr; flex: 1; }
  .menu__btn { flex-direction: column; justify-content: center; gap: 2px; min-height: 52px; padding: 4px; font-size: .72rem; text-align: center; }
  .side__note { display: none; }
  .search input { width: 100%; }
  .search { flex: 1 1 100%; }
  .top__tools { width: 100%; }
  .kan { grid-template-columns: 1fr; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  tbody tr { padding: 12px 14px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; }
  tbody tr:last-child { border-bottom: 0; }
  td { padding: 0; border: 0; }
  td.num { text-align: end; }
  td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: .8rem; font-weight: 700; }
  td.c-name::before, td.c-status::before, td.c-value::before { content: none; }
  td.c-name { grid-column: 1; }
  td.c-value { grid-column: 2; grid-row: 1; }
  td.c-status { grid-column: 2; grid-row: 2; text-align: end; }
  td.c-ind, td.c-owner { grid-column: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
}
