/* ============================================
   NEURAPHIC WORKERS — management.css
   Settings, billing, marketplace, admin, preferences
   All tokens inherited from base.css
   ============================================ */

.mgmt {
  max-width: var(--w);
  margin: 0 auto;
  padding: calc(var(--nav-h) + var(--s-8)) clamp(24px, 4vw, 48px) var(--s-11);
}
.mgmt .page__title { font-size: clamp(32px, 4vw, 48px); margin-bottom: var(--s-2); }
.mgmt .page__subtitle { color: var(--gray); margin-bottom: var(--s-7); max-width: 64ch; }

.mgmt .card + .card { margin-top: var(--s-5); }

/* ---------- Settings shell: left nav + content pane ---------- */
.mgmt__shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: var(--s-7);
  align-items: start;
}
@media (max-width: 860px) {
  .mgmt__shell { grid-template-columns: 1fr; }
}

.mgmt__nav {
  position: sticky;
  top: calc(var(--nav-h) + var(--s-5));
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--s-3);
  background: #e6e7e9;
  border-radius: var(--r-lg);
}
.mgmt__nav-link {
  text-align: left;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--gray);
  padding: 10px 14px;
  border-radius: var(--r-md);
  transition: background .15s, color .15s;
}
.mgmt__nav-link:hover { color: var(--black); background: rgba(19,19,20,0.04); }
.mgmt__nav-link.is-active {
  background: var(--black);
  color: var(--bg);
}

.mgmt__pane { min-width: 0; }
.mgmt__section { display: none; }
.mgmt__section.is-active { display: block; animation: mgmt-fade .18s ease-out; }
@keyframes mgmt-fade { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }

/* ---------- Segmented choice ---------- */
.mgmt__choice {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--s-2);
  margin-top: var(--s-3);
}
.mgmt__choice button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: #fff;
  border: 1px solid var(--line);
  text-align: left;
  transition: border-color .15s, background .15s;
}
.mgmt__choice button strong { font-family: var(--head); font-size: 14px; color: var(--black); }
.mgmt__choice button span { font-size: 12px; color: var(--gray); }
.mgmt__choice button:hover { border-color: rgba(19,19,20,0.2); }
.mgmt__choice button.is-active {
  background: var(--black);
  border-color: var(--black);
}
.mgmt__choice button.is-active strong,
.mgmt__choice button.is-active span { color: var(--bg); }

/* ---------- Toggle (switch) ---------- */
.mgmt__toggle {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  cursor: pointer;
  user-select: none;
}
.mgmt__toggle input { position: absolute; opacity: 0; pointer-events: none; }
.mgmt__toggle-track {
  flex: 0 0 auto;
  width: 40px; height: 24px;
  background: rgba(19,19,20,0.15);
  border-radius: 999px;
  position: relative;
  transition: background .15s;
  margin-top: 2px;
}
.mgmt__toggle-track::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform .18s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.mgmt__toggle input:checked + .mgmt__toggle-track { background: var(--green); }
.mgmt__toggle input:checked + .mgmt__toggle-track::after { transform: translateX(16px); }
.mgmt__toggle-label { font-size: 14px; color: var(--black); line-height: 1.5; display: flex; flex-direction: column; gap: 4px; }
.mgmt__toggle-label strong { font-weight: 600; }

.mgmt__voice-number {
  margin-top: var(--s-4);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: 15px;
}

