@font-face { font-family: "NW Display"; src: url(/assets/fonts/nw-display-cyr.woff2) format("woff2"); font-weight: 200 500; font-display: swap; unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "NW Display"; src: url(/assets/fonts/nw-display-latin.woff2) format("woff2"); font-weight: 200 500; font-display: swap; unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "NW Text"; src: url(/assets/fonts/nw-text-cyr.woff2) format("woff2"); font-weight: 300 600; font-display: swap; unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "NW Text"; src: url(/assets/fonts/nw-text-latin.woff2) format("woff2"); font-weight: 300 600; font-display: swap; unicode-range: U+0000-00FF, U+2000-206F, U+2212; }
@font-face { font-family: "NW Brand"; src: url(/assets/fonts/nw-brand.woff2) format("woff2"); font-weight: 500 600; font-display: swap; }

/* ---------- Themes ---------- */
:root, [data-theme="dark"] {
  --bg: #05061A; --ink: #F5FAF6; --ink-2: rgba(236, 241, 239, .72); --ink-3: rgba(236, 241, 239, .48);
  --line: rgba(236, 241, 239, .12); --glass: rgba(255, 255, 255, .06); --field: rgba(255, 255, 255, .07); --field-focus: rgba(255, 255, 255, .1);
  --inv-bg: #F5FAF6; --inv-fg: #0D0F2E; --accent: #7FE6C9; --accent-ink: #0D0F2E; --link: #7FE6C9;
  --aurora-opacity: .55; --card-shadow: none;
  --pill-new-bg: rgba(90, 84, 245, .3); --pill-new: #CFCBFF; --pill-work-bg: rgba(255, 200, 107, .2); --pill-work: #FFC86B;
  --pill-done-bg: rgba(127, 230, 201, .18); --pill-done: #7FE6C9; --pill-spam-bg: rgba(255, 255, 255, .1); --pill-spam: rgba(236, 241, 239, .5);
  --error: #FFB4A3;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #F1F3F8; --ink: #14163A; --ink-2: #4B4E70; --ink-3: #7A7D99;
  --line: rgba(20, 22, 58, .12); --glass: #fff; --field: #fff; --field-focus: #fff;
  --inv-bg: #14163A; --inv-fg: #F5FAF6; --accent: #4A44F0; --accent-ink: #fff; --link: #4A44F0;
  --aurora-opacity: .22; --card-shadow: 0 1px 2px rgba(20, 22, 58, .06);
  --pill-new-bg: rgba(74, 68, 240, .12); --pill-new: #4A44F0; --pill-work-bg: rgba(229, 160, 40, .16); --pill-work: #8A5A00;
  --pill-done-bg: rgba(47, 211, 164, .18); --pill-done: #11644C; --pill-spam-bg: rgba(20, 22, 58, .07); --pill-spam: #7A7D99;
  --error: #B23A27;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 400 16px/1.5 "NW Text", -apple-system, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased;
  min-height: var(--tg-viewport-stable-height, 100vh); position: relative; overflow-x: hidden; }
.shell { position: relative; z-index: 1; max-width: 600px; margin: 0 auto; padding: 0 16px calc(28px + env(safe-area-inset-bottom)); }
.aurora { position: fixed; inset: -20% -30% auto; height: 70vh; pointer-events: none; z-index: 0; filter: blur(40px); opacity: var(--aurora-opacity);
  background: radial-gradient(40% 50% at 20% 40%, rgba(90, 84, 245, .7), transparent 70%),
              radial-gradient(35% 45% at 70% 30%, rgba(47, 227, 176, .45), transparent 70%),
              radial-gradient(30% 40% at 90% 60%, rgba(255, 138, 112, .4), transparent 70%); }
