/* CRM SAZI AI. Монохром и Inter — как на сайте; цвет только там, где он что-то значит:
   плюс/минус в деньгах, приоритет лида, серии на графиках. Тёмная тема — мягкая, без чистого чёрного. */

:root {
  color-scheme: light;
  --bg: #f3f3f3;
  --bg-2: #ebebeb;
  --surface: #ffffff;
  --surface-2: #f6f6f6;
  --surface-3: #efefef;
  --line: #e4e4e4;
  --line-2: #d3d3d3;
  --ink: #111111;
  --ink-2: #4a4a4a;
  --ink-3: #767676;
  --ink-4: #a3a3a3;
  --accent: #111111;
  --accent-ink: #ffffff;
  --pos: #1c7445;
  --neg: #b3362f;
  --warn: #8f5b00;
  --pos-wash: rgba(28, 116, 69, 0.09);
  --neg-wash: rgba(179, 54, 47, 0.08);
  --warn-wash: rgba(201, 133, 0, 0.12);
  --hot: #d9483b;
  --warm: #d99a1e;
  --cold: #6b8fb8;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #ececec;
  --axis: #c9c9c9;
  --overlay: rgba(17, 17, 17, 0.32);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 24px rgba(0, 0, 0, 0.06);
  --shadow-lift: 0 2px 6px rgba(0, 0, 0, 0.08), 0 18px 40px rgba(0, 0, 0, 0.14);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121315;
    --bg-2: #17181b;
    --surface: #1c1d20;
    --surface-2: #232428;
    --surface-3: #2a2b30;
    --line: #2c2d32;
    --line-2: #3a3b41;
    --ink: #e8e8ea;
    --ink-2: #bdbec3;
    --ink-3: #8f9096;
    --ink-4: #66676d;
    --accent: #e8e8ea;
    --accent-ink: #141517;
    --pos: #62c08c;
    --neg: #ee8076;
    --warn: #dcaa52;
    --pos-wash: rgba(98, 192, 140, 0.12);
    --neg-wash: rgba(238, 128, 118, 0.11);
    --warn-wash: rgba(220, 170, 82, 0.13);
    --hot: #ec6a5e;
    --warm: #e2ad45;
    --cold: #84a7cf;
    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: #2a2b30;
    --axis: #3d3e44;
    --overlay: rgba(0, 0, 0, 0.55);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.28);
    --shadow-lift: 0 4px 12px rgba(0, 0, 0, 0.4), 0 22px 48px rgba(0, 0, 0, 0.45);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121315;
  --bg-2: #17181b;
  --surface: #1c1d20;
  --surface-2: #232428;
  --surface-3: #2a2b30;
  --line: #2c2d32;
  --line-2: #3a3b41;
  --ink: #e8e8ea;
  --ink-2: #bdbec3;
  --ink-3: #8f9096;
  --ink-4: #66676d;
  --accent: #e8e8ea;
  --accent-ink: #141517;
  --pos: #62c08c;
  --neg: #ee8076;
  --warn: #dcaa52;
  --pos-wash: rgba(98, 192, 140, 0.12);
  --neg-wash: rgba(238, 128, 118, 0.11);
  --warn-wash: rgba(220, 170, 82, 0.13);
  --hot: #ec6a5e;
  --warm: #e2ad45;
  --cold: #84a7cf;
  --series-1: #3987e5;
  --series-2: #d95926;
  --grid: #2a2b30;
  --axis: #3d3e44;
  --overlay: rgba(0, 0, 0, 0.55);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.28);
  --shadow-lift: 0 4px 12px rgba(0, 0, 0, 0.4), 0 22px 48px rgba(0, 0, 0, 0.45);
}

