/* PL+ Pulse. Meliora design system, web translation.
   Flat throughout. No shadows, no gradients, no glows. Hairlines only. */

/* ---------- Fonts (self-hosted) ---------- */
@font-face {
  font-family: 'Roca Two Light';
  src: url('assets/fonts/RocaTwo-Light.woff2') format('woff2');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Instrument Sans';
  src: url('assets/fonts/InstrumentSans-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Instrument Sans';
  src: url('assets/fonts/InstrumentSans-Medium.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Instrument Sans';
  src: url('assets/fonts/InstrumentSans-SemiBold.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Fira Code';
  src: url('assets/fonts/FiraCode-VariableFont_wght.woff2') format('woff2-variations');
  font-weight: 400; font-style: normal; font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  /* Colour */
  --sand: #F1F4ED;
  --sand-elevated: #F8FAF4;
  --teal-800: #143234;
  --teal-900: #0E2526;
  --stone-700: #3A4042;
  --stone-500: #606266;
  --ochre: #C6463C;
  --ochre-500: #D75A4A;
  --orange: #EA7943;
  --orange-soft: #FCE7D9;
  --divider: #B8B9BC;
  --divider-dark: #3F4448;
  --sage: #859363;
  --soft-teal: #7FB1B7;

  /* Type */
  --font-display: 'Roca Two Light', Georgia, serif;
  --font-body: 'Instrument Sans', Calibri, sans-serif;
  --font-mono: 'Fira Code', Consolas, monospace;

  /* Shape */
  --radius-card: 14px;
  --radius-tile: 10px;
  --radius-pill: 999px;

  /* Rhythm */
  --gap: 16px;
  --pad-card: 18px;
  --nav-w: 212px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--sand);
  color: var(--teal-800);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; }
a { color: var(--ochre); text-decoration: none; }
a:hover { color: var(--ochre-500); }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 300; }
p { margin: 0; }
[hidden] { display: none !important; }

/* ---------- Type helpers ---------- */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--orange);
}
.caption { font-size: 12px; color: var(--stone-500); }
.lede { font-family: var(--font-display); font-weight: 300; font-size: 18px; color: var(--orange); }
.view-heading { font-family: var(--font-display); font-weight: 300; font-size: 28px; color: var(--teal-800); }
.numeral { font-family: var(--font-display); font-weight: 300; font-size: 32px; color: var(--teal-800); line-height: 1.1; }
.mono-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--stone-500);
}

/* ---------- Left nav ---------- */
.app { display: flex; align-items: stretch; min-height: 100vh; }
.app__main { flex: 1; min-width: 0; }

.sidenav {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--nav-w);
  background: var(--teal-900);
  display: flex;
  flex-direction: column;
  padding: 22px 0 20px;
  z-index: 40;
}
.app__main { margin-left: var(--nav-w); }

.sidenav__brand { display: flex; flex-direction: column; gap: 9px; padding: 0 20px 24px; }
.sidenav__logo { height: 20px; width: auto; align-self: flex-start; }
.sidenav__title { font-family: var(--font-display); font-weight: 300; font-size: 22px; color: var(--sand); line-height: 1.1; }
.sidenav__eyebrow {
  font-family: var(--font-mono); font-size: 11px; font-weight: 400;
  text-transform: uppercase; letter-spacing: 0; color: var(--orange); line-height: 1.35;
}

.sidenav__links { display: flex; flex-direction: column; gap: 2px; }
.sidenav__links a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 20px;
  font-size: 14px;
  color: var(--sand);
  opacity: 0.72;
  border-left: 2px solid transparent;
  transition: opacity 120ms ease, color 120ms ease;
}
.sidenav__links a:hover { opacity: 1; color: var(--sand); }
.sidenav__links a[aria-current='page'] {
  opacity: 1;
  color: var(--ochre-500);
  border-left-color: var(--orange);
}
.sidenav__icon { width: 18px; height: 18px; flex: none; display: block; }

.sidenav__foot {
  margin-top: auto;
  display: flex; align-items: center; gap: 9px;
  padding: 18px 20px 0;
  border-top: 1px solid var(--divider-dark);
  font-size: 13px; color: var(--sand);
}

