/* =====================================================================
   TaxPeel app component classes — built on tokens.css.
   These are the building blocks Jinja templates reference via _macros.html.
   ===================================================================== */

/* ── HTMX indicator ──────────────────────────────────────────────── */
.htmx-indicator { opacity: 0; transition: opacity 200ms ease; }
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request.htmx-indicator { opacity: 1; }

/* Alpine.js: hide elements with x-cloak until the framework binds. */
[x-cloak] { display: none !important; }

/* Tab-pane fallback when Alpine fails to load: stack them vertically
   with a visible separator so the workspace still readable. Once Alpine
   is alive it controls visibility via x-show, overriding this rule. */
.tp-tab-pane + .tp-tab-pane { margin-top: 32px; padding-top: 24px; border-top: 2px dashed var(--tp-border); }

/* Narrative tab grid layout — moved out of inline style so x-show display:none can override. */
.tp-narrative-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 16px;
  align-items: flex-start;
}

/* Hide number-input arrows for cleaner cell editing. */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] { -moz-appearance: textfield; }

/* ── App shell / topbar ──────────────────────────────────────────── */
.tp-topbar {
  background: var(--tp-paper);
  border-bottom: var(--tp-border-thin);
  padding: 0 28px;
  height: var(--tp-topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
}
.tp-topbar__left  { display: flex; align-items: center; gap: 36px; }
.tp-topbar__brand { display: flex; align-items: center; }
.tp-topbar__brand img { height: 28px; display: block; }
.tp-topbar__nav   { display: flex; gap: 4px; }
.tp-topbar__nav a {
  font-family: var(--tp-font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--tp-fg-muted);
  padding: 6px 12px;
  border-radius: 3px;
  position: relative;
  border-bottom: none;
  transition: color var(--tp-duration-fast) var(--tp-ease);
}
.tp-topbar__nav a:hover { color: var(--tp-navy); }
.tp-topbar__nav a.is-active { color: var(--tp-navy); font-weight: 700; }
.tp-topbar__nav a.is-active::after {
  content: '';
  position: absolute;
  left: 12px; right: 12px; bottom: -19px;
  height: 2px;
  background: var(--tp-navy);
}
.tp-topbar__right { font-size: 12px; color: var(--tp-fg-subtle); display: flex; align-items: center; gap: 12px; }
.tp-topbar__right .tp-user { color: var(--tp-fg-muted); }
.tp-topbar__right .tp-divider { color: var(--tp-fg-faint); }
.tp-topbar__right form button {
  background: none; border: none; cursor: pointer;
  color: var(--tp-fg-subtle); font: inherit;
  text-decoration: underline; text-underline-offset: 2px;
}
.tp-topbar__right form button:hover { color: var(--tp-navy); }

/* ── Page container ──────────────────────────────────────────────── */
.tp-page {
  padding: var(--tp-space-5) var(--tp-space-6);
  max-width: var(--tp-container);
  margin: 0 auto;
}
.tp-page--wide {
  max-width: none;
  padding: var(--tp-space-5) var(--tp-space-6);
}

/* ── Cards ───────────────────────────────────────────────────────── */
.tp-card {
  background: var(--tp-paper);
  border: var(--tp-border-thin);
  border-radius: var(--tp-radius-sm);
  padding: var(--tp-space-4);
}
.tp-card--flush { padding: 0; }
.tp-card--accent-top { border-top: 2px solid var(--tp-terra); }

.tp-card__header {
  padding: 10px 14px;
  border-bottom: var(--tp-border-soft-1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.tp-card__header--plain { border-bottom: none; }
.tp-card__body { padding: var(--tp-space-4); }

/* ── Buttons ─────────────────────────────────────────────────────── */
.tp-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--tp-font-body);
  font-weight: var(--tp-weight-semibold);
  font-size: 13px;
  line-height: 1.2;
  padding: 7px 14px;
  border-radius: var(--tp-radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--tp-duration) var(--tp-ease),
              border-color var(--tp-duration) var(--tp-ease),
              color var(--tp-duration) var(--tp-ease);
  text-decoration: none;
  white-space: nowrap;
}
.tp-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.tp-btn--sm { padding: 4px 10px; font-size: 12px; }
.tp-btn--lg { padding: 10px 18px; font-size: 14px; }

.tp-btn--navy    { background: var(--tp-navy); color: #fff; border-color: var(--tp-navy); }
.tp-btn--navy:hover    { background: var(--tp-navy-700); border-color: var(--tp-navy-700); }
.tp-btn--terra   { background: var(--tp-terra); color: #fff; border-color: var(--tp-terra); }
.tp-btn--terra:hover   { background: var(--tp-terra-400); border-color: var(--tp-terra-400); }
.tp-btn--outline { background: var(--tp-paper); color: var(--tp-navy); border-color: var(--tp-navy); }
.tp-btn--outline:hover { background: var(--tp-bg-soft); }
.tp-btn--ghost   { background: transparent; color: var(--tp-navy); border-color: transparent; }
.tp-btn--ghost:hover   { background: var(--tp-bg-fill); }
.tp-btn--soft    { background: var(--tp-bg-fill); color: var(--tp-navy); border-color: var(--tp-border); }
.tp-btn--soft:hover    { background: var(--tp-bg-soft); }
.tp-btn--danger  { background: var(--tp-paper); color: var(--tp-negative); border-color: var(--tp-negative); }
.tp-btn--danger:hover  { background: var(--tp-negative-bg); }

.tp-btn__count {
  font-size: 10px;
  font-weight: 700;
  background: rgba(255,255,255,0.2);
  color: inherit;
  padding: 1px 6px;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
  border-left: 1px solid rgba(255,255,255,0.25);
  padding-left: 8px;
  margin-left: 4px;
}

/* ── Form controls ───────────────────────────────────────────────── */
.tp-input, .tp-select, .tp-textarea {
  font-family: var(--tp-font-body);
  font-size: 13px;
  padding: 7px 10px;
  border: var(--tp-border-thin);
  border-radius: var(--tp-radius-sm);
  background: var(--tp-paper);
  color: var(--tp-fg);
  outline: none;
  transition: border-color var(--tp-duration-fast) var(--tp-ease);
}
.tp-input:focus, .tp-select:focus, .tp-textarea:focus {
  border-color: var(--tp-focus-ring);
}
.tp-input--num { text-align: right; font-variant-numeric: tabular-nums; }
.tp-input--inline {
  background: transparent;
  border-color: transparent;
  padding: 2px 6px;
}
.tp-input--inline:hover { border-color: var(--tp-border); }
.tp-input--inline:focus { border-color: var(--tp-navy); background: var(--tp-paper); }

/* ── Pills / badges ──────────────────────────────────────────────── */
.tp-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 3px;
  background: var(--tp-bg-fill);
  color: var(--tp-fg-muted);
  border: 1px solid var(--tp-border);
  text-transform: uppercase;
}
.tp-pill--block    { background: var(--tp-negative-bg); color: var(--tp-negative); border-color: #e8b8b8; }
.tp-pill--warn     { background: var(--tp-warning-bg);  color: var(--tp-warning-fg); border-color: var(--tp-warning-border); }
.tp-pill--info     { background: var(--tp-bg-fill);     color: var(--tp-navy); border-color: var(--tp-border); }
.tp-pill--positive { background: var(--tp-positive-bg); color: var(--tp-positive); border-color: #b8d8c4; }
.tp-pill--terra    { background: var(--tp-terra-100);   color: var(--tp-terra); border-color: var(--tp-terra-200); }
.tp-pill--solid    { background: var(--tp-navy); color: #fff; border-color: var(--tp-navy); }
.tp-pill--center   { min-width: 52px; text-align: center; }

/* Soft round-cornered count badge for tabs. */
.tp-count {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  background: var(--tp-border-soft);
  color: var(--tp-fg-subtle);
  padding: 1px 6px;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
  margin-left: 6px;
}
.tp-count--active { background: var(--tp-navy); color: #fff; }

/* ── Status dot ──────────────────────────────────────────────────── */
.tp-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--tp-fg-subtle);
  flex-shrink: 0;
}
.tp-dot--pass    { background: var(--tp-positive); }
.tp-dot--fail    { background: var(--tp-negative); }
.tp-dot--warn    { background: var(--tp-warning); }
.tp-dot--pending { background: var(--tp-fg-subtle); }
.tp-dot--live    { background: var(--tp-positive); box-shadow: 0 0 0 0 rgba(26,107,60,0.4); animation: tp-live-pulse 1.6s infinite; }
@keyframes tp-live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(26,107,60,0.4); }
  70%  { box-shadow: 0 0 0 6px rgba(26,107,60,0); }
  100% { box-shadow: 0 0 0 0 rgba(26,107,60,0); }
}

/* ── Confidence bar ──────────────────────────────────────────────── */
.tp-conf {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  vertical-align: middle;
}
.tp-conf__bar {
  width: 38px; height: 5px;
  background: var(--tp-border-soft);
  border-radius: 3px;
  overflow: hidden;
}
.tp-conf__fill {
  height: 100%;
  background: var(--tp-positive);
}
.tp-conf__fill--mid  { background: var(--tp-terra); }
.tp-conf__fill--low  { background: var(--tp-warning); }
.tp-conf__num {
  font-size: 11px;
  color: var(--tp-fg-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ── Countdown chip (header) ─────────────────────────────────────── */
.tp-countdown {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  background: var(--tp-bg-soft);
  padding: 4px 10px;
  border-radius: 3px;
  line-height: 1.15;
}
.tp-countdown__eyebrow {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tp-fg-subtle);
}
.tp-countdown__value {
  font-size: 12px;
  font-weight: 700;
  color: var(--tp-navy);
  font-variant-numeric: tabular-nums;
}
.tp-countdown--overdue { background: var(--tp-negative-bg); }
.tp-countdown--overdue .tp-countdown__value { color: var(--tp-negative); }
.tp-countdown--urgent  { background: var(--tp-terra-100); }
.tp-countdown--urgent  .tp-countdown__value { color: var(--tp-terra); }

/* Inline countdown badge inside a primary button. */
.tp-btn__countdown {
  margin-left: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  border-left: 1px solid rgba(255,255,255,0.25);
  padding-left: 8px;
  color: var(--tp-navy-200);
}
.tp-btn--terra .tp-btn__countdown { color: rgba(255,255,255,0.85); }

/* ── Tab strip ───────────────────────────────────────────────────── */
.tp-tabs {
  display: flex;
  gap: 0;
  border-bottom: var(--tp-border-thin);
  margin-top: 14px;
}
.tp-tab {
  font-family: var(--tp-font-body);
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  color: var(--tp-fg-subtle);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
  cursor: pointer;
  margin-bottom: -1px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: color var(--tp-duration-fast) var(--tp-ease);
}
.tp-tab:hover { color: var(--tp-navy); }
.tp-tab.is-active {
  color: var(--tp-navy);
  border-bottom-color: var(--tp-terra);
}

/* ── Doc table (used inside cards) ───────────────────────────────── */
.tp-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--tp-font-body);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.tp-table thead th {
  padding: 10px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tp-fg-subtle);
  border-bottom: var(--tp-border-thin);
  white-space: nowrap;
  background: #fafbfd;
}
.tp-table tbody td {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--tp-fg);
  border-bottom: 1px solid #f4f6fa;
  white-space: nowrap;
}
.tp-table .tp-td--r,
.tp-table th.tp-td--r { text-align: right; }
.tp-table tbody tr:last-child td { border-bottom: none; }
.tp-table tbody tr.is-clickable { cursor: pointer; }
.tp-table tbody tr.is-clickable:hover { background: #faf9f3; }
.tp-table tbody tr.is-excluded { opacity: 0.5; }

.tp-cell-addr__line1 { font-weight: 600; color: var(--tp-navy); }
.tp-cell-addr__line2 { font-size: 11px; color: var(--tp-fg-subtle); margin-top: 1px; }

/* ── Adjustment matrix value cells (signed money) ────────────────── */
.tp-val--neg     { color: var(--tp-terra); font-weight: 600; }
.tp-val--pos     { color: var(--tp-positive); font-weight: 600; }
.tp-val--zero    { color: var(--tp-fg-faint); }
.tp-val--strong  { color: var(--tp-navy); font-weight: 700; }

/* ── Fact box (Comp drawer) ──────────────────────────────────────── */
.tp-factbox {
  background: var(--tp-bg-soft);
  border: var(--tp-border-soft-1);
  border-radius: 3px;
  padding: 8px 10px;
}
.tp-factbox__k {
  font-size: 10px;
  color: var(--tp-fg-subtle);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.tp-factbox__v {
  font-size: 14px;
  color: var(--tp-navy);
  font-weight: 700;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* ── Collapsible section (left & right rails) ────────────────────── */
.tp-section {
  border-bottom: var(--tp-border-soft-1);
}
.tp-section__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 11px 18px;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: var(--tp-font-body);
}
.tp-section__head:hover { background: var(--tp-bg-soft); }
.tp-section__title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: var(--tp-tracking-eyebrow);
  text-transform: uppercase;
  color: var(--tp-navy);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tp-section__caret {
  display: inline-block;
  transition: transform var(--tp-duration-fast) var(--tp-ease);
  color: var(--tp-fg-subtle);
  font-size: 12px;
  line-height: 1;
}
.tp-section[open] > .tp-section__head .tp-section__caret { transform: rotate(90deg); }
.tp-section__count {
  font-size: 11px;
  color: var(--tp-fg-subtle);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.tp-section__body { padding: 4px 18px 14px; }

/* details > summary plumbing */
details.tp-section > summary { list-style: none; }
details.tp-section > summary::-webkit-details-marker { display: none; }

/* ── Workflow checklist (left rail) ──────────────────────────────── */
.tp-checklist__progress {
  height: 4px;
  background: var(--tp-border-soft);
  margin: 0 0 12px;
  border-radius: 2px;
  overflow: hidden;
}
.tp-checklist__progress-fill {
  height: 100%;
  background: var(--tp-terra);
  border-radius: 2px;
}
.tp-checklist__item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 8px;
  padding: 6px 18px 6px 14px;
  align-items: center;
  margin-left: -18px;
  margin-right: -18px;
  border-left: 2px solid transparent;
  font-size: 12px;
}
.tp-checklist__item--current {
  background: var(--tp-cream-100);
  border-left-color: var(--tp-terra);
}
.tp-checklist__item--current .tp-checklist__label { color: var(--tp-navy); font-weight: 600; }
.tp-checklist__item--done    .tp-checklist__label { color: var(--tp-fg-subtle); text-decoration: line-through; }
.tp-checklist__bullet {
  width: 16px; height: 16px;
  border-radius: 8px;
  border: 1.5px solid #ccc;
  background: transparent;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
}
.tp-checklist__item--done .tp-checklist__bullet { background: var(--tp-positive); border-color: var(--tp-positive); }
.tp-checklist__item--current .tp-checklist__bullet { background: #fff; }
.tp-checklist__label { color: var(--tp-fg-muted); }

/* ── Deadline tile ───────────────────────────────────────────────── */
.tp-deadline {
  background: var(--tp-bg-soft);
  border: var(--tp-border-soft-1);
  border-radius: 3px;
  padding: 8px 10px;
}
.tp-deadline--overdue { background: var(--tp-negative-bg); border-color: transparent; }
.tp-deadline--urgent  { background: var(--tp-terra-100);  border-color: transparent; }
.tp-deadline__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tp-fg-subtle);
}
.tp-deadline__value {
  font-size: 13px;
  color: var(--tp-navy);
  font-weight: 700;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.tp-deadline--overdue .tp-deadline__value { color: var(--tp-negative); }
.tp-deadline--urgent  .tp-deadline__value { color: var(--tp-terra); }

/* ── Meta row (left rail) ────────────────────────────────────────── */
.tp-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  padding: 3px 0;
}
.tp-meta-row__k { color: var(--tp-fg-subtle); }
.tp-meta-row__v { color: var(--tp-navy); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── AI summary banner ───────────────────────────────────────────── */
.tp-ai-banner {
  background: var(--tp-cream-100);
  border: 1px solid var(--tp-warning-border);
  border-left: 3px solid var(--tp-terra);
  border-radius: 3px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}
.tp-ai-banner__body { flex: 1; min-width: 0; }
.tp-ai-banner__eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tp-navy);
  margin-bottom: 4px;
}
.tp-ai-banner__eyebrow .tp-spark { color: var(--tp-terra); }
.tp-ai-banner__text {
  font-size: 13px;
  color: var(--tp-fg);
  line-height: 1.55;
}
.tp-ai-banner__text strong { color: var(--tp-navy); font-weight: 700; }
.tp-ai-banner__text .tp-pop { color: var(--tp-terra); font-weight: 700; }

