/* ============================================================
   UI-SHELL.CSS — общая оболочка приложения «Реестр Актов»
   Государственно-строгий стиль (концепт 4).

   Локальные шрифты Inter (без CDN), брендовая полоса сверху,
   ГОРЯЗОНТАЛЬНАЯ навигация (замена левого сайдбара),
   шапка с поиском/пользователем, ИИ-панель справа.

   Классы .registry-* сохранены для совместимости с существующим
   app.js, но визуально перестроены под гос-стандарт.
   Дизайн-токены читаются из gov-tokens.css.
   ============================================================ */

@font-face{font-family:Inter;font-style:normal;font-weight:400;font-display:swap;src:url('/static/fonts/inter-400.woff2') format('woff2')}
@font-face{font-family:Inter;font-style:normal;font-weight:500;font-display:swap;src:url('/static/fonts/inter-500.woff2') format('woff2')}
@font-face{font-family:Inter;font-style:normal;font-weight:600;font-display:swap;src:url('/static/fonts/inter-600.woff2') format('woff2')}
@font-face{font-family:Inter;font-style:normal;font-weight:700;font-display:swap;src:url('/static/fonts/inter-700.woff2') format('woff2')}

/* ============================================================
   Базовый body
   ============================================================ */
body.registry-page{
  margin:0;padding:0;
  background:var(--page);
  color:var(--text);
  font-family:var(--font-system);
  font-size:13.5px;line-height:1.45;
  -webkit-font-smoothing:antialiased;
}
.ui-icon-label{display:inline-flex;align-items:center;gap:7px}
.ui-icon-button{display:inline-grid;place-items:center;line-height:0}
.ui-icon-button .ui-icon{margin:0!important}

/* ============================================================
   Брендовая цветная полоса (фирменный элемент гос-стандарта)
   ============================================================ */