.spacer { flex: 1; }

/* Live dot: 7px orange dot, 12px halo at 18%, 2s pulse */
.live-dot { position: relative; width: 12px; height: 12px; display: inline-block; flex: none; }
.live-dot::before {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: var(--orange); opacity: 0.18; animation: halo 2s ease-in-out infinite;
}
.live-dot::after {
  content: ''; position: absolute; top: 2.5px; left: 2.5px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--orange);
}
@keyframes halo {
  0%, 100% { transform: scale(1); opacity: 0.18; }
  50% { transform: scale(1.5); opacity: 0.06; }
}
@media (prefers-reduced-motion: reduce) {
  .live-dot::before { animation: none; }
}

/* ---------- Layout ---------- */
.shell { max-width: 1400px; margin: 0 auto; padding: 26px 24px 40px; }
.view-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.footer {
  border-top: 1px solid var(--divider);
  margin-top: 36px;
  padding: 16px 24px 26px;
  text-align: left;
  max-width: 1400px;
  margin-left: auto; margin-right: auto;
}

/* ---------- Card primitives ---------- */
.card {
  background: var(--sand-elevated);
  border: 1px solid var(--divider);
  border-radius: var(--radius-card);
  padding: var(--pad-card);
}
.icon-tile {
  width: 40px; height: 40px; flex: none;
  border-radius: var(--radius-tile);
  background: var(--orange-soft);
  display: flex; align-items: center; justify-content: center;
}
.icon-tile img { width: 24px; height: 24px; display: block; }
.icon-tile--sm { width: 30px; height: 30px; border-radius: 8px; }
.icon-tile--sm img { width: 18px; height: 18px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 34px; padding: 0 16px;
  border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 500;
  background: var(--sand-elevated);
  color: var(--teal-800);
  border: 1px solid var(--divider);
  transition: background 120ms ease, color 120ms ease;
}
.btn:hover { background: var(--orange-soft); color: var(--teal-800); }
.btn--primary { background: var(--ochre); color: var(--sand); border-color: var(--ochre); }
.btn--primary:hover { background: var(--ochre-500); border-color: var(--ochre-500); color: var(--sand); }
.btn--quiet { border-color: transparent; background: transparent; color: var(--stone-500); height: 28px; padding: 0 10px; font-size: 12px; }
.btn--quiet:hover { background: var(--orange-soft); color: var(--teal-800); }
.btn[disabled] { opacity: 0.45; cursor: default; }
.btn img { width: 14px; height: 14px; }

/* ---------- Pills ---------- */
.pill {
  display: inline-flex; align-items: center;
  height: 19px; padding: 0 9px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 400;
  text-transform: uppercase; letter-spacing: 0;
  white-space: nowrap;
}
.pill--workstream { background: var(--orange-soft); color: var(--teal-800); }
.pill--isolated { background: var(--sand); color: var(--divider); }
.pill--repeated { background: var(--sand-elevated); color: var(--stone-700); border: 1px solid var(--divider); }
.pill--widespread { background: var(--sand-elevated); color: var(--ochre); border: 1px solid var(--divider); }
.pill--report { background: var(--sand); color: var(--stone-500); border: 1px solid var(--divider); }
.pill--pinned { background: var(--orange-soft); color: var(--ochre); }
.signal-glyph { font-family: var(--font-mono); font-size: 12px; line-height: 1; }
.signal-glyph--positive { color: var(--ochre); }
.signal-glyph--negative { color: var(--teal-800); }
.signal-glyph--neutral { color: var(--stone-500); }
.signal-glyph--mixed { color: var(--stone-700); }

/* ---------- Monitor: KPI row ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap); margin-bottom: var(--gap); }
.kpi { display: flex; flex-direction: column; gap: 12px; }
.kpi__label { font-size: 11px; color: var(--stone-500); text-transform: none; }

/* ---------- Monitor: two columns ---------- */
.monitor-cols { display: grid; grid-template-columns: 38% 1fr; gap: var(--gap); align-items: start; }
.col-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }

