:root {
  --bg: #f5f1e9;
  --bg-accent: #efe5d1;
  --card: rgba(255, 252, 246, 0.96);
  --line: #d7cbbb;
  --line-strong: #bdaa90;
  --ink: #1f2632;
  --ink-muted: #5d6776;
  --brand: #0b6a67;
  --brand-strong: #074a48;
  --warn: #a56712;
  --danger: #8f2332;
  --ok: #1e6a39;
  --radius: 16px;
  --shadow: 0 12px 34px rgba(31, 38, 50, 0.08);
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  --sans: "Avenir Next", "Segoe UI Variable", "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(11, 106, 103, 0.08), transparent 40%),
    radial-gradient(circle at 82% 14%, rgba(165, 103, 18, 0.08), transparent 38%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-accent) 100%);
}

.app-shell {
  width: min(1460px, 100%);
  margin: 0 auto;
  padding: 20px 20px 28px;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 6px 0 4px;
  font-size: clamp(30px, 3vw, 40px);
  line-height: 1.05;
}

.subtitle {
  margin: 0;
  color: var(--ink-muted);
}

.status-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.notification-tray {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 20;
  display: grid;
  gap: 8px;
  width: min(420px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-left: 6px solid var(--brand);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 252, 246, 0.98);
  box-shadow: var(--shadow);
  pointer-events: auto;
}

.toast-neutral {
  border-left-color: var(--brand);
}

.toast-success {
  border-left-color: var(--ok);
}

.toast-success .toast-kind {
  color: var(--ok);
}

.toast-error {
  border-left-color: var(--danger);
}

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

.toast-win {
  border-left-color: var(--brand);
}

.toast-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
  font-size: 12px;
}

.toast-kind {
  color: var(--brand-strong);
  font-weight: 700;
}

.toast-time {
  color: var(--ink-muted);
  font-family: var(--mono);
}

.toast-body {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.4;
}

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.86);
  font-size: 12px;
}

.chip-offline { color: var(--danger); border-color: rgba(143, 35, 50, 0.26); }
.chip-online { color: var(--ok); border-color: rgba(30, 106, 57, 0.26); }
.chip-warn { color: var(--warn); border-color: rgba(165, 103, 18, 0.28); }
.chip-muted { color: var(--ink-muted); }

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,255,255,0.92), var(--card));
  box-shadow: var(--shadow);
  padding: 14px;
}

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

.panel-head h2 {
  margin: 0;
  font-size: 18px;
}

.panel-head > div {
  display: grid;
  gap: 2px;
}

.meta-text {
  color: var(--ink-muted);
  font-size: 12px;
}

.setup-panel { margin-bottom: 16px; }

.setup-grid {
  display: grid;
  grid-template-columns: 1.2fr 1.7fr auto;
  gap: 12px;
  align-items: end;
}

.gateway-field {
  align-self: stretch;
}

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

.layout {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 14px;
}

.panel-summary,
.panel-guide,
.panel-onboarding,
.panel-growth,
.panel-miners,
.panel-market,
 .panel-results,
.panel-log {
  grid-column: 1 / -1;
}

.panel-summary { display: grid; gap: 12px; }

.guide-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.guide-intro {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid rgba(11, 106, 103, 0.16);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(11, 106, 103, 0.06), rgba(255, 255, 255, 0.82));
}

.guide-intro h3 {
  margin: 0;
  font-size: 16px;
}

.guide-intro-copy {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

.guide-loop {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.guide-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(11, 106, 103, 0.18);
  background: rgba(255, 255, 255, 0.86);
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 700;
}

.next-action-card {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid rgba(11, 106, 103, 0.22);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(11, 106, 103, 0.12), rgba(255, 255, 255, 0.88)),
    rgba(255,255,255,0.78);
  box-shadow: 0 14px 30px rgba(43, 37, 29, 0.07);
}

.next-action-meta {
  color: var(--brand-strong);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.next-action-title {
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.15;
}

.next-action-text,
.next-action-result {
  margin: 0;
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.45;
}

.next-action-result {
  color: var(--ink);
}

.guide-step {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255,255,255,0.76);
  display: grid;
  gap: 8px;
}

.guide-step.current {
  border-color: var(--brand);
  box-shadow: inset 0 0 0 1px rgba(11, 106, 103, 0.15);
}

.guide-step.done {
  border-color: rgba(30, 106, 57, 0.24);
}