.gov-topline,.registry-topline{
  height:var(--topline-h);
  background:linear-gradient(90deg,#0a317e 0%,var(--blue) 55%,var(--gold) 100%);
}

/* ============================================================
   Контейнер оболочки — больше НЕ сетка с сайдбаром.
   Теперь: полоса → шапка → навигация → рабочая область.
   .registry-shell сохранён как обёртка, но стал вертикальным.
   ============================================================ */
.registry-shell{
  display:flex;
  flex-direction:column;
  min-height:100vh;
  background:var(--page);
}

/* ============================================================
   ШАПКА (header) — лого, поиск, пользователь
   ============================================================ */
.registry-header, .registry-topbar{
  height:var(--header-h);
  display:flex;
  align-items:center;
  gap:22px;
  padding:0 30px;
  background:var(--surface);
  border-bottom:1px solid var(--line);
  position:sticky;top:0;z-index:40;
}

.registry-brand{
  display:flex;align-items:center;gap:11px;
  min-width:236px;
  text-decoration:none;
  color:var(--ink);
}
.registry-brand img{
  width:38px;height:38px;border-radius:8px;
  box-shadow:0 4px 12px rgba(14,95,199,.25);
}
.registry-brand span{
  font-size:16px;font-weight:700;
  color:var(--ink);letter-spacing:-.01em;
  white-space:nowrap;
}
.registry-brand small{
  display:block;font-size:10px;color:var(--faint);letter-spacing:.04em;
}

/* Переключатель организации */
.org-pick, .registry-org{
  display:flex;align-items:center;gap:9px;
  height:40px;padding:0 12px 0 11px;
  border:1px solid var(--line);border-radius:var(--radius-sm);
  background:var(--surface-2);
  cursor:pointer;color:var(--ink-2);font-weight:600;font-size:12.5px;
  transition:border-color .15s,background .15s;
  min-height:40px;
}
.org-pick:hover, .registry-org:hover{
  border-color:var(--blue-line);background:#fff;
}
.registry-org{
  width:224px;max-width:224px;flex:0 1 224px;
  padding:7px 11px;min-height:48px;overflow:hidden
}
.registry-org-icon{
  width:30px;height:30px;display:grid;place-items:center;flex:0 0 30px;
  border-radius:8px;background:var(--blue-soft);color:var(--blue);
}
.registry-org-icon .ui-icon{width:17px;height:17px}
.registry-org-content{min-width:0;flex:1}
.registry-org-content.has-select{position:relative;padding-right:18px}
.registry-org-content>small{
  display:block;margin-bottom:1px;color:var(--faint);font-size:9px;
  text-transform:uppercase;letter-spacing:.04em;
}
.registry-org-content>strong{
  display:block;overflow:hidden;color:var(--ink-2);font-size:12px;
  text-overflow:ellipsis;white-space:nowrap;
}
.registry-org select,.registry-org .input-field,.registry-org-select{
  width:100%!important;max-width:100%;padding:0!important;border:0!important;
  background:transparent!important;box-shadow:none!important;
  color:var(--ink-2);font:600 12px var(--font-system)!important;outline:0;
  cursor:pointer;appearance:none;-webkit-appearance:none;
}
.registry-org-chevron{
  position:absolute;right:0;bottom:0;
  width:16px;height:18px;display:grid;place-items:center;
  color:var(--muted);pointer-events:none;
}
.registry-org-chevron .ui-icon{width:13px;height:13px}
.registry-org-select option{color:var(--ink);background:var(--surface);padding:6px;}

/* Глобальный поиск в шапке */
.registry-search, .header-search{
  flex:1;max-width:440px;
  display:flex;align-items:center;gap:9px;
  height:40px;padding:0 13px;
  border:1px solid var(--line);border-radius:var(--radius-sm);
  background:var(--surface-2);color:var(--faint);
  transition:border-color .14s,box-shadow .14s,background .14s;
}
.registry-search:focus-within, .header-search:focus-within{
  border-color:var(--blue-line);background:#fff;
  box-shadow:0 0 0 3px var(--blue-soft);
}
.registry-search input, .header-search input{
  flex:1;border:0;background:transparent;outline:0;
  color:var(--text);font:inherit;font-family:var(--font-system);
}
.registry-search input::placeholder, .header-search input::placeholder{color:var(--faint)}
.kbd{
  padding:1px 6px;border:1px solid var(--line);border-radius:4px;background:#fff;
  font:600 10px var(--font-mono);color:var(--faint);
}

/* Правая часть шапки */
.registry-topbar-space{flex:1}
.registry-header-right, .header-right{
  margin-left:auto;display:flex;align-items:center;gap:10px;
}
.registry-topbar-button, .iconbtn{
  width:38px;height:38px;display:grid;place-items:center;
  border:1px solid var(--line);border-radius:var(--radius-sm);
  background:var(--surface);color:var(--muted);cursor:pointer;
  position:relative;transition:background .15s,color .15s,border-color .15s;
}
.registry-topbar-button:hover, .iconbtn:hover{
  background:var(--surface-2);color:var(--blue);border-color:var(--blue-line);
}
.registry-topbar-button svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}

/* Здоровье системы / индикатор ИИ */
.registry-health, .health{
  display:flex;align-items:center;gap:8px;
  font-size:11.5px;color:var(--muted);font-weight:500;
}
.registry-health .pulse, .health .pulse{
  width:8px;height:8px;border-radius:50%;background:var(--green);
  box-shadow:0 0 0 4px var(--green-bg);
}
.registry-health.ai-health-checking .pulse, .health.ai-health-checking .pulse{
  background:var(--amber);box-shadow:0 0 0 4px var(--amber-bg);
}
.registry-health.ai-health-offline, .health.ai-health-offline{color:var(--red)}
.registry-health.ai-health-offline .pulse, .health.ai-health-offline .pulse{
  background:var(--red);box-shadow:0 0 0 4px var(--red-bg);
}