/* Agent cards */
.agent-list { display: flex; flex-direction: column; gap: 10px; }
.agent-card {
  display: flex; gap: 12px; align-items: flex-start;
  width: 100%; text-align: left;
  background: var(--sand-elevated);
  border: 1px solid var(--divider);
  border-radius: var(--radius-card);
  padding: 14px;
  transition: background 120ms ease;
}
.agent-card:hover { background: var(--orange-soft); }
.agent-card[aria-pressed='true'] { background: var(--orange-soft); }
.agent-card__body { flex: 1; min-width: 0; }
.agent-card__name { font-size: 14px; font-weight: 600; color: var(--teal-800); }
.agent-card__state { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--stone-700); margin-top: 5px; }
.agent-card__count { font-size: 12px; color: var(--stone-500); margin-top: 3px; }
.state-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--orange); }
.state-dot--sweeping { background: var(--ochre); box-shadow: none; position: relative; }
.state-dot--sweeping::after {
  content: ''; position: absolute; inset: -3px; border-radius: 50%;
  background: var(--ochre); opacity: 0.18; animation: halo 2s ease-in-out infinite;
}
.state-dot--failed { background: var(--divider); }
.agent-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }

/* Indeterminate scan bar: 2px orange rule that travels while a sweep runs.
   Motion only, no gradient or glow. */
