:root {
  --bg: #f7f7f2;
  --surface: #ffffff;
  --surface-strong: #fbfbf8;
  --line: #d8d3c7;
  --line-strong: #b8b09e;
  --text: #171612;
  --muted: #605b52;
  --accent: #0c4a6e;
  --accent-soft: #dcecf6;
  --danger: #9f1239;
  --danger-soft: #f9d8df;
  --success: #0e6b57;
  --success-soft: #d8f1ea;
  --warning: #8a5a00;
  --warning-soft: #f7ebc6;
  --shadow: 0 18px 40px rgba(23, 22, 18, 0.05);
  --radius: 18px;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
}

body {
  overflow-x: hidden;
}

a {
  color: var(--accent);
}

button,
input,
select {
  font: inherit;
}

code {
  font-family: "SFMono-Regular", ui-monospace, "Cascadia Code", monospace;
  font-size: 0.92em;
}

.shell {
  width: min(1680px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0 48px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(180deg, #fffdfa 0%, #f5f5ef 100%);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand__mark {
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
}

.brand__copy {
  min-width: 0;
}

.brand__eyebrow {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.brand h1 {
  margin: 3px 0 0;
  font-size: clamp(1.3rem, 2.1vw, 2rem);
  line-height: 1.05;
  white-space: nowrap;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
}

.button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}

.button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.button--ghost {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

.layout {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric-card {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card--wide {
  background: linear-gradient(135deg, #f9fbfc 0%, #eef4f7 100%);
}

.metric-card__label {
  display: block;
  font-size: 0.86rem;
  color: var(--muted);
}

.metric-card__value {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.4rem, 2vw, 2rem);
  line-height: 1.05;
}

.metric-card__value--wide {
  font-size: clamp(1.05rem, 1.5vw, 1.45rem);
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(360px, 0.9fr);
  gap: 16px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel__header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--line);
}

.panel__header--stacked {
  align-items: start;
}

.panel__kicker {
  margin: 0 0 4px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel h2,
.panel h3 {
  margin: 0;
}

.filters {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: nowrap;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field span {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.field input,
.field select {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-strong);
}

.field input {
  width: 240px;
}

.field select {
  width: 110px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.data-table th,
.data-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.data-table th {
  font-size: 0.82rem;
  color: var(--muted);
  background: var(--surface-strong);
}

.data-table tbody tr {
  cursor: pointer;
  transition: background 120ms ease;
}

.data-table tbody tr:hover {
  background: #faf8f2;
}

.data-table tbody tr.is-selected {
  background: #eef5f9;
}

.market-cell {
  display: grid;
  gap: 4px;
}

.market-cell strong,
.text-link {
  text-decoration: none;
}

.subcopy,
.timestamp,
.muted {
  color: var(--muted);
  font-size: 0.82rem;
}

.empty-cell,
.empty-copy {
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  white-space: nowrap;
}

.badge--success {
  background: var(--success-soft);
  color: var(--success);
}

.badge--danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge--warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge--neutral {
  background: #ece8dd;
  color: #645c4b;
}

.detail-summary,
.subpanel,
.triple > div,
.list-block {
  padding: 18px 20px;
}

.subpanel + .subpanel,
.triple > div + div {
  border-top: 1px solid var(--line);
}

.detail-grid {
  display: grid;
  gap: 12px;
}

.detail-card {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-strong);
}

.detail-card dl {
  margin: 0;
  display: grid;
  gap: 8px;
}

.detail-card dt {
  font-size: 0.78rem;
  color: var(--muted);
}

.detail-card dd {
  margin: 0;
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
}

.mini-table th,
.mini-table td {
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
  text-align: left;
  overflow-wrap: anywhere;
}

.embed-slot iframe {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.history-slot svg {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.comment-list,
.stack-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}

.comment-item,
.stack-item {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-strong);
}

.comment-item p,
.stack-item p {
  margin: 6px 0 0;
}

.triple {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.spark-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.detail-actions {
  display: flex;
  gap: 10px;
  flex-wrap: nowrap;
}

@media (max-width: 1180px) {
  .grid,
  .triple,
  .strip {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar__actions,
  .filters {
    flex-wrap: wrap;
  }

  .field input {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100vw - 18px, 100%);
    padding-top: 10px;
  }

  .topbar,
  .panel,
  .metric-card {
    border-radius: 18px;
  }

  .brand h1,
  .brand__eyebrow,
  .button,
  .status-pill,
  .text-link {
    white-space: normal;
  }

  .data-table thead {
    display: none;
  }

  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
    width: 100%;
  }

  .data-table tr {
    padding: 10px 14px;
  }

  .data-table td {
    padding: 7px 0;
    border: none;
  }

  .data-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.76rem;
    color: var(--muted);
    margin-bottom: 2px;
  }
}
