/* Quotations Pulse — local static surface */
:root {
  --ink: #101820;
  --navy: #0c2638;
  --navy-2: #173d52;
  --cyan: #007f97;
  --cyan-soft: #dff3f6;
  --paper: #f4f7f8;
  --surface: #ffffff;
  --line: rgba(12, 38, 56, 0.13);
  --muted: #60717c;
  --quiet: #60717c;
  --danger: #a33b35;
  --danger-soft: #fbe9e7;
  --warning: #875d12;
  --warning-soft: #fff3d5;
  --success: #16705a;
  --success-soft: #e3f4ee;
  --focus: #007e98;
  --sans: "Arial Nova", Arial, "Helvetica Neue", sans-serif;
  --mono: "IBM Plex Mono", "Cascadia Mono", Consolas, monospace;
  --ring: 0 0 0 1px var(--line);
  --card-shadow: 0 0 0 1px var(--line), 0 2px 3px rgba(12, 38, 56, 0.035),
    0 12px 28px -24px rgba(12, 38, 56, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(rgba(12, 38, 56, 0.022) 1px, transparent 1px),
    var(--paper);
  background-size: 100% 32px;
}

button {
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

::selection {
  background: var(--cyan-soft);
  color: var(--navy);
}

.page-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  min-height: 88px;
  padding: 16px max(24px, calc((100vw - 1320px) / 2));
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 1px 0 rgba(12, 38, 56, 0.12);
}

.identity,
.header-actions,
.source-summary,
.state-badge,
.chart-legend,
.legend-item {
  display: flex;
  align-items: center;
}

.identity {
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  position: relative;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  background: var(--navy);
  box-shadow: inset 0 -10px 0 rgba(0, 142, 168, 0.22);
}

.brand-hull {
  position: absolute;
  left: 9px;
  top: 12px;
  width: 22px;
  height: 10px;
  border-bottom: 3px solid white;
  transform: skewX(-24deg);
}

.brand-hull::before {
  content: "";
  position: absolute;
  left: 8px;
  bottom: 3px;
  height: 10px;
  border-left: 2px solid white;
}

.brand-water {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 9px;
  height: 2px;
  background: #56c8d7;
}

.title-group {
  min-width: 0;
}

.eyebrow,
.section-index,
.status-label,
.metric-label,
.error-code {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.09em;
  line-height: 1.4;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--cyan);
  white-space: nowrap;
}

.brand-title {
  margin: 0;
  color: var(--navy);
  font-size: clamp(20px, 2vw, 25px);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.08;
}

.header-actions {
  justify-content: flex-end;
  gap: 16px;
}

.source-summary {
  align-items: flex-end;
  flex-direction: column;
  gap: 5px;
}

.state-badge {
  gap: 7px;
  width: max-content;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

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

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

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

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 12%, transparent);
}

