/* Bitcoin theme - dark orange IBM-style */
:root {
  --bg: #1f1f1f;
  --panel: #2a2a2a;
  --panel-light: #333333;
  --panel-field: #3a3a3a;
  --border: #4a4a4a;
  --text: #e0e0e0;
  --muted: #b0b0b0;
  --accent: #00b7ff;
  --orange: #e0e0e0;
}

/* Portal pages: web UI + settings - full Bitcoin theme */
body.portal-page {
  --bg: #0a0604;
  --panel: #120b08;
  --panel-light: #1a100c;
  --panel-field: #241810;
  --border: #3d2818;
  --text: #e8d4b8;
  --muted: #a68b6b;
  --accent: #f7931a;
  --orange: #f7931a;
  background: #0a0604;
  position: relative;
}

body.portal-page::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 1px,
    rgba(0, 0, 0, 0.12) 1px,
    rgba(0, 0, 0, 0.12) 2px
  );
  z-index: 9998;
}

body.portal-page .container {
  position: relative;
  z-index: 1;
}

body.portal-page .loading-overlay {
  background: rgba(10, 6, 4, 0.96);
}

body.portal-page .loading-spinner {
  border-top-color: var(--accent);
}

body.portal-page input:focus,
body.portal-page select:focus {
  box-shadow: 0 0 0 2px rgba(247, 147, 26, 0.25);
}

body.portal-page .btn {
  box-shadow: 0 2px 4px rgba(247, 147, 26, 0.2);
}

body.portal-page .btn:hover {
  box-shadow: 0 3px 6px rgba(247, 147, 26, 0.35);
}

body.portal-page .btn.secondary:hover {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
}