.guide-step.locked {
  opacity: 0.72;
}

.guide-step.optional {
  opacity: 0.9;
}

.guide-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}

.guide-title,
.card-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.guide-step h3 {
  margin: 0;
  font-size: 14px;
}

.guide-step p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1.45;
}

.guide-step .guide-status {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.guide-step.done .guide-status {
  color: var(--ok);
}

.guide-step.current .guide-status {
  color: var(--brand);
}

.guide-step.locked .guide-status {
  color: var(--warn);
}

.guide-step.optional .guide-status {
  color: var(--ink-muted);
}

.guide-jump-btn {
  justify-self: start;
}

.advanced-actions-hint {
  margin-top: -4px;
  margin-bottom: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

[hidden] {
  display: none !important;
}

.field span {
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 600;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.92);
  color: var(--ink);
  font: inherit;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: 2px solid rgba(11, 106, 103, 0.16);
  border-color: var(--brand);
}

.btn {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  padding: 9px 12px;
  border-radius: 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  border-color: var(--brand);
  color: var(--brand-strong);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #f8fdfd;
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  color: #fff;
}

.btn-danger {
  color: var(--danger);
  border-color: rgba(143, 35, 50, 0.26);
}

.btn-small {
  padding: 5px 10px;
  font-size: 12px;
}

.button-stack,
.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.button-stack {
  align-items: end;
}

.button-row {
  align-items: center;
}

.gateway-presets {
  margin-top: 2px;
}

.gateway-preset-active {
  background: rgba(11, 106, 103, 0.12);
  border-color: var(--brand);
  color: var(--brand-strong);
}

.gateway-advanced-panel {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.remembered-strip {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.remember-hint {
  margin-top: 0;
}

.remembered-accounts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.remembered-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 8px 6px 10px;
  background: rgba(255,255,255,0.82);
  font-size: 12px;
}

.remembered-chip button {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--brand-strong);
  border-radius: 999px;
  padding: 4px 8px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.remembered-chip button:hover {
  border-color: var(--brand);
}

.remembered-chip .remembered-state {
  color: var(--ink-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hint {
  margin: 8px 0 0;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1.4;
}

code {
  font-family: var(--mono);
  background: rgba(11, 106, 103, 0.08);
  border-radius: 4px;
  padding: 1px 4px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.quick-stats {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.account-details-panel {
  display: grid;
  gap: 12px;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255,255,255,0.76);
}

.stat-label {
  color: var(--ink-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}

.note-stack {
  display: grid;
  gap: 8px;
}

.state-notes {
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.42);
  padding: 10px;
}

.state-notes summary {
  cursor: pointer;
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 700;
}

.state-notes[open] summary {
  margin-bottom: 10px;
  color: var(--ink);
}

.note {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 10px;
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.45;
  background: rgba(255,255,255,0.45);
}

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

.action-grid-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.starter-archive {
  margin-bottom: 12px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.48);
  padding: 10px;
}

.starter-archive summary {
  cursor: pointer;
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 800;
}

.starter-archive[open] summary {
  margin-bottom: 10px;
  color: var(--ink);
}

.starter-archive-list {
  display: grid;
  gap: 8px;
}

.starter-archive-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(30, 106, 57, 0.16);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.68);
  color: var(--ink-muted);
  font-size: 12px;
}

.starter-archive-item strong {
  color: var(--ink);
  font-weight: 700;
  text-align: right;
}

.action-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255,255,255,0.76);
  display: grid;
  gap: 10px;
  position: relative;
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.action-card.locked-once,
.action-card.completed-once {
  overflow: hidden;
}

.action-card.locked-once::after,
.action-card.completed-once::after {
  content: attr(data-card-state-message);
  position: absolute;
  inset: auto 10px 10px 10px;
  border: 1px solid rgba(165, 103, 18, 0.24);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(255, 252, 246, 0.94);
  color: var(--warn);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  pointer-events: none;
}

.action-card.completed-once::after {
  border-color: rgba(30, 106, 57, 0.22);
  color: var(--ok);
}

.action-card.locked-once,
.action-card.completed-once {
  padding-bottom: 54px;
}

.action-card.locked-once .btn-primary:disabled,
.action-card.completed-once .btn-primary:disabled {
  display: none;
}

.guide-target-highlight {
  border-color: var(--brand) !important;
  box-shadow:
    0 0 0 2px rgba(11, 106, 103, 0.2),
    0 18px 40px rgba(11, 106, 103, 0.12);
  background: linear-gradient(180deg, rgba(11, 106, 103, 0.08), rgba(255,255,255,0.9));
}

.action-card h3 {
  margin: 0;
  font-size: 15px;
}

.detail-stack {
  display: grid;
  gap: 8px;
}

.detail-card {
  border: 1px solid rgba(215, 203, 187, 0.9);
  border-radius: 10px;
  background: rgba(245, 241, 233, 0.5);
  padding: 10px;
}

.detail-grid {
  display: grid;
  gap: 8px;
}

.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.detail-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 600;
}

