* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Segoe UI, Arial, sans-serif;
  font-size: 13px;
  color: #222;
  background: #fafafa;
}

.viewer {
  margin: 0 auto;
  padding: 12px 16px;
}

/* Charts shown: the page is exactly as tall as the iframe (padding included, box-sizing) and the charts take what is
   left, so the iframe document never scrolls. Only the charts are in the flow: Diagnostics is an overlay then. */
.viewer-fill {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.viewer-charts {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.viewer-diagnostics {
  max-width: 760px;
  margin: 0 auto;
}

.viewer-diagnostics-overlay {
  position: fixed;
  top: 12px;
  right: 16px;
  bottom: 12px;
  width: min(760px, calc(100vw - 32px));
  max-width: none;
  margin: 0;
  padding: 8px 12px;
  overflow-y: auto;
  background: #fafafa;
  border: 1px solid #ccc;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  z-index: 1000;
}

.viewer-diagnostics > summary {
  cursor: pointer;
  font-size: 12px;
  color: #666;
  margin-bottom: 12px;
}

.status {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  padding: 14px;
  border-radius: 4px;
  margin-bottom: 20px;
}

.status-waiting {
  background: #fdf3d6;
  color: #8a6d1a;
  border: 1px solid #e9d38a;
}

.status-ok {
  background: #dff5e1;
  color: #1c6b2f;
  border: 1px solid #a9dfb4;
}

.params {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.params > div {
  flex: 1;
  min-width: 200px;
  background: #fff;
  border: 1px solid #ddd;
  padding: 10px 12px;
}

.param-label {
  display: block;
  font-size: 11px;
  color: #777;
  margin-bottom: 4px;
}

.param-value {
  font-family: Consolas, monospace;
  font-size: 15px;
  font-weight: 600;
}

.box {
  background: #fff;
  border: 1px solid #ddd;
  padding: 10px 12px;
  margin-bottom: 16px;
}

.box-token {
  border-color: #a9dfb4;
  background: #f4fbf5;
}

.box-label {
  font-size: 11px;
  color: #777;
  margin-bottom: 4px;
}

.box-value {
  font-family: Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
}

.box-meta {
  font-size: 11px;
  color: #888;
  margin-top: 6px;
}

.log-panel {
  border-top: 1px solid #ddd;
  padding-top: 8px;
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 11px;
  color: #666;
}

.log-header button {
  background: #eee;
  border: 1px solid #bbb;
  padding: 6px 10px;
  font-size: 11px;
  cursor: pointer;
}

.log-header button:hover {
  background: #ddd;
}

.log-output {
  background: #1e1e1e;
  color: #b6f5b6;
  font-family: Consolas, monospace;
  font-size: 11px;
  padding: 10px;
  max-height: 320px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.loader {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #666;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #ddd;
  border-top-color: #1c6b2f;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.warning {
  background: #fdf0d6;
  color: #8a5a1a;
  border: 1px solid #f0c07a;
  border-radius: 4px;
  padding: 10px 12px;
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 12px;
}
