/* Дашборд 2ГИС — в едином стиле хабов edrid-madrid (концепция владельца сервера
   от 21.09.2026: _exchange/to-partner/2026-09-21_edinaya-koncepciya-dizayna.md.done).
   Светлая редакторская сетка + глянцевые акценты раннего Apple.com; на телефоне —
   сгруппированный список в духе «Настроек» iOS. Токены — один в один из концепции. */

:root {
  color-scheme: light;
  --bg: #f7f6f3; --panel: #ffffff; --panel-hover: #fcfcfa;
  --ink: #17171a; --ink-2: #65646a; --ink-3: #9b9aa1;
  --border: rgba(23, 23, 26, .10);
  --r-instr: #2f5bff; --r-dash: #7a3ff2; --r-doc: #e0631a; --r-wip: #c98a06; --r-partner: #0f9a63; --r-home: #e23577;
  --font: -apple-system, "SF Pro Display", "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  --nav-grad-top: #ffffff; --nav-grad-bottom: #f1f0ec; --nav-shadow-hi: rgba(255, 255, 255, .8);
  --btn-grad-top: #fdfdfc; --btn-grad-mid: #ece9e3; --btn-grad-bottom: #d7d4cc;
  --btn-border: rgba(0, 0, 0, .15); --btn-text-shadow: 0 1px 0 rgba(255, 255, 255, .7);
  --btn-shadow-hi: rgba(255, 255, 255, .9); --btn-shadow-lo: rgba(0, 0, 0, .08);
  --field: #fbfaf8;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141416; --panel: #1e1e21; --panel-hover: #25252a;
    --ink: #f2f2f4; --ink-2: #9d9da3; --ink-3: #6f6f75;
    --border: rgba(255, 255, 255, .10);
    --nav-grad-top: #1c1c1f; --nav-grad-bottom: #0f0f11; --nav-shadow-hi: rgba(255, 255, 255, .06);
    --btn-grad-top: #4a4a4f; --btn-grad-mid: #333338; --btn-grad-bottom: #1d1d20;
    --btn-border: rgba(255, 255, 255, .18); --btn-text-shadow: 0 -1px 0 rgba(0, 0, 0, .5);
    --btn-shadow-hi: rgba(255, 255, 255, .14); --btn-shadow-lo: rgba(0, 0, 0, .35);
    --field: #19191c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141416; --panel: #1e1e21; --panel-hover: #25252a;
  --ink: #f2f2f4; --ink-2: #9d9da3; --ink-3: #6f6f75;
  --border: rgba(255, 255, 255, .10);
  --nav-grad-top: #1c1c1f; --nav-grad-bottom: #0f0f11; --nav-shadow-hi: rgba(255, 255, 255, .06);
  --btn-grad-top: #4a4a4f; --btn-grad-mid: #333338; --btn-grad-bottom: #1d1d20;
  --btn-border: rgba(255, 255, 255, .18); --btn-text-shadow: 0 -1px 0 rgba(0, 0, 0, .5);
  --btn-shadow-hi: rgba(255, 255, 255, .14); --btn-shadow-lo: rgba(0, 0, 0, .35);
  --field: #19191c;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font);
  -webkit-font-smoothing: antialiased; line-height: 1.5; font-size: 15px;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--r-instr); outline-offset: 2px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }

/* цвет плашек и иконок задаётся классом (CSP не пускает inline-стили) */
.c-partner { --c: var(--r-partner); }
.c-dash { --c: var(--r-dash); }
.c-instr { --c: var(--r-instr); }
.c-doc { --c: var(--r-doc); }

