:root {
  color-scheme:dark;
  --bg:#10151d;
  --panel:#18212c;
  --line:#2c3b4c;
  --text:#e9eef5;
  --muted:#95a4b6;
  --accent:#74e4bb;
  --red:#ff9b9b;
  --blue:#89b9ff;
  --input:#111923;
  --button:#233244;
  --tabs:#111c26;
  --selected:#294238;
  --soft-line:#293748;
  --running-bg:#193d31;
  font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  font-size:14px;
}

* {
  box-sizing:border-box;
}

body {
  margin:0;
  background:var(--tg-theme-bg-color,var(--bg));
  color:var(--tg-theme-text-color,var(--text));
}

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

button {
  cursor:pointer;
  border:1px solid var(--line);
  background:var(--button);
  color:var(--text);
  border-radius:9px;
  padding:10px 15px;
  font-weight:600;
  white-space:nowrap;
}

button:hover:not(:disabled) {
  border-color:var(--accent);
}

button:disabled {
  opacity:.45;
  cursor:not-allowed;
}

.primary {
  background:var(--accent);
  color:#102b24;
  border-color:transparent;
}

.danger {
  color:var(--red);
}

a {
  color:inherit;
  text-decoration:none;
}

a:hover {
  text-decoration:underline;
}

.shell {
  max-width:1440px;
  margin:auto;
  padding:0 28px;
}

header {
  display:flex;
  justify-content:space-between;
  align-items:center;
  min-height:86px;
  border-bottom:1px solid var(--line);
}

.brand {
  display:flex;
  align-items:center;
  gap:12px;
  font-size:25px;
  color:var(--accent);
  font-weight:700;
}

.brand>span {
  font-size:21px;
  color:var(--text);
}

.network {
  display:block;
  font-size:10px;
  letter-spacing:2px;
  color:var(--muted);
  margin-top:2px;
}

.main-nav {
  padding-top:20px;
  border-bottom:1px solid var(--line);
}

.main-tab {
  display:inline-block;
  padding:0 0 16px;
  border-bottom:2px solid var(--accent);
  font-weight:600;
}

.page-heading {
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin:28px 0 22px;
  gap:20px;
}

h1 {
  font-size:29px;
  letter-spacing:-.6px;
  margin:0 0 7px;
}

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

p {
  color:var(--muted);
  line-height:1.6;
  margin:7px 0 0;
}

.mode-tabs {
  display:flex;
  gap:4px;
  background:var(--tabs);
  border:1px solid var(--line);
  border-radius:12px;
  padding:5px;
  width:max-content;
  margin-bottom:20px;
}

.mode-tabs button {
  border:0;
  background:transparent;
  color:var(--muted);
}

.mode-tabs button.active {
  background:var(--selected);
  color:var(--accent);
}

.panel {
  background:var(--tg-theme-secondary-bg-color,var(--panel));
  border:1px solid var(--line);
  border-radius:14px;
  padding:23px;
  margin:0 0 18px;
}

.run-toolbar {
  display:flex;
  gap:16px;
  align-items:center;
}

.toolbar-actions {
  display:flex;
  gap:9px;
  margin-left:auto;
}

.badge {
  font-size:12px;
  display:inline-flex;
  align-items:center;
  padding:6px 10px;
  border:1px solid var(--line);
  border-radius:7px;
  color:var(--muted);
  white-space:nowrap;
}

.badge.running {
  background:var(--running-bg);
  color:var(--accent);
  border-color:#336650;
}

.badge.failed {
  color:var(--red);
}

label {
  display:flex;
  flex-direction:column;
  gap:7px;
  font-size:12px;
  color:var(--muted);
}

input,select,textarea {
  border:1px solid var(--line);
  border-radius:8px;
  background:var(--input);
  color:var(--text);
  padding:10px 11px;
  min-width:0;
  width:100%;
}

input:focus,select:focus,textarea:focus {
  outline:2px solid #74e4bb55;
  outline-offset:1px;
}

textarea {
  resize:vertical;
  font-family:ui-monospace,monospace;
  font-size:12px;
  line-height:1.7;
}

fieldset {
  padding:0;
  border:0;
  margin:0;
}

fieldset:disabled {
  opacity:.6;
}

.summary-grid {
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:14px;
  margin-bottom:18px;
}

.metric {
  border:1px solid var(--line);
  border-radius:12px;
  background:var(--panel);
  padding:20px;
}

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

.metric-value {
  font-size:26px;
  letter-spacing:-.6px;
  font-weight:650;
}

