:root {
  color-scheme: light dark;
  --bg: rgba(127, 127, 127, 0.10);
  --border: rgba(127, 127, 127, 0.30);
  --muted: rgba(127, 127, 127, 0.9);
  --ok: #0a7;
  --warn: #e6a700;
  --bad: #d33;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica,
    Arial;
  margin: 18px;
  line-height: 1.35;
}

code,
pre,
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  overflow-wrap: anywhere;
  word-break: break-word;
}

h1 {
  font-size: 18px;
  margin: 0;
}

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

.small {
  font-size: 12px;
}

.right {
  text-align: right;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.tabs {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 12px 0;
  flex-wrap: wrap;
}

.tab {
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
}

.tab[aria-selected="true"] {
  background: var(--bg);
  border-color: rgba(127, 127, 127, 0.55);
}

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

.card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: rgba(127, 127, 127, 0.06);
}

.span-4 {
  grid-column: span 4;
}

.span-6 {
  grid-column: span 6;
}

.span-8 {
  grid-column: span 8;
}

.span-12 {
  grid-column: span 12;
}

@media (max-width: 980px) {
  .span-4,
  .span-6,
  .span-8 {
    grid-column: span 12;
  }
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
}

.badge.ok {
  color: var(--ok);
  border-color: rgba(0, 170, 120, 0.45);
}

.badge.warn {
  color: var(--warn);
  border-color: rgba(230, 167, 0, 0.45);
}

.badge.bad {
  color: var(--bad);
  border-color: rgba(221, 51, 51, 0.45);
}

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

.kv {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 6px 10px;
}

.kv div {
  overflow-wrap: anywhere;
}

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

.oauth-table th,
.oauth-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.oauth-table th {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.oauth-expand-cell {
  width: 34px;
}

.oauth-expand {
  width: 22px;
  min-width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 6px;
  line-height: 1;
}

.oauth-status {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.oauth-status-fetched {
  color: var(--ok);
}

.oauth-status-error {
  color: var(--bad);
}

.oauth-status-pending,
.oauth-status-tried,
.oauth-status-skipped {
  color: var(--muted);
}

.oauth-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  overflow-wrap: anywhere;
}

.oauth-detail-row td {
  background: color-mix(in srgb, var(--bg) 92%, transparent);
}

.oauth-detail-wrap {
  display: grid;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
}

.oauth-detail-title {
  color: var(--muted);
  font-size: 18px;
  font-weight: 600;
}

.oauth-detail-kv {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px 12px;
}

.oauth-detail-collapse {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.oauth-detail-summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
  user-select: none;
}

.oauth-detail-empty {
  margin-top: 10px;
  border-radius: 999px;
  min-height: 48px;
  background: color-mix(in srgb, var(--border) 65%, transparent);
}

.oauth-detail-section,
.oauth-detail-collapse {
  display: grid;
  gap: 6px;
}

.oauth-detail-pre {
  margin: 6px 0 0 0;
  max-height: 260px;
}

.channel-expand-cell {
  width: 96px;
}

.channel-expand {
  padding: 2px 8px;
  border-radius: 999px;
  line-height: 1.2;
}

.channel-detail-row td {
  background: color-mix(in srgb, var(--bg) 92%, transparent);
}

.channel-detail-wrap {
  display: grid;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
}

.channel-detail-kv {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 6px 12px;
}

.system-expand-cell {
  width: 96px;
}

.system-expand {
  padding: 2px 8px;
  border-radius: 999px;
  line-height: 1.2;
}

.system-history-row td {
  background: color-mix(in srgb, var(--bg) 92%, transparent);
}

.system-history-wrap {
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
}

.system-history-head {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) auto minmax(160px, 1fr);
  gap: 6px 12px;
  align-items: center;
}

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

