/* «Картотека» — простая CRM. Чёрная боковая панель, светлый рабочий стол, жёлтый — только для действия и «сегодня». */
:root {
  --bg: #F4F3EE;
  --card: #FFFFFF;
  --line: #E2DFD5;
  --ink: #0A0A0A;
  --ink-2: #62625A;
  --yellow: #FFD400;
  --late: #C7281C;
  --late-bg: #FBE7E4;
  --ok: #1E7A3A;
  --side: 232px;
  --display: 'Unbounded', system-ui, sans-serif;
  --font: 'Onest', system-ui, sans-serif;
  --r: 14px;
  --shadow: 0 1px 2px rgba(10, 10, 0, .06), 0 10px 24px -18px rgba(10, 10, 0, .35);
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; }
body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font: 400 .9688rem/1.45 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, ul, ol, fieldset { margin: 0; padding: 0; }
ul, ol { list-style: none; }
fieldset { border: 0; min-width: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
svg { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; border-radius: 8px; }
::selection { background: var(--yellow); }
.muted { color: var(--ink-2); font-weight: 400; }

/* Боковая панель */
.side { position: fixed; inset: 0 auto 0 0; width: var(--side); display: flex; flex-direction: column; gap: 22px; padding: 20px 14px; background: var(--ink); color: #F5F5F0; z-index: 20; }
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px; text-decoration: none; font-family: var(--display); font-weight: 800; font-size: 1.0625rem; letter-spacing: -.01em; }
.logo svg { width: 30px; height: 30px; color: var(--yellow); stroke-width: 2.2; }
.nav { display: grid; gap: 4px; }
.nav button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 46px; padding: 0 12px; border-radius: 10px; font-weight: 500; color: #B9B9B1; text-align: left; transition: background-color .15s, color .15s; }
.nav svg { width: 20px; height: 20px; }
.nav button:hover { color: #fff; background: #1C1C1C; }
.nav button[aria-current] { background: var(--yellow); color: var(--ink); font-weight: 700; }
.nav i { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--late); color: #fff; font-style: normal; font-size: .75rem; font-weight: 700; text-align: center; }
.nav button[aria-current] i { background: var(--ink); }
.side__note { margin-top: auto; padding: 0 8px; font-size: .75rem; line-height: 1.5; color: #8A8A82; }

/* Рабочая область */
.main { margin-left: var(--side); min-height: 100vh; display: flex; flex-direction: column; }
.bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 14px; padding: 14px clamp(16px, 2.4vw, 32px); background: rgba(244, 243, 238, .92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.bar h1 { font-family: var(--display); font-weight: 800; font-size: clamp(1.125rem, 1.8vw, 1.5rem); letter-spacing: -.02em; margin-right: auto; }
.search { display: flex; align-items: center; gap: 8px; width: min(320px, 34vw); min-height: 44px; padding: 0 14px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
.search svg { width: 18px; height: 18px; color: var(--ink-2); }
.search input { width: 100%; border: 0; background: none; outline: none; }
.search:focus-within { border-color: var(--ink); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 12px; background: var(--yellow); color: var(--ink); font-weight: 700; white-space: nowrap; text-decoration: none; transition: transform .15s, background-color .15s, border-color .15s; }
.btn:hover { transform: translateY(-1px); background: #FFDF3D; }
.btn--line { background: var(--card); border: 1px solid var(--line); font-weight: 600; }
.btn--line:hover { background: var(--card); border-color: var(--ink); }
.btn--danger { color: var(--late); }
.btn--danger:hover { border-color: var(--late); }
.view { flex: 1; padding: clamp(14px, 2vw, 28px) clamp(16px, 2.4vw, 32px) 48px; }
.chip { display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: .8125rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.chip:hover { border-color: var(--ink); }
.tag { padding: 2px 9px; border-radius: 999px; background: var(--bg); font-size: .75rem; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.hint { font-size: .875rem; color: var(--ink-2); max-width: 64ch; }
.link { text-align: left; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* Доска */
.view--board { padding-right: 0; overflow-x: auto; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; align-items: start; min-width: min-content; padding-right: clamp(16px, 2.4vw, 32px); }
.col { display: flex; flex-direction: column; gap: 10px; min-height: 240px; padding: 12px; border-radius: 18px; background: #EAE8E0; border: 2px solid transparent; transition: border-color .15s, background-color .15s; }
.col.is-over { border-color: var(--ink); background: #E2DFD5; }
.col header { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; align-items: center; padding: 2px 4px; }
.col h2 { font-size: .8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col header span { min-width: 24px; padding: 1px 8px; border-radius: 999px; background: var(--card); font-size: .75rem; font-weight: 700; text-align: center; }
.col header b { grid-column: 1 / -1; min-height: 1.2em; font-size: .8125rem; font-weight: 500; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.col--won { background: #E0EEDD; }
.col--won h2 { color: var(--ok); }
.col--lost { background: #EDE6E4; }
.col--lost h2 { color: var(--ink-2); }
.col__list { display: grid; gap: 8px; }
.col__empty { padding: 18px 10px; border: 1.5px dashed #C9C5BA; border-radius: 12px; font-size: .8125rem; color: var(--ink-2); text-align: center; }
.col__add { min-height: 40px; border-radius: 10px; font-size: .875rem; font-weight: 600; color: var(--ink-2); transition: background-color .15s, color .15s; }
.col__add:hover { background: var(--card); color: var(--ink); }
.card { display: grid; gap: 6px; padding: 12px 14px; border-radius: var(--r); background: var(--card); box-shadow: var(--shadow); border-left: 4px solid transparent; cursor: grab; transition: transform .15s, box-shadow .15s; }
.card:hover { transform: translateY(-2px); }
.card:active { cursor: grabbing; }
.card.is-drag { opacity: .4; }
.card.is-late { border-left-color: var(--late); }
.card h3 { font-size: .9688rem; font-weight: 700; line-height: 1.3; }
.card__client { font-size: .8438rem; color: var(--ink-2); }
.card__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card__row b { font-variant-numeric: tabular-nums; }
.card__next { padding-top: 7px; border-top: 1px solid var(--line); font-size: .8125rem; color: var(--ink-2); }
.card__next.is-soon { color: var(--ink); font-weight: 600; }
.card__next.is-soon::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 1px var(--ink); }
.card__next.is-late { color: var(--late); font-weight: 600; }
.card__next.is-none { color: #9A6A00; }

/* Пустые состояния */
.empty { max-width: 640px; margin: clamp(20px, 6vh, 72px) auto; padding: clamp(24px, 4vw, 40px); border-radius: 22px; background: var(--card); box-shadow: var(--shadow); display: grid; gap: 14px; }
.empty h2 { font-family: var(--display); font-weight: 800; font-size: clamp(1.25rem, 2.4vw, 1.75rem); letter-spacing: -.02em; }
.empty p { color: var(--ink-2); }
.empty ol { display: grid; gap: 10px; counter-reset: s; }
.empty ol li { counter-increment: s; position: relative; min-height: 30px; padding: 3px 0 3px 42px; }
.empty ol li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--yellow); font-weight: 700; }
.empty__acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

/* Сегодня */
.tasks { margin-bottom: 26px; }
.tasks h2 { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: .8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.tasks h2 span { padding: 1px 9px; border-radius: 999px; background: var(--card); font-size: .75rem; }
.tasks.is-late h2 { color: var(--late); }
.tasks .hint { margin-bottom: 10px; }
.tasks ul { display: grid; gap: 6px; }
.task { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 12px 16px; border-radius: var(--r); background: var(--card); box-shadow: var(--shadow); }
.task > div { flex: 1 1 260px; min-width: 0; display: grid; }
.task b { font-weight: 700; }
.task span { font-size: .8438rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task em { font-style: normal; font-size: .8125rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.is-late .task { border-left: 4px solid var(--late); }
.is-late .task em { color: var(--late); }
.task__done { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--ink); flex: none; transition: background-color .15s; }
.task__done:hover { background: var(--yellow); }

/* Таблица клиентов */
.tablewrap { overflow-x: auto; border-radius: 18px; background: var(--card); box-shadow: var(--shadow); }
table { width: 100%; min-width: 720px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 13px 16px; text-align: left; border-top: 1px solid var(--line); }
thead th { border-top: 0; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); background: #FAF9F5; }
tbody th { font-weight: 600; }

/* Сводка */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.kpi { display: grid; gap: 6px; padding: 20px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow); }
.kpi span { font-size: .8125rem; font-weight: 600; color: var(--ink-2); }
.kpi b { font-family: var(--display); font-weight: 800; font-size: clamp(1.25rem, 2.2vw, 1.75rem); letter-spacing: -.03em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi em { font-style: normal; font-size: .8125rem; color: var(--ink-2); }
.kpi--main { background: var(--ink); color: #F5F5F0; }
.kpi--main span, .kpi--main em { color: #B9B9B1; }
.kpi--main b { color: var(--yellow); }
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.charts section { padding: 20px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow); }
.charts h2 { margin-bottom: 14px; font-size: .8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.bars { display: grid; gap: 12px; }
.bars li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline; }
.bars span { font-weight: 600; }
.bars b { font-size: .8438rem; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.bar-line { grid-column: 1 / -1; height: 10px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.bar-line i { display: block; height: 100%; border-radius: 999px; background: var(--ink); }
.bars li:first-child .bar-line i { background: var(--yellow); box-shadow: inset 0 0 0 1px var(--ink); }

/* Настройки */
.set { display: grid; gap: 12px; max-width: 860px; }
.set section { display: grid; gap: 12px; padding: 22px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow); }
.set h2 { font-size: 1.0625rem; font-weight: 700; }
.set__stages { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.set label { display: grid; gap: 6px; font-size: .75rem; font-weight: 600; color: var(--ink-2); }
.set input[type=text], .drawer input, .drawer select { width: 100%; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-size: .9688rem; color: var(--ink); }
.set input:focus, .drawer input:focus, .drawer select:focus { outline: none; border-color: var(--ink); background: #fff; }
.set__acts { display: flex; flex-wrap: wrap; gap: 8px; }
.set__acts label.btn { cursor: pointer; font-size: .9688rem; color: var(--ink); }

/* Карточка сделки */
.drawer { position: fixed; inset: 0; z-index: 40; }
.drawer__back { position: absolute; inset: 0; background: rgba(10, 10, 10, .45); }
.drawer__panel { position: absolute; inset: 0 0 0 auto; width: min(480px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 22px; background: var(--card); overflow-y: auto; box-shadow: -20px 0 50px -30px rgba(0, 0, 0, .5); animation: slide .22s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer header { display: flex; align-items: center; justify-content: space-between; }
.drawer h2 { font-family: var(--display); font-weight: 800; font-size: 1.25rem; letter-spacing: -.02em; }
.x { width: 40px; height: 40px; border-radius: 10px; font-size: 1.5rem; line-height: 1; color: var(--ink-2); }
.x:hover { background: var(--bg); color: var(--ink); }
.drawer label { display: grid; gap: 6px; font-size: .75rem; font-weight: 600; color: var(--ink-2); }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.reach { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -6px; }
.reach:empty { display: none; }
.drawer fieldset { display: grid; gap: 8px; padding: 14px; border-radius: 14px; background: var(--bg); }
.drawer legend { float: left; width: 100%; margin-bottom: 2px; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.drawer fieldset input { background: #fff; }
.next { border: 2px solid var(--yellow) !important; background: #FFFBE6 !important; }
.next__when { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; clear: both; }
.next__when input { width: auto; flex: 1 1 150px; }
.next > input { clear: both; }
.log__add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; clear: both; }
.log ul { display: grid; gap: 6px; max-height: 220px; overflow-y: auto; }
.log li { padding: 8px 10px; border-radius: 10px; background: #fff; font-size: .875rem; }
.log time { display: block; font-size: .6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); }
.drawer footer { display: flex; gap: 8px; margin-top: auto; padding-top: 6px; }
.drawer footer .btn:first-child { flex: 1; }
.is-drawer { overflow: hidden; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 60; translate: -50% 0; padding: 12px 18px; border-radius: 12px; background: var(--ink); color: #fff; font-weight: 500; font-size: .9063rem; box-shadow: 0 14px 30px -12px rgba(0, 0, 0, .5); max-width: calc(100% - 32px); }

@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .charts { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 820px) {
  .side { inset: auto 0 0 0; width: auto; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)); gap: 0; }
  .logo, .side__note { display: none; }
  .nav { grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; gap: 2px; }
  .nav button { flex-direction: column; justify-content: center; gap: 3px; min-height: 52px; padding: 4px 2px; font-size: .6875rem; position: relative; }
  .nav i { position: absolute; top: 3px; right: calc(50% - 22px); margin: 0; min-width: 18px; padding: 0 5px; font-size: .6875rem; }
  .main { margin-left: 0; padding-bottom: 72px; }
  .bar { flex-wrap: wrap; gap: 10px; }
  .search { order: 3; width: 100%; }
  .board { grid-auto-columns: 82vw; }
  .toast { bottom: 84px; }
  .two { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
