:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #182029;
  background: #f3f5f7;
  font-synthesis: none;
  --ink: #182029;
  --muted: #68727d;
  --line: #d9dee4;
  --surface: #ffffff;
  --blue: #0969da;
  --blue-hover: #0759ba;
  --green: #16784b;
  --green-bg: #eaf7f0;
  --amber: #8a5a00;
  --amber-bg: #fff4d6;
  --red: #b42318;
  --red-bg: #fff0ee;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, select { font: inherit; }
button { letter-spacing: 0; }

.app-header {
  height: 58px;
  border-bottom: 1px solid #232c35;
  background: #182029;
  color: #fff;
}

.header-inner,
.command-inner,
.storage-inner,
.summary-inner,
.workspace {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.header-inner { height: 100%; display: flex; align-items: center; justify-content: space-between; }
.brand-cluster { min-width: 0; display: flex; align-items: center; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-size: 17px; font-weight: 700; }
.brand-mark { width: 28px; height: 28px; display: block; flex: 0 0 auto; }
.brand-divider { width: 1px; height: 24px; background: #4b5764; }
.foc-brand { min-width: 0; display: inline-flex; align-items: center; gap: 8px; color: #d3dae2; text-decoration: none; font-size: 12px; font-weight: 650; }
.foc-brand:hover { color: #fff; }
.foc-brand img { width: 27px; height: 25px; flex: 0 0 auto; object-fit: contain; }
.foc-brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: 16px; }
.network-status { display: inline-flex; align-items: center; gap: 8px; color: #d3dae2; font-size: 13px; }
.network-dot { width: 8px; height: 8px; border-radius: 50%; background: #3cc57c; box-shadow: 0 0 0 3px rgba(60,197,124,.14); }
.network-warning .network-dot { background: #f5a524; box-shadow: 0 0 0 3px rgba(245,165,36,.14); }
.metamask-button { height: 38px; max-width: 230px; display: inline-flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid #f19a4a; border-radius: 5px; background: #fff7ef; color: #5b2c06; cursor: pointer; font-size: 13px; font-weight: 750; }
.metamask-button:hover:not(:disabled) { background: #ffead7; border-color: #e2761b; }
.metamask-button:disabled { opacity: .65; cursor: wait; }
.metamask-button img { width: 24px; height: 24px; flex: 0 0 auto; }
.metamask-button span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switch-wallet-button { height: 38px; padding: 0 12px; border: 1px solid #66717d; border-radius: 5px; background: transparent; color: #eef2f6; cursor: pointer; font-size: 13px; font-weight: 700; }
.switch-wallet-button:hover:not(:disabled) { border-color: #aeb7c1; background: #25303a; }
.switch-wallet-button:disabled { opacity: .55; cursor: wait; }
.switch-wallet-button[hidden] { display: none; }

.command-band { background: var(--surface); border-bottom: 1px solid var(--line); }
.command-inner { min-height: 86px; display: flex; align-items: center; }
h1, h2, p { margin: 0; }
h1 { margin-top: 5px; font-size: 27px; line-height: 1.2; letter-spacing: 0; }
h2 { margin-top: 4px; font-size: 18px; line-height: 1.25; letter-spacing: 0; }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.button { min-height: 38px; padding: 0 15px; border-radius: 5px; border: 1px solid transparent; cursor: pointer; font-size: 14px; font-weight: 650; }
.button:disabled { opacity: .5; cursor: not-allowed; }
.button-primary { background: var(--blue); color: #fff; }
.button-primary:hover:not(:disabled) { background: var(--blue-hover); }
.button-secondary { background: #fff; color: var(--ink); border-color: #b9c1ca; }
.button-secondary:hover:not(:disabled) { background: #f4f6f8; }
.button[aria-busy="true"] { opacity: .78; cursor: wait; }
.button-spinner { width: 14px; height: 14px; flex: 0 0 auto; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: button-spin .8s linear infinite; }
.button-spinner[hidden] { display: none; }
@keyframes button-spin { to { transform: rotate(360deg); } }

.storage-band { border-bottom: 1px solid var(--line); background: var(--surface); }

.summary-band { background: #eef1f4; border-bottom: 1px solid var(--line); }
.summary-inner { display: grid; grid-template-columns: 280px minmax(0, 1fr) 220px; min-height: 92px; }
.summary-item { display: flex; flex-direction: column; justify-content: center; gap: 8px; padding: 12px 24px 12px 0; border-right: 1px solid var(--line); }
.summary-item + .summary-item { padding-left: 24px; }
.summary-item:last-child { border-right: 0; }
.summary-label { color: var(--muted); font-size: 12px; }
.summary-value { font-size: 14px; font-weight: 650; }
.health-reason { max-width: 250px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.inline-value { min-width: 0; display: flex; align-items: center; gap: 12px; }
.inline-value code { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #2b3641; font-size: 13px; }
.text-button { padding: 0; border: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: 12px; font-weight: 700; }
.text-button:disabled { color: var(--muted); cursor: not-allowed; opacity: .65; }

.status-badge, .table-status { width: fit-content; display: inline-flex; align-items: center; min-height: 24px; padding: 3px 9px; border-radius: 4px; font-size: 12px; font-weight: 750; }
.status-healthy, .status-success { color: var(--green); background: var(--green-bg); }
.status-degraded, .status-pending { color: var(--amber); background: var(--amber-bg); }
.status-unhealthy, .status-failed { color: var(--red); background: var(--red-bg); }
.status-unknown { color: #59636e; background: #e6eaee; }

.status-guide { border-bottom: 1px solid var(--line); background: #fff; }
.status-guide-inner { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 13px 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.status-guide-inner > div { min-width: 0; display: flex; align-items: flex-start; gap: 9px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.status-guide-inner .table-status { flex: 0 0 auto; }

.workspace { padding: 28px 0 56px; }
.provider-section { margin-bottom: 26px; }
.upload-panel { margin-bottom: 24px; padding: 22px; display: grid; grid-template-columns: minmax(260px, .85fr) minmax(360px, 1.15fr); gap: 48px; align-items: center; border: 1px solid #cbd4de; border-left: 4px solid var(--blue); background: var(--surface); }
.upload-copy p:last-child { max-width: 480px; margin-top: 9px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.upload-control { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 12px; align-items: center; }
.file-picker { position: relative; height: 42px; min-width: 0; display: flex; align-items: center; padding: 0 12px 0 0; overflow: hidden; border: 1px dashed #9ba7b4; border-radius: 5px; background: #f8fafc; color: #44505c; cursor: pointer; font-size: 13px; }
.file-picker:hover { border-color: var(--blue); background: #f1f7ff; }
.file-picker-action { height: 100%; flex: 0 0 auto; display: flex; align-items: center; padding: 0 12px; border-right: 1px solid #c7d0da; color: var(--ink); font-weight: 700; }
.file-picker-name { min-width: 0; margin-left: 12px; overflow: hidden; color: var(--muted); font-size: 12px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.upload-control progress { grid-column: 1 / -1; width: 100%; height: 6px; accent-color: var(--blue); }
.upload-status { min-width: 0; color: var(--muted); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.upload-result { justify-self: end; color: var(--green); font-size: 11px; overflow-wrap: anywhere; }
.piece-picker { min-height: 136px; padding: 20px 0; display: grid; grid-template-columns: minmax(280px, .85fr) minmax(480px, 1.15fr); align-items: center; gap: 48px; }
.piece-picker-copy { min-width: 0; }
.wallet-scope { margin-top: 9px; color: var(--muted); font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.repair-description { max-width: 500px; margin-top: 7px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.piece-control { min-width: 0; display: grid; grid-template-columns: 1fr auto; gap: 7px 12px; align-items: center; }
.piece-control label { color: var(--muted); font-size: 12px; font-weight: 700; }
.piece-select-row { grid-column: 1 / -1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.piece-control select { min-width: 0; flex: 1 1 auto; width: 100%; height: 42px; padding: 0 38px 0 12px; border: 1px solid #aeb7c1; border-radius: 5px; background: var(--surface); color: var(--ink); cursor: pointer; font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 12px; }
.piece-control select:focus { outline: 2px solid rgba(9,105,218,.24); border-color: var(--blue); }
.piece-control select:disabled { background: #eef1f4; color: var(--muted); cursor: not-allowed; }
.piece-meta { grid-row: 1; grid-column: 2; color: var(--muted); font-size: 12px; white-space: nowrap; }
.repair-button { flex: 0 0 174px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
.repair-button[hidden] { display: none; }
.check-button { flex: 0 0 126px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
.repair-status { grid-column: 1 / -1; color: var(--blue); font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.repair-status[hidden] { display: none; }
.monitor-panel { margin: -8px 0 34px; padding: 22px; display: grid; grid-template-columns: minmax(260px, .85fr) minmax(420px, 1.15fr); gap: 48px; align-items: center; border: 1px solid #cbd4de; background: var(--surface); }
.monitor-description { max-width: 480px; margin-top: 9px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.monitor-target { margin-top: 10px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.monitor-target strong { margin-right: 7px; color: var(--ink); }
.monitor-control { min-width: 0; padding-left: 28px; display: grid; grid-template-columns: minmax(200px, 1fr) auto; grid-template-areas: "schedule next" "actions actions" "status status"; gap: 12px 18px; align-items: center; border-left: 1px solid var(--line); }
.monitor-schedule { grid-area: schedule; min-width: 0; display: flex; align-items: center; gap: 12px; }
.monitor-schedule label { flex: 0 0 auto; color: var(--muted); font-size: 12px; font-weight: 700; }
.interval-input { width: 160px; height: 40px; display: flex; align-items: center; border: 1px solid #aeb7c1; border-radius: 5px; background: #fff; }
.interval-input input { width: 68px; height: 100%; padding: 0 8px; border: 0; background: transparent; text-align: right; font-weight: 700; }
.interval-input input:focus { outline: 2px solid rgba(9,105,218,.24); }
.interval-input span { padding-right: 10px; color: var(--muted); font-size: 12px; }
.monitor-status, .monitor-next { color: var(--muted); font-size: 12px; line-height: 1.45; }
.monitor-actions { grid-area: actions; display: flex; justify-content: flex-start; flex-wrap: wrap; gap: 10px; }
.monitor-actions .button { white-space: nowrap; }
.test-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 124px; }
.monitor-status { grid-area: status; padding-top: 10px; border-top: 1px solid #e8ebef; }
.monitor-next { grid-area: next; justify-self: end; white-space: nowrap; }
.monitor-next strong { color: var(--ink); font-weight: 700; }
.section-block { margin-bottom: 34px; }
.section-heading { min-height: 52px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.section-count, .signature-state { color: var(--muted); font-size: 12px; padding-top: 17px; }
.signature-ok { color: var(--green); font-weight: 700; }
.signature-failed { color: var(--red); font-weight: 700; }

.table-shell { width: 100%; max-width: 100%; overflow-x: auto; border: 1px solid var(--line); background: var(--surface); }
.deliveries-section table { min-width: 1120px; }
.deliveries-section th:nth-child(3) { width: 260px; }
table { width: 100%; min-width: 760px; border-collapse: collapse; table-layout: fixed; }
th, td { height: 54px; padding: 10px 14px; border-bottom: 1px solid #e8ebef; text-align: left; vertical-align: middle; font-size: 13px; }
th { position: relative; height: 40px; background: #f8f9fa; color: #5c6670; font-size: 11px; font-weight: 750; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfc; }
td code { font-size: 12px; }
.provider-cell { display: flex; align-items: center; gap: 9px; font-weight: 700; }
.provider-role { color: var(--muted); font-size: 11px; font-weight: 600; }
.retrieval-cell { display: flex; align-items: flex-start; flex-direction: column; gap: 5px; }
.retrieval-link { color: var(--blue); font-size: 11px; font-weight: 700; line-height: 1.25; text-decoration: none; white-space: nowrap; }
.retrieval-link:hover { text-decoration: underline; }
.retrieval-link:focus-visible { border-radius: 2px; outline: 2px solid rgba(9,105,218,.28); outline-offset: 2px; }
.empty-cell { height: 92px; color: var(--muted); text-align: center; }
.row-action { padding: 5px 8px; border: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: 12px; font-weight: 700; }
.run-reason { color: var(--muted); font-size: 12px; line-height: 1.4; }
.delivery-pagination { min-height: 58px; padding-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--muted); font-size: 12px; }
.delivery-pagination[hidden] { display: none; }
.pagination-controls { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.pagination-controls label { white-space: nowrap; }
.pagination-controls select { height: 34px; padding: 0 28px 0 9px; border: 1px solid #aeb7c1; border-radius: 4px; background: #fff; color: var(--ink); font-size: 12px; }
.pagination-button { width: 34px; height: 34px; padding: 0; border: 1px solid #b9c1ca; border-radius: 4px; background: #fff; color: var(--ink); cursor: pointer; font-size: 18px; line-height: 1; }
.pagination-button:hover:not(:disabled) { background: #f4f6f8; border-color: #8995a1; }
.pagination-button:disabled { color: #aeb7c1; cursor: not-allowed; opacity: .65; }
.pagination-page { min-width: 76px; color: var(--ink); text-align: center; white-space: nowrap; }

.payload-section pre { min-height: 260px; max-height: 460px; margin: 0; padding: 18px; overflow: auto; border: 1px solid #303a44; background: #182029; color: #dce5ee; font: 12px/1.65 "SFMono-Regular", Consolas, "Liberation Mono", monospace; white-space: pre-wrap; word-break: break-word; }
.toast { position: fixed; right: 20px; bottom: 20px; max-width: min(380px, calc(100% - 40px)); padding: 11px 14px; border: 1px solid #303a44; border-radius: 5px; background: #182029; color: #fff; font-size: 13px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .18s ease, transform .18s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { border-color: #e36b60; background: #4e1f1b; }
.visually-hidden { position: absolute; left: 0; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 760px) {
  .header-inner, .command-inner, .storage-inner, .summary-inner, .status-guide-inner, .workspace { width: min(100% - 24px, 1180px); }
  .command-inner { min-height: 82px; }
  .header-actions { gap: 9px; }
  .network-status { display: none; }
  .metamask-button { max-width: 190px; padding: 0 9px; }
  .switch-wallet-button { padding: 0 9px; }
  .summary-inner { display: block; padding: 8px 0; }
  .summary-item, .summary-item + .summary-item { padding: 12px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .summary-item:last-child { border-bottom: 0; }
  .status-guide-inner { grid-template-columns: 1fr 1fr; gap: 12px 18px; }
  .workspace { padding-top: 24px; }
  .upload-panel { grid-template-columns: 1fr; gap: 18px; padding: 18px; }
  .piece-picker { grid-template-columns: 1fr; gap: 18px; padding: 20px 0; }
  .piece-select-row { flex-wrap: wrap; }
  .piece-select-row select { flex-basis: 320px; }
  .monitor-panel { grid-template-columns: 1fr; gap: 18px; padding: 18px; }
  .monitor-control { padding-left: 0; border-left: 0; }
  .section-block { min-width: 0; }
  .table-shell { overscroll-behavior-inline: contain; }
  h1 { font-size: 23px; }
}

@media (max-width: 430px) {
  .brand > span:last-child { display: none; }
  .metamask-button { max-width: 210px; }
  .upload-control { grid-template-columns: 1fr; }
  .upload-control .button, .upload-control progress { grid-column: 1; width: 100%; }
  .upload-result { justify-self: start; }
  .piece-select-row { align-items: stretch; flex-direction: column; }
  .piece-select-row select { flex-basis: auto; }
  .piece-select-row .button { width: 100%; flex-basis: auto; }
  .status-guide-inner { grid-template-columns: 1fr; }
  .monitor-control { grid-template-columns: 1fr; grid-template-areas: "schedule" "next" "actions" "status"; }
  .monitor-schedule { align-items: stretch; flex-direction: column; gap: 7px; }
  .interval-input { width: 100%; }
  .monitor-actions { align-items: stretch; flex-direction: column; }
  .monitor-actions .button { width: 100%; }
  .monitor-next { justify-self: start; white-space: normal; }
  .brand-cluster { gap: 8px; }
  .brand-divider { height: 22px; }
  .foc-brand span { display: none; }
  .delivery-pagination { align-items: stretch; flex-direction: column; gap: 12px; }
  .pagination-controls { justify-content: space-between; flex-wrap: wrap; }
  .pagination-controls label { flex: 1 0 100%; }
  .pagination-page { flex: 1 0 auto; }
}
