/* ─────────────────────────────────────────────
   Noetarist — Management Dashboard
   Dark mode default. Clean. Calm. Dense.
   ───────────────────────────────────────────── */

/* ── Reset & base ────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Palette — dark default */
  --bg:          #0e0e10;
  --bg-raised:   #18181b;
  --bg-card:     #1e1e22;
  --bg-hover:    #26262b;
  --bg-input:    #18181b;
  --border:      #2a2a2f;
  --border-light:#333339;

  --text:        #e4e4e7;
  --text-dim:    #a1a1aa;
  --text-muted:  #71717a;

  /* Status accents */
  --red:         #dc2626;
  --red-dim:     #991b1b;
  --amber:       #d97706;
  --amber-dim:   #92400e;
  --green:       #16a34a;
  --green-dim:   #166534;
  --blue:        #3b82f6;
  --blue-dim:    #1e3a5f;
  --grey:        #52525b;
  --grey-dim:    #3f3f46;

  /* UI */
  --radius:      2px;
  --font:        'SF Mono', 'Consolas', 'Liberation Mono', 'Menlo', monospace;
  --font-sans:   -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  --transition:  150ms ease;
}

html { font-size: 14px; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ── Typography ──────────────────────────── */
h1, h2, h3 { font-weight: 500; letter-spacing: -0.01em; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1rem; }
h3 { font-size: 0.875rem; }

/* ── Top bar ─────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-brand {
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.topbar-time {
  font-family: var(--font);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.topbar-nav {
  display: flex;
  gap: 0.25rem;
}

.topbar-nav a {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
}

.topbar-nav a:hover,
.topbar-nav a.active {
  color: var(--text);
  background: var(--bg-raised);
}

/* ── Buttons ─────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.btn-primary:hover {
  background: #d4d4d8;
  border-color: #d4d4d8;
}

.btn-danger {
  border-color: var(--red-dim);
  color: var(--red);
}
.btn-danger:hover {
  background: var(--red-dim);
  color: #fca5a5;
}

.btn-approve {
  border-color: var(--green-dim);
  color: var(--green);
}
.btn-approve:hover {
  background: var(--green-dim);
  color: #86efac;
}

.btn-sm { font-size: 0.75rem; padding: 0.25rem 0.5rem; }

/* ── Board layout ────────────────────────── */
.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  min-height: calc(100vh - 3rem);
}

.board-column {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.column-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: sticky;
  top: 3rem;
  background: var(--bg);
  z-index: 10;
}

.column-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.column-indicator--attention { background: var(--red); }
.column-indicator--running   { background: var(--amber); }
.column-indicator--completed { background: var(--green); }
.column-indicator--queued    { background: var(--grey); }

.column-title {
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.column-count {
  font-family: var(--font);
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: auto;
}

.column-body {
  flex: 1;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
}

.column-empty {
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 1rem;
  text-align: center;
  opacity: 0.5;
}

/* ── Job cards ───────────────────────────── */
.job-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.job-card:hover {
  border-color: var(--border-light);
  background: var(--bg-hover);
}

.job-card--attention { border-left: 2px solid var(--red); }
.job-card--running   { border-left: 2px solid var(--amber); }
.job-card--completed { border-left: 2px solid var(--green); }
.job-card--queued    { border-left: 2px solid var(--grey); }

.job-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.job-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  margin-bottom: 0.35rem;
}

.job-meta-sep::before { content: '\00b7'; }

.job-streams {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.job-elapsed {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font);
}

