/* ============================================================================
   24markirovka — приборка. Стилистика Честного Знака: жёлтый #f2eb3b,
   графит #363634. Тёмная тема по умолчанию, светлая — по системной настройке
   (или вручную через data-theme на <html>).
   ========================================================================= */

/* ------------------------------------------------------------ токены темы */
:root {
  --yellow: #f2eb3b;
  --yellow-dim: #cfc820;
  --ink: #363634;

  --bg: #171716;
  --bg-soft: #1f1f1d;
  --card: #262624;
  --card-2: #2e2e2b;
  --line: #3a3a36;
  --line-soft: #302f2c;
  --text: #f4f4ef;
  --muted: #a5a59c;
  --muted-2: #77776f;

  --ok: #37b26e;
  --warn: #e8b027;
  --fail: #ef5a4c;
  --off: #7c7c74;
  --info: #56a8ef;
  --accent: var(--yellow);
  --on-accent: #262624;

  --ok-bg: rgba(55, 178, 110, .14);
  --warn-bg: rgba(232, 176, 39, .14);
  --fail-bg: rgba(239, 90, 76, .15);
  --off-bg: rgba(124, 124, 116, .14);

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-2: 0 10px 30px -12px rgba(0, 0, 0, .65);
  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 8px;
  --mono: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* светлая тема по системной настройке (если пользователь не выбрал вручную) */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f2ec;
    --bg-soft: #eceadf;
    --card: #ffffff;
    --card-2: #f7f6f0;
    --line: #dedcd0;
    --line-soft: #e9e7dc;
    --text: #23231f;
    --muted: #6a6a61;
    --muted-2: #8e8e84;

    --ok: #1f8f52;
    --warn: #a97600;
    --fail: #cc3b2c;
    --off: #8a8a80;
    --info: #1f6fc0;

    --ok-bg: rgba(31, 143, 82, .12);
    --warn-bg: rgba(169, 118, 0, .13);
    --fail-bg: rgba(204, 59, 44, .11);
    --off-bg: rgba(138, 138, 128, .13);

    --shadow-1: 0 1px 2px rgba(54, 54, 52, .10);
    --shadow-2: 0 12px 28px -14px rgba(54, 54, 52, .35);
  }
}

/* ручной выбор темы (кнопка в шапке) */
:root[data-theme="light"] {
  --bg: #f3f2ec;
  --bg-soft: #eceadf;
  --card: #ffffff;
  --card-2: #f7f6f0;
  --line: #dedcd0;
  --line-soft: #e9e7dc;
  --text: #23231f;
  --muted: #6a6a61;
  --muted-2: #8e8e84;
  --ok: #1f8f52;
  --warn: #a97600;
  --fail: #cc3b2c;
  --off: #8a8a80;
  --info: #1f6fc0;
  --ok-bg: rgba(31, 143, 82, .12);
  --warn-bg: rgba(169, 118, 0, .13);
  --fail-bg: rgba(204, 59, 44, .11);
  --off-bg: rgba(138, 138, 128, .13);
  --shadow-1: 0 1px 2px rgba(54, 54, 52, .10);
  --shadow-2: 0 12px 28px -14px rgba(54, 54, 52, .35);
}

/* --------------------------------------------------------------- база */
* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