/* Пользователь */
.registry-user, .user{
  display:flex;align-items:center;gap:10px;
  padding:5px 10px 5px 6px;border-radius:var(--radius-sm);
  border:1px solid transparent;cursor:pointer;
  transition:background .15s,border-color .15s;
  margin-left:4px;padding-left:14px;
}
.registry-user{border-left:1px solid var(--line)}
.registry-user:hover, .user:hover{background:var(--surface-2);border-color:var(--line)}
.registry-avatar, .avatar{
  width:34px;height:34px;display:grid;place-items:center;border-radius:9px;
  background:linear-gradient(135deg,var(--blue),#3e72e4);
  color:#fff;font-weight:700;font-size:14px;
}
.registry-user-copy b{display:block;font-size:12.5px;color:var(--ink);line-height:1.2}
.registry-user-copy span{display:block;font-size:10px;color:var(--faint)}
.user b{display:block;font-size:12px;color:var(--ink)}
.user small{display:block;font-size:10px;color:var(--faint)}
.registry-logout{
  display:inline-flex;align-items:center;gap:6px;
  padding:7px 9px;border:0;border-radius:8px;background:transparent;
  color:var(--muted);font:500 11px var(--font-system);cursor:pointer;
}
.registry-logout:hover{background:var(--surface-2);color:var(--blue)}
.registry-logout .ui-icon{width:14px;height:14px}

/* ============================================================
   ГОРИЗОНТАЛЬНАЯ НАВИГАЦИЯ (замена левого сайдбара)
   ============================================================ */
.registry-nav{
  height:var(--nav-h);
  display:flex;align-items:stretch;
  padding:0 30px;gap:2px;
  background:var(--surface);
  border-bottom:1px solid var(--line);
  position:sticky;top:var(--header-h);z-index:39;
}
.registry-nav-item{
  display:flex!important;align-items:center!important;justify-content:center!important;
  gap:8px;padding:0 17px!important;
  color:var(--muted);font-weight:600;font-size:13px;
  border-bottom:3px solid transparent;border-top:3px solid transparent;
  margin-bottom:-1px;cursor:pointer;
  background:transparent!important;border-radius:0!important;
  border-left:0!important;border-right:0!important;
  text-decoration:none;
  transition:color .15s;
  min-height:46px;
}
.registry-nav-item:hover{color:var(--ink);background:transparent!important}
.registry-nav-item.active{
  color:var(--blue)!important;
  border-bottom-color:var(--blue);
  background:transparent!important;
}
.registry-nav-icon{
  width:30px;height:30px;display:grid;place-items:center;flex:0 0 30px;
  border-radius:8px;color:inherit;
}
.registry-nav-item.active .registry-nav-icon{
  background:var(--blue-soft);
}
.registry-nav-icon svg{width:18px;height:18px;fill:none}
/* Счётчик в навигации */
.registry-nav-item .nav-count{
  min-width:19px;height:19px;padding:0 6px;display:grid;place-items:center;
  border-radius:10px;background:var(--surface-2);color:var(--faint);
  font-size:10.5px;font-weight:700;
}
.registry-nav-item.active .nav-count{background:var(--blue-soft);color:var(--blue)}
/* Пункт, отжатый вправо */
.registry-nav-item.spacer{margin-left:auto;color:var(--blue)}
.registry-nav-item.spacer:before{
  content:"";width:1px;height:20px;background:var(--line);margin-right:14px;
}

/* Подпись «Организация» и статус — теперь в шапке, но класс сохранён */
.registry-sidebar-label{display:none}
.registry-sidebar-status{
  display:none;
}

/* ============================================================
   Рабочая область
   ============================================================ */
.registry-workspace{
  min-width:0;min-height:0;flex:1;
  display:flex;flex-direction:column;
}
.registry-main-row{
  min-width:0;min-height:0;display:flex;flex:1;
}
.registry-home-content, .registry-page-content{
  min-width:0;flex:1;overflow-y:auto;
  width:100%;max-width:1680px;margin:0 auto;
  padding:22px 30px 56px;
}
.registry-collision-content, .collision-content{padding:22px 30px 56px}

/* ============================================================
   Заголовок страницы + хлебные крошки
   ============================================================ */
.registry-crumbs, .crumbs{
  display:flex;align-items:center;gap:8px;
  font-size:11.5px;color:var(--faint);margin-bottom:9px;
}
.registry-crumbs b, .crumbs b{color:var(--ink-2);font-weight:600}
.registry-crumbs .sep, .crumbs .sep{opacity:.5}

.registry-heading{
  display:flex;align-items:flex-end;justify-content:space-between;
  gap:20px;margin-bottom:18px;
}
.registry-heading-eyebrow, .eyebrow{
  display:inline-flex;align-items:center;gap:8px;
  color:var(--blue);font-size:10px;font-weight:700;
  text-transform:uppercase;letter-spacing:.1em;
  margin-bottom:5px;
}
.registry-heading h1{
  margin:6px 0 3px;
  color:var(--ink);font-size:25px;line-height:1.1;letter-spacing:-.025em;
}
.registry-heading p{margin:0;color:var(--muted);font-size:12.5px}
.registry-heading .actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap}