/* ---------- основа ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  font-optical-sizing: auto;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 var(--font);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.032em;
}

h1 {
  font-size: 24px;
  line-height: 1.15;
}

h2 {
  font-size: 17px;
  letter-spacing: -0.02em;
}

h3 {
  font-size: 13px;
  letter-spacing: 0;
  color: var(--ink-3);
  font-weight: 500;
}

code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.92em;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 5px;
}

.muted {
  color: var(--ink-3);
}

.small {
  font-size: 12px;
}

.num {
  font-variant-numeric: tabular-nums;
}

.pos {
  color: var(--pos);
}

.neg {
  color: var(--neg);
}

.warn {
  color: var(--warn);
}

.hidden {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

::selection {
  background: var(--ink);
  color: var(--bg);
}

/* ---------- вход ---------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border-radius: 18px;
  padding: 32px 28px 28px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
}

.login-mark {
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--ink-3);
}

.login-card h1 {
  font-size: 32px;
  margin-top: -6px;
}

.btn-touch {
  height: 44px;
  font-size: 15px;
}

.login-or {
  text-align: center;
  color: var(--ink-4);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.login-or::before,
.login-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.login-error {
  margin: 0;
  color: var(--neg);
  font-size: 13px;
}

/* ---------- каркас ---------- */

.layout {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  min-height: 100vh;
}

.nav {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 20px 12px 16px;
  border-right: 1px solid var(--line);
  background: var(--bg);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 0 10px 18px;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-size: 17px;
}

.brand span {
  color: var(--ink-4);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ink-2);
  font-weight: 500;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--ink-3);
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.nav-link.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--line);
}

.nav-link.active svg {
  color: var(--ink);
}

.nav-spacer {
  flex: 1;
}

.nav-foot {
  display: grid;
  gap: 10px;
  padding: 0 4px;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 28px 16px;
  flex-wrap: wrap;
}

.top h1 {
  margin-right: auto;
}

.page {
  padding: 0 28px 40px;
  min-width: 0;
}

.page.page-board {
  padding: 0;
}

/* ---------- кнопки и поля ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
}

.btn:hover {
  background: var(--surface-2);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent);
  opacity: 0.88;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--ink-2);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.btn-danger {
  color: var(--neg);
  border-color: transparent;
  background: transparent;
}

.btn-danger:hover {
  background: var(--neg-wash);
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 0;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  flex: none;
  text-decoration: none;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.field > .seg {
  justify-self: start;
}

.field > span {
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 500;
}

.input,
.field input,
.field select,
.field textarea,
select.input {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--surface);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
  min-width: 0;
}

.field textarea,
textarea.input {
  height: auto;
  min-height: 76px;
  padding: 9px 11px;
  resize: vertical;
  line-height: 1.45;
}

.input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--ink-3);
  box-shadow: 0 0 0 3px var(--surface-3);
}

input[type="date"] {
  min-width: 0;
}

.input-money {
  font-variant-numeric: tabular-nums;
}

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.seg::-webkit-scrollbar {
  display: none;
}

.seg button {
  border: 0;
  background: transparent;
  height: 28px;
  padding: 0 11px;
  border-radius: 7px;
  color: var(--ink-3);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  font-size: 13px;
}

.seg button:hover {
  color: var(--ink);
}

.seg button.on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--line);
}

.seg-theme button {
  padding: 0 8px;
  display: inline-grid;
  place-items: center;
}

.seg-theme svg {
  width: 16px;
  height: 16px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--ink-3);
  color: var(--ink);
}

.chip.on {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.chip .x {
  border: 0;
  background: none;
  padding: 0;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag-pos {
  background: var(--pos-wash);
  color: var(--pos);
}

.tag-neg {
  background: var(--neg-wash);
  color: var(--neg);
}

.tag-warn {
  background: var(--warn-wash);
  color: var(--warn);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  background: var(--ink-4);
}

.dot-hot {
  background: var(--hot);
}

.dot-warm {
  background: var(--warm);
}

.dot-cold {
  background: var(--cold);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search {
  position: relative;
  flex: 1 1 220px;
  max-width: 340px;
}

.search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  color: var(--ink-4);
  pointer-events: none;
}

.search .input {
  padding-left: 33px;
}

/* ---------- канбан ---------- */

.board-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 0 28px 14px;
}

.board-total {
  margin-left: auto;
  color: var(--ink-3);
  font-size: 13px;
}

