/* Sentinel × AlphaMind demo — Perseus design language.
 *
 * Tokens and patterns mirror the Perseus Health Monitor
 * (sentinel-perseus/status-dashboard, public/styles.css): light warm-gray
 * canvas with a faint engineering grid, white hairline-bordered surfaces,
 * square corners, Manrope for prose, DM Mono for identifiers and
 * micro-labels, and status communicated by soft-ringed dots and tinted
 * chips — never by colour alone.
 */

:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-soft: #f9faf8;
  --ink: #17211e;
  --muted: #6f7c77;
  --faint: #98a39f;
  --line: #dfe4e1;
  --line-strong: #cfd7d3;
  --green: #23865f;
  --green-soft: #e8f5ef;
  --blue: #477e9d;
  --blue-soft: #ebf3f8;
  --amber: #b4761e;
  --amber-soft: #fbf1dd;
  --red: #b54c45;
  --red-soft: #f9e9e7;
  --shadow: 0 12px 32px rgba(31, 45, 40, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Manrope, sans-serif;
  font-size: 14px;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }

.shell {
  min-height: 100vh;
  background-image:
    linear-gradient(rgba(30, 55, 47, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(30, 55, 47, 0.025) 1px, transparent 1px);
  background-size: 56px 56px;
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------------ topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  padding: 0 max(24px, calc((100vw - 1560px) / 2));
  border-bottom: 1px solid rgba(207, 215, 211, 0.88);
  background: rgba(250, 251, 248, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line-strong);
  background: var(--surface);
}

.brand-mark img { width: 28px; height: 28px; object-fit: contain; }

.brand > span:last-child { display: flex; flex-direction: column; gap: 3px; }

.brand strong, .brand small {
  font-family: "DM Mono", monospace;
  letter-spacing: 0.1em;
}
.brand strong { font-size: 11px; }
.brand small { color: var(--muted); font-size: 8px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.poll-label {
  color: var(--muted);
  font: 9px "DM Mono", monospace;
  letter-spacing: 0.04em;
}

.poll-label i {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 4px #edf0ee;
}

.poll-label:has(.health.ok) i { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.poll-label:has(.health.bad) i { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }

.poll-label b { color: var(--ink); font-weight: 500; }

.health { color: var(--muted); }
.health.ok { color: var(--green); }
.health.bad { color: var(--red); }

/* ------------------------------------------------------------------ layout */

main {
  flex: 1;
  display: flex;
  align-items: stretch;
  max-width: 1560px;
  width: 100%;
  margin: 0 auto;
}

aside {
  width: 400px;
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  padding: 28px 24px 48px;
  overflow-y: auto;
}

.section-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 15px;
}

.section-title > div:first-child {
  display: flex;
  align-items: center;
  gap: 13px;
}

.section-number {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 1px solid var(--line-strong);
  color: var(--faint);
  font: 500 8px "DM Mono", monospace;
}

.section-title h2 { margin: 0; font-size: 13px; }
.section-title p { margin: 3px 0 0; color: var(--muted); font-size: 9px; }

.runs-heading { margin-top: 34px; }

/* ------------------------------------------------------------------ form */

.tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.56);
}

