/**
 * Posteingang (inbound communications triage) workbench styles.
 *
 * Speaks the same visual language as the casework workbench (the cockpit the
 * user lives in): the cw palette, the display font for headings, white card
 * panels on the soft canvas, pill states, and the lifted primary buttons. The
 * tokens are mirrored here as --pw-* so the sheet stays self-contained. Every
 * status is a tinted pill with a text label (never colour alone), the lowest
 * text pair is --pw-muted var(--legacy-ink-soft, #6b6560) on white at 4.7:1, and each scrollable list
 * sits in a focusable region so keyboard users can reach what it scrolls.
 */

.pw-root {
  --pw-ink: var(--legacy-ink, #232323);
  --pw-muted: var(--legacy-ink-soft, #6b6560);
  --pw-line: var(--legacy-line, #e7e4e0);
  --pw-surface: #ffffff;
  --pw-canvas: var(--legacy-paper, #f6f4f1);
  --pw-blue: var(--legacy-blue, #1300ff);
  --pw-blue-dark: var(--legacy-blue-hover, #0f00cc);
  --pw-red: #9b1c1c;
  --pw-amber: #855000;
  --pw-green: #197054;
  --pw-gap: 22px;
  display: flex;
  flex-direction: column;
  gap: var(--pw-gap);
  max-width: 1240px;
  margin: 0 auto;
  padding: 34px 30px 60px;
  color: var(--pw-ink);
  font-family: var(--font-body, inherit);
}

/* ---------- header ---------- */

.pw-eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--pw-blue);
}

.pw-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.pw-lede {
  margin: 0;
  max-width: 74ch;
  font-size: 15px;
  line-height: 1.6;
  color: var(--pw-muted);
}

/* ---------- section panels (the cockpit card language) ---------- */

.pw-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 24px;
  background: var(--pw-surface);
  border: 1px solid var(--pw-line);
  border-radius: 18px;
  box-shadow: 0 8px 26px rgba(21, 24, 43, 0.05);
}

.pw-section__head {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.pw-section__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 21px;
  letter-spacing: -0.02em;
}

.pw-section__lede {
  margin: 0;
  max-width: 88ch;
  font-size: 13.5px;
  color: var(--pw-muted);
  line-height: 1.55;
}

.pw-totals {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pw-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 700;
  color: #526079;
  background: #eef0f5;
  border-radius: 999px;
}

.pw-chip--attention {
  color: var(--pw-amber);
  background: #fdf1dc;
}

/* ---------- focusable scroll region + lists ---------- */

.pw-scroll {
  max-height: 480px;
  overflow-y: auto;
  padding: 3px;
  border-radius: 14px;
}

.pw-scroll:focus-visible,
.pw-button:focus-visible,
.pw-icon-button:focus-visible,
.pw-section__title:focus-visible {
  outline: 3px solid rgba(59, 54, 242, 0.28);
  outline-offset: 2px;
}

.pw-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- review / follow-up / exception rows ---------- */

.pw-review,
.pw-followup,
.pw-exception {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 14px 16px;
  background: var(--pw-surface);
  border: 1px solid var(--pw-line);
  border-radius: 14px;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.pw-review:hover,
.pw-followup:hover,
.pw-exception:hover {
  border-color: var(--legacy-line-strong, #d8d4cf);
  box-shadow: 0 6px 18px rgba(21, 24, 43, 0.07);
}

/* A needing-attention item carries a left rule in addition to its pill, so the
   cue is not colour alone. */
.pw-review--attention {
  border-left: 3px solid var(--pw-amber);
}

.pw-review__head,
.pw-exception__head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.pw-review__channel {
  font-size: 13px;
  color: var(--pw-muted);
}

.pw-review__flag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--legacy-blue, #1300ff);
  background: var(--legacy-blue-soft, #eceaff);
  border-radius: 999px;
}

.pw-review__subject,
.pw-followup__subject {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}

.pw-review__meta,
.pw-followup__meta,
.pw-exception__meta {
  margin: 0;
  font-size: 13px;
  color: var(--pw-muted);
  line-height: 1.5;
}

.pw-exception__title {
  font-size: 15px;
  font-weight: 650;
}

/* ---------- state pills (cw-state language: tinted, labelled) ---------- */

.pw-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  color: #3f4962;
  background: #eceef4;
}

.pw-badge--success { color: var(--pw-green); background: #e2f5ed; }
.pw-badge--info { color: var(--legacy-blue, #1300ff); background: var(--legacy-blue-soft, #eceaff); }
.pw-badge--warning { color: var(--pw-amber); background: #fdf1dc; }
.pw-badge--danger { color: var(--pw-red); background: #fbe4e4; }
.pw-badge--neutral { color: #526079; background: #eef0f5; }

/* ---------- states ---------- */

.pw-state {
  margin: 0;
  padding: 18px 20px;
  border: 1px solid var(--pw-line);
  border-radius: 14px;
  background: var(--pw-canvas);
  color: var(--pw-muted);
  line-height: 1.55;
}

.pw-state--empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.pw-state--error {
  border-color: #f0c4c4;
  background: #fdf5f5;
  color: var(--pw-ink);
}

.pw-state__title {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--pw-ink);
}

.pw-state__reason,
.pw-state__hint {
  margin: 0 0 8px;
  color: var(--pw-muted);
  line-height: 1.55;
}

.pw-state--error .pw-state__reason {
  color: var(--pw-red);
}

/* ---------- buttons (cw-button language) ---------- */

.pw-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 6px;
  min-height: 44px;
  min-width: 44px;
  padding: 10px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 750;
  color: #fff;
  text-decoration: none;
  background: var(--pw-blue);
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(59, 54, 242, 0.19);
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}

.pw-button:hover:not(:disabled) {
  background: var(--pw-blue-dark);
  transform: translateY(-1px);
}

.pw-button--secondary {
  color: var(--pw-ink);
  background: var(--pw-surface);
  border-color: var(--pw-line);
  box-shadow: none;
}

.pw-button--secondary:hover:not(:disabled) {
  color: var(--pw-ink);
  background: var(--pw-canvas);
}

.pw-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
  box-shadow: none;
}

/* ---------- footnote ---------- */

.pw-page-footnote {
  padding-top: 2px;
}

.pw-page-footnote p {
  margin: 0;
  max-width: 80ch;
  font-size: 12.5px;
  color: var(--pw-muted);
  line-height: 1.55;
}

@media (prefers-reduced-motion: reduce) {
  .pw-root * {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- communication timeline (?view=timeline) ---------- */

.pw-back {
  color: var(--pw-blue);
  text-decoration: none;
  font-weight: 650;
}

.pw-back:hover {
  text-decoration: underline;
}

.communication-timeline {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 22px;
  align-items: start;
}

@media (max-width: 880px) {
  .communication-timeline {
    grid-template-columns: 1fr;
  }
}

.communication-timeline__list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 20px;
  background: var(--pw-surface);
  border: 1px solid var(--pw-line);
  border-radius: 18px;
  box-shadow: 0 8px 26px rgba(21, 24, 43, 0.05);
}

.communication-timeline__threads {
  max-height: 560px;
  overflow-y: auto;
  padding: 3px;
  border-radius: 14px;
}

.communication-timeline__threads:focus-visible,
.pw-back:focus-visible {
  outline: 3px solid rgba(59, 54, 242, 0.28);
  outline-offset: 2px;
}

.communication-timeline__threads > ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.communication-timeline__thread {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--pw-surface);
  border: 1px solid var(--pw-line);
  border-radius: 14px;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.communication-timeline__thread:hover {
  border-color: var(--legacy-line-strong, #d8d4cf);
  box-shadow: 0 6px 18px rgba(21, 24, 43, 0.07);
}

.communication-timeline__thread.is-current {
  border-color: var(--pw-blue);
  background: #f4f3ff;
  box-shadow: inset 0 0 0 1px var(--pw-blue);
}

.communication-timeline__thread:focus-visible {
  outline: 3px solid rgba(59, 54, 242, 0.28);
  outline-offset: 2px;
}

.communication-timeline__thread > strong {
  font-size: 14.5px;
}

.communication-timeline__thread > p {
  margin: 0;
  font-size: 13px;
  color: var(--pw-muted);
}

.communication-timeline__thread-meta {
  font-size: 12px;
  color: var(--pw-muted);
}

.communication-timeline__main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.communication-timeline__detail {
  padding: 18px 20px;
  background: var(--pw-surface);
  border: 1px solid var(--pw-line);
  border-radius: 18px;
  box-shadow: 0 8px 26px rgba(21, 24, 43, 0.05);
}

.communication-timeline__detail > header {
  border-bottom: 1px solid var(--pw-line);
  padding-bottom: 8px;
  margin-bottom: 12px;
}

#communication-timeline-detail-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 19px;
  letter-spacing: -0.02em;
}

.communication-timeline__messages {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.communication-timeline__message {
  padding: 12px 14px;
  background: var(--pw-canvas);
  border: 1px solid var(--pw-line);
  border-radius: 14px;
}

.communication-timeline__message-head {
  margin: 0 0 4px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--pw-muted);
}

.communication-timeline__message-body {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
}

.dwc-context {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 14px 16px;
  background: var(--legacy-blue-soft, #eceaff);
  border-radius: 14px;
}

.dwc-context__status {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--legacy-blue, #1300ff);
}

.dwc-context__copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
}

.dwc-context__copy > span {
  font-size: 13.5px;
  color: var(--pw-ink);
}

.dwc-context__action {
  font-weight: 650;
  color: var(--legacy-blue, #1300ff);
}

/* ---------- governed writes: action strips, flash, dialog ---------- */

.pw-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 10px;
}

.pw-action {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
}

.pw-button--action {
  margin-top: 0;
  min-height: 38px;
  padding: 7px 14px;
  font-size: 13px;
}

.pw-action-reason {
  max-width: 34ch;
  font-size: 11.5px;
  color: var(--pw-muted);
  line-height: 1.4;
}

.pw-flash {
  margin: 0;
}

.pw-flash:focus {
  outline: none;
}

.pw-flash__message {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin: 0;
  padding: 13px 18px;
  font-size: 13.5px;
  border-radius: 14px;
  border: 1px solid var(--pw-line);
  background: var(--pw-surface);
  box-shadow: 0 8px 26px rgba(21, 24, 43, 0.05);
}

.pw-flash__message p {
  margin: 0;
  line-height: 1.5;
}

.pw-flash__message .pw-button--flash {
  margin-top: 0;
  min-height: 38px;
  padding: 7px 14px;
  font-size: 13px;
}

.pw-flash__message--success {
  border-color: #b9e2d2;
  background: #e2f5ed;
  color: #0c4a36;
}

.pw-flash__message--error {
  border-color: #f0c4c4;
  background: #fbe4e4;
  color: var(--pw-red);
}

.pw-flash__message--info {
  border-color: #cfd3f5;
  background: var(--legacy-blue-soft, #eceaff);
  color: #232063;
}

/* ---------- dialog (cw-dialog language) ---------- */

.pw-dialog {
  width: min(620px, calc(100vw - 28px));
  max-height: calc(100vh - 36px);
  padding: 0;
  color: var(--pw-ink);
  border: 1px solid var(--pw-line);
  border-radius: 18px;
  box-shadow: 0 30px 90px rgba(20, 20, 50, 0.25);
}

.pw-dialog::backdrop {
  background: rgba(14, 15, 31, 0.56);
  backdrop-filter: blur(4px);
}

.pw-dialog form {
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 20px 22px;
}

.pw-dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--pw-line);
}

.pw-dialog__head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.pw-icon-button {
  min-width: 36px;
  min-height: 36px;
  font-size: 18px;
  line-height: 1;
  color: var(--pw-muted);
  background: transparent;
  border: 1px solid var(--pw-line);
  border-radius: 11px;
  cursor: pointer;
}

.pw-icon-button:hover {
  background: var(--pw-canvas);
}

.pw-dialog__lede,
.pw-dialog__scope {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--pw-muted);
}

.pw-dialog__scope {
  padding: 10px 14px;
  border: 1px solid #deddf9;
  border-radius: 12px;
  background: #f7f6ff;
  color: var(--pw-ink);
}

.pw-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 650;
}

.pw-field select,
.pw-field input,
.pw-field textarea {
  font: inherit;
  font-weight: 400;
  padding: 9px 11px;
  border: 1px solid var(--pw-line);
  border-radius: 11px;
  background: var(--pw-surface);
}


.pw-dialog__error {
  min-height: 1em;
  font-size: 13px;
  color: var(--pw-red);
}

.pw-dialog__error:empty {
  display: none;
}

.pw-dialog__foot {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding-top: 13px;
  border-top: 1px solid var(--pw-line);
}
