/* Руки · компоненты */

/* ——— кнопки ——— */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: var(--s2); color: var(--text);
  font-weight: 550; font-size: 14px; line-height: 1.2; text-decoration: none; white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .08s var(--ease), box-shadow .15s var(--ease);
  box-shadow: 0 1px 0 var(--hi) inset;
}
.btn:hover { background: var(--s3); text-decoration: none; border-color: var(--lilac-line); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; transform: none; border-color: var(--line); }
.btn--primary {
  background: linear-gradient(180deg, var(--gold-hi), var(--gold));
  border-color: transparent; color: var(--gold-ink); font-weight: 650;
  box-shadow: 0 8px 22px rgba(242, 196, 92, .2), 0 1px 0 rgba(255, 255, 255, .5) inset;
}
.btn--primary:hover { background: linear-gradient(180deg, #ffe39a, var(--gold-hi)); border-color: transparent; }
:root[data-theme="light"] .btn--primary { box-shadow: 0 6px 16px rgba(176, 120, 8, .22), 0 1px 0 rgba(255, 255, 255, .6) inset; }
.btn--ghost { background: transparent; border-color: var(--line); box-shadow: none; }
.btn--ghost:hover { background: var(--s2); }
.btn--danger { color: var(--red-text); border-color: var(--red-line); background: var(--red-soft); }
.btn--danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn--sm { min-height: 34px; padding: 5px 12px; font-size: 13px; border-radius: 10px; }
.btn--lg { min-height: 48px; padding: 10px 22px; font-size: 15px; }
.btn--icon { width: 40px; padding: 0; }
.btn--icon.btn--sm { width: 34px; }
.btn--block { width: 100%; }
.btn .i { width: 1.2em; height: 1.2em; }

/* ——— пилюли и теги ——— */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px;
  border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--s3); color: var(--text-2);
  font-size: 12px; font-weight: 550; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.pill--plain::before { display: none; }
.pill--ok    { background: var(--green-soft); border-color: var(--green-line); color: var(--green-text); }
.pill--warn  { background: var(--gold-soft);  border-color: var(--gold-line);  color: var(--gold-text); }
.pill--bad   { background: var(--red-soft);   border-color: var(--red-line);   color: var(--red-text); }
.pill--info  { background: var(--blue-soft);  border-color: var(--blue-line);  color: var(--blue-text); }
.pill--agent { background: var(--lilac-soft); border-color: var(--lilac-line); color: var(--lilac-text); }
.pill--live::before { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.7); } }

/* метки зрелости: есть / в разработке / проверяется / план */
.tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px;
  border-radius: 6px; border: 1px solid transparent;
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; vertical-align: middle;
}
.tag--have { background: var(--green-soft); color: var(--green-text); border-color: var(--green-line); }
.tag--dev  { background: var(--gold-soft);  color: var(--gold-text);  border-color: var(--gold-line); }
.tag--test { background: var(--blue-soft);  color: var(--blue-text);  border-color: var(--blue-line); }
.tag--plan { background: var(--lilac-soft); color: var(--lilac-text); border-color: var(--lilac-line); }
.tag--demo { background: var(--s3); color: var(--muted); border-color: var(--line-strong); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--s-inset);
  font-size: 12.5px; color: var(--text-2); font-family: var(--font-mono);
}
.chip button { border: 0; background: none; color: var(--muted); padding: 0; display: grid; place-items: center; }
.chip button:hover { color: var(--red-text); }
.chip--lock { color: var(--muted); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; flex: none; }
.dot--ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.dot--warn { background: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.dot--bad { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.dot--agent { background: var(--lilac); box-shadow: 0 0 0 3px var(--lilac-soft); }
.dot--live { animation: pulse 1.8s ease-in-out infinite; }

/* ——— карточки ——— */
.card {
  position: relative;
  background: linear-gradient(180deg, color-mix(in srgb, var(--s2) 70%, var(--s1)), var(--s1) 55%);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  min-width: 0;
}
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 20px 0; }
.card__head h2, .card__head h3 { display: flex; align-items: center; gap: 10px; }
.card__head .i { color: var(--lilac-text); }
.card__body { padding: 16px 20px 20px; }
.card__foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }
.card--flat { box-shadow: none; background: var(--s1); }
.card--accent { border-color: var(--gold-line); background: linear-gradient(180deg, var(--gold-soft), var(--s1) 70%); }
.card--link { transition: transform .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease); }
.card--link:hover { transform: translateY(-2px); border-color: var(--lilac-line); }