a { color: var(--link); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
button { font-family: inherit; }

.top { display: flex; align-items: center; gap: 12px; padding: 18px 0 14px; }
.mark { width: 54px; height: 29px; flex: none; }
.top__text { flex: 1; }
.brand { margin: 0; font: 600 19px/1 "NW Brand", sans-serif; letter-spacing: -.01em; }
.tagline { margin: 5px 0 0; font: 500 11px/1 "NW Brand", sans-serif; letter-spacing: .08em; color: var(--link); }
.theme-btn, .icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--glass); box-shadow: inset 0 0 0 1px var(--line); display: grid; place-items: center; cursor: pointer; flex: none; }
.theme-btn svg, .icon-btn svg { width: 19px; height: 19px; fill: none; stroke: var(--ink-2); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.i-sun { display: none; }
[data-theme="dark"] .i-sun { display: inline; }
[data-theme="dark"] .i-moon { display: none; }

.tabs { display: flex; gap: 4px; padding: 4px; margin: 4px 0 18px; border-radius: 999px; background: var(--glass); box-shadow: inset 0 0 0 1px var(--line); }
.tabs button { flex: 1; border: 0; border-radius: 999px; padding: 10px 8px; background: transparent; color: var(--ink-2); font-family: inherit; font-weight: 500; font-size: 14px; line-height: 1; cursor: pointer; }
.tabs button[aria-pressed="true"] { background: var(--inv-bg); color: var(--inv-fg); }
.count { opacity: .7; }

h1 { margin: 10px 0 8px; font: 300 28px/1.1 "NW Display", sans-serif; letter-spacing: -.02em; }
.lead { margin: 0 0 18px; color: var(--ink-2); }
.group-label { margin: 6px 0 8px; font-size: 14px; color: var(--ink-2); }

.seg { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--glass); box-shadow: inset 0 0 0 1px var(--line); margin: 0 0 16px; }
.seg button { flex: 1; border: 0; border-radius: 999px; padding: 11px 10px; background: transparent; color: var(--ink-2); font-family: inherit; font-weight: 500; font-size: 15px; line-height: 1; cursor: pointer; }
.seg button[aria-checked="true"] { background: var(--inv-bg); color: var(--inv-fg); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.chips button { border: 0; border-radius: 999px; padding: 9px 14px; background: var(--glass); color: var(--ink); font-family: inherit; font-weight: 400; font-size: 14px; line-height: 1.2; cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--line), var(--card-shadow); transition: background-color .2s, color .2s; }
.chips button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); box-shadow: none; font-weight: 500; }
.chips--small button { padding: 8px 13px; font-size: 13px; }

