/* NextStep Education — member-directory administration */
.ns-admin-panel {
  padding: 0;
  overflow: visible;
  background: #f8fafc;
}

.ns-admin-shell { min-height: 560px; }

.ns-admin-shell > [data-member-view] { padding: 28px; }

.ns-titlebar,
.ns-workbench-header,
.ns-dialog-header,
.ns-reference-list-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.ns-titlebar { margin-bottom: 22px; }
.ns-titlebar h3,
.ns-workbench-header h3,
.ns-dialog-header h3 { margin: 2px 0 5px; }
.ns-titlebar p,
.ns-workbench-header p,
.ns-dialog-header p { max-width: 720px; font-size: .82rem; line-height: 1.6; }

.ns-eyebrow {
  color: var(--primary);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.ns-title-actions,
.ns-workbench-actions,
.ns-reference-form-actions,
.ns-confirm-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.ns-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.ns-stat {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.ns-stat > span {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 9px;
  color: var(--primary);
  background: var(--primary-bg);
  font-weight: 800;
}

.ns-stat strong { display: block; color: var(--dark); font-size: 1.08rem; line-height: 1.1; }
.ns-stat small { display: block; margin-top: 3px; color: var(--text-secondary); font-size: .66rem; line-height: 1.3; }

.ns-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) repeat(4, minmax(125px, .7fr)) 38px;
  gap: 8px;
  margin-bottom: 16px;
}

.ns-toolbar input,
.ns-toolbar select,
.ns-workbench input,
.ns-workbench select,
.ns-workbench textarea,
.ns-reference-dialog input,
.ns-reference-dialog select,
.ns-reference-dialog textarea,
.ns-confirm-dialog select {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .8rem;
  padding: 9px 10px;
}

.ns-toolbar input:focus,
.ns-toolbar select:focus,
.ns-workbench input:focus,
.ns-workbench select:focus,
.ns-workbench textarea:focus,
.ns-reference-dialog input:focus,
.ns-reference-dialog select:focus,
.ns-reference-dialog textarea:focus {
  outline: 3px solid rgba(37, 99, 235, .12);
  border-color: var(--primary);
}

.ns-search { position: relative; }
.ns-search > span { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); }
.ns-search input { height: 100%; padding-left: 31px; }

.ns-icon-button,
.ns-back,
.ns-dialog-close,
.ns-order-button {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  font: inherit;
}

.ns-icon-button { width: 38px; min-height: 38px; font-size: 1rem; }
.ns-icon-button:hover,
.ns-back:hover,
.ns-dialog-close:hover,
.ns-order-button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }

.ns-list-head,
.ns-member-row {
  display: grid;
  grid-template-columns: minmax(210px, 1.35fr) minmax(190px, 1fr) minmax(180px, .95fr) minmax(205px, auto);
  gap: 14px;
  align-items: center;
}