/* risk badges */
.risk-badge {
  font-family: var(--font);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius);
}
.risk-badge--high   { background: var(--red-dim);   color: #fca5a5; }
.risk-badge--medium { background: var(--amber-dim); color: #fcd34d; }
.risk-badge--low    { background: var(--grey-dim);  color: var(--text-dim); }

/* ── Job detail expanded ─────────────────── */
.job-expanded {
  display: none;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.job-card.expanded .job-expanded { display: block; }

.ws-list { list-style: none; margin: 0.25rem 0; }
.ws-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.ws-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ws-status--done    { background: var(--green); }
.ws-status--running { background: var(--amber); }
.ws-status--queued  { background: var(--grey); }
.ws-status--failed  { background: var(--red); }
.ws-status--paused  { background: var(--grey); border: 1px solid var(--amber); }

.ws-role {
  font-family: var(--font);
  font-size: 0.75rem;
  min-width: 5rem;
}
.ws-label { flex: 1; }
.ws-badge {
  font-family: var(--font);
  font-size: 0.65rem;
  color: var(--text-muted);
}

.job-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

/* ── Job detail page ─────────────────────── */
.detail-page {
  max-width: 56rem;
  margin: 0 auto;
  padding: 1.5rem;
}

.detail-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.detail-title {
  font-size: 1.25rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.detail-meta dt { color: var(--text-muted); }
.detail-meta dd { color: var(--text); margin-left: 0; }

.detail-section {
  margin-bottom: 1.5rem;
}

.detail-section-title {
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.detail-brief {
  font-size: 0.875rem;
  color: var(--text-dim);
  line-height: 1.6;
  white-space: pre-wrap;
}

/* workstream table */
.ws-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.ws-table th {
  text-align: left;
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.ws-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
}
.ws-table tr:hover td { background: var(--bg-raised); }

/* ── Upload brief modal ──────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 32rem;
  padding: 1.5rem;
}

.modal-title {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 1rem;
}

.drop-zone {
  border: 1px dashed var(--border-light);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
}
.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--text-muted);
  background: var(--bg-raised);
}
.drop-zone-label { margin-bottom: 0.5rem; }
.drop-zone-hint { font-size: 0.75rem; color: var(--text-muted); }

.upload-feedback {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  display: none;
}
.upload-feedback.success {
  display: block;
  background: var(--green-dim);
  color: #86efac;
  border: 1px solid var(--green);
}
.upload-feedback.error {
  display: block;
  background: var(--red-dim);
  color: #fca5a5;
  border: 1px solid var(--red);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* textarea for pasting brief */
.brief-textarea {
  width: 100%;
  min-height: 10rem;
  font-family: var(--font);
  font-size: 0.8rem;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  resize: vertical;
  margin-top: 0.75rem;
}
.brief-textarea:focus {
  outline: none;
  border-color: var(--text-muted);
}

.or-divider {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  margin: 0.75rem 0;
}

/* ── Decision panel ──────────────────────── */
.decision-panel {
  background: var(--bg-card);
  border: 1px solid var(--red-dim);
  border-left: 3px solid var(--red);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 1rem;
}

.decision-title {
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 0.75rem;
}

.decision-body {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 0.75rem;
}

.decision-notes {
  width: 100%;
  min-height: 3rem;
  font-family: var(--font);
  font-size: 0.8rem;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  resize: vertical;
  margin-bottom: 0.75rem;
}
.decision-notes:focus {
  outline: none;
  border-color: var(--text-muted);
}
.decision-notes::placeholder { color: var(--text-muted); }

.decision-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ── Events ──────────────────────────────── */
.event-list { list-style: none; }
.event-item {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.35rem 0;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--border);
}
.event-time {
  font-family: var(--font);
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 5rem;
}
.event-desc { color: var(--text-dim); }

/* ── Progress bar ────────────────────────── */
.progress-bar {
  height: 3px;
  background: var(--bg-raised);
  border-radius: 1px;
  overflow: hidden;
  margin-top: 0.35rem;
}
.progress-fill {
  height: 100%;
  background: var(--amber);
  transition: width 300ms ease;
}
.job-card--completed .progress-fill { background: var(--green); }

/* ── Back link ───────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 1rem;
  transition: color var(--transition);
}
.back-link:hover { color: var(--text); }

/* ── Loading / empty states ──────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--text-muted);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 0.5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Secretary / Provider panels ─────────── */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.panel-title {
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* ── Responsive: single column on mobile ── */
@media (max-width: 768px) {
  .board {
    grid-template-columns: 1fr;
  }
  .column-body { max-height: none; }
  .topbar-nav { display: none; }
  .topbar { padding: 0.5rem 1rem; }
}

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

/* ── Scrollbar ───────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ── Toast notifications ─────────────────── */
.toast-wrap {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  font-size: 0.8rem;
  color: var(--text);
  opacity: 1;
  transition: opacity 300ms ease;
}
.toast--success { border-left: 3px solid var(--green); }
.toast--error   { border-left: 3px solid var(--red); }

/* ── Trust score display ─────────────────── */
.trust-score-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 8rem;
}

.trust-score-value {
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  min-width: 2.5rem;
}

.trust-bar {
  flex: 1;
  height: 4px;
  background: var(--bg-raised);
  border-radius: 2px;
  overflow: hidden;
}

.trust-bar-fill {
  height: 100%;
  transition: width 300ms ease;
}

.trust-bar--green { background: var(--green); }
.trust-bar--blue  { background: #3b82f6; }
.trust-bar--amber { background: var(--amber); }
.trust-bar--red   { background: var(--red); }
.trust-bar--grey  { background: var(--grey); }

/* ── Trust tier badges ──────────────────── */
.trust-tier {
  font-family: var(--font);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius);
  white-space: nowrap;
}

.trust-tier--full_autonomy { background: var(--green-dim); color: #86efac; }
.trust-tier--standard      { background: #1e3a5f; color: #93c5fd; }
.trust-tier--supervised    { background: var(--amber-dim); color: #fcd34d; }
.trust-tier--probation     { background: var(--red-dim); color: #fca5a5; }
.trust-tier--benched       { background: var(--grey-dim); color: var(--text-muted); }

/* ── Agent status badges ────────────────── */
.agent-status {
  font-family: var(--font);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.agent-status--active    { color: var(--green); }
.agent-status--probation { color: var(--amber); }
.agent-status--benched   { color: var(--red); }
.agent-status--dismissed { color: var(--text-muted); text-decoration: line-through; }

/* ── Trust history mini bars ────────────── */
.trust-history {
  display: flex;
  align-items: flex-end;
  gap: 1px;
  height: 16px;
}

.trust-history-bar {
  width: 3px;
  min-height: 2px;
  height: 8px;
  border-radius: 1px;
}

.trust-history-bar--up      { background: var(--green); height: 12px; }
.trust-history-bar--down    { background: var(--red); height: 12px; }
.trust-history-bar--neutral { background: var(--grey); height: 6px; }

/* ── Agent panel ────────────────────────── */
.agent-panel {
  margin-bottom: 1.5rem;
}

.agent-actions-cell {
  display: flex;
  gap: 0.25rem;
  flex-wrap: nowrap;
}

/* ── Plan cards ─────────────────────────── */
.plan-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.plan-card:hover {
  border-color: var(--border-light);
  background: var(--bg-hover);
}

.plan-card--awaiting_approval { border-left: 3px solid var(--amber); }
.plan-card--approved          { border-left: 3px solid var(--green); }
.plan-card--rejected          { border-left: 3px solid var(--red); }
.plan-card--draft             { border-left: 3px solid var(--grey); }

.plan-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.plan-card-approach {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 0.25rem;
  line-height: 1.4;
}

.plan-card-roles {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Plan status badges ─────────────────── */
.plan-status {
  font-family: var(--font);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius);
  white-space: nowrap;
}

.plan-status--awaiting_approval { background: var(--amber-dim); color: #fcd34d; }
.plan-status--approved          { background: var(--green-dim); color: #86efac; }
.plan-status--rejected          { background: var(--red-dim); color: #fca5a5; }
.plan-status--draft             { background: var(--grey-dim); color: var(--text-muted); }

/* ── Plan pending badge on job cards ────── */
.plan-pending-badge {
  display: inline-block;
  font-family: var(--font);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--amber-dim);
  color: #fcd34d;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius);
  margin-bottom: 0.35rem;
}

/* ── Risk list (plan detail) ────────────── */
.risk-list {
  list-style: none;
  margin: 0;
}

.risk-list li {
  font-size: 0.85rem;
  color: var(--text-dim);
  padding: 0.25rem 0;
  padding-left: 1rem;
  position: relative;
}

.risk-list li::before {
  content: '\2022';
  position: absolute;
  left: 0;
  color: var(--text-muted);
}

/* ── Modify plan button ─────────────────── */
.btn-modify-plan {
  border-color: var(--amber-dim);
  color: var(--amber);
}

.btn-modify-plan:hover {
  background: var(--amber-dim);
  color: #fcd34d;
}

/* ── Utility ─────────────────────────────── */
.hidden { display: none !important; }
.mono { font-family: var(--font); }
.dim { color: var(--text-dim); }
.muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.gap-sm { gap: 0.25rem; }
