/* Токены — awesome-design-md/notion/DESIGN.md: нейтральная палитра, шкалы, радиусы.
   Маркетинговый фиолетовый Notion намеренно не используется: интерфейс монохромный, как рабочее пространство,
   акцент — графит (charcoal); цвет только у меток статусов (пастельные tag-тинты).
   Тёмная тема в спецификации не описана: значения выведены по тем же ролям (canvas/surface/hairline/ink). */
:root {
  --primary: #37352f;
  --primary-pressed: #1a1a1a;
  --on-primary: #ffffff;
  --focus-ring: rgba(55, 53, 47, 0.12);
  --link: #0075de;
  --canvas: #ffffff;
  --surface: #f6f5f4;
  --surface-soft: #fafaf9;
  --hairline: #e5e3df;
  --hairline-soft: #ede9e4;
  --hairline-strong: #c8c4be;
  --ink: #1a1a1a;
  --charcoal: #37352f;
  --slate: #5d5b54;
  --steel: #787671;
  --stone: #a4a097;
  --muted: #bbb8b1;
  --success: #1aae39;
  --warning: #dd5b00;
  --error: #e03131;
  --tint-sky: #dcecfa;      --on-sky: #0b4f8a;
  --tint-yellow: #fef7d6;   --on-yellow: #6b5300;
  --tint-mint: #d9f3e1;     --on-mint: #126b26;
  --tint-gray: #f0eeec;     --on-gray: #5d5b54;
  --tint-peach: #ffe8d4;    --on-peach: #793400;
  --shadow-1: rgba(15, 15, 15, 0.04) 0 1px 2px 0;
  --shadow-4: rgba(15, 15, 15, 0.16) 0 16px 48px -8px;
  --r-xs: 4px; --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-full: 9999px;
  --font: "Notion Sans", Inter, -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Helvetica, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --primary: #e9e9e7;
  --primary-pressed: #ffffff;
  --on-primary: #191919;
  --focus-ring: rgba(255, 255, 255, 0.12);
  --canvas: #191919;
  --surface: #202020;
  --surface-soft: #1d1d1d;
  --hairline: #2f2f2f;
  --hairline-soft: #282828;
  --hairline-strong: #3f3f3f;
  --ink: #ececea;
  --charcoal: #d9d8d4;
  --slate: #b0aea8;
  --steel: #9b9a97;
  --stone: #7d7b76;
  --muted: #5f5e5b;
  --tint-sky: #1d3045;      --on-sky: #a9d0f5;
  --tint-yellow: #3a3216;   --on-yellow: #f2dc8c;
  --tint-mint: #1c3524;     --on-mint: #9fe0b1;
  --tint-gray: #2a2a2a;     --on-gray: #b0aea8;
  --tint-peach: #3d2a1a;    --on-peach: #f5c39b;
  --shadow-1: none;
  --shadow-4: rgba(0, 0, 0, 0.5) 0 16px 48px -8px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--canvas); color: var(--ink); }
body {
  font: 400 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overscroll-behavior-y: none;
}
button, input, textarea { font: inherit; color: inherit; }
#app { max-width: 640px; margin: 0 auto; padding: 16px 16px 120px; }

/* типографика (heading-4, heading-5, body-sm, caption, micro-uppercase) */
h1 { font-size: 22px; font-weight: 600; line-height: 1.3; margin: 8px 0 4px; letter-spacing: -0.2px; }
h2 { font-size: 18px; font-weight: 600; line-height: 1.4; margin: 0; }
.sub { color: var(--steel); font-size: 14px; line-height: 1.5; margin: 0; }
.label { font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--stone); margin: 24px 0 8px; }
.muted { color: var(--steel); }
.small { font-size: 13px; line-height: 1.4; }
.num { font-variant-numeric: tabular-nums; }