.tp-ai-banner__actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Suggested-edit card (narrative sidebar) */
.tp-suggest {
  background: var(--tp-cream-100);
  border: 1px solid var(--tp-warning-border);
  border-left: 3px solid var(--tp-terra);
  border-radius: 3px;
  padding: 8px 10px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--tp-fg);
  line-height: 1.45;
}
.tp-suggest .tp-spark { color: var(--tp-terra); font-weight: 700; }
.tp-suggest__actions { margin-top: 6px; display: flex; gap: 6px; }

/* ── Conclusion card (navy) ──────────────────────────────────────── */
.tp-conclusion {
  background: var(--tp-navy);
  color: #fff;
  border-radius: 3px;
  border: 1px solid var(--tp-navy);
  padding: 14px 20px;
}
.tp-conclusion__grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr auto;
  gap: 24px;
  align-items: center;
}
.tp-conclusion__eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--tp-navy-300);
  margin-bottom: 4px;
}
.tp-conclusion__primary {
  font-family: var(--tp-font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--tp-terra-warm);
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tp-conclusion__secondary {
  font-family: var(--tp-font-display);
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.tp-conclusion__sub {
  font-size: 12px;
  color: var(--tp-navy-200);
  margin-top: 4px;
}

/* ── Issue / gate list rows inside health cards ──────────────────── */
.tp-issue-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 14px;
  border-bottom: var(--tp-border-soft-1);
  font-size: 12px;
  color: var(--tp-fg);
  line-height: 1.4;
}
.tp-issue-row:last-child { border-bottom: none; }
.tp-issue-row__action { font-size: 11px; }

.tp-gate-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  padding: 6px 14px;
  align-items: center;
  font-size: 12px;
  color: var(--tp-fg-muted);
}