.board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 2px 28px 28px;
  align-items: flex-start;
  min-height: calc(100vh - 140px);
  scroll-padding: 0 28px;
}

.col {
  flex: 0 0 272px;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border-radius: var(--radius);
  max-height: calc(100vh - 150px);
}

.col-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 12px 14px 8px;
}

.col-name {
  font-weight: 600;
  letter-spacing: -0.01em;
}

.col-count {
  color: var(--ink-4);
  font-weight: 500;
  font-size: 13px;
}

.col-sum {
  margin-left: auto;
  color: var(--ink-3);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.col-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 8px 10px;
  overflow-y: auto;
  min-height: 80px;
  flex: 1;
}

.col.drop-target {
  box-shadow: inset 0 0 0 2px var(--ink-4);
}

.col-empty {
  color: var(--ink-4);
  font-size: 12.5px;
  text-align: center;
  padding: 18px 8px;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-sm);
}

.card {
  background: var(--surface);
  border-radius: 10px;
  padding: 11px 12px 10px;
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
  display: grid;
  gap: 6px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: box-shadow 0.12s, transform 0.12s;
}

.card:hover {
  box-shadow: 0 0 0 1px var(--line-2), var(--shadow);
}

.card-top {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.card-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.card-amount {
  margin-left: auto;
  font-weight: 500;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.card-title {
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  color: var(--ink-3);
  font-size: 12px;
}

.card-meta svg {
  width: 13px;
  height: 13px;
}

.card-side {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.progress {
  height: 4px;
  border-radius: 4px;
  background: var(--surface-3);
  overflow: hidden;
}

.progress > i {
  display: block;
  height: 100%;
  background: var(--pos);
  border-radius: 4px;
}

.ghost {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  transform: rotate(1.5deg);
  box-shadow: var(--shadow-lift);
  opacity: 0.96;
}

.placeholder {
  background: transparent !important;
  box-shadow: none !important;
  border: 1.5px dashed var(--ink-4);
  border-radius: 10px;
}

.placeholder > * {
  visibility: hidden;
}

.dragging-src {
  display: none !important;
}

.nav-link.only-narrow {
  display: none;
}

body.is-dragging,
body.is-dragging * {
  cursor: grabbing !important;
}

body.is-dragging {
  touch-action: none;
  overscroll-behavior: none;
}

/* ---------- панель сделки ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 40;
  animation: fade 0.15s ease;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(600px, 100vw);
  background: var(--bg);
  z-index: 41;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lift);
  animation: slide 0.18s ease;
}

@keyframes slide {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.drawer-head {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
  background: var(--bg);
}

.drawer-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-meta {
  color: var(--ink-3);
  font-size: 12px;
  margin-right: auto;
}

.save-state {
  color: var(--ink-4);
  font-size: 12px;
  transition: opacity 0.3s;
}

.name-input {
  width: 100%;
  border: 0;
  background: transparent;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.03em;
  padding: 2px 0;
  outline: none;
  border-radius: 6px;
}

.name-input:focus {
  box-shadow: 0 0 0 3px var(--surface-3);
}

.stage-strip {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -20px;
  padding: 0 20px 2px;
}

.stage-strip::-webkit-scrollbar {
  display: none;
}

.stage-btn {
  flex: none;
  height: 28px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-3);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

.stage-btn:hover {
  color: var(--ink);
  border-color: var(--line-2);
}

.stage-btn.passed {
  color: var(--ink-2);
}

.stage-btn.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.stage-btn.lost.on {
  background: var(--neg);
  border-color: var(--neg);
  color: #fff;
}

.drawer-body {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-content: start;
  flex: 1;
}

.section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 0 0 1px var(--line);
  display: grid;
  gap: 12px;
  min-width: 0;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-head h2 {
  margin-right: auto;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.with-action {
  display: flex;
  gap: 6px;
  align-items: center;
}

.with-action .input {
  flex: 1;
}

.money-sum {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.money-sum > div {
  padding: 10px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.money-sum b {
  display: block;
  font-size: 18px;
  font-weight: 400;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.money-sum span {
  font-size: 11.5px;
  color: var(--ink-3);
}

.money-sum .hl {
  background: var(--surface-2);
}

.rows {
  display: grid;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.row:last-child {
  border-bottom: 0;
}

.row-main {
  flex: 1;
  min-width: 0;
}

.row-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-sub {
  color: var(--ink-3);
  font-size: 12px;
}

.row-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  white-space: nowrap;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--ink-3);
  white-space: nowrap;
  user-select: none;
}

.check input {
  width: 16px;
  height: 16px;
  accent-color: var(--ink);
  margin: 0;
}

.check.wrap {
  white-space: normal;
  align-items: flex-start;
  line-height: 1.35;
}

.check.wrap input {
  margin-top: 1px;
  flex: none;
}

.drawer-row.wrap {
  flex-wrap: wrap;
}

.check.done {
  color: var(--pos);
}

.add-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.add-row.add-row-3 {
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) auto;
}

.quick {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.note-box {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink-2);
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.timeline {
  display: grid;
  gap: 0;
}

.timeline > div {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  font-size: 13px;
  color: var(--ink-2);
}

.timeline time {
  color: var(--ink-4);
  font-size: 12px;
  min-width: 92px;
  font-variant-numeric: tabular-nums;
}

.hint {
  font-size: 12px;
  color: var(--ink-3);
  margin: 0;
}

/* ---------- модальные окна ---------- */

.modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--overlay);
  animation: fade 0.12s ease;
}

.modal {
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow-lift);
  display: grid;
  gap: 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* ---------- таблицы ---------- */

.table-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--line);
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  text-align: left;
  font-weight: 500;
  color: var(--ink-3);
  font-size: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--surface);
}

