/* ============================================
   NEURAPHIC WORKERS — app-core.css
   Dashboard, chat, team, hire wizard, profile.
   Extends base.css + shell.css. Uses design tokens only.
   ============================================ */

/* ---------- Shared page chrome ---------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-5);
  flex-wrap: wrap;
  margin-bottom: var(--s-7);
}
.page-head__title {
  font-family: var(--head);
  font-size: clamp(28px, 3.2vw, 40px);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--black);
  line-height: 1.15;
}
.page-head__sub {
  color: var(--gray);
  font-size: 15px;
  margin-top: var(--s-1);
  max-width: 560px;
}
.page-head__actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

.live-dot {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: 12px;
  color: var(--gray);
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,0.6);
}
.live-dot::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--gray);
  box-shadow: 0 0 0 0 currentColor;
}
.live-dot[data-live="1"]::before {
  background: var(--green);
  animation: live-pulse 2.4s infinite;
}
@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22,163,74,0.5); }
  50%      { box-shadow: 0 0 0 6px rgba(22,163,74,0); }
}

/* ---------- Dashboard ---------- */
.dash-section { margin-bottom: var(--s-9); }
.dash-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--s-4);
}
.dash-section__title {
  font-family: var(--head);
  font-size: 18px;
  font-weight: 600;
  color: var(--black);
  letter-spacing: -0.01em;
}
.dash-section__link {
  font-size: 13px;
  color: var(--black);
  border-bottom: 1px solid var(--line);
  padding-bottom: 1px;
  transition: opacity .2s;
}
.dash-section__link:hover { opacity: .6; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-4);
}
.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-5) var(--s-5);
  transition: border-color .2s, transform .2s;
}
.metric:hover { border-color: rgba(19,19,20,0.18); }
.metric__label {
  font-size: 12px;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}
.metric__value {
  font-family: var(--head);
  font-size: 34px;
  font-weight: 600;
  color: var(--black);
  letter-spacing: -0.02em;
  margin-top: var(--s-2);
  line-height: 1;
}
.metric__delta {
  display: inline-block;
  margin-top: var(--s-3);
  font-size: 12px;
  color: var(--gray);
}
.metric__delta--up   { color: var(--green); }
.metric__delta--down { color: var(--red); }

@media (max-width: 900px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
}

.approvals-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.approval-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--s-4);
  align-items: center;
  padding: var(--s-4);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.approval-row__icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg);
  display: grid;
  place-items: center;
  font-family: var(--head);
  font-weight: 600;
  color: var(--black);
  font-size: 14px;
}
.approval-row__body strong {
  display: block;
  color: var(--black);
  font-size: 14px;
  font-weight: 600;
}
.approval-row__body span {
  font-size: 13px;
  color: var(--gray);
}
.approval-row__actions { display: flex; gap: var(--s-2); }

.team-strip {
  display: flex;
  gap: var(--s-4);
  overflow-x: auto;
  padding-bottom: var(--s-3);
  scroll-snap-type: x mandatory;
}
.team-strip::-webkit-scrollbar { height: 6px; }
.team-strip::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.emp-card {
  flex: 0 0 260px;
  scroll-snap-align: start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  transition: border-color .2s, transform .2s;
  cursor: pointer;
}
.emp-card:hover {
  border-color: rgba(19,19,20,0.22);
  transform: translateY(-2px);
}
.emp-card__top {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.emp-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--black);
  color: var(--bg);
  display: grid;
  place-items: center;
  font-family: var(--head);
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}
.emp-avatar--lg { width: 80px; height: 80px; font-size: 28px; }
.emp-avatar--sm { width: 28px; height: 28px; font-size: 11px; }
.emp-card__name {
  font-family: var(--head);
  color: var(--black);
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
}
.emp-card__role {
  font-size: 12px;
  color: var(--gray);
}
.emp-card__task {
  font-size: 13px;
  color: var(--black);
  min-height: 36px;
}
.emp-card__bar {
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.emp-card__bar > span {
  display: block;
  height: 100%;
  background: var(--black);
  border-radius: 2px;
}
.emp-card__foot {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--gray);
}

