/* LPR-OSIENT — строгий практичный UI */

.osient-page {
  max-width: 960px;
}

.osient-page .page-intro h2 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.osient-page .page-intro p {
  margin: 0 0 0.35rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.osient-page .page-intro p:last-child {
  margin-bottom: 1.25rem;
}

.osient-page .osient-db-total {
  margin-top: 0.35rem;
  font-size: 0.9rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.osient-panel {
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.35);
  padding: 1rem 1.1rem;
  margin-bottom: 0.85rem;
}

.osient-panel h3 {
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.osient-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem 1rem;
}

.osient-field label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.osient-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.osient-check {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}

.osient-check input {
  width: 1rem;
  height: 1rem;
  accent-color: #64748b;
  flex-shrink: 0;
}

.osient-check:has(input:checked) {
  background: rgba(148, 163, 184, 0.14);
  border-color: rgba(148, 163, 184, 0.4);
  color: #f1f5f9;
}

.osient-links {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.osient-link {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(51, 65, 85, 0.55);
}

.osient-link:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.osient-link.is-open {
  padding-bottom: 0.25rem;
}

.osient-link-toggle {
  font-weight: 500;
  width: fit-content;
  max-width: 100%;
}

.osient-link-toggle:has(input:checked),
.osient-link.is-open > .osient-link-toggle {
  background: rgba(100, 116, 139, 0.22);
  border-color: #64748b;
  color: #f8fafc;
}

.osient-drawer {
  margin: 0.15rem 0 0.25rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid #475569;
  border-radius: 6px;
  background: #0f172a;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  overflow: visible;
}

.osient-link[data-link="osient"] .osient-drawer {
  max-height: 360px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 116, 139, 0.7) rgba(15, 23, 42, 0.95);
}

.osient-link[data-link="osient"] .osient-drawer::-webkit-scrollbar {
  width: 8px;
}

.osient-link[data-link="osient"] .osient-drawer::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.7);
  border-radius: 4px;
}

.osient-drawer[hidden] {
  display: none !important;
}

/* Multi-select panel inside drawer must not be clipped by drawer scroll */
.osient-drawer .osient-field,
.osient-drawer .slice-ms-field {
  overflow: visible;
  position: relative;
  z-index: 2;
}

.osient-drawer-title {
  font-size: 0.8rem;
  font-weight: 600;
  margin: 0 0 0.65rem;
  color: var(--text-muted);
}

.osient-contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.35rem 0.5rem;
  align-items: stretch;
}

.osient-contact-grid .osient-check {
  margin: 0;
}

.osient-age {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.osient-age input[type="number"] {
  width: 4.5rem;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
}

.osient-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  margin-top: 0.25rem;
}

.osient-count {
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.osient-count .muted {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.osient-count.is-counting {
  color: var(--text-muted);
}

.osient-count-wait {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.osient-count-spinner {
  width: 0.85rem;
  height: 0.85rem;
  border: 2px solid rgba(148, 163, 184, 0.35);
  border-top-color: #94a3b8;
  border-radius: 50%;
  animation: osient-spin 0.7s linear infinite;
  flex-shrink: 0;
}

.osient-count-elapsed {
  min-width: 2.5rem;
}

@keyframes osient-spin {
  to {
    transform: rotate(360deg);
  }
}

.osient-status {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-height: 1.2em;
}

.osient-status.is-error {
  color: #f87171;
}

.osient-sub {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.osient-sub-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

/* --- Multi-select (география / категории) --- */
.osient-page {
  --osient-ms-accent: #94a3b8;
  --osient-ms-selected-bg: rgba(148, 163, 184, 0.16);
  --osient-ms-scroll-thumb: rgba(100, 116, 139, 0.7);
  --osient-ms-scroll-track: rgba(15, 23, 42, 0.95);
}

.osient-panel,
.osient-field,
.osient-grid {
  overflow: visible;
}

.osient-page .slice-ms-field {
  position: relative;
  width: 100%;
}

.osient-page .slice-ms-trigger {
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.85rem;
  font-size: 0.875rem;
  border-radius: var(--radius-sm, 6px);
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.75);
  color: var(--text);
  transition: border-color 0.12s, background 0.12s;
}

.osient-page .slice-ms-trigger:hover {
  border-color: #64748b;
  background: rgba(15, 23, 42, 0.95);
}

.osient-page .ms-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 40;
  padding: 0.55rem;
  background: #0f172a;
  border: 1px solid #475569;
  border-radius: 6px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}

.osient-page .ms-panel.hidden {
  display: none !important;
}

.osient-page .ms-search {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 0.45rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 6px);
  background: rgba(2, 6, 23, 0.7);
  color: var(--text);
  font-size: 0.85rem;
}

.osient-page .ms-list {
  max-height: 260px;
  overflow-y: auto;
  overflow-x: hidden;
  margin-bottom: 0.45rem;
  padding-right: 0.15rem;
  scrollbar-width: thin;
  scrollbar-color: var(--osient-ms-scroll-thumb) var(--osient-ms-scroll-track);
}

.osient-page .ms-list::-webkit-scrollbar {
  width: 8px;
}

.osient-page .ms-list::-webkit-scrollbar-track {
  background: var(--osient-ms-scroll-track);
  border-radius: 4px;
}

.osient-page .ms-list::-webkit-scrollbar-thumb {
  background: var(--osient-ms-scroll-thumb);
  border-radius: 4px;
  border: 2px solid var(--osient-ms-scroll-track);
}

.osient-page .ms-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.45rem 0.4rem 1.85rem;
  margin: 0 0 2px;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
  transition: background 0.1s, border-color 0.1s;
}