.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--side { grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); align-items: start; }
@media (max-width: 1100px) { .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid--side { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px)  { .grid--2, .grid--3 { grid-template-columns: minmax(0, 1fr); } .grid { gap: 12px; } }

/* ——— плитки статистики ——— */
.stat { padding: 16px 18px; display: grid; gap: 4px; overflow: hidden; }
.stat__label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--muted); }
.stat__label .i { color: var(--lilac-text); width: 18px; height: 18px; }
.stat__value { font: 600 34px/1.1 var(--font-display); letter-spacing: -.02em; display: flex; align-items: baseline; gap: 6px; }
.stat__value small { font: 500 14px var(--font-ui); color: var(--muted); letter-spacing: 0; }
.stat__note { font-size: 12px; color: var(--muted); }
.stat--alert { border-color: var(--gold-line); }
.stat--alert .stat__value { color: var(--gold-text); }
@media (max-width: 720px) { .stat { padding: 13px 14px; } .stat__value { font-size: 28px; } }

/* ——— полоски расхода ——— */
.meter { --pct: 0; height: 6px; border-radius: 6px; background: var(--s3); overflow: hidden; border: 1px solid var(--line); }
.meter > i { display: block; height: 100%; width: calc(var(--pct) * 1%); border-radius: 6px; background: linear-gradient(90deg, var(--lilac), var(--gold)); transition: width .4s var(--ease); }
.meter--warn > i { background: var(--gold); }
.meter--bad > i { background: var(--red); }
.meter--ok > i { background: var(--green); }
.meter-row { display: grid; gap: 6px; }
.meter-row__top { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--text-2); }
.meter-row__top span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ——— таблицы ——— */
.table-wrap { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--s1); box-shadow: var(--shadow-1); overflow: hidden; }
.table-scroll { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  padding: 12px 16px; background: var(--s2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td { padding: 14px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:first-child td { border-top: 0; }
.tbl tbody tr:hover td { background: color-mix(in srgb, var(--s2) 60%, transparent); }
.tbl td .sub { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.tbl .col-actions { text-align: right; white-space: nowrap; }
.tbl a.row-link { color: var(--text); font-weight: 600; }
.tbl a.row-link:hover { color: var(--gold-text); text-decoration: none; }

/* таблица превращается в карточки на узком экране */
@media (max-width: 720px) {
  .tbl--cards thead { display: none; }
  .tbl--cards, .tbl--cards tbody, .tbl--cards tr, .tbl--cards td { display: block; width: 100%; }
  .tbl--cards tr { padding: 12px 14px; border-top: 1px solid var(--line); }
  .tbl--cards tbody tr:first-child { border-top: 0; }
  .tbl--cards td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 14px; align-items: baseline; text-align: right; }
  .tbl--cards td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex: none; }
  .tbl--cards td[data-label=""]::before, .tbl--cards td:not([data-label])::before { display: none; }
  .tbl--cards td.cell-title { display: block; text-align: left; padding-bottom: 6px; }
  .tbl--cards td.cell-title::before { display: none; }
  .tbl--cards .col-actions { text-align: left; padding-top: 8px; }
  .tbl--cards tbody tr:hover td { background: none; }
}

/* ——— формы ——— */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field__label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field__hint { font-size: 12px; color: var(--muted); }
.field__error { font-size: 12.5px; color: var(--red-text); }
.input, .select, .textarea {
  width: 100%; min-height: 42px; padding: 9px 12px;
  background: var(--s-inset); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--lilac-line); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--lilac-soft); }