/* шапка */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: var(--charcoal); }
.brand-mark { width: 24px; height: 24px; border-radius: var(--r-sm); background: var(--charcoal); color: var(--canvas);
  display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.who { text-align: right; font-size: 13px; line-height: 1.3; color: var(--steel); }
.who b { color: var(--charcoal); font-weight: 500; display: block; }

/* кнопки (button-primary / secondary / ghost) */
.btn { appearance: none; border: 1px solid transparent; border-radius: var(--r-md); padding: 10px 18px; min-height: 44px;
  font-size: 14px; font-weight: 500; line-height: 1.3; cursor: pointer; display: inline-flex; align-items: center;
  justify-content: center; gap: 8px; transition: background .15s ease, opacity .15s ease; }
.btn:disabled { background: var(--hairline); color: var(--muted); border-color: transparent; cursor: default; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:active { background: var(--primary-pressed); }
.btn-dark { background: var(--charcoal); color: var(--canvas); }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--hairline-strong); }
.btn-secondary:active { background: var(--surface); }
.btn-ghost { background: transparent; color: var(--charcoal); padding: 8px 12px; min-height: 36px; border-radius: var(--r-sm); }
.btn-ghost:active { background: var(--surface); }
.btn-danger { background: transparent; color: var(--error); border-color: var(--hairline-strong); }
.btn-block { width: 100%; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > .btn { flex: 1 1 0; }
.sticky { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--canvas) 70%, transparent); z-index: 5; }
.sticky > * { max-width: 608px; margin: 0 auto; }

/* карточки (card-base) */
.card { background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: 16px; }
.card + .card { margin-top: 12px; }
.card.soft { background: var(--surface); border-color: transparent; }
.kv { display: grid; grid-template-columns: 112px 1fr; gap: 6px 12px; font-size: 14px; line-height: 1.5; }
.kv dt { color: var(--steel); }
.kv dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }

/* поля (text-input / focused) */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; font-weight: 500; color: var(--slate); margin-bottom: 6px; }
.input { width: 100%; height: 44px; padding: 12px 16px; border: 1px solid var(--hairline-strong); border-radius: var(--r-md);
  background: var(--canvas); color: var(--ink); outline: none; font-size: 16px; }
.input::placeholder { color: var(--muted); }
.input:focus { border-color: var(--charcoal); box-shadow: 0 0 0 3px var(--focus-ring); }
textarea.input { height: 88px; resize: none; line-height: 1.5; }
.input.big { height: 52px; font-size: 20px; font-weight: 600; letter-spacing: 0.5px; }
.hint { font-size: 13px; color: var(--steel); margin-top: 6px; }
.error { color: var(--error); font-size: 14px; white-space: pre-line; margin: 8px 0; }

/* вкладки (pill-tab, segmented-tab) */
.pills { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }
.pill { flex: none; border: 1px solid var(--hairline); border-radius: var(--r-full); padding: 6px 14px; font-size: 14px;
  font-weight: 500; color: var(--steel); background: transparent; cursor: pointer; white-space: nowrap; }
.pill.on { background: var(--charcoal); border-color: var(--charcoal); color: var(--canvas); }
.tabs { display: flex; border-bottom: 1px solid var(--hairline); margin: 0 -16px 16px; padding: 0 16px; gap: 4px; }
.tab { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent; padding: 12px 4px; font-size: 14px;
  font-weight: 500; color: var(--steel); cursor: pointer; display: flex; justify-content: center; gap: 6px; align-items: center; }
.tab.on { color: var(--ink); border-bottom-color: var(--ink); }
.count { background: var(--error); color: #ffffff; border-radius: var(--r-full); font-size: 11px; font-weight: 600;
  min-width: 18px; height: 18px; padding: 0 5px; display: inline-grid; place-items: center; }

/* статусы (badge-tag-*) */
.badge { display: inline-block; border-radius: var(--r-sm); padding: 2px 8px; font-size: 12px; font-weight: 600; line-height: 1.4; white-space: nowrap; }
.s-on_review { background: var(--tint-peach); color: var(--on-peach); }
.s-sent { background: var(--tint-sky); color: var(--on-sky); }
.s-signed { background: var(--tint-yellow); color: var(--on-yellow); }
.s-paid { background: var(--tint-mint); color: var(--on-mint); }
.s-cancelled { background: var(--tint-gray); color: var(--on-gray); text-decoration: line-through; }
.s-pending { background: var(--tint-peach); color: var(--on-peach); }
.s-active { background: var(--tint-mint); color: var(--on-mint); }
.s-blocked, .s-rejected { background: var(--tint-gray); color: var(--on-gray); }