form { display: grid; gap: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 7px; align-content: start; }
.field > span, .field > label { font-size: 14px; color: var(--ink-2); }
.field em { font-style: normal; color: var(--ink-3); margin-left: 4px; }
input, textarea { width: 100%; font-family: inherit; font-weight: 400; font-size: 16px; line-height: 1.4; color: var(--ink); background: var(--field);
  border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; -webkit-appearance: none; box-shadow: var(--card-shadow); }
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:focus, textarea:focus { outline: none; border-color: var(--accent); background: var(--field-focus); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: #FF8A70; }
textarea { resize: vertical; min-height: 120px; }
.with-btn { display: flex; gap: 8px; }
.ghost { flex: none; border: 1px solid var(--line); background: transparent; color: var(--link); border-radius: 14px; padding: 0 14px; font-family: inherit; font-weight: 500; font-size: 14px; line-height: 1; cursor: pointer; }
.error { margin: 0; color: var(--error); font-size: 14px; }
.submit { display: flex; align-items: center; justify-content: center; width: 100%; height: 52px; border: 0; border-radius: 16px; margin-top: 6px;
  background: var(--accent); color: var(--accent-ink); font-family: inherit; font-weight: 600; font-size: 16px; line-height: 1; text-decoration: none; cursor: pointer; }
.tg .submit#submit-inline { display: none; }

.done { text-align: center; padding-top: 30px; }
.done__icon { width: 84px; height: 84px; margin: 0 auto 12px; border-radius: 50%; display: grid; place-items: center; color: #0D0F2E; background: linear-gradient(135deg, #7FE6C9, #B7AEFF); }
.done__icon svg { width: 46px; height: 46px; }

/* inbox */
.inbox-head { display: flex; gap: 8px; align-items: center; margin: 0 0 14px; }
.filters { display: flex; gap: 6px; overflow-x: auto; flex: 1; padding-bottom: 2px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters button, .periods button { flex: none; border: 0; border-radius: 999px; padding: 8px 13px; background: var(--glass); color: var(--ink-2); font-family: inherit; font-weight: 500; font-size: 13px; line-height: 1; box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; }
.filters button span { opacity: .65; margin-left: 2px; }
.filters button[aria-pressed="true"], .periods button[aria-pressed="true"] { background: var(--inv-bg); color: var(--inv-fg); box-shadow: none; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.card { min-width: 0; overflow-wrap: anywhere; background: var(--glass); border-radius: 18px; padding: 14px 16px; box-shadow: inset 0 0 0 1px var(--line), var(--card-shadow); }
.card__head { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--ink-3); }
.card__kind { margin: 8px 0 0; font-size: 13px; color: var(--link); font-weight: 500; }
.card__name { margin: 4px 0 0; font-weight: 600; }
.card__meta { margin: 2px 0 0; color: var(--ink-2); font-size: 14px; }
.card__task { margin: 10px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; max-height: 4.5em; overflow: hidden; }
.card[open-card] .card__task { max-height: none; }
.card__more { border: 0; background: none; color: var(--link); padding: 6px 0 0; font-family: inherit; font-weight: 500; font-size: 13px; line-height: 1; cursor: pointer; }
.contacts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.contacts a, .contacts button { max-width: 100%; text-align: left; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; border: 0; border-radius: 10px; padding: 8px 11px; font-family: inherit; font-weight: 500; font-size: 13px; line-height: 1.25;
  background: var(--field); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; }
.card__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.card__actions button { border: 0; border-radius: 12px; padding: 9px 13px; font-family: inherit; font-weight: 500; font-size: 13px; line-height: 1; background: var(--field); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; }
.card__actions button.primary { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill--new { background: var(--pill-new-bg); color: var(--pill-new); }
.pill--in_work { background: var(--pill-work-bg); color: var(--pill-work); }
.pill--done { background: var(--pill-done-bg); color: var(--pill-done); }
.pill--spam { background: var(--pill-spam-bg); color: var(--pill-spam); }
.empty { color: var(--ink-3); text-align: center; padding: 30px 0; }

/* clients */
.seg--small button[aria-pressed="true"] { background: var(--inv-bg); color: var(--inv-fg); }
.search { margin: 0 0 12px; }
.client__leads { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* stats */
.periods { display: flex; gap: 6px; margin: 0 0 14px; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--glass); border-radius: 16px; padding: 12px 14px; box-shadow: inset 0 0 0 1px var(--line), var(--card-shadow); }
.kpi__value { font: 300 26px/1.1 "NW Display", sans-serif; }
.kpi__label { margin-top: 4px; font-size: 13px; color: var(--ink-2); }
.chart-card { background: var(--glass); border-radius: 18px; padding: 14px 14px 10px; box-shadow: inset 0 0 0 1px var(--line), var(--card-shadow); margin-bottom: 12px; }
.chart-card__title { margin: 0 0 8px; font-size: 13px; color: var(--ink-2); }
#chart svg { display: block; width: 100%; height: 160px; }
.ticks { display: flex; justify-content: space-between; gap: 4px; margin-top: 4px; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.legend { margin: 6px 0 0; font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot--site { background: #7FE6C9; }
.dot--bot { background: #8E88FF; margin-left: 10px; }
.lists { display: grid; gap: 10px; margin-bottom: 12px; }
.list { background: var(--glass); border-radius: 16px; padding: 12px 14px; box-shadow: inset 0 0 0 1px var(--line), var(--card-shadow); }
.list__title { margin: 0 0 6px; font-size: 13px; color: var(--ink-2); }
.list__row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.list__row:first-of-type { border-top: 0; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }

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