/* ---------- шапка: хромовый градиент ---------- */
.nav {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(180deg, var(--nav-grad-top) 0%, var(--nav-grad-bottom) 100%);
  box-shadow: inset 0 1px 0 var(--nav-shadow-hi), 0 1px 0 rgba(0, 0, 0, .05);
  padding-top: var(--safe-t);
}
.nav-inner {
  display: flex; align-items: center; gap: 14px; max-width: 1400px; margin: 0 auto;
  padding: 12px calc(24px + var(--safe-r)) 12px calc(24px + var(--safe-l));
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 15px; letter-spacing: -.01em; text-decoration: none; }
.brand .swatch { width: 28px; height: 28px; border-radius: 8px; font-size: 11px; }
.brand small { font-weight: 600; color: var(--ink-3); font-size: 13px; }
.nav-total { margin-left: auto; font-size: 13px; color: var(--ink-2); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- глянцевые элементы ---------- */
.pill-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 20px; border-radius: 8px;
  font-size: 13px; font-weight: 700; color: var(--ink); text-decoration: none; white-space: nowrap; cursor: pointer;
  background: linear-gradient(180deg, var(--btn-grad-top) 0%, var(--btn-grad-mid) 45%, var(--btn-grad-bottom) 100%);
  border: 1px solid var(--btn-border);
  box-shadow: inset 0 1px 0 var(--btn-shadow-hi), inset 0 -1px 1px var(--btn-shadow-lo), 0 1px 2px rgba(0, 0, 0, .12);
  text-shadow: var(--btn-text-shadow);
  transition: transform .1s ease, box-shadow .1s ease;
}
.pill-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 var(--btn-shadow-hi), inset 0 -1px 1px var(--btn-shadow-lo), 0 3px 8px rgba(0, 0, 0, .2);
}
.pill-btn:disabled { opacity: .5; cursor: default; }
.pill-btn.primary {
  color: #fff; text-shadow: 0 -1px 0 rgba(0, 0, 0, .25);
  background: linear-gradient(180deg, #4c8dff 0%, #2f5bff 50%, #1c3fd1 100%); border-color: #1c3fd1;
}
.pill-btn.accent {
  color: #fff; text-shadow: 0 -1px 0 rgba(0, 0, 0, .25);
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 55%, #fff) 0%, var(--c) 52%, color-mix(in srgb, var(--c) 75%, #000) 100%);
  border-color: color-mix(in srgb, var(--c) 55%, #000);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), inset 0 -1px 1px rgba(0, 0, 0, .25), 0 1px 2px rgba(0, 0, 0, .15);
}
.pill-btn.block { width: 100%; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 4px 10px; border-radius: 99px; color: #fff; white-space: nowrap;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 55%, #fff) 0%, var(--c) 52%, color-mix(in srgb, var(--c) 75%, #000) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), inset 0 -1px 1px rgba(0, 0, 0, .25), 0 1px 2px rgba(0, 0, 0, .15);
  border: 1px solid color-mix(in srgb, var(--c) 55%, #000);
  text-shadow: 0 -1px 0 rgba(0, 0, 0, .25);
}

.swatch {
  width: 36px; height: 36px; border-radius: 10px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; color: #fff;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 55%, #fff) 0%, var(--c) 55%, color-mix(in srgb, var(--c) 78%, #000) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), inset 0 -1px 2px rgba(0, 0, 0, .3), 0 1px 2px rgba(0, 0, 0, .15);
  border: 1px solid color-mix(in srgb, var(--c) 55%, #000);
  text-shadow: 0 -1px 0 rgba(0, 0, 0, .3);
}

.arrow-btn {
  width: 44px; height: 44px; border-radius: 50%; flex: 0 0 auto; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 17px; color: var(--ink);
  background: linear-gradient(180deg, var(--btn-grad-top) 0%, var(--btn-grad-mid) 45%, var(--btn-grad-bottom) 100%);
  box-shadow: inset 0 1px 0 var(--btn-shadow-hi), inset 0 -1px 1px var(--btn-shadow-lo), 0 1px 2px rgba(0, 0, 0, .18);
  border: 1px solid var(--btn-border); text-shadow: var(--btn-text-shadow);
}
.link-btn { border: 0; background: none; color: var(--r-instr); cursor: pointer; padding: 10px 4px; font-size: 13px; font-weight: 600; min-height: 44px; }

/* ---------- заголовок страницы (как hero хаба, компактнее) ---------- */
.hero {
  max-width: 1400px; margin: 0 auto; border-bottom: 1px solid var(--border);
  padding: 28px calc(24px + var(--safe-r)) 26px calc(24px + var(--safe-l));
}
.kicker { font-size: 12px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; margin: 0 0 10px; }
.hero h1 { font-size: clamp(30px, 4.5vw, 52px); font-weight: 800; letter-spacing: -.03em; line-height: 1; margin: 0 0 10px; }
.hero p { font-size: 15px; color: var(--ink-2); margin: 0; max-width: 620px; }

/* ---------- вход ---------- */
.login { min-height: 100vh; display: flex; flex-direction: column; }
.login .hero { border: 0; width: 100%; max-width: 440px; padding-top: 12vh; }
.login-form { width: 100%; max-width: 440px; margin: 0 auto; padding: 0 24px 60px; display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.field input, .filter-search {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; font-size: 16px; /* 16px — iOS не зумит поле */
  text-transform: none; letter-spacing: 0; font-weight: 400;
  border: 1px solid var(--border); border-radius: 10px; background: var(--field); color: var(--ink);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .06);
}
.field input:focus, .filter-search:focus { outline: none; border-color: var(--r-instr); }
.alert { background: color-mix(in srgb, var(--r-wip) 14%, var(--panel)); border: 1px solid color-mix(in srgb, var(--r-wip) 40%, transparent); padding: 10px 12px; border-radius: 10px; font-size: 14px; margin: 0; }

/* ---------- раскладка дашборда ---------- */
.wrap { max-width: 1400px; margin: 0 auto; padding: 24px calc(24px + var(--safe-r)) 60px calc(24px + var(--safe-l)); }

/* фильтры — ячейки редакторской сетки */
.filters { margin-bottom: 24px; }
.sheet-head { display: none; }
.index-grid { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.cell { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 22px 24px; background: var(--panel); display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.cell-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.num { font-size: 12px; font-weight: 700; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.cell h3 { font-size: 18px; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.cell h3 .sel-count { font-size: 13px; font-weight: 600; color: var(--r-partner); margin-left: 6px; }

.check-list {
  height: 280px; overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
}
.check-list label {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 14px;
  border-bottom: 1px solid var(--border); cursor: pointer; font-size: 14px;
}
.check-list label:last-child { border-bottom: 0; }
.check-list label:hover { background: var(--panel-hover); }
.check-list input { position: absolute; opacity: 0; pointer-events: none; }
.check-list label span { flex: 1; min-width: 0; }
.check-list label::after { content: ""; width: 20px; flex: 0 0 20px; text-align: center; font-weight: 800; color: var(--r-instr); }
.check-list label:has(input:checked)::after { content: "✓"; }
.check-list label:has(input:checked) span { font-weight: 600; }
.check-list label:has(input:focus-visible) { outline: 2px solid var(--r-instr); outline-offset: -2px; }
.check-list .empty { padding: 14px; color: var(--ink-3); font-size: 14px; }
.filter-foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--ink-3); font-weight: 600; }
.filter-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chips:empty { display: none; }
.chip { border: 0; cursor: pointer; max-width: 100%; font: inherit; min-height: 30px; font-size: 10.5px; }
.chip span { overflow: hidden; text-overflow: ellipsis; }
.summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 14px; flex-wrap: wrap; }
.summary .found { font-size: 13px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; }

/* таблица — та же сетка тонких линий */
.table-wrap { overflow: auto; max-height: calc(100vh - 200px); border-top: 1px solid var(--border); border-left: 1px solid var(--border); background: var(--panel); }
table.orgs { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.orgs th, .orgs td { padding: 10px 12px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.orgs th {
  position: sticky; top: 0; z-index: 1; white-space: nowrap;
  font-size: 11px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em;
  background: linear-gradient(180deg, var(--nav-grad-top) 0%, var(--nav-grad-bottom) 100%);
}
.orgs tbody tr:hover td { background: var(--panel-hover); }
.orgs td.c-name { font-weight: 700; min-width: 180px; font-size: 14px; }
.orgs td.c-address { min-width: 180px; }
.orgs td.c-rubric { min-width: 220px; }
.orgs td.c-phone, .orgs td.c-whatsapp { white-space: nowrap; }
.orgs td.c-email { min-width: 150px; }
.orgs .na { color: var(--ink-3); }
.orgs a, .detail a { color: var(--r-instr); text-decoration: none; overflow-wrap: anywhere; }
.orgs a:hover, .detail a:hover { text-decoration: underline; }
.orgs td.c-email a { overflow-wrap: normal; }
.links { display: flex; flex-direction: column; gap: 2px; }
#more { margin-top: 16px; }

/* мобильный список (рендерится только на телефоне) */
.mlist { display: none; }
.bottombar { display: none; }
.sheet-backdrop { display: none; }

/* меню ⋯ */
.menu { position: relative; }
.menu .arrow-btn { font-size: 16px; }
.menu-pop {
  position: absolute; right: 0; top: 52px; min-width: 240px; overflow: hidden;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .14);
}
.menu-pop form { margin: 0; }
.menu-item {
  display: block; width: 100%; text-align: left; min-height: 44px; padding: 12px 16px; border: 0;
  border-bottom: 1px solid var(--border); background: none; cursor: pointer; font-size: 14px; font-weight: 600;
}
.menu-pop > :last-child .menu-item, .menu-pop > .menu-item:last-child { border-bottom: 0; }
.menu-item:hover { background: var(--panel-hover); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
  max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
}
footer { max-width: 1400px; margin: 0 auto; font-size: 12px; color: var(--ink-3); border-top: 1px solid var(--border);
  padding: 22px calc(24px + var(--safe-r)) calc(40px + var(--safe-b)) calc(24px + var(--safe-l)); }

/* ---------- телефон: сгруппированные списки как в «Настройках» iOS ---------- */
@media (max-width: 900px) {
  body { padding-bottom: calc(76px + var(--safe-b)); }
  .desktop-only { display: none !important; }
  .nav-inner { padding: 10px calc(18px + var(--safe-r)) 10px calc(18px + var(--safe-l)); }
  .brand small { display: none; }
  .hero { padding: 18px calc(18px + var(--safe-r)) 18px calc(18px + var(--safe-l)); }
  .hero h1 { font-size: clamp(28px, 8vw, 36px); }
  .hero p { font-size: 14px; }
  .wrap { padding: 16px calc(16px + var(--safe-r)) 24px calc(16px + var(--safe-l)); }
  .login-form { padding: 0 calc(18px + var(--safe-r)) 40px calc(18px + var(--safe-l)); }
  footer { display: none; }

  /* фильтры — выезжающая снизу панель */
  .filters {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; margin: 0;
    max-height: 90vh; display: flex; flex-direction: column;
    background: var(--bg); border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, .2);
    padding: 8px calc(16px + var(--safe-r)) calc(12px + var(--safe-b)) calc(16px + var(--safe-l));
    transform: translateY(105%); transition: transform .22s ease;
  }
  body.sheet-open .filters { transform: none; }
  body.sheet-open { overflow: hidden; }
  body.sheet-open .sheet-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 40; }
  .sheet-head {
    display: flex; justify-content: space-between; align-items: center; min-height: 48px;
    font-size: 17px; font-weight: 700; border-bottom: 1px solid var(--border); margin: 0 -16px 12px; padding: 0 16px;
  }
  .index-grid { display: flex; flex-direction: column; gap: 18px; overflow-y: auto; min-height: 0; border: 0; }
  .cell { border: 0; padding: 0; background: none; gap: 8px; }
  .cell-top { display: none; }
  .cell h3 { font-size: 11px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; padding: 0 4px; }
  .check-list { height: 32vh; border-radius: 14px; }
  .check-list label { font-size: 15px; }
  .filter-foot { padding: 0 4px; }
  .filter-actions { margin-top: 12px; flex-wrap: nowrap; }
  .filter-actions .pill-btn { flex: 1; }

  /* результаты — сгруппированный список */
  .table-wrap { display: none; }
  .mlist { display: block; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
  .mlist:empty { display: none; }
  .item { border-bottom: 1px solid var(--border); }
  .item:last-child { border-bottom: 0; }
  .row {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 12px 14px;
    border: 0; background: none; text-align: left; cursor: pointer;
  }
  .row:active { background: var(--panel-hover); }
  .row-body { flex: 1; min-width: 0; }
  .row-body h3 { font-size: 15px; font-weight: 600; margin: 0 0 1px; letter-spacing: -.005em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .row-body p { font-size: 12.5px; color: var(--ink-2); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .chev { color: var(--ink-3); font-size: 20px; transition: transform .15s ease; flex: 0 0 auto; }
  .item.open .chev { transform: rotate(90deg); }
  .detail { padding: 0 14px 14px 62px; font-size: 14px; }
  .detail dl { margin: 0 0 12px; display: grid; grid-template-columns: 96px 1fr; gap: 6px 10px; }
  .detail dt { color: var(--ink-3); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding-top: 2px; }
  .detail dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
  .actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .actions .pill-btn { padding: 10px 14px; color: var(--ink); text-decoration: none; }
  .actions .pill-btn.primary { color: #fff; }

  .bottombar {
    display: flex; gap: 10px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 10px calc(16px + var(--safe-r)) calc(10px + var(--safe-b)) calc(16px + var(--safe-l));
    background: linear-gradient(180deg, var(--nav-grad-top) 0%, var(--nav-grad-bottom) 100%);
    box-shadow: inset 0 1px 0 var(--nav-shadow-hi), 0 -1px 0 rgba(0, 0, 0, .06);
  }
  .bottombar .pill-btn { flex: 1; min-height: 48px; font-size: 15px; }
  .badge {
    min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; font-size: 12px; color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(180deg, #4c8dff 0%, #2f5bff 50%, #1c3fd1 100%); text-shadow: none;
  }
}