.ns-list-head {
  padding: 0 14px 8px;
  color: var(--text-secondary);
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.ns-member-row {
  margin-bottom: 9px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  transition: border-color .18s ease, box-shadow .18s ease;
}

.ns-member-row:hover { border-color: #bfdbfe; box-shadow: 0 8px 22px rgba(15, 23, 42, .05); }
.ns-member-identity { display: flex; align-items: center; gap: 11px; min-width: 0; }
.ns-member-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 12px;
  color: #fff;
  font-size: .85rem;
  font-weight: 800;
  letter-spacing: .03em;
}
.ns-member-name { min-width: 0; }
.ns-member-name strong { display: block; overflow: hidden; color: var(--dark); font-size: .84rem; text-overflow: ellipsis; white-space: nowrap; }
.ns-member-name small,
.ns-member-meta,
.ns-account-meta { display: block; margin-top: 3px; color: var(--text-secondary); font-size: .69rem; line-height: 1.45; overflow-wrap: anywhere; }

.ns-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.ns-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  border: 1px solid color-mix(in srgb, var(--ns-color, #64748b) 38%, white);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--ns-color, #475569);
  background: color-mix(in srgb, var(--ns-color, #64748b) 9%, white);
  font-size: .64rem;
  font-weight: 750;
  line-height: 1.25;
}
.ns-tag.primary::before { content: '★'; font-size: .58rem; }
.ns-tag.neutral { --ns-color: #64748b; }
.ns-tag.warning { --ns-color: #b45309; }
.ns-tag.success { --ns-color: #047857; }

.ns-member-actions { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.ns-order-controls { display: inline-flex; gap: 4px; }
.ns-order-button { width: 29px; height: 29px; }
.ns-order-button:disabled { opacity: .35; cursor: not-allowed; }

.ns-loading,
.ns-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  gap: 9px;
  color: var(--text-secondary);
  text-align: center;
  font-size: .82rem;
}
.ns-empty strong { color: var(--dark); font-size: .95rem; }
.ns-spinner { width: 23px; height: 23px; border: 3px solid #dbeafe; border-top-color: var(--primary); border-radius: 50%; animation: ns-spin .8s linear infinite; }
@keyframes ns-spin { to { transform: rotate(360deg); } }

.ns-workbench { min-height: 520px; }
.ns-workbench-header {
  margin-bottom: 18px;
  padding-bottom: 17px;
  border-bottom: 1px solid var(--border);
}
.ns-workbench-heading { display: flex; align-items: flex-start; gap: 12px; }
.ns-back { width: 35px; height: 35px; flex: 0 0 35px; font-size: 1rem; }
.ns-workbench-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(260px, .72fr); gap: 15px; align-items: start; }
.ns-form-column,
.ns-side-column { display: grid; gap: 14px; }

.ns-editor-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(15, 23, 42, .025);
}
.ns-card-heading { display: flex; gap: 10px; margin-bottom: 15px; }
.ns-card-heading > span {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  flex: 0 0 27px;
  border-radius: 8px;
  color: var(--primary);
  background: var(--primary-bg);
  font-size: .72rem;
  font-weight: 800;
}
.ns-card-heading h4 { margin: 2px 0 3px; font-size: .91rem; }
.ns-card-heading p { font-size: .7rem; line-height: 1.5; }
.ns-card-heading.compact { margin-bottom: 11px; }

.ns-workbench label,
.ns-reference-dialog label,
.ns-confirm-dialog label { display: block; color: var(--dark); font-size: .7rem; font-weight: 750; }
.ns-workbench label > span:first-child,
.ns-reference-dialog label > span:first-child,
.ns-confirm-dialog label > span:first-child { display: block; margin-bottom: 5px; }
.ns-workbench textarea,
.ns-reference-dialog textarea { resize: vertical; line-height: 1.55; }

.ns-bilingual-grid,
.ns-assignment-grid,
.ns-settings-grid { display: grid; gap: 11px; }
.ns-bilingual-grid,
.ns-assignment-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ns-settings-grid { grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); margin-top: 12px; }
.ns-bilingual-grid fieldset {
  display: grid;
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #f8fafc;
}
.ns-bilingual-grid legend { padding: 0 5px; color: var(--primary); font-size: .67rem; font-weight: 800; }
.ns-color-input { display: grid !important; grid-template-columns: 43px 1fr; gap: 7px; margin: 0 !important; }
.ns-color-input input[type='color'] { height: 37px; padding: 3px; cursor: pointer; }

.ns-field-title { margin-bottom: 7px; color: var(--dark); font-size: .72rem; font-weight: 800; }
.ns-choice-list { display: grid; gap: 6px; }
.ns-choice {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #f8fafc;
  cursor: pointer;
}
.ns-choice-select {
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
  margin: 0;
  cursor: pointer;
}
.ns-choice input { width: auto; margin: 0; }
.ns-choice-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ns-primary-choice { display: flex; align-items: center; gap: 4px; color: var(--text-secondary); font-size: .62rem; font-weight: 700; }
.ns-primary-choice input { width: auto; }

.ns-account-search { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 10px; }
.ns-account-selected:empty::before {
  content: 'No website account linked / 尚未关联网站账号';
  display: block;
  padding: 11px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: .72rem;
}
.ns-account-card,
.ns-account-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}
.ns-account-results { display: grid; gap: 6px; max-height: 230px; margin-top: 8px; overflow: auto; }
.ns-account-title { color: var(--dark); font-size: .76rem; font-weight: 800; overflow-wrap: anywhere; }
.ns-private-profile { margin-top: 12px; padding: 13px; border: 1px solid #c7d2fe; border-radius: 11px; background: #eef2ff; }
.ns-private-heading { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.ns-private-heading strong,
.ns-private-heading small { display: block; }
.ns-private-heading strong { color: #312e81; font-size: .73rem; }
.ns-private-heading small { margin-top: 2px; color: #4f46e5; font-size: .64rem; }

.ns-toggle {
  display: flex !important;
  align-items: flex-start;
  gap: 9px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  cursor: pointer;
}
.ns-toggle input { width: auto; margin: 2px 0 0; }
.ns-toggle > span { margin: 0 !important; }
.ns-toggle strong,
.ns-toggle small { display: block; }
.ns-toggle small { margin-top: 2px; color: var(--text-secondary); font-size: .63rem; font-weight: 500; line-height: 1.4; }

.ns-dialog {
  position: fixed;
  inset: 0;
  width: min(960px, calc(100vw - 30px));
  max-width: none;
  max-height: min(88vh, 820px);
  max-height: min(88dvh, 820px);
  margin: auto;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 0;
  border-radius: 17px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 28px 90px rgba(15, 23, 42, .34);
}
.ns-dialog::backdrop { background: rgba(15, 23, 42, .62); backdrop-filter: blur(3px); }
.ns-dialog-frame { padding: 23px; overflow: auto; }
.ns-dialog-header { padding-bottom: 15px; border-bottom: 1px solid var(--border); }
.ns-dialog-close { width: 34px; height: 34px; flex: 0 0 34px; }
.ns-reference-tabs { display: inline-flex; gap: 4px; margin: 16px 0; padding: 4px; border-radius: 999px; background: #f1f5f9; }
.ns-reference-tabs button { padding: 7px 14px; border: 0; border-radius: 999px; color: var(--text-secondary); background: transparent; font: 750 .72rem/1.2 inherit; cursor: pointer; }
.ns-reference-tabs button.active { color: var(--primary); background: var(--surface); box-shadow: 0 2px 7px rgba(15, 23, 42, .1); }
.ns-reference-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(280px, .75fr); gap: 16px; }
.ns-reference-layout > div,
.ns-reference-layout > form { min-width: 0; padding: 14px; border: 1px solid var(--border); border-radius: 12px; }
.ns-reference-list { display: grid; gap: 7px; margin-top: 10px; }
.ns-reference-row { display: grid; grid-template-columns: 1fr auto; gap: 9px; align-items: center; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: #f8fafc; }
.ns-reference-row-main { min-width: 0; }
.ns-reference-row-main strong { display: block; color: var(--dark); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ns-reference-row-main small { display: block; margin-top: 3px; color: var(--text-secondary); font-size: .64rem; line-height: 1.4; }
.ns-reference-row-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.ns-reference-layout form { display: grid; align-content: start; gap: 9px; }
.ns-reference-layout form > h4 { margin-bottom: 2px; }

.ns-confirm-dialog { width: min(520px, calc(100vw - 30px)); }
.ns-confirm-dialog .ns-dialog-frame { text-align: center; }
.ns-confirm-icon { display: grid; place-items: center; width: 47px; height: 47px; margin: 0 auto 12px; border-radius: 50%; color: #b91c1c; background: #fee2e2; font-size: 1.2rem; font-weight: 900; }
.ns-confirm-dialog h3 { margin-bottom: 8px; }
.ns-confirm-dialog p { font-size: .82rem; line-height: 1.65; white-space: pre-line; }
.ns-confirm-dialog label { margin-top: 14px; text-align: left; }
.ns-confirm-actions { margin-top: 19px; }

@media (max-width: 1040px) {
  .ns-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ns-toolbar { grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(130px, .7fr)) 38px; }
  .ns-toolbar select:nth-of-type(3),
  .ns-toolbar select:nth-of-type(4) { grid-row: 2; }
  .ns-list-head { display: none; }
  .ns-member-row { grid-template-columns: minmax(210px, 1.2fr) minmax(180px, 1fr); }
  .ns-member-actions { justify-content: flex-start; }
}

@media (max-width: 820px) {
  .ns-admin-shell > [data-member-view] { padding: 19px 15px; }
  .ns-titlebar,
  .ns-workbench-header,
  .ns-dialog-header { flex-direction: column; }
  .ns-title-actions,
  .ns-workbench-actions { justify-content: flex-start; }
  .ns-workbench-layout,
  .ns-reference-layout { grid-template-columns: 1fr; }
  .ns-bilingual-grid,
  .ns-assignment-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .ns-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ns-toolbar { grid-template-columns: 1fr; }
  .ns-toolbar > * { grid-row: auto !important; width: 100%; }
  .ns-icon-button { width: 100%; }
  .ns-member-row { grid-template-columns: 1fr; }
  .ns-member-actions { justify-content: flex-start; }
  .ns-account-search { grid-template-columns: 1fr; }
  .ns-reference-row { grid-template-columns: 1fr; }
  .ns-reference-row-actions { justify-content: flex-start; }
  .ns-confirm-actions { flex-direction: column-reverse; }
  .ns-confirm-actions .btn { width: 100%; }
}
