/* ИНТЕРНЕТ10000 · CRM 10k */
:root {
  --bg: #0d0e10;
  --surface: #15171a;
  --surface-2: #1c1f23;
  --surface-3: #22262b;
  --hairline: rgba(255,255,255,0.06);
  --hairline-2: rgba(255,255,255,0.10);
  --divider: rgba(255,255,255,0.04);

  --fg: #ecedef;
  --fg-2: #9da3ac;
  --fg-3: #6b7280;
  --fg-4: #4a4f57;

  --brand: #b5191f;
  --brand-hi: #e03a45;
  --brand-lo: #861216;
  --brand-bg: rgba(181,25,31,0.14);

  --st-new:    #4a90e2;
  --st-work:   #e2a23c;
  --st-wait:   #9c7ae0;
  --st-deny:   #d34d4d;
  --st-call:   #5dbe7b;
  --st-write:  #4fb8b0;
  --st-ignore: #6b7280;

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;
  --r-xl: 20px;

  --shadow-pop: 0 12px 32px rgba(0,0,0,0.45), 0 0 0 1px rgba(255,255,255,0.04);

  --font-brand: "Barlow Condensed", "Avenir Next Condensed", "Helvetica Neue", system-ui, sans-serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", system-ui, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, monospace;

  --safe-top:    env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; background: var(--bg); color: var(--fg); }
body { font-family: var(--font-ui); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--brand); color: #fff; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; }

/* ─── Layout ───────────────────────────────────────────────── */
:root { --sidebar-w: 200px; --sidebar-w-collapsed: 56px; }
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  transition: grid-template-columns .18s ease;
}
html.is-sidebar-collapsed .app { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--hairline);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 14px 10px;
  gap: 2px;
}
.sidebar .brand-row {
  display: flex; align-items: center; gap: 10px; padding: 4px 8px 10px;
  text-decoration: none;
}
.sidebar .nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: 7px;
  color: var(--fg-2); font-size: 13px; font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar .nav-item svg { flex-shrink: 0; opacity: 0.85; }
.sidebar .nav-item.active svg { opacity: 1; color: var(--brand-hi); }
.sidebar .nav-btn {
  width: 100%; border: 0; background: transparent; text-align: left; font: inherit;
}
.logo-img {
  width: 32px; height: 32px;
  border-radius: 22%;
  object-fit: cover;
  flex-shrink: 0;
}
.sidebar .nav-item:hover { background: var(--surface-2); color: var(--fg); }
.sidebar .nav-item.active { background: var(--brand-bg); color: var(--fg); }
.sidebar .nav-sub { padding-left: 28px; font-size: 12px; }
.sidebar .nav-sub svg { opacity: 0.65; }
.sidebar .nav-spacer { flex: 1; }
.sidebar .nav-section {
  font-size: 10px; font-weight: 700; color: var(--fg-4);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 10px 10px 4px;
}
.sidebar-toggle {
  background: transparent; border: 1px solid var(--hairline);
  color: var(--fg-3); cursor: pointer;
  width: 28px; height: 28px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  margin: 4px auto 0;
  transition: color .12s, border-color .12s;
}
.sidebar-toggle:hover { color: var(--fg); border-color: var(--hairline-2); }
.sidebar-toggle svg { transition: transform .18s ease; }
html.is-sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }

/* Collapsed state: hide labels, keep icons */
html.is-sidebar-collapsed .sidebar { padding: 14px 6px; }
html.is-sidebar-collapsed .sidebar .nav-item span,
html.is-sidebar-collapsed .sidebar .nav-section { display: none; }
html.is-sidebar-collapsed .sidebar .nav-item {
  justify-content: center; padding: 8px 0; gap: 0;
}
html.is-sidebar-collapsed .sidebar .nav-sub { padding-left: 0; }
html.is-sidebar-collapsed .sidebar .brand-row { justify-content: center; padding: 4px 0 10px; }
.main {
  min-width: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 28px 80px;
}
/* Топбар с одним пустым grow внутри — скрываем */
.topbar:has(> .grow:only-child) { display: none; }
.topbar {
  display: flex; align-items: center; gap: 14px; margin-bottom: 14px;
  min-height: 0;
}
.topbar:empty { display: none; margin: 0; }
.topbar .btn svg { flex-shrink: 0; }
.topbar h1 { display: none; }
.entity-title {
  font-family: var(--font-ui); font-style: normal; font-weight: 900;
  font-size: 24px; letter-spacing: -0.01em;
}
.page-title {
  font-family: var(--font-ui); font-style: normal; font-weight: 600;
  font-size: 22px; letter-spacing: -0.01em;
}
.topbar .grow { flex: 1; }

/* ─── Logo ─────────────────────────────────────────────────── */
.logo10 {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand); color: #fff;
  border-radius: 10px;
  font-family: var(--font-ui); font-style: normal; font-weight: 900;
  letter-spacing: -0.04em; line-height: 1;
}
.brand-text {
  font-family: var(--font-ui); font-style: normal; font-weight: 900;
  letter-spacing: 0.005em;
}

/* ─── Inputs / buttons ─────────────────────────────────────── */
.input, .select, .textarea {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  color: var(--fg);
  padding: 10px 12px;
  border-radius: 8px;
  width: 100%;
  font: inherit;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); }
.input::placeholder { color: var(--fg-3); }
.textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  border: 1px solid var(--hairline);
  background: var(--surface-2); color: var(--fg);
  cursor: pointer; transition: background .12s, border-color .12s;
  text-decoration: none;
}
.btn:hover { background: var(--surface-3); }
.btn-primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
}
.btn-primary:hover { background: var(--brand-hi); border-color: var(--brand-hi); }
.btn-ghost { background: transparent; }
.btn-danger { border-color: rgba(211,77,77,0.3); color: #d34d4d; }
.btn-danger:hover { background: rgba(211,77,77,0.1); }
.btn-icon { width: 36px; height: 36px; padding: 0; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

label { display: block; font-size: 12px; color: var(--fg-3); margin-bottom: 6px; font-weight: 500; }

/* ─── Status / tag ─────────────────────────────────────────── */
.st-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.st-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px 3px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.01em;
  border: 1px solid var(--hairline);
  background: rgba(255,255,255,0.02);
  white-space: nowrap;
}
.st-pill .st-dot { width: 6px; height: 6px; }

.tag {
  display: inline-flex; align-items: center;
  padding: 3px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 500; color: var(--fg-2);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--hairline);
  white-space: nowrap;
}
.tag.is-on { color: var(--fg); background: rgba(255,255,255,0.06); border-color: var(--hairline-2); }

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; letter-spacing: -0.01em;
  background: var(--surface-3); color: var(--fg-2);
  border-radius: 8px; flex-shrink: 0;
  width: 40px; height: 40px; font-size: 14px;
}
.avatar.lg { width: 56px; height: 56px; font-size: 18px; border-radius: 12px; }