.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gray);
  margin-right: 6px;
  vertical-align: middle;
}
.status-dot--active { background: var(--green); }
.status-dot--paused { background: var(--amber); }
.status-dot--fired  { background: var(--red); }

.brief-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: var(--s-5);
  align-items: center;
}
.brief-card__body h3 {
  font-family: var(--head);
  color: var(--black);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: var(--s-1);
}
.brief-card__body p {
  font-size: 14px;
  color: var(--gray);
  line-height: 1.5;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-3);
}
.quick-actions .btn {
  padding: var(--s-4);
  justify-content: flex-start;
}
@media (max-width: 720px) {
  .quick-actions { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Chat ---------- */
.chat-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 320px;
  gap: var(--s-5);
  min-height: calc(100vh - 220px);
}
.chat-layout[data-drawer="closed"] {
  grid-template-columns: 260px minmax(0, 1fr) 0;
}
.chat-layout[data-drawer="closed"] .chat-drawer { display: none; }
@media (max-width: 1100px) {
  .chat-layout { grid-template-columns: 220px 1fr; }
  .chat-drawer { display: none; }
}
@media (max-width: 720px) {
  .chat-layout { grid-template-columns: 1fr; }
  .chat-rail { display: none; }
}

.chat-rail {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-3);
  overflow-y: auto;
  max-height: calc(100vh - 220px);
}
.chat-rail__group {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray);
  padding: var(--s-3) var(--s-3) var(--s-2);
  font-weight: 500;
}
.chat-rail__item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background .15s;
  color: var(--black);
}
.chat-rail__item:hover { background: var(--bg); }
.chat-rail__item[aria-current="true"] { background: var(--black); color: var(--bg); }
.chat-rail__item[aria-current="true"] .emp-avatar { background: var(--bg); color: var(--black); }
.chat-rail__item small { color: inherit; opacity: .6; font-size: 11px; display: block; }

.chat-main {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  min-height: 0;
}
.chat-main__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--line);
}
.chat-main__head strong {
  font-family: var(--head);
  color: var(--black);
  font-size: 16px;
  font-weight: 600;
}

.chat__log {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  min-height: 0;
}
.chat__msg {
  max-width: 75%;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-lg);
  font-size: 14px;
  line-height: 1.55;
  color: var(--black);
  background: var(--bg);
  border: 1px solid var(--line);
}
.chat__msg--me {
  align-self: flex-end;
  background: var(--black);
  color: var(--bg);
  border-color: var(--black);
}
.chat__msg--emp { align-self: flex-start; }
.chat__sys {
  align-self: center;
  font-size: 11px;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--s-2) var(--s-3);
}
.chat__sys::before, .chat__sys::after {
  content: '';
  display: inline-block;
  width: 32px;
  height: 1px;
  background: var(--line);
  vertical-align: middle;
  margin: 0 var(--s-3);
}

.chat__tool {
  align-self: flex-start;
  max-width: 75%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
}
.chat__tool summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--black);
  font-weight: 500;
  list-style: none;
}
.chat__tool summary::before {
  content: '›';
  display: inline-block;
  margin-right: var(--s-2);
  transition: transform .2s;
}
.chat__tool[open] summary::before { transform: rotate(90deg); }
.chat__tool pre {
  margin-top: var(--s-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: var(--gray);
  white-space: pre-wrap;
  word-break: break-all;
}

.chat__approval {
  align-self: stretch;
  background: #fff;
  border: 1px solid var(--amber);
  border-left: 4px solid var(--amber);
  border-radius: var(--r-md);
  padding: var(--s-4);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s-3);
  align-items: center;
}
.chat__approval strong { color: var(--black); font-weight: 600; display: block; }
.chat__approval span  { color: var(--gray); font-size: 13px; }
.chat__approval__buttons { display: flex; gap: var(--s-2); }