.metric-note {
  font-size:12px;
  color:var(--muted);
  margin-top:9px;
  line-height:1.5;
}

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

.negative {
  color:var(--red);
}

.muted {
  color:var(--muted);
  font-size:12px;
  line-height:1.6;
}

.section-heading {
  display:flex;
  justify-content:space-between;
  gap:20px;
  align-items:center;
  margin-bottom:20px;
}

.section-heading label {
  min-width:145px;
}

.section-heading p {
  font-size:12px;
}

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

.check-label {
  flex-direction:row;
  align-items:center;
  gap:10px;
  padding:10px 0;
}

.check-label input {
  width:18px;
  height:18px;
}

.form-actions {
  display:flex;
  align-items:center;
  gap:15px;
  margin-top:20px;
}

.funding {
  border-top:1px solid var(--line);
  margin-top:20px;
  padding-top:20px;
}

.funding form {
  display:flex;
  align-items:end;
  gap:12px;
}

.funding label {
  max-width:250px;
  flex:1;
}

.table-controls {
  display:flex;
  align-items:end;
  gap:20px;
  flex-wrap:wrap;
}

.search {
  width:240px;
}

.column-filter {
  display:flex;
  align-items:end;
  gap:8px;
  flex-wrap:wrap;
  flex:1;
}

.column-filter label {
  flex:1;
  min-width:95px;
}

.column-filter label:first-child {
  min-width:145px;
}

.chips {
  display:flex;
  flex-wrap:wrap;
  gap:7px;
  margin:14px 0 5px;
}

.chips button {
  font-size:12px;
  padding:7px 10px;
}

.table-scroll {
  overflow:auto;
  margin-top:15px;
}

table {
  width:100%;
  border-collapse:collapse;
  text-align:left;
  font-size:12px;
}

th {
  font-weight:500;
  color:var(--muted);
  white-space:nowrap;
  border-bottom:1px solid var(--line);
  padding:12px 10px;
}

th button {
  font-size:12px;
  padding:0;
  border:0;
  background:transparent;
  color:var(--muted);
  text-align:left;
}

td {
  border-bottom:1px solid var(--soft-line);
  padding:14px 10px;
  vertical-align:top;
  white-space:nowrap;
}

tbody tr:last-child td {
  border-bottom:0;
}

.address {
  font-family:ui-monospace,monospace;
  font-size:11px;
}

.label-note {
  display:block;
  color:var(--muted);
  font-size:11px;
  margin-top:4px;
  max-width:180px;
  overflow:hidden;
  text-overflow:ellipsis;
}

.table-note {
  margin-top:16px;
}

.empty {
  text-align:center;
  padding:65px 20px;
}

.hidden {
  display:none!important;
}

.notice {
  padding:14px 18px;
  border-radius:10px;
  margin-bottom:18px;
  border:1px solid var(--line);
}

.error {
  color:var(--red);
  line-height:1.6;
}

.pagination {
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:12px;
  margin-top:16px;
  font-size:12px;
  color:var(--muted);
}

.pagination button {
  padding:6px 14px;
}

.chart {
  min-height:220px;
  margin-top:15px;
}

.chart svg {
  width:100%;
  height:auto;
  display:block;
}

.chart text {
  fill:var(--muted);
  font-size:11px;
  font-family:inherit;
}

.chart-empty {
  display:grid;
  place-items:center;
  min-height:220px;
  color:var(--muted);
  font-size:13px;
}

.events {
  display:grid;
  gap:8px;
  max-height:500px;
  overflow:auto;
}

.events details {
  border:1px solid var(--line);
  border-radius:9px;
  padding:11px 13px;
}

.events summary {
  cursor:pointer;
  font-size:12px;
  line-height:1.8;
}

.event-time {
  color:var(--muted);
  margin-right:12px;
}

.details-list {
  display:grid;
  grid-template-columns:auto 1fr;
  gap:7px 16px;
  margin:12px 0 0;
  font-size:11px;
}

.details-list dt {
  color:var(--muted);
}

.details-list dd {
  margin:0;
  white-space:normal;
  overflow-wrap:anywhere;
  font-family:ui-monospace,monospace;
}

dialog {
  color:var(--text);
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:16px;
  padding:25px;
  width:520px;
  max-width:calc(100% - 28px);
  max-height:90vh;
  overflow:auto;
}

dialog::backdrop {
  background:#0009;
  backdrop-filter:blur(3px);
}