.scan-rail { height: 2px; background: var(--divider); border-radius: 999px; overflow: hidden; margin: 10px 0 2px; }
.scan-rail__bar { height: 100%; width: 34%; background: var(--orange); animation: scan 1.5s ease-in-out infinite; }
@keyframes scan {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(320%); }
}
.agent-card__scan { height: 2px; background: var(--divider); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.agent-card__scan span { display: block; height: 100%; width: 40%; background: var(--ochre); animation: scan 1.5s ease-in-out infinite; }

/* Arrivals ticker */
.arrivals {
  display: inline-flex; align-items: center; height: 19px; padding: 0 9px;
  border-radius: var(--radius-pill);
  background: var(--orange-soft); color: var(--ochre);
  font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0;
  animation: slidein 260ms ease both;
}

@media (prefers-reduced-motion: reduce) {
  .scan-rail__bar, .agent-card__scan span { animation: none; width: 100%; }
  .arrivals { animation: none; }
}

/* Feed */
.feed { display: flex; flex-direction: column; gap: 10px; }
.feed-card { position: relative; display: flex; gap: 12px; }
.feed-card--new { animation: slidein 300ms ease both, flash 1400ms ease 300ms both; }
.feed-card--new .icon-tile { animation: tilepop 380ms ease both; }
@keyframes tilepop { from { transform: scale(0.82); } to { transform: none; } }
@keyframes slidein { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes flash { from { background-color: var(--orange-soft); } to { background-color: var(--sand-elevated); } }
@media (prefers-reduced-motion: reduce) {
  .feed-card--new, .feed-card--new .icon-tile { animation: none; }
}
.feed-card__body { flex: 1; min-width: 0; }
.feed-card__tags { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 8px; }
.feed-card__obs { font-size: 14px; color: var(--teal-800); }
.feed-card__obs.is-clamped { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.feed-card__more { font-size: 12px; color: var(--ochre); margin-top: 3px; }
.quote {
  margin: 9px 0 0;
  padding-left: 12px;
  border-left: 2px solid var(--ochre);
  font-size: 13px;
  color: var(--stone-700);
  font-style: italic;
}
.feed-card__meta { margin-top: 9px; font-size: 12px; color: var(--stone-500); }
.feed-card__why { margin-top: 6px; font-size: 12px; color: var(--stone-700); }
.feed-card__actions {
  display: flex; gap: 4px; margin-top: 10px; flex-wrap: wrap;
  opacity: 0; transition: opacity 120ms ease;
}
.feed-card:hover .feed-card__actions,
.feed-card:focus-within .feed-card__actions { opacity: 1; }
@media (hover: none) { .feed-card__actions { opacity: 1; } }

/* ---------- Insights table ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.field {
  height: 34px; padding: 0 12px;
  background: var(--sand-elevated);
  border: 1px solid var(--divider);
  border-radius: var(--radius-pill);
  font-size: 13px; color: var(--teal-800);
  outline: none;
}
.field:focus { border-color: var(--orange); }
select.field { padding-right: 26px; appearance: none; background-image: none; }
.toolbar__search { flex: 1; min-width: 180px; max-width: 320px; }
.table-wrap { border: 1px solid var(--divider); border-radius: var(--radius-card); overflow: hidden; background: var(--sand-elevated); }
table.data { width: 100%; border-collapse: collapse; }
table.data thead th {
  background: var(--teal-800);
  color: var(--sand);
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 400;
  text-transform: uppercase; letter-spacing: 0;
  text-align: left;
  padding: 9px 12px;
  white-space: nowrap;
}
table.data tbody td { padding: 11px 12px; vertical-align: top; font-size: 13px; border-top: 1px solid var(--divider); }
table.data tbody tr:nth-child(even) { background: var(--sand); }
table.data tbody tr:hover { background: var(--orange-soft); cursor: pointer; }
table.data tbody tr.is-dismissed { opacity: 0.5; }
.cell-obs { max-width: 460px; }
.cell-obs .quote { margin-top: 6px; font-size: 12px; }
.cell-actions { white-space: nowrap; }
.row-select { height: 26px; padding: 0 8px; font-size: 11px; border-radius: var(--radius-pill); border: 1px solid var(--divider); background: var(--sand-elevated); }

/* ---------- Detail panel ---------- */
.panel-scrim { position: fixed; inset: 0; background: rgba(14, 37, 38, 0.28); z-index: 50; }
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 420px; max-width: 100vw;
  background: var(--sand-elevated);
  border-left: 1px solid var(--divider);
  z-index: 51;
  display: flex; flex-direction: column;
}
.panel__head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 12px; }
.panel__body { flex: 1; overflow-y: auto; padding: 0 20px 20px; }
.panel__foot { border-top: 1px solid var(--divider); padding: 14px 20px; display: flex; gap: 8px; flex-wrap: wrap; }
.field-block { margin-bottom: 16px; }
.field-block > .mono-label { display: block; margin-bottom: 5px; }
.field-block input.field, .field-block select.field, .field-block textarea.field {
  width: 100%; border-radius: 10px;
}
.field-block textarea.field { height: auto; min-height: 84px; padding: 9px 12px; resize: vertical; line-height: 1.45; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Report view ---------- */
.report-cols { display: grid; grid-template-columns: 240px 1fr; gap: 24px; align-items: start; }
.rail { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 18px; }
.rail__group > .mono-label { display: block; margin-bottom: 8px; }
.outline { display: flex; flex-direction: column; gap: 4px; }
.outline button { text-align: left; font-size: 13px; color: var(--stone-700); padding: 3px 0; }
.outline button:hover { color: var(--ochre); }
.outline .lvl-2 { padding-left: 10px; font-size: 12px; }
.versions { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow-y: auto; }
.versions button { text-align: left; font-size: 12px; color: var(--stone-500); padding: 4px 0; }
.versions button:hover { color: var(--ochre); }
.rail__actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.rail__actions .btn { width: 100%; }

.doc-surface {
  background: var(--sand-elevated);
  border: 1px solid var(--divider);
  border-radius: var(--radius-card);
  max-width: 760px;
  padding: 46px 56px 60px;
}
.doc-toolbar {
  display: flex; gap: 4px; align-items: center; flex-wrap: wrap;
  max-width: 760px; margin-bottom: 12px;
  padding: 6px; background: var(--sand-elevated);
  border: 1px solid var(--divider); border-radius: var(--radius-pill);
}
.doc-toolbar button {
  height: 26px; min-width: 30px; padding: 0 9px; border-radius: var(--radius-pill);
  font-size: 12px; color: var(--stone-700);
}
.doc-toolbar button:hover { background: var(--orange-soft); color: var(--teal-800); }
.doc-toolbar button.is-active { background: var(--orange-soft); color: var(--ochre); }
.doc-toolbar .sep { width: 1px; height: 16px; background: var(--divider); margin: 0 4px; }
.save-state { text-align: right; max-width: 760px; margin-top: 8px; }

/* Editor content, styled as the Meliora document */
.ProseMirror { outline: none; }
.ProseMirror h1 { font-family: var(--font-display); font-weight: 300; font-size: 32px; color: var(--teal-800); margin: 0 0 6px; }
.ProseMirror h2 {
  font-family: var(--font-display); font-weight: 300; font-size: 22px; color: var(--teal-800);
  margin: 30px 0 8px; padding-top: 16px; border-top: 1px solid var(--divider);
}
.ProseMirror h3 { font-family: var(--font-display); font-weight: 300; font-size: 18px; color: var(--teal-800); margin: 20px 0 6px; }
.ProseMirror p { font-size: 15px; color: var(--teal-800); margin: 0 0 11px; line-height: 1.62; }
.ProseMirror p.subhead, .ProseMirror p[class='subhead'] { font-family: var(--font-display); font-size: 18px; color: var(--orange); font-style: normal; }
.ProseMirror p.subhead em { font-style: normal; }
.ProseMirror blockquote {
  margin: 0 0 12px; padding-left: 14px;
  border-left: 2px solid var(--ochre);
  color: var(--stone-700); font-style: italic;
}
.ProseMirror ul, .ProseMirror ol { margin: 0 0 12px; padding-left: 22px; font-size: 15px; line-height: 1.62; }
.ProseMirror li { margin-bottom: 4px; }
.ProseMirror hr { border: none; border-top: 1px solid var(--divider); margin: 22px 0; }
.ProseMirror a { color: var(--ochre); }
.ProseMirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder); float: left; height: 0; pointer-events: none; color: var(--stone-500);
}
.ProseMirror p.evidence-meta { font-size: 12px; color: var(--stone-500); }