.chat__form {
  border-top: 1px solid var(--line);
  padding: var(--s-4);
  position: sticky;
  bottom: 0;
  background: #fff;
  border-bottom-left-radius: var(--r-lg);
  border-bottom-right-radius: var(--r-lg);
}
.chat-composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s-3);
  align-items: end;
}
.chat-composer textarea {
  resize: none;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  font: inherit;
  color: var(--black);
  background: var(--bg);
  max-height: 200px;
  min-height: 44px;
  line-height: 1.5;
}
.chat-composer textarea:focus {
  outline: none;
  border-color: var(--black);
  background: #fff;
}
.chat-composer__tools {
  display: flex;
  gap: var(--s-1);
  margin-top: var(--s-2);
  color: var(--gray);
}
.icon-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--gray);
  background: transparent;
  transition: background .15s, color .15s;
  font-size: 15px;
}
.icon-btn:hover { background: var(--bg); color: var(--black); }
.icon-btn[aria-pressed="true"] { background: var(--black); color: var(--bg); }

.chat-drawer {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  overflow-y: auto;
  max-height: calc(100vh - 220px);
}
.chat-drawer h4 {
  font-family: var(--head);
  font-size: 13px;
  font-weight: 600;
  color: var(--black);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--s-3);
}
.chat-drawer dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-2) var(--s-3);
  margin-bottom: var(--s-5);
  font-size: 13px;
}
.chat-drawer dt { color: var(--gray); }
.chat-drawer dd { color: var(--black); text-align: right; font-weight: 500; }
.timeline {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding-left: var(--s-4);
  border-left: 1px solid var(--line);
}
.timeline__item { font-size: 12px; color: var(--gray); position: relative; }
.timeline__item::before {
  content: '';
  position: absolute;
  left: calc(-1 * var(--s-4) - 4px);
  top: 4px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--black);
}
.timeline__item strong { color: var(--black); display: block; font-weight: 500; }

/* ---------- Team page ---------- */
.org-chart {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  margin-bottom: var(--s-6);
  overflow-x: auto;
}
.org-chart svg { display: block; margin: 0 auto; }
.org-chart__node rect {
  fill: #fff;
  stroke: var(--line);
  stroke-width: 1;
}
.org-chart__node--nera rect { fill: var(--black); stroke: var(--black); }
.org-chart__node--nera text { fill: var(--bg); }
.org-chart__node text {
  font-family: var(--head);
  font-size: 12px;
  fill: var(--black);
  font-weight: 500;
}
.org-chart__node text.sub { font-size: 10px; fill: var(--gray); font-weight: 400; }
.org-chart__link {
  fill: none;
  stroke: var(--line);
  stroke-width: 1.2;
}

.filter-row {
  display: flex;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
  flex-wrap: wrap;
}
.filter-row select, .filter-row input {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-2) var(--s-4);
  font: inherit;
  color: var(--black);
  background: #fff;
  min-width: 180px;
}
.filter-row input:focus, .filter-row select:focus {
  outline: none;
  border-color: var(--black);
}

.team-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.team-table th,
.team-table td {
  padding: var(--s-3) var(--s-4);
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
  color: var(--black);
}
.team-table th {
  font-weight: 500;
  color: var(--gray);
  background: var(--bg);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
}
.team-table tr:last-child td { border-bottom: none; }
.team-table tr:hover td { background: rgba(19,19,20,0.02); }
.team-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions {
  display: flex;
  gap: var(--s-1);
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg);
  color: var(--black);
  border: 1px solid var(--line);
  text-transform: capitalize;
}
.pill--green { background: rgba(22,163,74,0.1); color: var(--green); border-color: rgba(22,163,74,0.2); }
.pill--amber { background: rgba(217,119,6,0.1); color: var(--amber); border-color: rgba(217,119,6,0.2); }
.pill--red   { background: rgba(220,38,38,0.1); color: var(--red); border-color: rgba(220,38,38,0.2); }