.textarea { min-height: 96px; resize: vertical; }
.select { appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.input-group { position: relative; }
.input-group .btn { position: absolute; right: 4px; top: 4px; min-height: 34px; }
.input-group .input { padding-right: 52px; }

.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track { position: relative; width: 44px; height: 26px; border-radius: 26px; background: var(--s3); border: 1px solid var(--line-strong); flex: none; transition: background .2s var(--ease), border-color .2s var(--ease); }
.switch__track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--text-2); transition: transform .2s var(--ease), background .2s var(--ease); }
.switch input:checked + .switch__track { background: var(--gold); border-color: transparent; }
.switch input:checked + .switch__track::after { transform: translateX(18px); background: var(--gold-ink); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch input:disabled + .switch__track { opacity: .5; }
.switch input:disabled ~ .switch__label { opacity: .7; }
.switch__label { display: grid; gap: 1px; }
.switch__label small { color: var(--muted); font-size: 12px; }

.range { width: 100%; accent-color: var(--gold); height: 28px; }
.stepper { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; }
.stepper__value { font: 600 20px var(--font-display); min-width: 3ch; text-align: right; font-variant-numeric: tabular-nums; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--s-inset); border: 1px solid var(--line); max-width: 100%; overflow-x: auto; }
.seg button, .seg a {
  min-height: 34px; padding: 6px 14px; border-radius: 9px; border: 0; background: none; color: var(--muted);
  font-weight: 550; font-size: 13.5px; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.seg--full { display: flex; width: 100%; }
.seg--full button { flex: 1 1 0; min-width: 0; justify-content: center; padding: 6px 6px; font-size: 12.5px; gap: 5px; }
.seg--full .i { width: 14px; height: 14px; }
.seg button:hover, .seg a:hover { color: var(--text); text-decoration: none; }
.seg [aria-pressed="true"], .seg [aria-selected="true"], .seg [aria-current="true"] { background: var(--s3); color: var(--text); box-shadow: 0 1px 0 var(--hi) inset, 0 0 0 1px var(--line-strong); }

/* ——— диалоги ——— */
dialog.dlg {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  padding: 0; margin: auto;
  color: var(--text); background: var(--s1);
  border: 1px solid var(--line-strong); border-radius: var(--r-xl);
  box-shadow: var(--shadow-2); overflow: hidden;
}
dialog.dlg[open] { display: flex; flex-direction: column; animation: dlg-in .22s var(--ease); }
dialog.dlg::backdrop { background: rgba(4, 7, 14, .62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.dlg--wide { width: min(860px, calc(100vw - 24px)); }
.dlg__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 22px 0; }
.dlg__head h2 { font: 600 22px/1.2 var(--font-display); }
.dlg__body { padding: 14px 22px 8px; overflow-y: auto; display: grid; gap: 14px; }
.dlg__foot { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; padding: 16px 22px 20px; }
@media (max-width: 560px) {
  dialog.dlg { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 92dvh; }
  .dlg__foot .btn { flex: 1 1 auto; }
}

/* ——— тосты ——— */
.toasts { position: fixed; z-index: 90; right: 20px; bottom: 20px; display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--r-md);
  background: var(--s2); border: 1px solid var(--line-strong); box-shadow: var(--shadow-2);
  animation: toast-in .24s var(--ease);
  font-size: 13.5px;
}
.toast .i { margin-top: 1px; }
.toast--ok .i { color: var(--green-text); }
.toast--bad .i { color: var(--red-text); }
.toast--warn .i { color: var(--gold-text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (max-width: 820px) { .toasts { right: 16px; left: 16px; bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom)); width: auto; } }

/* ——— прочее ——— */
.callout { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--s2); font-size: 13.5px; color: var(--text-2); }
.callout > .i { margin-top: 2px; color: var(--lilac-text); }
.callout > div { min-width: 0; display: grid; gap: 4px; }
.callout strong { color: var(--text); }
.callout--warn { background: var(--gold-soft); border-color: var(--gold-line); }
.callout--warn > .i { color: var(--gold-text); }
.callout--bad { background: var(--red-soft); border-color: var(--red-line); }
.callout--bad > .i { color: var(--red-text); }
.callout--ok { background: var(--green-soft); border-color: var(--green-line); }
.callout--ok > .i { color: var(--green-text); }
.callout--info { background: var(--blue-soft); border-color: var(--blue-line); }
.callout--info > .i { color: var(--blue-text); }

.empty { padding: 40px 24px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--r-lg); color: var(--muted); display: grid; gap: 6px; justify-items: center; }
.empty strong { color: var(--text); font-size: 15px; }
.empty .i { width: 28px; height: 28px; color: var(--lilac-text); margin-bottom: 4px; }

.kv { display: grid; grid-template-columns: minmax(110px, 38%) minmax(0, 1fr); gap: 0; font-size: 13.5px; }
.kv dt, .kv dd { padding: 9px 0; border-top: 1px solid var(--line); }
.kv dt:first-of-type, .kv dt:first-of-type + dd { border-top: 0; }
.kv dt { color: var(--muted); padding-right: 12px; }
.kv dd { color: var(--text); min-width: 0; overflow-wrap: anywhere; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.kv dd .sub { color: var(--muted); font-size: 12px; flex-basis: 100%; }
@media (max-width: 460px) { .kv { grid-template-columns: 1fr; } .kv dt { border-top: 1px solid var(--line); padding-bottom: 0; } .kv dd { border-top: 0; padding-top: 2px; } .kv dt:first-of-type { border-top: 0; } }

.lock { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.lock .i { width: 14px; height: 14px; color: var(--gold-text); }

.timeline { position: relative; display: grid; gap: 0; }
.timeline__item { position: relative; display: grid; grid-template-columns: 56px 1fr; gap: 12px; padding: 7px 0; font-size: 13px; }
.timeline__time { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; padding-top: 1px; }
.timeline__text { color: var(--text-2); min-width: 0; overflow-wrap: anywhere; }
.timeline__item--stop .timeline__text { color: var(--gold-text); font-weight: 600; }
.timeline__item--human .timeline__text { color: var(--lilac-text); }

.skeleton { border-radius: var(--r-md); background: linear-gradient(90deg, var(--s2), var(--s3), var(--s2)); background-size: 220% 100%; animation: shimmer 1.4s linear infinite; min-height: 18px; }
@keyframes shimmer { to { background-position: -220% 0; } }

.code { position: relative; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--s-inset); overflow: hidden; }
.code__bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--line); background: var(--s2); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.code pre { margin: 0; padding: 14px 16px; overflow-x: auto; font-size: 12.8px; line-height: 1.6; tab-size: 2; color: var(--text-2); }
.code pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; overflow-wrap: normal; }

.divider-label { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; }
.divider-label::before, .divider-label::after { content: ""; height: 1px; flex: 1; background: var(--line); }

.demo-ribbon { display: inline-flex; align-items: center; gap: 6px; }