/* ============================================================
   Метрики (gov: цветная левая кайма)
   ============================================================ */
.gov-metrics, .metrics{
  display:grid;grid-template-columns:repeat(4,1fr);gap:14px;margin-bottom:18px;
}
.gov-metrics.cols-3, .metrics.cols-3{grid-template-columns:repeat(3,1fr)}

.gov-metric, .metric, .stat-card{
  position:relative;min-height:96px;
  padding:16px 18px 14px 22px;
  background:var(--surface);border:1px solid var(--line);
  border-radius:var(--radius);box-shadow:var(--shadow);overflow:hidden;
}
.gov-metric:before, .metric:before{
  content:"";position:absolute;left:0;top:0;bottom:0;width:4px;background:var(--blue);
}
.gov-metric.green:before, .metric.green:before{background:var(--green)}
.gov-metric.amber:before, .metric.amber:before{background:var(--amber)}
.gov-metric.violet:before, .metric.violet:before{background:var(--violet)}
.gov-metric.red:before, .metric.red:before{background:var(--red)}
.stat-card::after{
  content:"";position:absolute;right:-34px;top:-52px;width:120px;height:120px;
  border-radius:50%;background:rgba(14,95,199,.055);
}
.gov-metric .top, .metric .top{
  display:flex;align-items:center;justify-content:space-between;margin-bottom:8px;
}
.gov-metric .label, .metric .label, .stat-card .stat-label{
  font-size:10.5px;color:var(--faint);font-weight:600;
  text-transform:uppercase;letter-spacing:.05em;
}
.gov-metric .micon, .metric .micon{
  width:30px;height:30px;display:grid;place-items:center;border-radius:8px;
  background:var(--blue-soft);color:var(--blue);
}
.metric.green .micon{background:var(--green-bg);color:var(--green)}
.metric.amber .micon{background:var(--amber-bg);color:var(--amber)}
.metric.violet .micon{background:var(--violet-bg);color:var(--violet)}
.metric.red .micon{background:var(--red-bg);color:var(--red)}
.gov-metric .val, .metric .val, .stat-card .stat-value{
  font-size:26px;font-weight:700;color:var(--ink);line-height:1;
  position:relative;z-index:1;
}
.gov-metric .sub, .metric .sub, .stat-card .stat-label{
  margin-top:4px;font-size:11px;color:var(--muted);position:relative;z-index:1;
}
.gov-metric.is-link, .metric.is-link{
  cursor:pointer;transition:transform .1s,box-shadow .15s;
}
.gov-metric.is-link:hover, .metric.is-link:hover{
  box-shadow:var(--shadow-lg);transform:translateY(-1px);
}
.delta{display:inline-flex;align-items:center;gap:2px;font-weight:700;font-size:10.5px}
.delta.up{color:var(--green)} .delta.down{color:var(--red)}
button.stat-card{font:inherit;color:inherit;appearance:none;text-align:left;width:100%;display:block}
button.stat-card:hover{border-color:var(--blue-line);cursor:pointer;box-shadow:var(--shadow-lg)}