body.portal-page .settings-section-actions .btn.secondary:hover {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

body.portal-page .settings-section-actions .btn.danger {
  background: var(--panel-light);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

body.portal-page .settings-section-actions .btn.danger:hover {
  background: #ef4444;
  color: #fff;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.35);
}

body.portal-page .progress-bar-fill {
  background: linear-gradient(90deg, var(--accent), #fbbf24);
}

body.portal-page .status.success,
body.portal-page .status.info {
  background: rgba(247, 147, 26, 0.12);
}

body.portal-page .block-height {
  color: var(--accent);
}

/* Scrollbar styling - match portal theme */
html:has(body.portal-page) ::-webkit-scrollbar,
body.portal-page ::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
html:has(body.portal-page) ::-webkit-scrollbar-track,
body.portal-page ::-webkit-scrollbar-track {
  background: var(--panel-light);
  border-radius: 5px;
}
html:has(body.portal-page) ::-webkit-scrollbar-thumb,
body.portal-page ::-webkit-scrollbar-thumb {
  background: rgba(247, 147, 26, 0.35);
  border-radius: 5px;
  border: 2px solid var(--panel-light);
}
html:has(body.portal-page) ::-webkit-scrollbar-thumb:hover,
body.portal-page ::-webkit-scrollbar-thumb:hover {
  background: rgba(247, 147, 26, 0.55);
}
html:has(body.portal-page) ::-webkit-scrollbar-corner,
body.portal-page ::-webkit-scrollbar-corner {
  background: var(--panel-light);
}

html:has(body.portal-page),
body.portal-page,
body.portal-page .tx-detail-panel,
body.portal-page .tx-graph {
  scrollbar-width: thin;
  scrollbar-color: rgba(247, 147, 26, 0.45) var(--panel-light);
}

/* ── Ocean theme ───────────────────────────────────────────── */
body[data-theme="ocean"].portal-page {
  --bg: #061a2e;
  --panel: #0c2438;
  --panel-light: #132d44;
  --panel-field: #1a3752;
  --border: #1e4976;
  --text: #b8e4f0;
  --muted: #7eb8c9;
  --accent: #22d3ee;
  --orange: #2dd4bf;
  background: #061a2e;
}

body[data-theme="ocean"].portal-page::after {
  background-image: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 1px,
    rgba(0, 20, 40, 0.15) 1px,
    rgba(0, 20, 40, 0.15) 2px
  );
}

body[data-theme="ocean"].portal-page .loading-overlay {
  background: rgba(6, 26, 46, 0.96);
}

body[data-theme="ocean"].portal-page .loading-spinner {
  border-top-color: var(--accent);
}

body[data-theme="ocean"].portal-page input:focus,
body[data-theme="ocean"].portal-page select:focus {
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.35);
}

body[data-theme="ocean"].portal-page .btn {
  box-shadow: 0 2px 4px rgba(34, 211, 238, 0.25);
}

body[data-theme="ocean"].portal-page .btn:hover {
  box-shadow: 0 3px 6px rgba(34, 211, 238, 0.4);
}

body[data-theme="ocean"].portal-page .progress-bar-fill {
  background: linear-gradient(90deg, #22d3ee, #2dd4bf);
}

body[data-theme="ocean"].portal-page .status.success,
body[data-theme="ocean"].portal-page .status.info {
  background: rgba(34, 211, 238, 0.15);
}

body[data-theme="ocean"].portal-page .block-height {
  color: var(--accent);
}

body[data-theme="ocean"].portal-page ::-webkit-scrollbar-thumb {
  background: rgba(34, 211, 238, 0.4);
  border: 2px solid var(--panel-light);
}

body[data-theme="ocean"].portal-page ::-webkit-scrollbar-thumb:hover {
  background: rgba(34, 211, 238, 0.6);
}

body[data-theme="ocean"].portal-page,
body[data-theme="ocean"].portal-page .tx-detail-panel,
body[data-theme="ocean"].portal-page .tx-graph {
  scrollbar-color: rgba(34, 211, 238, 0.5) var(--panel-light);
}

/* Ocean: display page + mempool */
body[data-theme="ocean"].display-page {
  background: #051420;
}

body[data-theme="ocean"] .display-shell,
body[data-theme="ocean"] .setup-screen,
body[data-theme="ocean"] .live-screen {
  background: #051420;
}

body[data-theme="ocean"] .mempool-treemap {
  background: #051420;
}

body[data-theme="ocean"] .display-shell::after {
  background-image: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 1px,
    rgba(0, 30, 60, 0.1) 1px,
    rgba(0, 30, 60, 0.1) 2px
  );
}

body[data-theme="ocean"] .mempool-fullscreen {
  color: #7eb8c9;
  background: rgba(12, 36, 56, 0.9);
  border-color: rgba(34, 211, 238, 0.4);
}

body[data-theme="ocean"] .mempool-fullscreen:hover {
  color: #22d3ee;
  border-color: rgba(34, 211, 238, 0.7);
}

body[data-theme="ocean"] .tx-tooltip {
  background: rgba(6, 26, 46, 0.96);
  border-color: rgba(34, 211, 238, 0.45);
  color: #b8e4f0;
  box-shadow: 0 4px 24px rgba(0, 50, 80, 0.5);
}

body[data-theme="ocean"] .mempool-interactive .mempool-block:hover {
  background: #0c2438 !important;
  border: 1px solid rgba(34, 211, 238, 0.5);
}

body[data-theme="ocean"] .mempool-empty {
  color: #7eb8c9;
}

body[data-theme="ocean"] .display-load-overlay {
  background: #051420;
}

body[data-theme="ocean"] .setup-content .sub,
body[data-theme="ocean"] .setup-stage-label {
  color: #7eb8c9;
}

body[data-theme="ocean"] .tx-ticker {
  background: linear-gradient(90deg, #061a2e, #22d3ee, #2dd4bf, #061a2e);
  background-size: 300% 100%;
}

/* Portal metrics: consistent 24px spacing between all sections */
#metrics {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
#metricsGrid .grid {
  margin-bottom: 0;
}
#metrics .section.display-preview {
  margin-top: 0;
  margin-bottom: 0;
}
#metricsRest {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
#metricsRest > * {
  margin-top: 0 !important;
}

.display-preview {
  overflow: hidden;
  border: none;
}

.display-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.display-preview-header h2 {
  margin: 0;
}