.system-history-table th,
.system-history-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.system-history-table th {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.system-certs-table {
  min-width: 780px;
}

.system-proxy-map-table {
  min-width: 740px;
}

.system-route-table {
  min-width: 1320px;
}

.system-history-table {
  min-width: 980px;
}

a {
  color: inherit;
}

button,
input,
select,
label {
  font: inherit;
}

input,
select {
  padding: 7px 9px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  min-width: 220px;
}

button {
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
}

button:hover,
.tab:hover {
  border-color: rgba(127, 127, 127, 0.55);
}

.checkbox-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.checkbox-stack label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.checkbox-stack input {
  margin: 0;
}

.panel {
  display: none;
}

.panel[aria-hidden="false"] {
  display: block;
}

.pre {
  border-radius: 12px;
  padding: 12px;
  background: var(--bg);
  overflow: auto;
  max-height: 520px;
}

.logs {
  border-radius: 12px;
  padding: 12px;
  background: var(--bg);
  overflow: auto;
  max-height: 520px;
  white-space: pre;
}

.log-line {
  padding: 1px 0;
}

.level-debug {
  color: rgba(127, 127, 127, 0.95);
}

.level-info {
  color: inherit;
}

.level-warn {
  color: var(--warn);
}

.level-error {
  color: var(--bad);
}

.harpoon-disabled {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  background: var(--bg);
  margin-top: 12px;
}

.harpoon-toolbar {
  align-items: flex-start;
}

.harpoon-toolbar-spacer {
  flex: 1 1 auto;
  min-width: 12px;
}

.harpoon-controls {
  align-items: center;
}

.harpoon-controls label {
  white-space: nowrap;
}

.harpoon-table-wrap {
  overflow-x: auto;
}

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

.harpoon-table th,
.harpoon-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  overflow-wrap: anywhere;
}

.harpoon-table th {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.harpoon-targets-table th:nth-child(1),
.harpoon-targets-table td:nth-child(1) {
  width: 18%;
}

.harpoon-targets-table th:nth-child(2),
.harpoon-targets-table td:nth-child(2) {
  width: 47%;
}

.harpoon-targets-table th:nth-child(3),
.harpoon-targets-table td:nth-child(3) {
  width: 35%;
}

.harpoon-proxy-routes-table {
  min-width: 1080px;
}

.harpoon-proxy-routes-table th:nth-child(1),
.harpoon-proxy-routes-table td:nth-child(1) {
  width: 16%;
}

.harpoon-proxy-routes-table th:nth-child(2),
.harpoon-proxy-routes-table td:nth-child(2) {
  width: 8%;
}

.harpoon-proxy-routes-table th:nth-child(3),
.harpoon-proxy-routes-table td:nth-child(3) {
  width: 30%;
}

.harpoon-proxy-routes-table th:nth-child(4),
.harpoon-proxy-routes-table td:nth-child(4) {
  width: 30%;
}

.harpoon-proxy-routes-table th:nth-child(5),
.harpoon-proxy-routes-table td:nth-child(5) {
  width: 16%;
}

.harpoon-proxy-routes-table td:nth-child(3),
.harpoon-proxy-routes-table td:nth-child(4),
.harpoon-proxy-routes-table td:nth-child(5) {
  white-space: nowrap;
  overflow-wrap: normal;
}

.harpoon-calls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.harpoon-call {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: rgba(127, 127, 127, 0.04);
}

.harpoon-call-header {
  display: grid;
  grid-template-columns: 26px minmax(160px, 1.4fr) minmax(90px, 0.7fr)
    minmax(70px, 0.6fr) minmax(70px, 0.6fr) minmax(80px, 0.7fr)
    minmax(120px, 0.9fr) minmax(120px, 1fr);
  gap: 8px;
  align-items: center;
}

.harpoon-toggle {
  padding: 4px 6px;
  border-radius: 8px;
  min-width: 24px;
}

.harpoon-response-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.harpoon-toggle-view {
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  font-size: 11px;
  cursor: pointer;
}

.harpoon-toggle-view:disabled {
  opacity: 0.6;
  cursor: default;
}

.harpoon-call-details {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.harpoon-payload pre {
  margin-top: 6px;
}

@media (max-width: 980px) {
  .harpoon-call-header {
    grid-template-columns: 26px minmax(160px, 1fr) minmax(90px, 0.8fr)
      minmax(80px, 0.8fr) minmax(90px, 1fr);
  }
}

@media (max-width: 820px) {
  .harpoon-table th:nth-child(4),
  .harpoon-table td:nth-child(4) {
    display: none;
  }

  .harpoon-toolbar {
    flex-direction: column;
  }

  .harpoon-toolbar-spacer {
    display: none;
  }

  .harpoon-controls {
    width: 100%;
    flex-wrap: wrap;
  }
}

@media (max-width: 720px) {
  .harpoon-call-header {
    grid-template-columns: 26px 1fr;
  }

  .channel-detail-kv {
    grid-template-columns: 1fr;
  }

  .system-history-head {
    grid-template-columns: 1fr;
  }
}
