/* The market proxy's console: a quiet workspace, the same tokens as the backtest console. */

@font-face {
  font-family: "Vazirmatn";
  src: url("Vazirmatn-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f4f6f9;
  --panel: #fff;
  --line: #e6e9ef;
  --ink: #1b1f27;
  --muted: #6b7280;
  --soft: #f7f8fa;
  --blue: #2563eb;
  --blue-bg: #eaf1ff;
  --green: #12a150;
  --green-bg: #e7f6ee;
  --amber: #b76e00;
  --amber-bg: #fff4e0;
  --red: #d92d20;
  --red-bg: #fdecea;
  --gray-bg: #eef0f3;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 "Vazirmatn", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

code,
.ltr {
  direction: ltr;
  unicode-bidi: isolate;
}

code {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--soft);
  font-size: 12px;
}

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

.small {
  font-size: 12px;
}

.num {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.pos {
  color: var(--green);
}

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

.warn {
  color: var(--amber);
}

.noscript {
  padding: 40px;
  text-align: center;
}

/* ------------------------------------------------------------------ layout */

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 92%);
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

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

.chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

.tabs {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
}

.tab {
  padding: 7px 14px;
  border-radius: 9px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.tab:hover {
  background: var(--soft);
  color: var(--ink);
}

.tab.is-active {
  background: var(--ink);
  color: #fff;
}

.user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-inline-end: 6px;
  border-radius: 50%;
  background: var(--green);
}

main {
  display: grid;
  gap: 16px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 24px 48px;
}

.panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

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

.panel-head p {
  margin: 2px 0 0;
}

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

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

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

/* ------------------------------------------------------------------ tiles */

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

@media (max-width: 900px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.stat {
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

.stat-value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

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

.stat--green .stat-value {
  color: var(--green);
}

.stat--amber .stat-value {
  color: var(--amber);
}

.stat--gray .stat-value {
  color: var(--muted);
}

/* ------------------------------------------------------------------ buttons and inputs */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--soft);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

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

.btn--primary {
  background: var(--ink);
  color: #fff;
}

.btn--ghost {
  border-color: var(--line);
  background: var(--panel);
}

.btn--danger {
  background: var(--red);
  color: #fff;
}

.btn--sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--blue);
  cursor: pointer;
}

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

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

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

.input,
.field input,
.field textarea,
.field select,
.select {
  width: 100%;
  min-height: 38px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  outline: none;
}

.input:focus,
.field input:focus,
.field textarea:focus,
.select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-bg);
}

.field textarea {
  resize: vertical;
}

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

.switch {
  position: relative;
  display: inline-flex;
  width: 38px;
  height: 22px;
}

.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.switch-track {
  width: 100%;
  border-radius: 999px;
  background: #cfd5de;
  transition: background 0.15s;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
}

.switch input:checked + .switch-track {
  background: var(--green);
}

.switch input:checked + .switch-track::after {
  transform: translateX(-16px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ banners and badges */

.banner,
.error {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 14px;
  border-radius: 10px;
}

.error,
.banner--red {
  background: var(--red-bg);
  color: var(--red);
}

.banner--amber {
  background: var(--amber-bg);
  color: var(--amber);
}

.banner--green {
  background: var(--green-bg);
  color: var(--green);
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge--green {
  background: var(--green-bg);
  color: var(--green);
}

.badge--amber {
  background: var(--amber-bg);
  color: var(--amber);
}

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

.badge--gray {
  background: var(--gray-bg);
  color: var(--muted);
}

.badge--blue {
  background: var(--blue-bg);
  color: var(--blue);
}

.tag {
  display: inline-flex;
  margin-inline-start: 6px;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

/* ------------------------------------------------------------------ mode cards and segments */

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

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

.mode {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  text-align: start;
  cursor: pointer;
}

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

.mode.is-active {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 14px;
}

.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: var(--soft);
}

.seg button {
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}

.seg button.is-active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

/* ------------------------------------------------------------------ table */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: start;
  white-space: nowrap;
}

td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tr.is-off td {
  color: var(--muted);
}

.name {
  display: grid;
}

.name strong {
  font-weight: 600;
}

.sub {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

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

/* ------------------------------------------------------------------ chart and log */

.bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 140px;
  padding-top: 8px;
}

.bar {
  display: flex;
  flex: 1;
  align-items: flex-end;
  height: 100%;
}

.bar-stack {
  display: flex;
  flex-direction: column-reverse;
  width: 100%;
  min-height: 2px;
  overflow: hidden;
  border-radius: 4px 4px 0 0;
  background: var(--gray-bg);
}

.bar-ok {
  background: var(--green);
}

.bar-fail {
  background: var(--red);
}

.log {
  display: grid;
  max-height: 360px;
  overflow-y: auto;
  font-size: 12px;
}

.log-row {
  display: grid;
  grid-template-columns: 70px 110px minmax(0, 1fr) 90px 70px;
  gap: 8px;
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
}

.log-row.is-fail {
  background: var(--red-bg);
}

.log-row > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.facts {
  display: grid;
  gap: 0;
  margin: 0;
}

.facts > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}

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

.facts dd {
  margin: 0;
  font-weight: 600;
  text-align: end;
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------ settings */

.setting {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.setting-text {
  display: grid;
}

.setting-input {
  display: flex;
  align-items: center;
  gap: 10px;
}

.setting-input .input {
  width: 120px;
}

/* ------------------------------------------------------------------ dialogs and sign-in */

dialog {
  width: min(560px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgb(16 24 40 / 25%);
}

dialog::backdrop {
  background: rgb(16 24 40 / 45%);
}

.dialog {
  display: grid;
  gap: 14px;
  padding: 20px;
}

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

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.login {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 16px;
}

.login form {
  display: grid;
  gap: 14px;
  width: min(380px, 100%);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login h1 {
  margin: 0;
  font-size: 18px;
}

@media (max-width: 640px) {
  .top,
  main {
    padding-inline: 16px;
  }

  .row {
    grid-template-columns: 1fr;
  }

  .log-row {
    grid-template-columns: 60px 80px minmax(0, 1fr) 60px;
  }

  .log-row > span:last-child {
    display: none;
  }
}
