/* ProjectSuite prototype — интеграционный слой (меню, окна, тосты, гид, состояния демо).
   Только добавленные элементы и состояния; вёрстка экранов не перекомпонуется. */

/* ── Видимый фокус для всего интерактивного ── */
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible,
[tabindex]:focus-visible, summary:focus-visible {
  outline: 2px solid #306BC1;
  outline-offset: 2px;
}
.ps-search:focus-within { box-shadow: 0 0 0 2px #306BC1; }
tr[tabindex]:focus-visible td { box-shadow: inset 0 2px 0 #306BC1, inset 0 -2px 0 #306BC1; }
td[tabindex]:focus-visible { outline-offset: -2px; }
.ps-user { cursor: pointer; border-radius: 6px; }
.ps-user:focus-visible { outline-offset: 3px; }

/* ── Подменю админки (Privileges · Integrations) — вид как крошки S5 ── */
.ps-subnav {
  display: flex; align-items: center; gap: 10px;
  height: 26px; padding: 0 20px;
  background: #EEF0F3;
  border-bottom: 1px solid #DDE0E5;
  font: 600 12px/26px var(--ps-font-head);
  color: #585A66;
  white-space: nowrap;
}
.ps-subnav a { color: #585A66; letter-spacing: .1px; }
.ps-subnav a.is-active { color: #0B2071; font-weight: 700; }
.ps-subnav span { color: #8A8C96; }

/* ── Выпадающие меню шапки ── */
.app-pop {
  position: absolute; z-index: 60;
  min-width: 240px; max-width: calc(100vw - 16px);
  background: #fff; border: 1px solid #D4D6DB; border-radius: 6px;
  box-shadow: 0 8px 24px rgba(10, 25, 60, .16);
  padding: 6px 0;
  font: 400 13px/1.4 var(--ps-font-text); color: var(--ps-ink);
  white-space: normal;
}
.app-pop[hidden] { display: none; }
.app-pop h4 { margin: 4px 14px 6px; font: 700 13px/18px var(--ps-font-head); color: var(--ps-title); }
.app-pop .app-mi {
  display: block; width: 100%; padding: 8px 14px; border: 0; background: none;
  text-align: left; font: inherit; color: inherit; cursor: pointer;
}
.app-pop .app-mi:hover, .app-pop .app-mi:focus-visible { background: #EEF4FD; }
.app-pop .app-mi small { display: block; color: var(--ps-muted); font-size: 11.5px; }
.app-pop .app-note { display: flex; gap: 10px; padding: 8px 14px; border-top: 1px solid #EEF0F2; text-align: left; }
.app-pop .app-note:first-of-type { border-top: 0; }
.app-pop .app-note b { color: var(--ps-title); }
.app-pop .app-note time { display: block; color: var(--ps-muted); font-size: 11.5px; }
.app-pop .app-dot { flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: #1550D0; }
.app-pop .app-sform { display: flex; gap: 6px; padding: 6px 12px 8px; }
.app-pop .app-sform input { flex: 1; min-width: 0; height: 30px; padding: 0 8px; border: 1px solid #BEC1C6; border-radius: 4px; font: 400 13px var(--ps-font-text); }
.app-pop .app-hint { padding: 0 14px 6px; color: var(--ps-muted); font-size: 11.5px; }

/* ── Тосты ── */
.app-toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.app-toast {
  max-width: 560px; padding: 10px 16px; border-radius: 6px;
  background: #13213F; color: #fff;
  font: 600 13px/1.4 var(--ps-font-text);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .22);
  animation: app-toast-in .18s ease-out;
}
@keyframes app-toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Окна (<dialog>) ── */
dialog.app-dlg {
  width: 520px; max-width: calc(100vw - 24px); max-height: calc(100vh - 32px);
  padding: 0; border: 1px solid #CDD2DA; border-radius: 8px;
  box-shadow: 0 16px 40px rgba(10, 25, 60, .22);
  color: var(--ps-ink); font: 400 13px/1.45 var(--ps-font-text);
  overflow: auto;
}
dialog.app-dlg.is-wide { width: 720px; }
dialog.app-dlg::backdrop { background: rgba(14, 24, 48, .28); }
.app-dlg-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; background: var(--ps-panel-navy); color: #fff; }
.app-dlg-h h2 { margin: 0; font: 700 16px/22px var(--ps-font-head); }
.app-dlg-b { padding: 14px 18px 4px; }
.app-dlg-b p { margin: 0 0 10px; }
.app-dlg-f { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; padding: 12px 18px 16px; }
.app-field { display: block; margin: 0 0 12px; }
.app-field > span { display: block; margin-bottom: 4px; font-weight: 600; font-size: 12.5px; color: var(--ps-ink-2); }
.app-field > span em { font-style: normal; font-weight: 400; color: var(--ps-muted); }
.app-field input[type=text], .app-field input[type=date], .app-field select, .app-field textarea {
  width: 100%; min-height: 32px; padding: 5px 8px;
  border: 1px solid #BEC1C6; border-radius: 4px; background: #fff;
  font: 400 13px/1.4 var(--ps-font-text); color: var(--ps-ink);
}
.app-field textarea { min-height: 72px; resize: vertical; }
.app-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.app-checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.app-checks label, .app-radio label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.app-radio { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.app-err { margin: -6px 0 10px; color: #A3140F; font-weight: 600; font-size: 12.5px; }
.app-err[hidden] { display: none; }
.app-ro { padding: 6px 8px; border: 1px solid #E1E3E7; border-radius: 4px; background: #F5F6F8; }
.app-muted { color: var(--ps-muted); font-size: 12px; }
.app-btn-link { border: 0; background: none; padding: 2px 4px; color: var(--ps-link-ink); font: 600 12.5px/1.2 var(--ps-font-text); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.app-btn-link:disabled { color: #A1A4AB; cursor: default; text-decoration: none; }
.app-btn-sm { height: 26px; padding: 0 10px; font-size: 12.5px; }
.app-multi { max-height: 180px; overflow: auto; padding: 6px 8px; border: 1px solid #BEC1C6; border-radius: 4px; }
.app-multi label { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; }

/* Manage assignments */
.app-zone { margin: 0 0 12px; border: 1px solid #DDE0E5; border-radius: 6px; }
.app-zone > h3 { display: flex; justify-content: space-between; align-items: center; margin: 0; padding: 7px 10px; background: #F3F5F7; border-bottom: 1px solid #DDE0E5; font: 700 13px/18px var(--ps-font-head); color: var(--ps-title); border-radius: 6px 6px 0 0; }
.app-asg { display: grid; grid-template-columns: 20px 30px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 6px 10px; border-top: 1px solid #EEF0F2; }
.app-asg:first-of-type { border-top: 0; }
.app-asg.is-sel { background: #EEF4FD; }
.app-asg .avatar { width: 28px; height: 28px; }
.app-asg .ord { font-weight: 700; color: var(--ps-muted); text-align: right; }
.app-asg .nm b { display: block; font-size: 13px; }
.app-asg .nm span { font-size: 11.5px; color: var(--ps-muted); }
.app-asg .ctl { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; justify-content: flex-end; }
.app-asg .ctl .pill { margin-right: 6px; }
.app-addbox { margin: 0 0 12px; padding: 10px 12px 2px; border: 1px dashed #A5C6F4; border-radius: 6px; background: #F8FBFF; }
.app-addbox[hidden] { display: none; }

/* ── Статусы, которых нет в shell.css ── */
.pill-hold      { background: #FDEED4; border-color: #F2C77E; color: #76330D; }
.pill-revision  { background: #FFF4CC; border-color: #E9CF6E; color: #6A4A00; }
.pill-clarify   { background: #FDEED4; border-color: #F2C77E; color: #76330D; }
.pill-withdrawn, .pill-closed { background: #E3E4E6; border-color: #C4C5CA; color: #4E4E52; }
.pill-rejected  { background: #FDE2E1; border-color: #F2B1AE; color: #8C1410; }
.scr-route .rt-pill.is-closed { background: #E3E4E6; color: #4E4E52; }
.scr-route .rt-pill.is-rej { background: #FDE2E1; color: #8C1410; }
.scr-route .rt-hdr-pill.st-hold, .scr-route .rt-hdr-pill.st-revision, .scr-route .rt-hdr-pill.st-clarify { background: #FDEED4; color: #76330D; width: auto; padding: 0 12px; }
.scr-route .rt-hdr-pill.st-ok { background: #C1E8C3; color: #16582F; }
.scr-route .rt-hdr-pill.st-closed { background: #E3E4E6; color: #4E4E52; }
.scr-route .rt-hdr-pill.st-rej { background: #FDE2E1; color: #8C1410; }
.scr-route .rt-route.is-grown { height: auto; padding-bottom: 12px; }
.scr-route .rt-route.is-grown .rt-sec { height: auto; padding-bottom: 6px; }
.scr-route .rt-route.is-grown .rt-wf { position: static; margin: 6px 0 0; height: auto; padding-bottom: 10px; }
.scr-key-system-update .ksu-ir.st-ok { background: #DEF4EC; color: #15834C; }
.scr-key-system-update .ksu-ir.st-hold { background: #FDEED4; color: #76330D; }
.scr-key-system-update .ksu-ir.st-closed { background: #E3E4E6; color: #4E4E52; }
.scr-key-system-update .ksu-ir.st-rej { background: #FDE2E1; color: #8C1410; }
.scr-key-system-update .st-done { color: #1E9E59; }
.scr-key-system-update .st-done i { background: #069D55; }
.scr-key-system-update .st-rtp { color: #1055BC; }
.scr-key-system-update .st-rtp i { background: #1B74E3; }
.scr-key-system-update .ksu-num.is-done { border-color: #46B57A; background: #DEF4EC; color: #0F7A34; }
.scr-key-system-update .ksu-num.is-done svg { display: block; }
.scr-key-system-update .ksu-after { position: relative; }
.app-sim {
  position: absolute; top: 14px; right: 18px;
  height: 28px; padding: 0 12px;
  border: 1.5px solid var(--ps-blue-line); border-radius: 4px; background: #fff; color: #0A38CA;
  font: 600 12.5px/1 var(--ps-font-text); cursor: pointer; white-space: nowrap;
}
.app-sim:hover { background: #F2F7FF; }
.app-sim:disabled { color: #8A8D93; border-color: #C8CCD2; cursor: default; background: #F5F6F8; }

/* Пакет: плашка примера, подсветка, роль */
.app-example {
  margin: 6px 0 0; padding: 6px 10px;
  border: 1px solid var(--ps-info-line); border-radius: 5px; background: #EEF5FE;
  color: var(--ps-info-ink); font: 600 12.5px/1.35 var(--ps-font-text);
}
.app-flash { animation: app-flash 2s ease-out; }
@keyframes app-flash { 0%, 60% { box-shadow: 0 0 0 3px #F5B63A, 0 0 0 7px rgba(245, 182, 58, .35); } 100% { box-shadow: 0 0 0 0 rgba(245, 182, 58, 0); } }
.app-rolebar {
  display: flex; align-items: center; justify-content: flex-start; gap: 8px; flex-wrap: wrap;
  padding: 4px 12px; margin-top: 7px;
  background: #F3F5F8; border-top: 1px solid #E2E2E5;
  font: 600 12px/20px var(--ps-font-text); color: var(--ps-ink-2);
}
.scr-route .app-rolebar { margin-top: 10px; border: 1px solid var(--rt-card-line); border-radius: 6px; }
.scr-route .app-rolebar + .rt-bar { margin-top: 6px; }
.scr-package .app-rolebar + .pk-actions { margin-top: 0; }
.app-rolebar select { max-width: 100%; height: 26px; padding: 0 6px; border: 1px solid #BEC1C6; border-radius: 4px; background: #fff; font: 400 12.5px var(--ps-font-text); color: var(--ps-ink); }
.app-rolebar .app-tag { padding: 0 8px; border-radius: 9px; background: #FEF3D8; border: 1px solid #F5C46A; color: #382B1F; font-weight: 600; font-size: 11px; line-height: 17px; }
.app-hide { display: none !important; }
.scr-integrations .int-tbl tr.int-new td.int-wrap { white-space: normal; line-height: 15px; padding-top: 4px; padding-bottom: 4px; }
.scr-integrations .int-table-card.app-scroll { overflow-y: auto; }
.scr-integrations .int-table-card.app-scroll .int-tbl thead th { position: sticky; top: -6px; z-index: 1; }
.scr-integrations .int-kv.int-kv-gen .int-kv-row,
.scr-integrations .int-kv.int-kv-gen .int-kv-row:first-child,
.scr-integrations .int-kv.int-kv-gen .int-kv-row:nth-child(2) { grid-template-columns: 150px minmax(0, 1fr); height: auto; min-height: 35px; padding: 7px 0 7px 1px; }
.scr-integrations .int-kv.int-kv-gen dd { white-space: normal; line-height: 17px; }
.scr-integrations .int-kv.int-kv-gen { margin-top: 12px; }
.scr-privileges .pv-item.is-selected { background: var(--ps-sel-bg); font-weight: 700; }
.scr-privileges .pv-item[aria-pressed="true"] { box-shadow: inset 4px 0 0 var(--ps-sel-bar); }
.scr-privileges .pv-audit-tbl tr.app-new > * { height: 39px; background: #F4FAF3; }

/* KSU карточка-пояснение */
.app-card {
  position: absolute; z-index: 55; width: 300px; max-width: calc(100vw - 16px);
  padding: 10px 12px; background: #fff; border: 1px solid #D4D6DB; border-radius: 6px;
  box-shadow: 0 8px 24px rgba(10, 25, 60, .16);
  font: 400 13px/1.45 var(--ps-font-text); color: var(--ps-ink); white-space: normal;
}
.app-card b { display: block; margin-bottom: 4px; color: var(--ps-title); font-family: var(--ps-font-head); }
.app-card p { margin: 0 0 4px; }

/* ── Гид ── */
body.app-has-tourbtn { padding-bottom: 64px; } /* кнопка гида не закрывает низ страницы (в ?shots=1 кнопки и отступа нет) */
.app-tourbtn {
  position: fixed; right: 18px; bottom: 34px; z-index: 70;
  height: 38px; padding: 0 16px;
  border: 0; border-radius: 19px; background: var(--ps-blue); color: #fff;
  font: 600 13px/1 var(--ps-font-text); cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 60, 160, .3);
}
.app-tourbtn:hover { background: #004BC2; }
.app-tour {
  position: absolute; z-index: 80; width: 340px; max-width: calc(100vw - 16px);
  padding: 14px 16px 12px; background: #fff; color: var(--ps-ink);
  border: 1px solid #B9C7DE; border-radius: 8px; box-shadow: 0 12px 32px rgba(10, 25, 60, .25);
  font: 400 13px/1.5 var(--ps-font-text);
}
.app-tour h3 { margin: 0 0 6px; font: 700 15px/20px var(--ps-font-head); color: var(--ps-title); }
.app-tour p { margin: 0 0 10px; }
.app-tour .app-tour-n { color: var(--ps-muted); font-size: 11.5px; font-weight: 600; }
.app-tour .app-tour-f { display: flex; align-items: center; gap: 8px; }
.app-tour .app-tour-f .sp { flex: 1; }
.app-tour .app-arrow { position: absolute; width: 14px; height: 14px; background: #fff; border: 1px solid #B9C7DE; transform: rotate(45deg); }
.app-tour.is-below .app-arrow { top: -8px; border-right: 0; border-bottom: 0; }
.app-tour.is-above .app-arrow { bottom: -8px; border-left: 0; border-top: 0; }
.app-tour.is-center { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 420px; }
.app-tour.is-center .app-arrow, .app-tour.is-dock .app-arrow { display: none; }
.app-tour-target { outline: 3px solid #F5B63A !important; outline-offset: 3px; border-radius: 4px; }
@media (max-width: 760px) {
  .app-tour.is-dock, .app-tour.is-center { position: fixed; left: 0; right: 0; top: auto; bottom: 0; width: auto; max-width: none; transform: none; border-radius: 10px 10px 0 0; }
  .app-tourbtn { right: 10px; bottom: 44px; height: 34px; padding: 0 12px; font-size: 12px; }
  .app-row2 { grid-template-columns: 1fr; }
  .app-sim { position: static; margin: 8px 0 0; }
  .app-asg { grid-template-columns: 18px 28px minmax(0, 1fr); }
  .app-asg .ctl { grid-column: 2 / -1; justify-content: flex-start; }
  .app-rolebar { justify-content: flex-start; }
}

/* ── Режим снимков: без анимаций ── */
html.app-shots *, html.app-shots *::before, html.app-shots *::after { animation: none !important; transition: none !important; }