/* списки (comparison-row) */
.list { border: 1px solid var(--hairline); border-radius: var(--r-lg); overflow: hidden; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 16px; border-bottom: 1px solid var(--hairline-soft);
  background: var(--canvas); cursor: pointer; text-align: left; width: 100%; border-left: 0; border-right: 0; border-top: 0; }
.item:last-child { border-bottom: 0; }
.item:active { background: var(--surface); }
.item .t { font-size: 15px; font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .m { font-size: 13px; color: var(--steel); }
.item .r { text-align: right; font-size: 15px; font-weight: 500; }
.empty { text-align: center; padding: 40px 16px; color: var(--steel); font-size: 14px; }
.empty .big { font-size: 32px; margin-bottom: 8px; }

/* пользователи в форме */
.person { border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: 12px; margin-bottom: 8px; position: relative; }
.person .n { font-size: 12px; font-weight: 600; color: var(--stone); margin-bottom: 8px; }
.person .x { position: absolute; top: 6px; right: 6px; }
.person .field:last-child { margin-bottom: 0; }

/* аналитика (stat-row) */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpi { background: var(--surface); border-radius: var(--r-lg); padding: 14px 16px; }
.kpi .v { font-size: 20px; font-weight: 600; line-height: 1.3; letter-spacing: -0.2px; }
.kpi .k { font-size: 13px; color: var(--steel); }
.bars { display: grid; gap: 10px; }
.bar { display: grid; grid-template-columns: 120px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.bar .track { height: 8px; background: var(--surface); border-radius: var(--r-full); overflow: hidden; }
.bar .fill { height: 100%; border-radius: var(--r-full); background: var(--charcoal); }
.chart { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; align-items: end; height: 140px; padding-top: 8px; }
.col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.col .b { width: 100%; max-width: 36px; border-radius: var(--r-xs) var(--r-xs) 0 0; background: var(--hairline); position: relative; min-height: 2px; }
.col .b .p { position: absolute; bottom: 0; left: 0; right: 0; background: var(--charcoal); border-radius: inherit; }
.col span { font-size: 11px; color: var(--steel); }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--steel); margin-top: 8px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-weight: 500; color: var(--steel); padding: 8px 6px; border-bottom: 1px solid var(--hairline); }
table.t td { padding: 10px 6px; border-bottom: 1px solid var(--hairline-soft); vertical-align: top; }
table.t td.r, table.t th.r { text-align: right; }

/* история (timeline) */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 20px; font-size: 14px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--charcoal); }
.timeline li::after { content: ""; position: absolute; left: 7px; top: 16px; bottom: 0; width: 1px; background: var(--hairline); }
.timeline li:last-child::after { display: none; }
.timeline .when { color: var(--steel); font-size: 12px; }

/* состояния */
.center { min-height: 70vh; display: grid; place-items: center; text-align: center; }
.done { font-size: 44px; width: 72px; height: 72px; border-radius: 50%; background: var(--tint-mint); color: var(--on-mint);
  display: grid; place-items: center; margin: 0 auto 16px; }
.skeleton { background: linear-gradient(90deg, var(--surface) 0%, var(--hairline-soft) 50%, var(--surface) 100%);
  background-size: 200% 100%; animation: sk 1.2s infinite linear; border-radius: var(--r-md); height: 16px; margin: 10px 0; }
@keyframes sk { to { background-position: -200% 0; } }
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sheet-bg { position: fixed; inset: 0; background: rgba(15, 15, 15, 0.4); z-index: 10; display: flex; align-items: flex-end; }
.sheet { background: var(--canvas); width: 100%; border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 20px 16px calc(16px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-4); }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--charcoal); color: var(--canvas);
  padding: 10px 16px; border-radius: var(--r-md); font-size: 14px; z-index: 20; max-width: 90vw; text-align: center; }
.fade { animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