/* ── Right-rail assistant chat ───────────────────────────────────── */
.tp-rail--right {
  border-left: var(--tp-border-thin);
  background: #fafbfd;
  display: flex;
  flex-direction: column;
}
.tp-rail--left {
  border-right: var(--tp-border-thin);
  background: var(--tp-paper);
}
.tp-assistant {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.tp-assistant__head {
  padding: 12px 16px;
  border-bottom: var(--tp-border-soft-1);
  background: var(--tp-paper);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tp-assistant__head-left { display: flex; align-items: center; gap: 8px; }
.tp-assistant__head-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tp-navy);
}
.tp-assistant__head-sub { font-size: 10px; color: var(--tp-fg-subtle); }

.tp-assistant__thread {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
}
.tp-msg {
  max-width: 88%;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12.5px;
  line-height: 1.5;
}
.tp-msg--user {
  align-self: flex-end;
  background: var(--tp-navy);
  color: #fff;
}
.tp-msg--assistant {
  align-self: flex-start;
  background: var(--tp-paper);
  border: var(--tp-border-soft-1);
  color: var(--tp-fg);
}
.tp-msg--assistant .tp-spark { color: var(--tp-terra); font-weight: 700; margin-right: 4px; }

.tp-assistant__chips {
  padding: 6px 14px 0;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.tp-chip {
  font-family: var(--tp-font-body);
  font-size: 11px;
  font-weight: 600;
  background: var(--tp-paper);
  color: var(--tp-navy);
  border: var(--tp-border-thin);
  padding: 4px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--tp-duration-fast) var(--tp-ease);
}
.tp-chip:hover { background: var(--tp-bg-soft); }