.source-meta {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.refresh-button,
.retry-button {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 5px;
  color: white;
  background: var(--navy);
  box-shadow: 0 0 0 1px var(--navy), 0 2px 3px rgba(12, 38, 56, 0.12);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background-color 140ms ease, transform 140ms ease;
}

.refresh-button:hover,
.retry-button:hover {
  background: var(--navy-2);
}

.refresh-button:active,
.retry-button:active {
  transform: translateY(1px);
}

.refresh-button:disabled {
  color: #afbac0;
  background: #e7ecee;
  box-shadow: var(--ring);
  cursor: wait;
}

.dashboard {
  width: min(1320px, calc(100% - 48px));
  margin: 32px auto 56px;
  flex: 1;
}

.status-strip {
  display: grid;
  grid-template-columns: 0.75fr 0.75fr 1fr 2fr;
  margin-bottom: 16px;
  background: var(--navy);
  color: white;
  box-shadow: 0 0 0 1px var(--navy);
}

.status-item {
  min-width: 0;
  padding: 15px 18px 16px;
  box-shadow: inset -1px 0 rgba(255, 255, 255, 0.12);
}

.status-item:last-child {
  box-shadow: none;
}

.status-label {
  display: block;
  margin-bottom: 6px;
  color: #91b1c2;
}

.status-value {
  display: block;
  overflow: hidden;
  color: white;
  font-family: var(--mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-fresh {
  color: #73d5bc;
}

.text-stale {
  color: #f3c86f;
}

.text-error {
  color: #f09a94;
}

.primary-grid {
  display: grid;
  grid-template-columns: minmax(250px, 0.82fr) minmax(520px, 1.8fr) minmax(250px, 0.82fr);
  grid-template-areas:
    "queue activity quality"
    "queue activity sla";
  gap: 16px;
  align-items: stretch;
}

.panel {
  min-width: 0;
  background: var(--surface);
  box-shadow: var(--card-shadow);
}

.queue-panel {
  grid-area: queue;
}

.activity-panel {
  grid-area: activity;
  min-height: 494px;
}

.quality-panel {
  grid-area: quality;
}

.sla-panel {
  grid-area: sla;
}

.section-heading {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 0;
  min-height: 78px;
  box-shadow: 0 1px 0 var(--line);
}

.section-index {
  display: grid;
  place-items: center;
  color: var(--cyan);
  box-shadow: inset -1px 0 var(--line);
}

.section-heading > div:last-child {
  padding: 16px 18px 15px;
}

.section-title {
  margin: 0;
  color: var(--navy);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

.section-detail {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.queue-content {
  padding: 20px;
}

.queue-total {
  display: flex;
  min-height: 118px;
  flex-direction: column;
  justify-content: center;
  padding-bottom: 20px;
  box-shadow: inset 0 -1px var(--line);
}

.metric-label {
  color: var(--muted);
}

.metric-value {
  margin-top: 8px;
  color: var(--navy);
  font-family: var(--mono);
  font-size: 40px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: -0.06em;
  line-height: 1;
}

.metric-value.unavailable {
  font-family: var(--sans);
  font-size: 25px;
  letter-spacing: -0.035em;
}

.metric-note {
  display: block;
  margin-top: 7px;
  color: var(--quiet);
  font-size: 11px;
  line-height: 1.4;
}

.queue-rows {
  padding-top: 9px;
}

.queue-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 37px;
}

.queue-name {
  color: var(--muted);
  font-size: 12px;
}

.queue-value {
  color: var(--navy);
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.queue-value.unavailable {
  color: var(--quiet);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
}

.activity-note {
  margin: 14px 20px 0;
  padding: 10px 12px;
  color: var(--muted);
  background: #f4f7f8;
  box-shadow: inset 3px 0 var(--cyan);
  font-size: 11px;
  line-height: 1.5;
}

.chart-legend {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 18px;
  padding: 15px 20px 0;
  color: var(--muted);
  font-size: 11px;
}

.legend-item {
  gap: 6px;
}

.legend-swatch {
  width: 8px;
  height: 8px;
}

.swatch-received,
.bar-received {
  background: var(--cyan);
}

.swatch-processed,
.bar-processed {
  background: var(--navy);
}

.swatch-changed,
.bar-changed {
  background: #85aab8;
}

.chart-plot {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  padding-left: 12px;
}

.chart-axis {
  display: flex;
  height: 350px;
  flex-direction: column;
  justify-content: space-between;
  margin-top: 10px;
  padding: 12px 7px 27px 0;
}

.chart-axis-label {
  color: var(--quiet);
  font-family: var(--mono);
  font-size: 8px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.chart-viewport {
  min-width: 0;
  overflow-x: auto;
  padding: 10px 20px 20px 0;
  scrollbar-color: #b7c5cb transparent;
  scrollbar-width: thin;
}

.chart {
  display: grid;
  grid-template-columns: repeat(var(--chart-days, 30), minmax(16px, 1fr));
  gap: 4px;
  min-width: 100%;
  height: 350px;
  padding-top: 12px;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(25% - 1px),
    rgba(12, 38, 56, 0.08) 25%
  );
}

.chart-column {
  display: grid;
  grid-template-rows: 1fr 27px;
  min-width: 0;
  height: 100%;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 1px;
  min-height: 0;
}

.chart-bar {
  width: min(7px, 30%);
  min-height: 0;
  transition: opacity 120ms ease;
}

.chart-column:hover .chart-bar {
  opacity: 0.7;
}

.chart-date {
  align-self: end;
  overflow: visible;
  color: var(--quiet);
  font-family: var(--mono);
  font-size: 8px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
  transform: rotate(-48deg) translate(-2px, 1px);
  transform-origin: center;
}

.chart-column:not(:nth-child(5n)):not(:last-child) .chart-date {
  opacity: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.chart-table-disclosure {
  margin: 0 20px 20px 48px;
  box-shadow: var(--ring);
  background: #fbfcfc;
}

.chart-table-summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  color: var(--navy);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.chart-table-summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.chart-table-viewport {
  max-height: 260px;
  overflow: auto;
  box-shadow: inset 0 1px var(--line);
}

.chart-data-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--navy);
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.chart-data-table th,
.chart-data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.chart-data-table th:first-child,
.chart-data-table td:first-child {
  text-align: left;
}

.chart-data-table thead th {
  position: sticky;
  top: 0;
  color: var(--muted);
  background: #f4f7f8;
  font-size: 10px;
  text-transform: uppercase;
}

.chart-data-table tbody tr:last-child th,
.chart-data-table tbody tr:last-child td {
  border-bottom: 0;
}

.quality-grid {
  padding: 4px 20px 12px;
}

.quality-metric {
  padding: 16px 0;
  box-shadow: inset 0 -1px var(--line);
}

.quality-metric:last-child {
  box-shadow: none;
}

.quality-value,
.quality-text {
  display: block;
  margin-top: 8px;
  color: var(--navy);
  font-family: var(--mono);
  font-size: 27px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: -0.05em;
}

.quality-text {
  font-family: var(--sans);
  font-size: 18px;
  letter-spacing: -0.025em;
}

.sla-state {
  display: grid;
  align-content: center;
  min-height: 183px;
  padding: 22px;
}

.sla-symbol {
  width: 28px;
  height: 4px;
  overflow: hidden;
  color: transparent;
  background: var(--cyan);
}

.sla-label {
  margin-top: 18px;
  color: var(--navy);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.04em;
}

.sla-copy {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 400px;
  padding: 32px;
  text-align: center;
}

.empty-title {
  color: var(--navy);
  font-size: 20px;
}

.empty-copy {
  max-width: 360px;
  margin: 8px auto 0;
  color: var(--muted);
  font-size: 13px;
}

.methodology {
  margin-top: 16px;
  background: #eef3f5;
  box-shadow: var(--ring);
}

.method-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0;
}

.method-row {
  min-width: 0;
  padding: 20px;
  box-shadow: inset -1px 0 var(--line);
}

.method-row:last-child {
  box-shadow: none;
}

.method-term {
  margin-bottom: 8px;
  color: var(--navy);
  font-size: 12px;
  font-weight: 600;
}

.method-description {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 62px;
  padding: 16px max(24px, calc((100vw - 1320px) / 2));
  color: var(--muted);
  background: white;
  box-shadow: 0 -1px 0 var(--line);
  font-size: 11px;
}

.footer-name {
  color: var(--navy);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.11em;
}

.state-main {
  display: grid;
  place-items: center;
  width: min(1320px, calc(100% - 48px));
  margin: 32px auto;
  flex: 1;
}

.state-card {
  width: min(540px, 100%);
  padding: 36px;
  background: white;
  box-shadow: var(--card-shadow);
}

.state-card-error {
  box-shadow: 0 0 0 1px rgba(163, 59, 53, 0.22), 0 12px 28px -24px rgba(163, 59, 53, 0.5);
}

.state-title {
  margin: 20px 0 0;
  color: var(--navy);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.045em;
}

.state-copy {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.error-code {
  color: var(--danger);
}

.retry-button {
  margin-top: 24px;
}

.loading-line {
  display: block;
  width: 74px;
  height: 4px;
  background: var(--cyan);
  animation: loading 1.2s ease-in-out infinite alternate;
  transform-origin: left;
}

@keyframes loading {
  from {
    transform: scaleX(0.25);
  }
  to {
    transform: scaleX(1);
  }
}

@media (max-width: 1050px) {
  .primary-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "queue quality"
      "activity activity"
      "sla sla";
  }

  .sla-state {
    min-height: 150px;
  }

  .method-list {
    grid-template-columns: 1fr 1fr;
  }

  .method-row:nth-child(2) {
    box-shadow: none;
  }

  .method-row:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
    padding: 16px 20px;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .source-summary {
    align-items: flex-start;
  }

  .dashboard,
  .state-main {
    width: calc(100% - 32px);
    margin-top: 20px;
  }

  .status-strip {
    grid-template-columns: 1fr 1fr;
  }

  .status-item:nth-child(2) {
    box-shadow: none;
  }

  .status-item:nth-child(-n + 2) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  }

  .primary-grid {
    grid-template-columns: 1fr;
    grid-template-areas: "queue" "activity" "quality" "sla";
  }

  .activity-panel {
    min-height: 460px;
  }

  .chart {
    width: 670px;
    min-width: 670px;
    height: 315px;
  }

  .chart-axis {
    height: 315px;
  }

  .method-list {
    grid-template-columns: 1fr;
  }

  .method-row,
  .method-row:nth-child(2) {
    border-bottom: 1px solid var(--line);
    box-shadow: none;
  }

  .method-row:last-child {
    border-bottom: 0;
  }
}

@media (max-width: 430px) {
  .topbar {
    padding-inline: 16px;
  }

  .brand-mark {
    flex-basis: 36px;
    width: 36px;
    height: 36px;
  }

  .eyebrow {
    font-size: 9px;
  }

  .header-actions {
    align-items: stretch;
  }

  .source-meta {
    max-width: 218px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .refresh-button {
    min-width: 96px;
  }

  .dashboard,
  .state-main {
    width: calc(100% - 24px);
    margin-bottom: 32px;
  }

  .status-strip {
    grid-template-columns: 1fr;
  }

  .status-item,
  .status-item:nth-child(2) {
    padding: 12px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: none;
  }

  .status-item:last-child {
    border-bottom: 0;
  }

  .status-value {
    font-size: 11px;
  }

  .section-heading {
    grid-template-columns: 36px 1fr;
  }

  .section-heading > div:last-child {
    padding-inline: 14px;
  }

  .queue-content,
  .quality-grid {
    padding-inline: 16px;
  }

  .chart-legend {
    justify-content: flex-start;
    gap: 12px;
    padding-inline: 16px;
  }

  .chart-viewport {
    padding-inline: 16px;
  }

  .chart-table-disclosure {
    margin: 0 16px 16px;
  }

  .footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
    padding-inline: 16px;
  }

  .state-card {
    padding: 28px 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