dialog form {
  display:grid;
  gap:16px;
}

.dialog-heading {
  display:flex;
  justify-content:space-between;
  align-items:center;
}

.dialog-heading button {
  padding:4px 10px;
  font-size:22px;
}

.dialog-error {
  font-size:12px;
}

.toast {
  position:fixed;
  bottom:25px;
  left:50%;
  transform:translateX(-50%);
  background:var(--selected);
  color:var(--text);
  border:1px solid #447d64;
  border-radius:10px;
  padding:13px 20px;
  max-width:90%;
  z-index:50;
  font-size:13px;
  box-shadow:0 4px 30px #0006;
}

footer {
  padding:15px 0 30px;
  font-size:11px;
  color:var(--muted);
}

details>summary::marker {
  color:var(--muted);
}

@media(max-width:950px) {
  .summary-grid {
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  .form-grid {
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  .edit-hint {
    display:none;
  }
  .table-controls {
    gap:12px;
  }
  .search {
    width:100%;
  }
}

@media(max-width:600px) {
  .shell {
    padding:0 14px;
  }
  header {
    min-height:70px;
  }
  .brand>span {
    font-size:18px;
  }
  .page-heading {
    align-items:flex-start;
    gap:12px;
  }
  h1 {
    font-size:24px;
  }
  .page-heading p {
    font-size:12px;
  }
  .page-heading>button {
    font-size:12px;
    padding:10px;
  }
  .panel {
    padding:16px;
    border-radius:12px;
  }
  .run-toolbar {
    flex-wrap:wrap;
    gap:10px;
  }
  .toolbar-actions {
    width:100%;
    margin-left:0;
  }
  .toolbar-actions button {
    flex:1;
  }
  .summary-grid {
    gap:9px;
  }
  .metric {
    padding:15px;
  }
  .metric-value {
    font-size:23px;
  }
  .form-grid {
    grid-template-columns:1fr;
  }
  .form-actions {
    align-items:start;
    flex-direction:column;
  }
  .section-heading {
    align-items:start;
    gap:12px;
  }
  .section-heading>button {
    font-size:12px;
    padding:8px;
  }
  .column-filter button {
    width:100%;
  }
  .funding form {
    align-items:stretch;
    flex-direction:column;
  }
  .funding label {
    max-width:none;
  }
  .mode-tabs {
    width:100%;
  }
  .mode-tabs button {
    flex:1;
  }
  .details-list {
    grid-template-columns:1fr;
    gap:4px;
  }
  .details-list dd {
    margin-bottom:8px;
  }
}

:root[data-theme="light"] {
  color-scheme:light;
  --bg:#f4f7fa;
  --panel:#fff;
  --line:#d8e1ea;
  --text:#182b3b;
  --muted:#576b7f;
  --accent:#147d59;
  --red:#bd3434;
  --blue:#286dc6;
  --input:#f6f8fb;
  --button:#f0f4f8;
  --tabs:#eaf0f5;
  --selected:#deeee7;
  --soft-line:#e6edf3;
  --running-bg:#e6f4ec;
}

:root[data-theme="light"] .primary {
  color:#fff;
}

:root[data-theme="light"] .badge.running {
  border-color:#bedccc;
}

:root[data-theme="light"] .toast {
  color:var(--text);
}

.runtime-status {
  margin:-5px 0 18px;
  padding:0 5px;
  overflow-wrap:anywhere;
}

/* Helius administration uses the same layout and theme as trading. */
.main-nav { display: flex; gap: 25px; }
button.main-tab { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; color: var(--muted); }
button.main-tab.active { border-bottom-color: var(--accent); color: var(--text); }
#status-section .page-heading { margin-top: 28px; }
.metric-value.unknown { font-size: 18px; }

#account-lock-status { border-color: var(--red); }
#account-lock-status p { font-size: 12px; }

@media (max-width: 600px) {
  .main-nav { gap: 12px; }
  button.main-tab { font-size: 13px; }
}

.account-heading { flex: 1; min-width: 150px; }
.account-heading p { font-size: 12px; }
.account-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.account-charts .panel { min-width: 0; }
.account-charts .section-heading { min-height: 62px; align-items: flex-start; gap: 12px; }
.account-charts .section-heading > .muted { white-space: nowrap; }
@media (max-width: 850px) { .account-charts { grid-template-columns: 1fr; gap: 0; } }
@media (max-width: 600px) { .account-charts .section-heading > .muted { white-space: normal; max-width: 80px; } }