.tp-assistant__input {
  padding: 12px;
  border-top: var(--tp-border-soft-1);
  background: var(--tp-paper);
}
.tp-assistant__input form {
  display: flex;
  gap: 6px;
  align-items: flex-end;
}
.tp-assistant__input textarea {
  flex: 1;
  resize: none;
  font-family: var(--tp-font-body);
  font-size: 13px;
  padding: 8px 10px;
  border: var(--tp-border-thin);
  border-radius: 3px;
  outline: none;
  color: var(--tp-fg);
  min-height: 56px;
}
.tp-assistant__input textarea:focus { border-color: var(--tp-focus-ring); }

/* ── Audit log entries ───────────────────────────────────────────── */
.tp-audit {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}
.tp-audit__entry {
  border-left: 2px solid var(--tp-border);
  padding-left: 10px;
}
.tp-audit__entry--human { border-left-color: var(--tp-terra); }
.tp-audit__meta {
  font-size: 11px;
  color: var(--tp-fg-subtle);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.tp-audit__who--human  { color: var(--tp-navy); font-weight: 600; }
.tp-audit__who--system { color: var(--tp-fg-subtle); font-weight: 600; }
.tp-audit__action { font-size: 12px; color: var(--tp-fg); margin-top: 1px; }
.tp-audit__detail {
  font-size: 11px;
  color: var(--tp-fg-muted);
  font-family: var(--tp-font-mono);
  margin-top: 1px;
  word-break: break-word;
  white-space: pre-wrap;
}

/* ── Comms tile ──────────────────────────────────────────────────── */
.tp-comms { display: flex; flex-direction: column; gap: 10px; max-height: 260px; overflow-y: auto; }
.tp-comm {
  background: var(--tp-paper);
  border: var(--tp-border-soft-1);
  border-radius: 3px;
  padding: 8px 10px;
}
.tp-comm--you      { background: var(--tp-cream-100); }
.tp-comm--external { background: var(--tp-terra-100); }

/* ── Comp drawer ─────────────────────────────────────────────────── */
.tp-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 39, 68, 0.35);
  z-index: 60;
}
.tp-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 480px;
  max-width: 100vw;
  background: var(--tp-paper);
  border-left: var(--tp-border-thin);
  z-index: 61;
  display: flex;
  flex-direction: column;
  box-shadow: var(--tp-shadow-drawer);
}
.tp-drawer__header {
  padding: 18px 22px;
  border-bottom: var(--tp-border-soft-1);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.tp-drawer__close {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  padding: 0;
  color: var(--tp-fg-subtle);
}
.tp-drawer__close:hover { color: var(--tp-navy); }
.tp-drawer__body { flex: 1; overflow-y: auto; padding: 18px 22px; }
.tp-drawer__footer {
  border-top: var(--tp-border-soft-1);
  padding: 12px 22px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.tp-include-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 3px;
  margin-bottom: 16px;
  background: var(--tp-positive-bg);
}
.tp-include-banner--excluded { background: var(--tp-negative-bg); }
.tp-include-banner__title {
  font-size: 12px;
  font-weight: 700;
  color: var(--tp-positive);
}
.tp-include-banner--excluded .tp-include-banner__title { color: var(--tp-negative); }
.tp-include-banner__sub { font-size: 11px; color: var(--tp-fg-muted); margin-top: 2px; }

/* ── Tab bar nested below tabs (filings list etc) ────────────────── */
.tp-list-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 14px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: var(--tp-border-soft-1);
}
.tp-list-row:last-child { border-bottom: none; }

