:root {
  --bg-surface: #ffffff;
  --bg-structure: #f0efed;
  --bg-workspace: #f0efed;
  --bg-stripe: #f5f4f3;
  --bg-heading: #e4e1df;
  --bg-hover: #e5f1fb;
  --bg-selected: #cfe5f7;
  --bg-structure-selected: #b5d5f1;
  --bg-structure-hover: #e4e1df;
  --bg-pressed: #e4e1df;
  --bg-accent: #2b579a;
  --bg-accent-hover: #1c3c6a;
  --bg-danger-subtle: #fdeaeb;
  --text: #201f1e;
  --text-muted: #5a5856;
  --text-empty: #9b9997;
  --text-accent: #2b579a;
  --text-success: #166b15;
  --text-warning: #9a3f00;
  --text-danger: #a80101;
  --border-divider: #c7c5c3;
  --border-grid: #dbd9d7;
  --border-field: #acaaa8;
  --border-field-hover: #3e3c3b;
  --border-button: #acaaa8;
  --border-button-hover: #1671c8;
  --border-hover: #a2cbf0;
  --border-focus: #1671c8;
  --border-accent: #2b579a;
  --titlebar: #1c1a14;
  --titlebar-hover: #3a362b;
  --titlebar-text: #ffffff;
  --titlebar-muted: #bdb7a6;
  --titlebar-border: #4d483a;
  --titlebar-success: #4eb34a;
  --titlebar-warning: #ffb37d;
}

* {
  box-sizing: border-box;
}

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

body {
  display: flex;
  flex-direction: column;
  background: var(--bg-workspace);
  color: var(--text);
  font: 400 13px/1.35 "Pretendard Variable", Pretendard, "Malgun Gothic", sans-serif;
  font-variant-numeric: tabular-nums;
}

b,
strong {
  font-weight: 600;
}

.titlebar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px;
  background: var(--titlebar);
  color: var(--titlebar-text);
  border-bottom: 1px solid var(--border-divider);
}

.app-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  background: #ffffff;
  border-radius: 2px;
}

.app-badge svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: var(--titlebar);
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.app-name {
  font-size: 14px;
  font-weight: 600;
}

.app-item {
  color: var(--titlebar-muted);
  padding-left: 8px;
  border-left: 1px solid var(--titlebar-border);
  line-height: 15px;
}

.tb-status {
  margin-left: auto;
  font-weight: 600;
  color: var(--titlebar-success);
}

.tb-status.off {
  color: var(--titlebar-warning);
}

.screen {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  background: var(--border-divider);
  gap: 1px;
}

.main {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 3fr) minmax(0, 2fr);
  gap: 1px;
  background: var(--border-divider);
}

.side {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border-divider);
}

.side .panel:last-child {
  flex: 1;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--bg-surface);
}

.ph {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 6px 0 8px;
  background: var(--bg-structure);
  border-bottom: 1px solid var(--border-divider);
  white-space: nowrap;
}

.ph > b {
  font-size: 14px;
}

.ic {
  flex: none;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 1.2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.ph-sub,
.ph-count {
  color: var(--text-muted);
}

.ph-hint {
  color: var(--text-muted);
  font-size: 12px;
  margin-left: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ph-sep {
  width: 1px;
  height: 15px;
  background: var(--border-divider);
  margin: 0 4px;
}

.ph-end {
  margin-left: auto;
  display: inline-flex;
  gap: 4px;
}

.btn {
  height: 24px;
  padding: 0 8px;
  font: inherit;
  color: var(--text);
  border-radius: 2px;
  cursor: pointer;
  white-space: nowrap;
}

.btn.ghost {
  background: transparent;
  border: 1px solid transparent;
}

.btn.ghost:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.btn.outline {
  background: var(--bg-structure);
  border: 1px solid var(--border-button);
}

.btn.outline:hover {
  background: var(--bg-hover);
  border-color: var(--border-button-hover);
}

.btn.outline[aria-pressed="true"] {
  background: var(--bg-selected);
}

.btn.solid {
  background: var(--bg-accent);
  border: 1px solid var(--border-accent);
  color: #ffffff;
}

.btn.solid:hover {
  background: var(--bg-accent-hover);
}

.btn:active {
  background: var(--bg-pressed);
}

.btn.solid:active {
  background: var(--bg-accent-hover);
}

.btn:focus-visible {
  outline: 1px solid var(--border-focus);
  outline-offset: -2px;
  border-color: var(--border-focus);
}

.toggle {
  display: inline-flex;
}

.toggle .btn {
  border-radius: 0;
}

.toggle .btn + .btn {
  margin-left: -1px;
}

.toggle .btn:first-child {
  border-radius: 2px 0 0 2px;
}

.toggle .btn:last-child {
  border-radius: 0 2px 2px 0;
}

.chart-body {
  flex: 1;
  min-height: 0;
  position: relative;
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.pf {
  flex: none;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 16px;
  min-height: 26px;
  padding: 0 8px;
  background: var(--bg-structure);
  border-top: 1px solid var(--border-divider);
  color: var(--text-muted);
  font-size: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.lg-line {
  width: 16px;
  height: 0;
}

.lg-wave {
  border-top: 2px solid var(--titlebar);
}

.lg-stop {
  border-top: 2px dashed var(--text-warning);
}

.lg-target {
  border-top: 2px dashed var(--text-success);
}

.lg-tri {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
}

.lg-buy {
  border-bottom: 8px solid #de4f4f;
}

.lg-sell {
  border-top: 8px solid #1b8ae6;
}

.lg-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border: 1px solid var(--titlebar);
  border-radius: 50%;
  background: #ffffff;
  color: var(--titlebar);
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  line-height: 1;
}

.lg-num + .lg-num {
  margin-left: -3px;
}

.sheet {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--bg-workspace);
}

.grid {
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-surface);
}

.grid th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 26px;
  padding: 0 6px;
  background: var(--bg-structure);
  border-right: 1px solid var(--border-divider);
  border-bottom: 1px solid var(--border-divider);
  font-weight: 400;
  text-align: left;
  white-space: nowrap;
}