/* ─── Card ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
}
.card-pad { padding: 18px 20px; }
.card-head {
  padding: 14px 18px; border-bottom: 1px solid var(--hairline);
  display: flex; align-items: center; gap: 10px;
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }

/* ─── Table ────────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; max-width: 100%; border-radius: var(--r-lg); }

/* ─── Tag block (groups + chips) ──────────────────────── */
.tagblock { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

/* Active filters strip */
.tagblock-active {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 8px 10px;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--hairline);
  border-radius: 10px;
}
.tagblock-active-label {
  font-size: 11px; color: var(--fg-3); text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 700; margin-right: 4px;
}
.tag-active-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 8px 4px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  border: 1px solid transparent;
  text-decoration: none;
  transition: filter .12s;
}
.tag-active-chip:hover { filter: brightness(1.2); }
.tag-active-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.tag-active-x { font-size: 14px; line-height: 1; opacity: 0.75; margin-left: 2px; }
.tagblock-clear {
  margin-left: auto;
  font-size: 11px; color: var(--fg-3); text-decoration: underline; text-underline-offset: 2px;
}
.tagblock-clear:hover { color: var(--brand-hi); }

/* Toolbar */
.tagblock-toolbar { display: flex; gap: 10px; align-items: center; }
.tagblock-search { flex: 1; max-width: 320px; }
.tagblock-search .input { height: 32px; padding: 6px 10px; font-size: 13px; }
.tagblock-toolbar-actions { display: flex; gap: 4px; }
.btn.btn-xs { padding: 4px 8px; font-size: 11px; height: 26px; }

/* Groups grid */
.tagblock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 10px;
}
.tag-group[data-size="lg"] { grid-column: span 2; }
@media (max-width: 1200px) {
  .tagblock-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .tagblock-grid { grid-template-columns: 1fr; }
  .tag-group[data-size="lg"] { grid-column: span 1; }
}

/* Group card */
.tag-group {
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}
.tag-group[data-active="1"] { border-color: var(--g-color, var(--hairline)); }
.tag-group > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px 8px 0;
  user-select: none;
  position: relative;
}
.tag-group > summary::-webkit-details-marker { display: none; }
.tag-group-bar {
  width: 4px; align-self: stretch;
  background: var(--g-color, var(--hairline-2));
  border-radius: 0 2px 2px 0;
}
.tag-group-title {
  font-size: 13px; font-weight: 700; color: var(--fg);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.tag-group-meta { font-size: 11px; color: var(--fg-4); font-variant-numeric: tabular-nums; }
.tag-group-filter {
  margin-left: auto;
  font-size: 11px; padding: 3px 8px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--fg-3);
  text-decoration: none;
  transition: all .12s;
}
.tag-group-filter:hover { color: var(--fg); border-color: var(--g-color, var(--hairline-2)); }
.tag-group-filter.is-active {
  background: var(--g-color); color: #fff; border-color: var(--g-color);
}
.tag-group-chev {
  font-size: 12px; color: var(--fg-3);
  transition: transform .15s;
  padding-right: 4px;
}
.tag-group:not([open]) .tag-group-chev { transform: rotate(-90deg); }

.tag-group-body {
  display: flex; flex-wrap: wrap; gap: 5px;
  padding: 4px 10px 12px 18px;
}

/* Individual chip */
.tag-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px 3px 10px;
  border-radius: 999px;
  font-size: 12px; font-weight: 500;
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  color: var(--fg-2);
  text-decoration: none;
  position: relative;
  transition: border-color .12s, background .12s, color .12s;
  white-space: nowrap;
}
.tag-chip:hover { border-color: var(--g-color, var(--hairline-2)); color: var(--fg); }
.tag-chip.is-active {
  background: var(--g-color);
  color: #fff;
  border-color: var(--g-color);
  font-weight: 600;
}
.tag-chip.is-active .tag-chip-cnt { background: rgba(255,255,255,0.22); color: #fff; }
.tag-chip-cnt {
  font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: 999px;
  background: rgba(255,255,255,0.04);
  color: var(--fg-4);
  font-variant-numeric: tabular-nums;
}

.tagblock-empty {
  padding: 14px; text-align: center; color: var(--fg-4); font-size: 13px;
  border: 1px dashed var(--hairline); border-radius: 8px;
}

@media (max-width: 720px) {
  .tagblock-toolbar { flex-wrap: wrap; }
  .tagblock-search { max-width: 100%; }
  .tag-group-meta { display: none; }
}
.card:has(> .tbl-wrap) { overflow: clip; }
.tbl {
  width: 100%; border-collapse: collapse;
}
.tbl th, .tbl td { padding: 10px 14px; text-align: left; vertical-align: middle; }
.tbl th {
  font-size: 11px; color: var(--fg-3); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface-2);
  white-space: nowrap;
}
.tbl td.col-created { white-space: nowrap; }
.tbl .col-tags { max-width: 320px; }
.tbl .col-tags .tags-inline { max-width: 100%; }
.tbl th.th-sort { cursor: pointer; user-select: none; transition: color .12s; }
.tbl th.th-sort:hover { color: var(--fg); }
.tbl th.th-sort.is-active { color: var(--fg); }
.tbl tbody tr { border-bottom: 1px solid var(--divider); transition: background .12s; }
.tbl tbody tr:hover { background: rgba(255,255,255,0.025); cursor: pointer; }
.tbl tbody tr:last-child { border-bottom: none; }
.tbl .cell-empty { color: var(--fg-4); }

/* ─── Filters bar ──────────────────────────────────────────── */
.filters {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin-bottom: 16px;
}
.filters .input { width: auto; flex: 0 0 280px; max-width: 100%; }

