:root {
  --bg: #0b0e11;
  --card: #181a20;
  --card-2: #22262f;
  --border: #2b3139;
  --text: #eaecef;
  --muted: #848e9c;
  --gold: #f0b90b;
  --green: #0ecb81;
  --red: #f6465d;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Helvetica Neue", sans-serif;
  font-size: 14px; line-height: 1.45;
}

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--card); border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.logo-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); display: inline-block; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.main {
  max-width: 640px; margin: 0 auto;
  padding: 12px 12px calc(76px + env(safe-area-inset-bottom));
}

.tab-view { display: none; }
.tab-view.active { display: block; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; margin-bottom: 12px;
}

.warn-card { border-color: var(--gold); }
.card-title { font-weight: 600; font-size: 15px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.list-stack { display: flex; flex-direction: column; gap: 8px; }
.section { margin-top: 14px; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 600; }

.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.row-gap { display: flex; gap: 8px; align-items: center; }
.btn-row { display: flex; gap: 8px; }
.btn-row > .btn { flex: 1; }

.big-num { font-size: 26px; font-weight: 700; margin: 6px 0; font-variant-numeric: tabular-nums; }
.stat-val { font-size: 18px; font-weight: 700; margin: 4px 0; font-variant-numeric: tabular-nums; }
.strong-txt { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sub-metrics { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; flex-wrap: wrap; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.hidden { display: none !important; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 600;
}
.badge-muted { background: var(--card-2); color: var(--muted); }
.badge-ok { background: rgba(14, 203, 129, 0.16); color: var(--green); }
.badge-warn { background: rgba(240, 185, 11, 0.18); color: var(--gold); }
.badge-danger { background: rgba(246, 70, 93, 0.18); color: var(--red); }

.btn {
  height: 42px; border: none; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 14px;
}
.btn-sm { height: 34px; font-size: 12px; padding: 0 10px; border-radius: 8px; }
.btn-primary { background: var(--gold); color: #0b0e11; }
.btn-secondary { background: var(--card-2); color: var(--text); border: 1px solid var(--border); }
.btn-long { background: var(--green); color: #0b0e11; }
.btn-short { background: var(--red); color: #fff; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card-2); color: var(--text); font-size: 16px; cursor: pointer;
}
.btn-kill {
  height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid rgba(246, 70, 93, 0.5);
  background: rgba(246, 70, 93, 0.14); color: var(--red); font-weight: 600; font-size: 12px; cursor: pointer;
}
.btn-kill.active { background: var(--red); color: #fff; }

.seg {
  display: flex; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 3px; gap: 4px;
}
.seg-btn {
  flex: 1; height: 34px; border: none; border-radius: 8px;
  background: transparent; color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer;
}
.seg-btn.active { background: var(--card-2); color: var(--text); }
.seg-btn.active-long { background: rgba(14, 203, 129, 0.2); color: var(--green); }
.seg-btn.active-short { background: rgba(246, 70, 93, 0.2); color: var(--red); }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
input, select {
  width: 100%; height: 42px; padding: 0 12px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; font-size: 14px; outline: none;
}
input:focus, select:focus { border-color: var(--gold); }

.switch-row { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.switch-row input { width: 16px; height: 16px; }

.toolbar { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; }
.toolbar select { flex: 1; height: 36px; font-size: 13px; }

.preview-box {
  margin-top: 10px; padding: 10px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--border);
  font-size: 12px; white-space: pre-wrap; word-break: break-word;
}

.item-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px;
}

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  height: 56px; border: none; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11px; cursor: pointer;
}
.nav-btn.active { color: var(--gold); font-weight: 600; }
.nav-ico { font-size: 17px; line-height: 1; }

.toast {
  position: fixed; left: 50%; bottom: calc(74px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 50;
  background: #2b3139; color: var(--text); padding: 10px 16px;
  border-radius: 99px; font-size: 13px; box-shadow: 0 6px 24px rgba(0,0,0,0.45);
  max-width: 90vw; text-align: center;
}
code { background: var(--card-2); padding: 1px 5px; border-radius: 4px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip {
  padding: 4px 8px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg); color: var(--muted); font-size: 11px; cursor: pointer;
}
.chip:active { border-color: var(--gold); color: var(--gold); }
