/* МАЯК · Grant Wizard styles */

.grant-wizard {
  width: min(1080px, 100%);
  max-height: calc(100vh - 64px);
  background: var(--paper);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: var(--r-4);
  box-shadow: var(--shadow-lg);
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

/* HEAD */
.gw-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.gw-title {
  margin: 4px 0 0;
  font-size: 22px; font-weight: 600; letter-spacing: -0.01em;
}

/* BODY = form | preview */
.gw-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  min-height: 0;
  overflow: hidden;
}

.gw-form {
  padding: 18px 22px 22px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 22px;
}
.gw-preview-shell {
  border-left: 1px solid var(--line);
  background: var(--bg-sub);
  padding: 18px;
  overflow-y: auto;
  min-height: 0;
}

/* sections */
.gw-section {
  display: flex; flex-direction: column; gap: 10px;
}
.gw-section-head {
  display: flex; align-items: flex-start; gap: 10px;
}
.gw-step-num {
  flex-shrink: 0;
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  margin-top: 1px;
}
.gw-section-head h4 {
  margin: 0;
  font-size: 14.5px; font-weight: 600; letter-spacing: -0.005em;
}
.gw-section-head p {
  margin: 1px 0 0;
  font-size: 12.5px;
}

/* segmented toggle */
.seg-toggle {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-sub);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  align-self: flex-start;
}
.seg-tab {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 12px;
  background: transparent; border: 0;
  color: var(--muted);
  font-size: 12.5px; font-weight: 500;
  border-radius: var(--r-1);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.seg-tab:hover { color: var(--fg); }
.seg-tab.active {
  background: var(--paper);
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}

/* locked pill — pre-filled subject/target */
.locked-pill {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: var(--accent-bg);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-2);
}
.locked-pill-icon {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--paper);
  border-radius: 6px;
  color: var(--accent);
}
.locked-pill-text { flex: 1; min-width: 0; }
.locked-pill-title { font-weight: 600; font-size: 13.5px; }

/* search input */
.gw-search {
  display: flex; align-items: center; gap: 6px;
  padding: 0 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  color: var(--muted);
  /* override .us-search's `flex: 0 1 280px`: in the wizard the search box lives
     in a column flex-context (.gw-section), where that basis becomes HEIGHT and
     blows the field up to ~280px tall. Pin it to its own single-line height. */
  flex: 0 0 auto;
  height: 36px;
}
.gw-search input {
  border: 0; outline: 0; background: transparent;
  flex: 1; min-width: 0;
  font-size: 13px; color: var(--fg);
}
.gw-search input:focus { box-shadow: none; }

/* pick list */
.gw-picklist {
  display: flex; flex-direction: column;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--paper);
}
.gw-pick {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background var(--t-fast);
}
.gw-pick:last-child { border-bottom: 0; }
.gw-pick:hover { background: var(--bg-sub); }
.gw-pick.on { background: var(--accent-bg); }
.gw-pick input { accent-color: var(--accent); flex-shrink: 0; }
.gw-pick-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.gw-pick-name { font-size: 13px; font-weight: 500; }

/* selected chips above the picker */
.gw-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 6px 0;
}
.chip-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px;
  background: transparent;
  border: 0;
  border-radius: 999px;
  margin-left: 2px;
  cursor: pointer;
  opacity: .7;
  color: inherit;
}
.chip-x:hover { opacity: 1; background: rgba(0,0,0,.06); }

/* level cards */
.gw-level-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.gw-level-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  padding: 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.gw-level-card:hover { border-color: var(--line-strong); }
.gw-level-card.active {
  border-color: var(--accent);
  background: var(--accent-bg);
  box-shadow: 0 0 0 1px var(--accent);
}
.gw-level-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.gw-level-title { font-weight: 600; font-size: 13px; }
.gw-level-desc {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

/* level pills (also reused by access tab) */
.level-pill {
  display: inline-flex; align-items: center; justify-content: center;
  height: 22px; min-width: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
}
.level-pill.level-A { background: var(--danger-bg); color: var(--danger); }
.level-pill.level-E { background: var(--accent-bg); color: var(--accent); }
.level-pill.level-W { background: var(--warn-bg); color: var(--warn); }
.level-pill.level-R { background: var(--accent-bg); color: var(--accent); }
.level-pill.pale { opacity: 0.55; }

/* expiry chips */
.gw-expiry {
  display: flex; flex-wrap: wrap; gap: 4px;
  align-items: center;
}

/* PREVIEW */
.gw-preview {
  display: flex; flex-direction: column; gap: 14px;
}
.gw-preview-head {
  display: flex; justify-content: space-between; gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--line);
}
.gw-preview-stats { display: flex; gap: 8px; }
.gw-preview-stats .stat-cell.sm { padding: 6px 10px; }
.accent-text { color: var(--accent); }

.gw-preview-list {
  display: flex; flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--paper);
  overflow: hidden;
}
.gw-prev-row {
  display: grid;
  grid-template-columns: 14px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.gw-prev-row:last-child { border-bottom: 0; }
.gw-prev-row.changed {
  background: linear-gradient(90deg, var(--accent-bg) 0%, transparent 100%);
}
.gw-prev-marker { display: flex; align-items: center; justify-content: center; }
.gw-prev-name { min-width: 0; overflow: hidden; }
.gw-prev-level { display: inline-flex; align-items: center; gap: 4px; }
.gw-prev-source {
  font-size: 10.5px;
  max-width: 120px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pill-new {
  display: inline-flex; align-items: center;
  height: 16px; padding: 0 5px;
  background: var(--accent); color: var(--accent-fg);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .05em;
  margin-left: 4px;
}

.gw-preview-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px;
  text-align: center;
  min-height: 200px;
  color: var(--muted);
}
.gw-preview-empty p { margin: 0; font-size: 13px; }
.gw-preview-empty p:first-of-type { color: var(--fg); font-weight: 500; }

.gw-hint { margin-top: auto; }

/* FOOT */
.gw-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: var(--bg-sub);
}
.btn.disabled, .btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* responsive: preview drops below at narrow */
@media (max-width: 960px) {
  .grant-wizard { width: min(680px, 100%); }
  .gw-body { grid-template-columns: 1fr; }
  .gw-preview-shell { border-left: 0; border-top: 1px solid var(--line); max-height: 320px; }
  .gw-level-grid { grid-template-columns: 1fr; }
}