/* ---------- Company logo ---------- */
.mgmt__logo {
  display: flex;
  align-items: center;
  gap: var(--s-5);
}
.mgmt__logo-preview {
  width: 72px; height: 72px;
  border-radius: var(--r-md);
  background: var(--black);
  color: var(--bg);
  font-family: var(--head);
  font-size: 32px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Settings: kill / destroy ---------- */
.mgmt__kill { border: 1px solid rgba(220,38,38,0.25); }
.mgmt__danger .card + .card { margin-top: var(--s-5); }
.mgmt__destroy { border: 1px solid rgba(220,38,38,0.35); }

.mgmt__team-table { margin-top: var(--s-4); }
.mgmt__team-table .pill { text-transform: capitalize; }

/* ---------- Billing ---------- */
.mgmt__grid--billing {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: var(--s-5);
  margin-bottom: var(--s-7);
}
@media (max-width: 960px) { .mgmt__grid--billing { grid-template-columns: 1fr; } }

.mgmt__total {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: var(--s-4) 0 var(--s-3);
}
.mgmt__total .mono { font-family: var(--head); font-size: 40px; font-weight: 700; color: var(--black); letter-spacing: -0.02em; }
.mgmt__bar {
  height: 8px;
  background: rgba(19,19,20,0.08);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: var(--s-4);
}
.mgmt__bar-fill {
  height: 100%;
  background: var(--black);
  transition: width .25s ease;
}
.mgmt__breakdown {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-2) var(--s-5);
}
.mgmt__breakdown li {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--gray);
}
.mgmt__breakdown li .mono { color: var(--black); }

.mgmt__plan-name {
  font-family: var(--head);
  font-size: 32px;
  font-weight: 700;
  color: var(--black);
  margin: var(--s-2) 0;
}

.mgmt__chart-card { margin-bottom: var(--s-5); }
.mgmt__chart { width: 100%; height: 260px; margin-top: var(--s-4); }
.mgmt__chart svg { width: 100%; height: 100%; }
.mgmt__chart rect.bar { fill: var(--black); transition: fill .15s; }
.mgmt__chart rect.bar:hover { fill: var(--ink-hover); }
.mgmt__chart rect.bar--current { fill: var(--green); }
.mgmt__chart .axis { stroke: rgba(19,19,20,0.12); stroke-width: 1; }
.mgmt__chart .label { font-family: var(--sans); font-size: 11px; fill: var(--gray); }
.mgmt__chart .value { font-family: var(--sans); font-size: 11px; fill: var(--black); font-weight: 500; }

.mgmt__invoices-card .table { margin-top: var(--s-3); }

/* ---------- Marketplace ---------- */
.mgmt__market-filters {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s-4);
  align-items: center;
  margin: var(--s-6) 0 var(--s-5);
}
.mgmt__market-search { max-width: 420px; }
.mgmt__chips { display: flex; flex-wrap: wrap; gap: var(--s-2); grid-column: 1 / -1; }
.mgmt__chip {
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--black);
  font-weight: 500;
  transition: background .15s, color .15s, border-color .15s;
}
.mgmt__chip:hover { border-color: var(--black); }
.mgmt__chip.is-active { background: var(--black); color: var(--bg); border-color: var(--black); }
.mgmt__market-sort {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  grid-column: 1 / -1;
}
.mgmt__market-sort .input { width: auto; }

.mgmt__market-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--s-5);
}
.mgmt__market-card {
  background: #e6e7e9;
  border-radius: var(--r-lg);
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  text-align: left;
  transition: background .15s, transform .15s;
}
.mgmt__market-card:hover { background: #dddee1; transform: translateY(-2px); }
.mgmt__market-card h3 {
  font-size: 18px;
  color: var(--black);
  margin-bottom: 2px;
}
.mgmt__market-tagline { font-size: 13px; color: var(--gray); min-height: 40px; }
.mgmt__market-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--gray);
}
.mgmt__market-price {
  font-family: var(--head);
  font-size: 15px;
  color: var(--black);
  font-weight: 600;
}
.mgmt__market-stats { display: flex; gap: var(--s-3); }