.osient-page .ms-row:hover {
  background: rgba(148, 163, 184, 0.08);
}

.osient-page .ms-row .ms-cb {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.osient-page .ms-row::before {
  content: "";
  position: absolute;
  left: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 3px;
  border: 1.5px solid #64748b;
  background: rgba(15, 23, 42, 0.9);
  box-sizing: border-box;
}

.osient-page .ms-row.is-selected,
.osient-page .ms-row:has(.ms-cb:checked) {
  background: var(--osient-ms-selected-bg);
  border-color: rgba(148, 163, 184, 0.45);
  color: #f1f5f9;
}

.osient-page .ms-row.is-selected::before,
.osient-page .ms-row:has(.ms-cb:checked)::before {
  background: #64748b;
  border-color: #94a3b8;
}

.osient-page .ms-row.is-selected::after,
.osient-page .ms-row:has(.ms-cb:checked)::after {
  content: "";
  position: absolute;
  left: 0.7rem;
  top: 50%;
  width: 0.28rem;
  height: 0.5rem;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: translateY(-60%) rotate(45deg);
}

.osient-page .ms-row__txt {
  flex: 1;
  min-width: 0;
  line-height: 1.3;
  word-break: break-word;
}

.osient-page .ms-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
}

.osient-page .ms-actions .btn {
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
}

.osient-page .ms-note {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
}

/* --- Финансы --- */
.osient-fin-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(180px, 1fr);
  gap: 0.5rem 1rem;
  align-items: start;
  margin-bottom: 0.75rem;
}

.osient-fin-meta {
  min-width: 0;
}

.osient-fin-label {
  font-size: 0.85rem;
  color: var(--text);
}

.osient-fin-hint {
  margin: 0.25rem 0 0;
  font-size: 0.72rem;
  line-height: 1.35;
  max-width: 36rem;
}