.grid td {
  height: 24px;
  padding: 0 6px;
  border-right: 1px solid var(--border-grid);
  border-bottom: 1px solid var(--border-grid);
  white-space: nowrap;
}

.grid tbody tr:nth-child(even) td {
  background: var(--bg-stripe);
}

.grid tbody tr {
  cursor: default;
}

.grid tbody tr:hover td {
  background: var(--bg-hover);
}

.grid tbody tr.sel td {
  background: var(--bg-selected);
}

.grid .fn {
  width: 18px;
  min-width: 18px;
  padding: 0;
  text-align: center;
  background: var(--bg-structure);
  border-right: 1px solid var(--border-divider);
  border-bottom-color: var(--border-divider);
  color: var(--text-accent);
  font-size: 9px;
}

.grid tbody tr:nth-child(even) td.fn,
.grid tbody tr td.fn {
  background: var(--bg-structure);
}

.grid tbody tr:hover td.fn {
  background: var(--bg-structure-hover);
}

.grid tbody tr.sel td.fn {
  background: var(--bg-structure-selected);
}

.grid .num {
  text-align: right;
}

.grid .wide {
  min-width: 320px;
}

.empty {
  margin: 8px;
  color: var(--text-muted);
}

.t-accent {
  color: var(--text-accent);
  font-weight: 600;
}

.t-success {
  color: var(--text-success);
  font-weight: 600;
}

.t-warning {
  color: var(--text-warning);
  font-weight: 600;
}

.t-danger {
  color: var(--text-danger);
  font-weight: 600;
}

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

.props {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
}

.props .cat {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 6px;
  background: var(--bg-heading);
  border-bottom: 1px solid var(--border-divider);
  font-weight: 600;
}

.props .cat + .k,
.props .cat ~ .cat {
  border-top: 0;
}

.props .k ~ .cat {
  border-top: 1px solid var(--border-divider);
  margin-top: -1px;
}

.props .k,
.props .v {
  height: 24px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-grid);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.props .k {
  background: var(--bg-structure);
  color: var(--text-muted);
  border-right: 1px solid var(--border-grid);
}

.props .v {
  background: var(--bg-surface);
}

.props .v.num {
  justify-content: flex-end;
}

.props .k .rn {
  margin-left: 4px;
  color: var(--text-accent);
}

.props.edit {
  display: block;
}

.props.edit .row {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  border-bottom: 1px solid var(--border-grid);
}

.props.edit label {
  display: flex;
  align-items: center;
  height: 24px;
  padding: 0 6px;
  background: var(--bg-structure);
  color: var(--text-muted);
  border-right: 1px solid var(--border-grid);
}

.props.edit input {
  height: 24px;
  width: 100%;
  margin: 0;
  padding: 0 4px 0 6px;
  font: inherit;
  color: var(--text);
  text-align: right;
  background: #ffffff;
  border: 0;
  border-radius: 0;
  box-shadow: inset 0 0 0 1px var(--border-field);
  outline: none;
}

.props.edit input:hover {
  box-shadow: inset 0 0 0 1px var(--border-field-hover);
}

.props.edit input:focus {
  box-shadow: inset 0 0 0 2px var(--border-focus);
}

.alert {
  flex: none;
  min-height: 28px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  background: var(--bg-danger-subtle);
  color: var(--text-danger);
  font-weight: 600;
  border-bottom: 1px solid var(--border-divider);
}

.alert[hidden] {
  display: none;
}

.rules {
  list-style: none;
  margin: 0;
  padding: 0;
}

.rules li {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  border-bottom: 1px solid var(--border-grid);
  transition: background-color 1.2s ease-out;
}

.rules .rn {
  padding: 4px 6px;
  background: var(--bg-structure);
  border-right: 1px solid var(--border-grid);
  color: var(--text-muted);
  transition: background-color 1.2s ease-out;
}

.rules p {
  margin: 0;
  padding: 4px 8px;
}

.rules p b {
  margin-right: 4px;
}

.rules li.hit {
  background: var(--bg-selected);
  transition: none;
}

.rules li.hit .rn {
  background: var(--bg-structure-selected);
  color: var(--text-accent);
  font-weight: 600;
  transition: none;
}

.statusbar {
  flex: none;
  min-height: 24px;
  display: flex;
  align-items: center;
  padding: 3px 10px;
  background: var(--bg-structure);
  border-top: 1px solid var(--border-divider);
  color: var(--text-muted);
  font-size: 12px;
}

@media (max-width: 900px) {
  body {
    height: auto;
  }

  .screen {
    display: flex;
    flex-direction: column;
  }

  .main {
    display: flex;
    flex-direction: column;
  }

  .chart-body {
    flex: none;
    height: 320px;
  }

  .sheet {
    max-height: 360px;
  }

  .side {
    overflow: visible;
  }

  .ph {
    overflow-x: auto;
  }

  .ph-hint {
    display: none;
  }
}