/* Drawer */
.mgmt__drawer {
  position: fixed;
  inset: 0;
  z-index: 200;
}
.mgmt__drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(19,19,20,0.45);
  backdrop-filter: blur(4px);
}
.mgmt__drawer-panel {
  position: absolute;
  top: 0; right: 0;
  width: min(520px, 100%);
  height: 100%;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  box-shadow: -20px 0 60px rgba(0,0,0,0.2);
  animation: mgmt-slide-in .22s ease-out;
}
@keyframes mgmt-slide-in { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.mgmt__drawer-head {
  padding: var(--s-5);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.mgmt__drawer-head h2 { font-family: var(--head); font-size: 22px; color: var(--black); }
.mgmt__drawer-body { flex: 1; overflow: auto; padding: var(--s-5); color: var(--black); font-size: 14px; line-height: 1.7; }
.mgmt__drawer-body h4 { margin-top: var(--s-4); margin-bottom: 6px; color: var(--black); }
.mgmt__drawer-body pre {
  background: #e6e7e9;
  border-radius: var(--r-md);
  padding: var(--s-3);
  font-family: 'SF Mono', ui-monospace, monospace;
  font-size: 12px;
  color: var(--black);
  overflow: auto;
  white-space: pre-wrap;
}
.mgmt__drawer-foot {
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
}

/* ---------- Admin ---------- */
.mgmt__admin-banner {
  background: rgba(220,38,38,0.08);
  border: 1px solid rgba(220,38,38,0.3);
  color: var(--black);
  padding: 12px 18px;
  border-radius: var(--r-md);
  font-size: 13px;
  margin-bottom: var(--s-5);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.mgmt__admin-banner strong { color: var(--red); }

.mgmt__admin {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: var(--s-6);
  align-items: start;
}
@media (max-width: 960px) { .mgmt__admin { grid-template-columns: 1fr; } }

.mgmt__admin-search {
  display: grid;
  grid-template-columns: 160px 1fr 260px auto;
  gap: var(--s-3);
  align-items: end;
  padding: var(--s-5);
  background: #e6e7e9;
  border-radius: var(--r-lg);
}
@media (max-width: 960px) { .mgmt__admin-search { grid-template-columns: 1fr; } }
.mgmt__admin-row { display: flex; flex-direction: column; gap: 4px; }
.mgmt__admin-row--grow { min-width: 0; }
.mgmt__admin-notice {
  margin-top: var(--s-3);
  font-size: 12px;
  color: var(--gray);
}
.mgmt__admin-results { margin-top: var(--s-5); display: flex; flex-direction: column; gap: var(--s-3); }
.mgmt__admin-card {
  background: #e6e7e9;
  border-radius: var(--r-md);
  padding: var(--s-4);
}
.mgmt__admin-card h4 { font-size: 15px; margin-bottom: 4px; color: var(--black); }
.mgmt__admin-card .mono { color: var(--gray); font-size: 12px; }
.mgmt__admin-card dl {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 4px 12px;
  margin-top: var(--s-3);
  font-size: 13px;
}
.mgmt__admin-card dt { color: var(--gray); }
.mgmt__admin-card dd { color: var(--black); }

.mgmt__admin-sidebar {
  position: sticky;
  top: calc(var(--nav-h) + var(--s-5));
  padding: var(--s-4);
  background: #e6e7e9;
  border-radius: var(--r-lg);
}
.mgmt__admin-sidebar h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray);
  margin-bottom: var(--s-3);
}
.mgmt__admin-recent { display: flex; flex-direction: column; gap: var(--s-2); }
.mgmt__admin-recent-item {
  padding: 10px 12px;
  background: #fff;
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--black);
}
.mgmt__admin-recent-item .muted { display: block; font-size: 11px; margin-top: 2px; }

/* ---------- Publish form ---------- */
.mgmt__publish-price { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.mgmt__publish-status {
  margin-top: var(--s-4);
  padding: 12px 16px;
  background: rgba(22,163,74,0.1);
  color: var(--green);
  border-radius: var(--r-md);
  font-size: 14px;
}
.mgmt__publish input[type="range"] { width: 100%; }

/* ---------- Preferences ---------- */
.mgmt__prefs .field + .field { margin-top: var(--s-4); }