.tab {
  flex: 1;
  padding: 7px 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 500 8.5px "DM Mono", monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.tab.active { background: var(--ink); color: #fff; }

form label {
  display: block;
  margin-bottom: 13px;
  color: #53615c;
  font-size: 8px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

textarea, input, select {
  display: block;
  width: 100%;
  margin-top: 7px;
  padding: 0 11px;
  outline: none;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 11px;
  letter-spacing: normal;
  text-transform: none;
}

input, select { height: 40px; }
textarea { padding: 9px 11px; resize: vertical; line-height: 1.6; font-family: "DM Mono", monospace; font-size: 10px; }

textarea:focus, input:focus, select:focus { border-color: #93a69d; }

.hidden { display: none; }

.constraints {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.56);
  color: var(--muted);
  font-size: 9px;
}

.constraints summary {
  cursor: pointer;
  font: 500 8px "DM Mono", monospace;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.constraints[open] summary { margin-bottom: 6px; }
.constraints .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }

#submit-btn {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: #fff;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

#submit-btn:hover { background: #243029; }
#submit-btn:disabled { opacity: 0.5; cursor: wait; }

.link-btn {
  background: none;
  border: none;
  color: var(--blue);
  cursor: pointer;
  font: 500 8px "DM Mono", monospace;
  letter-spacing: 0.06em;
  padding: 6px 0 0;
  text-transform: none;
}

.link-btn:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ run list */

.run-list { list-style: none; margin: 0; padding: 0; }

.run-list li {
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  margin-bottom: 8px;
  cursor: pointer;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.run-list li:hover { border-color: #abb9b3; }
.run-list li.active { border-color: var(--ink); box-shadow: inset 3px 0 0 var(--ink); }

.run-list .rl-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  font-size: 11px;
  font-weight: 600;
}

.run-list .rl-meta {
  color: var(--muted);
  font: 8px "DM Mono", monospace;
  margin-top: 7px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ------------------------------------------------------------------ detail */

.detail { flex: 1; min-width: 0; padding: 28px 32px 64px; overflow-y: auto; }
.detail.empty { display: flex; align-items: center; justify-content: center; }

.detail.empty .placeholder {
  color: var(--faint);
  font: 9px "DM Mono", monospace;
  letter-spacing: 0.08em;
}

/* ------------------------------------------------------------------ badges & buttons */

.badge {
  display: inline-block;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface-soft);
  color: var(--muted);
  font: 500 7.5px "DM Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  vertical-align: middle;
}

.badge.running, .badge.created, .badge.pending, .badge.queued {
  border-color: #c6d9e4; background: var(--blue-soft); color: var(--blue);
}
.badge.cancelling, .badge.cancelled {
  border-color: #ead4aa; background: var(--amber-soft); color: var(--amber);
}
.badge.completed { border-color: #bedccc; background: var(--green-soft); color: var(--green); }
.badge.failed { border-color: #e7c5c2; background: var(--red-soft); color: var(--red); }

.cancel-btn {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 0;
  color: var(--muted);
  cursor: pointer;
  font: 500 8px "DM Mono", monospace;
  padding: 2px 7px;
  margin-left: auto;
}

.cancel-btn:hover { color: var(--red); border-color: var(--red); }

.cancel-btn-lg {
  background: var(--surface);
  border: 1px solid var(--red);
  border-radius: 0;
  color: var(--red);
  cursor: pointer;
  font: 500 8px "DM Mono", monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 12px;
  margin-left: 12px;
  vertical-align: middle;
}

.cancel-btn-lg:hover { background: var(--red); color: #fff; }

/* ------------------------------------------------------------------ cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 0;
  box-shadow: var(--shadow);
  padding: 19px 20px;
  margin-bottom: 14px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 12px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.prose { white-space: pre-wrap; line-height: 1.65; color: var(--ink); font-size: 12px; }

/* ------------------------------------------------------------------ tables */

table { width: 100%; border-collapse: collapse; font-size: 11px; }

th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

tr:last-child td { border-bottom: 0; }

th {
  color: var(--faint);
  font: 500 7.5px "DM Mono", monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: #f3f5f2;
}

td.num, th.num { text-align: right; }

td strong { font-family: "DM Mono", monospace; font-size: 11px; letter-spacing: -0.01em; }

.weight-bar {
  display: inline-block;
  height: 7px;
  background: var(--green);
  border-radius: 0;
  vertical-align: middle;
  margin-right: 8px;
  opacity: 0.8;
}

.action-increase, .action-buy { color: var(--green); font-weight: 600; }
.action-decrease, .action-sell, .action-exit { color: var(--red); font-weight: 600; }
.action-hold { color: var(--muted); }

/* ------------------------------------------------------------------ notes, events, misc */

.notes-list { display: flex; flex-direction: column; gap: 6px; }

.note-row {
  border-left: 2px solid var(--line-strong);
  padding: 2px 0 2px 10px;
  color: var(--ink);
  line-height: 1.55;
  font-size: 11px;
}

.events-feed {
  max-height: 260px;
  overflow-y: auto;
  font: 9px "DM Mono", monospace;
  color: var(--muted);
  line-height: 1.6;
}

.events-feed .ev { padding: 4px 0; border-bottom: 1px dotted var(--line); }
.events-feed .ev.tool_start { color: var(--amber); }

.followup { display: flex; gap: 8px; margin-top: 4px; }
.followup input { flex: 1; margin-top: 0; }

.followup button {
  padding: 0 16px;
  background: var(--ink);
  color: #fff;
  border: 1px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.followup button:hover { background: #243029; }

.error-box {
  background: var(--red-soft);
  border: 1px solid #e7c5c2;
  border-radius: 0;
  padding: 12px 16px;
  margin-bottom: 14px;
  color: var(--red);
  font-size: 11px;
  line-height: 1.55;
}

ul.notes { margin: 6px 0; padding-left: 18px; }
ul.notes li { margin-bottom: 4px; font-size: 11px; }
ul.notes code { font-family: "DM Mono", monospace; font-size: 10px; background: rgba(0,0,0,0.05); padding: 1px 5px; }

.spinner {
  display: inline-block;
  width: 11px;
  height: 11px;
  border: 2px solid var(--blue);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ footer */

footer {
  display: flex;
  justify-content: space-between;
  max-width: 1560px;
  width: 100%;
  margin: auto auto 0;
  padding: 18px 28px 32px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font: 7.5px "DM Mono", monospace;
  letter-spacing: 0.1em;
}

/* ------------------------------------------------------------------ responsive */

@media (max-width: 900px) {
  main { flex-direction: column; }
  aside { width: 100%; border-right: 0; border-bottom: 1px solid var(--line); }
  .detail { padding: 24px 20px 48px; }
  .topbar { padding: 0 16px; }
  footer { padding-right: 16px; padding-left: 16px; }
  .constraints .grid { grid-template-columns: 1fr; }
}

/* ---- login ---- */
#login-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 340px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 28px; }
.login-card label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 12px; }
.login-error { background: #3d1d1d; border: 1px solid var(--red); border-radius: 6px; padding: 8px 12px; color: #ffb3ae; font-size: 12px; margin-bottom: 10px; }
.full-btn { width: 100%; padding: 10px; background: var(--accent); color: #fff; border: none; border-radius: 6px; font-weight: 700; cursor: pointer; }

/* ---- header / misc ---- */
.header-right { display: flex; align-items: center; gap: 14px; }
.user-email { color: var(--muted); font-size: 12px; }
.side-note { color: var(--muted); font-size: 12px; line-height: 1.5; padding: 4px 2px; }
.save-btn { padding: 7px 16px; background: var(--accent); color: #fff; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; }
.warn-box { background: #3d3a1d; border: 1px solid var(--amber); border-radius: 6px; padding: 10px 14px; color: #f0d9a8; margin-bottom: 16px; }
.muted { color: var(--muted); }
.sched-row { display: flex; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px dotted var(--border); font-size: 13px; }
#pos-table input { margin-top: 0; padding: 5px 7px; }
.hidden { display: none !important; }