.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.table tr:last-child td {
  border-bottom: 0;
}

.table .r {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.table tbody tr.click {
  cursor: pointer;
}

.table tbody tr.click:hover td {
  background: var(--surface-2);
}

.cell-main {
  font-weight: 500;
}

.cell-sub {
  color: var(--ink-3);
  font-size: 12px;
}

.empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--ink-3);
}

.empty b {
  display: block;
  color: var(--ink);
  font-weight: 600;
  margin-bottom: 4px;
}

/* ---------- аналитика ---------- */

.stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.hero {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--line);
  padding: 20px 22px;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 24px;
}

.hero-label {
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 500;
}

.hero-value {
  font-size: 54px;
  font-weight: 250;
  letter-spacing: -0.045em;
  line-height: 1.05;
  margin: 6px 0 4px;
  white-space: nowrap;
}

.waterfall {
  display: grid;
  gap: 2px;
  align-content: center;
  font-size: 13px;
}

.waterfall > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
}

.waterfall > div:last-child {
  border-bottom: 0;
  font-weight: 600;
}

.waterfall span:first-child {
  color: var(--ink-2);
}

.waterfall span:last-child {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 12px;
}

.tile {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--line);
  padding: 14px 16px;
  display: grid;
  gap: 2px;
  align-content: start;
  min-width: 0;
}

.tile-label {
  color: var(--ink-3);
  font-size: 12.5px;
  font-weight: 500;
}

.tile-value {
  font-size: 28px;
  font-weight: 300;
  letter-spacing: -0.035em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-sub {
  color: var(--ink-3);
  font-size: 12px;
}

.tile-hint {
  color: var(--ink-4);
  font-size: 11.5px;
  margin-top: 6px;
  line-height: 1.4;
}

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--line);
  padding: 16px 18px 18px;
  display: grid;
  gap: 12px;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-head h2 {
  margin-right: auto;
}

.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.legend {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--ink-2);
}

.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: -1px;
}

.chart {
  position: relative;
  width: 100%;
}

.chart svg {
  display: block;
  width: 100%;
  overflow: visible;
}

.chart text {
  fill: var(--ink-3);
  font-size: 11px;
  font-family: var(--font);
}

.chart .gridline {
  stroke: var(--grid);
  stroke-width: 1;
}