.display-open-full {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--panel-light);
  border: none;
  border-radius: 6px;
  color: var(--accent);
  cursor: pointer;
  transition: all 0.2s;
}
.display-open-full:hover {
  background: var(--panel);
  opacity: 0.9;
}

.display-iframe-wrapper {
  overflow: hidden;
  height: 0;
  transition: height .5s ease-out;
  border-radius: 8px;
}

.display-iframe-wrapper.iframe-ready {
  height: 420px;
}

.display-iframe {
  width: 100%;
  height: 420px;
  border: none;
  border-radius: 8px;
  background: var(--bg);
  display: block;
}

/* Transaction detail panel (expandable below iframe) - uses theme variables */
.tx-detail-panel {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.35s ease-out;
  background: color-mix(in srgb, var(--panel) 60%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-top: none;
  border-radius: 0 0 8px 8px;
  position: relative;
  margin-top: 12px;
}

.tx-detail-panel.expanded {
  max-height: min(70vh, 800px);
  overflow-y: auto;
}

.tx-detail-panel:fullscreen,
.tx-detail-panel:-webkit-full-screen {
  max-height: none;
  height: 100%;
  overflow-y: auto;
  border-radius: 0;
  border: none;
  background: color-mix(in srgb, var(--panel) 98%, transparent);
}

.tx-detail-panel:fullscreen .tx-graph,
.tx-detail-panel:-webkit-full-screen .tx-graph {
  padding: 32px 48px 48px;
  gap: 24px;
}

.tx-detail-panel:fullscreen .tx-graph-node,
.tx-detail-panel:-webkit-full-screen .tx-graph-node {
  font-size: 13px;
  padding: 12px 16px;
  max-width: 180px;
}

.tx-detail-close,
.tx-detail-fullscreen {
  position: absolute;
  top: 8px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  opacity: 0.8;
}
.tx-detail-close {
  right: 12px;
}
.tx-detail-fullscreen {
  right: 40px;
}
.tx-detail-close:hover,
.tx-detail-fullscreen:hover {
  color: var(--accent);
  opacity: 1;
}


.tx-detail-header {
  padding: 12px 40px 8px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.tx-detail-txid {
  font-family: ui-monospace, monospace;
  color: var(--text);
  word-break: break-all;
}

.tx-detail-status {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tx-graph {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px 24px 24px;
  min-height: 140px;
  overflow-x: auto;
  transition: opacity 0.2s ease;
}

.tx-graph.tx-graph-swapping {
  opacity: 0;
}

.tx-graph-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  min-width: 100px;
}

.tx-graph-column-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 4px;
}

.tx-graph-node {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text);
  text-align: center;
  word-break: break-all;
  max-width: 140px;
  transition: background 0.2s, border-color 0.2s;
}

.tx-node-expandable {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}
.tx-node-expandable:hover {
  color: var(--accent);
}

.tx-graph-node.tx-node-expanded {
  max-width: 360px;
}

.tx-graph-node.tx-center {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  font-weight: 600;
}

.tx-graph-node .tx-node-value {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  margin-top: 2px;
}

.tx-graph-connector {
  flex-shrink: 0;
  width: 24px;
  height: 2px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 40%, transparent), color-mix(in srgb, var(--accent) 20%, transparent));
}

.tx-detail-loading,
.tx-detail-error {
  padding: 16px 24px 24px;
  font-size: 13px;
  color: var(--muted);
}

.tx-detail-error {
  color: #e57373;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  overflow-x: hidden;
  max-width: 100%;
  width: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, Roboto, sans-serif;
  background: linear-gradient(135deg, #252525 0%, #1f1f1f 25%, #2a2a2a 50%, #1f1f1f 75%, #252525 100%);
  background-attachment: fixed;
  color: var(--text);
  padding: 20px;
  min-height: 100vh;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  transition: opacity 0.3s ease;
}

.container.faded {
  opacity: 0.5;
}

.loading-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(31, 31, 31, 0.95);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 20px;
}

.loading-overlay.active {
  display: flex;
}