/* ─── Page header (контакты/заказчики) ────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 14px; flex-wrap: wrap;
}
.page-header-title { display: flex; align-items: baseline; gap: 12px; }
.page-header-title h1 {
  margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.01em;
  font-family: var(--font-ui);
}
.page-header-count {
  font-size: 12px; font-weight: 600; color: var(--fg-3);
  padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--hairline);
  font-variant-numeric: tabular-nums;
}
.page-header-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.page-header-actions .btn-icon { width: 34px; height: 34px; }
.page-header-actions .btn-primary { padding: 8px 14px; font-weight: 600; }

.dropdown-section {
  font-size: 10px; font-weight: 700; color: var(--fg-4);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 8px 12px 4px;
}
.dropdown-item-row { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 10px 10px; }
.dropdown-pill {
  font-size: 12px; padding: 4px 10px;
  border-radius: 999px; border: 1px solid var(--hairline);
  color: var(--fg-2); text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.dropdown-pill:hover { border-color: var(--hairline-2); color: var(--fg); }
.dropdown-pill.is-active { background: var(--brand-bg); color: var(--fg); border-color: var(--brand); }

/* ─── Filter bar (sticky) ────────────────────────────── */
.filter-bar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin-bottom: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: blur(8px);
}
.filter-bar .input { flex: 1 1 220px; min-width: 220px; max-width: 360px; }
.filter-bar .select { flex: 0 0 auto; }
.filter-reset {
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: auto;
  padding: 6px 10px;
  font-size: 12px; font-weight: 600;
  color: var(--fg-3); text-decoration: none;
  border-radius: 8px;
  transition: background .12s, color .12s;
}
.filter-reset:hover { background: var(--surface-2); color: #d34d4d; }

/* ─── Quickfilters (status counts + dups) ─────────────── */
.quickfilters {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-bottom: 12px;
}
.qf-chip {
  --qf-color: var(--fg-3);
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--fg-2);
  font-size: 12px; font-weight: 500;
  text-decoration: none;
  transition: border-color .12s, background .12s, color .12s;
}
.qf-chip:hover { border-color: var(--qf-color); color: var(--fg); }
.qf-chip.is-active {
  background: color-mix(in srgb, var(--qf-color) 18%, transparent);
  border-color: var(--qf-color);
  color: var(--fg);
}
.qf-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--qf-color); }
.qf-cnt {
  font-size: 11px; font-weight: 600;
  color: var(--fg-4);
  padding-left: 4px;
  font-variant-numeric: tabular-nums;
}
.qf-chip.is-active .qf-cnt { color: var(--fg-2); }
.qf-sep {
  display: inline-block; width: 1px; height: 18px;
  background: var(--hairline); margin: 0 6px;
}
.qf-dup { --qf-color: #6b7280; }
.qf-dup.is-active { --qf-color: var(--brand); }
.qf-dup svg { opacity: 0.7; }

/* ─── Tagblock search icon ────────────────────────────── */
.tagblock-search { position: relative; }
.tagblock-search-icon {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  color: var(--fg-4); pointer-events: none; line-height: 0;
}
.tagblock-search .input { padding-left: 30px; }
.btn.btn-icon.btn-xs {
  width: 28px; height: 28px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px;
}

@media (max-width: 720px) {
  .filter-bar { position: relative; padding: 8px; }
  .page-header-title h1 { font-size: 18px; }
  .page-header-actions .btn-primary { padding: 7px 11px; font-size: 12px; }
}
.chip {
  padding: 6px 12px; font-size: 12px; font-weight: 500;
  border-radius: 999px; border: 1px solid var(--hairline);
  background: var(--surface-2); color: var(--fg-2); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { background: var(--surface-3); color: var(--fg); }
.chip.active { background: var(--brand-bg); color: var(--fg); border-color: rgba(181,25,31,0.4); }

/* ─── Detail layout ────────────────────────────────────────── */
.detail-grid {
  display: grid; grid-template-columns: 1fr 360px; gap: 24px;
}
.detail-grid > .col-main { min-width: 0; }

.kv {
  display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px;
  font-size: 14px;
}
.kv > dt { color: var(--fg-3); font-size: 12px; padding-top: 2px; }
.kv > dd { margin: 0; word-break: break-word; }

/* ─── Comment timeline ─────────────────────────────────────── */
.comment {
  padding: 14px 16px; border-bottom: 1px solid var(--divider);
}
.comment:last-child { border-bottom: none; }
.comment-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.comment-head .who { font-weight: 600; font-size: 13px; }
.comment-head .when { color: var(--fg-3); font-size: 12px; }
.comment-body { font-size: 14px; line-height: 1.5; color: var(--fg); white-space: pre-wrap; }
.comment-actions { margin-top: 6px; display: flex; gap: 8px; }
.comment-actions a, .comment-actions button {
  font-size: 11px; color: var(--fg-3); background: transparent; border: 0; padding: 0; cursor: pointer;
}
.comment-actions button:hover, .comment-actions a:hover { color: var(--fg); }

/* ─── Flash messages ───────────────────────────────────────── */
.flash {
  position: fixed; top: 16px; right: 16px; z-index: 1000;
  display: flex; flex-direction: column; gap: 8px;
}
.flash > div {
  padding: 10px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--hairline-2); background: var(--surface);
  box-shadow: var(--shadow-pop);
  animation: slideIn .2s ease-out;
}
.flash > .ok    { border-left: 3px solid #5dbe7b; }
.flash > .error { border-left: 3px solid #d34d4d; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ─── Mobile bottom tabs — pro UI ───────────────────────── */
.mtab {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
  padding-bottom: var(--safe-bottom);
  background: rgba(13,14,16,0.82);
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  border-top: 1px solid var(--hairline);
}
.mtab-inner {
  display: flex; padding: 6px 2px 4px;
}
.mtab a {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 4px 2px 4px;
  gap: 2px;
  color: var(--fg-3); font-size: 9px; font-weight: 500;
  text-decoration: none;
  border-radius: 12px;
  transition: color .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.mtab a:active { transform: scale(0.92); }
.mtab-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 10px;
  transition: background .18s ease, color .18s ease, transform .25s cubic-bezier(.34,1.56,.64,1);
}
.mtab a svg { opacity: 0.7; transition: opacity .15s; }
.mtab-lbl {
  line-height: 1;
  transition: opacity .15s;
}
.mtab a.active { color: var(--fg); }
.mtab a.active .mtab-ico {
  background: var(--brand-bg);
  color: var(--brand-hi);
  transform: translateY(-2px);
}
.mtab a.active svg { opacity: 1; color: var(--brand-hi); }
.mtab a.active::before {
  content: '';
  position: absolute;
  top: -1px; left: 50%; transform: translateX(-50%);
  width: 28px; height: 3px;
  background: var(--brand);
  border-radius: 0 0 3px 3px;
}
.mtab a { position: relative; }

/* ─── Auth screen ──────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 20px;
}
.auth-card {
  width: 100%; max-width: 380px;
  padding: 28px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  position: relative; overflow: hidden;
}
.auth-card::before {
  content: ''; position: absolute; top: -80px; right: -80px; width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(181,25,31,0.35) 0%, transparent 65%);
}
.auth-card form { position: relative; display: flex; flex-direction: column; gap: 14px; }

/* ─── Modal ────────────────────────────────────────────────── */
.modal-back {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.65);
  display: grid; place-items: center;
  padding: 20px;
}
.modal {
  width: 100%; max-width: 480px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-xl); box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.modal .modal-head {
  padding: 18px 20px; border-bottom: 1px solid var(--hairline);
  display: flex; align-items: center; gap: 10px;
}
.modal .modal-body { padding: 18px 20px; }
.modal .modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--hairline);
  display: flex; gap: 8px; justify-content: flex-end;
}