/* ---------- Banners, toasts, empties ---------- */
.banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--orange-soft);
  border: 1px solid var(--divider);
  border-radius: var(--radius-card);
  padding: 11px 16px;
  font-size: 13px; color: var(--teal-800);
  margin-bottom: 14px;
}
.toast-stack { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--teal-900); color: var(--sand);
  border-radius: var(--radius-pill); padding: 9px 18px; font-size: 13px;
  animation: slidein 220ms ease both;
}
.empty {
  border: 1px solid var(--divider);
  border-radius: var(--radius-card);
  background: var(--sand-elevated);
  padding: 34px 22px; text-align: center;
  color: var(--stone-500); font-size: 13px;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app { display: block; }
  .app__main { margin-left: 0; }
  .sidenav {
    position: static;
    width: auto;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    flex-wrap: wrap;
  }
  .sidenav__brand { flex-direction: row; align-items: baseline; gap: 10px; padding: 0; }
  .sidenav__logo { align-self: center; }
  .sidenav__eyebrow { display: none; }
  .sidenav__links { flex-direction: row; gap: 4px; margin-left: auto; }
  .sidenav__links a { padding: 6px 10px; border-left: none; border-bottom: 2px solid transparent; }
  .sidenav__links a[aria-current='page'] { border-left-color: transparent; border-bottom-color: var(--orange); }
  .sidenav__links a span { display: none; }
  .sidenav__icon { width: 20px; height: 20px; }
  .sidenav__foot { margin-top: 0; padding: 0; border-top: none; width: 100%; }
  .shell { padding: 20px 14px 32px; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .monitor-cols { grid-template-columns: 1fr; }
  .report-cols { grid-template-columns: 1fr; }
  .rail { position: static; }
  .rail.is-collapsed { display: none; }
  .doc-surface { padding: 26px 20px 36px; }
  .panel { width: 100%; }
  .table-wrap { border: none; background: transparent; }
  table.data thead { display: none; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tbody tr {
    background: var(--sand-elevated); border: 1px solid var(--divider);
    border-radius: var(--radius-card); margin-bottom: 10px; padding: 6px 4px;
  }
  table.data tbody tr:nth-child(even) { background: var(--sand-elevated); }
  table.data tbody td { border-top: none; padding: 5px 12px; }
  table.data tbody td::before {
    content: attr(data-label);
    display: block;
    font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; color: var(--stone-500);
    margin-bottom: 2px;
  }
  table.data tbody td.cell-obs::before { display: none; }
  .cell-obs { max-width: none; }
}
.rail-toggle { display: none; }
@media (max-width: 900px) { .rail-toggle { display: inline-flex; margin-bottom: 12px; } }