.loading-spinner {
  border: 4px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-text {
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  line-height: 1.4;
  max-width: 90%;
  word-wrap: break-word;
}

.logo {
  height: 22px;
  margin-top: -5px;
  width: auto;
  margin-right: 12px;
  flex-shrink: 0;
  display: block;
  object-fit: contain;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  gap: 12px;
}

.header-left {
  display: flex;
  align-items: center;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-btn {
  color: var(--accent);
  font-size: 14px;
  padding: 8px 12px;
  background: var(--panel-light);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.header-btn:hover {
  background: var(--panel);
  opacity: 0.9;
}

h1 {
  font-size: 17px;
  color: #e0e0e0;
  line-height: 1;
}

h2 {
  font-size: 18px;
  margin-bottom: 16px;
  color: var(--text);
  font-weight: 600;
}

h3 {
  font-size: 14px;
  margin-bottom: 12px;
  color: var(--text);
  font-weight: 600;
}

.back-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 16px;
  background: var(--panel-light);
  border-radius: 6px;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.back-link:hover {
  background: var(--panel);
  opacity: 0.9;
}

.section {
  background: var(--panel);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 32px;
  max-width: 100%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.section .section {
  background: var(--panel-light);
  margin-top: 16px;
  margin-bottom: 20px;
}

label {
  display: block;
  margin: 16px 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

label:first-child {
  margin-top: 0;
}

input, select {
  width: 100%;
  max-width: 100%;
  padding: 10px;
  background: var(--panel-field);
  border: none;
  border-radius: 6px;
  color: var(--text);
  font-size: 16px;
  box-sizing: border-box;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

select {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12"><path fill="%23b0b0b0" d="M6 9L1 4h10z"/></svg>');
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

input[data-password="true"] {
  -webkit-text-security: disc;
  text-security: disc;
}

input:focus, select:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 183, 255, 0.2);
}

form {
  max-width: 100%;
  overflow: hidden;
}

.form-row {
  margin-bottom: 16px;
}

.form-row:last-of-type {
  margin-bottom: 0;
}

body.settings-page .form-row + .btn {
  margin-top: 16px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-width: 100%;
}

.status {
  margin-top: 12px;
  padding: 12px;
  border-radius: 6px;
  background: var(--panel-light);
  font-size: 13px;
  max-width: 100%;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.status.success {
  background: rgba(0, 183, 255, 0.08);
}

.status.error {
  background: rgba(239, 68, 68, 0.08);
}

.status.info {
  background: rgba(0, 183, 255, 0.08);
}

.metrics {
  display: grid;
  gap: 12px;
  max-width: 100%;
}

.metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  padding: 8px 10px;
  background: var(--panel-light);
  border-radius: 6px;
  max-width: 100%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

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

.metric .value {
  color: var(--text);
  font-weight: 600;
  word-wrap: break-word;
  text-align: right;
  min-width: 0;
}

.system-groups {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.system-group {
  padding: 16px;
  background: var(--panel);
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.system-group-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 14px 0;
}

.system-group .metrics-compact {
  gap: 10px;
}

.system-group .metrics-compact .metric {
  padding: 8px 12px;
  font-size: 13px;
}

.btn {
  width: 100%;
  max-width: 100%;
  padding: 12px;
  margin-top: 16px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-sizing: border-box;
  box-shadow: 0 2px 4px rgba(0, 183, 255, 0.2);
  text-decoration: none;
  display: inline-block;
  text-align: center;
  font-size: inherit;
}

form .btn:first-of-type {
  margin-top: 20px;
}

.btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 183, 255, 0.3);
}

.btn.secondary {
  background: var(--panel-light);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  width: auto;
}

.btn.secondary:hover {
  background: var(--panel);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}

.btn.danger {
  background: #ef4444;
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.btn.danger:hover {
  box-shadow: 0 3px 6px rgba(239, 68, 68, 0.4);
  transform: translateY(-1px);
}

.btn-flat,
.btn-flat:hover {
  box-shadow: none !important;
}

/* Metrics / index page */
.subtitle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 16px;
}

.subtitle {
  font-size: 18px;
  color: var(--muted);
  font-weight: 400;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 16px;
  margin-bottom: 24px;
  max-width: 100%;
}

.card {
  background: var(--panel);
  border-radius: 8px;
  padding: 20px;
  max-width: 100%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.card-title {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.card-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.card-label {
  font-size: 14px;
  color: var(--muted);
}

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

.v {
  font-size: 28px;
  font-weight: 700;
}

.highlight {
  color: var(--accent);
}

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

.blocks-section {
  margin-top: 0;
}

.blocks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.block-card {
  background: var(--panel);
  border-radius: 6px;
  padding: 16px;
  transition: border-radius 1s ease, padding 1s ease, box-shadow 1s ease, background-color 0.1s ease;
  max-width: 100%;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.block-card.new-block-blue {
  background-color: rgba(0, 183, 255, 0.3) !important;
  transition: background-color 0.1s ease !important;
  border-color: var(--accent);
}

.block-card.new-block-orange {
  background-color: rgba(247, 147, 26, 0.3) !important;
  transition: background-color 0.1s ease !important;
  border-color: var(--orange);
}

.block-height {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.block-time {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

.block-stat {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  margin-top: 8px;
  padding-top: 8px;
}

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

.block-stat-value {
  color: var(--text);
  font-weight: 600;
}

.mempool-section {
  margin-top: 0;
}

.mempool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.mempool-card {
  background: var(--panel);
  border-radius: 6px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.mempool-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.mempool-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
}

.fee-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.fee-card {
  background: var(--panel);
  border-radius: 6px;
  padding: 16px;
  text-align: center;
  max-width: 100%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.fee-card-title {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.fee-card-value {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
}

.fee-card-time {
  font-size: 12px;
  color: var(--muted);
}

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

.fee-low {
  color: #22c55e;
}

.fee-medium {
  color: #f59e0b;
}

.fee-high {
  color: #ef4444;
}

.progress-section {
  margin-top: 0;
}

.progress-bar-container {
  background: var(--panel);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.progress-bar {
  height: 12px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--orange));
  transition: width 0.5s ease;
  border-radius: 6px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  font-size: 13px;
}

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

.progress-value {
  color: var(--text);
  font-weight: 600;
}

.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 24px;
  max-width: 100%;
  word-wrap: break-word;
}

.status-connected {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.status-disconnected {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.status-retry {
  background: rgba(247, 147, 26, 0.15);
  color: #f7931a;
}

.error-msg {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  padding: 16px;
  border-radius: 8px;
  margin-top: 16px;
}

.loading {
  text-align: center;
  padding: 40px;
  color: var(--muted);
}

.refresh-countdown {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  display: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.hidden {
  display: none;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
}

/* Display / kiosk shell - IBM-style dark orange + scan lines */
body.display-page {
  padding: 0;
  background: #0a0604;
}

.mempool-fullscreen {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 10001;
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #a68b6b;
  background: rgba(18, 11, 8, 0.8);
  border: 1px solid rgba(247, 147, 26, 0.35);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.2s, color 0.2s, border-color 0.2s;
}
.mempool-fullscreen:hover {
  opacity: 1;
  color: #f7931a;
  border-color: rgba(247, 147, 26, 0.6);
}

.display-load-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 99999;
  animation: display-load-fade 2s forwards;
}

@keyframes display-load-fade {
  0%, 50% { opacity: 1; }
  100% { opacity: 0; pointer-events: none; }
}

body.display-page .container.display-shell {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
}

.display-shell {
  min-height: 100vh;
  width: 100%;
  padding: 0;
  position: relative;
  background: #0a0604;
}

.display-shell::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 1px,
    rgba(0, 0, 0, 0.12) 1px,
    rgba(0, 0, 0, 0.12) 2px
  );
  z-index: 9999;
}

.setup-screen, .live-screen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding: 20px;
  text-align: center;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0a0604;
}

.setup-screen {
  padding: 0;
}

/* Setup: center tag for centering; flex for vertical centering in viewport */
.setup-content {
  display: block;
  opacity: 0;
  animation: setup-fade-in 0.6s ease forwards;
}

@keyframes setup-fade-in {
  to {
    opacity: 1;
  }
}

.setup-content .qr {
  display: block;
  margin: 0 auto 16px;
  transform: scale(1);
  max-width: none;
  opacity: 1;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.setup-content .sub {
  display: block;
  max-width: 280px;
  margin: 0 auto;
  opacity: 1;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

/* Animate out: shrink + fade */
.setup-content .qr.qr-exit {
  opacity: 0;
  transform: scale(0.7);
}

/* Animate in: start scaled up, land at normal */
.setup-content .qr.qr-enter {
  opacity: 0;
  transform: scale(1.15);
}

.setup-content .sub.qr-exit {
  opacity: 0;
  transform: translateY(12px);
}

.setup-content .sub.qr-enter {
  opacity: 0;
  transform: translateY(-8px);
}

.setup-screen.hidden, .live-screen.hidden {
  display: none !important;
}

.setup-screen h1, .live-screen h1 {
  margin: 4px 0 8px;
  font-size: 24px;
}

.setup-screen .sub, .live-screen .sub {
  margin: 4px 0;
  font-size: 13px;
}

.setup-screen .setup-content .sub {
  margin: 0;
}

.qr {
  width: min(62vw, 240px);
  max-width: 100%;
  background: white;
  padding: 8px;
  border-radius: 10px;
}

/* Mempool treemap (live-screen when setup complete) */
.live-screen.mempool-screen {
  padding: 0;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  border: none;
}

.mempool-treemap {
  flex: 1;
  min-height: 0;
  width: 100%;
  position: relative;
  overflow: hidden;
  background: #0a0604;
  transition: background 0.5s ease;
  border: none;
}
.mempool-block {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
  /* GPU-accelerated: transform avoids layout reflow during animation (smooth 60fps) */
  transform: translate(var(--tx, 0), var(--ty, 0)) scale(var(--tw, 1), var(--th, 1));
  background-color: var(--block-color, #f7931a);
  box-sizing: border-box;
  transition: transform 0.25s cubic-bezier(0.25, 0.1, 0.25, 1), opacity 0.25s ease-in-out;
  border: 0;
  animation: block-random-flash var(--flash-duration, 4s) ease-in-out infinite;
  animation-delay: var(--flash-delay, 0s);
  /* Avoid paint-containment artifacts where color appears only after hover/repaint. */
  contain: layout;
}

/* At high tx density, use shorter motion transitions to reduce refresh hitching. */
.mempool-treemap.mempool-high-density .mempool-block {
  transition: transform 0.14s linear, opacity 0.16s ease-out;
}

.mempool-block.mempool-block-static {
  animation: none;
}

@keyframes block-random-flash {
  0%, 90%, 100% { opacity: 1; }
  20%, 50%, 80% { opacity: var(--flash-dip, 0.4); }
  40%, 70% { opacity: 1; }
}

/* Ocean theme: wave-like animation */
body[data-theme="ocean"] .mempool-block:not(.mempool-block-static) {
  animation: block-ocean-wave var(--flash-duration, 5s) ease-in-out infinite;
}

@keyframes block-ocean-wave {
  0%, 100% { opacity: 1; }
  25% { opacity: var(--flash-dip, 0.4); }
  50% { opacity: 1; }
  75% { opacity: var(--flash-dip, 0.4); }
}

/* Hover effects only for /mempool (interactive); /display has pointer-events: none */
body.mempool-interactive .mempool-block {
  cursor: pointer;
}
body.mempool-interactive .mempool-block:hover {
  animation: none !important;
  opacity: 1 !important;
  background: #fff !important;
  transition: none;
}

/* /display (device kiosk): no pointer interaction, no hover effects */
body.display-kiosk .mempool-treemap {
  pointer-events: none;
}
body.display-kiosk .tx-tooltip {
  display: none !important;
}

.mempool-block.new {
  animation: mempool-block-appear 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  animation-fill-mode: both;
}

@keyframes mempool-block-appear {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.mempool-block.confirmation-ramp {
  animation: none !important;
  transition: opacity 0.9s ease-out;
}

.mempool-treemap.confirmation-flash {
  isolation: isolate;
}
.mempool-treemap.confirmation-flash::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  will-change: opacity;
  transform: translateZ(0);
  backface-visibility: hidden;
  background: linear-gradient(135deg,
    rgba(247, 147, 26, 0.9) 0%,
    rgba(255, 255, 255, 0.8) 50%,
    rgba(247, 147, 26, 0.9) 100%);
  mix-blend-mode: overlay;
  animation: confirmation-overlay-flash 3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

body[data-theme="ocean"] .mempool-treemap.confirmation-flash::after {
  background: linear-gradient(135deg,
    rgba(14, 165, 233, 0.9) 0%,
    rgba(255, 255, 255, 0.8) 50%,
    rgba(34, 211, 238, 0.9) 100%);
  mix-blend-mode: overlay;
}

@keyframes confirmation-overlay-flash {
  0% { opacity: 0; }
  8% { opacity: 1; }
  18% { opacity: 0; }
  26% { opacity: 1; }
  36% { opacity: 0; }
  44% { opacity: 1; }
  54% { opacity: 0; }
  62% { opacity: 1; }
  72% { opacity: 0; }
  78% { opacity: 1; }
  92% { opacity: 0; }
  100% { opacity: 0; }
}

.mempool-block.celebration {
  animation: block-celebration 1.4s ease-in-out forwards;
  animation-delay: 0s !important;
}

@keyframes block-celebration {
  0%, 100% { opacity: 1; }
  18% { opacity: 0; }
  36% { opacity: 1; }
  54% { opacity: 0; }
  72% { opacity: 1; }
  88% { opacity: 0; }
}

.mempool-exit-batch {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.4s ease-out;
}
.mempool-exit-batch.mempool-exit-batch-fade {
  opacity: 0;
}

/* Transaction hover card */
.tx-tooltip {
  position: fixed;
  z-index: 1000;
  padding: 12px 16px;
  background: rgba(18, 11, 8, 0.96);
  border: 1px solid rgba(247, 147, 26, 0.4);
  border-radius: 8px;
  color: #e8d4b8;
  font-size: 13px;
  line-height: 1.5;
  max-width: 320px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.tx-tooltip.visible {
  opacity: 1;
}

.tx-tooltip-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #a68b6b;
  margin-bottom: 2px;
}

.tx-tooltip-value {
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

.tx-tooltip .tx-tooltip-row {
  margin-bottom: 8px;
}

.tx-tooltip .tx-tooltip-row:last-child {
  margin-bottom: 0;
}

.mempool-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
}

.live-screen .ticker-wrap,
.live-screen .live-metrics {
  align-self: stretch;
}

.ticker-wrap {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 18px 0;
  padding: 16px;
}

.tx-ticker {
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg), var(--accent), #f59e0b, var(--bg));
  background-size: 300% 100%;
  animation: ticker-idle 4s linear infinite;
}

.live-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.pulse-soft {
  animation: ticker-soft 0.8s ease-out;
}

.pulse-strong {
  animation: ticker-strong 1.2s ease-out;
}

@keyframes ticker-idle {
  from { background-position: 0% 50%; }
  to { background-position: 100% 50%; }
}

@keyframes ticker-soft {
  0% { transform: scaleX(1); filter: brightness(1); }
  50% { transform: scaleX(1.02); filter: brightness(1.25); }
  100% { transform: scaleX(1); filter: brightness(1); }
}

@keyframes ticker-strong {
  0% { transform: scaleX(1); filter: brightness(1); }
  50% { transform: scaleX(1.04); filter: brightness(1.6); }
  100% { transform: scaleX(1); filter: brightness(1); }
}

/* Settings page - cards and structure */
body.settings-page .settings-card {
  padding: 20px;
  background: var(--panel);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
body.settings-page .settings-card h2 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 17px;
}

/* Settings page - actions (all viewports) */
body.settings-page .settings-section-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px;
}
body.settings-page .settings-section-actions h2 {
  flex-basis: 100%;
  margin-bottom: 0;
}
body.settings-page .settings-section-actions #actionStatus {
  flex-basis: 100%;
}
body.settings-page .settings-section-actions .btn {
  flex: 0 0 auto;
  min-width: 130px;
  width: auto;
  margin-top: 0;
}
body.settings-page .settings-section-actions .btn:first-of-type {
  flex: 1 1 auto;
  min-width: 140px;
}

/* Settings form buttons - proportional on desktop */
body.settings-page .settings-card form .btn,
body.settings-page .settings-card .btn[id] {
  width: 100%;
}
body.settings-page .settings-card .section .btn {
  width: auto;
  min-width: 140px;
}

/* Settings page - desktop layout */
@media (min-width: 900px) {
  body.settings-page .container {
    max-width: 1200px;
  }

  body.settings-page .settings-sections {
    display: flex;
    flex-direction: column;
    gap: 24px;
  }
  body.settings-page .settings-sections .section,
  body.settings-page .settings-sections .settings-card {
    margin-bottom: 0;
  }

  body.settings-page #setupSection {
    max-width: 640px;
  }

  /* Config row: WiFi + Appearance side by side */
  body.settings-page .settings-config-row {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 24px;
    align-items: start;
  }
  body.settings-page .settings-card-config {
    min-width: 0;
  }
  body.settings-page .settings-section-appearance {
    min-width: 0;
  }

  /* Form buttons in cards: auto width on desktop */
  body.settings-page .settings-card form .btn {
    width: auto;
    min-width: 140px;
    margin-top: 20px;
  }
  body.settings-page .settings-card .btn[id="saveThemeBtn"] {
    width: auto;
    min-width: 120px;
  }

  body.settings-page .settings-section-system .metrics-compact {
    grid-template-columns: repeat(2, 1fr);
  }

  body.settings-page .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 24px;
  }

  body.settings-page .form-row + .form-row {
    margin-top: 16px;
  }

  /* Single-field form rows (e.g. Theme) span full width */
  body.settings-page .form-row > div:only-child {
    grid-column: 1 / -1;
  }

  body.settings-page .form-row + .btn {
    margin-top: 20px;
  }

  /* Actions: primary wider, others proportional */
  body.settings-page .settings-section-actions .btn {
    min-width: 140px;
  }
  body.settings-page .settings-section-actions .btn:first-of-type {
    min-width: 160px;
  }
}

@media (min-width: 1100px) {
  body.settings-page .settings-section-system {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0;
  }
  body.settings-page .settings-section-system h2 {
    grid-column: 1 / -1;
  }
  body.settings-page .settings-section-system .system-groups {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  body.settings-page .settings-section-system .metrics-compact {
    grid-template-columns: 1fr;
  }
}

/* Responsive */
@media (max-width: 768px) {
  h1 { font-size: 17px; line-height: 1; }
  .logo { height: 22px; margin-top: -5px; }
  .back-link { font-size: 13px; padding: 6px 12px; }
  .subtitle { font-size: 16px; }
  .refresh-countdown { font-size: 11px; }
}

@media (max-width: 480px) {
  h1 { font-size: 16px; line-height: 1; }
  .logo { height: 21px; margin-top: -6px; }
  body { padding: 12px; }
  input, select { font-size: 16px; padding: 8px; }
  .section { padding: 16px; margin-bottom: 16px; }
  .section .section { padding: 12px; margin-top: 12px; }
  .row { grid-template-columns: 1fr; gap: 8px; }
  .metric { margin-bottom: 8px; }
  .metric:last-child { margin-bottom: 0; }
  h2 { font-size: 16px; margin-bottom: 12px; }
  h3 { font-size: 13px; margin-bottom: 10px; }
  label { margin: 12px 0 6px; }
  .subtitle { font-size: 14px; }
  .subtitle-row { gap: 8px; }
  .refresh-countdown { font-size: 10px; }
  .loading-text { font-size: 14px; padding: 0 10px; }
}