/* ============================================================
   Тулбар внутри панели
   ============================================================ */
.registry-toolbar{
  display:flex;align-items:center;gap:8px;
  padding:11px 16px;border-bottom:1px solid var(--line-soft);
  background:var(--surface-2);flex-wrap:wrap;
}
.registry-toolbar>div{flex-wrap:wrap}
.registry-orders-card{overflow:visible;position:relative}
.registry-toolbar-actions{position:relative}
.registry-action-menu{position:relative}
.registry-action-menu>summary{
  list-style:none;display:inline-flex;align-items:center;gap:6px;
  height:34px;cursor:pointer;user-select:none;white-space:nowrap;
}
.registry-action-menu>summary::-webkit-details-marker{display:none}
.registry-action-menu .menu-chevron{transition:transform .15s}
.registry-action-menu[open] .menu-chevron{transform:rotate(180deg)}
.registry-action-menu-popover{
  position:absolute;right:0;top:calc(100% + 8px);z-index:35;
  width:270px;padding:6px;
  border:1px solid var(--line);border-radius:10px;
  background:var(--surface);box-shadow:0 14px 38px rgba(25,45,78,.16);
}
.registry-action-menu-popover button{
  width:100%;display:flex;align-items:flex-start;gap:10px;
  border:0;border-radius:7px;background:transparent;color:var(--ink-2);
  padding:9px 10px;text-align:left;cursor:pointer;font:inherit;
}
.registry-action-menu-popover button:hover{background:var(--surface-2)}
.registry-action-menu-popover button>.ui-icon{margin-top:2px;color:var(--blue);flex:0 0 15px}
.registry-action-menu-popover button span{display:flex;flex-direction:column;gap:2px}
.registry-action-menu-popover button b{font-size:12px;font-weight:600;color:var(--ink)}
.registry-action-menu-popover button small{font-size:10.5px;color:var(--faint)}
.registry-empty-state.flex{
  min-height:180px;flex-direction:column;align-items:center;justify-content:center;gap:3px;
}
.registry-empty-state svg{margin:0 0 8px!important}
.registry-empty-state p{margin:0;line-height:1.45}

/* ============================================================
   Таблицы
   ============================================================ */
.table-header{
  font-size:10.5px;font-weight:700;color:#435169;
  text-transform:uppercase;letter-spacing:.04em;
  padding:10px 14px;white-space:nowrap;
}
.table-row-hover:hover{background:var(--row-hover)}

/* ============================================================
   ИИ-панель справа (чат-ассистент)
   ============================================================ */
.registry-ai-panel, #ai-chat-panel{
  position:sticky;top:calc(var(--header-h) + var(--nav-h));align-self:start;
  height:calc(100vh - var(--header-h) - var(--nav-h) - 44px);
  border-left:1px solid var(--line);
  background:linear-gradient(180deg,#fbfcff,#f7faff);
  display:flex;flex-direction:column;overflow:hidden;
  width:350px;min-width:350px;flex-shrink:0;
  box-shadow:-12px 0 30px rgba(35,57,91,.06);
}
#ai-chat-panel{transition:width .25s ease,min-width .25s ease,opacity .2s ease}
#ai-chat-panel.collapsed{width:0!important;min-width:0!important;overflow:hidden;opacity:0;border-left:none}
#ai-chat-panel>div:first-child{min-height:58px!important}