.detail-value {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  text-align: right;
  word-break: break-word;
}

.detail-footnote {
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1.45;
}

.detail-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(215, 203, 187, 0.9);
}

.detail-section-title {
  margin-bottom: 8px;
}

.team-count-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.team-count-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(215, 203, 187, 0.9);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.62);
}

.team-count-team {
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 600;
}

.team-count-value {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
}

.profile-list {
  display: grid;
  gap: 8px;
}

.profile-item {
  border: 1px solid rgba(215, 203, 187, 0.9);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.62);
}

.profile-name {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}

.profile-text {
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1.45;
}

.detail-empty {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 10px;
  color: var(--ink-muted);
  font-size: 12px;
  text-align: center;
}

.info-popover {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

.info-trigger {
  width: 20px;
  height: 20px;
  border: 1px solid rgba(11, 106, 103, 0.32);
  border-radius: 999px;
  padding: 0;
  background: rgba(11, 106, 103, 0.08);
  color: var(--brand-strong);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.info-trigger:hover,
.info-trigger:focus-visible,
.info-popover.open .info-trigger {
  border-color: var(--brand);
  background: rgba(11, 106, 103, 0.14);
  outline: none;
}

.info-bubble {
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  z-index: 3;
  width: min(280px, calc(100vw - 48px));
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(31, 38, 50, 0.96);
  color: #f9f7f1;
  box-shadow: 0 10px 24px rgba(31, 38, 50, 0.18);
  font-size: 12px;
  line-height: 1.45;
  transform: translateX(-50%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.info-bubble::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% - 1px);
  width: 10px;
  height: 10px;
  border-left: 1px solid var(--line-strong);
  border-top: 1px solid var(--line-strong);
  background: rgba(31, 38, 50, 0.96);
  transform: translateX(-50%) rotate(45deg);
}

.info-popover.open .info-bubble,
.info-popover:focus-within .info-bubble {
  opacity: 1;
  visibility: visible;
}

@media (hover: hover) and (pointer: fine) {
  .info-popover:hover .info-bubble {
    opacity: 1;
    visibility: visible;
  }
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.toolbar-field {
  min-width: 180px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.72);
}

.table-wrap-compact {
  max-height: 520px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table th,
.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(215, 203, 187, 0.72);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  background: rgba(245, 241, 233, 0.95);
  color: var(--ink-muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
}

.data-table td:nth-child(5),
.data-table td:nth-child(6) {
  font-family: var(--mono);
}

.muted-cell {
  color: var(--ink-muted);
  text-align: center;
}

.muted-cell-guide {
  padding: 18px 12px;
  line-height: 1.45;
}

.empty-state {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.42);
  color: var(--ink-muted);
  text-align: center;
  padding: 10px;
}

.log-list {
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow: auto;
}

.log-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,0.72);
  padding: 8px 10px;
  display: grid;
  gap: 4px;
}

.log-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}

.log-type { font-weight: 700; }
.log-time { color: var(--ink-muted); font-family: var(--mono); }
.log-text { color: var(--ink-muted); font-size: 12px; word-break: break-word; }

.receipt-status {
  font-weight: 700;
}

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

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

@media (max-width: 1080px) {
  .setup-grid,
  .layout,
  .guide-grid,
  .action-grid,
  .action-grid-three {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-shell { padding: 12px; }
  .hero { flex-direction: column; }
  .status-row { justify-content: flex-start; }
  .stats-grid { grid-template-columns: 1fr; }
  .button-stack,
  .button-row { flex-direction: column; }
  .btn { width: 100%; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .notification-tray {
    top: 10px;
    right: 10px;
    width: calc(100vw - 20px);
  }
  .team-count-grid {
    grid-template-columns: 1fr;
  }
}