/* ─── Breakpoint ───────────────────────────────────────────── */
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 90px; }
  .topbar h1 { font-size: 24px; }
  .detail-grid { grid-template-columns: 1fr; }
  .mtab { display: block; }
  .filters .input { flex: 1 1 100%; }
  .kv { grid-template-columns: 110px 1fr; gap: 8px 12px; font-size: 13px; }
  .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl th, .tbl td { padding: 10px 10px; }
  .modal { max-width: 100%; border-radius: 16px 16px 0 0; align-self: end; }
  .modal-back { align-items: end; padding: 0; }

  /* Топбар: компактные кнопки и обёртка */
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .topbar .btn { padding: 7px 10px; font-size: 12px; white-space: nowrap; }
  .topbar .btn svg { width: 13px; height: 13px; }
  .filters { flex-direction: column; align-items: stretch; gap: 6px; }
  .filters .input, .filters .select { flex: 1 1 100%; width: 100%; }

  /* Таблицы → карточки */
  .tbl, .tbl tbody { display: block; }
  .tbl thead { display: none; }
  .tbl tr {
    display: grid;
    grid-template-columns: auto 1fr auto;
    column-gap: 10px; row-gap: 4px;
    padding: 12px 14px;
    border: 1px solid var(--hairline);
    border-radius: 10px;
    margin-bottom: 8px;
    background: var(--surface);
    align-items: center;
  }
  .tbl tr:hover { background: var(--surface-2); }
  .tbl td {
    display: block;
    padding: 0 !important;
    border: none !important;
  }
  .tbl td[style*="display:none"] { display: none !important; }

  /* Расположение колонок в карточке */
  .tbl .col-check { grid-row: 1 / span 3; align-self: start; padding-top: 4px !important; padding-left: 0 !important; }
  .tbl .col-company,
  .tbl .col-name { grid-column: 2; font-weight: 600; }
  .tbl .col-status { grid-column: 3; grid-row: 1; justify-self: end; }
  .tbl .col-city { grid-column: 2; font-size: 12px; color: var(--fg-3); }
  .tbl .col-channel,
  .tbl .col-phone { grid-column: 2 / span 2; font-size: 12px; }
  .tbl .col-website { grid-column: 2 / span 2; max-width: 100%; font-size: 12px; }
  .tbl .col-tags { grid-column: 2 / span 2; }
  .tbl .col-source,
  .tbl .col-companies,
  .tbl .col-contact,
  .tbl .col-created { display: none; }
}

/* ─── Helpers ──────────────────────────────────────────────── */
.row { display: flex; align-items: center; gap: 10px; }
.row.gap-sm { gap: 6px; }
.row.gap-lg { gap: 16px; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; }
.muted { color: var(--fg-3); }
.dim   { color: var(--fg-4); }
.small { font-size: 12px; }
.tiny  { font-size: 11px; }
.h-tight { letter-spacing: -0.01em; }
.divider { height: 1px; background: var(--divider); margin: 14px 0; }
.empty-state {
  padding: 36px 20px; text-align: center; color: var(--fg-3);
}
.spacer { flex: 1; }
.grid-stat {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r);
  padding: 14px 16px;
}
.stat-card .v { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.stat-card .l { font-size: 12px; color: var(--fg-3); margin-top: 2px; }

/* ─── Dropdown (column toggle и пр.) ───────────────────────── */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 200px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r); box-shadow: var(--shadow-pop);
  padding: 6px;
  z-index: 50;
}
.dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px;
  font-size: 13px; cursor: pointer; color: var(--fg);
}
.dropdown-item:hover { background: var(--surface-2); }
.dropdown-item input[type=checkbox] { margin: 0; cursor: pointer; }
[x-cloak] { display: none !important; }

/* ─── Bulk action bar ──────────────────────────────────────── */
.bulk-bar {
  position: sticky; top: 0; z-index: 10;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--brand-bg);
  border: 1px solid rgba(181,25,31,0.35);
  border-radius: var(--r);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.bulk-bar .bulk-sel { width: auto; min-width: 150px; }

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }
.htmx-request.htmx-indicator { display: inline; }

/* Skeleton loading на htmx-request */
.results-busy { position: relative; }
.results-busy.htmx-request > * { opacity: 0.35; pointer-events: none; transition: opacity .15s; }
.results-busy.htmx-request::after {
  content: '';
  position: absolute; inset: 0;
  background-image: linear-gradient(
    var(--surface-2) 14px, transparent 14px, transparent 24px,
    var(--surface-2) 24px, var(--surface-2) 38px, transparent 38px, transparent 48px,
    var(--surface-2) 48px, var(--surface-2) 62px, transparent 62px, transparent 72px,
    var(--surface-2) 72px, var(--surface-2) 86px, transparent 86px
  );
  background-size: 100% 96px;
  background-repeat: repeat-y;
  background-position: 0 48px;
  border-radius: var(--r);
  pointer-events: none;
  animation: skel-pulse 1.2s ease-in-out infinite;
}
@keyframes skel-pulse { 0%,100% { opacity: 0.55; } 50% { opacity: 0.9; } }
.bulk-sep {
  width: 1px; height: 22px; background: var(--hairline-2);
}

/* Bulk checkbox column */
.col-check { width: 36px; padding-left: 12px !important; padding-right: 0 !important; }
.col-check input[type=checkbox] { margin: 0; cursor: pointer; }