.chat-fab{
  position:fixed;right:16px;bottom:24px;
  width:44px;height:44px;border-radius:50%;
  background:var(--blue);color:#fff;border:0;cursor:pointer;
  box-shadow:0 2px 8px rgba(0,0,0,.15);
  display:none;align-items:center;justify-content:center;z-index:40;
  transition:transform .2s;
}
.chat-fab:hover{transform:scale(1.08)}
.chat-fab.visible{display:flex}
.chat-bubble-user{background:var(--blue);color:#fff;border-radius:16px 16px 4px 16px;padding:8px 14px;font-size:13px;max-width:85%}
.chat-bubble-ai{background:#f1f0ef;color:var(--text);border-radius:16px 16px 16px 4px;padding:8px 14px;font-size:13px;max-width:85%;white-space:pre-wrap}

/* ============================================================
   Bulk-бар (массовые действия над выбранными строками)
   ============================================================ */
.bulkbar{
  position:absolute;left:50%;top:13px;transform:translateX(-50%);z-index:5;
  display:none;align-items:center;gap:14px;
  height:40px;padding:0 16px;border-radius:10px;
  background:var(--ink);color:#fff;box-shadow:var(--shadow-lg);
}
.bulkbar.show{display:flex}
.bulkbar b{font-weight:700}
.bulkbar .sep{width:1px;height:18px;background:rgba(255,255,255,.18)}
.bulkbar button{
  background:transparent;border:0;color:#cdd6e6;
  font-weight:600;font-size:12px;cursor:pointer;
  display:inline-flex;align-items:center;gap:6px;
  padding:5px 8px;border-radius:6px;
}
.bulkbar button:hover{background:rgba(255,255,255,.1);color:#fff}

/* ============================================================
   Stepper (для модуля коллизий / анализа)
   ============================================================ */
.stepper{display:flex;align-items:center;gap:4px;flex-wrap:wrap}
.step{display:flex;align-items:center;gap:9px;padding:7px 12px;border-radius:var(--radius-sm);
  cursor:pointer;transition:background .12s;border:1px solid transparent}
.step:hover{background:var(--surface)}
.step.done .step-num{background:var(--green);color:#fff;border-color:var(--green)}
.step.active{background:var(--blue-soft);border-color:var(--blue-line)}
.step.active .step-num{background:var(--blue);color:#fff;border-color:var(--blue)}
.step.active .step-label{color:var(--blue);font-weight:600}
.step-num{width:26px;height:26px;display:grid;place-items:center;border-radius:50%;
  border:1.5px solid var(--line);background:var(--surface);color:var(--faint);
  font-weight:700;font-size:12px;flex:0 0 26px}
.step-label{font-size:12px;font-weight:600;color:var(--muted)}
.step.done .step-label{color:var(--ink-2)}
.step-arr{color:var(--line);margin:0 2px}

/* ============================================================
   Dropzone
   ============================================================ */
.dropzone{
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;
  text-align:center;padding:38px 24px;
  border:1.5px dashed var(--blue-line);border-radius:var(--radius);
  background:var(--blue-soft);cursor:pointer;
  transition:background .15s,border-color .15s;color:var(--ink-2);
}
.dropzone:hover{background:#e1ecff;border-color:var(--blue)}

/* ============================================================
   Адаптивность
   ============================================================ */
@media(max-width:1180px){
  .gov-metrics,.metrics{grid-template-columns:repeat(2,1fr)}
  .gov-metrics.cols-3,.metrics.cols-3{grid-template-columns:repeat(3,1fr)}
}
@media(max-width:1050px){
  .registry-search,.header-search{display:none}
  .registry-nav{overflow-x:auto;padding:0 16px}
  .registry-brand{min-width:auto}
  .registry-page-content,.registry-home-content{padding:22px 16px 48px}
}
@media(max-width:760px){
  .registry-topbar,.registry-header{padding:0 16px;gap:12px}
  .registry-brand small{display:none}
  .registry-user-copy,.registry-topbar-context{display:none}
  #ai-chat-panel{
    position:fixed;inset:0 0 0 auto;z-index:80;height:100vh;max-width:92vw;
  }
  .gov-metrics,.metrics{grid-template-columns:1fr}
}
