:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f0f3f8;
  --text: #131a25;
  --muted: #5b6676;
  --line: #dfe4ec;
  --accent: #1f5fe0;
  --accent-hover: #184fc0;
  --accent-text: #ffffff;
  --accent-soft: #e8effd;
  --ok: #17794a;
  --ok-soft: #e3f4ea;
  --warn: #8a5300;
  --warn-soft: #fbefd9;
  --err: #b3261e;
  --err-soft: #fbe9e7;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 4px 16px rgb(16 24 40 / 5%);
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1218;
    --surface: #171c25;
    --surface-2: #1e2430;
    --text: #e8ecf3;
    --muted: #9aa5b5;
    --line: #2a3242;
    --accent: #7aa5ff;
    --accent-hover: #96b8ff;
    --accent-text: #0b1220;
    --accent-soft: #1c2a47;
    --ok: #5fd39a;
    --ok-soft: #153023;
    --warn: #f0b860;
    --warn-soft: #33270f;
    --err: #ff8a80;
    --err-soft: #3a1b19;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

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

a {
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px 64px;
}

/* ---- Top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.brand img {
  width: 30px;
  height: 30px;
}

.who {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--muted);
  font-size: 14px;
}

.who span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-2);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn.big {
  min-height: 48px;
  padding: 0 22px;
  font-size: 16px;
}

.btn.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
  border-radius: 8px;
}

.btn.danger {
  color: var(--err);
}

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

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

.link:hover {
  text-decoration: underline;
}

.link:disabled {
  color: var(--muted);
  cursor: default;
  text-decoration: none;
}

/* ---- Sign in ---- */
.auth {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px 16px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 32px 28px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin-top: 22px;
  font-size: 24px;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.auth-card .lede {
  margin-top: 6px;
  color: var(--muted);
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 22px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-2);
}

.tabs button {
  min-height: 36px;
  border: 0;
  border-radius: 9px;
  background: none;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.tabs button[aria-selected='true'] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.field {
  display: block;
  margin-top: 16px;
}

.field span {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
}

.input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.input.code {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.4em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.auth-card .btn.primary {
  width: 100%;
  margin-top: 20px;
}

.auth-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  font-size: 14px;
}

.form-error {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--err-soft);
  color: var(--err);
  font-size: 14px;
}

/* ---- Panes ---- */
.intro {
  margin: 8px 0 20px;
}

.intro h1 {
  font-size: 26px;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.intro p {
  margin-top: 4px;
  color: var(--muted);
}

.panes {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.swap {
  align-self: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
}

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.pane-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.mark {
  flex: none;
  width: 36px;
  height: 36px;
}

.pane-title {
  min-width: 0;
  flex: 1;
}

.pane-title small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pane-title strong {
  display: block;
  font-size: 16px;
}

.pane-title em {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connect {
  display: grid;
  gap: 12px;
  justify-items: center;
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.select {
  min-height: 34px;
  max-width: 100%;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1;
  font-size: 14px;
}

.crumbs button {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crumbs .here {
  font-weight: 700;
}

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

.list {
  height: 340px;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  list-style: none;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 2px 10px;
  border-radius: 8px;
}

.row:hover {
  background: var(--surface-2);
}

.row.all {
  margin-bottom: 4px;
  background: var(--accent-soft);
  font-weight: 600;
}

.row input[type='checkbox'] {
  flex: none;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.row svg {
  flex: none;
  width: 20px;
  height: 20px;
}

.row .name {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button.name {
  padding: 8px 0;
  border: 0;
  background: none;
  cursor: pointer;
}

button.name:hover {
  color: var(--accent);
}

.row .meta {
  flex: none;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.row.dim .name {
  color: var(--muted);
}

.empty {
  display: grid;
  height: 100%;
  place-items: center;
  padding: 20px;
  color: var(--muted);
  text-align: center;
}

.pane-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.pane-foot b {
  color: var(--text);
}

.pane-foot span {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ---- Start bar ---- */
.startbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.startbar .summary {
  min-width: 0;
  flex: 1 1 280px;
}

.startbar .summary p {
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* ---- Transfers ---- */
.section-title {
  margin: 34px 0 12px;
  font-size: 18px;
}

.job {
  margin-bottom: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.job-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.job-top h3 {
  font-size: 16px;
}

.job-top p {
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.chip {
  flex: none;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.chip.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.chip.run {
  background: var(--accent-soft);
  color: var(--accent);
}

.chip.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.chip.err {
  background: var(--err-soft);
  color: var(--err);
}

.bar {
  height: 8px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.bar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.4s ease;
}

.bar.busy i {
  width: 30%;
  animation: slide 1.4s ease-in-out infinite;
}

@keyframes slide {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(340%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bar.busy i {
    animation: none;
    width: 100%;
    opacity: 0.4;
  }
  .bar i {
    transition: none;
  }
}

.job-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.job-stats .bad {
  color: var(--err);
}

.job-error {
  margin-top: 10px;
  color: var(--err);
  font-size: 14px;
}

.job-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.issues {
  max-height: 260px;
  margin: 12px 0 0;
  padding: 0;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  list-style: none;
  font-size: 13px;
}

.issues li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2px 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}

.issues li:last-child {
  border-bottom: 0;
}

.issues .path {
  overflow-wrap: anywhere;
  font-weight: 600;
}

.issues .why {
  grid-column: 2;
  color: var(--muted);
}

.none {
  padding: 28px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.foot {
  margin-top: 40px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* ---- Toast ---- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  box-shadow: 0 8px 30px rgb(0 0 0 / 25%);
  transform: translateX(-50%);
}

#toast.err {
  background: var(--err);
  color: #fff;
}

@media (max-width: 800px) {
  .panes {
    grid-template-columns: minmax(0, 1fr);
  }
  .swap {
    justify-self: center;
    transform: rotate(90deg);
  }
  .list {
    height: 280px;
  }
  .startbar .btn.big {
    width: 100%;
  }
}