/* ---------- Hire wizard ---------- */
.wizard-steps {
  display: flex;
  gap: var(--s-3);
  margin-bottom: var(--s-6);
  align-items: center;
}
.wizard-step {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--gray);
  font-size: 13px;
}
.wizard-step__dot {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-family: var(--head);
  font-weight: 600;
  font-size: 12px;
  color: var(--black);
}
.wizard-step[aria-current="true"] { color: var(--black); font-weight: 500; }
.wizard-step[aria-current="true"] .wizard-step__dot {
  background: var(--black);
  color: var(--bg);
  border-color: var(--black);
}
.wizard-step[data-done="1"] .wizard-step__dot {
  background: var(--black);
  color: var(--bg);
  border-color: var(--black);
}
.wizard-step + .wizard-step::before {
  content: '';
  width: 32px;
  height: 1px;
  background: var(--line);
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--s-4);
  margin-bottom: var(--s-6);
}
.role-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  cursor: pointer;
  transition: border-color .2s, transform .2s;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.role-card:hover {
  border-color: rgba(19,19,20,0.22);
  transform: translateY(-2px);
}
.role-card[aria-selected="true"] {
  border-color: var(--black);
  box-shadow: 0 0 0 3px rgba(19,19,20,0.08);
}
.role-card__name {
  font-family: var(--head);
  color: var(--black);
  font-size: 16px;
  font-weight: 600;
}
.role-card__desc {
  font-size: 13px;
  color: var(--gray);
  line-height: 1.5;
  flex: 1;
}
.role-card__cost {
  font-family: var(--head);
  color: var(--black);
  font-size: 13px;
  font-weight: 500;
}

.wizard-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-7);
  max-width: 640px;
  margin: 0 auto;
}
.wizard-panel h2 {
  font-family: var(--head);
  color: var(--black);
  font-size: 22px;
  font-weight: 600;
  margin-bottom: var(--s-2);
}
.wizard-panel p.help {
  color: var(--gray);
  font-size: 14px;
  margin-bottom: var(--s-5);
}
.field {
  display: block;
  margin-bottom: var(--s-4);
}
.field label {
  display: block;
  font-size: 12px;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--s-2);
  font-weight: 500;
}
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  font: inherit;
  color: var(--black);
  background: var(--bg);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--black);
  background: #fff;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-4);
}
@media (max-width: 640px) {
  .field-row { grid-template-columns: 1fr; }
}

.slider-row {
  display: flex;
  align-items: center;
  gap: var(--s-4);
}
.slider-row input[type="range"] {
  flex: 1;
  accent-color: var(--black);
}
.slider-row output {
  font-family: var(--head);
  font-weight: 600;
  color: var(--black);
  font-size: 20px;
  min-width: 90px;
  text-align: right;
}

.wizard-footer {
  display: flex;
  justify-content: space-between;
  margin-top: var(--s-6);
  gap: var(--s-3);
}

.summary-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-4);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-2) var(--s-4);
  font-size: 13px;
  margin-bottom: var(--s-5);
}
.summary-card dt { color: var(--gray); }
.summary-card dd { color: var(--black); font-weight: 500; text-align: right; }

/* ---------- Profile page ---------- */
.profile-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--s-6);
}
@media (max-width: 900px) {
  .profile-grid { grid-template-columns: 1fr; }
}
.profile-side {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  text-align: center;
  height: fit-content;
}
.profile-side .emp-avatar { margin: 0 auto var(--s-3); }
.profile-side strong {
  font-family: var(--head);
  display: block;
  color: var(--black);
  font-size: 17px;
  font-weight: 600;
}
.profile-side span {
  color: var(--gray);
  font-size: 13px;
}

.profile-section {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  margin-bottom: var(--s-5);
}
.profile-section h3 {
  font-family: var(--head);
  font-size: 16px;
  font-weight: 600;
  color: var(--black);
  margin-bottom: var(--s-4);
}

.passkey-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.passkey-list li {
  display: flex;
  justify-content: space-between;
  padding: var(--s-3) var(--s-4);
  background: var(--bg);
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--black);
}

.danger-zone {
  background: #fff;
  border: 1px solid rgba(220,38,38,0.3);
  border-radius: var(--r-lg);
  padding: var(--s-6);
}
.danger-zone h3 { color: var(--red); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: var(--s-6);
  left: 50%;
  transform: translateX(-50%);
  background: var(--black);
  color: var(--bg);
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-md);
  font-size: 13px;
  z-index: 1000;
  animation: toast-in .25s ease-out;
  box-shadow: 0 10px 40px rgba(19,19,20,0.2);
}
@keyframes toast-in {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to   { transform: translate(-50%, 0);    opacity: 1; }
}
