/* styles.css — merge_cont UI
   Все значения — через var(--...) из design-tokens.css */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  min-height: 100vh;
}

button, input, select, textarea {
  font: inherit;
}

/* ===================================================
   LAYOUT: sidebar + main
   =================================================== */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===================================================
   SIDEBAR
   =================================================== */

.sidebar {
  width: 220px;
  min-height: 100vh;
  background: linear-gradient(180deg, #0f172a, #111827);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  flex-shrink: 0;
  z-index: 10;
}

.sidebar-brand {
  padding: 20px 18px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  display: grid;
  gap: 4px;
}

.sidebar-eyebrow {
  font-size: var(--font-size-eyebrow);
  font-weight: var(--font-weight-strong);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #475569;
  margin: 0;
}

.sidebar-title {
  font-size: 0.92rem;
  font-weight: var(--font-weight-strong);
  color: #f1f5f9;
  line-height: 1.3;
}

.sidebar-nav {
  padding: 10px 0;
  display: flex;
  flex-direction: column;
}

.sidebar-link {
  display: block;
  padding: 10px 18px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #94a3b8;
  text-decoration: none;
  transition: background var(--transition-base), color var(--transition-base);
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f1f5f9;
}

.sidebar-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.07);
  margin: 4px 0;
}

.sidebar-portal-btn {
  margin: 10px 12px;
  min-height: 38px;
  padding: 0 14px;
  background: rgba(15, 118, 110, 0.15);
  border: 1px solid rgba(15, 118, 110, 0.32);
  color: #5eead4;
  font-size: 0.85rem;
  font-weight: var(--font-weight-label);
  border-radius: var(--radius-md);
  box-shadow: none;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-base), border-color var(--transition-base);
}

.sidebar-portal-btn:hover {
  background: rgba(15, 118, 110, 0.25);
  border-color: rgba(15, 118, 110, 0.5);
  filter: none;
  transform: none;
  color: #99f6e4;
}

.sidebar-status {
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  display: grid;
  gap: 10px;
}

.sidebar-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
}

.sidebar-status-row > span:first-child {
  color: #475569;
  flex-shrink: 0;
}

.sidebar-status-row > span:last-child {
  color: #94a3b8;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

.sidebar .pill {
  font-size: 0.72rem;
  padding: 3px 8px;
}

/* ===================================================
   MODAL / DRAWER (настройки портала)
   =================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-panel {
  width: 480px;
  max-width: calc(100vw - 220px);
  height: 100vh;
  overflow-y: auto;
  background: var(--color-surface-solid);
  border-right: 1px solid var(--color-border);
  box-shadow: 8px 0 40px rgba(15, 23, 42, 0.18);
  padding: 28px 24px;
  display: grid;
  gap: 20px;
  align-content: start;
  margin-left: 220px;
  animation: slideInDrawer var(--transition-slow) both;
}

@keyframes slideInDrawer {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.modal-close {
  min-height: 32px;
  width: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--color-border-strong);
  color: var(--color-text-muted);
  font-size: 1rem;
  box-shadow: none;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--color-neutral-bg);
  filter: none;
  transform: none;
  color: var(--color-text);
}

.modal-footer {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ===================================================
   MAIN CONTENT
   =================================================== */

.main-content {
  flex: 1;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, var(--color-bg-gradient-1), transparent 32%),
    radial-gradient(circle at bottom right, var(--color-bg-gradient-2), transparent 30%),
    var(--color-bg);
}

.app-shell {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 24px 48px;
  display: grid;
  gap: 20px;
}

/* ===================================================
   TYPOGRAPHY
   =================================================== */

h1, h2, h3, h4, p {
  margin: 0;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: var(--font-weight-strong);
  line-height: 1.05;
  color: var(--color-text-strong);
}

h2 {
  font-size: 1.15rem;
  font-weight: var(--font-weight-label);
  color: var(--color-text-strong);
}

h3 {
  font-size: 1rem;
  font-weight: var(--font-weight-label);
  color: var(--color-text-strong);
}