.osient-fin-range {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.osient-fin-range input[type="number"],
.osient-fin-years input[type="number"] {
  width: 6.5rem;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
}

.osient-fin-years {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --- Конструктор доп. метрик --- */
.osient-fin-ctor-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}

.osient-fin-ctor-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.4fr) minmax(160px, 1fr) auto;
  gap: 0.45rem 0.75rem;
  align-items: center;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.osient-fin-ctor-meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.osient-fin-ctor-code {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.osient-fin-ctor-name {
  font-size: 0.85rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.osient-fin-ctor-remove {
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.osient-fin-ctor-remove:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.osient-fin-ctor-add {
  position: relative;
  display: inline-block;
}

.osient-fin-ctor-picker {
  position: absolute;
  z-index: 20;
  left: 0;
  top: calc(100% + 0.35rem);
  width: min(22rem, 90vw);
  max-height: 16rem;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.osient-fin-ctor-picker input[type="search"] {
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 0.5rem 0.65rem;
  background: transparent;
  color: var(--text);
  font-size: 0.875rem;
  outline: none;
}

.osient-fin-ctor-options {
  overflow-y: auto;
  max-height: 12.5rem;
  padding: 0.25rem;
}

.osient-fin-ctor-opt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  width: 100%;
  padding: 0.4rem 0.55rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-size: 0.85rem;
}

.osient-fin-ctor-opt:hover {
  background: var(--surface-2, rgba(0, 0, 0, 0.04));
}

.osient-fin-ctor-empty {
  padding: 0.65rem;
  font-size: 0.8rem;
}

.osient-sample-cache {
  margin-top: 0.65rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.osient-sample-cache.is-active {
  border-color: rgba(148, 163, 184, 0.45);
  color: var(--text);
}

.osient-sample-cache__title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

.osient-sample-cache__ok {
  text-transform: none;
  letter-spacing: 0;
  color: #86efac;
  font-weight: 600;
}

.osient-sample-cache__empty {
  font-size: 0.8rem;
}

.osient-sample-cache__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  gap: 0.35rem 0.75rem;
  margin: 0;
}

.osient-sample-cache__grid > div {
  min-width: 0;
}

.osient-sample-cache__grid dt {
  margin: 0;
  font-size: 0.68rem;
  color: var(--text-dim);
}

.osient-sample-cache__grid dd {
  margin: 0.05rem 0 0;
  font-variant-numeric: tabular-nums;
}

.osient-sample-cache__grid code {
  font-size: 0.72rem;
}

.osient-sample-cache__wide {
  grid-column: 1 / -1;
}

.osient-count-debug {
  margin-top: 0.65rem;
}

.osient-debug {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.osient-debug summary {
  cursor: pointer;
  user-select: none;
}

.osient-debug-pre {
  margin: 0.45rem 0 0;
  padding: 0.65rem 0.75rem;
  max-height: 18rem;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.72rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.osient-debug-warning {
  margin: 0 0 0.5rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.35;
}

/* --- Export constructor --- */
.osient-export-ctr {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem 0.75rem;
}

.osient-export-ctr label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.osient-export-ctr input {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
}

.osient-export-cols {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.osient-export-col {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--border);
  cursor: grab;
  user-select: none;
}

.osient-export-col:last-child {
  border-bottom: none;
}

.osient-export-col.is-dragging {
  opacity: 0.55;
}

.osient-export-col.is-disabled {
  opacity: 0.55;
  cursor: default;
}

.osient-export-drag {
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1;
}

.osient-export-col-label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.55rem;
  flex: 1;
  cursor: pointer;
  font-size: 0.82rem;
}

.osient-export-col-name {
  color: var(--text);
}

.osient-export-progress {
  margin-top: 0.85rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid #475569;
  border-radius: 6px;
  background: #0f172a;
}

.osient-export-progress[hidden] {
  display: none !important;
}

.osient-export-progress.is-error {
  border-color: rgba(248, 113, 113, 0.55);
}

.osient-export-progress.is-done {
  border-color: rgba(52, 211, 153, 0.45);
}

.osient-export-progress-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.osient-export-progress-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f1f5f9;
}

.osient-export-elapsed {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
}

.osient-export-steps {
  list-style: none;
  margin: 0 0 0.65rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
}

.osient-export-step {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  position: relative;
  padding-left: 0.85rem;
}

.osient-export-step::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.35em;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #475569;
}

.osient-export-step.is-active {
  color: #e2e8f0;
}

.osient-export-step.is-active::before {
  background: #94a3b8;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.25);
}

.osient-export-step.is-done {
  color: #86efac;
}

.osient-export-step.is-done::before {
  background: #34d399;
}

.osient-export-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(71, 85, 105, 0.65);
  overflow: hidden;
}

.osient-export-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #64748b, #94a3b8);
  transition: width 0.35s ease;
}

.osient-export-bar-fill.is-indeterminate {
  width: 40% !important;
  animation: osient-export-indeterminate 1.2s ease-in-out infinite;
}

@keyframes osient-export-indeterminate {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(280%);
  }
}

.osient-export-hint,
.osient-export-done-meta,
.osient-export-error-msg {
  margin-top: 0.55rem;
  font-size: 0.8rem;
}

.osient-export-done-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: baseline;
  color: #e2e8f0;
}

.osient-export-error-msg {
  color: #f87171;
}

.osient-export-progress.is-done .osient-export-bar-fill {
  background: linear-gradient(90deg, #059669, #34d399);
}

@media (max-width: 640px) {
  .osient-fin-row {
    grid-template-columns: 1fr;
  }

  .osient-export-ctr {
    grid-template-columns: 1fr;
  }

  .osient-fin-ctor-row {
    grid-template-columns: 1fr auto;
  }

  .osient-fin-ctor-row .osient-fin-range {
    grid-column: 1 / -1;
  }
}

/* —— Связки (match rebuild) —— */

.osient-match-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.osient-match-stat-grid > div {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.osient-match-stat-grid strong {
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

.osient-match-methods {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.osient-match-chip {
  font-size: 0.75rem;
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--border, #334155);
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.5);
}

.osient-match-chip code {
  font-size: 0.7rem;
  opacity: 0.85;
}

.osient-match-progress-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

#osient-match-progress.is-running #osient-match-progress-title {
  color: #93c5fd;
}

#osient-match-progress.is-done #osient-match-progress-title {
  color: #6ee7b7;
}

#osient-match-progress.is-error #osient-match-progress-title {
  color: #fca5a5;
}

.osient-match-log {
  margin: 0;
  max-height: 22rem;
  overflow: auto;
  padding: 0.65rem 0.75rem;
  font-size: 0.72rem;
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--border, #334155);
  border-radius: 6px;
  background: #0b1220;
  color: #cbd5e1;
}

button[data-match-target].is-running {
  opacity: 0.85;
}

@media (max-width: 640px) {
  .osient-match-stat-grid {
    grid-template-columns: 1fr;
  }
}