.chart .baseline {
  stroke: var(--axis);
  stroke-width: 1;
}

.chart .bar {
  transition: opacity 0.12s;
}

.chart .hit {
  fill: transparent;
  cursor: default;
}

.chart.hovering .bar:not(.lit) {
  opacity: 0.45;
}

.tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow-lift);
  padding: 8px 10px;
  font-size: 12px;
  min-width: 120px;
  white-space: nowrap;
}

.tip-title {
  color: var(--ink-3);
  margin-bottom: 4px;
}

.tip-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tip-row b {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tip-row i {
  display: inline-block;
  width: 12px;
  height: 2px;
  border-radius: 1px;
}

.tip-row span {
  color: var(--ink-3);
}

.funnel {
  display: grid;
  gap: 8px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) 92px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.funnel-label {
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.funnel-track {
  height: 22px;
  position: relative;
}

.funnel-bar {
  height: 100%;
  border-radius: 0 4px 4px 0;
  background: var(--series-1);
  min-width: 2px;
}

.funnel-row.top .funnel-bar {
  background: var(--ink-4);
}

.funnel-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.funnel-num span {
  color: var(--ink-3);
  font-size: 12px;
  margin-left: 6px;
}

.meter {
  height: 8px;
  border-radius: 8px;
  background: var(--surface-3);
  overflow: hidden;
}

.meter > i {
  display: block;
  height: 100%;
  border-radius: 8px;
  background: var(--ink-2);
}

.meter.warn > i {
  background: var(--warn);
}

.meter.danger > i {
  background: var(--neg);
}

.callout {
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 13px;
}

/* ---------- планировщик ---------- */

.plan-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 16px;
  align-items: start;
}

.plan-inputs {
  display: grid;
  gap: 12px;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stepper .input {
  text-align: center;
  font-size: 22px;
  height: 48px;
  font-weight: 300;
  letter-spacing: -0.03em;
}

.stepper .btn {
  height: 48px;
  width: 48px;
  padding: 0;
  font-size: 20px;
}

.plan-result {
  display: grid;
  gap: 14px;
}

.plan-big {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.plan-big .tile-value {
  font-size: 36px;
}

.factor {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--ink-2);
  margin-left: 6px;
  vertical-align: 6px;
}

/* ---------- деньги ---------- */

.totals {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  font-size: 13px;
  color: var(--ink-2);
}

.totals b {
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.form-row {
  display: grid;
  grid-template-columns: 1.1fr 1.1fr 1fr 1fr 1.6fr auto;
  gap: 8px;
  align-items: end;
}

.form-row.form-row-4 {
  grid-template-columns: 2fr 1.2fr 1fr auto;
}

/* ---------- уведомления ---------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 80;
  display: grid;
  gap: 8px;
  justify-items: center;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}

.toast {
  background: var(--ink);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow-lift);
  animation: fade 0.15s ease;
  pointer-events: auto;
  display: flex;
  gap: 10px;
  align-items: center;
}

.toast.error {
  background: var(--neg);
  color: #fff;
}

.toast button {
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.loading {
  opacity: 0.55;
  transition: opacity 0.2s;
}

/* ---------- мобильная версия ---------- */

@media (max-width: 1100px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .two,
  .plan-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .nav-link.only-narrow {
    display: flex;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .nav {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: auto;
    z-index: 30;
    flex-direction: row;
    justify-content: space-around;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--line);
    background: var(--bg);
  }

  .brand,
  .nav-spacer,
  .nav-foot {
    display: none;
  }

  .nav-link {
    flex-direction: column;
    gap: 2px;
    font-size: 10.5px;
    padding: 6px 4px;
    flex: 1;
    text-align: center;
    min-width: 0;
  }

  .nav-link.active {
    box-shadow: none;
    background: transparent;
  }

  .nav-link.only-wide {
    display: none;
  }

  .main {
    padding-bottom: 72px;
  }

  .top {
    padding: 16px 16px 12px;
  }

  .page {
    padding: 0 16px 32px;
  }

  .board-bar {
    padding: 0 16px 12px;
  }

  .board {
    padding: 2px 16px 20px;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 16px;
    min-height: calc(100vh - 200px);
  }

  .col {
    flex-basis: min(300px, calc(100vw - 48px));
    scroll-snap-align: start;
    max-height: calc(100vh - 210px);
  }

  .drawer {
    width: 100vw;
  }

  .drawer-head,
  .drawer-body {
    padding-left: 16px;
    padding-right: 16px;
  }

  .stage-strip {
    margin: 0 -16px;
    padding: 0 16px 2px;
  }

  .hero-value {
    font-size: 44px;
  }

  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .tile-value {
    font-size: 22px;
  }

  .plan-big .tile-value {
    font-size: 28px;
  }

  .form-row,
  .add-row,
  .add-row.add-row-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-row > :last-child,
  .add-row > :last-child {
    grid-column: 1 / -1;
  }

  .funnel-row {
    grid-template-columns: 92px minmax(0, 1fr) 80px;
  }

  .hide-sm {
    display: none;
  }
}

@media (max-width: 520px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .money-sum {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .plan-big {
    grid-template-columns: 1fr;
  }

  .top h1 {
    font-size: 21px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 860px) {
  .form-row.form-row-4 {
    grid-template-columns: 1fr;
  }
}


/* ---------- задачи: матрица Эйзенхауэра ---------- */

.quad-dot-do { background: var(--neg); }
.quad-dot-plan { background: var(--series-1); }
.quad-dot-delegate { background: var(--warm); }
.quad-dot-drop { background: var(--ink-4); }

.matrix {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.quad {
  background: var(--bg-2);
  border-radius: var(--radius);
  padding: 12px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 220px;
  min-width: 0;
}

.quad.drop-target {
  box-shadow: inset 0 0 0 2px var(--ink-4);
}

.quad-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
}

.quad-head .dot {
  width: 10px;
  height: 10px;
}

.quad-name {
  font-weight: 600;
  letter-spacing: -0.01em;
}

.quad-hint {
  color: var(--ink-3);
  font-size: 12px;
}

.quad-count {
  margin-left: auto;
  color: var(--ink-3);
  font-size: 12px;
  white-space: nowrap;
}

.quad-add {
  height: 34px;
  background: var(--surface);
  border-style: dashed;
}

.quad-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 60px;
}

.task {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.task:hover {
  box-shadow: 0 0 0 1px var(--line-2), var(--shadow);
}

.task.done .task-title {
  text-decoration: line-through;
  color: var(--ink-3);
}

.task-check {
  display: inline-flex;
  padding-top: 1px;
  cursor: pointer;
}

.task-check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--ink);
  cursor: pointer;
}

.task-main {
  display: grid;
  gap: 5px;
  min-width: 0;
  flex: 1;
}

.task-title {
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.tag-link {
  text-decoration: none;
}

.tag-link:hover {
  background: var(--line-2);
}

.quad-pick {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.quad-opt {
  display: grid;
  gap: 2px;
  text-align: left;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  cursor: pointer;
}

.quad-opt b {
  font-weight: 600;
  font-size: 13px;
}

.quad-opt span {
  color: var(--ink-3);
  font-size: 12px;
}

.quad-opt.on {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.quad-opt-do.on { border-color: var(--neg); box-shadow: inset 0 0 0 1px var(--neg); }
.quad-opt-plan.on { border-color: var(--series-1); box-shadow: inset 0 0 0 1px var(--series-1); }
.quad-opt-delegate.on { border-color: var(--warm); box-shadow: inset 0 0 0 1px var(--warm); }

/* ---------- календарь ---------- */

.ev-dot-call { background: var(--series-1); }
.ev-dot-meeting { background: var(--series-2); }
.ev-dot-task { background: var(--ink-4); }

.cal {
  display: grid;
  gap: 12px;
}

.cal-label {
  font-weight: 600;
  margin-right: auto;
}

.cal-bar .seg button {
  min-width: 34px;
}

.cal-scroll {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--line);
  overflow: auto;
  max-height: calc(100vh - 170px);
}

.cal-inner {
  min-width: 100%;
}

.cal-inner.week {
  min-width: 760px;
}

.cal-head,
.cal-allday,
.cal-grid {
  display: grid;
  grid-template-columns: 56px repeat(var(--days, 1), minmax(0, 1fr));
}

.cal-inner.week .cal-head,
.cal-inner.week .cal-allday,
.cal-inner.week .cal-grid {
  --days: 7;
}

.cal-head {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.cal-day-head {
  border: 0;
  background: transparent;
  padding: 8px 4px;
  display: flex;
  gap: 6px;
  align-items: baseline;
  justify-content: center;
  color: var(--ink-3);
  cursor: pointer;
  font-size: 12px;
}

.cal-day-head b {
  font-size: 18px;
  font-weight: 400;
  color: var(--ink);
}

.cal-day-head.today b {
  background: var(--neg);
  color: #fff;
  border-radius: 999px;
  padding: 0 7px;
}

.cal-allday {
  border-bottom: 1px solid var(--line);
  min-height: 30px;
}

.cal-allday .cal-gutter {
  padding: 6px 4px;
  text-align: right;
}

.cal-allday-cell {
  border-left: 1px solid var(--line);
  padding: 4px;
  display: grid;
  gap: 3px;
  align-content: start;
  min-width: 0;
}

.cal-task {
  display: flex;
  align-items: center;
  gap: 5px;
  border: 0;
  border-radius: 6px;
  background: var(--surface-2);
  padding: 3px 6px;
  font-size: 11.5px;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.cal-gutter {
  position: relative;
}

.cal-hours span {
  position: absolute;
  right: 8px;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}

.cal-hours span:first-child {
  transform: none;
}

.cal-col {
  position: relative;
  border-left: 1px solid var(--line);
  cursor: copy;
}

.cal-col.today {
  background: color-mix(in srgb, var(--surface-2) 60%, transparent);
}

.cal-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid var(--grid);
}

.cal-now {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 2px solid var(--neg);
  z-index: 2;
  pointer-events: none;
}

.cal-now::before {
  content: "";
  position: absolute;
  left: -5px;
  top: -6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--neg);
}

.cal-ev {
  position: absolute;
  z-index: 1;
  display: grid;
  align-content: start;
  gap: 1px;
  padding: 4px 7px;
  border: 0;
  border-left: 3px solid var(--ink-4);
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--ink);
  text-align: left;
  font-size: 12px;
  line-height: 1.3;
  overflow: hidden;
  cursor: pointer;
}

.cal-ev:hover {
  filter: brightness(0.97);
  z-index: 2;
}

.cal-ev.ev-call {
  border-left-color: var(--series-1);
  background: color-mix(in srgb, var(--series-1) 14%, var(--surface));
}

.cal-ev.ev-meeting {
  border-left-color: var(--series-2);
  background: color-mix(in srgb, var(--series-2) 14%, var(--surface));
}

.cal-ev-time {
  color: var(--ink-2);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-ev-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

.cal-ev.short .cal-ev-title {
  -webkit-line-clamp: 1;
  white-space: nowrap;
  display: block;
}

.cal-ev-sub {
  color: var(--ink-3);
  font-size: 11px;
}

.cal-ev.short {
  grid-auto-flow: column;
  justify-content: start;
  gap: 6px;
  padding-top: 2px;
}

.more-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid var(--line);
}

.more-link:last-child {
  border-bottom: 0;
}

.more-link svg {
  width: 20px;
  height: 20px;
  color: var(--ink-3);
}

@media (max-width: 860px) {
  .matrix {
    grid-template-columns: 1fr;
  }

  .quad {
    min-height: 0;
  }

  .cal-scroll {
    max-height: calc(100vh - 240px);
  }

  .cal-inner.week {
    min-width: 640px;
  }
}

.cal-ev.narrow .cal-ev-time {
  display: none;
}

.cal-ev.narrow {
  padding: 3px 5px;
}