/* ── Photo placeholder grid ──────────────────────────────────────── */
.tp-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.tp-photo {
  border: var(--tp-border-thin);
  border-radius: 3px;
  overflow: hidden;
  background: var(--tp-paper);
}
.tp-photo__img {
  height: 140px;
  background: repeating-linear-gradient(45deg, #eef0f4 0, #eef0f4 8px, #f8f9fc 8px, #f8f9fc 16px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tp-fg-faint);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
}
.tp-photo__caption { padding: 8px 12px; font-size: 12px; color: var(--tp-navy); font-weight: 600; }

/* Phase C — real photo grid (replaces the hatch placeholder grid). */
.tp-photo-grid {
  list-style: none;
  margin: 0;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.tp-photo-grid .tp-photo {
  display: flex;
  flex-direction: column;
  background: var(--tp-paper);
}
.tp-photo-grid .tp-photo__img {
  height: 140px;
  background: var(--tp-bg-soft);
  overflow: hidden;
}
.tp-photo__meta {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: var(--tp-border-soft-1);
}
.tp-photo__row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.tp-photo__drag {
  margin-left: auto;
  cursor: grab;
  user-select: none;
  color: var(--tp-fg-subtle);
  font-size: 14px;
  padding: 0 4px;
}
.tp-photo__drag:active { cursor: grabbing; }

/* Sortable.js drag affordance */
.tp-photo.sortable-ghost { opacity: 0.4; }
.tp-photo.sortable-chosen { box-shadow: var(--tp-shadow-md); }
.tp-photo.sortable-drag   { opacity: 0.9; }

/* Section spacer between subject + per-comp sections */
.tp-photo-sections { display: flex; flex-direction: column; gap: 16px; }

/* ── Evidence-PDF preview ────────────────────────────────────────── */
.tp-evidence-stage {
  background: #f0eee5;
  padding: 24px;
  display: flex;
  justify-content: center;
}
.tp-evidence-paper {
  width: 612px;
  max-width: 100%;
  min-height: 760px;
  background: var(--tp-paper);
  box-shadow: 0 4px 20px rgba(26, 39, 68, 0.15);
  padding: 50px 56px;
  font-family: var(--tp-font-display);
}

/* ── Pipeline kanban ─────────────────────────────────────────────── */
.tp-kanban {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
}
.tp-kanban__col {
  background: var(--tp-bg-soft);
  border: var(--tp-border-soft-1);
  border-radius: var(--tp-radius-sm);
  padding: 8px;
  min-height: 200px;
}
.tp-kanban__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding: 0 4px;
}
.tp-kanban__col-cards { display: flex; flex-direction: column; gap: 8px; }
.tp-kanban__card {
  display: block;
  background: var(--tp-paper);
  border: var(--tp-border-soft-1);
  border-radius: var(--tp-radius-sm);
  padding: 10px;
  text-decoration: none;
  color: inherit;
  transition: border-color var(--tp-duration-fast) var(--tp-ease),
              box-shadow var(--tp-duration-fast) var(--tp-ease);
}
.tp-kanban__card:hover {
  border-color: var(--tp-navy-300);
  box-shadow: var(--tp-shadow-sm);
}
.tp-kanban__parcel { font-size: 11px; color: var(--tp-fg-subtle); font-family: var(--tp-font-mono); }
.tp-kanban__address { font-size: 13px; font-weight: 600; color: var(--tp-navy); margin-top: 2px; line-height: 1.3; }
.tp-kanban__meta { font-size: 11px; color: var(--tp-fg-subtle); margin-top: 4px; }
.tp-kanban__metric { font-size: 11px; color: var(--tp-positive); font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tp-kanban__deadline { font-size: 11px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tp-kanban__deadline--urgent { color: var(--tp-negative); font-weight: 600; }
.tp-kanban__empty { font-size: 11px; color: var(--tp-fg-faint); padding: 8px 4px; text-align: center; }

/* ── Lookup table ────────────────────────────────────────────────── */
.tp-lookup-form {
  display: flex;
  gap: 8px;
  margin-bottom: var(--tp-space-5);
  max-width: 720px;
}
.tp-lookup-form .tp-input { flex: 1; }

.tp-banner {
  border-radius: var(--tp-radius-sm);
  padding: 12px 14px;
  margin-bottom: var(--tp-space-5);
  font-size: 13px;
}
.tp-banner--warn { background: var(--tp-warning-bg); border: 1px solid var(--tp-warning-border); color: var(--tp-warning-fg); }
.tp-banner--info { background: var(--tp-bg-fill);    border: var(--tp-border-thin); color: var(--tp-fg); }

/* ── Layout helpers ──────────────────────────────────────────────── */
.tp-row  { display: flex; align-items: center; gap: 12px; }
.tp-col  { display: flex; flex-direction: column; gap: 12px; }
.tp-grow { flex: 1; min-width: 0; }
.tp-stack-4  { display: flex; flex-direction: column; gap: var(--tp-space-1); }
.tp-stack-8  { display: flex; flex-direction: column; gap: var(--tp-space-2); }
.tp-stack-12 { display: flex; flex-direction: column; gap: var(--tp-space-3); }
.tp-stack-16 { display: flex; flex-direction: column; gap: var(--tp-space-4); }
.tp-stack-24 { display: flex; flex-direction: column; gap: var(--tp-space-6); }

/* Right-rail divider strip used between assistant/audit/comms */
.tp-divider-y {
  display: inline-block;
  width: 1px;
  height: 22px;
  background: var(--tp-border);
  margin: 0 4px;
}

/* hide the default <details> arrow on collapsibles */
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