/* Сайт-колонка: обрезаем длинные URL */
.tbl td.col-website,
.tbl th.col-website { max-width: 220px; overflow: hidden; }
.tbl td.col-website a {
  display: inline-block; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  vertical-align: middle;
}

/* ─── Kanban ───────────────────────────────────────────────── */
.kanban {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}
.kanban-col {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  display: flex; flex-direction: column;
  min-height: 200px;
  overflow: hidden;
}
.kanban-col-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--hairline);
  font-size: 12px; font-weight: 700;
  color: var(--fg-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
}
.kanban-col-head .count {
  margin-left: auto;
  font-size: 11px;
  color: var(--fg-2);
  background: var(--surface-3);
  padding: 2px 9px;
  border-radius: 999px;
  text-transform: none; letter-spacing: 0;
  font-weight: 600;
}
.kanban-body { display: flex; flex-direction: column; }
.kanban-card {
  padding: 12px 14px;
  border-bottom: 1px solid var(--divider);
}
.kanban-card:last-child { border-bottom: none; }
.kanban-card:hover { background: rgba(255,255,255,0.02); }
.kanban-card { cursor: grab; }
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: 0.4; }
.kanban-col.drag-over { background: var(--brand-bg); transition: background .12s; }
.kanban-col.drag-over .kanban-body { min-height: 60px; }
@media (max-width: 880px) {
  .kanban { grid-template-columns: 1fr; }
}

/* ─── Cmd+K палитра ─────────────────────────────────────── */
.cmdk-modal { max-width: 600px; }
.cmdk-input {
  border: 0; background: transparent;
  padding: 16px 20px;
  font-size: 16px;
  border-radius: 0;
  border-bottom: 1px solid var(--hairline);
}
.cmdk-input:focus { border-color: var(--brand); }
.cmdk-group {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--fg-3);
  padding: 10px 14px 4px;
}
.cmdk-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-radius: 8px;
  text-decoration: none; color: var(--fg);
  font-size: 13px;
  cursor: pointer;
}
.cmdk-item.is-active { background: var(--brand-bg); }
.cmdk-item:hover { background: var(--surface-2); }
.cmdk-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-sub { color: var(--fg-3); font-size: 11px; flex-shrink: 0; }

/* ─── Туду — pro UI/UX ──────────────────────────────────── */
.todo-page { display: flex; flex-direction: column; gap: 10px; }

.todo-topbar {
  align-items: center;
  margin-bottom: 8px;
  gap: 12px;
}
.todo-counter {
  font-size: 12px; color: var(--fg-3);
  padding: 4px 10px; background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  white-space: nowrap;
}

.todo-filters {
  display: flex; gap: 4px; flex-wrap: wrap;
  margin-bottom: 4px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px solid var(--hairline);
  width: fit-content;
}
.todo-filters button {
  background: transparent; border: 0;
  padding: 6px 12px; border-radius: 6px;
  color: var(--fg-2); font-size: 12px; font-weight: 500;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s, color .12s;
}
.todo-filters button:hover { color: var(--fg); background: var(--surface-3); }
.todo-filters button.is-active {
  background: var(--surface);
  color: var(--fg);
  box-shadow: 0 1px 2px rgba(0,0,0,0.4), inset 0 0 0 1px var(--hairline-2);
}
.todo-filter-cnt {
  font-size: 10px; color: var(--fg-3);
  background: var(--surface-3); padding: 1px 7px;
  border-radius: 999px; min-width: 18px; text-align: center;
}
.todo-filters button.is-active .todo-filter-cnt { background: var(--brand-bg); color: var(--brand-hi); }

.todo-card {
  padding: 14px 16px 18px;
  display: flex; flex-direction: column; gap: 14px;
}

.todo-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
}

.todo-item {
  display: grid;
  grid-template-columns: 22px 24px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  transition: background .15s, border-color .15s, box-shadow .15s, transform .2s;
  position: relative;
}
.todo-item:hover {
  border-color: var(--hairline-2);
  background: var(--surface-2);
}
.todo-item.is-new {
  animation: todoFadeIn 0.4s ease-out;
}
@keyframes todoFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}
.todo-item.dragging { opacity: 0.4; transform: scale(0.98); }
.todo-item.drag-over::before {
  content: ''; position: absolute; left: 0; right: 0; top: -3px;
  height: 2px; background: var(--brand-hi); border-radius: 2px;
}

.todo-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 0; border-top: 1px solid var(--hairline);
  border-radius: 0;
  padding: 18px 8px 8px 0;
  margin-top: 6px;
}
.todo-divider:first-child { border-top: 0; padding-top: 4px; margin-top: 0; }
.todo-divider:hover { background: transparent; border-color: var(--hairline); }
.todo-divider .todo-grip,
.todo-divider .todo-divider-icon { display: none; }
.todo-divider .todo-body { flex: 1; min-width: 0; }
.todo-divider .todo-actions { margin-left: auto; }
.todo-divider .todo-title {
  font-family: var(--font-ui);
  font-style: normal;
  font-weight: 900;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--fg);
  text-transform: uppercase;
}

.todo-grip {
  cursor: grab;
  color: var(--fg-4);
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity .15s, color .15s, background .15s;
}
.todo-item:hover .todo-grip { opacity: 1; }
.todo-grip:hover { color: var(--fg-2); background: var(--surface-3); }
.todo-grip:active { cursor: grabbing; }