/* фоновое сияние в фирменном жёлтом — очень деликатно */
body::before {
  content: "";
  position: fixed;
  inset: -30vh -10vw auto;
  height: 60vh;
  background: radial-gradient(60% 60% at 50% 0%, rgba(242, 235, 59, .10), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
a { color: inherit; }

button, input, select { font: inherit; color: inherit; }

::selection { background: var(--yellow); color: #262624; }

:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 2px;
  border-radius: 6px;
}

/* тонкий скроллбар */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------- стартовый экран */
.boot {
  min-height: 100vh;
  display: grid;
  place-content: center;
  gap: 18px;
  justify-items: center;
}
.boot-logo { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.boot-logo span { color: var(--muted); font-weight: 500; }
.boot-bar { width: 180px; height: 4px; border-radius: 99px; background: var(--line); overflow: hidden; }
.boot-bar i { display: block; width: 40%; height: 100%; background: var(--yellow); animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }

/* ------------------------------------------------------------- каркас */
.shell { position: relative; z-index: 1; min-height: 100vh; padding-bottom: 88px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}

.topbar-in {
  max-width: 1320px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; flex: none;
  border-radius: 10px;
  background: var(--yellow);
  display: grid; place-items: center;
  box-shadow: var(--shadow-1);
}
.brand-mark svg { display: block; }
.brand-name { font-weight: 700; letter-spacing: -.02em; line-height: 1.1; white-space: nowrap; }
.brand-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

.topbar-spacer { flex: 1; }

.stamp {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.stamp b { color: var(--text); font-weight: 600; }
.stamp .live {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent);
  animation: pulse 2.6s infinite;
}
.stamp .live.paused { background: var(--muted-2); animation: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ------------------------------------------------------------- кнопки */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 550;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, transform .12s ease, color .16s ease;
}
.btn:hover { background: var(--card-2); border-color: var(--muted-2); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: default; transform: none; }
.btn-accent {
  background: var(--yellow);
  border-color: transparent;
  color: #2b2b28;
  font-weight: 650;
}
.btn-accent:hover { background: var(--yellow-dim); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-icon { padding: 7px; width: 34px; height: 34px; justify-content: center; }
.btn svg { display: block; }
.spin { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------- вкладки */
.tabs {
  position: sticky; top: 55px; z-index: 25;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.tabs-in {
  max-width: 1320px; margin: 0 auto;
  padding: 0 16px;
  display: flex; gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs-in::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  border: 0; background: none;
  padding: 11px 13px 12px;
  color: var(--muted);
  font-size: 14px; font-weight: 550;
  cursor: pointer; white-space: nowrap;
  transition: color .16s ease;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); }
.tab.on::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: 0;
  height: 3px; border-radius: 3px 3px 0 0; background: var(--yellow);
  animation: growIn .22s ease;
}
@keyframes growIn { from { transform: scaleX(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.tab .badge {
  display: inline-block; margin-left: 6px;
  min-width: 18px; padding: 0 5px;
  border-radius: 99px;
  background: var(--yellow); color: #2b2b28;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
  vertical-align: 1px;
}

/* нижняя панель вкладок на телефоне */
.tabbar { display: none; }

/* ------------------------------------------------------------- контент */
.wrap { max-width: 1320px; margin: 0 auto; padding: 18px 16px 40px; }
.view { animation: fadeUp .26s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.section-head {
  display: flex; align-items: baseline; gap: 10px;
  margin: 26px 0 12px;
  flex-wrap: wrap;
}
.section-head:first-child { margin-top: 4px; }
.section-head h2 { font-size: 16.5px; }
.section-head .hint { font-size: 12.5px; color: var(--muted); }

/* ------------------------------------------------------------- карточки */
.card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card-pad { padding: 16px; }

.grid { display: grid; gap: 12px; }
.g-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.g-tiles { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.g-orgs { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.g-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

/* сводные плитки */
.stat {
  padding: 14px 15px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; gap: 3px;
  transition: transform .16s ease, border-color .16s ease;
}
.stat:hover { transform: translateY(-1px); border-color: var(--line); }
.stat .k { font-size: 12px; color: var(--muted); letter-spacing: .01em; }
.stat .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12px; color: var(--muted-2); }
.stat.accent { border-color: color-mix(in srgb, var(--yellow) 45%, var(--line)); }
.stat.accent .v { color: var(--yellow); }
:root[data-theme="light"] .stat.accent .v,
:root:not([data-theme="dark"]) .stat.accent .v { color: #8a8400; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .stat.accent .v { color: var(--yellow); } }

/* --------------------------------------------------- плитки процессов */
.tile {
  position: relative;
  text-align: left;
  padding: 15px 15px 13px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line-soft);
  background: var(--card);
  box-shadow: var(--shadow-1);
  cursor: pointer;
  display: flex; flex-direction: column; gap: 8px;
  overflow: hidden;
  transition: transform .16s ease, box-shadow .2s ease, border-color .16s ease;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.tile::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--s-color);
}
.tile.s-ok { --s-color: var(--ok); }
.tile.s-warn { --s-color: var(--warn); }
.tile.s-fail { --s-color: var(--fail); }
.tile.s-off { --s-color: var(--off); }
.tile .tile-top { display: flex; align-items: center; gap: 8px; }
.tile .tile-title { font-weight: 600; font-size: 14.5px; flex: 1; min-width: 0; }
.tile .tile-msg { font-size: 13px; color: var(--muted); }
.tile .tile-foot {
  display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted-2); margin-top: auto;
}
.tile .tile-foot > span { white-space: nowrap; }
.tile.s-fail { background: linear-gradient(180deg, var(--fail-bg), transparent 55%), var(--card); }
.tile.s-warn { background: linear-gradient(180deg, var(--warn-bg), transparent 55%), var(--card); }

.dot {
  width: 10px; height: 10px; border-radius: 50%; flex: none;
  background: var(--s-color, var(--off));
}
.dot.s-ok { background: var(--ok); }
.dot.s-warn { background: var(--warn); }
.dot.s-fail { background: var(--fail); }
.dot.s-off { background: var(--off); }
.dot.beat { animation: beat 1.8s ease-in-out infinite; }
@keyframes beat { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ------------------------------------------------------------- бейджи */
.badge-st {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge-st.s-ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.badge-st.s-warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.badge-st.s-fail { background: var(--fail-bg); color: var(--fail); border-color: color-mix(in srgb, var(--fail) 35%, transparent); }
.badge-st.s-off { background: var(--off-bg); color: var(--off); border-color: color-mix(in srgb, var(--off) 35%, transparent); }
.badge-st.s-info { background: rgba(86, 168, 239, .14); color: var(--info); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.badge-st.s-new { background: var(--yellow); color: #2b2b28; border-color: transparent; }

.chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--card-2);
  border: 1px solid var(--line-soft);
  font-size: 11.5px;
  color: var(--muted);
}

/* ------------------------------------------------------------- тревоги */
.alerts { display: flex; flex-direction: column; gap: 8px; }
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 13px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-soft);
  background: var(--card);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: border-color .16s ease, background .16s ease, transform .12s ease;
}
.alert:hover { transform: translateX(2px); }
.alert.lvl-error { background: linear-gradient(90deg, var(--fail-bg), transparent 60%), var(--card); border-color: color-mix(in srgb, var(--fail) 35%, var(--line-soft)); }
.alert.lvl-warn { background: linear-gradient(90deg, var(--warn-bg), transparent 60%), var(--card); border-color: color-mix(in srgb, var(--warn) 35%, var(--line-soft)); }
.alert .a-text { flex: 1; font-size: 13.5px; }
.alert .a-go { color: var(--muted-2); font-size: 12px; white-space: nowrap; }

/* --------------------------------------------------------- организации */
.org-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.org-head { display: flex; align-items: flex-start; gap: 10px; }
.org-name { font-weight: 650; font-size: 15px; line-height: 1.25; }
.org-inn { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.org-rows { display: flex; flex-direction: column; gap: 7px; }
.org-row { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; }
.org-row .rk { color: var(--muted); width: 84px; flex: none; padding-top: 1px; }
.org-row .rv { flex: 1; min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.org-codes { display: flex; gap: 8px; border-top: 1px dashed var(--line); padding-top: 11px; }
.org-codes div { flex: 1; text-align: center; }
.org-codes .n { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.org-codes .l { font-size: 11px; color: var(--muted); }

/* ------------------------------------------------------ сроки (3 дня) */
.dl-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.dl-card.s-fail { background: linear-gradient(180deg, var(--fail-bg), transparent 40%), var(--card); }
.dl-card.s-warn { background: linear-gradient(180deg, var(--warn-bg), transparent 40%), var(--card); }
.dl-nums { display: flex; gap: 8px; }
.dl-nums div { flex: 1; text-align: center; }
.dl-nums .n { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dl-nums .l { font-size: 11px; color: var(--muted); }
/* сегментированная полоса зон: в срок / на грани / просрочено */
.zone-bar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--card-2); }
.zone-bar span { display: block; height: 100%; transition: width .5s cubic-bezier(.2,.8,.2,1); }
.zone-bar .z-ok { background: var(--ok); }
.zone-bar .z-warn { background: var(--warn); }
.zone-bar .z-overdue { background: var(--fail); }
.dl-stages { display: flex; flex-direction: column; gap: 5px; border-top: 1px dashed var(--line); padding-top: 10px; }
.dl-stage { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dl-stage .st { flex: 1; min-width: 0; color: var(--muted); }
.dl-stage .n { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 28px; text-align: right; }
.dl-stage .n.zero { color: var(--muted-2); font-weight: 500; }
.dl-excl { font-size: 11.5px; color: var(--muted-2); }
.age-badge { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- таблицы */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.field {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card); border: 1px solid var(--line-soft);
  border-radius: 999px; padding: 5px 12px;
  transition: border-color .16s ease;
}
.field:focus-within { border-color: var(--yellow); }
.field input, .field select {
  border: 0; background: none; outline: none;
  font-size: 13.5px; min-width: 0;
}
.field select { cursor: pointer; }
.field select option { background: var(--card); color: var(--text); }
.field.search { flex: 1; min-width: 160px; max-width: 340px; }
.field.search input { width: 100%; }
.field svg { color: var(--muted); flex: none; }

.tbl-wrap {
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  overflow: auto;
  background: var(--card);
  box-shadow: var(--shadow-1);
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--card-2);
  color: var(--muted);
  font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .04em;
  text-align: left;
  padding: 9px 12px;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--text); }
thead th .arr { opacity: .45; font-size: 10px; margin-left: 4px; }
thead th.sorted { color: var(--text); }
thead th.sorted .arr { opacity: 1; color: var(--yellow); }
tbody td { padding: 9px 12px; border-top: 1px solid var(--line-soft); vertical-align: top; }
tbody tr { transition: background .12s ease; }
tbody tr:hover td { background: var(--card-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono { font-family: var(--mono); font-size: 12px; white-space: nowrap; }
td.wrap-any { word-break: break-word; }
.tbl-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 2px 0;
  font-size: 12.5px; color: var(--muted);
  flex-wrap: wrap;
}
.tbl-foot > span { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.tbl-foot .btn { white-space: normal; text-align: left; }

/* ------------------------------------------------------------- графики */
.chart { width: 100%; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--line-soft); stroke-width: 1; }
.chart .bar { fill: var(--yellow); transition: opacity .15s ease; }
:root[data-theme="light"] .chart .bar { fill: #cdae15; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .chart .bar { fill: #cdae15; } }
.chart .bar:hover { opacity: .75; }
.chart .spark-line { fill: none; stroke: var(--ok); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .spark-area { fill: color-mix(in srgb, var(--ok) 18%, transparent); }
.chart .axis { fill: var(--muted-2); font-size: 10px; }
.chart-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }

.hbar { display: flex; flex-direction: column; gap: 9px; }
.hbar-row { display: grid; grid-template-columns: 1fr; gap: 3px; }
.hbar-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.hbar-top .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.hbar-track { height: 8px; border-radius: 99px; background: var(--card-2); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 99px; background: var(--yellow); transition: width .5s cubic-bezier(.2,.8,.2,1); }
.hbar-fill.c-ok { background: var(--ok); }
.hbar-fill.c-warn { background: var(--warn); }
.hbar-fill.c-fail { background: var(--fail); }
.hbar-fill.c-info { background: var(--info); }

/* ------------------------------------------------------ база знаний */
.kb-list { display: flex; flex-direction: column; gap: 12px; }
.kb-item {
  padding: 15px 16px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line-soft);
  background: var(--card);
  box-shadow: var(--shadow-1);
  transition: border-color .16s ease, transform .16s ease;
}
.kb-item:hover { transform: translateY(-1px); border-color: var(--line); }
.kb-item.is-new { border-color: color-mix(in srgb, var(--yellow) 50%, var(--line-soft)); }
.kb-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 7px; }
.kb-title { font-size: 15.5px; font-weight: 650; line-height: 1.3; margin-bottom: 6px; }
.kb-title a { text-decoration: none; }
.kb-title a:hover { text-decoration: underline; text-decoration-color: var(--yellow); text-underline-offset: 3px; }
.kb-sum { font-size: 13.5px; color: var(--muted); }
.kb-impact {
  margin-top: 10px; padding: 9px 11px;
  border-radius: var(--r-sm);
  font-size: 13px;
  border-left: 3px solid var(--warn);
  background: var(--card-2);
}
.kb-impact.i-affects { border-left-color: var(--fail); }
.kb-impact.i-maybe { border-left-color: var(--warn); }
.kb-impact.i-none { border-left-color: var(--off); }

/* --------------------------------------------------- состояния экрана */
.skel {
  background: linear-gradient(90deg, var(--card-2) 25%, color-mix(in srgb, var(--card-2) 60%, var(--line)) 37%, var(--card-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: var(--r-md);
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.skel-line { height: 12px; border-radius: 6px; }
.skel-tile { height: 118px; }
.skel-row { height: 42px; }

.empty, .errbox {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 44px 18px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--r-lg);
  color: var(--muted);
  background: color-mix(in srgb, var(--card) 55%, transparent);
}
.empty .big, .errbox .big { font-size: 15px; color: var(--text); font-weight: 600; }
.errbox { border-color: color-mix(in srgb, var(--fail) 40%, var(--line)); }

/* ------------------------------------------------------------- вход */
.login-screen {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px 16px;
  position: relative; z-index: 1;
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 22px;
  box-shadow: var(--shadow-2);
  padding: 26px 24px;
  display: flex; flex-direction: column; gap: 14px;
  animation: fadeUp .3s ease;
}
.login-card h1 { font-size: 20px; }
.login-card .sub { font-size: 13px; color: var(--muted); }
.login-card label { font-size: 12.5px; color: var(--muted); display: block; margin-bottom: 5px; }
.login-card input[type="text"], .login-card input[type="password"] {
  width: 100%;
  padding: 10px 13px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  outline: none;
  transition: border-color .16s ease;
}
.login-card input:focus { border-color: var(--yellow); }
.login-err { font-size: 13px; color: var(--fail); }

/* ---------------------------------------------------------- адаптив */
@media (max-width: 860px) {
  .org-row .rk { width: 72px; }
}

@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .shell { padding-bottom: 74px; }
  .topbar-in { padding: 8px 12px; gap: 8px; }
  .brand-sub { display: none; }
  .stamp .txt { display: none; }
  .wrap { padding: 14px 12px 28px; }
  .stat .v { font-size: 22px; }
  .g-tiles { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
  .g-stats { grid-template-columns: repeat(2, 1fr); }

  /* вкладки уезжают в нижнюю панель */
  .tabs { display: none; }
  .tabbar {
    display: block;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .tabbar-in { display: flex; overflow-x: auto; scrollbar-width: none; }
  .tabbar-in::-webkit-scrollbar { display: none; }
  .tabbar .tab {
    flex: 0 0 auto;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 7px 12px 8px;
    font-size: 11px;
    min-width: 66px;
  }
  .tabbar .tab.on::after { top: 0; bottom: auto; left: 12px; right: 12px; height: 3px; border-radius: 0 0 3px 3px; }
  .tabbar .tab .badge { position: absolute; top: 2px; right: 6px; margin: 0; }
  .tabbar .tab svg { width: 20px; height: 20px; }
}

@media (max-width: 380px) {
  .g-tiles { grid-template-columns: 1fr; }
  .toolbar .field.search { max-width: none; }
  .brand-name { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* печать — на всякий случай, чтобы отчёт можно было распечатать */
@media print {
  .topbar, .tabs, .tabbar { display: none !important; }
  body { background: #fff; color: #000; }
}

/* ============================================================================
   v4 «Пульт»: строка статуса, лента процесса, KPI, дела, организации, свёртки,
   подсказки, демо-режим, мобильный лист «Ещё».
   ========================================================================= */

/* --------------------------------------------------- шапка: группы вкладок */
.tab-group { display: flex; align-items: center; gap: 2px; }
.tab-group + .tab-group { margin-left: 14px; padding-left: 14px; border-left: 1px solid var(--line-soft); }
.tab-group-name {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted-2); margin-right: 6px; white-space: nowrap;
}
.badge-abs { position: absolute; top: -5px; right: -5px; margin: 0; }
.btn-icon.on { border-color: var(--yellow); }
.stamp .live.s-warn { background: var(--warn); animation: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 30%, transparent); }
.stamp .live.s-fail { background: var(--fail); animation: beat 1.2s infinite; box-shadow: 0 0 0 3px color-mix(in srgb, var(--fail) 30%, transparent); }

/* тумблер «Демо» */
.demo-toggle { gap: 8px; padding-left: 9px; }
.demo-toggle .sw {
  width: 28px; height: 16px; border-radius: 99px; background: var(--line);
  position: relative; transition: background .18s ease; flex: none;
}
.demo-toggle .sw i {
  position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--card); box-shadow: var(--shadow-1); transition: transform .18s ease;
}
.demo-toggle.on { border-color: color-mix(in srgb, var(--yellow) 60%, var(--line)); }
.demo-toggle.on .sw { background: var(--yellow); }
.demo-toggle.on .sw i { transform: translateX(12px); background: #2b2b28; }

/* --------------------------------------------------------- строка статуса */
.status-line {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; margin-bottom: 14px;
}
.status-line.s-fail { background: linear-gradient(90deg, var(--fail-bg), transparent 60%), var(--card); border-color: color-mix(in srgb, var(--fail) 40%, var(--line-soft)); }
.status-line.s-warn { background: linear-gradient(90deg, var(--warn-bg), transparent 60%), var(--card); border-color: color-mix(in srgb, var(--warn) 40%, var(--line-soft)); }
.status-line.s-ok { background: linear-gradient(90deg, var(--ok-bg), transparent 55%), var(--card); }
.status-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.status-label { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 650; }
.status-title { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.status-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.status-time { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; display: flex; align-items: center; gap: 4px; }

/* ---------------------------------------------------------- лента процесса */
.pipe {
  display: flex; align-items: stretch; gap: 0;
  margin: 0 0 16px; padding: 4px 0;
}
.pipe-item { display: flex; align-items: stretch; flex: 1 1 0; min-width: 0; }
.pipe-arrow { display: flex; align-items: center; color: var(--muted-2); padding: 0 4px; flex: none; }
.pipe-step {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 3px;
  padding: 11px 12px 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-soft);
  background: var(--card);
  box-shadow: var(--shadow-1);
  cursor: pointer; text-align: left; font: inherit; color: inherit;
  position: relative; overflow: visible;
  transition: transform .16s ease, border-color .16s ease, box-shadow .2s ease;
}
.pipe-step:hover { transform: translateY(-1px); border-color: var(--line); box-shadow: var(--shadow-2); }
.pipe-step::before {
  content: ""; position: absolute; left: 10px; right: 10px; top: 0; height: 3px;
  border-radius: 0 0 3px 3px; background: var(--s-color, var(--off));
}
.pipe-step.s-ok { --s-color: var(--ok); }
.pipe-step.s-warn { --s-color: var(--warn); background: linear-gradient(180deg, var(--warn-bg), transparent 60%), var(--card); }
.pipe-step.s-fail { --s-color: var(--fail); background: linear-gradient(180deg, var(--fail-bg), transparent 60%), var(--card); }
.pipe-step.s-off { --s-color: var(--off); }
.pipe-title { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.pipe-title .dot { width: 8px; height: 8px; }
.pipe-value { font-size: 22px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.pipe-sub { font-size: 11.5px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------------------- KPI */
.g-kpi { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 4px; }
.stat .k { display: flex; align-items: center; gap: 4px; }
.stat-spark { margin-top: 4px; margin-bottom: -4px; }
.stat-spark .chart { opacity: .9; }
.stat.t-warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line-soft)); }
.stat.t-warn .v { color: var(--warn); }
.stat.t-fail { border-color: color-mix(in srgb, var(--fail) 50%, var(--line-soft)); background: linear-gradient(180deg, var(--fail-bg), transparent 70%), var(--card); }
.stat.t-fail .v { color: var(--fail); }
.stat.t-off .v { color: var(--muted); }
.stat.clickable { cursor: pointer; }

/* ------------------------------------------------------------ что сделать */
.actions { display: flex; flex-direction: column; gap: 8px; }
.action {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-soft);
  background: var(--card);
  box-shadow: var(--shadow-1);
}
.action.lvl-fail { background: linear-gradient(90deg, var(--fail-bg), transparent 55%), var(--card); border-color: color-mix(in srgb, var(--fail) 40%, var(--line-soft)); }
.action.lvl-warn { background: linear-gradient(90deg, var(--warn-bg), transparent 55%), var(--card); border-color: color-mix(in srgb, var(--warn) 40%, var(--line-soft)); }
.action-ic { flex: none; margin-top: 2px; }
.action-ic.s-fail { color: var(--fail); }
.action-ic.s-warn { color: var(--warn); }
.action-ic.s-info { color: var(--info); }
.action-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.action-title { font-weight: 650; font-size: 14.5px; }
.action-detail { font-size: 13px; color: var(--muted); }
.action-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.action-btns { display: flex; gap: 6px; flex: none; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.action-btns .btn { text-decoration: none; }
.actions-empty {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px; border-radius: var(--r-md);
  border: 1px dashed var(--line); color: var(--muted); font-size: 13.5px;
  background: color-mix(in srgb, var(--ok-bg) 60%, transparent);
}
.chip.owner { display: inline-flex; align-items: center; gap: 5px; }
.chip.owner.o-robot { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.chip.owner.o-human { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.chip.owner.o-accountant { color: var(--info); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.chip.late { color: var(--fail); border-color: color-mix(in srgb, var(--fail) 40%, transparent); }

/* ------------------------------------------------------------ организации */
.orgs-strip { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.org-pill {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  background: var(--card);
  box-shadow: var(--shadow-1);
  cursor: pointer; font: inherit; color: inherit;
  transition: transform .16s ease, border-color .16s ease;
}
.org-pill:hover { transform: translateY(-1px); border-color: var(--line); }
.org-pill.s-warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line-soft)); }
.org-pill.s-fail { border-color: color-mix(in srgb, var(--fail) 50%, var(--line-soft)); }
.org-pill-name { font-weight: 650; font-size: 14px; white-space: nowrap; }
.org-pill-lights { display: flex; gap: 8px; }
.org-light { position: relative; display: inline-flex; align-items: center; gap: 3px; border-radius: 6px; padding: 1px 2px; }
.org-light .dot { width: 9px; height: 9px; }
.org-light-l { font-size: 10.5px; color: var(--muted-2); letter-spacing: .02em; }
.org-light::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  background: var(--card-2); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 6px 9px; font-size: 12px; white-space: normal; width: max-content; max-width: 240px;
  box-shadow: var(--shadow-2); opacity: 0; pointer-events: none; transition: opacity .12s ease; z-index: 20;
}
.org-light:hover::after, .org-light:focus-visible::after { opacity: 1; }
.orgs-legend { font-size: 11.5px; color: var(--muted-2); margin-left: auto; display: inline-flex; align-items: center; gap: 4px; }

/* карточка организации (вкладка) */
.org-card.s-warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--line-soft)); }
.org-card.s-fail { border-color: color-mix(in srgb, var(--fail) 50%, var(--line-soft)); }
.org-lights { display: flex; flex-direction: column; gap: 6px; }
.org-light-row { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; }
.org-light-row .dot { margin-top: 5px; }
.org-light-row .rk { color: var(--muted); width: 52px; flex: none; display: inline-flex; align-items: center; gap: 3px; }
.org-light-row .rv { flex: 1; min-width: 0; }
.org-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.org-tech summary { cursor: pointer; font-size: 12.5px; color: var(--muted); list-style: none; display: flex; align-items: center; gap: 6px; }
.org-tech summary::-webkit-details-marker { display: none; }
.org-tech summary::before { content: "▸"; font-size: 11px; transition: transform .16s ease; }
.org-tech[open] summary::before { transform: rotate(90deg); }
.org-tech .org-rows { margin-top: 10px; }
.mono { font-family: var(--mono); font-size: 12px; }

/* ------------------------------------------------------- свёртки главной */
.home-collapsibles { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.collap {
  border: 1px solid var(--line-soft); border-radius: var(--r-lg);
  background: var(--card); box-shadow: var(--shadow-1);
  overflow: hidden;
}
.collap-head {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border: 0; background: none; cursor: pointer;
  font: inherit; color: inherit; text-align: left;
}
.collap-head:hover { background: var(--card-2); }
.collap-arr { color: var(--muted-2); font-size: 12px; transition: transform .18s ease; width: 12px; }
.collap.open .collap-arr { transform: rotate(90deg); }
.collap-title { font-weight: 650; font-size: 15px; }
.collap-sum { font-size: 12.5px; color: var(--muted); }
.collap-body { padding: 4px 16px 16px; border-top: 1px solid var(--line-soft); animation: fadeUp .2s ease; }
.collap-body .grid.g-tiles { margin-top: 12px; }

/* сегодня по шагам */
.steps { display: flex; flex-direction: column; margin-top: 6px; }
.steps-row {
  display: grid; grid-template-columns: 56px 1fr 56px 130px 150px; gap: 10px; align-items: start;
  padding: 9px 4px; border-top: 1px solid var(--line-soft); font-size: 13.5px;
}
.steps-row:first-child { border-top: 0; }
.steps-head { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-2); padding-bottom: 4px; }
.steps-plan, .steps-fact { font-variant-numeric: tabular-nums; font-weight: 600; }
.steps-fact { color: var(--muted); }
.steps-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 600; }
.steps-title .dot { width: 9px; height: 9px; }
.steps-msg { flex-basis: 100%; font-size: 12.5px; color: var(--muted); font-weight: 400; }
.dot.s-info { background: var(--info); }
.dot.s-pending, .dot.s-running { background: var(--info); }

/* новое в правилах */
.kb-mini { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.kb-mini-item { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.kb-mini-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-mini-date { font-size: 12px; color: var(--muted-2); white-space: nowrap; }

/* ------------------------------------------------------------- подсказки */
.hint-wrap { position: relative; display: inline-flex; vertical-align: middle; }
.hint-btn {
  width: 16px; height: 16px; border-radius: 50%; padding: 0;
  border: 1px solid var(--line); background: var(--card-2); color: var(--muted);
  font-size: 10.5px; font-weight: 700; line-height: 1; cursor: help;
  display: inline-grid; place-items: center;
}
.hint-btn:hover { color: var(--text); border-color: var(--muted-2); }
.hint-pop {
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 40;
  width: max-content; max-width: min(320px, 80vw);
  background: var(--card-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 8px 11px; font-size: 12.5px; font-weight: 400; line-height: 1.45;
  text-transform: none; letter-spacing: 0; white-space: normal; text-align: left;
  box-shadow: var(--shadow-2);
  opacity: 0; visibility: hidden; transform: translateY(-3px);
  transition: opacity .12s ease, transform .12s ease;
}
.hint-wrap.open .hint-pop, .hint-wrap:hover .hint-pop { opacity: 1; visibility: visible; transform: none; }
.section-head .hint-wrap { align-self: center; }

/* ---------------------------------------------------------------- прочее */
.dash-reason { color: var(--muted-2); font-size: 12px; font-style: italic; }
.reason-banner {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px 18px; margin-bottom: 14px;
  border-radius: var(--r-lg); border: 1px dashed var(--line);
  background: color-mix(in srgb, var(--card) 70%, transparent);
}
.reason-banner.s-warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.reason-banner.s-fail { border-color: color-mix(in srgb, var(--fail) 50%, var(--line)); }
.raw-details { margin-top: 4px; }
.raw-details summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.raw { margin: 6px 0 0; padding: 8px 10px; border-radius: var(--r-sm); background: var(--bg-soft); font-family: var(--mono); font-size: 11.5px; white-space: pre-wrap; word-break: break-word; max-height: 240px; overflow: auto; }

/* УПД между организациями: карточка пары, стрелка «откуда → куда», подсказка над списком бухгалтеру */
.ic-card .org-rows { font-size: 12.5px; }
.ic-card .org-row .rk { width: 110px; }
.ic-pair { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ic-pair-cell { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.ic-arrow { display: inline-flex; color: var(--muted-2); }
.ic-hint {
  display: flex; align-items: flex-start; gap: 8px; margin: 0 0 10px;
  padding: 10px 12px; border-radius: var(--r-md); font-size: 12.5px; color: var(--muted);
  background: color-mix(in srgb, var(--info) 8%, var(--card)); border: 1px dashed color-mix(in srgb, var(--info) 35%, var(--line));
}
.ic-hint svg { flex: none; margin-top: 1px; color: var(--info); }

.subtabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--card); border: 1px solid var(--line-soft); margin-bottom: 14px; }
.subtab { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; border: 0; background: none; color: var(--muted); font-size: 13.5px; font-weight: 600; cursor: pointer; }
.subtab.on { background: var(--yellow); color: #2b2b28; }
.subtab:hover:not(.on) { color: var(--text); }

/* ------------------------------------------------------------ экран входа */
.login-wrap {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(300px, 380px); gap: 40px; align-items: center;
  width: 100%; max-width: 940px;
}
.login-value h1 { font-size: 30px; line-height: 1.15; letter-spacing: -.02em; margin-bottom: 20px; }
.login-value ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; color: var(--muted); font-size: 15px; }
.login-value li { display: flex; align-items: flex-start; gap: 10px; }
.login-value li .dot { margin-top: 7px; }
.login-card { max-width: none; }

/* ------------------------------------------------------------ демо-режим */
:root.demo .tech { display: none !important; }
:root.demo .stat .v { font-size: 32px; }
:root.demo .pipe-value { font-size: 26px; }
:root.demo .status-title { font-size: 21px; }
:root.demo .org-pill-name { font-size: 15px; }
:root.demo .action-title { font-size: 15.5px; }
:root.demo table { font-size: 14.5px; }

/* ------------------------------------------------------------ мобильный лист */
.sheet-back { position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, .45); animation: fadeUp .15s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 46;
  background: var(--card); border-radius: 18px 18px 0 0;
  border-top: 1px solid var(--line);
  padding: 8px 10px calc(14px + env(safe-area-inset-bottom, 0));
  display: flex; flex-direction: column; gap: 2px;
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-grip { width: 40px; height: 4px; border-radius: 99px; background: var(--line); margin: 2px auto 10px; }
.sheet-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 12px;
  border: 0; background: none; border-radius: var(--r-md);
  font: inherit; color: inherit; font-size: 15px; text-align: left; cursor: pointer;
  position: relative;
}
.sheet-item:hover, .sheet-item.on { background: var(--card-2); }
.sheet-item.on { font-weight: 650; }
.sheet-item .badge { position: static; margin-left: auto; }
.sheet-sep { height: 1px; background: var(--line-soft); margin: 6px 4px; }

@media (max-width: 900px) {
  .pipe { flex-wrap: wrap; gap: 6px; }
  .pipe-item { flex: 1 1 calc(25% - 6px); }
}

@media (max-width: 640px) {
  .hide-sm { display: none; }
  .demo-toggle { font-size: 12.5px; padding: 6px 9px; }
  .tabbar-in { display: flex; overflow: visible; }
  .tabbar .tab { flex: 1 1 0; min-width: 0; padding: 7px 4px 8px; }
  .pipe { flex-direction: column; flex-wrap: nowrap; gap: 0; }
  .pipe-item { flex-direction: column; flex: none; }
  .pipe-arrow { transform: rotate(90deg); justify-content: center; padding: 2px 0; height: 20px; }
  .pipe-step { flex-direction: row; align-items: center; gap: 10px; padding: 9px 12px 9px 14px; }
  .pipe-step::before { top: 0; bottom: 0; left: 0; right: auto; width: 3px; height: auto; border-radius: 0 3px 3px 0; }
  .pipe-title { flex: 1; }
  .pipe-value { font-size: 18px; }
  .g-kpi { grid-template-columns: repeat(2, 1fr); }
  .status-line { flex-wrap: wrap; }
  .status-time { width: 100%; }
  .action { flex-wrap: wrap; }
  .action-btns { width: 100%; justify-content: flex-start; margin-left: 29px; }
  .org-pill { width: 100%; justify-content: space-between; }
  .orgs-legend { margin-left: 0; }
  .steps-row { grid-template-columns: 48px 1fr; }
  .steps-head { display: none; }
  .steps-row > :nth-child(3), .steps-row > :nth-child(4), .steps-row > :nth-child(5) { grid-column: 2; }
  .login-wrap { grid-template-columns: 1fr; gap: 22px; }
  .login-value h1 { font-size: 22px; }
  .login-value ul { font-size: 13.5px; }
  :root.demo .stat .v { font-size: 26px; }
}