.eyebrow {
  font-size: var(--font-size-eyebrow);
  font-weight: var(--font-weight-strong);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.subtle {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ===================================================
   SECTION ANIMATION
   =================================================== */

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel-section {
  display: none;
}

.panel-section.section--visible {
  display: block;
  animation: fadeSlideIn var(--transition-slow) both;
}

/* ===================================================
   PANELS / CARDS
   =================================================== */

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(14px);
  padding: 24px;
  display: grid;
  gap: 16px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-head > div {
  display: grid;
  gap: 2px;
}

.result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ===================================================
   STACK / EMPTY STATE
   =================================================== */

.stack {
  display: grid;
  gap: 14px;
}

.empty-state {
  min-height: 100px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--color-text-muted);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  font-size: 0.9rem;
}

/* ===================================================
   FORM
   =================================================== */

.field {
  display: grid;
  gap: 6px;
}

.field > span {
  font-size: 0.85rem;
  font-weight: var(--font-weight-label);
  color: var(--color-text-strong);
}

input, select {
  width: 100%;
  min-height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.38);
  background: var(--color-surface-solid);
  padding: 10px 14px;
  color: var(--color-text);
}

input:focus, select:focus {
  outline: 2px solid rgba(15, 118, 110, 0.14);
  border-color: rgba(15, 118, 110, 0.42);
  outline-offset: 0;
}

/* ===================================================
   BUTTONS
   =================================================== */

button {
  cursor: pointer;
  min-height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-dark));
  color: var(--color-surface-solid);
  font-weight: var(--font-weight-strong);
  box-shadow: var(--shadow-button);
  transition: filter var(--transition-base), transform var(--transition-base);
}

button:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

button:focus {
  outline: 2px solid rgba(15, 118, 110, 0.3);
  outline-offset: 2px;
}

button.ghost {
  background: var(--color-surface-solid);
  border: 1px solid var(--color-border-strong);
  color: var(--color-text-muted);
  box-shadow: none;
}

button.ghost:hover {
  filter: none;
  background: var(--color-neutral-bg);
  transform: none;
}

.inline-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* ===================================================
   PORTAL GRID (в drawer)
   =================================================== */

.portal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.portal-grid-wide {
  grid-column: 1 / -1;
}

/* ===================================================
   PILLS
   =================================================== */

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: var(--font-weight-label);
  white-space: nowrap;
}

.pill.neutral  { background: var(--color-neutral-bg);  color: var(--color-neutral);  }
.pill.info     { background: var(--color-info-bg);     color: var(--color-info);     }
.pill.success  { background: var(--color-success-bg);  color: var(--color-success);  }
.pill.warning  { background: var(--color-warning-bg);  color: var(--color-warning);  }
.pill.danger   { background: var(--color-danger-bg);   color: var(--color-danger);   }

/* ===================================================
   BANNERS
   =================================================== */

.banner {
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  padding: 12px 14px;
  line-height: 1.45;
  font-size: 0.9rem;
}

.banner.error {
  background: var(--color-danger-bg);
  border-color: rgba(185, 28, 28, 0.2);
  color: var(--color-danger);
}

.banner.info {
  background: var(--color-info-bg);
  border-color: rgba(15, 118, 110, 0.2);
  color: var(--color-info);
}

.hidden {
  display: none !important;
}

/* ===================================================
   TAGS
   =================================================== */

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--color-neutral-bg);
  color: var(--color-text);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.tag-row, .group-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ===================================================
   CONTENT CARDS (рендерятся из app.js)
   =================================================== */

.group-card,
.summary-card,
.list-card,
.result-card {
  background: var(--color-surface-solid);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.group-card {
  display: grid;
  gap: 12px;
}

.summary-card h3,
.list-card h3,
.result-card h3 {
  margin-bottom: 10px;
}

.candidate-list,
.warning-list,
.signal-list,
.audit-list,
.contact-list {
  display: grid;
  gap: 10px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px;
  background: var(--color-surface-solid);
  display: grid;
  gap: 8px;
}

.item-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}

.key-value {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.key-value span {
  color: var(--color-text-muted);
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

pre.mono {
  background: #f8fafc;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 0.8rem;
}

.muted-block {
  color: var(--color-text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

/* ===================================================
   RESPONSIVE
   =================================================== */

@media (max-width: 760px) {
  .app-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
  }

  .sidebar-brand { border: none; padding: 0; }
  .sidebar-nav { flex-direction: row; padding: 0; }
  .sidebar-nav .sidebar-link { padding: 6px 12px; }
  .sidebar-divider { display: none; }
  .sidebar-portal-btn { margin: 0; }
  .sidebar-status { margin-top: 0; border: none; padding: 0; flex-direction: row; }

  .modal-panel {
    margin-left: 0;
    max-width: 100vw;
    height: auto;
    max-height: 90vh;
  }

  .summary-grid,
  .detail-grid,
  .portal-grid {
    grid-template-columns: 1fr;
  }

  .inline-actions button {
    width: 100%;
  }

  .app-shell {
    padding: 16px 16px 32px;
    gap: 16px;
  }
}
