.brand-link {
  color: inherit;
  text-decoration: none;
}

.admin-controls {
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.admin-controls select,
.call-filter input,
.token-panel input {
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font: inherit;
}

.token-panel {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

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

.small {
  font-size: 0.78rem;
  margin: 0;
}

.warn-banner {
  margin: 0 0 1rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid color-mix(in srgb, var(--warn) 50%, var(--line));
  border-radius: 10px;
  color: var(--warn);
  font-size: 0.85rem;
}

.shell > section {
  margin-bottom: 1rem;
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.sys-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.6rem 1rem;
  margin: 0;
}

.sys-grid dt {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sys-grid dd {
  margin: 0.15rem 0 0;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.tz-form {
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin: 1rem 0 0.4rem;
}

.tz-form input {
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font: inherit;
  min-width: 16rem;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.75rem;
}

.kpi {
  background: color-mix(in srgb, var(--bg1) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
}

.kpi .label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.kpi .value {
  font-size: 1.5rem;
  font-weight: 650;
  margin-top: 0.2rem;
  font-variant-numeric: tabular-nums;
}

.kpi .sub {
  font-size: 0.75rem;
  color: var(--muted);
}

.kpi.bad .value {
  color: var(--sell);
}

.grid-2,
.grid-3 {
  display: grid;
  gap: 1rem;
}

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

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

.bar-row {
  display: grid;
  grid-template-columns: minmax(6rem, 40%) 1fr auto;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.82rem;
  margin-bottom: 0.4rem;
}

.bar-row .name {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 8px;
  background: var(--bg2);
  border-radius: 999px;
  overflow: hidden;
  display: flex;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
}

.bar-fill.no {
  background: var(--sell);
}

.bar-fill.unsettled {
  background: var(--hold);
}

.bar-row .num {
  font-variant-numeric: tabular-nums;
  min-width: 2.5rem;
  text-align: right;
}

.legend {
  display: flex;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

.dot {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  margin-right: 0.3rem;
  vertical-align: middle;
}

.sub-h {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0.8rem 0 0.4rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.admin-table th {
  color: var(--muted);
  font-weight: 600;
}

.admin-table td.wrap {
  white-space: normal;
  max-width: 28rem;
  overflow-wrap: anywhere;
}

.admin-table tbody tr.click {
  cursor: pointer;
}

.admin-table tbody tr.click:hover {
  background: var(--bg2);
}

.pill {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid var(--line);
}

.pill.BUY,
.pill.ok,
.pill.yes,
.pill.cached,
.pill.fetched {
  color: var(--accent);
}

.pill.SELL,
.pill.err,
.pill.no,
.pill.error {
  color: var(--sell);
}

.pill.HOLD,
.pill.unsettled {
  color: var(--hold);
}

.pill.fallback {
  color: var(--warn);
}

.suggestions {
  margin: 0 0 1rem;
  padding-left: 1.1rem;
  font-size: 0.85rem;
  line-height: 1.45;
}

.suggestions li.warn {
  color: var(--warn);
}

.suggestions li.info {
  color: var(--ink);
}

.r-pos {
  color: var(--accent);
}

.r-neg {
  color: var(--sell);
}

#paper-groupby {
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 0.4rem 0.55rem;
  font: inherit;
}

.pill.won {
  color: var(--accent);
}

.pill.lost {
  color: var(--sell);
}

.pill.open {
  color: var(--warn);
}

.pill.pending,
.pill.expired,
.pill.cancelled,
.pill.closed {
  color: var(--hold);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.6rem;
  font-size: 0.78rem;
  color: var(--muted);
  flex-wrap: wrap;
}

.pager button {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
}

.pager button:disabled {
  opacity: 0.4;
  cursor: default;
}

.call-filter select {
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font: inherit;
}

.bt-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 0.9rem;
  align-items: flex-end;
  margin-bottom: 0.6rem;
}

.bt-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.bt-form label.check {
  flex-direction: row;
  align-items: center;
}

.bt-form input:not([type="checkbox"]),
.bt-form select {
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font: inherit;
  font-size: 0.85rem;
  width: 8.5rem;
  max-width: 100%;
}

.bt-whatif {
  font-size: 0.8rem;
  color: var(--muted);
}

.bt-whatif[open] {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: flex-end;
}

.bt-whatif summary {
  cursor: pointer;
  width: 100%;
}

.bt-buttons {
  display: flex;
  gap: 0.5rem;
}

.jobs-note {
  margin: -0.4rem 0 0.6rem;
}

.job-actions {
  display: flex;
  gap: 0.35rem;
}

.job-actions button {
  font-size: 0.72rem;
  padding: 0.25rem 0.55rem;
}

.log-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.log-head h2 {
  margin: 0;
}

.call-filter {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.more {
  margin-top: 0.75rem;
}

.empty {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}

.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(760px, 100%);
  background: var(--bg1);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.45);
  overflow-y: auto;
  padding: 1.1rem 1.2rem 2rem;
  z-index: 10;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.drawer-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.drawer h3 {
  font-size: 0.85rem;
  margin: 1.1rem 0 0.4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.json {
  background: var(--bg0);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
  max-height: 26rem;
  overflow: auto;
}

.copy {
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
}

.question {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.82rem;
}

.question .q-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.3rem;
}

.question .crit {
  color: var(--muted);
  margin: 0.2rem 0 0;
}

@media (max-width: 900px) {
  .grid-3 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 700px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

.backup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 1rem;
}

.backup-box {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 0;
}

.backup-box .sub-h {
  margin-top: 0;
}

.backup-sections {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.35rem 1rem;
}

.backup-sections label.check {
  display: flex;
  font-size: 0.88rem;
}

.backup-sections label.check.unavailable {
  color: var(--muted);
}

.backup-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

#import-file {
  color: var(--ink);
  max-width: 100%;
}

button.danger {
  background: var(--sell);
  color: #2a0808;
}

.backup-report td.num {
  text-align: right;
}