.todo-check {
  width: 24px; height: 24px;
  border: 1.5px solid var(--hairline-2);
  border-radius: 50%;
  background: transparent; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  padding: 0;
  transition: all .15s;
}
.todo-check:hover { border-color: var(--brand); transform: scale(1.08); }
.todo-check.is-checked {
  background: var(--brand);
  border-color: var(--brand);
  animation: todoCheckPop 0.25s ease-out;
}
@keyframes todoCheckPop {
  0% { transform: scale(0.85); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.todo-divider-icon {
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--brand-hi);
  flex-shrink: 0;
}

.todo-body { min-width: 0; }
.todo-text {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.todo-title {
  font-size: 14px;
  word-break: break-word;
  line-height: 1.4;
}
.todo-item.is-done .todo-title {
  text-decoration: line-through;
  color: var(--fg-3);
}

.todo-due {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px;
  font-weight: 500;
  color: var(--fg-3);
  padding: 3px 9px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  white-space: nowrap;
}
.todo-due.is-today {
  color: #e2a23c; background: rgba(226,162,60,0.12); border-color: rgba(226,162,60,0.35);
}
.todo-due.is-overdue {
  color: #d34d4d; background: rgba(211,77,77,0.12); border-color: rgba(211,77,77,0.4);
}
.todo-item.is-overdue { border-left: 3px solid rgba(211,77,77,0.6); padding-left: 9px; }

.todo-edit {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap; width: 100%;
}
.todo-edit .input { flex: 1; min-width: 180px; }
.todo-edit-due { width: auto !important; min-width: 180px; }

.todo-actions {
  display: flex; gap: 2px;
  opacity: 0;
  transition: opacity .15s;
}
.todo-item:hover .todo-actions,
.todo-item:focus-within .todo-actions {
  opacity: 1;
}
.todo-act {
  width: 30px; height: 30px;
  padding: 0 !important;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--fg-3);
}
.todo-act:hover { color: var(--fg); }

/* ── Empty state ── */
.todo-empty {
  text-align: center;
  padding: 36px 20px 24px;
  color: var(--fg-3);
}
.todo-empty-icon {
  display: inline-flex;
  width: 76px; height: 76px;
  border-radius: 18px;
  background: var(--surface-2);
  align-items: center; justify-content: center;
  color: var(--fg-4);
  margin-bottom: 14px;
}
.todo-empty h3 {
  margin: 0 0 6px;
  font-size: 16px; font-weight: 600;
  color: var(--fg);
}
.todo-empty p { margin: 0; max-width: 360px; margin-inline: auto; }

/* ── Add row ── */
.todo-add {
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
  display: flex; flex-direction: column; gap: 10px;
}
.todo-add-toggle {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 3px;
  width: fit-content;
  gap: 2px;
}
.todo-add-toggle button {
  background: transparent; border: 0;
  padding: 6px 14px; border-radius: 6px;
  color: var(--fg-2); font-size: 12px; font-weight: 500;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s, color .12s;
}
.todo-add-toggle button:hover { color: var(--fg); }
.todo-add-toggle button.is-active {
  background: var(--surface);
  color: var(--fg);
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.todo-add-row {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.todo-add-input { flex: 1 1 280px; min-width: 200px; }
.todo-add-row .btn { flex-shrink: 0; }
.todo-add-hint { padding-left: 4px; }

/* Due-wrap: иконка часы + label-text + скрытый datetime-local поверх */
.todo-add-due-wrap {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 0 12px;
  height: 38px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  cursor: pointer;
  flex: 0 0 auto;
  min-width: 160px;
  font-size: 13px;
  color: var(--fg-3);
  transition: border-color .12s, color .12s;
}
.todo-add-due-wrap:hover { border-color: var(--hairline-2); color: var(--fg-2); }
.todo-add-due-wrap:focus-within { border-color: var(--brand); }
.todo-add-due-ic { display: inline-flex; color: var(--fg-3); flex-shrink: 0; }
.todo-add-due-label { white-space: nowrap; user-select: none; }
.todo-add-due-label.is-set { color: var(--fg); font-weight: 500; }
.todo-add-due-input {
  position: absolute; inset: 0;
  opacity: 0;
  width: 100%; height: 100%;
  border: 0; padding: 0; margin: 0;
  background: transparent; cursor: pointer;
  color: transparent;
  font-size: 0;
}
.todo-add-due-input::-webkit-calendar-picker-indicator {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}

/* ── Mobile ── */
@media (max-width: 880px) {
  .todo-topbar { flex-wrap: wrap; }
  .todo-filters {
    width: 100%; overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .todo-filters::-webkit-scrollbar { display: none; }
  .todo-filters button { white-space: nowrap; flex-shrink: 0; }
  .todo-card { padding: 10px 10px 14px; }
  .todo-item {
    grid-template-columns: 24px 1fr auto;
    gap: 8px;
    padding: 12px 10px;
  }
  .todo-grip { display: none; }  /* mobile: длинный тап = drag, иконка не нужна */
  .todo-actions { opacity: 1; }
  .todo-act { width: 32px; height: 32px; }
  .todo-divider { padding: 14px 10px 6px; }
  .todo-divider .todo-title { font-size: 16px; }
  .todo-add-row { flex-direction: column; align-items: stretch; }
  .todo-add-input { flex: 1 1 100%; width: 100%; }
  .todo-add-due-wrap { width: 100%; min-width: 0; justify-content: flex-start; }
  .todo-add-row .btn { width: 100%; justify-content: center; }
  .todo-add-label { display: inline; }
}

/* Icon picker для строк "Сделано" */
.icon-picker {
  position: absolute;
  top: 100%; right: 0;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  box-shadow: var(--shadow-pop);
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(6, 32px);
  gap: 4px;
  z-index: 50;
}
.icon-picker-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--hairline);
  border-radius: 6px;
  color: var(--fg-2);
  cursor: pointer;
  padding: 0;
}
.icon-picker-btn:hover { background: var(--surface-2); color: var(--fg); }
.icon-picker-btn.is-active { background: var(--brand-bg); border-color: var(--brand); color: var(--fg); }
.done-row-icon { display: inline-flex; align-items: center; vertical-align: middle; }
.done-row-icon svg { display: block; }
.tbl-done td { line-height: 1.4; }

/* ─── Inline edit (tags + status) на /contacts ──────── */
.tags-inline { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.tag-inline {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 4px 2px 8px; border-radius: 4px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--hairline);
  font-size: 11px; color: var(--fg-2);
  white-space: nowrap;
}
.tag-x {
  background: transparent; border: 0;
  cursor: pointer; color: var(--fg-3);
  font-size: 14px; line-height: 1;
  padding: 0 3px;
  border-radius: 3px;
}
.tag-x:hover { color: #fff; background: #d34d4d; }
.tag-add-btn {
  background: transparent;
  border: 1px dashed var(--hairline-2);
  border-radius: 4px;
  color: var(--fg-3);
  padding: 2px 8px;
  cursor: pointer;
  font-size: 12px; font-weight: 600;
  line-height: 1.2;
}
.tag-add-btn:hover { color: var(--fg); border-color: var(--brand); border-style: solid; }

.status-inline-select {
  --st-color: var(--fg-3);
  background: transparent;
  border: 1px solid var(--hairline);
  padding: 4px 22px 4px 22px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
  color: var(--fg);
  cursor: pointer;
  max-width: 150px;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%239da3ac' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"),
                    radial-gradient(circle at 11px center, var(--st-color) 0 4px, transparent 5px);
  background-repeat: no-repeat, no-repeat;
  background-position: right 6px center, left center;
  background-size: 10px, auto;
  transition: border-color .15s, box-shadow .15s;
}
.status-inline-select:hover { border-color: var(--hairline-2); }
.status-inline-select.saved { border-color: #5dbe7b; box-shadow: 0 0 0 2px rgba(93,190,123,0.2); }

.priority-inline-select {
  --pri-color: var(--fg-4);
  background: transparent;
  border: 1px solid var(--hairline);
  padding: 4px 22px 4px 22px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
  color: var(--fg);
  cursor: pointer;
  max-width: 130px;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%239da3ac' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"),
                    radial-gradient(circle at 11px center, var(--pri-color) 0 4px, transparent 5px);
  background-repeat: no-repeat, no-repeat;
  background-position: right 6px center, left center;
  background-size: 10px, auto;
  transition: border-color .15s, box-shadow .15s;
}
.priority-inline-select:hover { border-color: var(--hairline-2); }
.priority-inline-select.saved { border-color: #5dbe7b; box-shadow: 0 0 0 2px rgba(93,190,123,0.2); }

/* ─── List hero (контакты/заказчики) ──────────────────── */
.list-hero {
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 14px;
}
.list-hero-title { display: inline-flex; align-items: baseline; gap: 12px; }
.list-hero-title .page-title { margin: 0; }
.list-hero-count {
  font-size: 13px; color: var(--fg-3);
  padding: 3px 11px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  font-weight: 500;
}
.list-hero-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.list-stat-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--fg-2);
  font-size: 12px; font-weight: 500;
  text-decoration: none;
  transition: background .12s, border-color .12s, color .12s;
}
.list-stat-chip:hover { background: var(--surface-3); color: var(--fg); }
.list-stat-chip.is-active {
  background: var(--brand-bg);
  border-color: rgba(181,25,31,0.4);
  color: var(--fg);
}
.list-stat-chip .st-dot { width: 7px; height: 7px; }
.list-stat-cnt {
  font-size: 11px; color: var(--fg-3);
  padding: 1px 7px;
  background: var(--surface);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.list-stat-chip.is-active .list-stat-cnt { background: var(--brand); color: #fff; }

@media (max-width: 880px) {
  .list-hero-chips { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .list-hero-chips::-webkit-scrollbar { display: none; }
  .list-stat-chip { white-space: nowrap; flex-shrink: 0; }
}

/* ─── Dashboard — pro UI ────────────────────────────────── */
.dash { display: flex; flex-direction: column; gap: 18px; }

.dash-hero {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 4px 4px 8px;
}
.dash-greet {
  font-family: var(--font-ui);
  font-style: normal; font-weight: 900;
  font-size: 28px;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
  color: var(--fg);
  line-height: 1.1;
}
.dash-actions {
  display: flex; gap: 8px; margin-left: auto;
  flex-shrink: 0;
}

.dash-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.dash-stat {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  text-decoration: none;
  color: var(--fg);
  transition: background .15s, border-color .15s, transform .2s;
  position: relative;
  overflow: hidden;
}
.dash-stat:hover {
  border-color: var(--hairline-2);
  transform: translateY(-2px);
}
.dash-stat-ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border-radius: 12px;
  flex-shrink: 0;
  background: var(--surface-2);
  color: var(--fg-3);
}
.dash-stat-body { flex: 1; min-width: 0; }
.dash-stat-v { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.dash-stat-l { font-size: 12px; color: var(--fg-3); margin-top: 4px; }
.dash-stat-sub {
  font-size: 11px;
  margin-top: 2px;
  color: var(--fg-2);
}

/* Colour variants */
.dash-stat-blue .dash-stat-ic    { background: rgba(74,144,226,0.12); color: #4a90e2; }
.dash-stat-green .dash-stat-ic   { background: rgba(93,190,123,0.12); color: #5dbe7b; }
.dash-stat-brand .dash-stat-ic   { background: var(--brand-bg); color: var(--brand-hi); }
.dash-stat-brand { border-color: rgba(181,25,31,0.25); }
.dash-stat-brand:hover { border-color: var(--brand); }
.dash-stat-brand .dash-stat-v { color: var(--brand-hi); }
.dash-stat-amber .dash-stat-ic   { background: rgba(226,162,60,0.12); color: #e2a23c; }
.dash-stat-red .dash-stat-ic     { background: rgba(211,77,77,0.15); color: #d34d4d; }
.dash-stat-red { border-color: rgba(211,77,77,0.3); }
.dash-stat-mute .dash-stat-ic    { background: var(--surface-2); color: var(--fg-4); }

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.dash-panel .card-head h2 {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-ui);
  font-style: normal; font-weight: 900;
  font-size: 15px;
}
.dash-list {
  list-style: none; margin: 0; padding: 0;
}
.dash-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: background .12s;
}
.dash-list li:hover { background: var(--surface-2); }
.dash-list li:last-child { border-bottom: none; }
.dash-list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dash-list-title { font-size: 13px; font-weight: 600; color: var(--fg); }
.dash-list-sub { font-size: 11px; color: var(--fg-3); }
.dash-list-time { white-space: nowrap; flex-shrink: 0; }

@media (max-width: 880px) {
  .dash-hero { flex-direction: column; align-items: flex-start; }
  .dash-actions { width: 100%; margin-left: 0; }
  .dash-actions .btn { flex: 1; justify-content: center; }
  .dash-greet { font-size: 22px; }
  .dash-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-stat { padding: 12px 14px; }
  .dash-stat-ic { width: 36px; height: 36px; }
  .dash-stat-v { font-size: 22px; }
  .dash-grid { grid-template-columns: 1fr; }
}

/* ─── Contact show — pro UI ─────────────────────────────── */
.contact-page { display: flex; flex-direction: column; gap: 14px; }
.contact-topbar { gap: 8px; }

.hero-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  padding: 20px 22px;
  align-items: center;
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
}
.hero-main { min-width: 0; }
.hero-title {
  font-family: var(--font-ui);
  font-style: normal; font-weight: 900;
  font-size: 32px;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
  color: var(--fg);
  line-height: 1.1;
  word-break: break-word;
}
.hero-meta {
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: center;
}
.hero-meta-item {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--fg-2);
  padding: 3px 9px;
  background: var(--surface-3);
  border-radius: 999px;
}
.hero-meta-item.muted { background: transparent; color: var(--fg-3); padding-left: 4px; }
.hero-banner {
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
}
.hero-banner-warn { background: rgba(226,162,60,0.1); color: #e2a23c; border: 1px solid rgba(226,162,60,0.3); }
.hero-banner-warn a { color: #e2a23c; text-decoration: underline; }
.hero-banner-danger { background: rgba(211,77,77,0.1); color: #d34d4d; border: 1px solid rgba(211,77,77,0.3); }

.hero-actions {
  display: flex; gap: 6px; flex-shrink: 0;
}
.hero-act {
  display: inline-flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px;
  width: 64px; height: 64px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  color: var(--fg);
  font-size: 11px;
  text-decoration: none;
  transition: background .12s, border-color .12s, transform .15s;
}
.hero-act:hover { background: var(--surface-3); border-color: var(--brand); transform: translateY(-2px); }
.hero-act svg { color: var(--brand-hi); }

.contact-tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  width: fit-content;
}
.contact-tabs button {
  background: transparent; border: 0;
  padding: 8px 14px; border-radius: 7px;
  color: var(--fg-2); font-size: 13px; font-weight: 500;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s, color .12s;
}
.contact-tabs button:hover { color: var(--fg); background: var(--surface-3); }
.contact-tabs button.is-active {
  background: var(--surface);
  color: var(--fg);
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.tab-cnt {
  font-size: 10px;
  background: var(--surface-3);
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--fg-3);
}
.contact-tabs button.is-active .tab-cnt { background: var(--brand-bg); color: var(--brand-hi); }

.kv-pro {
  grid-template-columns: 160px 1fr;
  gap: 14px 20px;
  font-size: 14px;
}
.kv-pro > dt { font-size: 12px; color: var(--fg-3); padding-top: 4px; }
.kv-pro > dd { margin: 0; word-break: break-word; }
.kv-list { display: flex; flex-direction: column; gap: 6px; }
.kv-list-item { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
.kv-list-label {
  font-size: 11px; color: var(--fg-3);
  padding: 2px 8px;
  background: var(--surface-3);
  border-radius: 999px;
}
.kv-list-item a { color: var(--fg); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.kv-list-item a:hover { color: var(--brand-hi); }

@media (max-width: 880px) {
  .hero-card {
    grid-template-columns: 1fr;
    padding: 16px 14px;
    gap: 14px;
  }
  .hero-title { font-size: 24px; }
  .hero-actions { width: 100%; justify-content: stretch; }
  .hero-act { flex: 1; width: auto; height: 56px; }
  .contact-tabs {
    width: 100%; overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .contact-tabs::-webkit-scrollbar { display: none; }
  .contact-tabs button { white-space: nowrap; flex-shrink: 0; padding: 8px 10px; font-size: 12px; }
  .kv-pro { grid-template-columns: 110px 1fr; gap: 10px 12px; font-size: 13px; }
}

/* ─── Сделано — pro UI ──────────────────────────────────── */
.done-page { display: flex; flex-direction: column; gap: 12px; }
.done-card { padding: 12px 14px 16px; display: flex; flex-direction: column; gap: 14px; }

.done-search {
  position: relative;
  display: inline-flex; align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 0 8px 0 32px;
  min-width: 220px;
  transition: border-color .12s;
}
.done-search:focus-within { border-color: var(--brand); }
.done-search-ic {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--fg-3); display: inline-flex;
}
.done-search-input {
  border: 0 !important; background: transparent !important; padding: 7px 0 !important;
  font-size: 13px; flex: 1; min-width: 0;
}
.done-search-clear {
  background: transparent; border: 0; cursor: pointer; padding: 4px;
  color: var(--fg-3); display: inline-flex; align-items: center;
}
.done-search-clear:hover { color: var(--fg); }

.done-list {
  display: flex; flex-direction: column; gap: 4px;
}

.done-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  transition: background .12s, border-color .12s;
}
.done-row:hover {
  background: var(--surface-2);
  border-color: var(--hairline);
}
.done-row.is-new {
  animation: todoFadeIn 0.4s ease-out;
}

.done-icon-slot {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--brand-hi);
}
.done-icon-empty { color: var(--fg-4); opacity: 0; transition: opacity .15s; }
.done-row:hover .done-icon-empty { opacity: 0.6; }

.done-body { min-width: 0; }
.done-cells {
  display: inline-flex; flex-wrap: wrap; align-items: baseline;
  gap: 8px;
  font-size: 14px;
  line-height: 1.5;
}
.done-c1 { color: var(--fg); word-break: break-word; }
.done-c2 { color: var(--fg-2); word-break: break-word; }
.done-c1 a, .done-c2 a { color: var(--brand-hi); text-decoration: underline; text-underline-offset: 2px; }
.done-c1 a:hover, .done-c2 a:hover { color: var(--fg); }
.done-sep {
  display: inline-block; width: 4px; height: 4px;
  background: var(--fg-4); border-radius: 50%;
}

.done-edit {
  display: flex; gap: 6px; flex-wrap: wrap; width: 100%;
}
.done-edit .input { flex: 1; min-width: 180px; padding: 7px 10px; font-size: 13px; }

.done-actions {
  display: flex; gap: 2px;
  opacity: 0;
  transition: opacity .15s;
}
.done-row:hover .done-actions,
.done-row:focus-within .done-actions { opacity: 1; }
.done-act {
  width: 30px; height: 30px;
  padding: 0 !important;
  color: var(--fg-3);
}
.done-act:hover { color: var(--fg); }
.done-del:hover { color: #d34d4d; }

.done-empty {
  text-align: center;
  padding: 32px 20px;
  color: var(--fg-3);
}
.done-empty h3 { margin: 0 0 6px; font-size: 16px; font-weight: 600; color: var(--fg); }
.done-empty p { margin: 0; max-width: 380px; margin-inline: auto; }
.done-empty-filter { text-align: center; padding: 16px; }

.done-add {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
  align-items: stretch;
}
.done-add .input { flex: 1 1 220px; min-width: 180px; }
.done-add-btn { flex-shrink: 0; }

@media (max-width: 880px) {
  .done-search { width: 100%; min-width: 0; }
  .done-row {
    grid-template-columns: 28px 1fr auto;
    padding: 12px 10px;
  }
  .done-actions { opacity: 1; }
  .done-cells { font-size: 13px; }
  .done-add { flex-direction: column; }
  .done-add .input { width: 100%; }
  .done-add-btn { width: 100%; justify-content: center; }
}

/* списки телефонов/email */
.list-tight { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.list-tight .lbl { color: var(--fg-3); font-size: 11px; margin-right: 6px; }
