/* bit_dog console — light terminal, B&W + PnL color */
:root {
  --bg: #f3f3f1;
  --panel: #ffffff;
  --ink: #111111;
  --muted: #6b6b6b;
  --line: #e4e4e0;
  --line-strong: #d0d0ca;
  --chip: #f0efe9;
  --demo: #efe8d6;
  --demo-ink: #5c5340;
  --live: #1a1a1a;
  --up: #0a7a45;
  --down: #b42318;
  --warn: #8a5a00;
  --radius: 10px;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: "Cascadia Mono", "SF Mono", "Consolas", "Menlo", monospace;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.04), 0 12px 32px rgba(0, 0, 0, 0.04);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #ffffff 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #ebeae4 0%, transparent 50%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

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

#app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.brand img {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: block;
}

.topbar-mid {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.user-name {
  font-size: 13px;
  color: var(--muted);
}

.btn-text {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 6px 4px;
  color: var(--ink);
  font-size: 13px;
}

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

.env-switch {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fafaf8;
}

.env-btn {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.env-btn.is-on {
  background: var(--ink);
  color: #fff;
}

.env-btn.is-on.is-live {
  background: #8b1e1e;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--chip);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.chip.muted {
  color: var(--muted);
  font-weight: 500;
}

.app-body {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0;
  flex: 1;
  min-height: 0;
}

.sidenav {
  padding: 16px 12px 32px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
}

.nav-item {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 2px;
}

.nav-item:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--ink);
  text-decoration: none;
}

.nav-item.is-active {
  background: var(--ink);
  color: #fff;
  font-weight: 600;
}

.main {
  padding: 22px 24px 48px;
  min-width: 0;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.page-head h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.03em;
  font-weight: 750;
}

.page-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 52ch;
}

.banner {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.45;
}

.banner.demo {
  background: var(--demo);
  color: var(--demo-ink);
}

.banner.warn {
  background: #f7e8e6;
  color: #7a241c;
}

.banner.ok {
  background: #e7f4ec;
  color: #1b5c38;
}

.grid {
  display: grid;
  gap: 14px;
}

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

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

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

.stat,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat {
  padding: 16px 18px;
}

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

.stat .value {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.stat .sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.panel {
  padding: 16px 18px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-title h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

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

.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.num.up {
  color: var(--up);
}

.num.down {
  color: var(--down);
}

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

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data th,
table.data td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

table.data th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}

table.data td.wrap {
  white-space: normal;
  min-width: 180px;
  line-height: 1.4;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: var(--chip);
}

.tag.open,
.tag.long {
  background: #e7f4ec;
  color: var(--up);
}

.tag.close,
.tag.short {
  background: #f7e8e6;
  color: var(--down);
}

.tag.flat,
.tag.hold {
  background: #eee;
  color: #444;
}

.tag.pass {
  background: #e7f4ec;
  color: var(--up);
}

.tag.fail {
  background: #f7e8e6;
  color: var(--down);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}

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

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

.btn-primary:hover:not(:disabled) {
  background: #2a2a2a;
}

.btn-ghost {
  background: #fff;
  border-color: var(--line-strong);
}

.btn-ghost:hover:not(:disabled) {
  background: #f7f7f5;
}

.btn-danger {
  background: #8b1e1e;
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #6e1515;
}

.btn-warn {
  background: #8a5a00;
  color: #fff;
}

.field {
  margin-bottom: 14px;
}

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

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.field textarea {
  min-height: 84px;
  resize: vertical;
}

.field-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

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

.check-list {
  display: grid;
  gap: 8px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.check-item input {
  width: 16px;
  height: 16px;
}

.check-item .meta {
  flex: 1;
  min-width: 0;
}

.check-item .meta strong {
  display: block;
  font-size: 14px;
}

.check-item .meta span {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}

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

.preset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: #fff;
  cursor: pointer;
  text-align: left;
}

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

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

.preset p {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  min-height: 2.9em;
}

.preset dl {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  font-size: 12px;
}

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

.preset dd {
  margin: 0;
  font-family: var(--mono);
  text-align: right;
}

.ticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.ticker {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ticker:hover {
  border-color: #bdbdb6;
}

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

.ticker-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.ticker .sym {
  font-size: 13px;
  font-weight: 700;
  word-break: break-all;
}

.ticker .btn-remove {
  flex-shrink: 0;
  color: var(--muted);
  padding: 0;
  font-size: 12px;
}

.search-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  max-height: 320px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.search-row:last-child {
  border-bottom: 0;
}

.search-meta {
  min-width: 0;
}

.search-meta strong {
  display: block;
  font-size: 13px;
  font-family: var(--mono);
}

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

.search-empty {
  padding: 14px 12px;
  font-size: 13px;
  color: var(--muted);
}

.chart-panel {
  margin-top: 14px;
}

.chart-host {
  width: 100%;
  height: 380px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.bar-switch {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fafaf8;
}

.bar-btn {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  font-family: var(--mono);
}

.bar-btn.is-on {
  background: var(--ink);
  color: #fff;
}

.ticker .px {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 650;
}

.ticker .chg {
  margin-top: 6px;
  font-size: 12px;
  font-family: var(--mono);
}

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

.status-dot.off {
  background: var(--muted);
}

.status-dot.warn {
  background: var(--warn);
}

.status-dot.danger {
  background: var(--down);
}

.split {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 14px;
}

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

  .preset-cards,
  .grid-3,
  .split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 800px) {
  .app-body {
    grid-template-columns: 1fr;
  }

  .sidenav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
  }

  .nav-item {
    white-space: nowrap;
    margin-bottom: 0;
  }

  .topbar {
    flex-wrap: wrap;
  }

  .main {
    padding: 16px 14px 40px;
  }

  .grid-4,
  .grid-2 {
    grid-template-columns: 1fr;
  }
}
